some minor refactoring in search mode

This commit is contained in:
4am 2019-06-27 11:37:23 -04:00
parent 531abf6076
commit ff699d9bd1
5 changed files with 136 additions and 125 deletions

View File

@ -139,7 +139,7 @@ OneTimeSetup
@digitDone @digitDone
pla pla
ora #$30 ora #$30
sta UILine2_GameCount,y sta VisibleGameCount,y
iny iny
cpy #$03 cpy #$03
bcc @outer bcc @outer

View File

@ -35,6 +35,8 @@ SLOT3STATUS = $C017 ; bit 7 only
NEWVIDEO = $C029 ; IIgs graphics modes NEWVIDEO = $C029 ; IIgs graphics modes
SPEAKER = $C030 ; chirp chirp SPEAKER = $C030 ; chirp chirp
SHADOW = $C035 ; IIgs auxmem-to-bank-E1 shadowing SHADOW = $C035 ; IIgs auxmem-to-bank-E1 shadowing
PAGE1 = $C054 ; page 1 (affects text, HGR, DHGR)
PAGE2 = $C055 ; page 2 (affects text, HGR, DHGR)
DHIRESON = $C05E ; double hi-res on switch DHIRESON = $C05E ; double hi-res on switch
DHIRESOFF = $C05F ; double hi-res off switch DHIRESOFF = $C05F ; double hi-res off switch

View File

@ -123,3 +123,10 @@
ora #$20 ora #$20
+ +
} }
; does not set page 1 or 2
!macro HGR_MODE {
lda $C057
lda $C052
lda $C050
}

View File

@ -94,10 +94,8 @@ Home
BlankHGR BlankHGR
jsr Home jsr Home
jsr .ClearHGR1 ; clear hi-res screen 1 jsr .ClearHGR1 ; clear hi-res screen 1
lda $c057 ; show hi-res screen 1 (now blank) bit PAGE1 ; show hi-res screen 1 (now blank)
lda $c054 +HGR_MODE
lda $c052
lda $c050
rts rts
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
@ -115,10 +113,8 @@ BlankDHGR
jsr .ClearHGR1 ; clear hi-res screen 1 in auxmem jsr .ClearHGR1 ; clear hi-res screen 1 in auxmem
sta WRITEMAINMEM sta WRITEMAINMEM
sta SET80VID sta SET80VID
sta $c057 bit PAGE1
sta $c054 +HGR_MODE
sta $c052
sta $c050
sta DHIRESON sta DHIRESON
rts rts
@ -136,6 +132,7 @@ ExecuteTransitionAndWait
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; .ClearHGR1 [private] ; .ClearHGR1 [private]
; clear $2000..$3FFF in current memory bank (main or auxmem) ; clear $2000..$3FFF in current memory bank (main or auxmem)
; does not change HGR mode
; ;
; in: none ; in: none
; out: $2000..$3FFF cleared ; out: $2000..$3FFF cleared

View File

@ -6,6 +6,10 @@
; Public functions ; Public functions
; - SearchMode ; - SearchMode
; ;
; Public addresses
; - VisibleGameCount (set during init)
!zone {
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; SearchMode ; SearchMode
@ -21,50 +25,48 @@ SearchMode
txs txs
stx SelectedIndex ; no game selected stx SelectedIndex ; no game selected
inx inx
stx OffscreenPage stx .OffscreenPage
jsr Home ; clear screen jsr Home ; clear screen
jsr OnInputChanged ; draw UI on HGR page 1 jsr .OnInputChanged ; draw UI on HGR page 1
bit $C052 +HGR_MODE ; show HGR
bit $C057
bit $C050 ; show HGR page 1
bit CLEARKBD bit CLEARKBD
jsr _ResetInputTimeout jsr .ResetInputTimeout
_SearchModeInputLoop .SearchModeInputLoop
lda KBD lda KBD
bmi @gotKey bmi @gotKey
inc $4F ; these are only ever incremented, never inc RNDSEED+1 ; these are only ever incremented, never
bne + ; reset (may be used as a pseudorandom bne + ; reset (may be used as a pseudorandom
inc $4E ; seed) inc RNDSEED ; seed)
+ +
dec Timeout ; these are a 3-byte timeout counter dec Timeout ; these are a 3-byte timeout counter
bne _SearchModeInputLoop ; that counts down from a number set bne .SearchModeInputLoop ; that counts down from a number set
dec Timeout+1 ; in _ResetInputTimeout and reset dec Timeout+1 ; in .ResetInputTimeout and reset
bne _SearchModeInputLoop ; on every keypress (whether or not bne .SearchModeInputLoop ; on every keypress (whether or not
dec Timeout+2 ; the key leads to an action) dec Timeout+2 ; the key leads to an action)
bne _SearchModeInputLoop bne .SearchModeInputLoop
jsr _CoverFade ; no input for ~30 seconds, switch to jsr .CoverFade ; no input for ~30 seconds, switch to
jmp MegaAttractMode ; mega-attract mode jmp MegaAttractMode ; mega-attract mode
@gotKey @gotKey
bit CLEARKBD bit CLEARKBD
jsr _ResetInputTimeout jsr .ResetInputTimeout
cmp #$9B ; Esc clears the input buffer (if any) cmp #$9B ; Esc clears the input buffer (if any)
bne + ; or switches to mega attract mode bne + ; or switches to mega attract mode
ldx #kInputClear ldx #kInputClear
bne InputDispatch ; always branches bne @InputDispatch ; always branches
+ +
cmp #$8D ; ENTER launches the current game (if any) cmp #$8D ; ENTER launches the current game (if any)
bne + bne +
ldx #kInputLaunch ldx #kInputLaunch
bne InputDispatch ; always branches bne @InputDispatch ; always branches
+ +
cmp #$FF ; delete key cmp #$FF ; delete key
bne + bne +
- ldx #kInputBack - ldx #kInputBack
bne InputDispatch ; always branches bne @InputDispatch ; always branches
+ cmp #$88 ; left arrow = delete + cmp #$88 ; left arrow = delete
beq - beq -
@ -72,7 +74,7 @@ _SearchModeInputLoop
cmp #$89 ; TAB switches to mini attract mode cmp #$89 ; TAB switches to mini attract mode
bne + ; if there is a game selected bne + ; if there is a game selected
ldx #kInputTab ldx #kInputTab
bne InputDispatch ; always branches bne @InputDispatch ; always branches
+ +
and #$7F ; strip high bit for search characters and #$7F ; strip high bit for search characters
cmp #$30 ; control keys and punctuation ignored cmp #$30 ; control keys and punctuation ignored
@ -92,56 +94,56 @@ _SearchModeInputLoop
bcc @goodkey bcc @goodkey
@badkey @badkey
jsr SoftBell ; beep on invalid input jsr SoftBell ; beep on invalid input
jmp _SearchModeInputLoop ; and start over jmp .SearchModeInputLoop ; and start over
@goodkey @goodkey
ldx #kInputSearch ldx #kInputSearch
; execution falls through here ; execution falls through here
InputDispatch @InputDispatch
pha ; save key pressed pha ; save key pressed
txa txa
asl asl
tax tax
lda InputDispatchTable,x lda .InputDispatchTable,x
sta @j+1 sta @j+1
lda InputDispatchTable+1,x lda .InputDispatchTable+1,x
sta @j+2 sta @j+2
pla ; restore key pressed pla ; restore key pressed
@j jsr $FDFD ; SMC @j jsr $FDFD ; SMC
bcs + bcs +
jmp _SearchModeInputLoop ; if carry is clear, continue jmp .SearchModeInputLoop ; if carry is clear, we're done
+ jmp SearchMode ; if carry is set, force full redraw + jmp SearchMode ; if carry is set, force full redraw
OnClear .OnClear
ldx InputLength ldx InputLength
bne + bne +
jsr _CoverFade ; Esc with no input switches to jsr .CoverFade ; Esc with no input switches to
jmp MegaAttractMode ; mega-attract mode jmp MegaAttractMode ; mega-attract mode
+ ldx #0 ; Esc with input clears the input + ldx #0 ; Esc with input clears the input
stx InputLength stx InputLength
jmp OnInputChanged jmp .OnInputChanged
OnBack .OnBack
ldx InputLength ldx InputLength
bne + bne +
jsr SoftBell jsr SoftBell
rts rts
+ dec InputLength + dec InputLength
jmp OnInputChanged jmp .OnInputChanged
OnTab .OnTab
ldx SelectedIndex ldx SelectedIndex
cpx #$FF cpx #$FF
beq + beq +
jsr MiniAttractMode jsr MiniAttractMode
cmp #$8D cmp #$8D ; if we exited mini attract mode
beq OnLaunch beq .OnLaunch ; by pressing Enter, launch the game
sec ; tell caller to redraw UI sec ; tell caller to redraw UI
rts rts
+ clc + clc
rts rts
OnLaunch .OnLaunch
ldx SelectedIndex ldx SelectedIndex
cpx #$FF cpx #$FF
beq + beq +
@ -151,7 +153,7 @@ OnLaunch
+ clc + clc
rts rts
OnSearch .OnSearch
ldx InputLength ldx InputLength
cpx #MaxInputLength cpx #MaxInputLength
bne + bne +
@ -161,7 +163,7 @@ OnSearch
+ sta InputBuffer,x + sta InputBuffer,x
inc InputLength inc InputLength
; execution falls through here ; execution falls through here
OnInputChanged .OnInputChanged
lda InputLength lda InputLength
bne @findMatchingTitle bne @findMatchingTitle
; no input, reset params and UI ; no input, reset params and UI
@ -169,19 +171,19 @@ OnInputChanged
sta SelectedIndex ; no game selected sta SelectedIndex ; no game selected
ldx #40 ; reset visible line ldx #40 ; reset visible line
lda #0 lda #0
- sta UILine1-1,x - sta .UILine1-1,x
dex dex
bne - bne -
ldy #MaxInputLength ; clear visible search bar ldy #MaxInputLength ; clear visible search bar
lda #" " lda #" "
- sta UILine2+1,y - sta .UILine2+1,y
dey dey
bne - bne -
lda #$7F lda #$7F
sta UILine2+1 sta .UILine2+1
jsr _LoadTitleOffscreen jsr .LoadTitleOffscreen
jsr _DrawSearchBarOffscreen jsr .DrawSearchBarOffscreen
jsr _ShowOtherPage jsr .ShowOtherPage
clc clc
rts rts
@findMatchingTitle @findMatchingTitle
@ -203,29 +205,26 @@ OnInputChanged
php ; (we'll use this later to skip reloading) php ; (we'll use this later to skip reloading)
sta SelectedIndex sta SelectedIndex
sta @index sta @index
jsr okvs_nth jsr okvs_nth ; get the name of the new best match
!word gGamesListStore !word gGamesListStore
@index !byte $FD @index !byte $FD
+STAY @key +STAY @key
plp plp
bne + bne +
lda OffscreenPage lda .OffscreenPage ; since we're not loading a new screenshot
eor #$01 eor #$01 ; we fake switching the 'offscreen' page
sta OffscreenPage sta .OffscreenPage ; in order to draw on the visible page
jmp @skipload bpl @skipload ; always branches
+ lda OffscreenPage ; we have a new best match, so load the +
beq + ; new title screenshot (offscreen) jsr .GetOffscreenAddress ; we have a new best match, so load the
lda #$40 sta + ; new title screenshot (offscreen)
+HIDE_NEXT_2_BYTES
+ lda #$20
sta @titleaddress+1
+LDADDR kHGRTitleDirectory +LDADDR kHGRTitleDirectory
jsr SetPath jsr SetPath
+LDAY @key +LDAY @key
jsr AddToPath jsr AddToPath
jsr LoadFileAt jsr LoadFileAt
@titleaddress !byte $00
!word $FD00 + !byte $FD ; SMC
@skipload @skipload
jsr okvs_get jsr okvs_get
@ -247,12 +246,12 @@ OnInputChanged
+HIDE_NEXT_2_BYTES +HIDE_NEXT_2_BYTES
@printTitleChar @printTitleChar
lda (SRC),y ; copy game title to search UI lda (SRC),y ; copy game title to search UI
sta UILine2,y sta .UILine2,y
cpy #MaxInputLength+1 cpy #MaxInputLength+1
bcc - bcc -
ldx #40 ldx #40
lda #0 lda #0
- sta UILine1-1,x ; reset search bar - sta .UILine1-1,x ; reset search bar
dex dex
bne - bne -
tay tay
@ -261,7 +260,7 @@ OnInputChanged
cmp InputBuffer,x cmp InputBuffer,x
bne + bne +
lda #$0B ; add dots to highlight matched characters lda #$0B ; add dots to highlight matched characters
sta UILine1,y sta .UILine1,y
inx inx
cpx InputLength cpx InputLength
beq @doneHighlight beq @doneHighlight
@ -270,64 +269,75 @@ OnInputChanged
cpy #40 cpy #40
bne - bne -
@doneHighlight @doneHighlight
jsr _DrawSearchBarOffscreen; actually draw the search UI (offscreen) jsr .DrawSearchBarOffscreen; actually draw the search UI (offscreen)
jmp _ShowOtherPage ; now show everything at once jmp .ShowOtherPage ; now show everything at once
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
_LoadTitleOffscreen .GetOffscreenAddress
; clobbers all ; in: none
lda OffscreenPage ; out: A = high byte of offscreen HGR page (#$20 or #$40)
; preserves X/Y
lda .OffscreenPage
beq + beq +
lda #$40 lda #$40
+HIDE_NEXT_2_BYTES rts
+ lda #$20 + lda #$20
sta @addr+1
+LDADDR Title
jsr SetPath
jsr LoadFileAt
@addr !word $FD00 ; SMC
rts rts
_LoadCoverOffscreen .LoadTitleOffscreen
; clobbers all ; clobbers all
lda OffscreenPage jsr .GetOffscreenAddress
beq + sta +
lda #$40 +LDADDR @TitleFile
+HIDE_NEXT_2_BYTES
+ lda #$20
sta @addr+1
+LDADDR Cover
jsr SetPath jsr SetPath
jsr LoadFileAt jsr LoadFileAt
@addr !word $FD00 ; SMC !byte $00
+ !byte $FD ; SMC
rts rts
@TitleFile
!byte 5
!text "TITLE"
_DrawSearchBarOffscreen .LoadCoverOffscreen
; clobbers all
jsr .GetOffscreenAddress
sta +
+LDADDR @CoverFile
jsr SetPath
jsr LoadFileAt
!byte $00
+ !byte $FD ; SMC
rts
@CoverFile
!byte 5
!text "COVER"
.DrawSearchBarOffscreen
; clobbers all ; clobbers all
LDA #22 ; draw visible search bar LDA #22 ; draw visible search bar
sta VTAB sta VTAB
lda OffscreenPage lda .OffscreenPage
ror ; draw on offscreen page ror ; draw on offscreen page
+LDADDR UILine1 +LDADDR .UILine1
jsr Draw40Chars jsr Draw40Chars
lda OffscreenPage lda .OffscreenPage
ror ; draw on offscreen page ror ; draw on offscreen page
+LDADDR UILine2 +LDADDR .UILine2
jmp Draw40Chars jmp Draw40Chars
_ShowOtherPage .ShowOtherPage
; clobbers A, preserves X/Y ; clobbers A, preserves X/Y
lda OffscreenPage lda .OffscreenPage
eor #$01 eor #$01
sta OffscreenPage sta .OffscreenPage
bne + bne +
bit $C055 ; show page 2 bit PAGE2 ; show page 2
rts rts
+ bit $C054 ; show page 1 + bit PAGE1 ; show page 1
rts rts
_ResetInputTimeout .ResetInputTimeout
; clobbers X, preserves A/Y ; clobbers X, preserves A/Y
ldx #$16 ldx #$16
stx Timeout stx Timeout
@ -335,49 +345,42 @@ _ResetInputTimeout
stx Timeout+2 stx Timeout+2
rts rts
_CoverFade .CoverFade
; clobbers all ; clobbers all
jsr _LoadCoverOffscreen jsr .LoadCoverOffscreen
jsr _ShowOtherPage jsr .ShowOtherPage
lda OffscreenPage lda .OffscreenPage
bne + bne +
jsr _LoadCoverOffscreen jsr .LoadCoverOffscreen
jsr _ShowOtherPage jsr .ShowOtherPage
+ +
; load transition effect code at $6000 ; load transition effect code at $6000
+LDADDR kFXDirectory +LDADDR kFXDirectory
jsr SetPath jsr SetPath
+LDADDR kFXCoverFade +LDADDR @CoverFadeFile
jsr AddToPath jsr AddToPath
jsr LoadFile jsr LoadFile
jmp $6000 ; exit via loaded code
jmp $6000 @CoverFadeFile
kFXCoverFade
!byte 9 !byte 9
!text "COVERFADE" !text "COVERFADE"
Cover !byte 5 .UILine1
!text "COVER"
Title !byte 5
!text "TITLE"
UILine1
!byte 0,0,0,0,0,0,0,0,0,0 !byte 0,0,0,0,0,0,0,0,0,0
!byte 0,0,0,0,0,0,0,0,0,0 !byte 0,0,0,0,0,0,0,0,0,0
!byte 0,0,0,0,0,0,0,0,0,0 !byte 0,0,0,0,0,0,0,0,0,0
!byte 0,0,0,0,0,0,0,0,0,0 !byte 0,0,0,0,0,0,0,0,0,0
UILine2 .UILine2
!text "[" !text "["
!byte $7F !byte $7F
!text " " !text " "
!text "] " !text "] "
UILine2_GameCount VisibleGameCount
!text "000 games" !text "000"
!text " games"
OffscreenPage .OffscreenPage
!byte 1 ; 0 = currently showing HGR page 2 !byte 1 ; 0 = currently showing HGR page 2
; (so offscreen is page 1 @ $2000) ; (so offscreen is page 1 @ $2000)
; 1 = currently showing HGR page 1 ; 1 = currently showing HGR page 1
@ -390,9 +393,11 @@ kInputBack = 2
kInputTab = 3 kInputTab = 3
kInputLaunch = 4 kInputLaunch = 4
InputDispatchTable .InputDispatchTable
!word OnSearch !word .OnSearch
!word OnClear !word .OnClear
!word OnBack !word .OnBack
!word OnTab !word .OnTab
!word OnLaunch !word .OnLaunch
}