shave some bytes

This commit is contained in:
4am 2021-06-21 10:33:16 -04:00
parent 0b4ab1d247
commit 2a594af93b
51 changed files with 103 additions and 180 deletions

View File

@ -31,6 +31,8 @@
jmp PrintByID
;jmodify
jmp modify
;jmodify1
jmp modify1
;jcompare
jmp compare
;gDisplayBytes

View File

@ -190,7 +190,8 @@ gRAMDiskRef = gTargetType-$01 ; byte
gHardDiskRef = gRAMDiskRef-$01 ; byte
gDisplayBytes = gHardDiskRef-$0A ; 10 bytes
jcompare = gDisplayBytes-$03 ; 3-byte
jmodify = jcompare-$03 ; 3-byte
jmodify1 = jcompare-$03 ; 3-byte
jmodify = jmodify1-$03 ; 3-byte
jPrintByID = jmodify-$03 ; 3-byte
jSearchTrack = jPrintByID-$03 ; 3-byte
jCallRWTS = jSearchTrack-$03 ; 3-byte
@ -204,6 +205,7 @@ gNIBTableBase = gNIBTableFF-$7F ; 127 byte
!ifdef MODULE {
compare = jcompare
modify = jmodify
modify1 = jmodify1
PrintByID = jPrintByID
SearchTrack = jSearchTrack
CallRWTS = jCallRWTS

View File

@ -1,3 +1,7 @@
modify1
ldy #$01
; /!\ execution falls through here
;-------------------------------
; modify subroutine
; in: A = starting address (high byte)

View File

@ -458,8 +458,8 @@ _byte_hi = * + 2
_byte_skip_hi:
rts
!source "id/bootfailure.a"
!source "wholetrack.a"
!source "id/bootfailure.a"
!source "apicode.a" ; /!\ must be last
!if RELBASE = $2000 {

View File

@ -33,8 +33,7 @@
bcs .exit
jsr PrintByID
!byte s_a6bc95
ldy #$01
jsr modify
jsr modify1
!byte $60 ; RTS
.exit
}

View File

@ -22,8 +22,7 @@
bcs + ; passport-test-suite/Moebius.woz [C=0] matches
jsr PrintByID
!byte s_aacount
ldy #$01
jsr modify
jsr modify1
!byte $60 ; RTS
+
dec .sector+1

View File

@ -13,7 +13,6 @@
!byte $B9,$34,$37,$34 ; 'POKE 47445,' in Applesoft BASIC (POKE opcode is $B9)
!byte $34,$35,$2C
bcs + ; passport-test-suite/SocMate Analogies Games.woz [C=0] matches
ldy #$01
jsr modify
jsr modify1
!byte $B2 ; change POKE opcode to REM
+

View File

@ -32,11 +32,10 @@
!byte $60 ; RTS
bcs .exit ; passport-test-suite/Mr. Pixel's Programming Paint Set.woz [C=0] matches
jsr inx9
ldy #$01
jsr modify
jsr modify1
!byte $DE
jsr inx0A
jsr modify
jsr modify1
!byte $AA
.exit
}

View File

@ -44,8 +44,7 @@
bcs .exit ; passport-test-suite/Squire.woz [C=0] matches
jsr PrintByID
!byte s_corrupter
ldy #$01
jsr modify
jsr modify1
!byte $60 ; RTS
.exit
}

View File

@ -50,8 +50,7 @@
; passport-test-suite/Notecard Maker.woz [C=0] matches
jsr PrintByID
!byte s_d5d5f7
ldy #$01
jsr modify
jsr modify1
!byte $60 ; RTS
.exit
}

View File

@ -29,8 +29,7 @@
jsr PrintByID
!byte s_badblock
ldx #$04
ldy #$01
jsr modify
jsr modify1
!byte $79 ; JMP to $0879 instead
+ dec .sector+1
bpl .sector

View File

@ -20,8 +20,7 @@
jsr PrintByID
!byte s_badblock
inx
ldy #$01
jsr modify
jsr modify1
!byte $CC ; MLI CLOSE command (instead of BLOCKREAD)
.exit
}

View File

@ -38,15 +38,13 @@ ERRORD51
pla
tax
pla
ldy #$01
jsr modify
jsr modify1
!byte $4C ; JMP opcode
@highBytePtr
ldy $FDFD ; SMC
sty +
inx
inx
ldy #$01
jsr modify
jsr modify1
+ !byte $FD ; SMC (high byte of JMP address)
@exit

View File

@ -27,8 +27,7 @@ F7F6
bcs + ; passport-test-suite/Might and Magic.woz [C=0] matches
jsr inx4
ldy #$01
jsr modify
jsr modify1
!byte $18 ; CLC
lda #TRUE ; needed for Might & Magic

View File

@ -36,8 +36,7 @@
inx
jsr PrintByID
!byte s_fbff
ldy #$01
jsr modify
jsr modify1
!byte $A2 ; change encrypted BNE +4 to +5D so code exits with Death Counter > 0
.exit
}

View File

@ -37,8 +37,7 @@
bcs .exit ; passport-test-suite/Super Taxman II.woz [C=0] matches
jsr PrintByID
!byte s_hallabs
ldy #$01
jsr modify
RTS
jsr modify1
!byte $60
.exit
}

View File

@ -176,8 +176,7 @@
.addressEpilogueEnd
bcs +
inx
ldy #$01
jsr modify ; normalize address epilogue 1st nibble
jsr modify1 ; normalize address epilogue 1st nibble
!byte $DE
+
ldy #(.dataPrologue3End-.dataPrologue3Start)
@ -206,8 +205,7 @@
.dataEpilogue1End
bcs +
inx
ldy #$01
jsr modify ; normalize data epilogue 1st nibble
jsr modify1 ; normalize data epilogue 1st nibble
!byte $DE
+
ldy #(.dataEpilogue3End-.dataEpilogue3Start)
@ -219,8 +217,7 @@
bcs +
inx
inx
ldy #$01
jsr modify ; ignore data epilogue 3rd nibble
jsr modify1 ; ignore data epilogue 3rd nibble
!byte $00
+
ldy #(.diskVolumeEnd-.diskVolumeStart)
@ -240,8 +237,7 @@
AND #$01
.alternatingTrackEnd
bcs .exit
ldy #$01
jsr modify
jsr modify1
!byte $A9 ; EOR -> LDA so alternating track check always passes
jmp .exit

View File

@ -28,8 +28,7 @@
jsr PrintByID
!byte s_d5d5f7
ldx #$04
ldy #$01
jsr modify
jsr modify1
!byte $60
+ dec .sector+1
bpl .sector

View File

@ -35,8 +35,7 @@
;and disable it
ldy #$01
jsr modify ; passport-test-suite/Stickybear Math.woz [Z=0] reaches here
jsr modify1 ; passport-test-suite/Stickybear Math.woz [Z=0] reaches here
!byte $60 ;RTS
pla

View File

@ -28,8 +28,7 @@
inx
jsr PrintByID
!byte s_fbff
ldy #$01
jsr modify
jsr modify1
!byte $B2 ; change encrypted BNE +4 to +5D so code exits with Death Counter > 0
lda #TRUE
sta gPolarwareTamperCheck
@ -45,8 +44,7 @@
jsr inx9
jsr PrintByID
!byte s_tamper
ldy #$01
jsr modify
jsr modify1
!byte $50 ; change BEQ to BVC which acts as a branch-always
.exit
}

View File

@ -38,8 +38,7 @@
!byte $60
bcs + ; passport-test-suite/Miner's Cave.woz [C=0] matches
jsr inx9
ldy #$01
jsr modify
jsr modify1
!byte $18
+
ldy #$18
@ -53,8 +52,7 @@
bcs + ; passport-test-suite/Spelling Press v1.1.woz [C=0] matches
jsr inx0B
jsr inx0B
ldy #$01
jsr modify
jsr modify1
!byte $18
+
ldy #$0C
@ -68,8 +66,7 @@
!byte $60
bcs + ; passport-test-suite/Spelling Press v1.1.woz [C=0] matches
jsr inx0A
ldy #$01
jsr modify
jsr modify1
!byte $18
+
ldy #$0B
@ -78,8 +75,7 @@
bcs .exit ; passport-test-suite/Spelling Press v1.1.woz [C=0] matches
inx
inx
ldy #$01
jsr modify
jsr modify1
!byte $18
.exit
}

View File

@ -29,8 +29,7 @@
sta .swapper2+1
inx
stx .swapper1+1
ldy #$01
jsr modify ; offset $01. $B5 -> $AD
jsr modify1 ; offset $01. $B5 -> $AD
!byte $AD
.swapper1
lda #$FF ; modified at runtime
@ -104,11 +103,10 @@
!byte $8E,$2C,$BF
bcs .exitt1
inx
ldy #$01
jsr modify ; then set T01,S02,$B0 =
jsr modify1 ; then set T01,S02,$B0 =
!byte $AD
ldx #$B7
jsr modify ; and set T01,S02,$B7 =
jsr modify1 ; and set T01,S02,$B7 =
!byte $9B
.exitt1

View File

@ -14,8 +14,7 @@
!byte $8D,$7A,$BC
bcs + ; passport-test-suite/Word Wizards v1.0.woz [C=0] matches
jsr inx5
ldy #$01
jsr modify
jsr modify1
!byte $60
+
lda gMECCFastloadType
@ -28,8 +27,7 @@
!byte $BD
bcs + ; passport-test-suite/Zoyon Patrol v1.0.woz [C=0] matches
jsr inx4
ldy #$01
jsr modify
jsr modify1
!byte $00
+
ldy #$08
@ -40,8 +38,7 @@
!byte $B9
bcs + ; passport-test-suite/MECC Dataquest Composer [C=0] matches
jsr inx5
ldy #$01
jsr modify
jsr modify1
!byte $24
+
ldy #$11

View File

@ -23,8 +23,7 @@
!byte $8D,$9E,$B8
bcs .exit ; passport-test-suite/Arcade Boot Camp.woz [C=0] matches
inx
ldy #$01
jsr modify ; then set T01,S04,$53 =
jsr modify1 ; then set T01,S04,$53 =
!byte $DE
.exit
}

View File

@ -41,8 +41,7 @@
.call
!byte $20,$D1,$D1 ;JSR $xxxx
bcs +
ldy #$01
jsr modify
jsr modify1
!byte $2C
;there are two of these on the same track
@ -52,16 +51,14 @@
.jmp1
!byte $4C,$D1,$D1 ;JMP $xxxx
bcs +
ldy #$01
jsr modify
jsr modify1
!byte $60
ldy #3
jsr SearchTrack
.jmp2
!byte $4C,$D1,$D1 ;JMP $xxxx
bcs +
ldy #$01
jsr modify
jsr modify1
!byte $60
+ ldy #3
jsr SearchTrack
@ -92,8 +89,7 @@
inx
inx
inx
ldy #$01
jsr modify
jsr modify1
!byte $00
+ ldy #12
jsr SearchTrack
@ -108,8 +104,7 @@
adc #9
tax
pla
ldy #$01
jsr modify
jsr modify1
!byte $60
+ ldy #14
jsr SearchTrack
@ -148,8 +143,7 @@
!byte $8D,$DF,$4D ;STA $4DDF
bcs +
inx
ldy #$01
jsr modify
jsr modify1
!byte $2C ;BIT $xxxx
+ ldy #6
jsr SearchTrack
@ -159,8 +153,7 @@
inx
inx
inx
ldy #$01
jsr modify
jsr modify1
!byte $60 ;RTS
+ ldy #17
jsr SearchTrack
@ -179,8 +172,7 @@
!byte $6C,$36,$00 ;JMP ($0036)
bcs +
jsr inx5
ldy #$01
jsr modify
jsr modify1
!byte $2C ;BIT $xxxx
+ ldy #15
jsr SearchTrack
@ -201,12 +193,10 @@
adc #6
tax
pla
ldy #$01
jsr modify
jsr modify1
!byte $EA ;NOP
jsr inx4
ldy #$01
jsr modify
jsr modify1
!byte $EA ;NOP
+ ldy #7
jsr SearchTrack
@ -215,8 +205,7 @@
!byte $4C,$BF,$48 ;JMP $48BF
bcs +
inx
ldy #$01
jsr modify
jsr modify1
!byte $A6 ;encoded BIT
+ jmp .exit
@ -289,8 +278,7 @@
+
jsr PrintByID
!byte s_sierra
ldy #$01
jsr modify
jsr modify1
.patchstyle
!byte $2C ;BIT $xxxx
jmp .exit
@ -314,8 +302,7 @@
adc #5
tax
pla
ldy #$01
jsr modify
jsr modify1
!byte $B5 ;load instead of store
ldy #24
@ -332,8 +319,7 @@
bcs +
jsr PrintByID
!byte s_tamper
ldy #$01
jsr modify
jsr modify1
!byte $60 ;just return
+ ldy #15
@ -351,8 +337,7 @@
adc #12
tax
pla
ldy #$01
jsr modify
jsr modify1
!byte $2C ;don't load sector #$10
+ ldy #13
@ -369,8 +354,7 @@
adc #10
tax
pla
ldy #$01
jsr modify
jsr modify1
!byte $2C ;don't call protection check
.jmpexit

View File

@ -29,8 +29,7 @@
bcs +
inx
inx ;patch the STA
ldy #$01
jsr modify
jsr modify1
!byte $AD ;LDA
lda #$24
sta $B91E
@ -125,8 +124,7 @@
adc #$0A
tax
pla
ldy #$01
jsr modify
jsr modify1
!byte $FC
bvc .exit
@ -147,8 +145,7 @@
inx
inx
inx ;patch the second JSR
ldy #$01
jsr modify
jsr modify1
!byte $2C ;LDA
bvc .exit
@ -184,8 +181,7 @@
bcs .exit
inx
.adjust lda #$d1
ldy #$01
jsr modify
jsr modify1
!byte $55 ;encoded zero
lda #TRUE
sta gIsSierra13

View File

@ -20,8 +20,7 @@
!byte $48
bcs .exit ; passport-test-suite/Advanced Electricity.woz [C=0] matches
jsr inx8
ldy #$01
jsr modify
jsr modify1
!byte $00
.exit
}

View File

@ -23,8 +23,7 @@
jsr PrintByID
!byte s_ssi
ldy #$01
jsr modify
jsr modify1
!byte $A9 ; LDA #$..
+
ldy #$09
@ -34,8 +33,7 @@
!byte $A9,$44 ; LDA #$22
!byte $20 ; JSR ...
bcs .exit ; passport-test-suite/Sixgun Shootout.woz [C=0] matches
ldy #$01
jsr modify
jsr modify1
!byte $60 ; RTS
.exit
}

View File

@ -27,7 +27,6 @@ T00_ARTSCI
bcs + ; passport-test-suite/Photar.woz [C=0] matches
jsr PrintByID
!byte s_bytrack
ldy #$01
jsr modify
jsr modify1
!byte $60
+

View File

@ -29,7 +29,6 @@ T00_BADEMU
!byte s_d5timing
inx
inx
ldy #$01
jsr modify ; then change $C0 to $BF to avoid hitting softswitch
jsr modify1 ; then change $C0 to $BF to avoid hitting softswitch
!byte $BF
+

View File

@ -13,8 +13,7 @@
bcs .exit ; passport-test-suite/Tomahawk.woz [C=0] matches
jsr PrintByID
!byte s_datasoft
ldy #$01
jsr modify
jsr modify1
!byte $C0
.exit
}

View File

@ -45,8 +45,7 @@
jsr compare
!byte $20,$93,$37
bcs + ; passport-test-suite/Bellhop.woz [C=0] matches
ldy #$01
jsr modify
jsr modify1
!byte $2C
+

View File

@ -36,10 +36,7 @@
jsr PrintByID
!byte s_hoffman
lda #$0C
ldy #$01
jsr modify ; then set T00,S0C,$00 =
;
RTS
;
jsr modify1 ; then set T00,S0C,$00 =
!byte $60
.exit
}

View File

@ -133,8 +133,7 @@ _jmpbbfe
!byte $6C,$FD,$08
ldx #$FE
ldy #$01
jsr modify
jsr modify1
@offset !byte $FD ; SMC (byte offset of new entry point)
; check for code that branches over a serial number

View File

@ -61,8 +61,7 @@ _jmpbeb1
!byte $20,$BB,WILDCARD
bcs .exit ; passport-test-suite/Easy as ABC.woz [C=0] matches
ldx #$49 ; passport-test-suite/Spelling Rules.woz [C=0] matches
ldy #$01
jsr modify ; then set T00,S02,$49 =
jsr modify1 ; then set T00,S02,$49 =
!byte $04
lda $124E
sta _jsr+2
@ -73,8 +72,7 @@ _jmpbeb1
!byte $A9,$D5
_jsr !byte $20,$B8,$d1; final byte set at runtime
ldx #$5F
ldy #$01
jsr modify ; and set T00,S02,$5F =
jsr modify1 ; and set T00,S02,$5F =
!byte $B8
.exit
}

View File

@ -33,8 +33,7 @@
sta .value
lda .sectors,y
ldx .offsets,y
ldy #$01
jsr modify
jsr modify1
.value !byte $d1
dec .loop+1
bpl .loop

View File

@ -27,8 +27,7 @@
jsr PrintByID
!byte s_bytrack
ldx #$D1
ldy #$01
jsr modify
jsr modify1
!byte $FB
.exit
}

View File

@ -29,8 +29,7 @@
jsr PrintByID
!byte s_bytrack
ldx #$B8
ldy #$01
jsr modify
jsr modify1
!byte $23
.exit
}

View File

@ -36,8 +36,7 @@
jsr PrintByID
!byte s_bytrack
ldx #$BD
ldy #$01
jsr modify ; then set T00,S00,$BD =
jsr modify1 ; then set T00,S00,$BD =
!byte $24 ; BIT
tya
ldx #$47
@ -46,8 +45,7 @@
!byte $4C,$CE,$36; JMP $36CE
bcs .exit
inx
ldy #$01
jsr modify ; then set T00,S01,$48 =
jsr modify1 ; then set T00,S01,$48 =
!byte $D8
.exit
}

View File

@ -22,8 +22,7 @@
adc #8
tax
tya
ldy #$01
jsr modify ; change BNE to continue instead
jsr modify1 ; change BNE to continue instead
!byte $00
.exit
}

View File

@ -20,8 +20,7 @@
bcs .exit ; passport-test-suite/The Function Game.woz [C=0] matches
jsr PrintByID
!byte s_bytrack
ldy #$01
jsr modify ; then set T00,S06,$F2 =
jsr modify1 ; then set T00,S06,$F2 =
!byte $2C
.exit
}

View File

@ -55,8 +55,7 @@
!byte $60 ;RTS
bcs .exit
inx
ldy #$01
jsr modify
jsr modify1
!byte $AA
ldy #$03
jsr SearchTrack

View File

@ -67,8 +67,7 @@
!byte $6C,$58,$9D
bcs .variant2 ; passport-test-suite/Pac-Man (Thunder Mountain).woz [C=0] here
ldx #$8E
ldy #$01
jsr modify ; then set T00,S01,$8E =
jsr modify1 ; then set T00,S01,$8E =
!byte $F8 ; change branch to unconditionally jump to success path
ldx #$92
jsr modify ; and set T00,S01,$92 =
@ -83,11 +82,10 @@
bcs .exit ; passport/test-suite/Problem Solving in Algebra.woz [C=0] here
; if we didn't find indirect jump in either location, bail
ldx #$8E ; variant #2 is similar to variant #1 but branch offsets differ by 1 byte
ldy #$01
jsr modify ; then set T00,S01,$8E =
jsr modify1 ; then set T00,S01,$8E =
!byte $F9 ; change branch to unconditionally jump to success path
ldx #$92
jsr modify ; and set T00,S01,$92 =
jsr modify1 ; and set T00,S01,$92 =
!byte $F2 ; change branch to unconditionally jump to success path
.exit
}

View File

@ -29,11 +29,10 @@
!byte $10,$F7
bcs .exit ; passport-test-suite/Easy as ABC.woz [C=0] matches
ldx #$69
ldy #$01
jsr modify ; then set T00,S04,$69 =
jsr modify1 ; then set T00,S04,$69 =
!byte $60
ldx #$7F
jsr modify ; and set T00,S04,$7F =
jsr modify1 ; and set T00,S04,$7F =
!byte $60
.exit
}

View File

@ -16,8 +16,7 @@
!byte $A9,$00
!byte $8D,$00,$B9
bcs +
ldy #$01
jsr modify
jsr modify1
!byte $60
+
ldx #$61
@ -26,8 +25,7 @@
!byte $A9,$01
!byte $8D,$00,$B9
bcs .exit ; passport-test-suite/Crown Of Arthain.woz [C=0] matches
ldy #$01
jsr modify
jsr modify1
!byte $60
.exit
}

View File

@ -25,8 +25,7 @@
jsr PrintByID
!byte s_springboard
ldx #$98
ldy #$01
jsr modify ; then set T00,S03,$98 =
jsr modify1 ; then set T00,S03,$98 =
!byte $00 ; branch to next instruction on failure
.exit
}

View File

@ -97,11 +97,10 @@
.yes
lda #$03
ldx #$40
ldy #$01
jsr modify ; then set T00,S03,$40 =
jsr modify1 ; then set T00,S03,$40 =
!byte $F0
ldx #$9C
jsr modify ; and set T00,S03,$9C =
jsr modify1 ; and set T00,S03,$9C =
!byte $D0
lda #$06
ldx #$69

View File

@ -27,15 +27,12 @@
!byte $BD,$8E,$C0 ; LDA $C08E,X
bcs .exit
lda (BASEPAGE*256)+$655
bpl .noconfig
bpl .exit
and #$7f
sta .config
sta +
lda #$06
dex
ldy #$01
jsr modify
.config
!byte $64
.noconfig
jsr modify1
+ !byte $64
.exit
}

View File

@ -28,8 +28,7 @@
bcs .exit ; passport-test-suite/Rendezvous with Rama rev. 2.woz [C=0] matches
jsr PrintByID
!byte s_trillium
ldy #$01
jsr modify
jsr modify1
!byte $2C ; BIT
.exit
}

View File

@ -23,13 +23,12 @@
!byte s_trillium
jsr inx4
ldy #$01
jsr modify
jsr modify1
!byte $2C ; BIT
inx
inx
inx
jsr modify
jsr modify1
!byte $A9 ; LDA
.exit
}

View File

@ -29,11 +29,10 @@
!byte s_bytrack
ldx #$A2
ldy #$01
jsr modify ; then set T04,S0B,$A2 =
jsr modify1 ; then set T04,S0B,$A2 =
!byte $2C
ldx #$A7
jsr modify ; and set T04,S0B,$A7 =
jsr modify1 ; and set T04,S0B,$A7 =
!byte $2C
.exit
}