refactor DrawUI some more

This commit is contained in:
4am 2019-09-21 17:35:49 -04:00
parent 6f1895c1a7
commit d28a84a6f6
4 changed files with 40 additions and 55 deletions

View File

@ -9,7 +9,7 @@
; D000..E5F4 - persistent data structures (per-game cheat categories,
; gGlobalPrefsStore, gGamesListStore)
; ...unused...
; EBCF..FFF9 - main program code
; EBEE..FFF9 - main program code
; FFFA..FFFF - NMI, reset, IRQ vectors
;
; LC RAM BANK 2

View File

@ -94,21 +94,9 @@ GameCount = *+1
ldx gGameToLaunch
; execution falls through here
.OnBrowseChanged
+LDADDR gGamesListStore
jsr okvs_nth ; get the filename of the new game
+STAY @key
jsr GetOffscreenAddress ; load new title screenshot offscreen
sta + ; new title screenshot (offscreen)
jsr LoadFile
!word kHGRTitleDirectory
@key !word $FDFD ; SMC
!byte $00
+ !byte $FD ; SMC
clc
jsr DrawUIOffscreen
jmp ShowOtherPage
; in: X = game index
jsr LoadGameTitleOffscreen
jmp DrawUIWithoutDots
;------------------------------------------------------------------------------

View File

@ -8,7 +8,9 @@
; - GetOffscreenAddress
; - LoadTitleOffscreen
; - LoadCoverOffscreen
; - DrawUIOffscreen
; - LoadGameTitleOffscreen
; - DrawBrowseUI
; - DrawSearchUI
; - ShowOtherPage
; - ToggleOffscreenPage
; - CoverFade
@ -143,6 +145,20 @@ LoadCoverOffscreen
!byte 5
!text "COVER"
LoadGameTitleOffscreen
; in: X = game index
+LDADDR gGamesListStore
jsr okvs_nth
+STAY @fname
jsr GetOffscreenAddress
sta +
jsr LoadFile
!word kHGRTitleDirectory
@fname !word $FDFD ; SMC
!byte $00
+ !byte $FD ; SMC
rts
;------------------------------------------------------------------------------
; CoverFade
; load cover screen and animate per-character fade
@ -168,24 +184,22 @@ CoverFade
!text "COVERFADE"
;------------------------------------------------------------------------------
; DrawUIOffscreen
; draw 2- or 4-line search/browse UI on the HGR page that is not currently
; showing
; DrawUIWithoutDots/DrawUI
; draw 2- or 4-line UI on the HGR page that is not currently showing, then
; show that HGR page
;
; in: gGameToLaunch = game index, or #$FF if no game is selected
; C set = print block cursor after game title and print dots to
; highlight matching characters
; C clear = don't print either of those things
; out: all flags and registers clobbered
;------------------------------------------------------------------------------
DrawUIOffscreen
php
bcc + ; set up cursor printing if caller wanted that
lda #$7F
+HIDE_NEXT_2_BYTES
+
DrawUIWithoutDots
lda #" "
sta @printCursor+1
clc
bcc +
DrawUI
lda #$7F
sec
+ sta @printCursor+1 ; set up cursor printing based on entry point
php
ldy #39
- lda #$00 ; horizontal bar character
@ -307,7 +321,7 @@ DrawUIOffscreen
jsr Draw40Chars ; draw UI line 2 on offscreen page
bit gCheatsEnabled ; if cheats are disabled, then we're done drawing UI
bpl OffscreenDone
bpl @uidone
; (SAVE) still points to length-prefixed cheat description
ldy #0
lda (SAVE),y ; A = length of cheat description
@ -346,7 +360,9 @@ DrawUIOffscreen
inc VTAB
plp
+LDADDR gPathname
jmp DrawCenteredString ; draw cheat UI line 2
jsr DrawCenteredString ; draw cheat UI line 2
@uidone jmp ShowOtherPage
;------------------------------------------------------------------------------
; ClearOffscreen
@ -376,7 +392,6 @@ ClearOffscreen
inc @a+2
dex
bne @a
OffscreenDone
rts
;------------------------------------------------------------------------------

View File

@ -126,9 +126,7 @@ SearchMode
ldx #$FF
stx gGameToLaunch ; no game selected
jsr LoadTitleOffscreen
clc
jsr DrawUIOffscreen
jsr ShowOtherPage
jsr DrawUIWithoutDots
clc
rts
@ -147,30 +145,14 @@ SearchMode
+
ldx BestMatchIndex ; check if the new best match is the same
cpx gGameToLaunch ; as the current best match
php ; (we'll use this later to skip reloading)
stx gGameToLaunch
+LDADDR gGamesListStore
jsr okvs_nth ; get the filename of the new best match
+STAY @key
plp
bne +
jsr ToggleOffscreenPage ; Since we're not loading a new screenshot
; we fake switching the 'offscreen' page
; in order to draw on the visible page.
bpl @skipload ; always branches
+
jsr GetOffscreenAddress ; we have a new best match, so load the
sta + ; new title screenshot (offscreen)
jsr LoadFile
!word kHGRTitleDirectory
@key !word $FDFD ; SMC
!byte $00
+ !byte $FD ; SMC
@skipload
sec
jsr DrawUIOffscreen
jmp ShowOtherPage
bpl @noload ; (always branches)
+ jsr LoadGameTitleOffscreen
@noload jmp DrawUI
;------------------------------------------------------------------------------