shave some bytes

This commit is contained in:
Peter Ferrie 2020-11-09 12:22:38 -08:00
parent 532ce58a16
commit 68bb9e0454
7 changed files with 34 additions and 41 deletions

View File

@ -7,7 +7,7 @@
; ;
; LC RAM BANK 1 ; LC RAM BANK 1
; D000..E908 - persistent data structures (gGlobalPrefsStore, gGamesListStore) ; D000..E908 - persistent data structures (gGlobalPrefsStore, gGamesListStore)
; E912..FFF1 - main program code ; E92D..FFF1 - main program code
; FFF2..FFF9 - API functions and global constants available for main program ; FFF2..FFF9 - API functions and global constants available for main program
; code, prelaunchers, transition effects, &c. ; code, prelaunchers, transition effects, &c.
; (Wait/UnwaitForVBL, MockingboardStuff, MachineStatus) ; (Wait/UnwaitForVBL, MockingboardStuff, MachineStatus)

View File

@ -114,8 +114,9 @@
} }
; compare a 16-bit value in A (low) and Y (high) to an absolute address ; compare a 16-bit value in A (low) and Y (high) to an absolute address
; zeroes A!
!macro CMP16ADDR .addr { !macro CMP16ADDR .addr {
cmp .addr eor .addr
bne + bne +
cpy .addr+1 cpy .addr+1
+ +
@ -221,15 +222,6 @@
bit $C082 bit $C082
} }
!macro LOW_ASCII_TO_LOWER {
cmp #$41
bcc +
cmp #$5B
bcs +
ora #$20
+
}
; requires setting zpCharMask in zero page to #$FF or #$DF before use ; requires setting zpCharMask in zero page to #$FF or #$DF before use
!macro FORCE_UPPERCASE_IF_REQUIRED { !macro FORCE_UPPERCASE_IF_REQUIRED {
cmp #$E1 cmp #$E1

View File

@ -231,7 +231,7 @@ okvs_append
; out: if C clear, record was found ; out: if C clear, record was found
; A/Y = lo/hi address of key (okvs_find) or value (okvs_get) ; A/Y = lo/hi address of key (okvs_find) or value (okvs_get)
; $WINDEX = index of found record (word) ; $WINDEX = index of found record (word)
; if C set, keyrecord was not found and all registers are clobbered ; if C set, keyrecord was not found and X/Y are clobbered, A=0
; all other flags clobbered ; all other flags clobbered
; $00/$01 clobbered ; $00/$01 clobbered
; $02/$03 clobbered ; $02/$03 clobbered
@ -268,15 +268,13 @@ okvs_get
iny iny
sty KEYLEN sty KEYLEN
@matchRecordLoop @matchRecordLoop
lda PTR+1 +LD16 PTR
sta DEST+1
lda PTR
clc clc
adc #2 adc #2
sta DEST
bcc + bcc +
inc DEST+1 ; DEST -> key of this record iny ; DEST -> key of this record
+ ldy #0 + +ST16 DEST
ldy #0
@matchKeyLoop @matchKeyLoop
lda (SRC),y lda (SRC),y
cmp (DEST),y cmp (DEST),y
@ -302,7 +300,7 @@ KEYLEN = *+1
cmp WCOUNT cmp WCOUNT
bne @matchRecordLoop bne @matchRecordLoop
lda WINDEX+1 lda WINDEX+1
cmp WCOUNT+1 eor WCOUNT+1
bne @matchRecordLoop bne @matchRecordLoop
@fail sec @fail sec
rts rts
@ -338,7 +336,6 @@ okvs_next
+LD16 WINDEX +LD16 WINDEX
+CMP16ADDR WCOUNT +CMP16ADDR WCOUNT
bne + bne +
lda #0
sta WINDEX sta WINDEX
sta WINDEX+1 sta WINDEX+1
+ +
@ -367,13 +364,13 @@ okvs_nth
jmp @next jmp @next
- jsr derefptr - jsr derefptr
@next @next
dec SAVE
lda SAVE lda SAVE
cmp #$FF dec SAVE
tay
bne - bne -
dec SAVE+1
lda SAVE+1 lda SAVE+1
cmp #$FF dec SAVE+1
tay
bne - bne -
jsr incptr2 jsr incptr2
+LD16 PTR +LD16 PTR
@ -473,7 +470,7 @@ okvs_iter_values
lda #2 ; for iter, skip length = 2 lda #2 ; for iter, skip length = 2
@branch bne + ; SMC (iter_values puts a BIT here, so no branch) @branch bne + ; SMC (iter_values puts a BIT here, so no branch)
; for iter_values, skip length = length(key) + 2 + 1 ; for iter_values, skip length = length(key) + 2 + 1
ldy #2 tay ;;ldy #2
lda (PTR),y ; A = length of key lda (PTR),y ; A = length of key
clc clc
adc #3 ; skip over pointer to next record (2 bytes) + key length (1 byte) adc #3 ; skip over pointer to next record (2 bytes) + key length (1 byte)

View File

@ -132,7 +132,6 @@ pref_get
+ !word $FDFD ; SMC + !word $FDFD ; SMC
bcc + ; found key, continue bcc + ; found key, continue
.useDefaultValue ; did not find key, use first key in passed store as a default value .useDefaultValue ; did not find key, use first key in passed store as a default value
lda #0
sta WINDEX sta WINDEX
sta WINDEX+1 sta WINDEX+1
+ +

View File

@ -99,9 +99,9 @@ TextRankCallback
+ST16 zpword +ST16 zpword
ldy #0 ldy #0
lda (zpstring),y lda (zpstring),y
sec tax
sbc #1 dex
cmp InputLength cpx InputLength
bcc ++ bcc ++
sta gamelength sta gamelength
sty runningscore sty runningscore
@ -110,11 +110,11 @@ TextRankCallback
sty startat sty startat
- sty i - sty i
lda (zpword),y lda (zpword),y
+LOW_ASCII_TO_LOWER jsr tolower
sta tmp sta tmp
ldy startat ldy startat
-- lda (zpstring),y -- lda (zpstring),y
+LOW_ASCII_TO_LOWER jsr tolower
cmp tmp cmp tmp
beq + beq +
cpy gamelength cpy gamelength
@ -165,7 +165,7 @@ TextRankCallback
pha pha
ldy #1 ldy #1
lda (zpstring),y lda (zpstring),y
+LOW_ASCII_TO_LOWER jsr tolower
sta firstletter sta firstletter
pla pla
ldx InputBuffer ldx InputBuffer
@ -208,3 +208,11 @@ TextRankCallback
bne - bne -
lda num1 lda num1
rts rts
tolower
cmp #$41
bcc +
cmp #$5B
bcs +
ora #$20
+ rts

View File

@ -28,9 +28,9 @@ Home
; bits 1-4 reserved ; bits 1-4 reserved
; bit 0 = 1 -> disable bank latch ; bit 0 = 1 -> disable bank latch
sta NEWVIDEO sta NEWVIDEO
lda #$F0 ldy #$F0
sta TBCOLOR ; white text on black background sty TBCOLOR ; white text on black background
lda #$00 lsr
sta CLOCKCTL ; black border sta CLOCKCTL ; black border
sta CLOCKCTL ; set twice for VidHD sta CLOCKCTL ; set twice for VidHD
@noSHR @noSHR

View File

@ -23,11 +23,11 @@ Credits
!word $8000 !word $8000
-- jsr ForceHGRMode -- jsr ForceHGRMode
jsr ClearOffscreen jsr ClearOffscreen
lda OffscreenPage ldx #0
- lda OffscreenPage
ror ; draw on offscreen page ror ; draw on offscreen page
+LDADDR $8000 +LDADDR $8000
tax jsr DrawPage ; draw credits
- jsr DrawPage ; draw credits
jsr ShowOtherPage ; show credits jsr ShowOtherPage ; show credits
jsr WaitForKeyFor30Seconds; wait jsr WaitForKeyFor30Seconds; wait
bit CLEARKBD ; don't care about key bit CLEARKBD ; don't care about key
@ -64,8 +64,5 @@ Help
!word kHelpTextFile !word kHelpTextFile
!word $8000 !word $8000
jsr LoadHelpOffscreen ; load fancy backdrop jsr LoadHelpOffscreen ; load fancy backdrop
lda OffscreenPage
ror ; draw on offscreen page
+LDADDR $8000
ldx #7 ldx #7
bne - ; always branches bne - ; always branches