From 831441425d1851bab96d48ffa6adcef0989833d6 Mon Sep 17 00:00:00 2001 From: 4am Date: Mon, 4 Feb 2019 17:20:29 -0500 Subject: [PATCH] add support for MUSE RWTS [fixes The Function Game, The Caverns of Freitag, others] --- src/apicode.a | 6 +++++- src/apidefs.a | 4 +++- src/id/dos33.a | 28 +++++++++++++++++++++++++--- src/id/inspect0.a | 7 +++++++ src/id/trace33.a | 27 +++++++++++++++++++++++---- src/mods/t00only.a | 1 + src/patchers/muserwts.a | 30 ++++++++++++++++++++++++++++++ src/sectormap.a | 3 ++- src/strings/en.a | 2 +- 9 files changed, 97 insertions(+), 11 deletions(-) create mode 100644 src/patchers/muserwts.a diff --git a/src/apicode.a b/src/apicode.a index 09cc254..d19af65 100644 --- a/src/apicode.a +++ b/src/apicode.a @@ -64,7 +64,11 @@ ; set in IDBootloader() after reading T00,S00 FIRSTFILTER -;gIsRDOS +;gIsMUSERWTS + !byte FALSE ; 0=true, 1=false + ; reset before each operation + ; set in IDBootloader() after reading T00,S00 +;gIsRDOS13 !byte FALSE ; 0=true, 1=false ; reset before each operation ; set in IDBootloader() after reading T00,S00 diff --git a/src/apidefs.a b/src/apidefs.a index faee4d7..7b54614 100644 --- a/src/apidefs.a +++ b/src/apidefs.a @@ -98,9 +98,10 @@ gIsAdvent = gForceDiskVol-$01 ; byte gIsPanglosDOS = gIsAdvent-$01 ; byte gIsDavidson = gIsPanglosDOS-$01 ; byte gIsRDOS13 = gIsDavidson-$01 ; byte +gIsMUSERWTS = gIsRDOS13-$01 ; byte ;LASTFILTER ; add new gIs* above this line ;gIsInfocom18 is a special case whose ID is not in the regular inspection path -gIsInfocom18 = gIsRDOS13-$01 ; byte +gIsInfocom18 = gIsMUSERWTS-$01 ; byte ;gIs13Sector is a special case whose ID is not in the regular inspection path gIs13Sector = gIsInfocom18-$01 ; byte ;gMECCFastloadType is a special case integer whose default value cannot be #FALSE @@ -171,6 +172,7 @@ ConstructStandardDelivery = jConstructStandardDelivery !warn "gIsAdvent=",gIsAdvent !warn "gIsPanglosDOS=",gIsPanglosDOS !warn "gIsDavidson=",gIsDavidson +!warn "gIsMUSERWTS=",gIsMUSERWTS !warn "gIsRDOS13=",gIsRDOS13 !warn "gIsInfocom18=",gIsInfocom18 !warn "gIs13Sector=",gIs13Sector diff --git a/src/id/dos33.a b/src/id/dos33.a index ab90c9f..41a249b 100755 --- a/src/id/dos33.a +++ b/src/id/dos33.a @@ -66,7 +66,9 @@ IDDOS33 !byte $6C,$3E,$00 !byte $EE,$FE,$08 !byte $EE,$FE,$08 - bcs .exit + bcc + + jmp .exit ++ ; ; DOS 3.3 has JSR $FE89 / JSR $FE93 / JSR $FB2F ; some Sierra have STA $C050 / STA $C057 / STA $C055 instead @@ -93,16 +95,33 @@ IDDOS33 + ; -; Sector order map must be standard (no exceptions) +; Check sector order map ; lda #$00 ldx #$4D ldy #$10 jsr compare ; if T00,S00,$4D == !byte $00,$0D,$0B,$09,$07,$05,$03,$01 - !byte $0E,$0C,$0A,$08,$06,$04,$02,$0F + !byte WILDCARD,$0C,$0A,$08,$06,$04,$02,$0F bcs .exit ; +; Check for MUSE sector order map +; + lda #$00 + ldx #$55 + ldy #$01 + jsr compare ; if T00,S00,$55 == + !byte $02 + bcs + + lda #TRUE + sta gIsMUSERWTS + lda #$0E + sta precheck_sectors+1 + lda #kSectorIgnore + sta T00S08 + sta T00S0F ++ +; ; Minor variant (e.g. Terrapin Logo 3.0) jumps to $08F0 and back ; but is still safe to trace. Check for this jump and match ; the code at $08F0 exactly. @@ -126,6 +145,9 @@ IDDOS33 ldy #$09 jsr compare ; if T00,S00,$F0 == !byte $8D,$FE,$08 + + + !byte $EE,$F3,$03 !byte $4C,$1F,$08 ; bcs .exit ; unknown code at $08F0 -> failure diff --git a/src/id/inspect0.a b/src/id/inspect0.a index eee7c71..bf53af1 100755 --- a/src/id/inspect0.a +++ b/src/id/inspect0.a @@ -18,6 +18,13 @@ IDBootloader bne - stx gMECCFastloadType stx gLastTrack + ldx #$0F + ldy #$F8 +- tya + sta precheck_sectors,x + iny + dex + bpl - lda gIsInfocom18 bne .check13 diff --git a/src/id/trace33.a b/src/id/trace33.a index 7d742d6..88303d5 100755 --- a/src/id/trace33.a +++ b/src/id/trace33.a @@ -13,16 +13,23 @@ TraceDOS33 ; lda #$00 sta gTrack - lda #$09 + ldy #$00 +@precheck_loop + lda precheck_sectors,y + bmi + sta gSector jsr IgnoreAddressChecksum -precheck + tya + pha jsr ReadSector + pla + tay bcc + jmp FatalError + - dec gSector - bne precheck + iny + cpy #$10 + bne @precheck_loop ; ; pre-check passed, do the trace ; @@ -30,6 +37,18 @@ precheck ldx #>TraceDOS33b jmp Trace +precheck_sectors + ; This list is (re)initialized in IDBootloader, + ; then potentially altered in IDDOS33. + ; Values are logical sector numbers. + ; There are always 16 (0x10) values in this list. + ; Negative values are ignored. + ; Positive values are treated as logical + ; sector numbers and read from track $00. + ; Sectors are read in the order listed here. + !byte $09,$08,$07,$06,$05,$04,$03,$02,$01 + !byte $00,$FF,$FE,$FD,$FC,$FB,$FA,$F9,$F8 + ;------------------------------- ; TraceDOS33b ; set up 2nd boot trace at $084A diff --git a/src/mods/t00only.a b/src/mods/t00only.a index e5486d6..1843deb 100644 --- a/src/mods/t00only.a +++ b/src/mods/t00only.a @@ -112,6 +112,7 @@ AnalyzeT00 !source "../patchers/rdos13.a" !source "../patchers/swordthrust.a" !source "../patchers/dakin5.a" + !source "../patchers/muserwts.a" ;add only above this line rts diff --git a/src/patchers/muserwts.a b/src/patchers/muserwts.a new file mode 100644 index 0000000..d385575 --- /dev/null +++ b/src/patchers/muserwts.a @@ -0,0 +1,30 @@ +;------------------------------- +; #MUSERWTS +; RWTS changes based on track +; +; tested on +; - The Caverns of Freitag (MUSE) +; - The Function Game (MUSE) +;------------------------------- +!zone { + bit gMode ; nothing to do here in verify-only mode + bpl .exit + lda gIsMUSERWTS + bne .exit + lda #$06 + ldx #$F2 + ldy #$03 + jsr compare ; if T00,S06,$F2 == + !byte $20,$B6,$B6 + bcs .exit + pha + lda #6 + sta gDisplayBytes + lda #s_bytrack + jsr PrintByID + pla + ldy #$01 + jsr modify ; then set T00,S06,$F2 = + !byte $2C +.exit +} diff --git a/src/sectormap.a b/src/sectormap.a index 803a5f7..42faa26 100755 --- a/src/sectormap.a +++ b/src/sectormap.a @@ -60,7 +60,8 @@ InitSectorMap sectormap T00S00 -T00 !byte $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF +T00 !byte $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF +T00S08 !byte $FF T00S09 !byte $FF T00S0A !byte $FF T00S0B !byte $FF diff --git a/src/strings/en.a b/src/strings/en.a index bc2e3b0..ea2b130 100755 --- a/src/strings/en.a +++ b/src/strings/en.a @@ -152,7 +152,7 @@ StringTable ; can be set directly before calling PrintByID. ; .header - !text "Passport by 4am 2019-02-03",$00 + !text "Passport by 4am 2019-02-04",$00 .mainmenu !text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D !text " "