mirror of
https://github.com/a2-4am/4cade.git
synced 2024-11-27 08:50:01 +00:00
shave some bytes
This commit is contained in:
parent
7fe893d48a
commit
0c03da8599
15
src/4cade.a
15
src/4cade.a
@ -41,6 +41,8 @@ FirstMover
|
||||
Reenter
|
||||
cld
|
||||
cli
|
||||
ldx #$ff
|
||||
txs ; so that we never trash the reset vector
|
||||
jsr SwitchToBank2
|
||||
jsr DisableAccelerator ; back to 1 MHz (especially important on IIgs
|
||||
; which restores default speed on Ctrl-Reset)
|
||||
@ -67,11 +69,12 @@ RestoreStackNextTime
|
||||
sta RestoreStackNextTime + 1
|
||||
; restore the same stack twice
|
||||
ldx #$F1
|
||||
- lda STACKBASE - $F0,x ; restore stack
|
||||
- lda STACKBASE - $EF,x ; restore stack
|
||||
sta $100,x
|
||||
inx
|
||||
bne -
|
||||
ldx STACKBASE ; restore stack pointer
|
||||
STACKPTR
|
||||
ldx #$D1 ; SMC, restore stack pointer
|
||||
txs
|
||||
SwitchToBank1
|
||||
+READ_RAM1_WRITE_RAM1
|
||||
@ -144,12 +147,12 @@ SwitchToBank2
|
||||
!word Ignore ; IRQ vector ($FFFE-F)
|
||||
}
|
||||
LastMover
|
||||
!if ((hdddataend & 255) > $ec) and ((hdddataend & 255) < $f0) {
|
||||
!if ((hdddataend & 255) > $ec) and ((hdddataend & 255) < $f2) {
|
||||
; in the unlikely event that a bit over 16 bytes are left in the page
|
||||
; then use it for the stack
|
||||
STACKBASE = (hdddataend + 15) and -16
|
||||
STACKBASE = ((hdddataend + 15) and -16) + 1
|
||||
FONTSRC = *
|
||||
!pseudopc STACKBASE + 16 {
|
||||
!pseudopc STACKBASE + 15 {
|
||||
FONTDST = *
|
||||
!source "src/ui.font.data.lc2.a"
|
||||
COPYDST = *
|
||||
@ -177,7 +180,7 @@ EvenLasterMover
|
||||
!source "src/glue.launch.lc2.a"
|
||||
!source "src/hw.accel.lc2.a"
|
||||
STACKBASE = *
|
||||
LCRAM2_END = STACKBASE + 16
|
||||
LCRAM2_END = STACKBASE + 15
|
||||
FONTDST = (LCRAM2_END + 255) and -256
|
||||
}
|
||||
EvenLasterMover
|
||||
|
@ -9,14 +9,14 @@
|
||||
; D000..E635 - persistent data structures (per-game cheat categories,
|
||||
; gGlobalPrefsStore, gGamesListStore)
|
||||
; ...unused...
|
||||
; ECC6..FFF9 - main program code
|
||||
; ECF3..FFF9 - main program code
|
||||
; FFFA..FFFF - NMI, reset, IRQ vectors
|
||||
;
|
||||
; LC RAM BANK 2
|
||||
; D000..D3FF - ProRWTS data
|
||||
; D400..D671 - ProRWTS code
|
||||
; D672..DB6D - HGR font code & ProRWTS glue code
|
||||
; DB6E..DB7D - backup of stack (during gameplay and self-running demos)
|
||||
; D400..D66F - ProRWTS code
|
||||
; D670..DB6B - HGR font code & ProRWTS glue code
|
||||
; DB6B..DB79 - backup of stack (during gameplay and self-running demos)
|
||||
; ...unused...
|
||||
; DBB2..DBFF - (de)acceleration function
|
||||
; DC00..DFFF - HGR font data
|
||||
|
@ -128,7 +128,7 @@ PlayGame
|
||||
; and then finds the subdirectory name and game name right after it
|
||||
; and attaches it to the path by overwriting the count byte
|
||||
|
||||
sec
|
||||
;;sec ; carry set by AddToPath
|
||||
lda gPathname
|
||||
sbc #kGameDirectoryLen
|
||||
sta gPathname+kGameDirectoryLen
|
||||
|
@ -10,11 +10,11 @@
|
||||
LaunchInternal
|
||||
ldy #$F1
|
||||
- lda $100,y
|
||||
sta STACKBASE - $F0,y ; back up stack
|
||||
sta STACKBASE - $EF,y ; back up stack
|
||||
iny
|
||||
bne -
|
||||
tsx ; back up stack pointer
|
||||
stx STACKBASE
|
||||
stx STACKPTR + 1
|
||||
sty RestoreStackNextTime + 1
|
||||
; tell |Reenter| to restore the stack and stack pointer
|
||||
|
||||
|
@ -52,8 +52,7 @@ LoadFile
|
||||
jsr SetPath
|
||||
+LDPARAM 3
|
||||
jsr AddToPath
|
||||
+LDPARAM 5
|
||||
+STAY ldrlo ; set load address
|
||||
+LDPARAMPTR 5, ldrlo ; set load address
|
||||
jsr SwitchToBank2
|
||||
jsr LoadFileInternal
|
||||
jmp SwitchToBank1
|
||||
|
@ -251,37 +251,24 @@ iicplus !pseudopc DisableAccelerator {
|
||||
|
||||
; cgga calls save X and Y regs but sets $0 to 0
|
||||
; (this will get a laugh from C programmers)
|
||||
ldx $0
|
||||
!cpu 65c02
|
||||
phx
|
||||
!cpu 6502
|
||||
lda $0
|
||||
pha
|
||||
|
||||
ldy #(@endpokery - @jiggery) - 1
|
||||
@copyiicp
|
||||
lda @jiggery,y
|
||||
sta $106, y
|
||||
dey
|
||||
bpl @copyiicp
|
||||
|
||||
php
|
||||
sei ; timing sensitive
|
||||
jsr @jiggerypokery
|
||||
jsr $106
|
||||
plp ; restore interrupt state
|
||||
pla
|
||||
sta $0
|
||||
rts
|
||||
|
||||
@jiggerypokery
|
||||
tsx
|
||||
ldy #(@endpokery - @jiggery)
|
||||
@copyiicp
|
||||
lda @jiggery-1,y
|
||||
pha
|
||||
dey
|
||||
bne @copyiicp
|
||||
txa
|
||||
tsx
|
||||
iny
|
||||
!cpu 65c02
|
||||
phy
|
||||
phx
|
||||
!cpu 6502
|
||||
tax
|
||||
rts
|
||||
|
||||
@jiggery
|
||||
+READ_ROM_NO_WRITE
|
||||
lda #CGGA_UNLOCK ; unlock to change
|
||||
@ -296,7 +283,6 @@ iicplus !pseudopc DisableAccelerator {
|
||||
lda #CGGA_LOCK ; should lock after a change
|
||||
pha
|
||||
jsr cgga ; reads parm from stack, must JSR
|
||||
txs
|
||||
+READ_RAM2_WRITE_RAM2
|
||||
rts
|
||||
@endpokery
|
||||
@ -385,4 +371,4 @@ FASTChip
|
||||
|
||||
plp ; restore interrupt state
|
||||
rts
|
||||
end_addon
|
||||
end_addon
|
||||
|
13
src/macros.a
13
src/macros.a
@ -39,6 +39,19 @@
|
||||
pla
|
||||
}
|
||||
|
||||
; for functions that take parameters on the stack
|
||||
; load a 16-bit value from the parameters on the stack into A (low) and Y (high)
|
||||
; then store it as new source
|
||||
; (assumes PARAMS_ON_STACK was used first)
|
||||
!macro LDPARAMPTR .offset,.dest {
|
||||
ldy #.offset
|
||||
lda (PARAM),y
|
||||
sta .dest
|
||||
iny
|
||||
lda (PARAM),y
|
||||
sta .dest+1
|
||||
}
|
||||
|
||||
; load the address of .ptr into A (low) and Y (high)
|
||||
!macro LDADDR .ptr {
|
||||
lda #<.ptr
|
||||
|
@ -144,8 +144,7 @@ okvs_append
|
||||
; SAVE -> new record
|
||||
jsr incptr2
|
||||
; PTR -> space for new key
|
||||
+LDPARAM 3
|
||||
+STAY SRC ; SRC -> new key to copy
|
||||
+LDPARAMPTR 3, SRC ; SRC -> new key to copy
|
||||
ldy #0
|
||||
lda (SRC),y
|
||||
tay
|
||||
@ -163,8 +162,7 @@ okvs_append
|
||||
bcc +
|
||||
inc PTR+1
|
||||
+ ; PTR -> space for new value
|
||||
+LDPARAM 5
|
||||
+STAY SRC ; SRC -> new value to copy
|
||||
+LDPARAMPTR 5, SRC ; SRC -> new value to copy
|
||||
ldy #7
|
||||
lda (PARAM),y ; get max length of value
|
||||
tax
|
||||
@ -233,8 +231,7 @@ okvs_get
|
||||
jsr incptr3
|
||||
; PTR -> first record
|
||||
ldx #0
|
||||
+LDPARAM 3
|
||||
+STAY SRC ; SRC -> key we want to find
|
||||
+LDPARAMPTR 3, SRC ; SRC -> key we want to find
|
||||
ldy #0
|
||||
lda (SRC),y
|
||||
tay
|
||||
|
@ -103,19 +103,17 @@ ParseKeyValueList
|
||||
SetKeyPtr
|
||||
jsr okvs_init ; reset key/value store
|
||||
|
||||
+LDPARAM 3
|
||||
+STAY $FE
|
||||
+LDPARAMPTR 3, $FE
|
||||
|
||||
ldy #1
|
||||
ldy #0
|
||||
lda ($FE),y
|
||||
tax
|
||||
dey
|
||||
lda ($FE),y
|
||||
bne +
|
||||
dex
|
||||
stx $FF
|
||||
+ tax
|
||||
dex
|
||||
iny
|
||||
lda ($FE),y
|
||||
sta $FF
|
||||
dec $FF
|
||||
+ dex
|
||||
stx $FE
|
||||
rts
|
||||
|
||||
|
@ -113,10 +113,8 @@ PREFRTS rts
|
||||
;------------------------------------------------------------------------------
|
||||
pref_get
|
||||
+PARAMS_ON_STACK 4
|
||||
+LDPARAM 1
|
||||
+STAY +
|
||||
+LDPARAM 3
|
||||
+STAY .store1
|
||||
+LDPARAMPTR 1, +
|
||||
+LDPARAMPTR 3, .store1
|
||||
|
||||
jsr okvs_get ; look up pref key in prefs store
|
||||
!word gGlobalPrefsStore
|
||||
@ -154,10 +152,8 @@ pref_get
|
||||
;------------------------------------------------------------------------------
|
||||
pref_set
|
||||
+PARAMS_ON_STACK 4
|
||||
+LDPARAM 1
|
||||
+STAY +
|
||||
+LDPARAM 3
|
||||
+STAY ++
|
||||
+LDPARAMPTR 1, +
|
||||
+LDPARAMPTR 3, ++
|
||||
|
||||
jsr okvs_update ; save that in prefs store
|
||||
!word gGlobalPrefsStore
|
||||
|
@ -98,6 +98,7 @@ BlankHGR
|
||||
;------------------------------------------------------------------------------
|
||||
HGRMode
|
||||
bit $C057
|
||||
GRMode
|
||||
bit $C052
|
||||
bit $C050
|
||||
DHGRRTS rts
|
||||
|
@ -64,9 +64,7 @@ BlankGR
|
||||
bne @loop
|
||||
bit PAGE1
|
||||
bit $C056 ; set GR mode
|
||||
bit $C052
|
||||
bit $C050
|
||||
rts
|
||||
jmp GRMode
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; .LoadGRTransition [private]
|
||||
|
@ -33,7 +33,7 @@ kBrowseLaunch = 5
|
||||
kBrowseHelp = 6
|
||||
kBrowseCredits = 7
|
||||
kBrowseCheat = 8
|
||||
kSoftBell = 9
|
||||
kSoftBell = 9 ; must match kInputError
|
||||
|
||||
ldy #kNumBrowseKeys
|
||||
- dey
|
||||
@ -45,15 +45,9 @@ kSoftBell = 9
|
||||
|
||||
@noKeyMatch
|
||||
jsr IsSearchKey
|
||||
beq +
|
||||
ldx #kSoftBell ; beep on invalid input
|
||||
!if kBrowseSearch > 0 {
|
||||
+HIDE_NEXT_2_BYTES
|
||||
+
|
||||
bne @BrowseDispatch
|
||||
ldx #kBrowseSearch
|
||||
} else {
|
||||
+
|
||||
}
|
||||
|
||||
; execution falls through here
|
||||
@BrowseDispatch
|
||||
ldy BrowseDispatchTableLo,x
|
||||
|
@ -125,7 +125,7 @@ IsSearchKey
|
||||
cmp #$7B ; lowercase letters are good input
|
||||
bcc @goodkey
|
||||
@badkey
|
||||
ldx #1
|
||||
ldx #kInputError ; also #kSoftBell
|
||||
rts
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
|
@ -141,7 +141,7 @@ DrawUI
|
||||
tax
|
||||
lda #$09 ; rounded bottom-right character
|
||||
sta UILine1,x
|
||||
ldy #1 ; fill the proper width with spaces
|
||||
iny ; fill the proper width with spaces
|
||||
lda #$20 ; space character
|
||||
- inx
|
||||
sta UILine1,x
|
||||
@ -221,14 +221,15 @@ DrawUI
|
||||
+LDADDR gPathname
|
||||
jsr DrawCenteredString ; draw cheat UI line 2
|
||||
|
||||
@uidone jmp ShowOtherPage
|
||||
@uidone clc
|
||||
jmp ShowOtherPage
|
||||
|
||||
CheckCheats
|
||||
ldy #kCheatsEnabled
|
||||
ldx gGameToLaunch
|
||||
cpx #$FF
|
||||
inx
|
||||
beq +
|
||||
ldy gCheatsAvailable,x
|
||||
ldy gCheatsAvailable-1,x
|
||||
+
|
||||
lda kCheatDescriptionLo,y
|
||||
sta SAVE
|
||||
|
@ -71,8 +71,6 @@ InputKeyDispatch
|
||||
|
||||
.noKeyMatch
|
||||
jsr IsSearchKey
|
||||
beq .foundSearchKey
|
||||
ldx #kInputError
|
||||
!if kInputSearch > 0 {
|
||||
+HIDE_NEXT_2_BYTES
|
||||
.foundSearchKey
|
||||
@ -108,8 +106,8 @@ SearchMode
|
||||
jsr ResyncPage
|
||||
lda KBD
|
||||
jsr IsSearchKey
|
||||
beq .SearchModeInputLoop
|
||||
bit CLEARKBD
|
||||
lda CLEARKBD - kInputError,X
|
||||
; clear strobe if key was bad
|
||||
|
||||
.SearchModeInputLoop
|
||||
jsr WaitForKeyFor30Seconds
|
||||
@ -181,9 +179,7 @@ OnInputChanged
|
||||
dex
|
||||
stx gGameToLaunch ; no game selected
|
||||
jsr LoadTitleOffscreen
|
||||
jsr DrawUIWithoutDots
|
||||
clc
|
||||
rts
|
||||
jmp DrawUIWithoutDots
|
||||
|
||||
FindMatchingTitle
|
||||
jsr SwitchToBank2
|
||||
|
@ -84,10 +84,8 @@ CoverFade
|
||||
jsr LoadCoverOffscreen
|
||||
jsr ShowOtherPage
|
||||
lda OffscreenPage
|
||||
bne +
|
||||
jsr LoadCoverOffscreen
|
||||
jsr ShowOtherPage
|
||||
+ jsr LoadFile ; load transition effect code at $6000
|
||||
beq CoverFade
|
||||
jsr LoadFile ; load transition effect code at $6000
|
||||
!word kFXDirectory
|
||||
!word kCoverFadeFile
|
||||
!word $6000
|
||||
|
Loading…
Reference in New Issue
Block a user