diff --git a/src/constants.a b/src/constants.a index d4bf8e49c..da1cf104c 100644 --- a/src/constants.a +++ b/src/constants.a @@ -9,7 +9,7 @@ ; D000..E4E9 - persistent data structures (gGlobalPrefsStore, gGamesListStore) ; ...end of data and start of code are approximate, in between is unused... ; ...if they ever overlap, things will go boom... -; E9B8..FFF9 - main program code +; E9C4..FFF9 - main program code ; FFFA..FFFF - NMI, reset, IRQ vectors ; ; LC RAM BANK 2 diff --git a/src/macros.a b/src/macros.a index e8ea63483..c0a8cca24 100644 --- a/src/macros.a +++ b/src/macros.a @@ -112,17 +112,3 @@ and zpCharMask + } - -; does not set page 1 or 2 -!macro HGR_MODE { - bit $C057 - bit $C052 - bit $C050 -} - -; does not set page 1 or 2 -!macro GR_MODE { - bit $C056 - bit $C052 - bit $C050 -} diff --git a/src/ui.attract.gr.a b/src/ui.attract.gr.a index 3102db7c1..25a3b6985 100644 --- a/src/ui.attract.gr.a +++ b/src/ui.attract.gr.a @@ -49,7 +49,9 @@ BlankGR dex bne @loop bit PAGE1 - +GR_MODE + bit $C056 ; set GR mode + bit $C052 + bit $C050 rts ;------------------------------------------------------------------------------ diff --git a/src/ui.browse.mode.a b/src/ui.browse.mode.a index b4b6b86b6..84b4b1690 100644 --- a/src/ui.browse.mode.a +++ b/src/ui.browse.mode.a @@ -25,7 +25,7 @@ BrowseMode .BrowseModeInputLoop jsr WaitForKeyFor30Seconds - jsr ResetInputTimeout + bit CLEARKBD ldy #kNumBrowseKeys - dey diff --git a/src/ui.common.a b/src/ui.common.a index abf6a6882..52e394d6d 100644 --- a/src/ui.common.a +++ b/src/ui.common.a @@ -1,4 +1,4 @@ -;license:MIT +;License:MIT ;(c) 2018-9 by 4am ; ; common UI functions @@ -9,15 +9,15 @@ ; - LoadTitleOffscreen ; - LoadCoverOffscreen ; - DrawSearchBarOffscreen -; - ClearOffscreen ; - ShowOtherPage ; - ToggleOffscreenPage ; - CoverFade -; - ResetInputTimeout ; - SoftBell ; - Home ; - BlankHGR ; - BlankDHGR +; - ClearOffscreen +; - ExecuteTransitionAndWait ; - IsSearchKey ; Public variables @@ -126,6 +126,36 @@ DrawSearchBarOffscreen +LDADDR UILine2 jmp Draw40Chars +;------------------------------------------------------------------------------ +; 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 or $4000..$5FFF cleared +; A = 0 +; X = 0 +; Y = 0 +; Z = 1 +;------------------------------------------------------------------------------ +ClearOffscreen + jsr GetOffscreenAddress + +HIDE_NEXT_2_BYTES +.ClearHGR1 + lda #$20 + sta @a+2 + ldx #$20 + lda #$80 + ldy #0 +@a sta $2000,y + iny + bne @a + inc @a+2 + dex + bne @a + rts + ShowOtherPage ; in: none ; out: A = new value of OffscreenPage @@ -146,16 +176,24 @@ ToggleOffscreenPage sta OffscreenPage rts -ResetInputTimeout -; clobbers X, preserves A/Y - ldx #$16 - stx Timeout - stx Timeout+1 - stx Timeout+2 - bit CLEARKBD - rts - +;------------------------------------------------------------------------------ +; WaitForKeyFor30Seconds +; does what it says on the tin +; +; in: none +; out: if user presses a key before the timer runs out, exits with A = key +; otherwise exits via MegaAttractMode +; X/Y preserved +;------------------------------------------------------------------------------ WaitForKeyFor30Seconds + lda KBD + bmi @gotKey ; if we have a key on entry, exit with it in A + + lda #$16 ; initialize timeout counters + sta Timeout + sta Timeout+1 + sta Timeout+2 +@loop lda KBD bmi @gotKey @@ -164,11 +202,11 @@ WaitForKeyFor30Seconds inc RNDSEED ; seed) + dec Timeout ; these are a 3-byte timeout counter - bne WaitForKeyFor30Seconds; that counts down from a number set + bne @loop ; that counts down from a number set dec Timeout+1 ; in .ResetInputTimeout and reset - bne WaitForKeyFor30Seconds; on every keypress (whether or not + bne @loop ; on every keypress (whether or not dec Timeout+2 ; the key leads to an action) - bne WaitForKeyFor30Seconds + bne @loop jsr CoverFade ; no input for ~30 seconds, switch to jmp MegaAttractMode ; mega-attract mode @gotKey rts @@ -255,8 +293,7 @@ BlankHGR jsr Home jsr .ClearHGR1 ; clear hi-res screen 1 bit PAGE1 ; show hi-res screen 1 (now blank) - +HGR_MODE - rts + jmp HGRMode ;------------------------------------------------------------------------------ ; BlankDHGR @@ -273,11 +310,31 @@ BlankDHGR jsr .ClearHGR1 ; clear hi-res screen 1 in auxmem sta WRITEMAINMEM sta SET80VID - bit PAGE1 - +HGR_MODE sta DHIRESON + bit PAGE1 + jmp HGRMode + +;------------------------------------------------------------------------------ +; HGRMode +; twiddles softswitches to set HGR mode (does not set page 1 or 2) +; +; in: none +; out: all registers preserved +;------------------------------------------------------------------------------ +HGRMode + bit $C057 + bit $C052 + bit $C050 rts +;------------------------------------------------------------------------------ +; ExecuteTransitionAndWait +; call transition effect code (address passed in) and wait a period of time +; or until the user presses a key +; +; in: A/Y = address of transition effect code +; out: all flags and registers clobbered +;------------------------------------------------------------------------------ ExecuteTransitionAndWait +STAY @j+1 @j jsr $FDFD ; SMC call transition effect code @@ -293,36 +350,6 @@ ExecuteTransitionAndWait bit CLEARKBD + rts -;------------------------------------------------------------------------------ -; 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 or $4000..$5FFF cleared -; A = 0 -; X = 0 -; Y = 0 -; Z = 1 -;------------------------------------------------------------------------------ -ClearOffscreen - jsr GetOffscreenAddress - +HIDE_NEXT_2_BYTES -.ClearHGR1 - lda #$20 - sta @a+2 - ldx #$20 - lda #$80 - ldy #0 -@a sta $2000,y - iny - bne @a - inc @a+2 - dex - bne @a - rts - ;------------------------------------------------------------------------------ ; IsSearchKey ; test whether accumulator contains a key that might trigger a new textrank diff --git a/src/ui.search.mode.a b/src/ui.search.mode.a index 053a7476a..09791bb6a 100644 --- a/src/ui.search.mode.a +++ b/src/ui.search.mode.a @@ -24,11 +24,10 @@ SearchMode stx SelectedIndex ; $FF = no game selected inx stx OffscreenPage ; $00 = currently showing HGR page 2 - jsr Home ; clear screen + jsr Home ; clear screen (switches to text mode) jsr .OnInputChanged ; draw UI on HGR page 1 - +HGR_MODE ; show HGR + jsr HGRMode ; show HGR screen bit CLEARKBD - jsr ResetInputTimeout .SearchModeInputLoop jsr WaitForKeyFor30Seconds @@ -46,7 +45,7 @@ SearchMode @arrow ldx #kInputBrowse bne @InputDispatch ; always branches @notArrow - jsr ResetInputTimeout + bit CLEARKBD ldy #kNumBrowseKeys - dey