cgetc export data now
This commit is contained in:
@@ -5,24 +5,38 @@
|
|||||||
|
|
||||||
.import cursor
|
.import cursor
|
||||||
|
|
||||||
|
.export store_char
|
||||||
|
|
||||||
.include "telestrat.inc"
|
.include "telestrat.inc"
|
||||||
|
|
||||||
.proc _cgetc
|
.proc _cgetc
|
||||||
; this routine could be quicker if we wrote in page 2 variables,
|
; 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
|
; 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
|
ldx cursor ; If cursor equal to 0, then switch off cursor
|
||||||
beq switchoff_cursor
|
beq switchoff_cursor
|
||||||
|
|
||||||
ldx #$00 ; x is the first screen
|
ldx #$00 ; x is the first screen
|
||||||
BRK_TELEMON(XCSSCR) ; display cursor
|
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
|
jmp start ; Could be replaced by a bne/beq but 'jmp' is cleaner than a bne/beq which could expect some matters
|
||||||
|
|
||||||
switchoff_cursor:
|
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)
|
; 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
|
BRK_TELEMON(XCOSCR) ; Switch off cursor
|
||||||
|
|
||||||
loop:
|
|
||||||
BRK_TELEMON XRD0 ; waits until key is pressed
|
start:
|
||||||
bcs loop
|
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
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
.data
|
||||||
|
store_char:
|
||||||
|
.byte 0
|
||||||
|
|||||||
@@ -6,12 +6,24 @@
|
|||||||
|
|
||||||
.export _kbhit
|
.export _kbhit
|
||||||
|
|
||||||
|
.import store_char
|
||||||
|
|
||||||
.include "telestrat.inc"
|
.include "telestrat.inc"
|
||||||
|
|
||||||
_kbhit:
|
_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
|
ldx #$00
|
||||||
txa
|
rts
|
||||||
rol
|
@call_telemon:
|
||||||
eor #$01
|
BRK_TELEMON XRD0
|
||||||
|
|
||||||
|
ldx #$00
|
||||||
|
bcs @no_char_action
|
||||||
|
sta store_char
|
||||||
|
lda #$01
|
||||||
|
rts
|
||||||
|
@no_char_action:
|
||||||
|
tax
|
||||||
rts
|
rts
|
||||||
|
|||||||
Reference in New Issue
Block a user