From 74a6d52420b641b11302b6d71aef198a2696a501 Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Sat, 13 Apr 2019 10:33:15 -0700 Subject: [PATCH 1/7] support Choplifter copying --- src/id/inspect0.a | 4 +- src/id/trace32.a | 36 +++++- src/passport.a | 18 ++- src/patchers/choplifter.a | 257 ++++++++++++++++++++++++++++++++++++++ src/rwts.a | 3 +- src/strings/en.a | 3 + src/strings/enid.a | 3 +- 7 files changed, 306 insertions(+), 18 deletions(-) create mode 100644 src/patchers/choplifter.a diff --git a/src/id/inspect0.a b/src/id/inspect0.a index 9aff5ca..09838c1 100755 --- a/src/id/inspect0.a +++ b/src/id/inspect0.a @@ -218,7 +218,7 @@ IDBootloader sta gIsProDOS jsr IDVolumeName bcc + - jmp .useuniv + jmp UseUniversal + ; ; Dinkey-DOS (ProDOS file structure with DOS 3.3-ish RWTS in language card) @@ -227,7 +227,7 @@ IDBootloader ; jsr IDDinkeyDOS bcc + - jmp .useuniv + jmp UseUniversal + lda #s_dinkeydos jsr PrintByID lda #TRUE diff --git a/src/id/trace32.a b/src/id/trace32.a index 26b9702..bedd376 100644 --- a/src/id/trace32.a +++ b/src/id/trace32.a @@ -74,6 +74,11 @@ IDDOS32LO ldy #$03 jsr compare !byte $4C,$01,$03; JMP $0301 + bcc .exit + ldx #$37 + ldy #$03 + jsr compare + !byte $4C,$01,$03; JMP $0301 .exit rts } @@ -99,10 +104,15 @@ TraceDOS32LO jmp $0801 .TraceDOS32LOb - lda #<.TraceDOS32c - sta $0842 + ldy #$00 + lda $0837 + cmp #$4C + beq + + ldy #$0A ++ lda #<.TraceDOS32c + sta $0838,y lda #>.TraceDOS32c - sta $0843 + sta $0839,y jmp $0801 .TraceDOS32c @@ -138,7 +148,7 @@ TraceDOS32LO !byte $85,$3F !byte $E6,$3F !byte $6C,$3E,$00 - bcs .fail + bcs .tryChoplifter lda $03CC cmp #$B6 beq + @@ -174,6 +184,24 @@ TraceDOS32LO ldy $0300 jmp $0301 +.tryChoplifter + lda #$03 + ldx #$01 + ldy #$10 + jsr CompareMemory + !byte $A2,$2E ;LDX #$2E + !byte $9A ;TXS + !byte $84,$48 ;STY $48 + !byte $A2,$00 ;LDX #$00 + !byte $BC,$00,$03 ;LDY $0300,X + !byte $88 ;DEY + !byte $A9,$EA ;LDA #$EA + !byte $20,$26,$03 ;JSR $0326 + bcs .fail + lda #s_choplifter + jsr PrintByID + jmp Choplifter + ; something did not match, not comfortable tracing, ; but we know enough to know that the universal RWTS won't work, ; so we're done diff --git a/src/passport.a b/src/passport.a index 40544c4..489508e 100755 --- a/src/passport.a +++ b/src/passport.a @@ -411,17 +411,15 @@ ReadWithRWTS checksector lda $FFFF ; status of current sector in sector map (modified above) - pha cmp #kSectorCustomFirst ; call a custom routine before deciding what to do with this sector? bcc + cmp #kSectorCustomLast bcs + - pla jsr PreReadSector - pha ; replace status (on stack) with new status returned from PreReadSector -+ cmp #kSectorIgnore ; skip this sector? ++ pha ; replace status (on stack) with new status returned from PreReadSector + cmp #kSectorIgnore ; skip this sector? beq nextsector -+ cmp #kSectorSwitchToBuiltinRWTS ; switch to built-in RWTS before reading this sector? + cmp #kSectorSwitchToBuiltinRWTS ; switch to built-in RWTS before reading this sector? bne + lda gTriedUniv beq + @@ -499,12 +497,11 @@ checksector nextsector pla - dec checksector+1 lda checksector+1 - cmp #$FF bne .nodec dec checksector+2 .nodec + dec checksector+1 lda gSector sec sbc #$01 @@ -524,11 +521,11 @@ nextsector jsr ChangeTrack jsr IncProgress lda gTrack - bmi .pass + bmi Pass cmp gLastTrack - bcc .pass + bcc Pass jmp .read -.pass +Pass bit gMode bmi .passwrite lda #s_pass @@ -847,6 +844,7 @@ _applyToAll !source "patchers/holle.a" ; gIsHolle only !source "patchers/zoomgrafix.a" ; gIsPhoenix only !source "patchers/e7everywhere.a" ; gIsBoot0 || gIsProDOS only + !source "patchers/choplifter.a" ; gIsChoplifter only lda gPatchCount beq .nopatches diff --git a/src/patchers/choplifter.a b/src/patchers/choplifter.a new file mode 100644 index 0000000..5a24a77 --- /dev/null +++ b/src/patchers/choplifter.a @@ -0,0 +1,257 @@ +;------------------------------- +; #Choplifter +; insane protection by Roland Gustafsson +; licensed by Broderbund, Gebelli, and others +; +; module by qkumba +;------------------------------- +!zone { +.exit rts ; reachable only via inspect + +Choplifter + bit gMode ; nothing to do here in verify-only mode + bpl .exit + lda #$00 + sta gCommand + sta dct+1 + jsr ChangeTrackNW + jsr IncProgress + +.read + lda KEY + bmi .cancel + asl gTrack + jsr ReadChoplifter + lsr gTrack + jsr WriteTrackNA + lda gTrack + clc + adc #$01 + jsr ChangeTrackNW + jsr IncProgress + lda gTrack + cmp #$23 + bne .read + jsr .cleanup + jmp Pass + +.cleanup + lda $C0E8 + lda #$01 + sta gCommand + sta dct+1 + rts + +.fatal + jsr .cleanup + ; if we get to here, we've + jmp FatalError ; decided the read error is fatal + +.cancel + jsr .cleanup + jmp Cancel + +ReadChoplifter + lda #BASEPAGE + sta modsrc+1 + lda #$00 + sta modsrc +- jsr ReadSector ; really just seek + lda $C0E9 ; turn the drive back on + ; no need for spin-up because we are fast enough + ldx #$04 + lda gTrack + beq .settrack00 + cmp #$12 + bcc .settrack01 + cmp #$16 + bcc .ignore + beq .readtrack0B + cmp #$3E + bcs .checktrack1E + jsr .readtrack + inc gTrack + lda gTrack + lsr + bcs - + dec gTrack +.ignore + rts + +.readtrack0B + +.checkkey1 + lda KEY + bmi .cancel + jsr .readnib +- cmp #$DD + bne .checkkey1 + jsr .readnib +-- cmp #$F5 + bne - + jsr .readnib + cmp #$D5 + bne -- ; this is the same bug + ldx #$03 +- jsr .read4x4 + jsr .read4x4 + jsr .read4x4 + sta cmp1+0,x + dex + bpl - + rts + +.checktrack1E + cmp #$40 + bcs .checktrack20 + rts + +.settrack00 + lda #$D5 + sta cmp1+1 + sta cmp2+1 + lda #$DD + sta cmp1+0 + sta cmp2+0 + !byte $2C +.settrack01 + ldx #$08 + +.readtrack + stx tmpx + ldx #3 + +.retry0 + dex + beq .jmpfatal + +.checkkey0 + lda KEY + bmi .jmpcancel + jsr .readnib +- cmp cmp2+1 + bne .checkkey0 + jsr .readnib +-- cmp cmp2+0 + bne - + jsr .readnib + cmp cmp1+1 + bne -- ; this is a bug + ; it allows PR0 PR1 [any] PR1 PR2 instead of requiring PR0 PR1 PR2 + ldy #0 +-- jsr .read4x4 + sta (modsrc), y + iny + bne -- +- lda $C0EC + bpl - + cmp cmp1+0 + bne .retry0 + inc modsrc+1 + dec tmpx + bne -- + jsr .readnib + sta cmp1+1 ; prologue 3 + jsr .readnib + sta cmp2+0 ; prologue 2 + jsr .readnib + sta cmp2+1 ; prologue 1 + jsr .readnib + sta cmp1+0 ; epilog + rts + +.jmpfatal + jmp .fatal + +.jmpcancel + jmp .cancel + +.checktrack20 + beq .readtrack20 + cmp #$44 + beq .readtrack22 + rts + +.readtrack20 + ldx #1 + jsr .readtrack + lda (BASEPAGE<<8)+$C5 + sta .prolog1+1 + lda (BASEPAGE<<8)+$CC + sta .prolog2+1 + lda (BASEPAGE<<8)+$D3 + sta .prolog3+1 + +.checkkey2 + lda KEY + bmi .jmpcancel + jsr .readnib +.prolog1 +- cmp #$D1 ; SMC + bne .checkkey2 + jsr .readnib +.prolog2 +-- cmp #$D1 ; SMC + bne - + jsr .readnib +.prolog3 + cmp #$D1 ; SMC + bne -- ; this is the same bug + nop ; timing bits + ldx #$00 +- jsr .read4x4 + sta (BASEPAGE+1)<<8,x + inx + jsr .read4x4 + sta (BASEPAGE+1)<<8,x + inx + jsr .read4x4 + sta (BASEPAGE+1)<<8,x + inx + cmp #$EA + bne - + rts + +.readtrack22 + ldx #$40 + ldy #0 + +.checkkey3 + dey + bne + + dex + beq ++ ++ lda KEY + bmi .jmpcancel + jsr .readnib +- cmp #$D5 + bne .checkkey3 + jsr .readnib +-- cmp #$FF + bne - + jsr .readnib + cmp #$DD + bne -- ; this is the same bug + ldx #$00 +- jsr .read4x4 + sta BASEPAGE<<8,x + inx + bne - +++ rts + +.read4x4 +- lda $C0EC + bpl - + sec + rol + sta tmp +- lda $C0EC + bpl - + and tmp + rts + +.readnib +- lda $C0EC + bpl - + rts +} diff --git a/src/rwts.a b/src/rwts.a index 27d1b31..51ff023 100755 --- a/src/rwts.a +++ b/src/rwts.a @@ -199,5 +199,6 @@ _track !byte $00 _sector !byte $00 !word dct gAddress !word $1F00 - !byte $00,$00,$01,$00,$FE,$60,$01,$00,$00 + !byte $00,$00 +gCommand !byte $01,$00,$FE,$60,$01,$00,$00 dct !byte $00,$01,$EF,$D8,$00 diff --git a/src/strings/en.a b/src/strings/en.a index fa5549a..e273964 100755 --- a/src/strings/en.a +++ b/src/strings/en.a @@ -133,6 +133,7 @@ StringTable !word .hoffman !word .diskvol0 !word .e7everywhere + !word .choplifter ; ; Text can contain substitution strings, which ; are replaced by current values at runtime. Each @@ -486,4 +487,6 @@ StringTable !text "T%t,S%0 Disk requires volume number 000",$8D,$00 .e7everywhere !text "T%t,S%0 Found E7 Everywhere protection",$8D,$00 +.choplifter + !text "T00,S01 Found Choplifter protection",$8D,$00 } diff --git a/src/strings/enid.a b/src/strings/enid.a index 8ea28a4..899f190 100644 --- a/src/strings/enid.a +++ b/src/strings/enid.a @@ -119,4 +119,5 @@ s_holle = $71 s_hoffman = $72 s_diskvol0 = $73 s_e7everywhere=$74 -STRINGCOUNT = $75 +s_choplifter = $75 +STRINGCOUNT = $76 From 3601c5be62282d78ffa60100ae069571704eeb25 Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Mon, 15 Apr 2019 17:15:36 -0700 Subject: [PATCH 2/7] auto-crack Choplifter (read-only) also make one-time procs discardable and double stringtable capacity --- src/initscan.a | 205 ++++++++++++++++++++++ src/mli.a | 100 +---------- src/passport.a | 41 ++--- src/patchers/choplifter.a | 225 +++++++++++++++++++++--- src/prefs.a | 16 -- src/print.a | 10 +- src/slots.a | 111 ------------ src/strings/en.a | 361 +++++++++++++++++++++++++------------- 8 files changed, 682 insertions(+), 387 deletions(-) create mode 100644 src/initscan.a diff --git a/src/initscan.a b/src/initscan.a new file mode 100644 index 0000000..34cebc8 --- /dev/null +++ b/src/initscan.a @@ -0,0 +1,205 @@ +;------------------------------- +; ScanForDiskII +; scan all slots for things that +; look like Disk II cards +; +; out: all registers clobbered +; all flags clobbered +; DiskIIArray filled with 00 or FF +;------------------------------- +!zone { +ScanForDiskII + lda #$00 + sta cmp1 + ldx #$07 +.fingerprint + txa + ora #$C0 + sta cmp1+1 + ldy #$01 + lda (cmp1),y + cmp #$20 + bne .next + ldy #$03 + lda (cmp1),y + bne .next + ldy #$05 + lda (cmp1),y + cmp #$03 + bne .next + ldy #$FF + lda (cmp1),y + bne .next + tya + sta DiskIIArray-1,x +.next + dex + bne .fingerprint + rts +} + +!zone { +ScanForRAMDisk + lda #$00 + sta iunit +- lda iunit + clc + adc #$10 + sta iunit + beq .done + cmp #$80 + beq - + pha + and #$70 + lsr + lsr + lsr + lsr + tay + pla + ldx DiskIIArray-1,y + bne - + jsr GetVolumeName + bcs - + lda OnlineReturn + beq - + jsr GetVolumeInfo + + ;watch for RAM disk type + + lda filetype + and #$0F + cmp #$0F + bne - + + ;check for RAM[x] by name + + ldy OnlineReturn + cpy #4 + beq + + cpy #5 + bne - + dey ++ +-- lda SlashRAM-1,y + cmp VolumeName-1,y + bne - + dey + bne -- + + ;check free space + ;need at least $118 blocks + + sec + lda auxtype + sbc blocks + tax + lda auxtype+1 + sbc blocks+1 + cmp #1 + bcc - + bne + + cpx #$18 + bcc - ++ lda #TRUE + sta gUsingRAMDisk +.done + rts + +SlashRAM !byte $2F, $52, $41, $4D +} + +;------------------------------- +; LoadPrefs +; load preferences from file +; +; in: ProDOS must be in memory +;------------------------------- +LoadPrefs + lda #$FF + sta PREFSVER + jsr LoadFile1Shot + !word PREFSFILE + !word PREFSVER + !word PREFSREADLEN + !word PREFSBUFFER + jsr ValidatePrefs + bcc .goodprefs + jmp SavePrefs + +.goodprefs + rts + +;------------------------------- +; LoadFile1Shot +; load a file into memory all at once, +; using ProDOS MLI calls +; +; in: stack contains 8 bytes of parameters: +; +1 address of pathname +; +3 address of data buffer (to receive file contents) +; +5 [word] maximum length of data to read +; +7 address of ProDOS file buffer +; out: if C set, load failed and A contains error code +; from open or read +; if C clear, load succeeded and ($02) contains +; data loaded from file +; all other flags clobbered +; all registers clobbered +; stack set to next instruction after parameters +;------------------------------- +!zone { +LoadFile1Shot + clc + pla + adc #$08 + sta $00 + tax + pla + adc #$00 + sta $01 + pha + txa + pha + + ldy #$01 + lda ($00),y ; lo byte of pathname + sta mliparam+1 + iny + lda ($00),y ; hi byte of pathname + sta mliparam+2 + ldy #$07 + lda ($00),y ; lo byte of ProDOS file buffer + sta mliparam+3 + iny + lda ($00),y ; hi byte of ProDOS file buffer + sta mliparam+4 + + jsr OpenFile + bcs .loadfile1s ; C set on error + + pha ; push file reference number + ldy #$03 + lda ($00),y ; lo address of data buffer + sta mliparam+2 + iny + lda ($00),y ; hi address of data buffer + sta mliparam+3 + iny + lda ($00),y ; lo data length + sta mliparam+4 + iny + lda ($00),y ; hi data length + sta mliparam+5 + pla ; pull file reference number + jsr ReadFile + php ; save flags from readfile + pha + jsr CloseFile ; always close whether read worked or not + pla + plp ; restore flags from readfile + ; (so caller gets codes from read attempt, + ; not close) +.loadfile1s + rts +} diff --git a/src/mli.a b/src/mli.a index fba5f1a..c8bd48a 100755 --- a/src/mli.a +++ b/src/mli.a @@ -139,21 +139,16 @@ WriteTrackMLI ;------------------------------- !zone { SaveFile1Shot - pla - sta $00 - pla - sta $01 - tax - lda #$0B clc - adc $00 - bcc .noinc - inx -.noinc - tay - txa + pla + adc #$0B + sta $00 + tax + pla + adc #$00 + sta $01 pha - tya + txa pha ldy #$01 @@ -211,85 +206,6 @@ SaveFile1Shot rts } -;------------------------------- -; LoadFile1Shot -; load a file into memory all at once, -; using ProDOS MLI calls -; -; in: stack contains 8 bytes of parameters: -; +1 address of pathname -; +3 address of data buffer (to receive file contents) -; +5 [word] maximum length of data to read -; +7 address of ProDOS file buffer -; out: if C set, load failed and A contains error code -; from open or read -; if C clear, load succeeded and ($02) contains -; data loaded from file -; all other flags clobbered -; all registers clobbered -; stack set to next instruction after parameters -;------------------------------- -!zone { -LoadFile1Shot - pla - sta $00 - pla - sta $01 - tax - lda #$08 - clc - adc $00 - bcc .noinc - inx -.noinc - tay - txa - pha - tya - pha - - ldy #$01 - lda ($00),y ; lo byte of pathname - sta mliparam+1 - iny - lda ($00),y ; hi byte of pathname - sta mliparam+2 - ldy #$07 - lda ($00),y ; lo byte of ProDOS file buffer - sta mliparam+3 - iny - lda ($00),y ; hi byte of ProDOS file buffer - sta mliparam+4 - - jsr OpenFile - bcs .loadfile1s ; C set on error - - pha ; push file reference number - ldy #$03 - lda ($00),y ; lo address of data buffer - sta mliparam+2 - iny - lda ($00),y ; hi address of data buffer - sta mliparam+3 - iny - lda ($00),y ; lo data length - sta mliparam+4 - iny - lda ($00),y ; hi data length - sta mliparam+5 - pla ; pull file reference number - jsr ReadFile - php ; save flags from readfile - pha - jsr CloseFile ; always close whether read worked or not - pla - plp ; restore flags from readfile - ; (so caller gets codes from read attempt, - ; not close) -.loadfile1s - rts -} - ;------------------------------- ; open file via ProDOS MLI ; diff --git a/src/passport.a b/src/passport.a index 489508e..848a708 100755 --- a/src/passport.a +++ b/src/passport.a @@ -96,7 +96,26 @@ FM lda LastMover - 256,x lda FM+5 cmp #(>RELBASE)-((>(RELBASE+255))->RELBASE)-1 bne FM - jmp OneTimeSetup + +OneTimeSetup + lda $C0E8 + jsr SaveProDOS + ldx MACHINEID + cpx #$EA + bne .slotscan + lda #$DF + sta kForceLower +.slotscan + jsr ScanForDiskII + lda DiskIIArray+5 + bne .founds6 + jmp FatalNoSlot6 +.founds6 + jsr ScanForRAMDisk + jsr LoadPrefs ; load preferences (if available) + jmp ResetVector + + !source "initscan.a" FirstMover !pseudopc RELBASE { @@ -165,24 +184,6 @@ FirstMover !source "rwts.a" !source "standarddelivery.a" -OneTimeSetup - lda $C0E8 - jsr SaveProDOS - ldx MACHINEID - cpx #$EA - bne .slotscan - lda #$DF - sta kForceLower -.slotscan - jsr ScanForDiskII - lda DiskIIArray+5 - bne .founds6 - jmp FatalNoSlot6 -.founds6 - jsr ScanForRAMDisk - jsr LoadPrefs ; load preferences (if available) - bcc ResetVector - jsr SavePrefs ; save preferences (if possible) ResetVector lda # !source "strings/enid.a" !zone { -StringTable - !word .header - !word .mainmenu - !word .progbar - !word .reading - !word .diskrwts - !word .bb00 - !word .sunburst - !word .optimum - !word .builtin - !word .switch - !word .writing - !word .unformat - !word .f7 - !word .sync - !word .optbad - !word .passver - !word .passdemuf - !word .passcrack - !word .passcrack0 - !word .fail - !word .fatal0000 - !word .fatal220f - !word .done - !word .noslot6 - !word .writeerr - !word .writeioerr - !word .writenodev - !word .writeprot - !word .othermli - !word .canttrace - !word .canceled - !word .bademu - !word .reset - !word .modify - !word .modifyto - !word .dos33boot0 - !word .prodosboot0 - !word .pascalboot0 - !word .mecc - !word .sierra - !word .a6bc95 - !word .jmpbcf0 - !word .rol1e - !word .runhello - !word .e7 - !word .jmpb4bb - !word .jmpb400 - !word .jmpbeca - !word .bb03 - !word .thunder - !word .jmpae8e - !word .diskvol - !word .d5d5f7 - !word .construct - !word .datasoftb0 - !word .datasoft - !word .lsr6a - !word .bcs08 - !word .jmpb660 - !word .protdos - !word .decryptrwts - !word .protserial - !word .fbff - !word .encoded44 - !word .encoded53 - !word .specdel - !word .bytrack - !word .a5count - !word .restart - !word .corrupter - !word .eaboot0 - !word .eatrk6 - !word .eeef - !word .poke - !word .bootcounter - !word .milliken - !word .jsr8b3 - !word .daviddos - !word .quickdos - !word .diversidos - !word .prontodos - !word .jmpb412 - !word .laureate - !word .bbf9 - !word .micrograms - !word .cmpbne0 - !word .writeram - !word .d5timing - !word .advint - !word .dos32boot0 - !word .bootwrite - !word .rwtswrite - !word .rdos - !word .sra - !word .muse - !word .origin - !word .volumename - !word .dinkeydos - !word .trillium - !word .tamper - !word .microfun - !word .advent - !word .gathering - !word .davidson - !word .rdos13 - !word .ssi - !word .aacount - !word .infocom18 - !word .toverify - !word .sector13 - !word .dakin5 - !word .springboard - !word .hallabs - !word .holle - !word .hoffman - !word .diskvol0 - !word .e7everywhere - !word .choplifter +StringTableLow + !byte <.header + !byte <.mainmenu + !byte <.progbar + !byte <.reading + !byte <.diskrwts + !byte <.bb00 + !byte <.sunburst + !byte <.optimum + !byte <.builtin + !byte <.switch + !byte <.writing + !byte <.unformat + !byte <.f7 + !byte <.sync + !byte <.optbad + !byte <.passver + !byte <.passdemuf + !byte <.passcrack + !byte <.passcrack0 + !byte <.fail + !byte <.fatal0000 + !byte <.fatal220f + !byte <.done + !byte <.noslot6 + !byte <.writeerr + !byte <.writeioerr + !byte <.writenodev + !byte <.writeprot + !byte <.othermli + !byte <.canttrace + !byte <.canceled + !byte <.bademu + !byte <.reset + !byte <.modify + !byte <.modifyto + !byte <.dos33boot0 + !byte <.prodosboot0 + !byte <.pascalboot0 + !byte <.mecc + !byte <.sierra + !byte <.a6bc95 + !byte <.jmpbcf0 + !byte <.rol1e + !byte <.runhello + !byte <.e7 + !byte <.jmpb4bb + !byte <.jmpb400 + !byte <.jmpbeca + !byte <.bb03 + !byte <.thunder + !byte <.jmpae8e + !byte <.diskvol + !byte <.d5d5f7 + !byte <.construct + !byte <.datasoftb0 + !byte <.datasoft + !byte <.lsr6a + !byte <.bcs08 + !byte <.jmpb660 + !byte <.protdos + !byte <.decryptrwts + !byte <.protserial + !byte <.fbff + !byte <.encoded44 + !byte <.encoded53 + !byte <.specdel + !byte <.bytrack + !byte <.a5count + !byte <.restart + !byte <.corrupter + !byte <.eaboot0 + !byte <.eatrk6 + !byte <.eeef + !byte <.poke + !byte <.bootcounter + !byte <.milliken + !byte <.jsr8b3 + !byte <.daviddos + !byte <.quickdos + !byte <.diversidos + !byte <.prontodos + !byte <.jmpb412 + !byte <.laureate + !byte <.bbf9 + !byte <.micrograms + !byte <.cmpbne0 + !byte <.writeram + !byte <.d5timing + !byte <.advint + !byte <.dos32boot0 + !byte <.bootwrite + !byte <.rwtswrite + !byte <.rdos + !byte <.sra + !byte <.muse + !byte <.origin + !byte <.volumename + !byte <.dinkeydos + !byte <.trillium + !byte <.tamper + !byte <.microfun + !byte <.advent + !byte <.gathering + !byte <.davidson + !byte <.rdos13 + !byte <.ssi + !byte <.aacount + !byte <.infocom18 + !byte <.toverify + !byte <.sector13 + !byte <.dakin5 + !byte <.springboard + !byte <.hallabs + !byte <.holle + !byte <.hoffman + !byte <.diskvol0 + !byte <.e7everywhere + !byte <.choplifter + +StringTableHigh + !byte >.header + !byte >.mainmenu + !byte >.progbar + !byte >.reading + !byte >.diskrwts + !byte >.bb00 + !byte >.sunburst + !byte >.optimum + !byte >.builtin + !byte >.switch + !byte >.writing + !byte >.unformat + !byte >.f7 + !byte >.sync + !byte >.optbad + !byte >.passver + !byte >.passdemuf + !byte >.passcrack + !byte >.passcrack0 + !byte >.fail + !byte >.fatal0000 + !byte >.fatal220f + !byte >.done + !byte >.noslot6 + !byte >.writeerr + !byte >.writeioerr + !byte >.writenodev + !byte >.writeprot + !byte >.othermli + !byte >.canttrace + !byte >.canceled + !byte >.bademu + !byte >.reset + !byte >.modify + !byte >.modifyto + !byte >.dos33boot0 + !byte >.prodosboot0 + !byte >.pascalboot0 + !byte >.mecc + !byte >.sierra + !byte >.a6bc95 + !byte >.jmpbcf0 + !byte >.rol1e + !byte >.runhello + !byte >.e7 + !byte >.jmpb4bb + !byte >.jmpb400 + !byte >.jmpbeca + !byte >.bb03 + !byte >.thunder + !byte >.jmpae8e + !byte >.diskvol + !byte >.d5d5f7 + !byte >.construct + !byte >.datasoftb0 + !byte >.datasoft + !byte >.lsr6a + !byte >.bcs08 + !byte >.jmpb660 + !byte >.protdos + !byte >.decryptrwts + !byte >.protserial + !byte >.fbff + !byte >.encoded44 + !byte >.encoded53 + !byte >.specdel + !byte >.bytrack + !byte >.a5count + !byte >.restart + !byte >.corrupter + !byte >.eaboot0 + !byte >.eatrk6 + !byte >.eeef + !byte >.poke + !byte >.bootcounter + !byte >.milliken + !byte >.jsr8b3 + !byte >.daviddos + !byte >.quickdos + !byte >.diversidos + !byte >.prontodos + !byte >.jmpb412 + !byte >.laureate + !byte >.bbf9 + !byte >.micrograms + !byte >.cmpbne0 + !byte >.writeram + !byte >.d5timing + !byte >.advint + !byte >.dos32boot0 + !byte >.bootwrite + !byte >.rwtswrite + !byte >.rdos + !byte >.sra + !byte >.muse + !byte >.origin + !byte >.volumename + !byte >.dinkeydos + !byte >.trillium + !byte >.tamper + !byte >.microfun + !byte >.advent + !byte >.gathering + !byte >.davidson + !byte >.rdos13 + !byte >.ssi + !byte >.aacount + !byte >.infocom18 + !byte >.toverify + !byte >.sector13 + !byte >.dakin5 + !byte >.springboard + !byte >.hallabs + !byte >.holle + !byte >.hoffman + !byte >.diskvol0 + !byte >.e7everywhere + !byte >.choplifter + ; ; Text can contain substitution strings, which ; are replaced by current values at runtime. Each @@ -159,7 +280,7 @@ StringTable ; can be set directly before calling PrintByID. ; .header - !text "Passport by 4am 2019-04-13",$00 + !text "Passport by 4am 2019-04-15",$00 .mainmenu !text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D !text " " From 4e2ddef1d73f03228cb02a4130c3282bad026129 Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Mon, 15 Apr 2019 22:39:12 -0700 Subject: [PATCH 3/7] cut some bytes --- src/analyze.a | 58 +++++------- src/id/datasoft.a | 2 +- src/id/davidson.a | 2 +- src/id/dos33.a | 2 +- src/id/inspect0.a | 22 ++--- src/id/jsr8b3.a | 2 +- src/id/mecc.a | 2 +- src/id/pascal.a | 2 +- src/id/prodos.a | 2 +- src/id/rdos.a | 2 +- src/id/trace.a | 19 ++-- src/id/trace32.a | 14 +-- src/id/trace33p.a | 11 ++- src/memory.a | 179 ++++++++++++++++++------------------ src/passport.a | 54 +++++------ src/patchers/bootcounter.a | 7 +- src/patchers/border.a | 3 +- src/patchers/d5d5f7.a | 3 +- src/patchers/diskvol.a | 5 +- src/patchers/holle.a | 7 +- src/patchers/jmpae8e.a | 3 +- src/patchers/jmpb400.a | 2 +- src/patchers/jmpb4bb.a | 7 +- src/patchers/jmpbbfe.a | 1 - src/patchers/micrograms.a | 13 +-- src/patchers/prodosmecc.a | 82 ++++------------- src/patchers/prodosrwts.a | 20 +--- src/patchers/protecteddos.a | 2 +- src/patchers/rwtsswap.a | 3 +- src/patchers/universale7.a | 5 +- src/print.a | 33 ++++--- 31 files changed, 240 insertions(+), 329 deletions(-) diff --git a/src/analyze.a b/src/analyze.a index c9a61d5..5810beb 100755 --- a/src/analyze.a +++ b/src/analyze.a @@ -7,7 +7,8 @@ SkipTrack ; don't look for whole-track protections on track 0, that's silly lda gTrack - beq .donotskip + sec + beq .linknoskip ; ; Electronic Arts protection track? ; @@ -24,6 +25,7 @@ SkipTrack ; Unformatted track? ; jsr IsUnformatted +.linknoskip bcs .donotskip ; ; $F7F6EFEAAB protection track? @@ -52,15 +54,12 @@ SkipTrack ; lda gTrack cmp #$22 - bne + + clc + bne .donotskip lda gIsProDOS - bne + - lda #TRUE + bne .donotskip sta gPossibleGamco -+ clc - !byte $24 ; hides next SEC .donotskip - sec rts } @@ -79,40 +78,40 @@ IsF7F6 lda $C0E9 lda #$00 jsr WAIT + tay lda #$19 sta nibcount - ldy #$00 -- lda $C0EC - bpl - + jsr .readnib cmp #$F7 beq + .restart iny bne - dec nibcount bne - - beq .fail + sec + beq .driveoff + -- lda $C0EC - bpl - + jsr .readnib cmp #$F6 bne .restart -- lda $C0EC - bpl - + jsr .readnib cmp #$EF bne .restart -- lda $C0EC - bpl - + jsr .readnib cmp #$EE bne .restart -- lda $C0EC - bpl - + jsr .readnib cmp #$AB bne .restart clc - !byte $24 ; hides SEC -.fail sec +.driveoff lda $C0E8 rts + +.readnib +- lda $C0EC + bpl - + rts } ;------------------------------- @@ -250,7 +249,6 @@ xHeredityDog lda $08FE clc adc #$04 - pha ldx #$16 ldy #$4A jsr CompareMemory @@ -259,7 +257,6 @@ xHeredityDog !byte $C0,$10,$FB,$C9,$D5,$D0,$EE,$BD,$8C,$C0,$10,$FB,$C9,$AA,$D0,$E5 !byte $A9,$4C,$A0,$00,$99,$00,$95,$88,$D0,$FA,$CE,$46,$BB,$AD,$46,$BB !byte $C9,$07,$D0,$EC,$A9,$18,$8D,$42,$B9,$A9,$0A,$8D,$ED,$B7,$D0,$05 - pla bcs .exit lda #kSectorOptional sta T00S0A @@ -351,9 +348,8 @@ b4bbcompare !byte $08,$85,$3D,$85,$43,$A9,$BF,$85 !byte $3F,$A9,$00,$85,$3C,$85,$42,$E6 !byte $42,$A9,$FE,$85,$3E,$A0,$00,$AD - bcc + - jmp _b4bbexit -+ lda gIsDOS32 + bcs _b4bbexit + ldy gIsDOS32 beq .dos32 lda #$55 ; low byte of address that checks address prologue 1 sta b4bbmodify+1 @@ -368,14 +364,13 @@ b4bbcompare lda #$B2 ; low byte of address that checks address epilogue 1 sta b4bbmodify2+1 ldx #$01 ; track - ldy #$00 ; sector + ;;ldy #$00 ; sector .all stx gTrack sty gSector lda #$00 sta gAddress lda #$0C - clc adc #BASEPAGE sta gAddress+1 jsr ReadSector ; read sector so we can look for 'JMP $B4BB' marker @@ -386,13 +381,11 @@ b4bbcompare jsr compare !byte $4C,$BB,$B4 bcs _b4bbexit - lda gIsDOS32 - beq .dos32b ldx #$02 ; track ldy #$02 ; sector - bne .allb ; always branches + lda gIsDOS32 + bne .allb .dos32b - ldx #$02 ; track ldy #$09 ; sector .allb stx gTrack @@ -400,7 +393,6 @@ b4bbcompare jsr ReadSector ; read sector to get address prologue 3 for rest of disk bcs _b4bbexit lda #$0C - clc adc #BASEPAGE sta x0+2 x0 lda $FFC2 ; high byte modified at runtime (above) diff --git a/src/id/datasoft.a b/src/id/datasoft.a index fe91ab6..b2c718c 100755 --- a/src/id/datasoft.a +++ b/src/id/datasoft.a @@ -10,7 +10,7 @@ ;------------------------------- IDDatasoft lda #$00 - ldx #$00 + tax ldy #$7E jsr compare !byte $01,$4C,$7E,$08,$04,$8A,$0C,$B8 diff --git a/src/id/davidson.a b/src/id/davidson.a index e715253..00538aa 100644 --- a/src/id/davidson.a +++ b/src/id/davidson.a @@ -17,7 +17,7 @@ IDDavidson bne .no ; no, give up lda gSector ; sector $00? bne .no ; no, give up - lda #$00 ; try re-reading the sector but + ;;lda #$00 ; try re-reading the sector but sta $B92E ; ignore data field checksum failure jsr ReadSector lda #$13 diff --git a/src/id/dos33.a b/src/id/dos33.a index 41a249b..24d8cb7 100755 --- a/src/id/dos33.a +++ b/src/id/dos33.a @@ -32,7 +32,7 @@ IDDOS33 ; Code at $0801 must be standard (with one exception) ; ++ lda #$00 - ldx #$00 + tax ldy #$3F jsr compare ; if T00,S00,$00 == !byte $01 diff --git a/src/id/inspect0.a b/src/id/inspect0.a index 09838c1..41d6fe2 100755 --- a/src/id/inspect0.a +++ b/src/id/inspect0.a @@ -26,16 +26,16 @@ IDBootloader dex bpl - - lda gIsInfocom18 - bne .check13 lda #s_infocom18 - jsr PrintByID - jmp UseUniversal + ldx gIsInfocom18 + beq .printinfo .check13 lda gIs13Sector bne .sanity lda #s_13sector + +.printinfo jsr PrintByID jmp UseUniversal @@ -74,16 +74,14 @@ IDBootloader lda #TRUE sta gPossibleD5D5F7 + jsr IDDiversi - bcc .diversi - jsr IDPronto - bcc .pronto - lda #s_dosb0 - !byte $2c -.diversi lda #s_diversidos - !byte $2c -.pronto + bcc .printdos + jsr IDPronto lda #s_prontodos + bcc .printdos + lda #s_dosb0 + +.printdos jsr PrintByID jmp TraceDOS33 ; diff --git a/src/id/jsr8b3.a b/src/id/jsr8b3.a index 6e52d9a..0dc0500 100755 --- a/src/id/jsr8b3.a +++ b/src/id/jsr8b3.a @@ -13,7 +13,7 @@ !zone { ID8b3 lda #$00 - ldx #$00 + tax ldy #$5A jsr compare !byte $01,$20,$B3,$08,$D0,$19,$EA,$A5 diff --git a/src/id/mecc.a b/src/id/mecc.a index 07de565..ab978dc 100755 --- a/src/id/mecc.a +++ b/src/id/mecc.a @@ -16,7 +16,7 @@ !zone { IDMECC lda #$00 - ldx #$00 + tax ldy #$17 jsr compare !byte $01,$4C,$1A,$08,$17,$0F,$00,$00 diff --git a/src/id/pascal.a b/src/id/pascal.a index a1041cf..bd271ca 100644 --- a/src/id/pascal.a +++ b/src/id/pascal.a @@ -17,7 +17,7 @@ IDPascal ; addresses (e.g. Wizardry I, Sundog Frozen Legacy) ; lda #$00 - ldx #$00 + tax ldy #$08 jsr compare ; if T00,S00,$00 == !byte $01 diff --git a/src/id/prodos.a b/src/id/prodos.a index 4b29e68..4878ab2 100644 --- a/src/id/prodos.a +++ b/src/id/prodos.a @@ -17,7 +17,7 @@ IDProDOS ; Dazzle Draw, SuperPrint II). All of these variants ; will match. lda #$00 - ldx #$00 + tax ldy #$05 jsr compare ; if T00,S00,$00 == !byte $01 diff --git a/src/id/rdos.a b/src/id/rdos.a index e3902e1..4371be7 100644 --- a/src/id/rdos.a +++ b/src/id/rdos.a @@ -12,7 +12,7 @@ !zone { IDRDOS lda #$00 - ldx #$00 + tax ldy #$0E jsr compare ; if T00,S00,$00 == !byte $01 diff --git a/src/id/trace.a b/src/id/trace.a index ffb0a9f..804ed4d 100644 --- a/src/id/trace.a +++ b/src/id/trace.a @@ -15,24 +15,21 @@ Trace ldy #$01 jsr CopyMemory pla - tax - pla + ldx #0 ldy $B6F8 cpy #$4C - bne + - sty $B6F8 ; JMP for Disk II controller - sta $B6F9 ; lo byte of callback - stx $B6FA ; hi byte of callback - jmp $B600 + beq + + ldx #3 + ldy $B6FB cpy #$4C bne + - sty $B6FB ; JMP for IIgs smart controller - sta $B6FC ; lo byte of callback - stx $B6FD ; hi byte of callback + sta $B6FA,x ; hi byte of callback + pla + sta $B6F9,x ; lo byte of callback jmp $B600 -+ lda #s_canttrace ; unknown disk controller ++ pla + lda #s_canttrace ; unknown disk controller jsr PrintByID jmp UseUniversal } diff --git a/src/id/trace32.a b/src/id/trace32.a index bedd376..df6ed59 100644 --- a/src/id/trace32.a +++ b/src/id/trace32.a @@ -10,7 +10,7 @@ !zone { IDDOS32 lda #$00 - ldx #$00 + tax ldy #$0F jsr compare !byte $01 @@ -52,7 +52,7 @@ IDDOS32 !zone { IDDOS32LO lda #$00 - ldx #$00 + tax ldy #$0F jsr compare !byte $01 @@ -90,10 +90,11 @@ IDDOS32LO TraceDOS32 lda #<.TraceDOS32b ldx #>.TraceDOS32b - jmp Trace + bne .linktrace TraceDOS32LO lda #<.TraceDOS32LOb ldx #>.TraceDOS32LOb +.linktrace jmp Trace .TraceDOS32b @@ -101,7 +102,7 @@ TraceDOS32LO sta $0846 lda #>.TraceDOS32c sta $0847 - jmp $0801 + bne .linkjmp .TraceDOS32LOb ldy #$00 @@ -113,6 +114,7 @@ TraceDOS32LO sta $0838,y lda #>.TraceDOS32c sta $0839,y +.linkjmp jmp $0801 .TraceDOS32c @@ -336,13 +338,13 @@ FFer bne + iny bne - + tya ldy jCallRWTS+2 dey sty .G+2 dey sty .F+2 - ldy #$00 - tya + tay .F sta $FF00,y iny bne .F diff --git a/src/id/trace33p.a b/src/id/trace33p.a index 9693e86..fcdddf6 100755 --- a/src/id/trace33p.a +++ b/src/id/trace33p.a @@ -9,7 +9,7 @@ ;------------------------------- IDSpecDel lda #$00 - ldx #$00 + tax ldy #$58 jsr compare !byte $02,$90,$4A,$C6,$27,$BD,$31,$09 @@ -35,7 +35,7 @@ TraceSpecDel jsr ClearTSBuffer lda #$00 ; set a marker to see if entire sta $3FFF ; RWTS loads successfully later - lda #$00 ; save zero page before trace +;; lda #$00 ; save zero page before trace ldx #$0A ldy #$01 jsr CopyMemory @@ -164,9 +164,10 @@ SDsuccess jsr IncProgress inc gTrack - lda #$20 - ldx #$10 - ldy #$10 + lda #$10 + tax + tay + asl jsr CopyMemory jsr WriteTrackNA ; doesn't really write anything in verify-only mode diff --git a/src/memory.a b/src/memory.a index 62bcaaa..6f4cd49 100755 --- a/src/memory.a +++ b/src/memory.a @@ -17,6 +17,30 @@ ;------------------------------- +;------------------------------- +; SaveProDOS +; saves memory pages used by ProDOS +; pages $00, $03, $BF +; in: none +; out: all flags and registers clobbered +;------------------------------- +!zone { +SaveProDOS + lda #$00 + ldx #$40 + ldy #$01 + jsr CopyMemory + lda #$03 + ldx #$41 + ldy #$01 + jsr CopyMemory +SaveGlobal + lda #$BF + ldx #$42 + ldy #$01 + ;;jsr CopyMemory ; fall through +} + ;------------------------------- ; CopyMemory ; in: A = source address (high) @@ -40,27 +64,6 @@ CopyMemory rts } -;------------------------------- -; ClearMemory -; in: A = source address (high) -; X = value to set -; Y = number of pages -; out: all flags and registers clobbered -;------------------------------- -!zone { -ClearMemory - sta .dest+2 - txa - ldx #$00 -.dest sta $FF00,x - inx - bne .dest - inc .dest+2 - dey - bne .dest - rts -} - ;------------------------------- ; ClearTSBuffer ; clear the $1000 byte memory buffer @@ -72,7 +75,69 @@ ClearTSBuffer lda #BASEPAGE ldx #$00 ldy #$10 - jmp ClearMemory + ;; jmp ClearMemory ; fall through + +;------------------------------- +; ClearMemory +; in: A = source address (high) +; X = value to set +; Y = number of pages +; out: all flags and registers clobbered +;------------------------------- +!zone { +ClearMemory + sta .dest+2 +.dest stx $FF00 + inc .dest+1 + bne .dest + inc .dest+2 + dey + bne .dest + rts +} + +;------------------------------- +; ReorderBuffer - convert data +; buffer between ProDOS and +; DOS 3.3 ordering (use after +; read or before write under +; ProDOS) +; in: none +; out: all flags clobbered +; all registers clobbered +;------------------------------- +!zone { +ReorderBuffer + lda #BASEPAGE+1 + ldx #BASEPAGE+$0E + ldy #$07 + clc + bcc SwapMemory ; branch always +} + +;------------------------------- +; SwapProDOS +; saves/restores memory pages used by ProDOS +; pages $00, $03, $BF +; in: none +; out: all flags and registers clobbered +;------------------------------- +SwapProDOS + lda #$00 + ldx #$40 + ldy #$01 + sec + jsr SwapMemory + lda #$03 + ldx #$41 + ldy #$01 + sec + jsr SwapMemory + lda #$BF + ldx #$42 + ldy #$01 + sec + ;;jsr SwapMemory ; fall through ;------------------------------- ; SwapMemory @@ -114,76 +179,6 @@ SwapMemory rts } -;------------------------------- -; ReorderBuffer - convert data -; buffer between ProDOS and -; DOS 3.3 ordering (use after -; read or before write under -; ProDOS) -; in: none -; out: all flags clobbered -; all registers clobbered -;------------------------------- -!zone { -ReorderBuffer - lda #BASEPAGE+1 - ldx #BASEPAGE+$0E - ldy #$07 - clc - jmp SwapMemory -} - -;------------------------------- -; SaveProDOS -; saves memory pages used by ProDOS -; pages $00, $03, $BF -; in: none -; out: all flags and registers clobbered -;------------------------------- -!zone { -SaveProDOS - lda #$00 - ldx #$40 - ldy #$01 - jsr CopyMemory - lda #$03 - ldx #$41 - ldy #$01 - jsr CopyMemory -SaveGlobal - lda #$BF - ldx #$42 - ldy #$01 - jsr CopyMemory -.exit - rts -} - -;------------------------------- -; SwapProDOS -; saves/restores memory pages used by ProDOS -; pages $00, $03, $BF -; in: none -; out: all flags and registers clobbered -;------------------------------- -SwapProDOS - lda #$00 - ldx #$40 - ldy #$01 - sec - jsr SwapMemory - lda #$03 - ldx #$41 - ldy #$01 - sec - jsr SwapMemory - lda #$BF - ldx #$42 - ldy #$01 - sec - jsr SwapMemory - rts - ;------------------------------- ; ReorderLogicalToPhysical - reorder pages in ; track data buffer for disks that expect diff --git a/src/passport.a b/src/passport.a index 848a708..368f58e 100755 --- a/src/passport.a +++ b/src/passport.a @@ -503,12 +503,13 @@ nextsector dec checksector+2 .nodec dec checksector+1 - lda gSector - sec - sbc #$01 + ldy gSector + dey + tya jsr ChangeSector lda gSector bmi .prevtrack +.linkread jmp .read .prevtrack lda #$0F @@ -516,16 +517,15 @@ nextsector bne + lda #$0C + jsr ChangeSector - lda gTrack - sec - sbc #$01 + ldy gTrack + dey + tya jsr ChangeTrack jsr IncProgress lda gTrack bmi Pass cmp gLastTrack - bcc Pass - jmp .read + bcs .linkread Pass bit gMode bmi .passwrite @@ -543,12 +543,10 @@ Pass jsr WriteRAMToDisk bcc + jmp FatalWriteError -+ lda gPatchCount - beq .passcrack0 ++ lda #s_passcrack0 + ldx gPatchCount + beq .passprint lda #s_passcrack - !byte $2C ; hide next LDA -.passcrack0 - lda #s_passcrack0 .passprint jsr PrintByID jmp TheEnd @@ -600,17 +598,15 @@ FatalError jsr PrintByID lda gTrack cmp #$22 - beq .failont22 - jmp TheEnd + bne TheEnd .failont22 lda gSector cmp #$0F beq .failont22s0f ldx gIsDOS32 - bne + + bne TheEnd cmp #$0C - beq .failont22s0f -+ jmp TheEnd + bne TheEnd .failont22s0f lda #s_fatal220f jsr PrintByID @@ -706,22 +702,18 @@ WriteTrackNA ; entry point used by Special Delivery tracer ;------------------------------- FatalWriteError sta gDisplayBytes ; for use in error messages, if any - cmp #MLI_IOERR - beq .ioerr - cmp #MLI_NODEV - beq .nodev - cmp #MLI_WRITEPROT - beq .writeprot - lda #s_othermli - !byte $2C ; hide next LDA -.ioerr + tax lda #s_writeioerr - !byte $2C ; hide next LDA -.nodev + cpx #MLI_IOERR + beq .printerr lda #s_writenodev - !byte $2C ; hide next LDA -.writeprot + cpx #MLI_NODEV + beq .printerr lda #s_writeprot + cpx #MLI_WRITEPROT + beq .printerr + lda #s_othermli +.printerr pha lda #s_writeerr jsr PrintByID diff --git a/src/patchers/bootcounter.a b/src/patchers/bootcounter.a index 1e0cd58..3b510e7 100644 --- a/src/patchers/bootcounter.a +++ b/src/patchers/bootcounter.a @@ -7,11 +7,10 @@ !zone { bit gMode ; nothing to do here in verify-only mode bpl .exit - lda gTrack - cmp #$01 + ldx gTrack + dex bne .exit - lda #$00 - ldx #$00 + txa ldy #$23 jsr compare ; if T01,S00,$00 != !byte $AD,$F3,$03,$8D,$F4,$03,$20,$2F diff --git a/src/patchers/border.a b/src/patchers/border.a index d44645b..fbeca05 100644 --- a/src/patchers/border.a +++ b/src/patchers/border.a @@ -10,8 +10,7 @@ bit gMode ; nothing to do here in verify-only mode bpl .exit lda gIsBoot0 ; if DOS 3.3 boot0 loader - bne .exit - lda gIsBoot1 ; and DOS 3.3 boot1 loader + ora gIsBoot1 ; and DOS 3.3 boot1 loader bne .exit lda #$08 ldx #$5A diff --git a/src/patchers/d5d5f7.a b/src/patchers/d5d5f7.a index 9c64a3a..cd9f585 100755 --- a/src/patchers/d5d5f7.a +++ b/src/patchers/d5d5f7.a @@ -29,8 +29,7 @@ ; additional samples.) ; lda gIsBoot0 - bne .exit - lda gPossibleD5D5F7 + ora gPossibleD5D5F7 bne .exit + ldy #$20 diff --git a/src/patchers/diskvol.a b/src/patchers/diskvol.a index aa936a5..de3e5ae 100755 --- a/src/patchers/diskvol.a +++ b/src/patchers/diskvol.a @@ -12,7 +12,7 @@ lda #$01 ldx #$EE - ldy #$01 + tay jsr compare ; and T00,S01,$EE == !byte $FB bcs .exit @@ -27,8 +27,7 @@ beq .yes lda gIsPanglosDOS - bne + - lda gCapturedDiskVolumeNumber + ora gCapturedDiskVolumeNumber bne + lda gDiskVolumeNumber cmp #$FE diff --git a/src/patchers/holle.a b/src/patchers/holle.a index 57fe3a4..edc63b2 100644 --- a/src/patchers/holle.a +++ b/src/patchers/holle.a @@ -18,8 +18,7 @@ - jmp .exit + bvc - ; nothing to do here in demuffin mode lda gIsHolle - beq + - jmp .exit + bne - + lda gTrack bne + jmp .DecryptBootloader @@ -246,11 +245,11 @@ EOR $01 AND #$01 .alternatingTrackEnd - bcs + + bcs .exit ldy #$01 jsr modify !byte $A9 ; EOR -> LDA so alternating track check always passes -+ + jmp .exit .reorderAndExit jsr ReorderBuffer diff --git a/src/patchers/jmpae8e.a b/src/patchers/jmpae8e.a index d480af4..536456a 100755 --- a/src/patchers/jmpae8e.a +++ b/src/patchers/jmpae8e.a @@ -8,8 +8,7 @@ bit gMode ; nothing to do here in verify-only mode bpl .exit lda gIsBoot0 ; if DOS 3.3 boot0 loader - bne .exit - lda gIsBoot1 ; and DOS 3.3 boot1 loader + ora gIsBoot1 ; and DOS 3.3 boot1 loader bne .exit lda #$0D ldx #$4D diff --git a/src/patchers/jmpb400.a b/src/patchers/jmpb400.a index e84f6b2..110b139 100644 --- a/src/patchers/jmpb400.a +++ b/src/patchers/jmpb400.a @@ -52,7 +52,7 @@ jsr PrintByID lda #$03 ldx #$00 - ldy #$03 + tay jsr modify ; then set T02,S03,$00 = !byte $4C,$84,$9D .exit diff --git a/src/patchers/jmpb4bb.a b/src/patchers/jmpb4bb.a index fc6818e..73bfe36 100755 --- a/src/patchers/jmpb4bb.a +++ b/src/patchers/jmpb4bb.a @@ -10,12 +10,11 @@ lda gTrack cmp #$02 bne .exit - lda gIsDOS32 + lda #$03 + ldx gIsDOS32 bne + lda #$0A - !byte $2C ; hide next LDA -+ lda #$03 - sta gDisplayBytes ++ sta gDisplayBytes ldx #$D7 ldy #$04 jsr compare ; and T02,S0x,$D7 == diff --git a/src/patchers/jmpbbfe.a b/src/patchers/jmpbbfe.a index 28e9d13..878e228 100755 --- a/src/patchers/jmpbbfe.a +++ b/src/patchers/jmpbbfe.a @@ -10,7 +10,6 @@ _jmpbbfe bpl .exit lda gIsBoot0 ; if DOS 3.3 boot0 loader bne .exit - lda #$00 ldx #$4A ldy #$03 jsr compare ; and T00,S00,$4A == diff --git a/src/patchers/micrograms.a b/src/patchers/micrograms.a index e0bdf35..e3610a6 100644 --- a/src/patchers/micrograms.a +++ b/src/patchers/micrograms.a @@ -19,14 +19,11 @@ !byte $C9,$BE !byte $D0,$E5 bcs .exit - inx - inx - inx - inx - inx - inx - inx - inx + tay + txa + adc #8 + tax + tya ldy #$01 jsr modify ; change BNE to continue instead !byte $00 diff --git a/src/patchers/prodosmecc.a b/src/patchers/prodosmecc.a index f6d24b3..f085305 100755 --- a/src/patchers/prodosmecc.a +++ b/src/patchers/prodosmecc.a @@ -18,17 +18,11 @@ !byte $20,$10,$30,WILDCARD,$AA,$EB bcs + sta gDisplayBytes - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx + tay + txa + adc #$0B + tax + tya ldy #$01 jsr compare !byte $DE @@ -44,25 +38,11 @@ !byte $02,$18,$24,$38,$60 bcs + sta gDisplayBytes - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx + tay + txa + adc #$13 + tax + tya ldy #$01 jsr compare !byte $38 @@ -81,28 +61,11 @@ !byte $C9,$DE,$F0,$02,$18,$24,$38,$60 bcs + sta gDisplayBytes - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx + tay + txa + adc #$16 + tax + tya ldy #$01 jsr compare !byte $38 @@ -121,16 +84,11 @@ !byte $38 !byte $60 bcs + - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx + tay + txa + adc #$0A + tax + tya ldy #$01 jsr compare !byte $38 diff --git a/src/patchers/prodosrwts.a b/src/patchers/prodosrwts.a index 5447efd..d95ba77 100755 --- a/src/patchers/prodosrwts.a +++ b/src/patchers/prodosrwts.a @@ -23,21 +23,11 @@ _prodosrwts !byte $38 bcs .exit sta gDisplayBytes - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx - inx + tay + txa + adc #$0F + tax + tya ldy #$01 jsr compare !byte $DE diff --git a/src/patchers/protecteddos.a b/src/patchers/protecteddos.a index 7b9fa0c..0377175 100755 --- a/src/patchers/protecteddos.a +++ b/src/patchers/protecteddos.a @@ -152,7 +152,7 @@ ; lda #$01 ldx #$07 - ldy #$01 + tay jsr modify ; set T00,S01,$07 = !byte $2C diff --git a/src/patchers/rwtsswap.a b/src/patchers/rwtsswap.a index 61dbea4..64f2172 100755 --- a/src/patchers/rwtsswap.a +++ b/src/patchers/rwtsswap.a @@ -10,8 +10,7 @@ bit gMode ; nothing to do here in verify-only mode bpl .exit lda gIsBoot0 ; if DOS 3.3 boot0 loader - bne .exit - lda gIsBoot1 ; and DOS 3.3 boot1 loader + ora gIsBoot1 ; and DOS 3.3 boot1 loader bne .exit lda #$04 ldx #$69 diff --git a/src/patchers/universale7.a b/src/patchers/universale7.a index bb5e6d0..436749c 100755 --- a/src/patchers/universale7.a +++ b/src/patchers/universale7.a @@ -54,9 +54,8 @@ universale7 !byte $00,$00,$00,$00,$00,$00,$00,$00 !byte $00,$00,$00,$00,$00,$00,$00,$00 !byte $00,$00,$00,$00,$00,$00,$00,$00 - bcc + - jmp .nextsector -+ + bcs .nextsector + lda .sector+1 sta gDisplayBytes lda #s_e7 diff --git a/src/print.a b/src/print.a index 6cb3502..5f9d4df 100755 --- a/src/print.a +++ b/src/print.a @@ -96,15 +96,9 @@ PrintByID ; @tmpy clobbered ;------------------------------- PrintByte - sta tmpa - stx tmpx - sty tmpy + jsr .saveAXY jsr PRBYTE - lda tmpa - ldx tmpx - ldy tmpy - clv - rts + jmp .loadAXY ;------------------------------- ; PrintA @@ -117,16 +111,22 @@ PrintByte ; @tmpy clobbered ;------------------------------- PrintA - sta tmpa - stx tmpx - sty tmpy + jsr .saveAXY jsr COUT + +.loadAXY lda tmpa ldx tmpx ldy tmpy clv rts +.saveAXY + sta tmpa + stx tmpx + sty tmpy + rts + ;------------------------------- ; ClearScreen ;------------------------------- @@ -144,17 +144,16 @@ ClearScreen ldy #$00 sty flag .loop - lda $FF00,y ; modified at runtime - cmp #$A0 + ldx $FF00,y ; modified at runtime + cpx #$A0 beq .nochange bcs .down - clc - adc #$01 + inx bne .change .down - sec - sbc #$01 + dex .change + txa sta $FF00,y ; modified at runtime sta flag .nochange From 8740b3447c90a7ecc5160e997afa2811ff640987 Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Tue, 16 Apr 2019 11:26:59 -0700 Subject: [PATCH 4/7] placeholder for write routine --- src/id/trace.a | 8 ++--- src/patchers/choplifter.a | 60 ++++++++++++++++++++++++---------- src/patchers/dos32muse.a | 4 +-- src/patchers/hallabs.a | 4 +-- src/patchers/rwtsswappenguin.a | 4 +-- 5 files changed, 52 insertions(+), 28 deletions(-) diff --git a/src/id/trace.a b/src/id/trace.a index 804ed4d..aac3506 100644 --- a/src/id/trace.a +++ b/src/id/trace.a @@ -20,15 +20,15 @@ Trace cpy #$4C beq + ldx #3 -+ ldy $B6FB + ldy $B6FB cpy #$4C - bne + - sta $B6FA,x ; hi byte of callback + bne ++ ++ sta $B6FA,x ; hi byte of callback pla sta $B6F9,x ; lo byte of callback jmp $B600 -+ pla +++ pla lda #s_canttrace ; unknown disk controller jsr PrintByID jmp UseUniversal diff --git a/src/patchers/choplifter.a b/src/patchers/choplifter.a index 6605671..433b874 100644 --- a/src/patchers/choplifter.a +++ b/src/patchers/choplifter.a @@ -11,6 +11,9 @@ Choplifter bit gMode ; nothing to do here in verify-only mode bpl .exit + +;;prepare write routine at $2000-21ff first + lda #$00 sta gCommand sta dct+1 @@ -27,12 +30,13 @@ Choplifter jsr ReadChoplifter lsr gTrack jsr WriteTrackNA - lda gTrack - clc - adc #$01 + ldx gTrack + inx + txa + pha jsr ChangeTrackNW jsr IncProgress - lda gTrack + pla cmp #$23 bne .read @@ -264,16 +268,22 @@ ReadChoplifter nop ; timing bits ldx #$00 - jsr .read4x4 - sta (BASEPAGE+8)<<8,x + sta (BASEPAGE+$0f)<<8,x inx jsr .read4x4 - sta (BASEPAGE+8)<<8,x + sta (BASEPAGE+$0f)<<8,x inx jsr .read4x4 - sta (BASEPAGE+8)<<8,x + sta (BASEPAGE+$0f)<<8,x inx cmp #$EA bne - + ldx #0 +.copywrite1 + lda $2000,x + sta (BASEPAGE+8)<<8,x + inx + bne .copywrite1 rts .readtrack22 @@ -284,7 +294,7 @@ ReadChoplifter dey bne + dex - beq ++ + beq .copywrite2 + lda KEY bmi .linkcancel3 jsr .readnib @@ -304,7 +314,13 @@ ReadChoplifter sta BASEPAGE<<8,x inx bne - -++ rts + +.copywrite2 + lda $2100,x + sta (BASEPAGE+7)<<8,x + inx + bne .copywrite2 + rts .read4x4 - lda $C0EC @@ -354,8 +370,18 @@ ReadChoplifter .stage2 !pseudopc $B000 { ; high address that won't be hit on the first round of SD lda $c057 + lda $c054 lda $c052 lda $c050 + ldx #$42 + txs + lda #>(.resume-1) + pha + lda #<(.resume-1) + pha + jmp $4000 + +.resume ldy #0 - lda .stager,y sta $500,y @@ -370,6 +396,7 @@ ReadChoplifter sty $807 ldy #$60 ; rts sty $84c + ldx $2b jsr .callSD ; including original $8xx to $7xx asl $807 ; 4xx, second table jmp $500 @@ -379,9 +406,11 @@ ReadChoplifter jsr .step lda #$60 sta $801 - lda #4 + lda #2 sta $27 - jsr $823 ; read patch table + jsr $823 ; read half of write routine to $200 (but starts at $207) + inc $27 + jsr $823 ; read patch table to $400 ldy #0 ; avoid CFFA bug - lda $400,y sta .patcher+1 @@ -400,13 +429,7 @@ ReadChoplifter sta $3d dec $27 jsr $823 ; read high scores - lsr $27 - lda #7 - sta $26 - jsr $823 ; read half of write routine to $207 - asl $27 - lda #0 - sta $26 + inc $27 jsr $823 ; read half of write routine to $600 ldy #0 ; avoid CFFA bug - lda ($26),y @@ -415,6 +438,7 @@ ReadChoplifter sta $300,y iny bne - + lda $C088,x jmp ($20) .callSD diff --git a/src/patchers/dos32muse.a b/src/patchers/dos32muse.a index c63051c..4833aaa 100644 --- a/src/patchers/dos32muse.a +++ b/src/patchers/dos32muse.a @@ -10,8 +10,8 @@ bpl .exit lda gIsDOS32 bne .exit - lda gTrack - cmp #$01 + ldx gTrack + dex bne .exit lda #$08 ldx #$D6 diff --git a/src/patchers/hallabs.a b/src/patchers/hallabs.a index b1a61af..4a6a9f2 100644 --- a/src/patchers/hallabs.a +++ b/src/patchers/hallabs.a @@ -11,8 +11,8 @@ bpl .exit lda gIsBoot0 bne .exit - lda gTrack - cmp #$01 + ldx gTrack + dex bne .exit ldy #(@search1end-@search1start) diff --git a/src/patchers/rwtsswappenguin.a b/src/patchers/rwtsswappenguin.a index 81d9d84..cdf4d76 100644 --- a/src/patchers/rwtsswappenguin.a +++ b/src/patchers/rwtsswappenguin.a @@ -12,8 +12,8 @@ !zone { bit gMode ; nothing to do here in verify-only mode bpl .exit - lda gTrack ; and track 1 - cmp #$01 + ldx gTrack ; and track 1 + dex bne .exit lda #$04 ldx #$52 From 22b2c8a867e609801a9d8213aa73cecc05d405e3 Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Tue, 16 Apr 2019 18:16:40 -0700 Subject: [PATCH 5/7] re-enable Pascal, Datasoft, RDOS, etc. --- src/id/inspect0.a | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/id/inspect0.a b/src/id/inspect0.a index 41d6fe2..0067ffb 100755 --- a/src/id/inspect0.a +++ b/src/id/inspect0.a @@ -215,18 +215,16 @@ IDBootloader lda #TRUE sta gIsProDOS jsr IDVolumeName - bcc + - jmp UseUniversal -+ + bcs .useuniv + ; ; Dinkey-DOS (ProDOS file structure with DOS 3.3-ish RWTS in language card) ; detectable now because IDVolumeName just read the first sector of the ; volume directory into memory so we can look for a unique filename ; jsr IDDinkeyDOS - bcc + - jmp UseUniversal -+ lda #s_dinkeydos + bcs .useuniv + lda #s_dinkeydos jsr PrintByID lda #TRUE sta gIsDinkeyDOS From c309ea313e5b90be4ba71dcaa456d8543f582825 Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Tue, 16 Apr 2019 22:56:58 -0700 Subject: [PATCH 6/7] fix timing, free some memory --- src/apidefs.a | 2 +- src/memory.a | 32 ++------ src/patchers/choplifter.a | 157 +++++++++++++++++--------------------- 3 files changed, 77 insertions(+), 114 deletions(-) diff --git a/src/apidefs.a b/src/apidefs.a index ab037b9..679ef74 100644 --- a/src/apidefs.a +++ b/src/apidefs.a @@ -48,7 +48,7 @@ flag = $FF ; byte RELBASE = $2000 ; dummy assignment for first build ; to allow calculation of proper value } -LOWPOINT = $4300 ; lowest available address for code +LOWPOINT = $4000 ; lowest available address for code HIGHPOINT = $B200 ; highest available address+1 for code BASEPAGE = $10 ; Special Delivery tracer assumes ; this is $10, so don't change it! diff --git a/src/memory.a b/src/memory.a index 6f4cd49..342c3c7 100755 --- a/src/memory.a +++ b/src/memory.a @@ -7,12 +7,12 @@ ; 0A00..0AFF - backup of zero page during Special Delivery tracer, used by RAM disk ; 0B00..0BFF - used by RAM disk ; 0C00..0CFF - clobbered by Special Delivery tracer -; 0D00..0FFF - unused +; 0D00..0EFF - unused +; 0F00..0FFF - backup of page $BF (SaveProDOS, SwapProDOS) ; 1000..1FFF - data buffer for current track ; 2000..35FF - clobbered by Special Delivery tracer ; 3600..3FFF - clobbered by lomem DOS 3.3 / Special Delivery tracers -; 4000..42FF - backup of zero page, page 3, page $BF (SaveProDOS, SwapProDOS) -; 4300..B1FF - program code +; 4000..B1FF - program code ; B200..BFFF - clobbered by DOS boot tracer (RDOS is B200+, DOS 3.x is B600+) ;------------------------------- @@ -20,23 +20,15 @@ ;------------------------------- ; SaveProDOS ; saves memory pages used by ProDOS -; pages $00, $03, $BF +; pages $BF ; in: none ; out: all flags and registers clobbered ;------------------------------- !zone { SaveProDOS - lda #$00 - ldx #$40 - ldy #$01 - jsr CopyMemory - lda #$03 - ldx #$41 - ldy #$01 - jsr CopyMemory SaveGlobal lda #$BF - ldx #$42 + ldx #$0F ldy #$01 ;;jsr CopyMemory ; fall through } @@ -118,23 +110,13 @@ ReorderBuffer ;------------------------------- ; SwapProDOS ; saves/restores memory pages used by ProDOS -; pages $00, $03, $BF +; pages $BF ; in: none ; out: all flags and registers clobbered ;------------------------------- SwapProDOS - lda #$00 - ldx #$40 - ldy #$01 - sec - jsr SwapMemory - lda #$03 - ldx #$41 - ldy #$01 - sec - jsr SwapMemory lda #$BF - ldx #$42 + ldx #$0F ldy #$01 sec ;;jsr SwapMemory ; fall through diff --git a/src/patchers/choplifter.a b/src/patchers/choplifter.a index 433b874..3e7f08b 100644 --- a/src/patchers/choplifter.a +++ b/src/patchers/choplifter.a @@ -12,7 +12,8 @@ Choplifter bit gMode ; nothing to do here in verify-only mode bpl .exit -;;prepare write routine at $2000-21ff first +;; prepare write routine at $2000 for relocated address at $207 +;; the difficulty here is to find three spare pages across all games lda #$00 sta gCommand @@ -21,11 +22,6 @@ Choplifter jsr IncProgress .read - lda KEY - bpl .continue - jmp .cancel - -.continue asl gTrack jsr ReadChoplifter lsr gTrack @@ -98,10 +94,6 @@ Choplifter jsr .cleanup jmp Pass -.cancel - jsr .cleanup - jmp Cancel - .cleanup lda $C0E8 lda #$01 @@ -140,20 +132,16 @@ ReadChoplifter .checkkey1 lda KEY -.linkcancel1 bmi .cancel jsr .readnib - cmp #$DD bne .checkkey1 jsr .readnib --- cmp #$F5 + cmp #$F5 bne - jsr .readnib cmp #$D5 - bne -- ; this is the same bug - nop ; timing bits - nop ; timing bits - nop ; timing bits + bne - ; this had the same bug (see below) ldx #$03 - jsr .read4x4 jsr .read4x4 @@ -168,6 +156,10 @@ ReadChoplifter bcs .checktrack20 rts +.cancel + jsr .cleanup + jmp Cancel + .settrack00 lda #$D5 sta cmp1+1 @@ -190,21 +182,19 @@ ReadChoplifter .checkkey0 lda KEY .linkcancel2 - bmi .linkcancel1 + bmi .cancel jsr .readnib - cmp cmp2+1 bne .checkkey0 jsr .readnib --- cmp cmp2+0 + cmp cmp2+0 bne - jsr .readnib - cmp cmp1+1 - bne -- ; this is a bug - ; it allows PR0 PR1 [any] PR1 PR2 instead of requiring PR0 PR1 PR2 - nop ; timing bits - nop ; timing bits - nop ; timing bits - ldy #0 + eor cmp1+1 + bne - ; this had a bug + ; it branched to the middle nibble instead of the first one + ; it allowed PR0 PR1 [any] PR1 PR2 instead of requiring PR0 PR1 PR2 + tay -- jsr .read4x4 sta (modsrc), y iny @@ -246,81 +236,75 @@ ReadChoplifter sta .prolog2+1 lda (BASEPAGE<<8)+$D3 sta .prolog3+1 - -.checkkey2 - lda KEY -.linkcancel3 - bmi .linkcancel2 - jsr .readnib +-- jsr .readnib .prolog1 - cmp #$D1 ; SMC - bne .checkkey2 + bne -- jsr .readnib .prolog2 --- cmp #$D1 ; SMC + cmp #$D1 ; SMC bne - jsr .readnib .prolog3 - cmp #$D1 ; SMC - bne -- ; this is the same bug - nop ; timing bits - nop ; timing bits - nop ; timing bits - ldx #$00 -- jsr .read4x4 + eor #$D1 ; SMC + bne - ; this had the same bug + tax +-- lda $C0EC ; timing issue requires unrolling part of this + bpl -- + sec + rol + sta tmp + jsr .readnib + and tmp sta (BASEPAGE+$0f)<<8,x inx jsr .read4x4 sta (BASEPAGE+$0f)<<8,x inx - jsr .read4x4 + jsr .readnib + sec + rol + sta tmp +- lda $C0EC + bpl - + and tmp sta (BASEPAGE+$0f)<<8,x inx cmp #$EA - bne - - ldx #0 -.copywrite1 - lda $2000,x - sta (BASEPAGE+8)<<8,x - inx - bne .copywrite1 + bne -- +;; future work, just disable for now +;; ldx #0 +;;.copywrite +;; lda .writeroutine,x +;; sta (BASEPAGE+8)<<8,x +;; inx +;; bne .copywrite + lda #$60 ; rts + sta ((BASEPAGE+8)<<8)+7 rts .readtrack22 ldx #$40 ldy #0 - -.checkkey3 - dey +-- dey bne + dex - beq .copywrite2 -+ lda KEY - bmi .linkcancel3 - jsr .readnib + beq ++ ++ jsr .readnib - cmp #$D5 - bne .checkkey3 + bne -- jsr .readnib --- cmp #$FF + cmp #$FF bne - jsr .readnib cmp #$DD - bne -- ; this is the same bug - nop ; timing bits - nop ; timing bits - nop ; timing bits + bne - ; this had the same bug ldx #$00 - jsr .read4x4 sta BASEPAGE<<8,x inx bne - - -.copywrite2 - lda $2100,x - sta (BASEPAGE+7)<<8,x - inx - bne .copywrite2 - rts +++ rts .read4x4 - lda $C0EC @@ -359,7 +343,7 @@ ReadChoplifter txa sta (modsrc),y tya - adc #$17 ; carry set by sbc + adc #$18-1 ; carry set by sbc tay txa adc #$0F @@ -382,14 +366,15 @@ ReadChoplifter jmp $4000 .resume - ldy #0 -- lda .stager,y - sta $500,y - lda (*+$ff) and $ff00,y - sta $200,y - lda (*+$1ff) and $ff00,y - sta $400,y - iny + ldx #0 +- lda .stager,x + sta $500,x + lda (*+$ff) and $ff00,x + sta $200,x + lda (*+$1ff) and $ff00,x + sta $400,x + txs + inx bne - jsr .dostep4 ldy #2 ; pagehi, first table @@ -408,10 +393,10 @@ ReadChoplifter sta $801 lda #2 sta $27 - jsr $823 ; read half of write routine to $200 (but starts at $207) + jsr $823 ; read write routine to $200 (but starts at $207) inc $27 jsr $823 ; read patch table to $400 - ldy #0 ; avoid CFFA bug + ldy #0 ; avoid CFFA bug (Y is not zero on return) - lda $400,y sta .patcher+1 lda $401,y @@ -428,14 +413,10 @@ ReadChoplifter jsr .dostep2 ; reach track $22 sta $3d dec $27 - jsr $823 ; read high scores - inc $27 - jsr $823 ; read half of write routine to $600 - ldy #0 ; avoid CFFA bug -- lda ($26),y + jsr $823 ; read high scores to $400 + ldy #0 ; avoid CFFA bug (Y is not zero on return) +- lda $700,y sta $800,y - lda $600,y - sta $300,y iny bne - lda $C088,x @@ -457,6 +438,6 @@ ReadChoplifter jsr $82F lsr $40 rts -} -} + } ;$5xx + } ;$Bxxx } From 7c6ee6e9cb302b0eace29d485dfe61da7256cef0 Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Wed, 17 Apr 2019 09:50:44 -0700 Subject: [PATCH 7/7] support verify --- src/patchers/choplifter.a | 50 +++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/patchers/choplifter.a b/src/patchers/choplifter.a index 3e7f08b..ce70a51 100644 --- a/src/patchers/choplifter.a +++ b/src/patchers/choplifter.a @@ -6,15 +6,9 @@ ; module by qkumba ;------------------------------- !zone { -.exit rts ; reachable only via inspect + rts ; reachable only via inspect Choplifter - bit gMode ; nothing to do here in verify-only mode - bpl .exit - -;; prepare write routine at $2000 for relocated address at $207 -;; the difficulty here is to find three spare pages across all games - lda #$00 sta gCommand sta dct+1 @@ -36,6 +30,9 @@ Choplifter cmp #$23 bne .read + bit gMode ; done if in verify-only mode + bpl .exit + ; start with RDOS as a minimal SD base ; and copy SD code for free @@ -91,6 +88,8 @@ Choplifter sta gTrack jsr WriteTrackNA inc gPatchCount + +.exit jsr .cleanup jmp Pass @@ -236,10 +235,15 @@ ReadChoplifter sta .prolog2+1 lda (BASEPAGE<<8)+$D3 sta .prolog3+1 --- jsr .readnib + +.checkkey2 + lda KEY + bmi .linkcancel2 + jsr .readnib + .prolog1 - cmp #$D1 ; SMC - bne -- + bne .checkkey2 jsr .readnib .prolog2 cmp #$D1 ; SMC @@ -256,10 +260,10 @@ ReadChoplifter sta tmp jsr .readnib and tmp - sta (BASEPAGE+$0f)<<8,x + sta (BASEPAGE+8)<<8,x inx jsr .read4x4 - sta (BASEPAGE+$0f)<<8,x + sta (BASEPAGE+8)<<8,x inx jsr .readnib sec @@ -268,19 +272,10 @@ ReadChoplifter - lda $C0EC bpl - and tmp - sta (BASEPAGE+$0f)<<8,x + sta (BASEPAGE+8)<<8,x inx cmp #$EA bne -- -;; future work, just disable for now -;; ldx #0 -;;.copywrite -;; lda .writeroutine,x -;; sta (BASEPAGE+8)<<8,x -;; inx -;; bne .copywrite - lda #$60 ; rts - sta ((BASEPAGE+8)<<8)+7 rts .readtrack22 @@ -389,12 +384,17 @@ ReadChoplifter .stager !pseudopc $500 { jsr .callSD jsr .step - lda #$60 + lda #$60 ; rts sta $801 - lda #2 + + ; to enable writing requires finding three spare pages + ; that is common to all games. I did not succeed. + ; for that reason, auto-crack is read-only. + + sta $207 + + lda #4 sta $27 - jsr $823 ; read write routine to $200 (but starts at $207) - inc $27 jsr $823 ; read patch table to $400 ldy #0 ; avoid CFFA bug (Y is not zero on return) - lda $400,y