mirror of
https://github.com/a2-4am/4cade.git
synced 2024-12-25 13:33:13 +00:00
shave some bytes, add some comments
This commit is contained in:
parent
f40c8ebae6
commit
308fdea6d0
@ -81,6 +81,7 @@ RestoreStackNextTime
|
|||||||
!source "src/parse.common.a"
|
!source "src/parse.common.a"
|
||||||
!source "src/parse.prefs.a"
|
!source "src/parse.prefs.a"
|
||||||
!source "src/ui.font.a"
|
!source "src/ui.font.a"
|
||||||
|
; add new files above here so ui.common stays last
|
||||||
!source "src/ui.common.a"
|
!source "src/ui.common.a"
|
||||||
MachineStatus
|
MachineStatus
|
||||||
!byte 0
|
!byte 0
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
; D000..E4E9 - persistent data structures (gGlobalPrefsStore, gGamesListStore)
|
; D000..E4E9 - persistent data structures (gGlobalPrefsStore, gGamesListStore)
|
||||||
; ...end of data and start of code are approximate, in between is unused...
|
; ...end of data and start of code are approximate, in between is unused...
|
||||||
; ...if they ever overlap, things will go boom...
|
; ...if they ever overlap, things will go boom...
|
||||||
; E9C4..FFF9 - main program code
|
; E9C9..FFF9 - main program code
|
||||||
; FFFA..FFFF - NMI, reset, IRQ vectors
|
; FFFA..FFFF - NMI, reset, IRQ vectors
|
||||||
;
|
;
|
||||||
; LC RAM BANK 2
|
; LC RAM BANK 2
|
||||||
|
122
src/ui.common.a
122
src/ui.common.a
@ -58,10 +58,15 @@ ReturnToPlay
|
|||||||
!byte $0D
|
!byte $0D
|
||||||
!text " to play"
|
!text " to play"
|
||||||
|
|
||||||
GetOffscreenAddress
|
;------------------------------------------------------------------------------
|
||||||
|
; GetOffscreenAddress
|
||||||
|
; get high byte of HGR page that is currently not showing
|
||||||
|
;
|
||||||
; in: none
|
; in: none
|
||||||
; out: A = high byte of offscreen HGR page (#$20 or #$40)
|
; out: A = high byte of offscreen HGR page (#$20 or #$40)
|
||||||
; preserves X/Y
|
; preserves X/Y
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
GetOffscreenAddress
|
||||||
lda OffscreenPage
|
lda OffscreenPage
|
||||||
beq +
|
beq +
|
||||||
lda #$40
|
lda #$40
|
||||||
@ -69,12 +74,26 @@ GetOffscreenAddress
|
|||||||
+ lda #$20
|
+ lda #$20
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
; LoadTitleOffscreen
|
||||||
|
; load title screen in the HGR page that is currently not showing
|
||||||
|
;
|
||||||
|
; in: none
|
||||||
|
; out: all flags and registers clobbered
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
LoadTitleOffscreen
|
LoadTitleOffscreen
|
||||||
; clobbers all
|
|
||||||
+LDADDR .TitleFile
|
+LDADDR .TitleFile
|
||||||
bne + ; Always branches, because Y is loaded
|
bne + ; Always branches, because Y is loaded
|
||||||
; last with the high byte of the address,
|
; last with the high byte of the address,
|
||||||
; which is never 0. I miss my 65c02.
|
; which is never 0. I miss my 65c02.
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
; LoadCoverOffscreen
|
||||||
|
; load cover screen in the HGR page that is currently not showing
|
||||||
|
;
|
||||||
|
; in: none
|
||||||
|
; out: all flags and registers clobbered
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
LoadCoverOffscreen
|
LoadCoverOffscreen
|
||||||
; clobbers all
|
; clobbers all
|
||||||
+LDADDR .CoverFile
|
+LDADDR .CoverFile
|
||||||
@ -95,8 +114,14 @@ LoadCoverOffscreen
|
|||||||
!byte 5
|
!byte 5
|
||||||
!text "COVER"
|
!text "COVER"
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
; CoverFade
|
||||||
|
; load cover screen and animate per-character fade
|
||||||
|
;
|
||||||
|
; in: none
|
||||||
|
; out: all flags and registers clobbered
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
CoverFade
|
CoverFade
|
||||||
; clobbers all
|
|
||||||
jsr LoadCoverOffscreen
|
jsr LoadCoverOffscreen
|
||||||
jsr ShowOtherPage
|
jsr ShowOtherPage
|
||||||
lda OffscreenPage
|
lda OffscreenPage
|
||||||
@ -113,8 +138,14 @@ CoverFade
|
|||||||
!byte 9
|
!byte 9
|
||||||
!text "COVERFADE"
|
!text "COVERFADE"
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
; DrawSearchBarOffscreen
|
||||||
|
; draw 2-line search UI on the HGR page that is not currently showing
|
||||||
|
;
|
||||||
|
; in: none
|
||||||
|
; out: all flags and registers clobbered
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
DrawSearchBarOffscreen
|
DrawSearchBarOffscreen
|
||||||
; clobbers all
|
|
||||||
LDA #22 ; draw visible search bar
|
LDA #22 ; draw visible search bar
|
||||||
sta VTAB
|
sta VTAB
|
||||||
lda OffscreenPage
|
lda OffscreenPage
|
||||||
@ -156,10 +187,15 @@ ClearOffscreen
|
|||||||
bne @a
|
bne @a
|
||||||
rts
|
rts
|
||||||
|
|
||||||
ShowOtherPage
|
;------------------------------------------------------------------------------
|
||||||
|
; ShowOtherPage
|
||||||
|
; switch to the HGR page that is not currently showing
|
||||||
|
;
|
||||||
; in: none
|
; in: none
|
||||||
; out: A = new value of OffscreenPage
|
; out: A = new value of OffscreenPage
|
||||||
; preserves X/Y
|
; preserves X/Y
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
ShowOtherPage
|
||||||
jsr ToggleOffscreenPage
|
jsr ToggleOffscreenPage
|
||||||
bne +
|
bne +
|
||||||
bit PAGE2 ; show page 2
|
bit PAGE2 ; show page 2
|
||||||
@ -167,50 +203,21 @@ ShowOtherPage
|
|||||||
+ bit PAGE1 ; show page 1
|
+ bit PAGE1 ; show page 1
|
||||||
rts
|
rts
|
||||||
|
|
||||||
ToggleOffscreenPage
|
;------------------------------------------------------------------------------
|
||||||
|
; ToggleOffscreenPage
|
||||||
|
; switch the internal variable that tracks which HGR page is showing
|
||||||
|
; (does not affect screen)
|
||||||
|
;
|
||||||
; in: none
|
; in: none
|
||||||
; out: A = new value of OffscreenPage
|
; out: A = new value of OffscreenPage
|
||||||
; preserves X/Y
|
; preserves X/Y
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
ToggleOffscreenPage
|
||||||
lda OffscreenPage
|
lda OffscreenPage
|
||||||
eor #$01
|
eor #$01
|
||||||
sta OffscreenPage
|
sta OffscreenPage
|
||||||
rts
|
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
|
|
||||||
|
|
||||||
inc RNDSEED+1 ; these are only ever incremented, never
|
|
||||||
bne + ; reset (may be used as a pseudorandom
|
|
||||||
inc RNDSEED ; seed)
|
|
||||||
+
|
|
||||||
dec Timeout ; these are a 3-byte timeout counter
|
|
||||||
bne @loop ; that counts down from a number set
|
|
||||||
dec Timeout+1 ; in .ResetInputTimeout and reset
|
|
||||||
bne @loop ; on every keypress (whether or not
|
|
||||||
dec Timeout+2 ; the key leads to an action)
|
|
||||||
bne @loop
|
|
||||||
jsr CoverFade ; no input for ~30 seconds, switch to
|
|
||||||
jmp MegaAttractMode ; mega-attract mode
|
|
||||||
@gotKey rts
|
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; SoftBell
|
; SoftBell
|
||||||
; yell at the user, but, like, gently
|
; yell at the user, but, like, gently
|
||||||
@ -386,4 +393,37 @@ IsSearchKey
|
|||||||
ldx #0
|
ldx #0
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
; /!\ keep this last in the file to ensure it doesn't cross a page boundary /!\
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
; 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 #$16 ; initialize timeout counters
|
||||||
|
sta Timeout
|
||||||
|
sta Timeout+1
|
||||||
|
sta Timeout+2
|
||||||
|
@loop
|
||||||
|
lda KBD
|
||||||
|
bmi @gotKey
|
||||||
|
|
||||||
|
inc RNDSEED+1 ; these are only ever incremented, never
|
||||||
|
bne + ; reset (may be used as a pseudorandom
|
||||||
|
inc RNDSEED ; seed)
|
||||||
|
+
|
||||||
|
dec Timeout ; these are a 3-byte timeout counter
|
||||||
|
bne @loop ; that counts down from a number set
|
||||||
|
dec Timeout+1 ; in .ResetInputTimeout and reset
|
||||||
|
bne @loop ; on every keypress (whether or not
|
||||||
|
dec Timeout+2 ; the key leads to an action)
|
||||||
|
bne @loop
|
||||||
|
jsr CoverFade ; no input for ~30 seconds, switch to
|
||||||
|
jmp MegaAttractMode ; mega-attract mode
|
||||||
|
@gotKey rts
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user