shave some bytes

This commit is contained in:
Peter Ferrie 2019-10-09 21:26:18 -07:00
parent ee89815f11
commit 275395929a
5 changed files with 53 additions and 57 deletions

View File

@ -91,7 +91,6 @@ ResetVector ; 6 bytes, copied to $100
!source "src/ui.attract.hgr.a" ; \__ execution falls through !source "src/ui.attract.hgr.a" ; \__ execution falls through
!source "src/ui.font.a" ; / !source "src/ui.font.a" ; /
!source "src/prodos.path.a"
!source "src/ui.overlay.a" !source "src/ui.overlay.a"
!source "src/ui.offscreen.a" !source "src/ui.offscreen.a"
!source "src/ui.attract.mode.a" !source "src/ui.attract.mode.a"
@ -125,6 +124,8 @@ gGamesListStore
SwitchToBank2 SwitchToBank2
+READ_RAM2_WRITE_RAM2 +READ_RAM2_WRITE_RAM2
rts rts
!source "src/prodos.path.a" ; paths end up on the same page
; MachineStatus (label is in constants.a so prelaunchers can use it) ; MachineStatus (label is in constants.a so prelaunchers can use it)
; 7 6 5 4 3 2 1 0 ; 7 6 5 4 3 2 1 0
; | | | | | | | +- bit 0 reserved ; | | | | | | | +- bit 0 reserved

View File

@ -9,7 +9,7 @@
; D000..E611 - persistent data structures (per-game cheat categories, ; D000..E611 - persistent data structures (per-game cheat categories,
; gGlobalPrefsStore, gGamesListStore) ; gGlobalPrefsStore, gGamesListStore)
; ...unused... ; ...unused...
; ECBB..FFF9 - main program code ; ECC8..FFF9 - main program code
; FFFA..FFFF - NMI, reset, IRQ vectors ; FFFA..FFFF - NMI, reset, IRQ vectors
; ;
; LC RAM BANK 2 ; LC RAM BANK 2

View File

@ -8,6 +8,43 @@
; - AddToPath ; - AddToPath
; ;
;------------------------------------------------------------------------------
; SetPath/AddToPath
; append a length-prefixed string to gPathname
; SetPath will reset the path first
;
; in: A contains low byte of address of length-prefixed string to append
; Y contains high byte of address of length-prefixed string to append
; out: all registers and flags clobbered
; $02/$03 (PTR/PTR+1) clobbered
; gPathname updated with concatenated length-prefixed string
;------------------------------------------------------------------------------
SetPath
kRootDirectory=*+1
ldx #0
stx gPathname
; execution falls through here
AddToPath
+STAY PTR
ldy #0
lda (PTR),y ; length of this segment
beq @done
tay
iny
sty @max
ldx gPathname ; current pathname length
ldy #$01
- lda (PTR),y
sta gPathname+1,x
inx
iny
@max = *+1
cpy #$D1 ; SMC
bcc -
stx gPathname
@done
rts
kHGRTitleDirectory kHGRTitleDirectory
!byte 10 !byte 10
!raw "TITLE.HGR/" !raw "TITLE.HGR/"
@ -108,40 +145,3 @@ kGRFizzleFile
kSFXFizzleFile kSFXFizzleFile
!byte 10 !byte 10
!raw "SHR.FIZZLE" !raw "SHR.FIZZLE"
;------------------------------------------------------------------------------
; SetPath/AddToPath
; append a length-prefixed string to gPathname
; SetPath will reset the path first
;
; in: A contains low byte of address of length-prefixed string to append
; Y contains high byte of address of length-prefixed string to append
; out: all registers and flags clobbered
; $02/$03 (PTR/PTR+1) clobbered
; gPathname updated with concatenated length-prefixed string
;------------------------------------------------------------------------------
SetPath
kRootDirectory=*+1
ldx #0
stx gPathname
; execution falls through here
AddToPath
+STAY PTR
ldy #0
lda (PTR),y ; length of this segment
beq @done
tay
iny
sty @max
ldx gPathname ; current pathname length
ldy #$01
- lda (PTR),y
sta gPathname+1,x
inx
iny
@max = *+1
cpy #$D1 ; SMC
bcc -
stx gPathname
@done
rts

View File

@ -46,10 +46,8 @@ OffscreenPage = * + 1
; out: all flags and registers clobbered ; out: all flags and registers clobbered
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
LoadTitleOffscreen LoadTitleOffscreen
+LDADDR kTitleFile lda #<kTitleFile
bne LoadOffscreenFromAY ; Always branches, because Y is loaded +HIDE_NEXT_2_BYTES
; last with the high byte of the address,
; which is never 0. I miss my 65c02.
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; LoadHelpOffscreen ; LoadHelpOffscreen
; load help screen in the HGR page that is currently not showing ; load help screen in the HGR page that is currently not showing
@ -58,9 +56,8 @@ LoadTitleOffscreen
; out: all flags and registers clobbered ; out: all flags and registers clobbered
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
LoadHelpOffscreen LoadHelpOffscreen
+LDADDR kHelpFile lda #<kHelpFile
bne LoadOffscreenFromAY ; always branches +HIDE_NEXT_2_BYTES
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; LoadCoverOffscreen ; LoadCoverOffscreen
; load cover screen in the HGR page that is currently not showing ; load cover screen in the HGR page that is currently not showing
@ -69,14 +66,15 @@ LoadHelpOffscreen
; out: all flags and registers clobbered ; out: all flags and registers clobbered
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
LoadCoverOffscreen LoadCoverOffscreen
+LDADDR kCoverFile lda #<kCoverFile
LoadOffscreenFromAY LoadOffscreenFromAY
+STAY @fname sta @fname
jsr GetOffscreenAddress jsr GetOffscreenAddress
sta + sta +
jsr LoadFile jsr LoadFile
!word kRootDirectory !word kRootDirectory
@fname !word $FDFD ; SMC @fname !byte $FD ; SMC
!byte >kCoverFile ; all of these are on the same page
!byte $00 !byte $00
+ !byte $FD ; SMC + !byte $FD ; SMC
rts rts

View File

@ -73,9 +73,6 @@ InputKeyDispatch
jsr IsSearchKey jsr IsSearchKey
beq .foundSearchKey beq .foundSearchKey
ldx #kInputError ldx #kInputError
+HIDE_NEXT_2_BYTES
.IsArrow
ldx #kInputBrowse
!if kInputSearch > 0 { !if kInputSearch > 0 {
+HIDE_NEXT_2_BYTES +HIDE_NEXT_2_BYTES
.foundSearchKey .foundSearchKey
@ -121,8 +118,9 @@ SearchMode
; we want to switch to Browse Mode with the keyboard still hot so ; we want to switch to Browse Mode with the keyboard still hot so
; that mode finds and dispatches the arrow key. ; that mode finds and dispatches the arrow key.
ldx #kInputBrowse
jsr IsUpDownOrRightArrow jsr IsUpDownOrRightArrow
beq .IsArrow beq .InputDispatch
bit CLEARKBD bit CLEARKBD
ldy #kNumBrowseKeys ldy #kNumBrowseKeys
@ -134,16 +132,15 @@ SearchMode
bne .InputDispatch ; always branches bne .InputDispatch ; always branches
OnClear OnClear
ldx InputLength ldx #1 ; Esc with input clears the input
ldy InputLength
bne + bne +
jmp CoverFade ; Esc with no input transitions to jmp CoverFade ; Esc with no input transitions to
; mega attract mode ; mega attract mode
OnBack OnBack
ldx InputLength ldx InputLength
beq OnError beq OnError
+HIDE_NEXT_2_BYTES + dex
+ ldx #1 ; Esc with input clears the input
dex
stx InputLength stx InputLength
bpl OnInputChanged ; always branches bpl OnInputChanged ; always branches