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
114
afscanner.s
114
afscanner.s
|
@ -12,17 +12,19 @@
|
||||||
* - Split source into multiple files as one file finally got way too big.
|
* - Split source into multiple files as one file finally got way too big.
|
||||||
* - Slowly switching from spaces to tabs as an experiment in code formatting.
|
* - Slowly switching from spaces to tabs as an experiment in code formatting.
|
||||||
* - Pages available:
|
* - Pages available:
|
||||||
* + About (default page)
|
* + About (default page)
|
||||||
* + Headers (updated Address Field Header information)
|
* + Headers (updated Address Field Header information)
|
||||||
* + Browse track buffer (hilights Address Field Header bytes)
|
* + Browse track buffer (hilights Address Field Header bytes)
|
||||||
* + Graphical disk display
|
* + Graphical disk display
|
||||||
* + Buffer counts
|
* + Buffer counts
|
||||||
*
|
*
|
||||||
******************************************************************************************
|
******************************************************************************************
|
||||||
|
|
||||||
TYP SYS
|
TYP SYS
|
||||||
|
|
||||||
XC ; enable 65C02
|
XC ; enable 65C02
|
||||||
|
|
||||||
|
use macros
|
||||||
|
|
||||||
* Program Locations
|
* Program Locations
|
||||||
|
|
||||||
|
@ -32,51 +34,51 @@ ProgramLength = ProgramEnd-ProgramAddress
|
||||||
|
|
||||||
* Constants:
|
* Constants:
|
||||||
|
|
||||||
NUMBYTES = 29 ; Number of bytes on screen
|
NUMBYTES = 29 ; Number of bytes on screen
|
||||||
OFFSETV = 3 ; Offset to volume
|
OFFSETV = 3 ; Offset to volume
|
||||||
OFFSETT = OFFSETV+2 ; Offset to track
|
OFFSETT = OFFSETV+2 ; Offset to track
|
||||||
OFFSETS = OFFSETT+2 ; Offset to sector
|
OFFSETS = OFFSETT+2 ; Offset to sector
|
||||||
OFFSETC = OFFSETS+2 ; Offset to checksum
|
OFFSETC = OFFSETS+2 ; Offset to checksum
|
||||||
FAILBYTS = 6656 ; Number of bytes before failure
|
FAILBYTS = 6656 ; Number of bytes before failure
|
||||||
|
|
||||||
* 80 column card / print controls:
|
* 80 column card / print controls:
|
||||||
|
|
||||||
_PRBYTE = 1 ; print byte @ addr
|
_PRBYTE = 1 ; print byte @ addr
|
||||||
_CLS = $8C ; clear screen
|
_CLS = $8C ; clear screen
|
||||||
_INVERSE = $8F
|
_INVERSE = $8F
|
||||||
_NORMAL = $8E
|
_NORMAL = $8E
|
||||||
_MT_OFF = $98 ; disable MouseText
|
_MT_OFF = $98 ; disable MouseText
|
||||||
_HOME = $99 ; home the cursor, not cls
|
_HOME = $99 ; home the cursor, not cls
|
||||||
_MT_ON = $9B ; enable MouseText for uppercase inverse characters
|
_MT_ON = $9B ; enable MouseText for uppercase inverse characters
|
||||||
_CLREOL = $9D ; clear to EOL
|
_CLREOL = $9D ; clear to EOL
|
||||||
|
|
||||||
_C_APPLE = "@" ; Closed Apple
|
_C_APPLE = "@" ; Closed Apple
|
||||||
_O_APPLE = "A" ; Open Apple
|
_O_APPLE = "A" ; Open Apple
|
||||||
_L_ARROW = "H" ; Left Arrow
|
_L_ARROW = "H" ; Left Arrow
|
||||||
_R_ARROW = "U" ; Right Arrow
|
_R_ARROW = "U" ; Right Arrow
|
||||||
_U_ARROW = "K" ; Up Arrow
|
_U_ARROW = "K" ; Up Arrow
|
||||||
_D_ARROW = "J" ; Down Arrow
|
_D_ARROW = "J" ; Down Arrow
|
||||||
_H_LINE = "S" ; Horizontal Line (full width)
|
_H_LINE = "S" ; Horizontal Line (full width)
|
||||||
|
|
||||||
|
|
||||||
* Variable locations:
|
* Variable locations:
|
||||||
|
|
||||||
DUM $0 ; ZP locs
|
DUM $0 ; ZP locs
|
||||||
SAMPLES DFB 0 ; number of sector samples
|
SAMPLES DFB 0 ; number of sector samples
|
||||||
CURTRK DFB 0 ; current track
|
CURTRK DFB 0 ; current track
|
||||||
DSTTRK DFB 0 ; destination track
|
DSTTRK DFB 0 ; destination track
|
||||||
PTR DA 0 ; primary print pointer
|
PTR DA 0 ; primary print pointer
|
||||||
PTR2 DA 0 ; secondary print pointer
|
PTR2 DA 0 ; secondary print pointer
|
||||||
SLOT16 DFB 0 ; slot# * 16
|
SLOT16 DFB 0 ; slot# * 16
|
||||||
COUNTER DA 0 ; fail counter
|
COUNTER DA 0 ; fail counter
|
||||||
TEMP DFB 0 ; local variable
|
TEMP DFB 0 ; local variable
|
||||||
TEMPY DFB 0 ; local Y coordinate
|
TEMPY DFB 0 ; local Y coordinate
|
||||||
DATA DA 0 ; data buffer
|
DATA DA 0 ; data buffer
|
||||||
|
|
||||||
_init da 0 ; current page init
|
_init da 0 ; current page init
|
||||||
_display da 0 ; current page line display handler
|
_display da 0 ; current page line display handler
|
||||||
_keypress da 0 ; current page keypress 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
|
topline dw 0 ; current line at top of page
|
||||||
maxlines dw 0 ; maximum number of lines available
|
maxlines dw 0 ; maximum number of lines available
|
||||||
printline dw 0 ; line being printed
|
printline dw 0 ; line being printed
|
||||||
|
@ -84,9 +86,9 @@ printline dw 0 ; line being printed
|
||||||
|
|
||||||
inbuf = $200 ; reusable buffer
|
inbuf = $200 ; reusable buffer
|
||||||
|
|
||||||
DATASTART = $4000
|
DATASTART = $4000
|
||||||
DATAEND = $6000
|
DATAEND = $6000
|
||||||
DATALEN = DATAEND-DATASTART
|
DATALEN = DATAEND-DATASTART
|
||||||
|
|
||||||
PAGELEN = 20 ; number of lines displayed in content window
|
PAGELEN = 20 ; number of lines displayed in content window
|
||||||
|
|
||||||
|
@ -104,8 +106,8 @@ DownArrow = CTRLJ
|
||||||
|
|
||||||
* ProDOS:
|
* ProDOS:
|
||||||
|
|
||||||
PRODOSMLI = $BF00
|
PRODOSMLI = $BF00
|
||||||
_MLIQUIT = $65
|
_MLIQUIT = $65
|
||||||
|
|
||||||
* ROM routines and associated addresses:
|
* ROM routines and associated addresses:
|
||||||
|
|
||||||
|
@ -115,7 +117,7 @@ HPOSN = $F411
|
||||||
HBAS = $26
|
HBAS = $26
|
||||||
|
|
||||||
DELAY = $FCA8
|
DELAY = $FCA8
|
||||||
GETCH = $FD0C
|
GETCH = $FD0C
|
||||||
PRCR = $FD8E
|
PRCR = $FD8E
|
||||||
PRHEX = $FDDA
|
PRHEX = $FDDA
|
||||||
COUT = $FDED
|
COUT = $FDED
|
||||||
|
@ -140,7 +142,7 @@ OpenApple = $C061
|
||||||
sta PTR2+1
|
sta PTR2+1
|
||||||
stz PTR2
|
stz PTR2
|
||||||
ldy #0
|
ldy #0
|
||||||
ldx #>ProgramLength+255 ; account for non-zero low byte
|
ldx #>ProgramLength+255 ; account for non-zero low byte
|
||||||
:0 lda (PTR),y
|
:0 lda (PTR),y
|
||||||
sta (PTR2),y
|
sta (PTR2),y
|
||||||
iny
|
iny
|
||||||
|
@ -163,21 +165,21 @@ MAIN lda #$4C ; JMP
|
||||||
lda #>ProgramAddress
|
lda #>ProgramAddress
|
||||||
sta USRADR+2
|
sta USRADR+2
|
||||||
|
|
||||||
JSR $C300 ; Assuming 80 columns
|
JSR $C300 ; Assuming 80 columns
|
||||||
JSR PRINT
|
JSR PRINT
|
||||||
DFB _CLS
|
DFB _CLS
|
||||||
ASC "AFScanner",$8D
|
ASC "AFScanner",$8D
|
||||||
DFB _MT_ON,_INVERSE,80,_H_LINE,_NORMAL,_MT_OFF ; wraps!
|
DFB _MT_ON,_INVERSE,80,_H_LINE,_NORMAL,_MT_OFF ; wraps!
|
||||||
DFB 20,$8D
|
DFB 20,$8D
|
||||||
DFB _MT_ON,_INVERSE,80,_H_LINE,_NORMAL,_MT_OFF ; wraps!
|
DFB _MT_ON,_INVERSE,80,_H_LINE,_NORMAL,_MT_OFF ; wraps!
|
||||||
ASC _MT_ON,_INVERSE,_L_ARROW,_NORMAL,", ",_INVERSE,_R_ARROW,_NORMAL,_MT_OFF," Track / "
|
ASC _MT_ON,_INVERSE,_L_ARROW,_NORMAL,", ",_INVERSE,_R_ARROW,_NORMAL,_MT_OFF," Track / "
|
||||||
ASC "re",_INVERSE,"S",_NORMAL,"can / "
|
ASC "re",_INVERSE,"S",_NORMAL,"can / "
|
||||||
ASC _INVERSE,"R",_NORMAL,"ecalibrate / "
|
ASC _INVERSE,"R",_NORMAL,"ecalibrate / "
|
||||||
ASC "goto ",_INVERSE,"T",_NORMAL,"rack / "
|
ASC "goto ",_INVERSE,"T",_NORMAL,"rack / "
|
||||||
ASC _INVERSE,"ESC",_NORMAL," quit"
|
ASC _INVERSE,"ESC",_NORMAL," quit"
|
||||||
DFB _HOME
|
DFB _HOME
|
||||||
HEX 8D8D
|
HEX 8D8D
|
||||||
HEX 00
|
HEX 00
|
||||||
|
|
||||||
* Setup local variables
|
* Setup local variables
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
******************************************************************************************
|
||||||
|
*
|
||||||
|
* Macros
|
||||||
|
* ========================================================================================
|
||||||
|
*
|
||||||
|
******************************************************************************************
|
||||||
|
|
||||||
|
MenuKey mac
|
||||||
|
dfb ]1
|
||||||
|
da ]2
|
||||||
|
<<<
|
|
@ -94,5 +94,5 @@ BrowseDisplay ; Called with Acc = line
|
||||||
jmp PRCR
|
jmp PRCR
|
||||||
|
|
||||||
BrowseKeypress ; Called with Acc = key
|
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
|
CountDisplay ; Called with A:Y = line
|
||||||
jsr PRINT
|
jsr PRINT
|
||||||
dfb $8D
|
dfb _CLREOL,$8D
|
||||||
dfb 14
|
dfb 14 ; repeat the next space 14x
|
||||||
asc " Low +0 +1 +2 +3 +4 +5 +6 +7 High",$8D
|
asc " Low +0 +1 +2 +3 +4 +5 +6 +7 High",$8D
|
||||||
dfb 19
|
dfb 19 ; repeat the next space 19x
|
||||||
asc " ==== ==== ==== ==== ==== ==== ==== ====",$8D
|
asc " ==== ==== ==== ==== ==== ==== ==== ====",$8D
|
||||||
dfb 0
|
dfb 0
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ CountKeypress ; Called with Acc = key
|
||||||
inx
|
inx
|
||||||
cpx #4
|
cpx #4
|
||||||
bne :test
|
bne :test
|
||||||
jmp KeyboardWait
|
jmp TrackNavigationKeys
|
||||||
:keys asc "-036"
|
:keys asc "-036"
|
||||||
|
|
||||||
:set stx CountSettings
|
:set stx CountSettings
|
||||||
|
|
|
@ -104,6 +104,8 @@ FieldDisplay ; Called with A:Y = line
|
||||||
:groups dfb 3,2,2,2,2,3
|
:groups dfb 3,2,2,2,2,3
|
||||||
|
|
||||||
FieldKeypress ; Called with Acc = key
|
FieldKeypress ; Called with Acc = key
|
||||||
|
|
||||||
|
TrackNavigationKeys
|
||||||
ldx #-1
|
ldx #-1
|
||||||
cmp #LARROW
|
cmp #LARROW
|
||||||
beq :chgtrk
|
beq :chgtrk
|
||||||
|
|
70
page.s
70
page.s
|
@ -5,7 +5,6 @@
|
||||||
*
|
*
|
||||||
******************************************************************************************
|
******************************************************************************************
|
||||||
|
|
||||||
|
|
||||||
SetupPage
|
SetupPage
|
||||||
jsr TEXT ; ensure we are out of graphics modes as application has some!
|
jsr TEXT ; ensure we are out of graphics modes as application has some!
|
||||||
jsr PRINT ; position cursor on bottom line
|
jsr PRINT ; position cursor on bottom line
|
||||||
|
@ -15,7 +14,7 @@ SetupPage
|
||||||
dfb $00
|
dfb $00
|
||||||
ldx #_init ; vector offset
|
ldx #_init ; vector offset
|
||||||
jsr _VCALL
|
jsr _VCALL
|
||||||
ror scrolling ; set flag based on C
|
ror noscroll ; set flag based on C
|
||||||
sty maxlines
|
sty maxlines
|
||||||
sta maxlines+1
|
sta maxlines+1
|
||||||
stz topline
|
stz topline
|
||||||
|
@ -26,7 +25,7 @@ DrawPage
|
||||||
dfb _HOME,$8d,$8d,0
|
dfb _HOME,$8d,$8d,0
|
||||||
|
|
||||||
; If we aren't scrolling, call _display vector ONCE and then handle keyboard.
|
; If we aren't scrolling, call _display vector ONCE and then handle keyboard.
|
||||||
bit scrolling
|
bit noscroll
|
||||||
bpl :scroll
|
bpl :scroll
|
||||||
lda #0
|
lda #0
|
||||||
tay
|
tay
|
||||||
|
@ -34,6 +33,7 @@ DrawPage
|
||||||
jsr _VCALL
|
jsr _VCALL
|
||||||
jmp KeyboardWait
|
jmp KeyboardWait
|
||||||
|
|
||||||
|
; We are scrolling, for each line, redraw it
|
||||||
:scroll lda #0
|
:scroll lda #0
|
||||||
:loop pha
|
:loop pha
|
||||||
clc
|
clc
|
||||||
|
@ -47,7 +47,7 @@ DrawPage
|
||||||
lda printline
|
lda printline
|
||||||
cmp maxlines
|
cmp maxlines
|
||||||
bge :erase
|
bge :erase
|
||||||
|
|
||||||
:drwlin lda printline+1
|
:drwlin lda printline+1
|
||||||
ldy printline
|
ldy printline
|
||||||
ldx #_display
|
ldx #_display
|
||||||
|
@ -62,6 +62,7 @@ DrawPage
|
||||||
cmp #PAGELEN
|
cmp #PAGELEN
|
||||||
blt :loop
|
blt :loop
|
||||||
|
|
||||||
|
; Handle all keyboard interactions
|
||||||
KeyboardWait
|
KeyboardWait
|
||||||
lda KEYBOARD
|
lda KEYBOARD
|
||||||
bpl KeyboardWait
|
bpl KeyboardWait
|
||||||
|
@ -73,53 +74,68 @@ KeyboardWait
|
||||||
and #$df ; uppercase mask
|
and #$df ; uppercase mask
|
||||||
:goodky sta KEYCLEAR
|
:goodky sta KEYCLEAR
|
||||||
bit OpenApple
|
bit OpenApple
|
||||||
bpl :normal
|
bpl :keys
|
||||||
; OpenApple handler
|
; OpenApple handler
|
||||||
jsr SetScreen
|
jsr SetScreen
|
||||||
bcs :paging
|
bcs :oakeys
|
||||||
jsr CLRSCRN
|
jsr CLRSCRN
|
||||||
jmp SetupPage
|
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
|
; OA-Up
|
||||||
:paging cmp #UpArrow
|
:PgUp ldy #15
|
||||||
bne :nPgUp
|
|
||||||
ldy #15
|
|
||||||
:uploop jsr :up1
|
:uploop jsr :up1
|
||||||
dey
|
dey
|
||||||
bne :uploop
|
bne :uploop
|
||||||
beq :back ; always
|
beq :back ; always
|
||||||
|
|
||||||
; OA-Down
|
; OA-Down
|
||||||
:nPgUp cmp #DownArrow
|
:PgDn ldy #15
|
||||||
bne :chkOAQ
|
|
||||||
ldy #15
|
|
||||||
:dnloop jsr :down1
|
:dnloop jsr :down1
|
||||||
dey
|
dey
|
||||||
bne :dnloop
|
bne :dnloop
|
||||||
beq :back ; always
|
beq :back ; always
|
||||||
|
|
||||||
; OA-Q
|
; OA-Q
|
||||||
:chkOAQ cmp #"Q"
|
:Quit jsr PRODOSMLI
|
||||||
bne :chkOA7
|
|
||||||
jsr PRODOSMLI
|
|
||||||
dfb _MLIQUIT
|
dfb _MLIQUIT
|
||||||
da QUITPARM
|
da QUITPARM
|
||||||
:back jmp DrawPage ; fall through and common return
|
:back jmp DrawPage ; fall through and common return
|
||||||
|
|
||||||
; OA-*
|
; OA-*
|
||||||
:chkOA7 cmp #"*"
|
:Mon jsr PRINT
|
||||||
bne :back
|
|
||||||
jsr PRINT
|
|
||||||
asc _CLS,"Press CTRL-Y to re-enter AFScanner.",$8D,$00
|
asc _CLS,"Press CTRL-Y to re-enter AFScanner.",$8D,$00
|
||||||
jmp MONITOR
|
jmp MONITOR
|
||||||
|
|
||||||
; Common keypress handler
|
|
||||||
; Up
|
; Up
|
||||||
:normal cmp #UpArrow
|
:Up jsr :up1
|
||||||
bne :notUp
|
|
||||||
jsr :up1
|
|
||||||
jmp DrawPage
|
jmp DrawPage
|
||||||
|
|
||||||
; Down
|
; Down
|
||||||
:notUp cmp #DownArrow
|
:Down jsr :down1
|
||||||
bne :pgKey
|
|
||||||
jsr :down1
|
|
||||||
jmp DrawPage
|
jmp DrawPage
|
||||||
|
|
||||||
; "Local" subroutines
|
; "Local" subroutines
|
||||||
|
@ -156,12 +172,12 @@ KeyboardWait
|
||||||
sta topline+1
|
sta topline+1
|
||||||
:rts rts
|
:rts rts
|
||||||
|
|
||||||
:pgKey ldx #_keypress
|
:local ldx #_keypress
|
||||||
; Fall through and JMP to _keypress which takes control for local page keys
|
; Fall through and JMP to _keypress which takes control for local page keys
|
||||||
|
|
||||||
* Simple vector call from ZP based on X register
|
* 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
|
* 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
|
DA 0 ; reserved
|
||||||
DFB 0 ; reserved
|
DFB 0 ; reserved
|
||||||
DA 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…
Reference in New Issue