passport/src/passport.a

899 lines
27 KiB
Plaintext
Raw Normal View History

2017-01-08 03:35:35 +00:00
!cpu 6502
!ifdef RELBASE {
*=RELBASE
} else {
2017-01-08 03:35:35 +00:00
*=$2000
}
2017-01-08 03:35:35 +00:00
;-------------------------------
; Passport
; a 4am hack
; (c) 2016-2020 by 4am
2017-01-08 03:35:35 +00:00
;
; Permission is hereby granted, free of charge, to any
; person obtaining a copy of this software and associated
; documentation files (the "Software"), to deal in the
; Software without restriction, including without limitation
; the rights to use, copy, modify, merge, publish,
; distribute, sublicense, and/or sell copies of the
; furnished to do so, subject to the following conditions:
;
; The above copyright notice and this permission notice
; shall be included in all copies or substantial portions of
; the Software.
;
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
; KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
; WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
; PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
; OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
; OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
; OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
;
;-------------------------------
!ifndef VERBOSE {
VERBOSE = $00 ; set to $01 to display API label addresses
}
!to "../build/PASSPORT.TMP",plain
2017-01-08 03:35:35 +00:00
;-------------------------------
; Addresses we read/call
TEXTTOP = $22
VPOS = $25
MLI = $BF00
REBOOT = $FAA6
TEXT = $FB2F
MACHINEID = $FBB3
HOME = $FC58
WAIT = $FCA8
PRBYTE = $FDDA
COUT = $FDED
PR0 = $FE89
IN0 = $FE93
;Universal RWTS-specific values
UNIV_A1 = $B956 ; must LSR before setting
UNIV_A2 = $B95F
UNIV_A3 = $B968
UNIV_D1 = $B8E7
UNIV_D2 = $B8F1
UNIV_D3 = $B8FC
2017-01-08 03:35:35 +00:00
!source "apidefs.a"
2017-01-08 03:35:35 +00:00
2017-01-30 22:10:41 +00:00
FirstMover
jmp ResetVector
!source "strings/en.a"
2017-01-08 03:35:35 +00:00
!source "analyze.a"
!source "id/inspect0.a"
!source "id/precheck.a"
2017-05-04 14:54:59 +00:00
!source "id/trace.a"
2017-08-15 15:31:36 +00:00
!source "id/trace33.a"
!source "id/trace32.a"
!source "id/trace8b3.a"
!source "id/trace33p.a"
!source "id/dos33.a"
2017-05-04 14:54:59 +00:00
!source "id/prodos.a"
!source "id/pascal.a"
2017-09-07 13:52:27 +00:00
!source "id/rdos.a"
2017-01-08 03:35:35 +00:00
!source "id/jsr8b3.a"
!source "id/mecc.a"
!source "id/datasoft.a"
2020-07-22 23:01:07 +00:00
!source "id/tsr.a"
2017-01-08 03:35:35 +00:00
!source "id/protecteddos.a"
!source "id/encode44.a"
!source "id/encode53.a"
2017-01-30 22:10:41 +00:00
!source "id/ea.a"
2017-04-05 01:20:05 +00:00
!source "id/milliken.a"
!source "id/daviddos.a"
!source "id/quickdos.a"
!source "id/diversidos.a"
!source "id/prontodos.a"
!source "id/d5d5f7.a"
!source "id/laureate.a"
!source "id/micrograms.a"
2017-12-06 01:59:55 +00:00
!source "id/volumename.a"
!source "id/dinkeydos.a"
!source "id/advent.a"
2018-06-07 15:18:06 +00:00
!source "id/panglosdos.a"
!source "id/davidson.a"
!source "id/holle.a"
2019-04-08 00:02:19 +00:00
!source "id/phoenix.a"
2017-01-08 03:35:35 +00:00
!source "print.a"
!source "compare.a"
!source "modify.a"
!source "memory.a"
!source "sectormap.a"
!source "mli.a"
!source "ramdisk.a"
!source "harddisk.a"
2017-01-08 03:35:35 +00:00
!source "slots.a"
!source "prefs.a"
!source "keys.a"
!source "cffa.a"
2017-01-08 03:35:35 +00:00
!source "rwts.a"
2017-08-15 15:31:36 +00:00
!source "standarddelivery.a"
2017-01-08 03:35:35 +00:00
ResetVector
lda $C0E8
jsr PR0
jsr IN0
sta $C000
sta $C002
sta $C004
sta $C00C
sta $C00E
2021-04-19 14:44:51 +00:00
jsr CleanupFiles
jsr ThisSlot
; /!\ execution falls through here
2017-01-08 03:35:35 +00:00
MainMenu
2019-04-24 05:00:02 +00:00
lda #<ResetVector
sta $03F2
lda #>ResetVector
sta $03F3
eor #$A5
sta $03F4
2017-01-08 03:35:35 +00:00
ldx #$FF
txs
jsr ClearScreen
lda #s_header
jsr PrintByID
lda #s_mainmenu
jsr PrintByID
bit gTargetType
bmi @usingHardDisk
bvs @usingCFFA
2021-04-15 03:35:14 +00:00
lda #s_targetdisk
!byte $2C
@usingCFFA
2021-04-15 03:35:14 +00:00
lda #s_targetcffa
!byte $2C
@usingHardDisk
2021-04-14 16:40:53 +00:00
lda #s_targetfile
jsr PrintByID
@getkey
2017-01-08 03:35:35 +00:00
jsr WaitForKey
cmp #$80
bne +
jsr EnterCFFAIfAvailable
bcc ResetVector
bcs @getkey
+ cmp #$9B ; Esc quits
beq @jumpToExit
cmp #$91 ; Ctrl-Q quits
beq @jumpToExit
2017-01-08 03:35:35 +00:00
cmp #k_quit
bne +
@jumpToExit
2017-01-08 03:35:35 +00:00
jmp CleanExit
+ cmp #k_slot
2017-01-08 03:35:35 +00:00
bne +
jsr NextSlot
lda #TRUE
sta gChangedPrefs
beq MainMenu ; always branches
+ cmp #k_verify
2017-01-08 03:35:35 +00:00
bne +
lda #%00000000
beq Action ; always branches
+ cmp #k_crack
bne @getkey
2017-01-08 03:35:35 +00:00
lda #%11000000
; /!\ execution falls through here
2017-01-08 03:35:35 +00:00
Action
sta gMode
jsr InitSectorMap
2018-10-12 23:43:40 +00:00
Reaction
2017-01-08 03:35:35 +00:00
lda #FALSE
sta gTriedUniv
sta gSaidWriting
sta gIsProtDOS
2018-12-29 06:20:48 +00:00
sta gIsInfocom18
sta gIs13Sector
2017-01-08 03:35:35 +00:00
lda #$00
sta gTrack
sta gSector
sta gPatchCount
sta jCallRWTS+1
2017-01-08 03:35:35 +00:00
lda #$08
sta gAddress+1
jsr ShowInitialProgressScreen
lda gMode
bpl @printReading ; don't create RAM disk or hard disk file in verify mode
jsr LookupUnitNumberOfSelectedHardDisk
beq @notHardDrive
jsr SwapProDOS ; ProDOS out -> in
jsr CreateFileOnHardDisk
jsr SwapProDOS ; ProDOS in -> out (preserves flags)
bcc @printReading
jmp FatalWriteError ; failed to create target file on hard disk
; this is fatal
@notHardDrive
lda RAMDiskImagePath
beq @printReading ; no RAM disk available
jsr SwapProDOS ; ProDOS out -> in
jsr CreateFileOnRAMDisk
jsr SwapProDOS ; ProDOS in -> out (preserves flags)
bcc @printReading
lda #0 ; failed to create temporary file on RAM disk
sta RAMDiskImagePath ; this is not fatal, but we'll mark the RAM
; disk as unavailable so we don't bother with it
@printReading
2017-01-08 03:35:35 +00:00
lda #s_reading
jsr PrintByID
lda #$B2
ldx #$00
ldy #$0D
jsr ClearMemory
jsr CopyUniversal
jsr IgnoreAddressChecksum
jsr ReadSector
bcc +
2018-12-28 19:46:36 +00:00
jsr IDBootFailure ; /src/id/inspect0
bcc +
2017-01-08 03:35:35 +00:00
lda #s_fail
jsr PrintByID
lda #s_fatal0000
jsr PrintByID
jmp TheEnd
+ jmp IDBootloader ; /src/id/inspect0
2017-01-08 03:35:35 +00:00
;
; We are now fairly confident that the RWTS in memory
; is normal enough to call, Advanced Demuffin style.
;
ADStyle
jsr IncProgress
lda #s_diskrwts
jsr PrintByID
;
; Check for protections in early boot that
; might indicate intentional bad sectors
; elsewhere in the disk that we should skip,
; or changes we need to make to the RWTS
; before we start.
;
jsr xHeredityDog
bcs +
2021-04-08 20:11:00 +00:00
lda #$05
sta gDisplayBytes
lda #s_lockitup
2017-01-08 03:35:35 +00:00
jsr PrintByID
+
2017-01-08 03:35:35 +00:00
jsr xSunburst
bcs +
2021-04-08 20:11:00 +00:00
lda #$04
sta gDisplayBytes
2017-01-08 03:35:35 +00:00
lda #s_sunburst
jsr PrintByID
+
2017-01-08 03:35:35 +00:00
jsr xOptimumRes
bcs +
2017-02-10 05:13:35 +00:00
lda #TRUE
sta gIsOptimum
2017-01-08 03:35:35 +00:00
lda #s_optimum
jsr PrintByID
+
jsr xSVE
bcs +
lda #s_sve
jsr PrintByID
lda #$CA
sta $BE5B
lda #$B6
sta $BE5C
+
jsr xRPS
bcs +
2021-04-08 20:11:00 +00:00
lda #$01
sta gDisplayBytes
lda #s_rps
jsr PrintByID
+
2017-01-08 03:35:35 +00:00
jsr xB660
jsr xB4BB
jsr xHarvey
2017-01-08 03:35:35 +00:00
jmp ReadWithRWTS
UseUniversal
jsr IncProgress
jsr StartWithUniv
;
; On Dinkey-DOS disks (e.g. Ultima V, Times of Lore), we start with the
; universal RWTS then apply a patch in memory.
; These disks use a hybrid RWTS that alters the sector number in the
; address field based on the address epilogue. Once we normalize the
; sector numbers, no further patches are required, since the RWTS can also
; read unprotected disks. A separate patcher finds the actual code that
; alters the sector number to print it to the log.
;
2020-07-22 23:01:07 +00:00
lda gIsDinkeyDOS
bne +
jsr PatchUniversalRWTSForOrigin
bmi ReadWithRWTS ; always branches
;
2020-07-22 23:01:07 +00:00
; On TSR disks (e.g. Dawn Patrol, Dungeon), we start with the universal
; RWTS then apply a patch in memory.
;
+ lda gIsTSR
bne +
jsr PatchUniversalRWTSForTSR
;
2018-12-29 06:20:48 +00:00
; On pure 13-sector disks, we just hijack the read routine to perform a
; verification instead.
;
+ lda gIs13Sector
bne +
lda #<read13
sta jCallRWTS+1
lda #>read13
sta jCallRWTS+2
bne ReadWithRWTS ; always branches
;
; On other disks that use the universal RWTS for the entire disk, we use
; an adaptive RWTS that accepts any epilogue on the first sector but then
; enforces all other sectors to have the same epilogue.
;
+ jsr PatchUniversalRWTSForAdaptive
;
; Disable drive recalibration on bad sectors so we give up on bad sectors
; faster and detect unformatted or specially structured tracks faster.
;
jsr PatchUniversalRWTSForNoRecal
;
; Some disks have different epilogues on track 0, so we stop using the
; adaptive RWTS so we don't falsely accuse those disks of being damaged.
;
lda #kSectorResetAdaptiveRWTS
sta T00S0F
;
; Some disks have an intentionally invalid checksum on T00,S00 (read by
; the drive firmware, which doesn't verify it).
;
lda #kSectorIgnoreAddressChecksum
sta T00S00
;
2017-01-08 03:35:35 +00:00
; note: execution falls through here
;
2017-01-08 03:35:35 +00:00
ReadWithRWTS
lda #$22
jsr ChangeTrackNW
lda #$0F
2018-12-29 06:20:48 +00:00
ldx gIs13Sector
bne +
lda #$0C
+ jsr ChangeSector
2017-01-08 03:35:35 +00:00
lda #<T22S0F
sta checksector+1
lda #>T22S0F
sta checksector+2
.read
2017-01-08 03:35:35 +00:00
lda KEY
2018-12-28 19:46:36 +00:00
bpl .checkinfocom
bit STROBE
cmp #$e0 ;ignore backtick (MAME debug break)
2018-12-28 19:46:36 +00:00
beq .checkinfocom
2017-01-08 03:35:35 +00:00
jmp Cancel
2018-12-28 19:46:36 +00:00
.checkinfocom
lda gIsInfocom18
bne checksector
jsr VerifyInfocom18
bcc .passtrack
jmp FatalError
.passtrack
jmp .prevtrack
2017-01-08 03:35:35 +00:00
checksector
lda $FFFF ; status of current sector in sector map (modified above)
cmp #kSectorCustomFirst ; call a custom routine before deciding what to do with this sector?
bcc +
cmp #kSectorCustomLast
bcs +
2018-12-28 19:46:36 +00:00
jsr PreReadSector
2019-04-13 17:33:15 +00:00
+ pha ; replace status (on stack) with new status returned from PreReadSector
cmp #kSectorIgnore ; skip this sector?
beq nextsector
2019-04-13 17:33:15 +00:00
cmp #kSectorSwitchToBuiltinRWTS ; switch to built-in RWTS before reading this sector?
bne +
2017-01-08 03:35:35 +00:00
lda gTriedUniv
beq +
jsr SwitchToUniv
+ jsr ReadSector
2017-01-08 03:35:35 +00:00
bcc nextsector
;
; Uh oh, we got a read error. But do we care?
; If we just got to this track, check for whole-track protections.
;
ldx #$0F ;16-sector
2018-12-29 06:20:48 +00:00
lda gIs13Sector
beq .expect13
lda gIsDOS32
bne +
2018-12-29 06:20:48 +00:00
.expect13
ldx #$0C ;13-sector
+ cpx gSector
bne .checkoptional
stx .sub+1
jsr SkipTrack
bcs .checkoptional
; Skip this track (we already printed the reason)
lda #$00
2017-01-08 03:35:35 +00:00
jsr ChangeSector
lda checksector+1
sec
.sub sbc #$0F ;self-modified according to sectors per track
2017-01-08 03:35:35 +00:00
sta checksector+1
bcs +
2017-01-08 03:35:35 +00:00
dec checksector+2
+ jmp nextsector
2017-01-08 03:35:35 +00:00
; do this only *after* checking for track-skip
; to avoid fatal errors on unformatted tracks
.checkoptional
pla
pha
;
; Maybe we marked this sector as optional based
; on markers in the bootloader.
;
cmp #kSectorOptional
beq .optional
;
; Otherwise we're in the middle of a track, so try switching to
; the universal RWTS and see if that helps. (Many disks contain
; an RWTS that can't read the early tracks or sectors that
; contain the RWTS code, since those are loaded by the
; disk controller firmware.)
;
.tryuniversal
lda gIsDOS32 ; is this a DOS 3.2 disk?
beq .fatal ; yes, so read error is fatal
2017-01-08 03:35:35 +00:00
lda gTriedUniv ; have we tried the universal RWTS?
beq .maybedavidson ; yes, but check one last thing
2017-01-08 03:35:35 +00:00
jsr SwitchToUniv ; no, switch it in now
jmp .read ; and re-read this sector
2017-01-08 03:35:35 +00:00
.maybedavidson
jsr IDDavidson
bcc .optional
.fatal pla ; if we get to here, we've
2017-01-08 03:35:35 +00:00
jmp FatalError ; decided the read error is fatal
.optional
2017-01-08 03:35:35 +00:00
lda #s_optbad ; say we're skipping this
jsr PrintByID ; optional sector
; note: execution falls through here
nextsector
pla
lda checksector+1
bne .nodec
2017-01-08 03:35:35 +00:00
dec checksector+2
.nodec
2019-04-13 17:33:15 +00:00
dec checksector+1
2019-04-16 05:39:12 +00:00
ldy gSector
dey
tya
2017-01-08 03:35:35 +00:00
jsr ChangeSector
lda gSector
bmi .prevtrack
2019-04-16 05:39:12 +00:00
.linkread
jmp .read
.prevtrack
2017-01-08 03:35:35 +00:00
lda #$0F
2018-12-29 06:20:48 +00:00
ldx gIs13Sector
bne +
lda #$0C
+ jsr ChangeSector
2019-04-16 05:39:12 +00:00
ldy gTrack
dey
tya
2017-01-08 03:35:35 +00:00
jsr ChangeTrack
jsr IncProgress
lda gTrack
2019-04-13 17:33:15 +00:00
bmi Pass
2017-01-08 03:35:35 +00:00
cmp gLastTrack
2019-04-16 05:39:12 +00:00
bcs .linkread
2019-04-13 17:33:15 +00:00
Pass
2017-01-08 03:35:35 +00:00
bit gMode
bpl @passVerify
lda gRAMDiskRef
beq @printFinalMessage ; not using RAM disk, so we're done
; we've written the entire cracked disk as a file on the RAM disk,
; now a second pass to write that file out to the target disk drive
2021-04-14 16:40:53 +00:00
lda #s_writingto
jsr PrintByID
lda #s_slotanddrive
2017-06-23 03:50:39 +00:00
jsr PrintByID
jsr SwapProDOS ; ProDOS out -> in
2017-06-23 03:50:39 +00:00
jsr WriteRAMToDisk
jsr SwapProDOS ; ProDOS in -> out (preserves flags)
bcc @printFinalMessage
jmp FatalWriteError
@printFinalMessage
lda gPatchCount
beq @passWithZeroPatches
lda #s_passcrack ; 'crack complete'
!byte $2C
@passWithZeroPatches
lda #s_passcrack0 ; 'crack complete but no patches'
!byte $2C
@passVerify
lda #s_pass ; 'verification complete'
2017-01-08 03:35:35 +00:00
jsr PrintByID
jmp TheEnd
Cancel
lda #s_canceled
jsr PrintByID
jmp TheEnd
FatalError
lda #s_fail
jsr PrintByID
lda gTrack
cmp #$22
2019-04-16 05:39:12 +00:00
bne TheEnd
.failont22
2017-01-08 03:35:35 +00:00
lda gSector
cmp #$0F
beq .failont22s0f
ldx gIsDOS32
2019-04-16 05:39:12 +00:00
bne TheEnd
cmp #$0C
2019-04-16 05:39:12 +00:00
bne TheEnd
.failont22s0f
2017-01-08 03:35:35 +00:00
lda #s_fatal220f
jsr PrintByID
; /!\ execution falls through here
2017-01-08 03:35:35 +00:00
TheEnd
lda $C0E8
2021-04-19 14:44:51 +00:00
jsr CleanupFiles
lda #s_done
2017-01-08 03:35:35 +00:00
jsr PrintByID
jsr WaitForKey
cmp #$9B
beq CleanExit
2018-05-29 01:15:45 +00:00
cmp #k_redo
beq HandleRedo
cmp #k_redo_with_ignore
beq HandleRedoWithIgnore
2017-01-08 03:35:35 +00:00
jmp MainMenu
HandleRedoWithIgnore
jsr InitSectorMapWithIgnore
2018-10-12 23:43:40 +00:00
jmp Reaction
2018-05-29 01:15:45 +00:00
HandleRedo
jsr ShowInitialProgressScreen
2018-05-29 01:15:45 +00:00
lda #s_reading
jsr PrintByID
; /!\ execution falls through here
;-------------------------------
; RestartScan
; Print 'Restarting scan...' then do exactly that.
; Used by several patchers that find evidence of a protection
; then activate an expensive search the second time around.
; Can be called from anywhere.
; Resets stack, never returns.
; Exits via ReadWithRWTS
;-------------------------------
RestartScan
lda #s_restart
jsr PrintByID
jsr RestartProgress
jsr IncProgress
ldx #$FF
txs
jmp ReadWithRWTS
2018-05-29 01:15:45 +00:00
2017-01-08 03:35:35 +00:00
CleanExit
jsr SwapProDOS ; ProDOS out -> in
2017-01-08 03:35:35 +00:00
lda gChangedPrefs
bne +
2017-01-08 03:35:35 +00:00
jsr SavePrefs
2021-04-19 14:44:51 +00:00
+ jsr CleanupFiles
jsr MLI ; does not return
2017-01-08 03:35:35 +00:00
!byte $65
!word +
+ !byte $04
2017-01-08 03:35:35 +00:00
!source "progress.a"
2017-01-08 03:35:35 +00:00
2021-04-19 14:44:51 +00:00
CleanupFiles
jsr SwapProDOS ; ProDOS out -> in
jsr DeleteFileOnRAMDisk ; always safe to call
jsr CloseFileOnHardDisk ; always safe to call
jmp SwapProDOS ; ProDOS in -> out
2017-01-08 03:35:35 +00:00
;-------------------------------
; WriteTrack
;-------------------------------
MLI_IOERR = $27
MLI_NODEV = $28
MLI_WRITEPROT = $2B
WriteTrack
jsr AnalyzeTrack
WriteTrackNA ; entry point used by Special Delivery tracer
; to write track with 'N'o 'A'nalysis
2017-01-08 03:35:35 +00:00
bit gMode
bpl @exit ; don't write anything in verify mode
2017-01-08 03:35:35 +00:00
lda gSaidWriting
beq @doTheWriteThing ; only print 'writing to' message once
; we haven't yet printed any 'writing to...' message in the log, so
; figure out what that should look like and do it now
2021-04-14 16:40:53 +00:00
lda #s_writingto
jsr PrintByID
lda gHardDiskRef
beq @maybeWritingToRAMDisk
; we are writing to a file on a hard disk, so print the
; full pathname of that file
jsr PrintHardDiskImagePath
bvc @doneSaidWriting ; always branches
@maybeWritingToRAMDisk
lda gRAMDiskRef
beq @notWritingToRAMDisk
lda #s_ramdisk ; writing to (a file on) a RAM disk
!byte $2C
@notWritingToRAMDisk
lda #s_slotanddrive ; writing to a slot and drive
jsr PrintByID
@doneSaidWriting
lda #TRUE
2017-01-08 03:35:35 +00:00
sta gSaidWriting
@doTheWriteThing
jsr SwapProDOS ; ProDOS out -> in
jsr WriteTrackFirstPass
jsr SwapProDOS ; ProDOS in -> out
bcs FatalWriteError
@exit rts
;-------------------------------
; FatalWriteError
; in: A has MLI code (from WriteTrackFirstPass or WriteTrackSecondPass)
; out: does not return, exits via TheEnd
;-------------------------------
FatalWriteError
2017-01-08 03:35:35 +00:00
sta gDisplayBytes ; for use in error messages, if any
2019-04-16 05:39:12 +00:00
tax
2017-01-08 03:35:35 +00:00
lda #s_writeioerr
2019-04-16 05:39:12 +00:00
cpx #MLI_IOERR
beq .printerr
2017-01-08 03:35:35 +00:00
lda #s_writenodev
2019-04-16 05:39:12 +00:00
cpx #MLI_NODEV
beq .printerr
2017-01-08 03:35:35 +00:00
lda #s_writeprot
2019-04-16 05:39:12 +00:00
cpx #MLI_WRITEPROT
beq .printerr
lda #s_othermli
.printerr
2017-01-08 03:35:35 +00:00
pha
lda #s_writeerr
jsr PrintByID
pla
jsr PrintByID
jmp TheEnd
;-------------------------------
; ChangeTrack
; in: A = new track
;-------------------------------
ChangeTrack
sta .new+1
2017-01-08 03:35:35 +00:00
jsr WriteTrack
.new lda #$d1 ; modified at runtime
2017-01-08 03:35:35 +00:00
; note: execution falls through here
ChangeTrackNW ; "N"o "W"rite
sta gTrack
jsr ClearTSBuffer
rts
;-------------------------------
; ChangeSector
; in: A = new sector
;-------------------------------
ChangeSector
sta gSector
clc
adc #BASEPAGE
sta gAddress+1
rts
;-------------------------------
; AnalyzeTrack routine
; Looks at buffer in memory to detect known
; copy protections and disable/revert/modify them
; to work on standard disks.
; Prints through COUT
; Makes modifications in memory only.
2017-01-08 03:35:35 +00:00
; in: $BASEPAGE page contains one track worth of data
; out: if C set, no known protections were found and
; no modifications were made
; if C clear, at least one modification was made
;-------------------------------
AnalyzeTrack
lda gTrack
bne _applyToAll
2017-01-08 03:35:35 +00:00
_applyToT00
lda #>AnalyzeT00
sta _byte_hi
lda #<AnalyzeT00
sta _byte_lo
jsr decrunch
jsr $2000
2017-01-08 03:35:35 +00:00
_applyToAll
2021-04-08 16:22:02 +00:00
; run these modules in verify and crack mode
2017-12-26 16:44:19 +00:00
!source "patchers/t11diskvol.a" ; T11 && gIsRWTS only
!source "patchers/t02volumename.a" ; T02 && gIsBoot0 only
2021-04-08 16:22:02 +00:00
bit gMode
bmi +
jmp .checkPatchCount
+
; only run these modules in crack mode
2017-01-08 03:35:35 +00:00
!source "patchers/universale7.a"
2018-09-24 02:30:17 +00:00
!source "patchers/c9ff.a"
2017-05-05 18:04:32 +00:00
!source "patchers/a6bc95.a" ; gIsPascal only
!source "patchers/a5count.a" ; gIsPascal only
!source "patchers/d5d5f7.a" ; gIsPascal || (gIsBoot0 && gPossibleD5D5F7) only
2017-05-05 18:04:32 +00:00
!source "patchers/prodosrwts.a" ; gIsProDOS only
!source "patchers/prodos6a.a" ; gIsProDOS only
!source "patchers/prodosmecc.a" ; gIsProDOS only
!source "patchers/bbf9.a" ; gIsProDOS only
!source "patchers/memory.config.a" ; gIsProDOS only
!source "patchers/origin.a" ; gIsProDOS only
!source "patchers/rwtsswapmecc.a" ; gMECCFastloadType || gPossibleMECCSwapper only
2021-03-01 05:27:38 +00:00
!source "patchers/meccdqc.a" ; gMECCFastloadType==1 && gT07 only
!source "patchers/rwtsswappenguin.a" ; T01 only
2017-05-05 18:04:32 +00:00
!source "patchers/protecteddos.a" ; gIsProtDOS only
2017-01-24 04:37:16 +00:00
!source "patchers/fbff.a"
!source "patchers/fbffencrypted.a" ; gIsProDOS only
!source "patchers/fbffpascal.a" ; gIsPascal only
!source "patchers/polarware.a" ; gIsProDOS only
!source "patchers/sierra.a" ; gIsBoot0 only
!source "patchers/corrupter.a" ; T13 only
2020-07-22 23:01:07 +00:00
!source "patchers/ea.a" ; gIsEA || gIsBoot0 only
!source "patchers/gamco.a" ; gPossibleGamco only
2017-05-05 18:04:32 +00:00
!source "patchers/optimum.a" ; gIsOptimum only
!source "patchers/bootcounter.a" ; T01 only
!source "patchers/jmpb412.a" ; T02 only
!source "patchers/jmp2012.a" ; T02 only
!source "patchers/jmpb400.a" ; T02 && gIsBoot0 only
!source "patchers/advint.a" ; gAdventureInternational only
!source "patchers/jsr8635.a" ; gIsRWTS only
2017-11-25 16:22:25 +00:00
!source "patchers/jmpb4bb.a" ; T02 only
!source "patchers/dos32muse.a" ; T01 && gIsDOS32 only
2020-07-22 23:01:07 +00:00
!source "patchers/sra.a" ; gIsDOS32 || gIsRWTS only
!source "patchers/sierra13.a" ; gIsDOS32 only
2017-12-26 16:44:19 +00:00
!source "patchers/ssprot.a" ; gIsF7F6 only
!source "patchers/f7f6.a" ; gIsF7F6 only
!source "patchers/trillium.a" ; gIsTrillium only
!source "patchers/trillium2.a" ; T17 only
!source "patchers/advent.a" ; gIsAdvent only
!source "patchers/davidsonforth.a" ; gIsDavidson only
!source "patchers/davidsonasm.a" ; gIsDavidson only
!source "patchers/ssi.a" ; gIsRDOS13 only
2018-09-27 21:26:08 +00:00
!source "patchers/rdosfmt.a" ; gIsRDOS13 only
!source "patchers/aacount.a"
!source "patchers/hallabs.a" ; T01 only
!source "patchers/holle.a" ; gIsHolle only
2019-04-08 00:02:19 +00:00
!source "patchers/zoomgrafix.a" ; gIsPhoenix only
!source "patchers/e7everywhere.a" ; gIsBoot0 || gIsProDOS only
2019-04-13 17:33:15 +00:00
!source "patchers/choplifter.a" ; gIsChoplifter only
!source "patchers/pdi.a" ; gIsDiversi only
!source "patchers/harvey.a" ; T01 only
2020-07-22 23:01:07 +00:00
!source "patchers/tsr.a" ; T04 && gIsTSR only
!source "patchers/woodbury.a" ; gPossibleWoodbury only
!source "patchers/leisure.a" ; gIsProDOS && T22 only
!source "patchers/b4bbbasic.a" ; gPossibleB4BBBasic only
2017-01-08 03:35:35 +00:00
2021-04-08 16:22:02 +00:00
.checkPatchCount
2017-01-08 03:35:35 +00:00
lda gPatchCount
beq .nopatches
2017-01-08 03:35:35 +00:00
clc
!byte $24 ; hide next SEC
.nopatches
2017-01-08 03:35:35 +00:00
sec ; set carry if nothing happened
rts
inx6 inx
inx5 inx
inx4 inx
inx
inx
inx
rts
universalrwts
!bin "../build/universalrwts.pak"
!source "exodecrunch.s"
get_crunched_byte:
_byte_lo = * + 1
_byte_hi = * + 2
lda $1234 ; needs to be set correctly before
; decrunch_file is called.
inc _byte_lo
bne _byte_skip_hi
inc _byte_hi
_byte_skip_hi:
rts
AnalyzeT00 ; placeholder to identify stack of packed data
!bin "../build/t00only.pak"
!source "apicode.a"
2017-01-30 22:10:41 +00:00
LastMover
!if RELBASE = $2000 {
!ifdef PASS2 {
} else { ;PASS2
!set PASS2=1
!warn "RELBASE = ", HIGHPOINT - (LastMover - FirstMover)
}
} else {
!if (HIGHPOINT - (LastMover - FirstMover)) < LOWPOINT {
2021-04-08 16:22:02 +00:00
!serious "My spoon is too big (", HIGHPOINT - (LastMover - FirstMover), ") is below minimum (", LOWPOINT, ")!"
} else {
!warn "LowPoint=", HIGHPOINT - (LastMover - FirstMover)
}
!warn "CleanExit=",CleanExit
!warn "WaitForKey=",WaitForKey
!warn "OpenFile=",OpenFile
!warn "ReadFile=",ReadFile
!warn "CloseFile=",CloseFile
!warn "GetVolumeName=",GetVolumeName
!warn "OnlineReturn=",OnlineReturn
!warn "VolumeName=",VolumeName
!warn "RAMDiskImagePath=",RAMDiskImagePath
!warn "GetVolumeInfo=",GetVolumeInfo
!warn "mliparam=",mliparam
2021-04-14 01:09:55 +00:00
!warn "access=",access
!warn "filetype=",filetype
!warn "auxtype=",auxtype
!warn "blocks=",blocks
!warn "PREFSFILE=",PREFSFILE
!warn "PREFSBUFFER=",PREFSBUFFER
!warn "PREFSREADLEN=",PREFSREADLEN
!warn "PREFSVER=",PREFSVER
!warn "SavePrefs=",SavePrefs
!warn "ValidatePrefs=",ValidatePrefs
!warn "kForceLower=",kForceLower
!warn "PrintByID=",PrintByID
!warn "DiskIIArray=",DiskIIArray
!warn "HardDiskArray=",HardDiskArray
2017-02-13 21:20:24 +00:00
}