From d28a84a6f67877ef9a89701c91d0cac35e0779ba Mon Sep 17 00:00:00 2001 From: 4am Date: Sat, 21 Sep 2019 17:35:49 -0400 Subject: [PATCH] refactor DrawUI some more --- src/constants.a | 2 +- src/ui.browse.mode.a | 18 +++------------- src/ui.common.a | 49 +++++++++++++++++++++++++++++--------------- src/ui.search.mode.a | 26 ++++------------------- 4 files changed, 40 insertions(+), 55 deletions(-) diff --git a/src/constants.a b/src/constants.a index 1f9b9db49..82dfeac6e 100644 --- a/src/constants.a +++ b/src/constants.a @@ -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 diff --git a/src/ui.browse.mode.a b/src/ui.browse.mode.a index 959e2bb17..26abb1b1e 100644 --- a/src/ui.browse.mode.a +++ b/src/ui.browse.mode.a @@ -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 ;------------------------------------------------------------------------------ diff --git a/src/ui.common.a b/src/ui.common.a index 92e4182e7..be9d36866 100644 --- a/src/ui.common.a +++ b/src/ui.common.a @@ -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 ;------------------------------------------------------------------------------ diff --git a/src/ui.search.mode.a b/src/ui.search.mode.a index 5d4973981..60adb72da 100644 --- a/src/ui.search.mode.a +++ b/src/ui.search.mode.a @@ -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 ;------------------------------------------------------------------------------