support Optimum

This commit is contained in:
Peter Ferrie 2017-02-09 21:13:35 -08:00
parent 96c4a5d8da
commit 4f17ba87c1
4 changed files with 342 additions and 71 deletions

View File

@ -94,7 +94,7 @@ flag = $FF ; byte
} }
; Application constants (not zero addresses) ; Application constants (not zero addresses)
RELBASE = $6900 ; address to move Passport code RELBASE = $6800 ; address to move Passport code
; so that it's out of the way ; so that it's out of the way
BASEPAGE = $10 ; Special Delivery tracer assumes BASEPAGE = $10 ; Special Delivery tracer assumes
; this is $10, so don't change it! ; this is $10, so don't change it!
@ -331,6 +331,8 @@ ADStyle
.noSun .noSun
jsr xOptimumRes jsr xOptimumRes
bcs .noOptimum bcs .noOptimum
lda #TRUE
sta gIsOptimum
lda #s_optimum lda #s_optimum
jsr PrintByID jsr PrintByID
.noOptimum .noOptimum
@ -694,6 +696,7 @@ _applyToAll
!source "patchers/corrupter.a" !source "patchers/corrupter.a"
!source "patchers/ea.a" !source "patchers/ea.a"
!source "patchers/gamco.a" !source "patchers/gamco.a"
!source "patchers/optimum.a"
lda gPatchCount lda gPatchCount
beq .nopatches beq .nopatches
@ -778,6 +781,10 @@ gIsEEEF
!byte FALSE ; 0=true, 1=false !byte FALSE ; 0=true, 1=false
; reset before each operation ; reset before each operation
; set in IsEEEF() after reading T22 ; set in IsEEEF() after reading T22
gIsOptimum
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
gOnAClearDayYouCanReadForever gOnAClearDayYouCanReadForever
!byte FALSE ; 0=true, 1=false !byte FALSE ; 0=true, 1=false
; retry reads with a captured RWTS forever, ; retry reads with a captured RWTS forever,

View File

@ -12,11 +12,25 @@ _ea
+ ldy #40 + ldy #40
jsr SearchTrack jsr SearchTrack
!byte $8D,$6F,$BC,$8C,$70,$BC,$A0,$20 !byte $8D,$6F,$BC ;STA $BC6F
!byte $88,$F0,$D7,$AD,$EC,$C0,$10,$FB !byte $8C,$70,$BC ;STY $BC70
!byte $49,$D5,$D0,$F4,$EA,$AD,$EC,$C0 !byte $A0,$20 ;LDY #$20
!byte $10,$FB,$C9,$BB,$D0,$F2,$EA,$AD !byte $88 ;DEY
!byte $EC,$C0,$10,$FB,$C9,$CF,$D0,$E8 !byte $F0,$D7 ;BEQ -$D7
!byte $AD,$EC,$C0 ;LDA $C0EC
!byte $10,$FB ;BPL -$FB
!byte $49,$D5 ;EOR #$D5
!byte $D0,$F4 ;BNE -$F4
!byte $EA ;NOP
!byte $AD,$EC,$C0 ;LDA $C0EC
!byte $10,$FB ;BPL -$FB
!byte $C9,$BB ;CMP #$BB
!byte $D0,$F2 ;BNE -$F2
!byte $EA ;NOP
!byte $AD,$EC,$C0 ;LDA $C0EC
!byte $10,$FB ;BPL -$FB
!byte $C9,$CF ;CMP #$CF
!byte $D0,$E8 ;BNE -$E8
bcs + bcs +
pha pha
txa txa
@ -29,21 +43,21 @@ _ea
pha pha
ldy #1 ldy #1
jsr modify jsr modify
!byte $AA !byte $AA ;data prologue #2
.patch2 .patch2
ldx #$D1 ldx #$D1
pla pla
ldy #1 ldy #1
jsr modify jsr modify
!byte $AD !byte $AD ;data prologue #3
+ ldy #13 + ldy #13
jsr SearchTrack jsr SearchTrack
!byte $03, $49 ;ldi #$05 !byte $03,$49 ;LDI #$05
!byte $01, $03, $65 ;jsra $bc00 !byte $01,$03,$65 ;JSRA $bc00
!byte $01, $03, $79 ;jsra $a000 !byte $01,$03,$79 ;JSRA $a000
!byte $03, $4C ;ldi #$00 !byte $03,$4C ;LDI #$00
!byte $04, $EB, $19 ;lda $c0e8 !byte $04,$EB,$19 ;LDA $c0e8
bcs + bcs +
inx inx
inx inx
@ -55,17 +69,21 @@ _ea
!byte $04 !byte $04
+ ldy #15 + ldy #15
jsr SearchTrack jsr SearchTrack
;enciphered call to p-code as above
!byte $BF,$9F,$BE,$F6,$04,$2E,$9B,$DA !byte $BF,$9F,$BE,$F6,$04,$2E,$9B,$DA
!byte $5A,$16,$DA,$30,$06,$45,$C2 !byte $5A,$16,$DA,$30,$06,$45,$C2
bcs + bcs +
inx inx
ldy #1 ldy #1
jsr modify jsr modify
!byte $EE !byte $EE ;enciphered jsra->lda to disable call
+ ldy #8 + ldy #8
jsr SearchTrack jsr SearchTrack
!byte $20,$10,$07,$A5,$56,$D0,$A7,$4C !byte $20,$10,$07 ;JSR $0710
!byte $A5,$56 ;LDA $56
!byte $D0,$A7 ;BNE -$A7
!byte $4C ;JMP $xxxx
bcs + bcs +
inx inx
inx inx
@ -75,16 +93,16 @@ _ea
inx inx
ldy #1 ldy #1
jsr modify jsr modify
!byte $00 !byte $00 ;disable branch
+ ldy #15 + ldy #15
jsr SearchTrack jsr SearchTrack
!byte $03, $49 ;ldi #$05 !byte $03,$49 ;LDI #$05
!byte $01, $03, $65 ;jsra $bc00 !byte $01,$03,$65 ;JSRA $bc00
!byte $03, $4C ;ldi #$00 !byte $03,$4C ;LDI #$00
!byte $01, $03, $79 ;jsra $a000 !byte $01,$03,$79 ;JSRA $a000
!byte $07, $01 ;sub #$4d !byte $07,$01 ;SUB #$4d
!byte $0F, $F5, $70 ;bne $a9f6 !byte $0F,$F5,$70 ;BNE $a9f6
bcs + bcs +
pha pha
txa txa
@ -96,18 +114,23 @@ _ea
pha pha
ldy #1 ldy #1
jsr modify jsr modify
!byte $04 !byte $04 ;new checksum value for sub
pla pla
.patch3 .patch3
ldx #$D1 ldx #$D1
ldy #1 ldy #1
jsr modify jsr modify
!byte $00 !byte $00 ;jsra->lda to disable call
;routine loops infinitely on failure
+ ldy #13 + ldy #13
jsr SearchTrack jsr SearchTrack
!byte $4C,$E7,$B2,$4C,$74,$B3,$00,$00 !byte $4C,$E7,$B2 ;JMP $B2E7
!byte $C9,$CB,$D0,$7C,$60 !byte $4C,$74,$B3 ;JMP $B374
!byte $00,$00 ;filler
!byte $C9,$CB ;CMP #$CB
!byte $D0,$7C ;BNE +$7C
!byte $60 ;RTS
bcs + bcs +
pha pha
txa txa
@ -116,16 +139,16 @@ _ea
pla pla
ldy #1 ldy #1
jsr modify jsr modify
!byte $00 !byte $00 ;disable branch
+ ldy #15 + ldy #15
jsr SearchTrack jsr SearchTrack
!byte $03,$49 ;ldi #$05 !byte $03,$49 ;LDI #$05
!byte $01,$03,$65 ;jsr $BC00 !byte $01,$03,$65 ;JSR $BC00
!byte $03,$4C ;ldi #$00 !byte $03,$4C ;LDI #$00
!byte $01,$03,$6C ;jsr $B500 !byte $01,$03,$6C ;JSR $B500
!byte $07,$1C ;sub #$50 !byte $07,$1C ;SUB #$50
!byte $0F,$78,$60 ;bne $B97B !byte $0F,$78,$60 ;BNE $B97B
bcs + bcs +
pha pha
txa txa
@ -134,12 +157,16 @@ _ea
pla pla
ldy #1 ldy #1
jsr modify jsr modify
!byte $4C !byte $4C ;new checksum value for sub
+ ldy #14 + ldy #14
jsr SearchTrack jsr SearchTrack
!byte $78,$20,$00,$D7,$C9,$4D,$F0,$06 !byte $78 ;SEI
!byte $20,$67,$67,$20,$AA,$BF !byte $20,$00,$D7 ;JSR $D700
!byte $C9,$4D ;CMP #$4D
!byte $F0,$06 ;BEQ +$06
!byte $20,$67,$67 ;JSR $6767
!byte $20,$AA,$BF ;JSR $BFAA
bcs + bcs +
inx inx
inx inx
@ -148,12 +175,14 @@ _ea
inx inx
ldy #1 ldy #1
jsr modify jsr modify
!byte $00 !byte $00 ;new checksum value for cmp
+ ldy #12 + ldy #12
jsr SearchTrack jsr SearchTrack
!byte $20,$3E,$91,$20,$F3,$76,$20,$00 !byte $20,$3E,$91 ;JSR $913E
!byte $61,$4C,$94,$69 !byte $20,$F3,$76 ;JSR $76F3
!byte $20,$00,$61 ;JSR $6100
!byte $4C,$94,$69 ;JMP $6994
bcs + bcs +
inx inx
inx inx
@ -163,19 +192,19 @@ _ea
inx inx
ldy #1 ldy #1
jsr modify jsr modify
!byte $2C !byte $2C ;JSR->BIT
+ ldy #23 + ldy #23
jsr SearchTrack jsr SearchTrack
;looks like garbage because it's enciphered ;looks like garbage because it's enciphered
!byte $03, $5B ;ldi #$00 !byte $03,$5B ;LDI #$00
!byte $06, $FF, $97 ;sta $4ee4 !byte $06,$FF,$97 ;STA $4ee4
!byte $1C, $E0, $8F ;jsra $4ce3 !byte $1C,$E0,$8F ;JSRA $4ce3
!byte $05, $FB, $95 ;jsra $4ce3 !byte $05,$FB,$95 ;JSRA $4ce3
!byte $19, $E0, $88 ;jsra $4ce3 !byte $19,$E0,$88 ;JSRA $4ce3
!byte $05, $FE, $95 ;jsra $4ce3 !byte $05,$FE,$95 ;JSRA $4ce3
!byte $1B, $EB, $39 ;lda $c0e8 !byte $1B,$EB,$39 ;LDA $c0e8
!byte $04, $C6, $97 ;lda $4ee4 !byte $04,$C6,$97 ;LDA $4ee4
bcs + bcs +
pha pha
txa txa
@ -184,18 +213,18 @@ _ea
pla pla
ldy #1 ldy #1
jsr modify jsr modify
!byte $C7 !byte $C7 ;lda from known-zero instead
+ ldy #23 + ldy #23
jsr SearchTrack jsr SearchTrack
!byte $03, $4C ;ldi #$00 !byte $03,$4C ;LDI #$00
!byte $06, $E1, $DE ;sta $07e2 !byte $06,$E1,$DE ;STA $07e2
!byte $05, $CC, $DC ;jsra $05cf !byte $05,$CC,$DC ;JSRA $05cf
!byte $05, $CC, $DC ;jsra $05cf !byte $05,$CC,$DC ;JSRA $05cf
!byte $05, $CC, $DC ;jsra $05cf !byte $05,$CC,$DC ;JSRA $05cf
!byte $05, $CC, $DC ;jsra $05cf !byte $05,$CC,$DC ;JSRA $05cf
!byte $04, $EB, $19 ;lda $c0e8 !byte $04,$EB,$19 ;LDA $c0e8
!byte $04, $E1, $DE ;lda $07e2 !byte $04,$E1,$DE ;LDA $07e2
bcs .exit bcs .exit
pha pha
txa txa
@ -204,7 +233,7 @@ _ea
pla pla
ldy #1 ldy #1
jsr modify jsr modify
!byte $E0 !byte $E0 ;lda from known-zero instead
.dostitles .dostitles
lda gIsBoot0 lda gIsBoot0
@ -212,14 +241,14 @@ _ea
ldy #23 ldy #23
jsr SearchTrack jsr SearchTrack
!byte $09, $7A ;ldi #$00 !byte $09,$7A ;LDI #$00
!byte $06, $7E, $A3 ;sta $0ee2 !byte $06,$7E,$A3 ;STA $0ee2
!byte $08, $4D, $A1 ;jsra $0cd1 !byte $08,$4D,$A1 ;JSRA $0cd1
!byte $08, $4D, $A1 ;jsra $0cd1 !byte $08,$4D,$A1 ;JSRA $0cd1
!byte $08, $4D, $A1 ;jsra $0cd1 !byte $08,$4D,$A1 ;JSRA $0cd1
!byte $08, $4D, $A1 ;jsra $0cd1 !byte $08,$4D,$A1 ;JSRA $0cd1
!byte $07, $74, $6D ;lda $c0e8 !byte $07,$74,$6D ;LDA $c0e8
!byte $07, $7E, $A3 ;lda $0ee2 !byte $07,$7E,$A3 ;LDA $0ee2
bcs + bcs +
pha pha
txa txa
@ -228,12 +257,16 @@ _ea
pla pla
ldy #1 ldy #1
jsr modify jsr modify
!byte $7F !byte $7F ;lda from known-zero instead
+ ldy #13 + ldy #13
jsr SearchTrack jsr SearchTrack
!byte $A2,$04,$20,$4F,$1E,$20,$00,$A6 !byte $A2,$04 ;LDX #$04
!byte $A5,$48,$D0,$01,$60 !byte $20,$4F,$1E ;JSR $1E4F
!byte $20,$00,$A6 ;JSR $A600
!byte $A5,$48 ;LDA $48
!byte $D0,$01 ;BNE +$01
!byte $60 ;RTS
bcs + bcs +
pha pha
txa txa
@ -242,7 +275,7 @@ _ea
pla pla
ldy #1 ldy #1
jsr modify jsr modify
!byte $00 !byte $00 ;disable branch
+ +
.exit .exit

231
src/patchers/optimum.a Normal file
View File

@ -0,0 +1,231 @@
;-------------------------------
; #Optimum
; self-overwriter that restores
; content later from custom sector
; e.g. StickyBear Math
;
; module by qkumba
;-------------------------------
!zone {
_optimum
lda gIsOptimum
bne .jmpexit1
lda gTrack
beq .jmpreread
ldy #15
jsr SearchTrack
!byte $A2,$00 ;LDX #$00
!byte $A0,$00 ;LDY #$00
!byte $BD,$21,$03 ;LDA $0321,X
!byte $E8 ;INX
!byte $85,WILDCARD ;STA $xx
!byte $BD,$21,$03 ;LDA $0321,X
!byte $E8 ;INX
!byte $85 ;STA $xx
bcc +
.jmpexit1
jmp .exit
.jmpreread
jmp .reread1
+ pha
adc #BASEPAGE
sta .swapbase1+2
tay
txa
pha
dey
sty .swapbase4+2
dey
sty .swapbase2+2
sty .swapbase3+2
ldy #$B5
-
.swapbase1
lda $D100,y
sta $2D8,y
dey
cpy #$FF
bne -
;disable decoding because using the real version
;would corrupt the text screen
lda #$2C
sta $BE40
;read T01S0F
lda gTrack
pha
lda #1
sta gTrack
ldy #<gRWTSParams
lda #>gRWTSParams
jsr $2E2
pla
sta gTrack
;re-enable decoding
lda #$20
sta $BE40
;disable redirection
pla
tax
pla
ldy #$01
jsr modify
!byte $60 ;RTS
;decode and stash content
lda #$BC
sta .tblsel1+2
sta .tblsel2+2
lda #$88
sta .direction1
sta .direction2
lda #$86
sta $26
ldy #$53
-
.tblsel1
ldx $D100,y
.swapbase2
lda ($D110-$96)-$16,x
asl
asl
asl
asl
.direction1
dey
.tblsel2
ldx $D100,y
.swapbase3
ora ($D110-$96)-$16,x
sty $2C
ldy $26
sta $B600,y
ldy $2C
bne +
dec .tblsel1+2
dec .tblsel2+2
lda #$C8
sta .direction1
sta .direction2
!byte $24 ;mask DEY
+
.direction2
dey
dec $26
ldx $26
inx
bne -
;read IOB with replaced page
.swapbase4
lda $D16D,x
sta .address+1
.jmpexit2
jmp .exit
;track 0, find the region with replaced page
.reread1
ldy #8
jsr SearchTrack
!byte $20,$5D,$B6 ;JSR $B65D
!byte WILDCARD, WILDCARD
!byte $00,$08,$18 ;address, count
bcs .jmpexit2 ;give up
adc #BASEPAGE
sta .patch1+2
sta .patch2+2
;convert address to track/sector
.address
lda #$D1
sbc #7
pha
and #$0F
sta tmp
.patch1
lda $D104,x
sbc tmp
and #$0F
sta gSector
pla
php
lsr
lsr
lsr
lsr
clc
.patch2
adc $D103,x
tay
plp
bcs +
iny
+ sty gTrack
;read replaced page
ldy #<gRWTSParams
lda #>gRWTSParams
jsr $BD00
;merge content
ldy #$86
- lda $B600,y
sta (BASEPAGE+$0F)*256,y
dey
cpy #$FF
bne -
;write replaced page
lda gRWTSParams+1
pha
lda gRWTSParams+2
pha
lda SLOT
asl
asl
asl
asl
sta gRWTSParams+1
lda DRIVE
and #$0F
sta gRWTSParams+2
lda #1
sta gTrack
lda #$0F
sta gSector
inc gRWTSParams+$0C
ldy #<gRWTSParams
lda #>gRWTSParams
jsr $BD00
dec gRWTSParams+$0C
pla
sta gRWTSParams+2
pla
sta gRWTSParams+1
;restore original page
dec gTrack
ldy #<gRWTSParams
lda #>gRWTSParams
jsr $BD00
.exit
}

View File

@ -192,7 +192,7 @@ StringTable
; can be set directly before calling PrintByID. ; can be set directly before calling PrintByID.
; ;
.header .header
!text "Passport by 4am 2017-02-07",00 !text "Passport by 4am 2017-02-09",00
.mainmenu .mainmenu
!text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D !text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D
!text " " !text " "