mirror of
https://github.com/a2-4am/4cade.git
synced 2024-12-21 02:30:27 +00:00
shave some bytes
This commit is contained in:
parent
5faffbd825
commit
99b1de5380
@ -25,50 +25,17 @@ BrowseMode
|
||||
|
||||
.BrowseModeInputLoop
|
||||
jsr WaitForKeyFor30Seconds
|
||||
bit CLEARKBD
|
||||
jsr ResetInputTimeout
|
||||
|
||||
cmp #$88 ; left arrow = previous
|
||||
bne +
|
||||
- ldx #kBrowsePrevious
|
||||
ldy #kNumBrowseKeys
|
||||
- dey
|
||||
bmi @noKeyMatch
|
||||
cmp .BrowseKeys,y
|
||||
bne -
|
||||
ldx .BrowseKeyDispatch,y
|
||||
bne @BrowseDispatch ; always branches
|
||||
+ cmp #$8B ; up arrow is same as left arrow
|
||||
beq -
|
||||
|
||||
cmp #$95 ; right arrow = next
|
||||
bne +
|
||||
- ldx #kBrowseNext
|
||||
bne @BrowseDispatch ; always branches
|
||||
+ cmp #$8A ; down arrow is same as right arrow
|
||||
beq -
|
||||
|
||||
cmp #$9B ; Esc switches to search mode
|
||||
bne +
|
||||
ldx #kBrowseExitToSearch
|
||||
bne @BrowseDispatch ; always branches
|
||||
+
|
||||
cmp #$8D ; ENTER launches the current game
|
||||
bne +
|
||||
ldx #kBrowseLaunch
|
||||
bne @BrowseDispatch ; always branches
|
||||
+
|
||||
cmp #$89 ; TAB switches to mini attract mode
|
||||
bne + ; temporarily
|
||||
- ldx #kBrowseTab
|
||||
bne @BrowseDispatch ; always branches
|
||||
+
|
||||
cmp #$A0 ; SPACE = TAB because ][+ doesn't have TAB
|
||||
beq -
|
||||
|
||||
cmp #$BF ; '?' display scredits
|
||||
bne +
|
||||
- ldx #kBrowseCredits
|
||||
bne @BrowseDispatch ; always branches
|
||||
+
|
||||
cmp #$AF ; '/' also displays credits
|
||||
beq -
|
||||
|
||||
and #$7F ; strip high bit for search characters
|
||||
@noKeyMatch
|
||||
jsr IsSearchKey
|
||||
beq +
|
||||
jsr SoftBell ; beep on invalid input
|
||||
@ -77,15 +44,10 @@ BrowseMode
|
||||
ldx #kBrowseSearch
|
||||
; execution falls through here
|
||||
@BrowseDispatch
|
||||
pha ; save key pressed
|
||||
txa
|
||||
asl
|
||||
tax
|
||||
lda .BrowseDispatchTable,x
|
||||
sta @j+1
|
||||
lda .BrowseDispatchTable+1,x
|
||||
sta @j+2
|
||||
pla ; restore key pressed
|
||||
ldy .BrowseDispatchTableLo,x
|
||||
sty @j+1
|
||||
ldy .BrowseDispatchTableHi,x
|
||||
sty @j+2
|
||||
@j jsr $FDFD ; SMC
|
||||
jmp .BrowseModeInputLoop
|
||||
|
||||
@ -187,14 +149,46 @@ kBrowseTab = 4
|
||||
kBrowseLaunch = 5
|
||||
kBrowseCredits = 6
|
||||
|
||||
.BrowseDispatchTable
|
||||
!word .OnSearch
|
||||
!word .OnPrevious
|
||||
!word .OnNext
|
||||
!word SearchMode
|
||||
!word .OnTab
|
||||
!word .OnLaunch
|
||||
!word Credits
|
||||
.BrowseDispatchTableLo
|
||||
!byte <.OnSearch
|
||||
!byte <.OnPrevious
|
||||
!byte <.OnNext
|
||||
!byte <SearchMode
|
||||
!byte <.OnTab
|
||||
!byte <.OnLaunch
|
||||
!byte <Credits
|
||||
.BrowseDispatchTableHi
|
||||
!byte >.OnSearch
|
||||
!byte >.OnPrevious
|
||||
!byte >.OnNext
|
||||
!byte >SearchMode
|
||||
!byte >.OnTab
|
||||
!byte >.OnLaunch
|
||||
!byte >Credits
|
||||
|
||||
kNumBrowseKeys = 10 ; number of entries in next 2 tables (each)
|
||||
.BrowseKeys
|
||||
!byte $AF ; '/' = credits
|
||||
!byte $BF ; '?' = credits
|
||||
!byte $A0 ; Space = mini attract mode
|
||||
!byte $89 ; TAB = mini attract mode
|
||||
!byte $8D ; ENTER = launch current game
|
||||
!byte $9B ; Esc = switch to search mode
|
||||
!byte $8A ; down arrow = next
|
||||
!byte $95 ; right arrow = next
|
||||
!byte $8B ; up arrow = previous
|
||||
!byte $88 ; left arrow = previous
|
||||
.BrowseKeyDispatch
|
||||
!byte kBrowseCredits
|
||||
!byte kBrowseCredits
|
||||
!byte kBrowseTab
|
||||
!byte kBrowseTab
|
||||
!byte kBrowseLaunch
|
||||
!byte kBrowseExitToSearch
|
||||
!byte kBrowseNext
|
||||
!byte kBrowseNext
|
||||
!byte kBrowsePrevious
|
||||
!byte kBrowsePrevious
|
||||
|
||||
BrowseSelectedIndex
|
||||
!byte $FF
|
||||
|
@ -18,6 +18,7 @@
|
||||
; - Home
|
||||
; - BlankHGR
|
||||
; - BlankDHGR
|
||||
; - IsSearchKey
|
||||
|
||||
; Public variables
|
||||
; - OffscreenPage
|
||||
@ -151,6 +152,7 @@ ResetInputTimeout
|
||||
stx Timeout
|
||||
stx Timeout+1
|
||||
stx Timeout+2
|
||||
bit CLEARKBD
|
||||
rts
|
||||
|
||||
WaitForKeyFor30Seconds
|
||||
@ -291,12 +293,13 @@ ExecuteTransitionAndWait
|
||||
+ rts
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; .ClearHGR1 [private]
|
||||
; clear $2000..$3FFF in current memory bank (main or auxmem)
|
||||
; ClearOffscreen
|
||||
; clear $2000..$3FFF or $4000..$5FFF, depending on which HGR page is not
|
||||
; visible right now
|
||||
; does not change HGR mode
|
||||
;
|
||||
; in: none
|
||||
; out: $2000..$3FFF cleared
|
||||
; out: $2000..$3FFF or $4000..$5FFF cleared
|
||||
; A = 0
|
||||
; X = 0
|
||||
; Y = 0
|
||||
@ -318,4 +321,41 @@ ClearOffscreen
|
||||
dex
|
||||
bne @a
|
||||
rts
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; IsSearchKey
|
||||
; test whether accumulator contains a key that might trigger a new textrank
|
||||
; search
|
||||
;
|
||||
; in: A = key
|
||||
; out: A &= 0x7F
|
||||
; Y preserved
|
||||
; X clobbered
|
||||
; Z = 1 if this is a search key
|
||||
; Z = 0 if this is not a search key
|
||||
;------------------------------------------------------------------------------
|
||||
IsSearchKey
|
||||
and #$7F ; strip high bit for search characters
|
||||
cmp #$30 ; control keys and punctuation ignored
|
||||
bcc @badkey
|
||||
cmp #$3A ; numbers are good input
|
||||
bcc @goodkey
|
||||
cmp #$41 ; more punctuation (also ignored)
|
||||
bcc @badkey
|
||||
cmp #$5B ; uppercase letters are good input
|
||||
bcs +
|
||||
ora #$20 ; convert uppercase letters to lowercase
|
||||
bne @goodkey ; always branches
|
||||
|
||||
+ cmp #$61 ; more punctuation (also ignored)
|
||||
bcc @badkey
|
||||
cmp #$7B ; lowercase letters are good input
|
||||
bcc @goodkey
|
||||
@badkey
|
||||
ldx #1
|
||||
rts
|
||||
@goodkey
|
||||
ldx #0
|
||||
rts
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,9 @@
|
||||
|
||||
Credits
|
||||
; clobbers all
|
||||
jsr .LoadCredits
|
||||
+LDADDR .CreditsFile
|
||||
jsr SetPath
|
||||
jsr LoadFile ; loads at $8000
|
||||
jsr ClearOffscreen
|
||||
lda OffscreenPage
|
||||
ror ; draw on offscreen page
|
||||
@ -22,14 +24,6 @@ Credits
|
||||
bit CLEARKBD
|
||||
clc
|
||||
rts
|
||||
|
||||
.LoadCredits
|
||||
; [private] clobbers all
|
||||
+LDADDR .CreditsFile
|
||||
+
|
||||
jsr SetPath
|
||||
jsr LoadFile ; loads at $8000
|
||||
rts
|
||||
.CreditsFile
|
||||
!byte 7
|
||||
!text "CREDITS"
|
||||
|
@ -5,7 +5,6 @@
|
||||
;
|
||||
; Public functions
|
||||
; - SearchMode
|
||||
; - IsSearchKey
|
||||
;
|
||||
|
||||
!zone {
|
||||
@ -22,9 +21,9 @@ SearchMode
|
||||
+READ_RAM1_WRITE_RAM1
|
||||
ldx #$FF
|
||||
txs
|
||||
stx SelectedIndex ; no game selected
|
||||
stx SelectedIndex ; $FF = no game selected
|
||||
inx
|
||||
stx OffscreenPage
|
||||
stx OffscreenPage ; $00 = currently showing HGR page 2
|
||||
jsr Home ; clear screen
|
||||
jsr .OnInputChanged ; draw UI on HGR page 1
|
||||
+HGR_MODE ; show HGR
|
||||
@ -47,68 +46,32 @@ SearchMode
|
||||
@arrow ldx #kInputBrowse
|
||||
bne @InputDispatch ; always branches
|
||||
@notArrow
|
||||
bit CLEARKBD
|
||||
jsr ResetInputTimeout
|
||||
|
||||
cmp #$9B ; Esc clears the input buffer (if any)
|
||||
bne + ; or switches to mega attract mode
|
||||
ldx #kInputClear
|
||||
ldy #kNumBrowseKeys
|
||||
- dey
|
||||
bmi @noKeyMatch
|
||||
cmp .InputKeys,y
|
||||
bne -
|
||||
ldx .InputKeyDispatch,y
|
||||
bne @InputDispatch ; always branches
|
||||
+
|
||||
cmp #$8D ; ENTER launches the current game (if any)
|
||||
bne +
|
||||
ldx #kInputLaunch
|
||||
bne @InputDispatch ; always branches
|
||||
+
|
||||
cmp #$FF ; delete key
|
||||
bne +
|
||||
- ldx #kInputBack
|
||||
bne @InputDispatch ; always branches
|
||||
+
|
||||
cmp #$88 ; left arrow = delete (may as well, since
|
||||
; popular emulators remap this anyway)
|
||||
beq -
|
||||
|
||||
cmp #$89 ; TAB switches to mini attract mode
|
||||
bne + ; if there is a game selected
|
||||
- ldx #kInputTab
|
||||
bne @InputDispatch ; always branches
|
||||
+
|
||||
cmp #$A0 ; SPACE = TAB because ][+ doesn't have TAB
|
||||
beq -
|
||||
|
||||
cmp #$BF ; '?' display scredits
|
||||
bne +
|
||||
- ldx #kInputCredits
|
||||
bne @InputDispatch ; always branches
|
||||
+
|
||||
cmp #$AF ; '/' also displays credits
|
||||
beq -
|
||||
|
||||
and #$7F ; strip high bit for search characters
|
||||
@noKeyMatch
|
||||
jsr IsSearchKey
|
||||
beq +
|
||||
jsr SoftBell ; Beep on invalid input and start over.
|
||||
bne .SearchModeInputLoop ; This always branches because SoftBell
|
||||
; preserves all flags and we got here
|
||||
; because the BEQ didn't branch.
|
||||
+
|
||||
beq @foundSearchKey
|
||||
ldx #kInputError
|
||||
+HIDE_NEXT_2_BYTES
|
||||
@foundSearchKey
|
||||
ldx #kInputSearch
|
||||
; execution falls through here
|
||||
@InputDispatch
|
||||
pha ; save key pressed
|
||||
txa
|
||||
asl
|
||||
tax
|
||||
lda .InputDispatchTable,x
|
||||
sta @j+1
|
||||
lda .InputDispatchTable+1,x
|
||||
sta @j+2
|
||||
pla ; restore key pressed
|
||||
ldy .InputDispatchTableLo,x
|
||||
sty @j+1
|
||||
ldy .InputDispatchTableHi,x
|
||||
sty @j+2
|
||||
@j jsr $FDFD ; SMC
|
||||
bcs +
|
||||
jmp .SearchModeInputLoop ; if carry is clear, we're done
|
||||
+ jmp SearchMode ; if carry is set, force full redraw
|
||||
bcc .SearchModeInputLoop ; if carry is clear, we're done
|
||||
bcs SearchMode ; if carry is set, force full redraw
|
||||
|
||||
.OnClear
|
||||
ldx InputLength
|
||||
@ -122,44 +85,40 @@ SearchMode
|
||||
.OnBack
|
||||
ldx InputLength
|
||||
bne +
|
||||
jsr SoftBell
|
||||
rts
|
||||
jmp SoftBell
|
||||
+ dec InputLength
|
||||
jmp .OnInputChanged
|
||||
|
||||
.OnTab
|
||||
ldx SelectedIndex
|
||||
cpx #$FF
|
||||
beq +
|
||||
beq .ClearAndReturn
|
||||
jsr MiniAttractMode
|
||||
cmp #$8D ; if we exited mini attract mode
|
||||
beq .OnLaunch ; by pressing Enter, launch the game
|
||||
sec ; tell caller to redraw UI
|
||||
rts
|
||||
+ clc
|
||||
rts
|
||||
|
||||
.OnLaunch
|
||||
ldx SelectedIndex
|
||||
cpx #$FF
|
||||
beq +
|
||||
beq .ClearAndReturn
|
||||
jsr PlayGameFromSearch
|
||||
sec ; tell caller to redraw UI
|
||||
rts
|
||||
+ clc
|
||||
rts
|
||||
|
||||
.OnSearch
|
||||
ldx InputLength
|
||||
cpx #MaxInputLength
|
||||
bne +
|
||||
jsr SoftBell
|
||||
.OnError
|
||||
jsr SoftBell ; Beep on invalid input and start over.
|
||||
.ClearAndReturn
|
||||
clc
|
||||
rts
|
||||
+ sta InputBuffer,x
|
||||
inc InputLength
|
||||
; execution falls through here
|
||||
|
||||
.OnInputChanged
|
||||
lda InputLength
|
||||
bne @findMatchingTitle
|
||||
@ -178,6 +137,7 @@ SearchMode
|
||||
jsr ShowOtherPage
|
||||
clc
|
||||
rts
|
||||
|
||||
@findMatchingTitle
|
||||
jsr ResetTextRank
|
||||
|
||||
@ -187,10 +147,9 @@ SearchMode
|
||||
|
||||
lda MatchCount ; any matches at all?
|
||||
bne +
|
||||
jsr SoftBell ; no matches for this input buffer, beep
|
||||
dec InputLength ; and ignore the last key typed
|
||||
clc
|
||||
rts
|
||||
; no matches for this input buffer
|
||||
dec InputLength ; ignore the last key typed
|
||||
jmp .OnError ; beep and return
|
||||
+
|
||||
lda BestMatchIndex ; check if the new best match is the same
|
||||
cmp SelectedIndex ; as the current best match
|
||||
@ -270,29 +229,6 @@ SearchMode
|
||||
jsr DrawSearchBarOffscreen; actually draw the search UI (offscreen)
|
||||
jmp ShowOtherPage ; now show everything at once
|
||||
|
||||
IsSearchKey
|
||||
cmp #$30 ; control keys and punctuation ignored
|
||||
bcc @badkey
|
||||
cmp #$3A ; numbers are good input
|
||||
bcc @goodkey
|
||||
cmp #$41 ; more punctuation (also ignored)
|
||||
bcc @badkey
|
||||
cmp #$5B ; uppercase letters are good input
|
||||
bcs +
|
||||
ora #$20 ; convert uppercase letters to lowercase
|
||||
bne @goodkey ; always branches
|
||||
|
||||
+ cmp #$61 ; more punctuation (also ignored)
|
||||
bcc @badkey
|
||||
cmp #$7B ; lowercase letters are good input
|
||||
bcc @goodkey
|
||||
@badkey
|
||||
ldx #1
|
||||
rts
|
||||
@goodkey
|
||||
ldx #0
|
||||
rts
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; indices into InputDispatchTable
|
||||
@ -303,14 +239,46 @@ kInputBrowse = 3
|
||||
kInputTab = 4
|
||||
kInputLaunch = 5
|
||||
kInputCredits = 6
|
||||
kInputError = 7
|
||||
|
||||
.InputDispatchTable
|
||||
!word .OnSearch
|
||||
!word .OnClear
|
||||
!word .OnBack
|
||||
!word BrowseMode
|
||||
!word .OnTab
|
||||
!word .OnLaunch
|
||||
!word Credits
|
||||
.InputDispatchTableLo
|
||||
!byte <.OnSearch
|
||||
!byte <.OnClear
|
||||
!byte <.OnBack
|
||||
!byte <BrowseMode
|
||||
!byte <.OnTab
|
||||
!byte <.OnLaunch
|
||||
!byte <Credits
|
||||
!byte <.OnError
|
||||
.InputDispatchTableHi
|
||||
!byte >.OnSearch
|
||||
!byte >.OnClear
|
||||
!byte >.OnBack
|
||||
!byte >BrowseMode
|
||||
!byte >.OnTab
|
||||
!byte >.OnLaunch
|
||||
!byte >Credits
|
||||
!byte >.OnError
|
||||
|
||||
kNumInputKeys = 8 ; number of entries in next 2 tables (each)
|
||||
.InputKeys
|
||||
!byte $AF ; '/' = credits
|
||||
!byte $BF ; '?' = credits
|
||||
!byte $A0 ; Space = mini attract mode
|
||||
!byte $89 ; TAB = mini attract mode
|
||||
!byte $88 ; left arrow = delete (may as well, since
|
||||
; popular emulators remap this anyway)
|
||||
!byte $FF ; backspace = delete
|
||||
!byte $8D ; ENTER = launch current game (if any)
|
||||
!byte $9B ; Esc = clear input buffer (if any)
|
||||
; or switch to mega attract mode
|
||||
.InputKeyDispatch
|
||||
!byte kInputCredits
|
||||
!byte kInputCredits
|
||||
!byte kInputTab
|
||||
!byte kInputTab
|
||||
!byte kInputBack
|
||||
!byte kInputBack
|
||||
!byte kInputLaunch
|
||||
!byte kInputClear
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user