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