mirror of
https://github.com/a2-4am/4cade.git
synced 2025-01-02 22:31:17 +00:00
shave some bytes
This commit is contained in:
parent
c4ac4883dd
commit
89869a2d3d
@ -9,7 +9,7 @@
|
||||
; D000..E611 - persistent data structures (per-game cheat categories,
|
||||
; gGlobalPrefsStore, gGamesListStore)
|
||||
; ...unused...
|
||||
; EC5F..FFF9 - main program code
|
||||
; ECA6..FFF9 - main program code
|
||||
; FFFA..FFFF - NMI, reset, IRQ vectors
|
||||
;
|
||||
; LC RAM BANK 2
|
||||
@ -71,9 +71,6 @@ PTR = $02 ; word
|
||||
SRC = $04 ; word
|
||||
DEST = $06 ; word
|
||||
SAVE = $08 ; word
|
||||
KEYLEN = $0A ; byte
|
||||
VALUELEN = $0B ; byte
|
||||
MAX = $0C ; byte
|
||||
HTAB = $24 ; byte
|
||||
VTAB = $25 ; byte
|
||||
RNDSEED = $4E ; word
|
||||
|
@ -87,18 +87,8 @@ PlayGame
|
||||
+STAY SAVE
|
||||
+STAY @pfile ; assume we're loading a game-specific prelaunch file
|
||||
|
||||
jsr Home ; clear screen (clobbers $106, must do now before loading prelaunch code)
|
||||
lda #$20 ; clear both hi-res pages
|
||||
sta @clear+2 ; (in case game loader shows them, we don't want
|
||||
ldx #$40 ; to flash previous bits of the launcher UI)
|
||||
ldy #$00
|
||||
tya
|
||||
@clear sta $FD00,y ; SMC
|
||||
iny
|
||||
bne @clear
|
||||
inc @clear+2
|
||||
dex
|
||||
bne @clear
|
||||
jsr ClearScreens ; avoid seeing code load into the HGR page
|
||||
; (clobbers $106, must do now before loading prelaunch code)
|
||||
|
||||
jsr LoadFile ; load this game's prelaunch file at $106
|
||||
!word kPrelaunchDirectory
|
||||
|
38
src/okvs.a
38
src/okvs.a
@ -149,17 +149,16 @@ okvs_append
|
||||
ldy #0
|
||||
lda (SRC),y
|
||||
tay
|
||||
iny
|
||||
sty KEYLEN
|
||||
- dey ; copy new key
|
||||
lda (SRC),y
|
||||
tax
|
||||
- lda (SRC),y ; copy new key
|
||||
sta (PTR),y
|
||||
dey
|
||||
cpy #$FF
|
||||
bne -
|
||||
|
||||
lda PTR ; update PTR to byte after copied key
|
||||
clc
|
||||
adc KEYLEN
|
||||
sec
|
||||
txa
|
||||
adc PTR ; update PTR to byte after copied key
|
||||
sta PTR
|
||||
bcc +
|
||||
inc PTR+1
|
||||
@ -168,21 +167,22 @@ okvs_append
|
||||
+STAY SRC ; SRC -> new value to copy
|
||||
ldy #7
|
||||
lda (PARAM),y ; get max length of value
|
||||
tay
|
||||
tax
|
||||
bne +
|
||||
lda (SRC),y ; no max, use actual length instead
|
||||
tay
|
||||
iny
|
||||
+ sty VALUELEN
|
||||
- dey
|
||||
lda (SRC),y
|
||||
lda (SRC),y ; no max, use actual length instead
|
||||
tax
|
||||
inx
|
||||
+ tay
|
||||
- lda (SRC),y
|
||||
sta (PTR),y
|
||||
dey
|
||||
cpy #$FF
|
||||
bne -
|
||||
|
||||
lda PTR
|
||||
txa
|
||||
clc
|
||||
adc VALUELEN
|
||||
adc PTR
|
||||
sta SRC
|
||||
bcc +
|
||||
inc PTR+1
|
||||
@ -229,7 +229,7 @@ okvs_get
|
||||
; Y = 0
|
||||
lda (PTR),y ; A = number of keys in store
|
||||
beq @fail ; no keys, fail immediately
|
||||
sta MAX
|
||||
sta @max
|
||||
jsr incptr3
|
||||
; PTR -> first record
|
||||
ldx #0
|
||||
@ -255,7 +255,8 @@ okvs_get
|
||||
cmp (DEST),y
|
||||
bne @next
|
||||
iny
|
||||
cpy KEYLEN
|
||||
KEYLEN = *+1
|
||||
cpy #$D1 ; SMC
|
||||
bne @matchKeyLoop
|
||||
+LDAY PTR
|
||||
clc
|
||||
@ -271,7 +272,8 @@ okvs_get
|
||||
+ rts
|
||||
@next jsr derefptr ; PTR -> next record
|
||||
inx
|
||||
cpx MAX
|
||||
@max = *+1
|
||||
cpx #$D1 ; SMC
|
||||
bne @matchRecordLoop
|
||||
@fail sec
|
||||
rts
|
||||
|
@ -118,7 +118,6 @@ kSFXFizzleFile
|
||||
; Y contains high byte of address of length-prefixed string to append
|
||||
; out: all registers and flags clobbered
|
||||
; $02/$03 (PTR/PTR+1) clobbered
|
||||
; MAX clobbered
|
||||
; gPathname updated with concatenated length-prefixed string
|
||||
;------------------------------------------------------------------------------
|
||||
SetPath
|
||||
@ -133,14 +132,15 @@ AddToPath
|
||||
beq @done
|
||||
tay
|
||||
iny
|
||||
sty MAX
|
||||
sty @max
|
||||
ldx gPathname ; current pathname length
|
||||
ldy #$01
|
||||
- lda (PTR),y
|
||||
sta gPathname+1,x
|
||||
inx
|
||||
iny
|
||||
cpy MAX
|
||||
@max = *+1
|
||||
cpy #$D1 ; SMC
|
||||
bcc -
|
||||
stx gPathname
|
||||
@done
|
||||
|
@ -8,6 +8,9 @@
|
||||
|
||||
; /!\ execution falls through from ui.search.mode/FindMatchingTitle
|
||||
MaybeAnimateTitle
|
||||
jsr SwitchToBank2
|
||||
jsr DisableAcceleratorAndSwitchToBank1
|
||||
|
||||
; out: C clear
|
||||
lda #$3F
|
||||
ldy OffscreenPage
|
||||
|
@ -30,8 +30,7 @@ HGRSingle
|
||||
@fname !word $FDFD ; SMC
|
||||
!word $4000
|
||||
jsr LoadHGRTransition ; load transition effect code at $6000
|
||||
+LDADDR $6000
|
||||
jmp ExecuteTransitionAndWait
|
||||
jmp .transition
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; LoadHGRTransition [private]
|
||||
@ -100,8 +99,7 @@ HGRTitleCallback
|
||||
+ !word $FDFD ; SMC
|
||||
!word $4000
|
||||
|
||||
+LDADDR $6000
|
||||
jmp ExecuteTransitionAndWait
|
||||
jmp .transition
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; HGRActionCallback [private]
|
||||
@ -160,6 +158,7 @@ HGRActionCallback
|
||||
lda #3 ; solid vertical bar character
|
||||
jsr @drawline
|
||||
|
||||
.transition
|
||||
+LDADDR $6000
|
||||
jmp ExecuteTransitionAndWait
|
||||
@resetline
|
||||
|
@ -143,7 +143,8 @@ RunAttractModule
|
||||
beq +
|
||||
stx gGameToLaunch
|
||||
+
|
||||
jsr Home ; avoid seeing code load into the HGR page
|
||||
jsr ClearScreens ; avoid seeing code load into the HGR page
|
||||
; (clobbers $106, must do now before loading prelaunch code)
|
||||
|
||||
jsr LoadFile ; load standard prelaunch code (|Launch| will call it)
|
||||
!word kPrelaunchDirectory
|
||||
|
@ -110,16 +110,8 @@ BlankSHR
|
||||
sta SHADOW
|
||||
|
||||
lda #$20 ; clear $2000..$9FFF in auxmem
|
||||
sta @a+2
|
||||
ldx #$80
|
||||
lda #0
|
||||
tay
|
||||
@a sta $2000,y
|
||||
iny
|
||||
bne @a
|
||||
inc @a+2
|
||||
dex
|
||||
bne @a
|
||||
jsr ClearMem
|
||||
|
||||
sta WRITEMAINMEM ; writes go to main memory
|
||||
|
||||
|
@ -70,25 +70,26 @@ OnBrowseSearch
|
||||
jmp SearchMode
|
||||
|
||||
OnBrowsePrevious
|
||||
dec gGameToLaunch
|
||||
jmp +
|
||||
OnBrowseNext
|
||||
inc gGameToLaunch
|
||||
+
|
||||
ldx gGameToLaunch
|
||||
cpx #$FF
|
||||
bne @notTooSmall
|
||||
GameCount = *+1
|
||||
ldx #$D1 ; SMC
|
||||
bne .decindex
|
||||
ldx GameCount
|
||||
|
||||
.decindex
|
||||
dex
|
||||
bne @done ; always branches
|
||||
@notTooSmall
|
||||
cpx GameCount
|
||||
bcc @done
|
||||
ldx #0
|
||||
@done stx gGameToLaunch
|
||||
|
||||
.setindex
|
||||
stx gGameToLaunch
|
||||
jmp OnBrowseChanged
|
||||
|
||||
OnBrowseNext
|
||||
ldx gGameToLaunch
|
||||
inx
|
||||
GameCount = *+1
|
||||
cpx #$D1 ; SMC
|
||||
bne .setindex
|
||||
ldx #0
|
||||
beq .setindex ; branch always
|
||||
|
||||
OnBrowseLaunch
|
||||
jsr PlayGame
|
||||
jsr BlankHGR
|
||||
@ -112,8 +113,6 @@ OnBrowseChanged
|
||||
jsr EnableAcceleratorAndSwitchToBank1
|
||||
jsr LoadGameTitleOffscreen
|
||||
jsr DrawUIWithoutDots
|
||||
jsr SwitchToBank2
|
||||
jsr DisableAcceleratorAndSwitchToBank1
|
||||
jmp MaybeAnimateTitle
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
@ -4,12 +4,36 @@
|
||||
; miscellaneous UI functions
|
||||
;
|
||||
; Public functions
|
||||
; - ClearScreens
|
||||
; - Home
|
||||
; - BlankDHGR
|
||||
; - IsSearchKey
|
||||
; - IsUpDownOrRightArrow
|
||||
;
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; ClearScreens
|
||||
; clear and display text screen and then clear both hires screens
|
||||
; (in this order so that the erasing isn't visible)
|
||||
;
|
||||
; in: none
|
||||
; out: $0106..$011F clobbered
|
||||
;------------------------------------------------------------------------------
|
||||
ClearScreens
|
||||
jsr Home
|
||||
lda #$20 ; clear both hi-res pages
|
||||
sta @clear+2 ; (in case game loader shows them, we don't want
|
||||
ldx #$40 ; to flash previous bits of the launcher UI)
|
||||
ldy #$00
|
||||
tya
|
||||
@clear sta $FD00,y ; SMC
|
||||
iny
|
||||
bne @clear
|
||||
inc @clear+2
|
||||
dex
|
||||
bne @clear
|
||||
rts
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Home
|
||||
; clear and display text screen (HARDER THAN IT SOUNDS)
|
||||
@ -75,7 +99,7 @@ BlankDHGR
|
||||
; out: A &= 0x7F
|
||||
; Y preserved
|
||||
; X clobbered
|
||||
; Z = 1 if this is a search key
|
||||
; Z = 1 and C = 0 if this is a search key
|
||||
; Z = 0 if this is not a search key
|
||||
;------------------------------------------------------------------------------
|
||||
IsSearchKey
|
||||
|
@ -38,5 +38,5 @@ Help
|
||||
jsr IsUpDownOrRightArrow
|
||||
beq -
|
||||
jsr IsSearchKey
|
||||
beq -
|
||||
bne --
|
||||
rts
|
||||
|
@ -13,6 +13,7 @@
|
||||
; - ToggleOffscreenPage
|
||||
; - ClearOffscreen
|
||||
; - ClearHGR1
|
||||
; - ClearMem
|
||||
;
|
||||
; Public variables
|
||||
; - OffscreenPage
|
||||
@ -27,16 +28,14 @@
|
||||
; preserves X/Y
|
||||
;------------------------------------------------------------------------------
|
||||
GetOffscreenAddress
|
||||
lda #$40
|
||||
OffscreenPage = * + 1
|
||||
lda #$00 ; SMC
|
||||
bne + ; SMC
|
||||
; 0 = currently showing HGR page 2
|
||||
; (so offscreen is page 1 @ $2000)
|
||||
; 1 = currently showing HGR page 1
|
||||
; (so offscreen is page 2 @ $4000)
|
||||
beq +
|
||||
lda #$40
|
||||
rts
|
||||
+ lda #$20
|
||||
+ lsr
|
||||
rts
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
@ -113,8 +112,9 @@ ClearOffscreen
|
||||
+HIDE_NEXT_2_BYTES
|
||||
ClearHGR1
|
||||
lda #$20 ; note to self: LDX #$20 can't move here
|
||||
sta @a+2
|
||||
ldx #$20
|
||||
ClearMem
|
||||
sta @a+2
|
||||
lda #$80
|
||||
ldy #0
|
||||
@a sta $2000,y
|
||||
|
@ -91,27 +91,26 @@ DrawUI
|
||||
bpl -
|
||||
|
||||
ldx gGameToLaunch
|
||||
cpx #$FF ; if no game, nothing more to do on UI line 2
|
||||
inx ; if no game, nothing more to do on UI line 2
|
||||
beq @doneWithLine2
|
||||
|
||||
jsr GetGameToLaunch
|
||||
jsr okvs_get_current
|
||||
; (PTR) -> game title
|
||||
ldy #0 ; copy game title into UI line 2
|
||||
lda (PTR),y
|
||||
lda (PTR),y ; copy game title into UI line 2
|
||||
sta SAVE ; title length
|
||||
inc SAVE
|
||||
- iny
|
||||
cpy SAVE
|
||||
bcc @printTitleChar
|
||||
beq @printCursor
|
||||
lda #" "
|
||||
+HIDE_NEXT_2_BYTES
|
||||
@printCursor
|
||||
lda #$FD ; SMC
|
||||
cpy SAVE
|
||||
bcc @printTitleChar
|
||||
beq @printChar
|
||||
lda #" "
|
||||
+HIDE_NEXT_2_BYTES
|
||||
@printTitleChar
|
||||
lda (PTR),y
|
||||
@printChar
|
||||
sta UILine2,y
|
||||
cpy #MaxInputLength+1
|
||||
bcc -
|
||||
@ -127,16 +126,7 @@ DrawUI
|
||||
and #CHEATS_ENABLED
|
||||
beq @maybeDrawDots ; if cheat mode is disabled, we don't need
|
||||
; any curves or spaces on UI line 1
|
||||
ldx gGameToLaunch
|
||||
ldy gCheatsAvailable,x
|
||||
cpx #$FF
|
||||
bne +
|
||||
ldy #kCheatsEnabled
|
||||
+
|
||||
lda kCheatDescriptionLo,y
|
||||
sta SAVE
|
||||
lda kCheatDescriptionHi,y
|
||||
sta SAVE+1
|
||||
jsr CheckCheats
|
||||
; (SAVE) -> length-prefixed string
|
||||
; (game-specific description or 'cheats enabled' message)
|
||||
ldy #0
|
||||
@ -171,7 +161,7 @@ DrawUI
|
||||
@dotloop
|
||||
iny
|
||||
lda (PTR),y ; (PTR) still points to game title
|
||||
+LOW_ASCII_TO_LOWER
|
||||
ora #$20 ; force lower-case always
|
||||
cmp InputBuffer,x
|
||||
bne +
|
||||
lda #$11 ; dot character
|
||||
@ -218,15 +208,7 @@ DrawUI
|
||||
+LDADDR gPathname
|
||||
jsr DrawCenteredString ; draw cheat UI line 1
|
||||
|
||||
ldx gGameToLaunch
|
||||
ldy gCheatsAvailable,x
|
||||
cpx #$FF
|
||||
bne +
|
||||
ldy #kCheatsEnabled
|
||||
+ lda kCheatDescriptionLo,y
|
||||
sta SAVE
|
||||
lda kCheatDescriptionHi,y
|
||||
sta SAVE+1
|
||||
jsr CheckCheats
|
||||
; (SAVE) -> length-prefixed cheat description
|
||||
+LDADDR sCheatDescriptionPrefix
|
||||
jsr SetPath
|
||||
@ -240,3 +222,16 @@ DrawUI
|
||||
jsr DrawCenteredString ; draw cheat UI line 2
|
||||
|
||||
@uidone jmp ShowOtherPage
|
||||
|
||||
CheckCheats
|
||||
ldy #kCheatsEnabled
|
||||
ldx gGameToLaunch
|
||||
inx
|
||||
beq +
|
||||
ldy gCheatsAvailable,x
|
||||
+
|
||||
lda kCheatDescriptionLo,y
|
||||
sta SAVE
|
||||
lda kCheatDescriptionHi,y
|
||||
sta SAVE+1
|
||||
rts
|
||||
|
@ -149,7 +149,7 @@ OnBack
|
||||
|
||||
OnTab
|
||||
ldx gGameToLaunch
|
||||
cpx #$FF
|
||||
inx
|
||||
beq OnError
|
||||
jsr MiniAttractMode
|
||||
cmp #$8D ; if we exited mini attract mode
|
||||
@ -157,7 +157,7 @@ OnTab
|
||||
|
||||
OnLaunch
|
||||
ldx gGameToLaunch
|
||||
cpx #$FF
|
||||
inx
|
||||
beq OnError
|
||||
jsr PlayGame
|
||||
|
||||
@ -178,10 +178,10 @@ OnSearch
|
||||
inc InputLength
|
||||
; execution falls through here to OnInputChanged
|
||||
OnInputChanged
|
||||
lda InputLength
|
||||
ldx InputLength
|
||||
bne FindMatchingTitle
|
||||
; no input, reset params and UI
|
||||
ldx #$FF
|
||||
dex
|
||||
stx gGameToLaunch ; no game selected
|
||||
jsr LoadTitleOffscreen
|
||||
jsr DrawUIWithoutDots
|
||||
@ -243,14 +243,12 @@ SoftBell
|
||||
+
|
||||
ldx BestMatchIndex ; check if the new best match is the same
|
||||
cpx gGameToLaunch ; as the current best match
|
||||
stx gGameToLaunch
|
||||
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 @noload ; (always branches)
|
||||
+ jsr LoadGameTitleOffscreen
|
||||
+ stx gGameToLaunch
|
||||
jsr LoadGameTitleOffscreen
|
||||
@noload jsr DrawUI
|
||||
jsr SwitchToBank2
|
||||
jsr DisableAcceleratorAndSwitchToBank1
|
||||
; /!\ execution falls through to ui.animation/MaybeAnimateTitle
|
||||
|
Loading…
Reference in New Issue
Block a user