From 935779e6e814062c70243d10208d436f6d0c1f9d Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Tue, 23 Apr 2019 21:59:04 -0700 Subject: [PATCH 1/5] support EDDs like Neptune --- src/patchers/choplifter.a | 274 +++++++++++++++++++++----------------- src/strings/en.a | 2 +- 2 files changed, 154 insertions(+), 122 deletions(-) diff --git a/src/patchers/choplifter.a b/src/patchers/choplifter.a index cbac599..e237cde 100644 --- a/src/patchers/choplifter.a +++ b/src/patchers/choplifter.a @@ -8,6 +8,7 @@ ; tested on ; - Choplifter (Broderbund) ; - Eggs-It (Gebelli) +; - Neptune (Gebelli) ;------------------------------- !zone { rts ; reachable only via inspect @@ -131,34 +132,6 @@ ReadChoplifter .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 had the same bug (see below) - ldx #$03 -- jsr .read4x4 - jsr .read4x4 - jsr .read4x4 - sta cmp1+0,x - dex - bpl - - rts - -.checktrack1E - cmp #$40 - bcs .checktrack20 - rts - .cancel jsr .cleanup jmp Cancel @@ -176,53 +149,52 @@ ReadChoplifter .readtrack stx tmpx - ldx #3 - -.retry0 - dex - beq .fatal - -.checkkey0 - lda KEY -.linkcancel2 - bmi .cancel - jsr .readnib -- cmp cmp2+1 - bne .checkkey0 - jsr .readnib - cmp cmp2+0 + ldx #$00 +- lda .readtracki,x + sta $2000,x + inx bne - - jsr .readnib - 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 - 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 + jsr $2000 ; must run from page-aligned address for precise timing + + ;back-up in case of read failure + + lda unform+0 ; prologue 2 + sta cmp2+0 + lda unform+1 ; prologue 1 + sta cmp2+1 + lda prbuf+0 ; epilog + sta cmp1+0 + lda prbuf+1 ; prologue 3 + sta cmp1+1 rts -.fatal - jsr .cleanup - ; if we get to here, we've - jmp FatalError ; decided the read error is fatal +.readtrack0B + +.checkkey1 + lda KEY + bmi .cancel + jsr ReadNib +- cmp #$DD + bne .checkkey1 + jsr ReadNib + cmp #$F5 + bne - + jsr ReadNib + cmp #$D5 + bne - ; this had the same bug (see below) + ldx #$03 +- jsr Read4x4 + jsr Read4x4 + jsr Read4x4 + sta cmp1+0,x + dex + bpl - + rts + +.checktrack1E + cmp #$40 + bcs .checktrack20 + rts .checktrack20 beq .readtrack20 @@ -234,92 +206,152 @@ ReadChoplifter ldx #1 jsr .readtrack lda (BASEPAGE<<8)+$C5 - sta .prolog1+1 + sta .readtrack20i+.prolog1+1-.reloc lda (BASEPAGE<<8)+$CC - sta .prolog2+1 + sta .readtrack20i+.prolog2+1-.reloc lda (BASEPAGE<<8)+$D3 - sta .prolog3+1 + sta .readtrack20i+.prolog3+1-.reloc + ldy #$00 +- lda .readtrack20i,y + sta $2100,y + iny + bne - + ldx #$60 + jmp $2100 ; must run from page-aligned address for precise timing -.checkkey2 - lda KEY - bmi .linkcancel2 - jsr .readnib +.readtrack20i !pseudopc $2100 { +.reloc +-- jsr .readnibx .prolog1 - cmp #$D1 ; SMC - bne .checkkey2 - jsr .readnib + bne -- + jsr .readnibx .prolog2 cmp #$D1 ; SMC bne - - jsr .readnib + jsr .readnibx .prolog3 - eor #$D1 ; SMC + cmp #$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 + jsr .readnibx and tmp - sta (BASEPAGE+8)<<8,x - inx - jsr .read4x4 - sta (BASEPAGE+8)<<8,x - inx - jsr .readnib + sta (BASEPAGE+8)<<8,y + iny + jsr .read4x4x + sta (BASEPAGE+8)<<8,y + iny + jsr .readnibx sec rol sta tmp - lda $C0EC bpl - and tmp - sta (BASEPAGE+8)<<8,x - inx + sta (BASEPAGE+8)<<8,y + iny cmp #$EA bne -- rts -.readtrack22 - ldx #$40 - ldy #0 --- dey - bne + - dex - beq ++ -+ jsr .readnib -- cmp #$D5 - bne -- - jsr .readnib - cmp #$FF - bne - - jsr .readnib - cmp #$DD - bne - ; this had the same bug - ldx #$00 -- jsr .read4x4 - sta BASEPAGE<<8,x - inx - bne - -++ rts - -.read4x4 -- lda $C0EC +.read4x4x +- lda $C08C,x bpl - sec rol sta tmp -- lda $C0EC +- lda $C08C,x bpl - and tmp rts +} -.readnib -- lda $C0EC +.readtrack22 + ldx #$40 + ldy #$00 +-- dey + bne + + dex + beq ++ ++ ldx #$60 + jsr .readnibx +- cmp #$D5 + bne -- + jsr .readnibx + cmp #$FF + bne - + jsr .readnibx + cmp #$DD + bne - ; this had the same bug + ldy #$00 +- jsr .read4x4x + sta BASEPAGE<<8,y + iny + bne - +++ rts + +.readtracki !pseudopc $2000 { + ldx #$60 +.retry + lda tmpx + sta nibcount + lda modsrc + sta moddest + lda modsrc+1 + sta moddest+1 + ldy #$00 +--- jsr .readnibx +-- cmp cmp2+1 + bne --- + jsr .readnibx +- cmp cmp2+0 + bne -- + jsr .readnibx + cmp cmp1+1 + bne - ; this has a bug which is also present in the original code + ; it branches to the middle nibble instead of the first one + ; it allows PR0 PR1 [any] PR1 PR2 instead of requiring PR0 PR1 PR2 +-- lda $C08C,x + bpl -- + rol + sta tmp +- lda $C08C,x + bpl - + and tmp + sta (moddest), y + iny + bne -- + asl $C000 +- lda $C08C,x + bpl - + cmp cmp1+0 + bne .retry + inc modsrc+1 + dec nibcount + bne -- + jsr .readnibx + sta prbuf+1 ; prologue 3 + jsr .readnibx + sta unform+0 ; prologue 2 + jsr .readnibx + sta unform+1 ; prologue 1 + jsr .readnibx + sta prbuf+0 ; epilog + jsr .readnibx + cmp unform+1 ; trailer epilog + bne .retry + rts + +.readnibx +- lda $C08C,x bpl - rts +} .inittable ldy #$08 diff --git a/src/strings/en.a b/src/strings/en.a index a859f73..b24e18f 100755 --- a/src/strings/en.a +++ b/src/strings/en.a @@ -280,7 +280,7 @@ StringTableHigh ; can be set directly before calling PrintByID. ; .header - !text "Passport by 4am 2019-04-20",$00 + !text "Passport by 4am 2019-04-23",$00 .mainmenu !text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D,$8D !text " " From c8912f67c1f9e89beeece0843b51983785ff2c2c Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Tue, 23 Apr 2019 22:00:02 -0700 Subject: [PATCH 2/5] rehook reset in case of $3xx use --- src/passport.a | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/passport.a b/src/passport.a index 721db33..090cab5 100755 --- a/src/passport.a +++ b/src/passport.a @@ -185,12 +185,6 @@ FirstMover !source "standarddelivery.a" ResetVector - lda #ResetVector - sta $03F3 - eor #$A5 - sta $03F4 lda $C0E8 jsr PR0 jsr IN0 @@ -200,6 +194,12 @@ ResetVector sta $C00C sta $C00E MainMenu + lda #ResetVector + sta $03F3 + eor #$A5 + sta $03F4 ldx #$FF txs jsr ClearScreen From 7d79ba16381551d85154678a7d8230490d0c06bc Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Tue, 23 Apr 2019 22:00:34 -0700 Subject: [PATCH 3/5] cut some bytes --- src/analyze.a | 25 ++++++++++++++++++------- src/id/inspect0.a | 26 +++++++------------------- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/analyze.a b/src/analyze.a index 97657ff..213d38f 100755 --- a/src/analyze.a +++ b/src/analyze.a @@ -81,7 +81,7 @@ IsF7F6 tay lda #$19 sta nibcount -- jsr .readnib +- jsr ReadNib cmp #$F7 beq + .restart iny @@ -91,28 +91,39 @@ IsF7F6 sec beq .driveoff + - jsr .readnib + jsr ReadNib cmp #$F6 bne .restart - jsr .readnib + jsr ReadNib cmp #$EF bne .restart - jsr .readnib + jsr ReadNib cmp #$EE bne .restart - jsr .readnib + jsr ReadNib cmp #$AB bne .restart clc .driveoff lda $C0E8 rts +} -.readnib +ReadNib - lda $C0EC bpl - rts -} + +Read4x4 +- lda $C0EC + bpl - + sec + rol + sta tmp +- lda $C0EC + bpl - + and tmp + rts ;------------------------------- ; SetupF7F6SecondRound diff --git a/src/id/inspect0.a b/src/id/inspect0.a index c161e57..8445e38 100755 --- a/src/id/inspect0.a +++ b/src/id/inspect0.a @@ -366,28 +366,19 @@ VerifyInfocom18 ; the issue being that both have a D5 AA AD sequence + -- lda $C0EC - bpl - + jsr ReadNib -- cmp #$D5 bne --- -- lda $C0EC - bpl - + jsr ReadNib cmp #$AA bne -- -- lda $C0EC - bpl - + jsr ReadNib cmp #$B5 ; 13-sector only beq .build13 cmp #$AD bne -- -- lda $C0EC - bpl - - nop - nop ; ignore half of 4x4 track number -- lda $C0EC - bpl - ; ignore half of 4x4 track number - + jsr Read4x4 lda #$12 ; all 18 sectors when in verify mode ldx gIsInfocom18 beq .setcount @@ -469,16 +460,13 @@ read13 dex beq .badread1 + -- lda $C0EC - bpl - + jsr ReadNib -- cmp #$D5 bne --- -- lda $C0EC - bpl - + jsr ReadNib cmp #$AA bne -- -- lda $C0EC - bpl - + jsr ReadNib cmp #$B5 bne + ldy #$03 From 3e42659f1ebed4ad8be84b7a61717971e6fe03be Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Wed, 24 Apr 2019 09:23:40 -0700 Subject: [PATCH 4/5] fix typo --- src/patchers/choplifter.a | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/patchers/choplifter.a b/src/patchers/choplifter.a index e237cde..22fe6ab 100644 --- a/src/patchers/choplifter.a +++ b/src/patchers/choplifter.a @@ -331,7 +331,7 @@ ReadChoplifter bpl - cmp cmp1+0 bne .retry - inc modsrc+1 + inc moddest+1 dec nibcount bne -- jsr .readnibx From 8ff4133522ca62a792f75ec34af7f9325f2b9eeb Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Wed, 24 Apr 2019 15:03:19 -0700 Subject: [PATCH 5/5] preserve address --- src/patchers/choplifter.a | 2 ++ src/strings/en.a | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/patchers/choplifter.a b/src/patchers/choplifter.a index 22fe6ab..d07f2d1 100644 --- a/src/patchers/choplifter.a +++ b/src/patchers/choplifter.a @@ -166,6 +166,8 @@ ReadChoplifter sta cmp1+0 lda prbuf+1 ; prologue 3 sta cmp1+1 + lda moddest+1 + sta modsrc+1 rts .readtrack0B diff --git a/src/strings/en.a b/src/strings/en.a index b24e18f..bf70045 100755 --- a/src/strings/en.a +++ b/src/strings/en.a @@ -280,7 +280,7 @@ StringTableHigh ; can be set directly before calling PrintByID. ; .header - !text "Passport by 4am 2019-04-23",$00 + !text "Passport by 4am 2019-04-24",$00 .mainmenu !text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D,$8D !text " "