From e9597e872101604e382468235cdba69a1ab8bf6b Mon Sep 17 00:00:00 2001 From: jede Date: Tue, 26 Apr 2022 00:40:16 +0200 Subject: [PATCH 1/4] cgetc export data now --- libsrc/telestrat/cgetc.s | 34 ++++++++++++++++++++++++---------- libsrc/telestrat/kbhit.s | 20 ++++++++++++++++---- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/libsrc/telestrat/cgetc.s b/libsrc/telestrat/cgetc.s index cad8814af..e77ed794b 100644 --- a/libsrc/telestrat/cgetc.s +++ b/libsrc/telestrat/cgetc.s @@ -5,24 +5,38 @@ .import cursor + .export store_char + .include "telestrat.inc" .proc _cgetc - ; this routine could be quicker if we wrote in page 2 variables, - ; but it's better to use telemon routine in that case, because telemon can manage 4 I/O - ldx cursor ; if cursor equal to 0, then switch off cursor + ; This routine could be quicker if we wrote in page 2 variables, + ; But it's better to use telemon routine in that case, because telemon can manage 4 I/O + ldx cursor ; If cursor equal to 0, then switch off cursor beq switchoff_cursor ldx #$00 ; x is the first screen - BRK_TELEMON(XCSSCR) ; display cursor - jmp loop ; could be replaced by a bne/beq but 'jmp' is cleaner than a bne/beq which could expect some matters + BRK_TELEMON(XCSSCR) ; Display cursor + jmp start ; Could be replaced by a bne/beq but 'jmp' is cleaner than a bne/beq which could expect some matters switchoff_cursor: - ; at this step X is equal to $00, X must be set, because it's the id of the screen (telestrat can handle 4 virtuals screen) - BRK_TELEMON(XCOSCR) ; switch off cursor + ; At this step X is equal to $00, X must be set, because it's the id of the screen (telestrat can handle 4 virtuals screen) + BRK_TELEMON(XCOSCR) ; Switch off cursor -loop: - BRK_TELEMON XRD0 ; waits until key is pressed - bcs loop + +start: + lda store_char ; Does kbhit store a value in store_char ? + bne @out ; Yes, we returns A and we reset store_char +@wait_key: + BRK_TELEMON XRD0 ; Waits until key is pressed + bcs @wait_key + ldx #$00 + rts +@out: + ldx #$00 + stx store_char rts .endproc +.data +store_char: + .byte 0 diff --git a/libsrc/telestrat/kbhit.s b/libsrc/telestrat/kbhit.s index 54e4bf4d8..da2c8b587 100644 --- a/libsrc/telestrat/kbhit.s +++ b/libsrc/telestrat/kbhit.s @@ -6,12 +6,24 @@ .export _kbhit + .import store_char + .include "telestrat.inc" _kbhit: - BRK_TELEMON XRD0 + lda store_char ; Check if a key has been detected previously + beq @call_telemon ; No, calls Telemon routine + lda #$01 ; There is a key pressed previously, return 1 ldx #$00 - txa - rol - eor #$01 + rts +@call_telemon: + BRK_TELEMON XRD0 + + ldx #$00 + bcs @no_char_action + sta store_char + lda #$01 + rts +@no_char_action: + tax rts From 1281032f33125c541ff5aac0906fd97a390890b7 Mon Sep 17 00:00:00 2001 From: jede Date: Tue, 26 Apr 2022 10:23:38 +0200 Subject: [PATCH 2/4] FIX space --- libsrc/telestrat/kbhit.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/telestrat/kbhit.s b/libsrc/telestrat/kbhit.s index da2c8b587..9af696e24 100644 --- a/libsrc/telestrat/kbhit.s +++ b/libsrc/telestrat/kbhit.s @@ -11,7 +11,7 @@ .include "telestrat.inc" _kbhit: - lda store_char ; Check if a key has been detected previously + lda store_char ; Check if a key has been detected previously beq @call_telemon ; No, calls Telemon routine lda #$01 ; There is a key pressed previously, return 1 ldx #$00 From 4474ed2668444238cf06207cb13a06711d11855f Mon Sep 17 00:00:00 2001 From: jede Date: Tue, 26 Apr 2022 11:10:07 +0200 Subject: [PATCH 3/4] fix space --- libsrc/telestrat/kbhit.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/telestrat/kbhit.s b/libsrc/telestrat/kbhit.s index 9af696e24..aea345036 100644 --- a/libsrc/telestrat/kbhit.s +++ b/libsrc/telestrat/kbhit.s @@ -16,7 +16,7 @@ _kbhit: lda #$01 ; There is a key pressed previously, return 1 ldx #$00 rts -@call_telemon: +@call_telemon: BRK_TELEMON XRD0 ldx #$00 From 4bfd57153f4b9733bec6684d2a25af60cb277df5 Mon Sep 17 00:00:00 2001 From: jede Date: Tue, 26 Apr 2022 14:14:27 +0200 Subject: [PATCH 4/4] fix bss --- libsrc/telestrat/cgetc.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/telestrat/cgetc.s b/libsrc/telestrat/cgetc.s index e77ed794b..b76c62ee0 100644 --- a/libsrc/telestrat/cgetc.s +++ b/libsrc/telestrat/cgetc.s @@ -37,6 +37,6 @@ start: stx store_char rts .endproc -.data +.bss store_char: .byte 0