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.font.a" ; /
!source "src/prodos.path.a"
!source "src/ui.overlay.a"
!source "src/ui.offscreen.a"
!source "src/ui.attract.mode.a"
@ -125,6 +124,8 @@ gGamesListStore
SwitchToBank2
+READ_RAM2_WRITE_RAM2
rts
!source "src/prodos.path.a" ; paths end up on the same page
; MachineStatus (label is in constants.a so prelaunchers can use it)
; 7 6 5 4 3 2 1 0
; | | | | | | | +- bit 0 reserved

View File

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

View File

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

View File

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