diff --git a/src/apicode.a b/src/apicode.a index a8e2cba..11ec22b 100644 --- a/src/apicode.a +++ b/src/apicode.a @@ -262,3 +262,25 @@ LASTFILTER !byte %00000000 ; bit 7 0=verify, 1=see bit 6 ; bit 6 0=demuffin, 1=crack ; set based on main menu choice +;HardDiskImagePath + !fill 37 +;RAMDiskImagePath + !fill 21 +;HardDiskArray + !fill 15 +;DiskIIArray + !fill 7 +;T00PakPtr + !word $3200 +;kForceLower + !byte $FF +;OnlineReturn + !byte 0 +;VolumeName + !fill 15 +;mliparam + !fill 26 +;gSector + !byte 0 +;gTrack + !byte 0 diff --git a/src/apidefs.a b/src/apidefs.a index 59143a0..6c34cec 100644 --- a/src/apidefs.a +++ b/src/apidefs.a @@ -80,46 +80,6 @@ tmpx = $FD ; byte tmpy = $FE ; byte flag = $FF ; byte -; Other addresses we use for global variables -gTrack = $0210 -gSector = gTrack+1 -mliparam = gSector+1 -access = mliparam+3 ; access privileges (set by MLI get_file_info) -filetype = access+1 ; file type (set by MLI get_file_info) -auxtype = filetype+1 ; auxiliary file type (2 bytes, set by MLI get_file_info) -refnum = auxtype ; file refnum (set by MLI open) -mlilen = refnum+1 ; file length (set by MLI read) -blocks = mlilen+2 ; blocks used (set by getvolumeinfo) - ; member is also used by createfile -; !fill 8 ; used by get_file_info -OnlineReturn = blocks + 10 -VolumeName = OnlineReturn + 1 -; !byte $FF,$FF,$FF,$FF,$FF,$FF,$FF -; !byte $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF - - -DiskIIArray = $038E -; !fill 7 -HardDiskArray = DiskIIArray+7 -; !fill 15 -RAMDiskImagePath = HardDiskArray+15 -; !byte 0 ; length byte (0 means no suitable RAM disk is available) -; !fill 1 ; / character -; !fill 4 ; longest possible volume name for supported RAM disks -; ; (code only matches 'RAM' or 'RAMn' where n is usually a slot number) -; !fill 1 ; / character -; !fill 15 ; filename without leading slash (constant, see initscan.a) -HardDiskImagePath = RAMDiskImagePath+21 -; !byte 0 ; length byte -; !fill 1 ; / character -; !fill 15 ; longest possible volume name -; !fill 1 ; / character -; !fill 8 ; directory name (constant) -; !fill 12 ; filename with leading slash -; ; (modified at runtime but always the same length) -kForceLower = HardDiskImagePath+37 ; AND mask for lowercase letters (set at program startup) - - ; Other application-specific constants and assembler magic !ifdef RELBASE { !set VERBOSE = $00 ; override for make script @@ -149,76 +109,95 @@ UNIV_D3 = $B8FC ;------------------------------- APIEND = HIGHPOINT -gMode = APIEND-$01 ; byte -gPatchCount = gMode-$01 ; byte -gTriedUniv = gPatchCount-$01 ; byte -gSaidWriting = gTriedUniv-$01 ; byte -gChangedPrefs = gSaidWriting-$01 ; byte -gLastTrack = gChangedPrefs-$01 ; byte -gDiskVolumeNumber = gLastTrack-$01 ; byte +gTrack = APIEND-$01 ; byte +gSector = gTrack-$01 ; byte +mliparam = gSector-26 ; 26 bytes +access = mliparam + 3 ; access privileges (set by MLI get_file_info) +filetype = access + 1 ; file type (set by MLI get_file_info) +auxtype = filetype + 1 ; auxiliary file type (2 bytes, set by MLI get_file_info) +refnum = auxtype ; file refnum (set by MLI open) +mlilen = refnum + 1 ; file length (set by MLI read) +blocks = mlilen + 2 ; blocks used (set by getvolumeinfo) + ; member is also used by createfile +; !fill 8 ; used by get_file_info +VolumeName = mliparam-15 ; 15 bytes +OnlineReturn = VolumeName-1 ; byte +kForceLower = OnlineReturn-1 ; byte +T00PakPtr = kForceLower-2 ; 2 bytes +DiskIIArray = T00PakPtr-7 ; 7 bytes +HardDiskArray = DiskIIArray-15 ; 15 bytes +RAMDiskImagePath = HardDiskArray-21 ; 21 bytes +HardDiskImagePath = RAMDiskImagePath-37 ; 37 bytes +gMode = HardDiskImagePath-$01 ; byte +gPatchCount = gMode-$01 ; byte +gTriedUniv = gPatchCount-$01 ; byte +gSaidWriting = gTriedUniv-$01 ; byte +gChangedPrefs = gSaidWriting-$01 ; byte +gLastTrack = gChangedPrefs-$01 ; byte +gDiskVolumeNumber = gLastTrack-$01 ; byte ;FIRSTFILTER ; add new gIs* below this line -gIsDOS32 = gDiskVolumeNumber-$01 ; byte -gIsBoot0 = gIsDOS32-$01 ; byte -gCapturedDiskVolumeNumber = gIsBoot0-$01 ; byte -gIsProDOS = gCapturedDiskVolumeNumber-$01 ; byte -gIsDinkeyDOS = gIsProDOS-$01 ; byte -gIsPascal = gIsDinkeyDOS-$01 ; byte -gIsProtDOS = gIsPascal-$01 ; byte -gIsDavidDOS = gIsProtDOS-$01 ; byte -gIsEA = gIsDavidDOS-$01 ; byte -gPossibleGamco = gIsEA-$01 ; byte -gIsOptimum = gPossibleGamco-$01 ; byte -gPossibleD5D5F7 = gIsOptimum-$01 ; byte -gIs8b3 = gPossibleD5D5F7-$01 ; byte -gIsMilliken1 = gIs8b3-$01 ; byte -gAdventureInternational = gIsMilliken1-$01 ; byte -gIsLaureate = gAdventureInternational-$01 ; byte -gIsDatasoft = gIsLaureate-$01 ; byte -gIsSierra = gIsDatasoft-$01 ; byte -gIsSierra13 = gIsSierra-$01 ; byte -gIsF7F6 = gIsSierra13-$01 ; byte -gIsTrillium = gIsF7F6-$01 ; byte -gPolarwareTamperCheck = gIsTrillium-$01 ; byte -gForceDiskVol = gPolarwareTamperCheck-$01 ; byte -gIsAdvent = gForceDiskVol-$01 ; byte -gIsPanglosDOS = gIsAdvent-$01 ; byte -gIsDavidson = gIsPanglosDOS-$01 ; byte -gIsRDOS13 = gIsDavidson-$01 ; byte -gIsMUSERWTS = gIsRDOS13-$01 ; byte -gIsHolle = gIsMUSERWTS-$01 ; byte -gIsPhoenix = gIsHolle-$01 ; byte -gIsDiversi = gIsPhoenix-$01 ; byte -gIsTSR = gIsDiversi-$01 ; byte -gPossibleMECCSwapper = gIsTSR-$01 ; byte -gPossibleWoodbury = gPossibleMECCSwapper-$01 ; byte -gPossibleB4BBBasic = gPossibleWoodbury-$01 ; byte -gIsLowDOS = gPossibleB4BBBasic-$01 ; byte +gIsDOS32 = gDiskVolumeNumber-$01 ; byte +gIsBoot0 = gIsDOS32-$01 ; byte +gCapturedDiskVolumeNumber = gIsBoot0-$01 ; byte +gIsProDOS = gCapturedDiskVolumeNumber-$01 ; byte +gIsDinkeyDOS = gIsProDOS-$01 ; byte +gIsPascal = gIsDinkeyDOS-$01 ; byte +gIsProtDOS = gIsPascal-$01 ; byte +gIsDavidDOS = gIsProtDOS-$01 ; byte +gIsEA = gIsDavidDOS-$01 ; byte +gPossibleGamco = gIsEA-$01 ; byte +gIsOptimum = gPossibleGamco-$01 ; byte +gPossibleD5D5F7 = gIsOptimum-$01 ; byte +gIs8b3 = gPossibleD5D5F7-$01 ; byte +gIsMilliken1 = gIs8b3-$01 ; byte +gAdventureInternational = gIsMilliken1-$01 ; byte +gIsLaureate = gAdventureInternational-$01 ; byte +gIsDatasoft = gIsLaureate-$01 ; byte +gIsSierra = gIsDatasoft-$01 ; byte +gIsSierra13 = gIsSierra-$01 ; byte +gIsF7F6 = gIsSierra13-$01 ; byte +gIsTrillium = gIsF7F6-$01 ; byte +gPolarwareTamperCheck = gIsTrillium-$01 ; byte +gForceDiskVol = gPolarwareTamperCheck-$01 ; byte +gIsAdvent = gForceDiskVol-$01 ; byte +gIsPanglosDOS = gIsAdvent-$01 ; byte +gIsDavidson = gIsPanglosDOS-$01 ; byte +gIsRDOS13 = gIsDavidson-$01 ; byte +gIsMUSERWTS = gIsRDOS13-$01 ; byte +gIsHolle = gIsMUSERWTS-$01 ; byte +gIsPhoenix = gIsHolle-$01 ; byte +gIsDiversi = gIsPhoenix-$01 ; byte +gIsTSR = gIsDiversi-$01 ; byte +gPossibleMECCSwapper = gIsTSR-$01 ; byte +gPossibleWoodbury = gPossibleMECCSwapper-$01 ; byte +gPossibleB4BBBasic = gPossibleWoodbury-$01 ; byte +gIsLowDOS = gPossibleB4BBBasic-$01 ; byte ;LASTFILTER ; add new gIs* above this line ;gIsInfocom18 is a special case whose ID is not in the regular inspection path -gIsInfocom18 = gIsLowDOS-$01 ; byte +gIsInfocom18 = gIsLowDOS-$01 ; byte ;gIs13Sector is a special case whose ID is not in the regular inspection path -gIs13Sector = gIsInfocom18-$01 ; byte +gIs13Sector = gIsInfocom18-$01 ; byte ;gMECCFastloadType is a special case integer whose default value cannot be #FALSE -gMECCFastloadType = gIs13Sector-$01 ; byte +gMECCFastloadType = gIs13Sector-$01 ; byte ;gIsRW18 is a special case whose ID is not in the regular inspection path -gIsRW18 = gMECCFastloadType-$01 ; byte +gIsRW18 = gMECCFastloadType-$01 ; byte -gOnAClearDayYouCanReadForever = gIsRW18-$01 ; byte -gTargetType = gOnAClearDayYouCanReadForever-$01 ; byte -gRAMDiskRef = gTargetType-$01 ; byte -gHardDiskRef = gRAMDiskRef-$01 ; byte -gDisplayBytes = gHardDiskRef-$0A ; 10 bytes -jcompare = gDisplayBytes-$03 ; 3-byte -jmodify = jcompare-$03 ; 3-byte -jPrintByID = jmodify-$03 ; 3-byte -jSearchTrack = jPrintByID-$03 ; 3-byte -jCallRWTS = jSearchTrack-$03 ; 3-byte -jCopyMemory = jCallRWTS-$03 ; 3-byte -jCopyUniversalAnywhere = jCopyMemory-$03 ; 3-byte -jConstructStandardDelivery = jCopyUniversalAnywhere-$03 ; 3-byte -gNIBTableFF = jConstructStandardDelivery-1 ; 1 byte -gNIBTable = gNIBTableFF-$FF ; accessed by +$80 -gNIBTableBase = gNIBTableFF-$7F ; 127 bytes +gOnAClearDayYouCanReadForever = gIsRW18-$01 ; byte +gTargetType = gOnAClearDayYouCanReadForever-$01 ; byte +gRAMDiskRef = gTargetType-$01 ; byte +gHardDiskRef = gRAMDiskRef-$01 ; byte +gDisplayBytes = gHardDiskRef-$0A ; 10 bytes +jcompare = gDisplayBytes-$03 ; 3-byte +jmodify = jcompare-$03 ; 3-byte +jPrintByID = jmodify-$03 ; 3-byte +jSearchTrack = jPrintByID-$03 ; 3-byte +jCallRWTS = jSearchTrack-$03 ; 3-byte +jCopyMemory = jCallRWTS-$03 ; 3-byte +jCopyUniversalAnywhere = jCopyMemory-$03 ; 3-byte +jConstructStandardDelivery = jCopyUniversalAnywhere-$03 ; 3-byte +gNIBTableFF = jConstructStandardDelivery-1 ; 1 byte +gNIBTable = gNIBTableFF-$FF ; accessed by +$80 +gNIBTableBase = gNIBTableFF-$7F ; 127 bytes !ifdef MODULE { compare = jcompare @@ -233,6 +212,23 @@ ConstructStandardDelivery = jConstructStandardDelivery !ifdef VERBOSE { !if VERBOSE=1 { +!warn "gTrack=",gTrack +!warn "gSector=",gSector +!warn "mliparam=",mliparam +!warn "access=",access +!warn "filetype=",filetype +!warn "auxtype=",auxtype +!warn "refnum=",refnum +!warn "mlilen=",mlilen +!warn "blocks=",blocks +!warn "OnlineReturn=",OnlineReturn +!warn "VolumeName=",VolumeName +!warn "kForceLower=",kForceLower +!warn "T00PakPtr=",T00PakPtr +!warn "DiskIIArray=",DiskIIArray +!warn "HardDiskArray=",HardDiskArray +!warn "RAMDiskImagePath=",RAMDiskImagePath +!warn "HardDiskImagePath=",HardDiskImagePath !warn "gMode=",gMode !warn "gPatchCount=",gPatchCount !warn "gTriedUniv=",gTriedUniv diff --git a/src/id/trace.a b/src/id/trace.a index 3608289..50bec3b 100644 --- a/src/id/trace.a +++ b/src/id/trace.a @@ -11,22 +11,22 @@ Trace txa pha lda #$C6 - ldx #$B6 + ldx #$16 ldy #$01 jsr CopyMemory pla ldx #0 - ldy $B6F8 + ldy $16F8 cpy #$4C beq + ldx #3 - ldy $B6FB + ldy $16FB cpy #$4C bne ++ -+ sta $B6FA,x ; hi byte of callback ++ sta $16FA,x ; hi byte of callback pla - sta $B6F9,x ; lo byte of callback - jmp $B600 + sta $16F9,x ; lo byte of callback + jmp $1600 ++ pla jsr PrintByID ; unknown disk controller diff --git a/src/id/trace32.a b/src/id/trace32.a index 4f6a798..4626b23 100644 --- a/src/id/trace32.a +++ b/src/id/trace32.a @@ -90,7 +90,7 @@ IDDOS32LO TraceDOS32 lda #<.TraceDOS32b ldx #>.TraceDOS32b - bne .linktrace + bne .linktrace ; always branches TraceDOS32LO lda #<.TraceDOS32LOb ldx #>.TraceDOS32LOb @@ -152,14 +152,18 @@ TraceDOS32LO !byte $6C,$3E,$00 bcs .tryChoplifter lda $03CC - cmp #$B6 - beq + - cmp #$36 - beq + - cmp #$B2 ;RDOS - bne .fail ; passport-test-suite/Epidemic.woz [Z=1] matches + cmp #$B2 ; RDOS clc -+ php + beq ++ ; passport-test-suite/Epidemic.woz [Z=1] matches + cmp #$B6 ; DOS 3.2 loaded high + beq + + cmp #$36 ; DOS 3.2 loaded low + bne .fail + pha + jsr MoveT00PakHigh ; move our packed T00 modules out of the way first + pla ++ sec +++ php ; pulled later to distinguish RDOS from DOS 3.2 ; ; set up RWTS entry point and other self-modified vectors ; that depend on where the RWTS is in memory diff --git a/src/id/trace33.a b/src/id/trace33.a index e922c98..6aba817 100755 --- a/src/id/trace33.a +++ b/src/id/trace33.a @@ -5,10 +5,12 @@ ;------------------------------- !zone { TraceDOS33 - jsr PreCheckT00 -; -; pre-check passed, do the trace -; + jsr PreCheckT00 ; does not return on failure + + lda $08FE + bmi + ; if we're about to trace a DOS that loads at $3600, + jsr MoveT00PakHigh ; move our packed T00 modules out of the way first ++ lda #TraceDOS33b jmp Trace diff --git a/src/id/trace33p.a b/src/id/trace33p.a index ddf8250..0fce1d3 100755 --- a/src/id/trace33p.a +++ b/src/id/trace33p.a @@ -50,6 +50,8 @@ TraceSpecDel ldy #$01 jsr CopyMemory + jsr MoveT00PakHigh + lda #TraceSpecDel2 jmp Trace diff --git a/src/initscan.a b/src/initscan.a index 2efb60c..f43cb22 100644 --- a/src/initscan.a +++ b/src/initscan.a @@ -13,11 +13,7 @@ RAMFileName_e ; all registers and flags clobbered ;------------------------------- ScanForDiskII - ldx #$06 lda #$00 -- sta DiskIIArray, x - dex - bpl - sta cmp1 ldx #$07 - txa @@ -53,12 +49,7 @@ ScanForDiskII ; all registers and flags clobbered ;------------------------------- ScanForRAMAndHardDisks - ldy #14 lda #$00 -- sta HardDiskArray, y - dey - bpl - - sta RAMDiskImagePath sta iunit @nextunit lda iunit diff --git a/src/memory.a b/src/memory.a index 101897d..9116e36 100755 --- a/src/memory.a +++ b/src/memory.a @@ -1,9 +1,9 @@ ;------------------------------- ; YE OLDE GRAND UNIFIED MEMORY MAP ; -; 0210..02D7 - globals (see apidefs.a) +; 0200..03FF - clobbered by DOS 3.2 tracer (and other supported 13-sector disks like Choplifter) ; 02D8..038D - clobbered by Optimum reader -; 038E..03EF - globals (see apidefs.a) +; 0300..0395 - clobbered by DOS 3.3 tracer ; 0800..08FF - clobbered by all boot tracers and RAM disk ; 0800..08CB - clobbered by exodecrunch ; 0900..09FF - clobbered by Special Delivery tracer and RAM disk @@ -14,7 +14,8 @@ ; 0F00..0FFF - backup of page $BF (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 +; 2600..26FF - clobbered by all boot tracers (copy of C600) +; 3600..3FFF - clobbered by lomem DOS 3.2/3.3 tracers, Special Delivery tracer ; 4000..B1FF - program code ; B200..BFFF - clobbered by DOS boot tracer (RDOS is B200+, DOS 3.x is B600+) ;------------------------------- @@ -22,10 +23,9 @@ ;------------------------------- ; SwapProDOS -; saves/restores memory pages used by ProDOS -; pages $BF -; in: none -; out: all flags and registers preserved +; saves/restores memory used by ProDOS ($BF00..$BFFF) +; in: none +; out: all flags and registers preserved ;------------------------------- SwapProDOS php @@ -37,14 +37,32 @@ SwapProDOS jsr SwapMemory pla plp - rts +- rts + +MoveT00PakLow + bit T00PakPtr+1 + bpl - ; already low + lda #$B2 + ldx #$32 + bne + ; always branches +MoveT00PakHigh + bit T00PakPtr+1 + bmi - ; already high + lda #$32 + ldx #$B2 ++ stx T00PakPtr+1 + ldy #$0D + ; /!\ execution falls through here ;------------------------------- ; CopyMemory -; in: A = source address (high) -; X = destination address (high) -; Y = number of pages to copy -; out: all flags and registers clobbered +; in: A = source address (high) +; X = destination address (high) +; Y = number of pages to copy +; out: Z = 1 +; X = 0 +; Y = 0 +; all other flags and registers clobbered ;------------------------------- CopyMemory sta @source+2 @@ -64,8 +82,11 @@ CopyMemory ; ClearTSBuffer ; clear the $1000 byte memory buffer ; used to store the current track's data -; in: none -; out: all flags and registers clobbered +; in: none +; out: Z = 1 +; X preserved +; Y = 0 +; all other flags and registers clobbered ;------------------------------- ClearTSBuffer lda #BASEPAGE @@ -75,10 +96,13 @@ ClearTSBuffer ;------------------------------- ; ClearMemory -; in: A = source address (high) -; X = value to set -; Y = number of pages -; out: all flags and registers clobbered +; in: A = source address (high) +; X = value to set +; Y = number of pages +; out: Z = 1 +; X preserved +; Y = 0 +; all other flags and registers clobbered ;------------------------------- ClearMemory sta @dest+2 diff --git a/src/mods/t00only.a b/src/mods/t00only.a index 8ab2f21..bb2e271 100644 --- a/src/mods/t00only.a +++ b/src/mods/t00only.a @@ -96,6 +96,6 @@ T00_IsNotRWTS !source "../patchers/t00_rol1e.a" rts -!if * > $4000 { +!if * > $3200 { !serious "code is too large to fit in available space!" } diff --git a/src/passport.a b/src/passport.a index 9dad557..8167a26 100755 --- a/src/passport.a +++ b/src/passport.a @@ -42,11 +42,27 @@ VERBOSE = $00 ; set to $01 to display API label addresses !source "apidefs.a" ; no code in here +FirstMover + jmp MainMenu + + !bin "../build/t00only.pak" + MainMenu ldx #$FF txs + lda #MainMenu + sta $03F3 + eor #$A5 + sta $03F4 + lda #CheckCache + sta $37 jsr Cleanup ; RAM/HD files might be left open after Ctrl-Reset jsr ClearScreen + jsr MoveT00PakLow @refreshMainMenu jsr PrintByID !byte s_header @@ -270,9 +286,9 @@ AnalyzeTrack ; then decompressed into $2000 when needed bit gMode bpl @applyToAll ; only run track 0 modules in crack mode - lda #>AnalyzeT00 + lda T00PakPtr+1 sta _byte_hi - lda #CheckCache - sta $37 - lda $FE ; set reset vector - sta $03F2 + lda $FE + sta $F0 lda $FF - sta $03F3 - eor #$A5 - sta $03F4 - jmp ($FE) ; jump to decompressed code (MainMenu) + sta $F1 + lda #$FD + sta $F2 + lda #$31 + sta $F3 + ldx #$0D + ldy #$00 +- lda ($F0), y + sta ($F2), y + iny + bne - + inc $F1 + inc $F3 + dex + bne - + jmp ($FE) !source "apidefs.a" !source "strings/enid.a"