From d6f2fda5757ee0786579cd76b6b50f2926e9836e Mon Sep 17 00:00:00 2001
From: Oliver Schmidt
Date: Sat, 6 Mar 2021 11:56:22 +0100
Subject: [PATCH] Revert "revert read.s"
This reverts commit 65d5786da564e3937795361cbdc8e1f48f0b0272.
---
libsrc/telestrat/read.s | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/libsrc/telestrat/read.s b/libsrc/telestrat/read.s
index 76de9d0ac..0782c4d21 100644
--- a/libsrc/telestrat/read.s
+++ b/libsrc/telestrat/read.s
@@ -8,21 +8,33 @@
.include "zeropage.inc"
.include "telestrat.inc"
+ .include "fcntl.inc"
;int read (int fd, void* buf, unsigned count);
.proc _read
- sta ptr1 ; count
- stx ptr1+1 ; count
- jsr popax ; get buf
+ sta ptr1 ; count
+ stx ptr1+1 ; count
+ jsr popax ; get buf
sta PTR_READ_DEST
stx PTR_READ_DEST+1
- sta ptr2 ; in order to calculate nb of bytes read
+ sta ptr2 ; in order to calculate nb of bytes read
stx ptr2+1 ;
- ; jsr popax ; fp pointer don't care in this version
+ jsr popax ; fp pointer don't care in this version
+ cpx #$00
+ bne @is_not_stdin
+ cmp #STDIN_FILENO
+ bne @is_not_stdin
+ ; stdin
+@L1:
+ BRK_TELEMON XRD0 ; waits until key is pressed
+ bcs @L1
+
+ rts
+@is_not_stdin:
lda ptr1 ;
ldy ptr1+1 ;
BRK_TELEMON XFREAD ; calls telemon30 routine