mirror of
https://github.com/a2geek/afscanner.git
synced 2025-01-13 23:30:48 +00:00
Working on key handling; added HandleKey for more structured general key handling. Added track movement to count page.
This commit is contained in:
parent
8b3684890a
commit
6f1daaefd9
@ -24,6 +24,8 @@
|
||||
|
||||
XC ; enable 65C02
|
||||
|
||||
use macros
|
||||
|
||||
* Program Locations
|
||||
|
||||
OriginAddress = $2000
|
||||
@ -76,7 +78,7 @@ DATA DA 0 ; data buffer
|
||||
_init da 0 ; current page init
|
||||
_display da 0 ; current page line display handler
|
||||
_keypress da 0 ; current page keypress handler
|
||||
scrolling dfb 0 ; flag for scrolling (in high bit)
|
||||
noscroll dfb 0 ; flag for scrolling (in high bit)
|
||||
topline dw 0 ; current line at top of page
|
||||
maxlines dw 0 ; maximum number of lines available
|
||||
printline dw 0 ; line being printed
|
||||
|
11
macros.s
Normal file
11
macros.s
Normal file
@ -0,0 +1,11 @@
|
||||
******************************************************************************************
|
||||
*
|
||||
* Macros
|
||||
* ========================================================================================
|
||||
*
|
||||
******************************************************************************************
|
||||
|
||||
MenuKey mac
|
||||
dfb ]1
|
||||
da ]2
|
||||
<<<
|
@ -94,5 +94,5 @@ BrowseDisplay ; Called with Acc = line
|
||||
jmp PRCR
|
||||
|
||||
BrowseKeypress ; Called with Acc = key
|
||||
jmp FieldKeypress ; identical to Field ... for now at least
|
||||
jmp TrackNavigationKeys
|
||||
|
||||
|
@ -46,10 +46,10 @@ CountInit ; Returns with A:Y = max lines, C = scrolling
|
||||
|
||||
CountDisplay ; Called with A:Y = line
|
||||
jsr PRINT
|
||||
dfb $8D
|
||||
dfb 14
|
||||
dfb _CLREOL,$8D
|
||||
dfb 14 ; repeat the next space 14x
|
||||
asc " Low +0 +1 +2 +3 +4 +5 +6 +7 High",$8D
|
||||
dfb 19
|
||||
dfb 19 ; repeat the next space 19x
|
||||
asc " ==== ==== ==== ==== ==== ==== ==== ====",$8D
|
||||
dfb 0
|
||||
|
||||
@ -148,7 +148,7 @@ CountKeypress ; Called with Acc = key
|
||||
inx
|
||||
cpx #4
|
||||
bne :test
|
||||
jmp KeyboardWait
|
||||
jmp TrackNavigationKeys
|
||||
:keys asc "-036"
|
||||
|
||||
:set stx CountSettings
|
||||
|
@ -104,6 +104,8 @@ FieldDisplay ; Called with A:Y = line
|
||||
:groups dfb 3,2,2,2,2,3
|
||||
|
||||
FieldKeypress ; Called with Acc = key
|
||||
|
||||
TrackNavigationKeys
|
||||
ldx #-1
|
||||
cmp #LARROW
|
||||
beq :chgtrk
|
||||
|
68
page.s
68
page.s
@ -5,7 +5,6 @@
|
||||
*
|
||||
******************************************************************************************
|
||||
|
||||
|
||||
SetupPage
|
||||
jsr TEXT ; ensure we are out of graphics modes as application has some!
|
||||
jsr PRINT ; position cursor on bottom line
|
||||
@ -15,7 +14,7 @@ SetupPage
|
||||
dfb $00
|
||||
ldx #_init ; vector offset
|
||||
jsr _VCALL
|
||||
ror scrolling ; set flag based on C
|
||||
ror noscroll ; set flag based on C
|
||||
sty maxlines
|
||||
sta maxlines+1
|
||||
stz topline
|
||||
@ -26,7 +25,7 @@ DrawPage
|
||||
dfb _HOME,$8d,$8d,0
|
||||
|
||||
; If we aren't scrolling, call _display vector ONCE and then handle keyboard.
|
||||
bit scrolling
|
||||
bit noscroll
|
||||
bpl :scroll
|
||||
lda #0
|
||||
tay
|
||||
@ -34,6 +33,7 @@ DrawPage
|
||||
jsr _VCALL
|
||||
jmp KeyboardWait
|
||||
|
||||
; We are scrolling, for each line, redraw it
|
||||
:scroll lda #0
|
||||
:loop pha
|
||||
clc
|
||||
@ -62,6 +62,7 @@ DrawPage
|
||||
cmp #PAGELEN
|
||||
blt :loop
|
||||
|
||||
; Handle all keyboard interactions
|
||||
KeyboardWait
|
||||
lda KEYBOARD
|
||||
bpl KeyboardWait
|
||||
@ -73,53 +74,68 @@ KeyboardWait
|
||||
and #$df ; uppercase mask
|
||||
:goodky sta KEYCLEAR
|
||||
bit OpenApple
|
||||
bpl :normal
|
||||
bpl :keys
|
||||
; OpenApple handler
|
||||
jsr SetScreen
|
||||
bcs :paging
|
||||
bcs :oakeys
|
||||
jsr CLRSCRN
|
||||
jmp SetupPage
|
||||
|
||||
; Standard open-apple keys that are always available
|
||||
:oakeys jsr HandleKey
|
||||
MenuKey "Q";:Quit
|
||||
MenuKey "*";:Mon
|
||||
dfb 0
|
||||
|
||||
; Open-Apple arrow keys only if scrolling is enabled
|
||||
bit noscroll
|
||||
bmi :local0
|
||||
jsr HandleKey
|
||||
MenuKey UpArrow;:PgUp
|
||||
MenuKey DownArrow;:PgDn
|
||||
dfb 0
|
||||
:local0 jmp :local
|
||||
|
||||
; Normal key handler (only when scrolling)
|
||||
:keys bit noscroll
|
||||
bmi :local0
|
||||
jsr HandleKey
|
||||
MenuKey UpArrow;:Up
|
||||
MenuKey DownArrow;:Down
|
||||
dfb 0
|
||||
jmp :local
|
||||
|
||||
; OA-Up
|
||||
:paging cmp #UpArrow
|
||||
bne :nPgUp
|
||||
ldy #15
|
||||
:PgUp ldy #15
|
||||
:uploop jsr :up1
|
||||
dey
|
||||
bne :uploop
|
||||
beq :back ; always
|
||||
|
||||
; OA-Down
|
||||
:nPgUp cmp #DownArrow
|
||||
bne :chkOAQ
|
||||
ldy #15
|
||||
:PgDn ldy #15
|
||||
:dnloop jsr :down1
|
||||
dey
|
||||
bne :dnloop
|
||||
beq :back ; always
|
||||
|
||||
; OA-Q
|
||||
:chkOAQ cmp #"Q"
|
||||
bne :chkOA7
|
||||
jsr PRODOSMLI
|
||||
:Quit jsr PRODOSMLI
|
||||
dfb _MLIQUIT
|
||||
da QUITPARM
|
||||
:back jmp DrawPage ; fall through and common return
|
||||
|
||||
; OA-*
|
||||
:chkOA7 cmp #"*"
|
||||
bne :back
|
||||
jsr PRINT
|
||||
:Mon jsr PRINT
|
||||
asc _CLS,"Press CTRL-Y to re-enter AFScanner.",$8D,$00
|
||||
jmp MONITOR
|
||||
|
||||
; Common keypress handler
|
||||
; Up
|
||||
:normal cmp #UpArrow
|
||||
bne :notUp
|
||||
jsr :up1
|
||||
:Up jsr :up1
|
||||
jmp DrawPage
|
||||
|
||||
; Down
|
||||
:notUp cmp #DownArrow
|
||||
bne :pgKey
|
||||
jsr :down1
|
||||
:Down jsr :down1
|
||||
jmp DrawPage
|
||||
|
||||
; "Local" subroutines
|
||||
@ -156,12 +172,12 @@ KeyboardWait
|
||||
sta topline+1
|
||||
:rts rts
|
||||
|
||||
:pgKey ldx #_keypress
|
||||
:local ldx #_keypress
|
||||
; Fall through and JMP to _keypress which takes control for local page keys
|
||||
|
||||
* Simple vector call from ZP based on X register
|
||||
|
||||
_VCALL jmp: ($00,x) ; Merlin32 needs to know 16 bit JMP
|
||||
_VCALL jmp: ($00,x) ; Merlin32 needs to know 16 bit JMP, ":" does that
|
||||
|
||||
* Handle screen change - both called by app init and normal keyboard handler
|
||||
|
||||
|
43
util.s
43
util.s
@ -144,3 +144,46 @@ QUITPARM DFB 4 ; 4 parameters
|
||||
DA 0 ; reserved
|
||||
DFB 0 ; reserved
|
||||
DA 0 ; reserved
|
||||
|
||||
; On entry:
|
||||
; Acc = keypress
|
||||
; Stack = address of table (format: key address key address 0)
|
||||
; Will not return if key found, a JMP will be performed.
|
||||
; If not found, return with carry set.
|
||||
HandleKey
|
||||
sta TEMP
|
||||
pla
|
||||
sta PTR
|
||||
pla
|
||||
sta PTR+1
|
||||
ldy #0
|
||||
:next
|
||||
iny
|
||||
lda (PTR),y
|
||||
bpl :notFound
|
||||
cmp TEMP
|
||||
beq :jmp
|
||||
iny
|
||||
iny
|
||||
bra :next
|
||||
; Jump to keypress handler
|
||||
:jmp iny
|
||||
lda (PTR),y
|
||||
sta PTR2
|
||||
iny
|
||||
lda (PTR),y
|
||||
sta PTR2+1
|
||||
jmp (PTR2)
|
||||
; Not found - return to caller (Y + PTR = return address - 1)
|
||||
:notFound
|
||||
clc
|
||||
tya
|
||||
adc PTR
|
||||
tax
|
||||
lda #0
|
||||
adc PTR+1
|
||||
pha
|
||||
phx
|
||||
lda TEMP
|
||||
sec
|
||||
rts
|
||||
|
Loading…
x
Reference in New Issue
Block a user