move T00 modules to 3200 or B200 as necessary

also move globals back to program space for compatibility
This commit is contained in:
4am 2021-06-18 13:53:17 -04:00
parent b7d4a41909
commit 53f92388b0
13 changed files with 237 additions and 173 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
ldx #>TraceDOS33b
jmp Trace

View File

@ -50,6 +50,8 @@ TraceSpecDel
ldy #$01
jsr CopyMemory
jsr MoveT00PakHigh
lda #<TraceSpecDel2
ldx #>TraceSpecDel2
jmp Trace

View File

@ -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

View File

@ -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

View File

@ -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!"
}

View File

@ -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 ; set reset vector
sta $03F2
lda #>MainMenu
sta $03F3
eor #$A5
sta $03F4
lda #<CheckCache ; set up output hook used to store log messages before they scroll off
sta $36
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 #<AnalyzeT00
lda T00PakPtr
sta _byte_lo
jsr decrunch
jsr $2000
@ -449,11 +465,11 @@ _byte_skip_hi:
!source "id/dinkeydos.a"
!source "id/advent.a"
!source "id/panglosdos.a"
!source "id/bootfailure.a"
!source "id/davidson.a"
!source "id/holle.a"
!source "id/phoenix.a"
!source "id/555.a"
!source "id/bootfailure.a"
!source "print.a"
!source "compare.a"
!source "modify.a"
@ -469,29 +485,28 @@ _byte_skip_hi:
!source "cffa.a"
!source "progress.a"
!source "rwts.a"
!source "standarddelivery.a"
!source "wholetrack.a"
!source "standarddelivery.a"
!source "adstyle.a"
!source "universalstyle.a"
!source "crackme.a"
AnalyzeT00 ; placeholder to identify stack of packed data
!bin "../build/t00only.pak"
!source "apicode.a"
!source "apicode.a" ; /!\ must be last
!if RELBASE = $2000 {
!ifdef PASS2 {
} else { ;PASS2
!set PASS2=1
!warn "RELBASE = ", HIGHPOINT - (* - MainMenu)
!warn "RELBASE = ", HIGHPOINT - (* - FirstMover)
}
} else {
!if (HIGHPOINT - (* - MainMenu)) < LOWPOINT {
; code between FirstMover and MainMenu is moved and tracked, so it can be below LOWPOINT
!serious "My spoon is too big (", HIGHPOINT - (* - MainMenu), ") is below minimum (", LOWPOINT, ")!"
} else {
!warn "LowPoint=", HIGHPOINT - (* - MainMenu)
!warn "LowPoint=", HIGHPOINT - (* - FirstMover)
}
!warn "MainMenu=",MainMenu
!warn "CleanExit=",CleanExit
!warn "WaitForKey=",WaitForKey
!warn "OpenFile=",OpenFile

View File

@ -148,8 +148,7 @@ ChangeTrack
ChangeTrackNW ; "N"o "W"rite
sta gTrack
jsr ClearTSBuffer
rts
jmp ClearTSBuffer
;-------------------------------
; ChangeSector

View File

@ -117,6 +117,9 @@ StartWithUniv
CopyUniversal
lda #$B8
pha
jsr MoveT00PakLow ; move T00 modules out of the way if necessary
pla
; /!\ execution falls through here
CopyUniversalAnywhere

View File

@ -23,8 +23,6 @@
quit !byte 4
OneTimeSetup
jsr $FE89 ; PR#0
jsr $FE93 ; IN#0
jsr decrunch ; decompress main Passport code
sty $FE ;;zp_dest_lo = low byte of Passport entry point
ldy #0 ; save a copy of ProDOS system global page
@ -50,17 +48,25 @@ OneTimeSetup
jsr ScanForRAMAndHardDisks; scan for things that look like RAM disks or hard disks
jsr LoadPrefs ; load preferences (if available)
jsr ThisSlot ; get information about selected drive and set gTargetType for main menu
lda #<CheckCache ; set up output hook used to store log messages before they scroll off
sta $36
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"