Move the conio initialization routines where they belong (cgetc), make them
module constructors/destructors and remove the conio init functions that were called from the startup code. git-svn-id: svn://svn.cc65.org/cc65/trunk@479 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -10,6 +10,8 @@
|
|||||||
.include "plus4.inc"
|
.include "plus4.inc"
|
||||||
|
|
||||||
|
|
||||||
|
; --------------------------------------------------------------------------
|
||||||
|
|
||||||
_cgetc: lda KEY_COUNT ; Get number of characters
|
_cgetc: lda KEY_COUNT ; Get number of characters
|
||||||
ora FKEY_COUNT ; Or with number of function key chars
|
ora FKEY_COUNT ; Or with number of function key chars
|
||||||
bne L2 ; Jump if there are already chars waiting
|
bne L2 ; Jump if there are already chars waiting
|
||||||
@@ -46,3 +48,41 @@ L2: jsr KBDREAD ; Read char and return in A
|
|||||||
ldx #0
|
ldx #0
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
; --------------------------------------------------------------------------
|
||||||
|
; Make the function keys return function key codes instead of the current
|
||||||
|
; strings so the program will see and may handle them.
|
||||||
|
; Undo this change when the program ends
|
||||||
|
|
||||||
|
.constructor initkbd
|
||||||
|
.destructor donekbd
|
||||||
|
|
||||||
|
.proc initkbd
|
||||||
|
|
||||||
|
ldy #15
|
||||||
|
@L1: lda fnkeys,y
|
||||||
|
sta FKEY_SPACE,y
|
||||||
|
dey
|
||||||
|
bpl @L1
|
||||||
|
rts
|
||||||
|
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
|
.proc donekbd
|
||||||
|
|
||||||
|
ldx #$39 ; Copy the original function keys
|
||||||
|
@L1: lda FKEY_ORIG,x
|
||||||
|
sta FKEY_SPACE,x
|
||||||
|
dex
|
||||||
|
bpl @L1
|
||||||
|
rts
|
||||||
|
|
||||||
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
|
; Function key table, readonly
|
||||||
|
|
||||||
|
.rodata
|
||||||
|
fnkeys: .byte $01, $01, $01, $01, $01, $01, $01, $01
|
||||||
|
.byte 133, 137, 134, 138, 135, 139, 136, 140
|
||||||
|
|
||||||
|
|||||||
@@ -4,35 +4,7 @@
|
|||||||
; Low level stuff for screen output/console input
|
; Low level stuff for screen output/console input
|
||||||
;
|
;
|
||||||
|
|
||||||
.export initconio, doneconio
|
|
||||||
.exportzp CURS_X, CURS_Y
|
.exportzp CURS_X, CURS_Y
|
||||||
.import xsize, ysize
|
|
||||||
|
|
||||||
.include "plus4.inc"
|
.include "plus4.inc"
|
||||||
.include "../cbm/cbm.inc"
|
|
||||||
|
|
||||||
.code
|
|
||||||
|
|
||||||
initconio:
|
|
||||||
ldy #15
|
|
||||||
L1: lda fnkeys,y
|
|
||||||
sta FKEY_SPACE,y
|
|
||||||
dey
|
|
||||||
bpl L1
|
|
||||||
rts
|
|
||||||
|
|
||||||
|
|
||||||
doneconio:
|
|
||||||
ldx #$39 ; Copy the original function keys
|
|
||||||
L2: lda FKEY_ORIG,x
|
|
||||||
sta FKEY_SPACE,x
|
|
||||||
dex
|
|
||||||
bpl L2
|
|
||||||
rts
|
|
||||||
|
|
||||||
; Function key table, readonly
|
|
||||||
|
|
||||||
.rodata
|
|
||||||
fnkeys: .byte $01, $01, $01, $01, $01, $01, $01, $01
|
|
||||||
.byte 133, 137, 134, 138, 135, 139, 136, 140
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,7 @@
|
|||||||
|
|
||||||
.export _exit
|
.export _exit
|
||||||
.import initlib, donelib
|
.import initlib, donelib
|
||||||
.import push0, _main
|
.import push0, _main, zerobss
|
||||||
.import initconio, doneconio, zerobss
|
|
||||||
|
|
||||||
.include "plus4.inc"
|
.include "plus4.inc"
|
||||||
.include "../cbm/cbm.inc"
|
.include "../cbm/cbm.inc"
|
||||||
@@ -92,10 +91,6 @@ MemOk: stx sp
|
|||||||
|
|
||||||
jsr initlib
|
jsr initlib
|
||||||
|
|
||||||
; Initialize conio stuff
|
|
||||||
|
|
||||||
jsr initconio
|
|
||||||
|
|
||||||
; Pass an empty command line
|
; Pass an empty command line
|
||||||
|
|
||||||
jsr push0 ; argc
|
jsr push0 ; argc
|
||||||
@@ -113,10 +108,6 @@ _exit: jsr donelib ; Run module destructors
|
|||||||
ldx spsave
|
ldx spsave
|
||||||
txs
|
txs
|
||||||
|
|
||||||
; Reset the conio stuff
|
|
||||||
|
|
||||||
jsr doneconio
|
|
||||||
|
|
||||||
; Copy back the zero page stuff
|
; Copy back the zero page stuff
|
||||||
|
|
||||||
ldx #zpspace-1
|
ldx #zpspace-1
|
||||||
|
|||||||
Reference in New Issue
Block a user