passport/src/passport.a

488 lines
16 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
2021-04-20 01:17:23 +00:00
; (c) 2016-2021 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
2017-01-30 22:10:41 +00:00
FirstMover
jmp ResetVector
2021-04-20 04:02:09 +00:00
!source "apidefs.a"
!source "strings/en.a"
2017-01-08 03:35:35 +00:00
!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"
2021-05-27 02:22:36 +00:00
!source "id/555.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"
!source "progress.a"
2017-01-08 03:35:35 +00:00
!source "rwts.a"
2017-08-15 15:31:36 +00:00
!source "standarddelivery.a"
2021-04-20 04:02:09 +00:00
!source "wholetrack.a"
2021-04-20 03:48:41 +00:00
!source "adstyle.a"
!source "universalstyle.a"
!source "crackme.a"
2017-01-08 03:35:35 +00:00
ResetVector
2021-04-19 14:58:00 +00:00
ldx #$FF
txs
2017-01-08 03:35:35 +00:00
lda $C0E8
jsr CleanupFiles ; RAM/HD files might be left open after Ctrl-Reset
; /!\ execution falls through here
MainMenu
2017-01-08 03:35:35 +00:00
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
2021-04-19 14:58:00 +00:00
bcc MainMenu
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
2021-04-20 23:29:46 +00:00
sta gIsRW18
2017-01-08 03:35:35 +00:00
lda #$00
sta gTrack
sta gSector
sta gPatchCount
sta jCallRWTS+1
2021-04-20 20:02:07 +00:00
sta CacheDst+1
2017-01-08 03:35:35 +00:00
lda #$08
sta gAddress+1
2021-04-20 20:02:07 +00:00
lda #$D4
sta CacheDst+2
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
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
2021-04-20 20:02:07 +00:00
jsr CheckLogKeys
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
2021-04-20 03:48:41 +00:00
;-------------------------------
; CleanupFiles
;
; Cleans up open files (if any)
;
; in: ProDOS is NOT in memory
; out: ProDOS is NOT in memory
; all registers and flags clobbered
;-------------------------------
CleanupFiles
lda gHardDiskRef
ora gRAMDiskRef
beq +
jsr SwapProDOS ; ProDOS out -> in
jsr DeleteFileOnRAMDisk
jsr CloseFileOnHardDisk
jsr SwapProDOS ; ProDOS in -> out
+ rts
;-------------------------------
; CleanExit
;
; Cleans up open files, saves preferences (if modified),
; and quits via ProDOS MLI
;
; in: ProDOS is NOT in memory
; out: does not return
;-------------------------------
2017-01-08 03:35:35 +00:00
CleanExit
jsr CleanupFiles
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-20 01:17:23 +00:00
+ jsr PRODOSMLI ; does not return
2017-01-08 03:35:35 +00:00
!byte $65
!word +
+ !byte $04
2017-01-08 03:35:35 +00:00
;-------------------------------
; 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.
2021-04-20 03:48:41 +00:00
; in: @BASEPAGE contains one track worth of data ($1000 bytes)
; gTrack contains track number
; out: if C set, no known protections were found and
; no modifications were made
; if C clear, at least one modification was made
2017-01-08 03:35:35 +00:00
;-------------------------------
AnalyzeTrack
lda gTrack
2021-04-20 03:48:41 +00:00
bne @applyToAll
; Track 0 patchers are stored compressed in memory
; then decompressed into $2000 when needed
lda #>AnalyzeT00
sta _byte_hi
lda #<AnalyzeT00
sta _byte_lo
jsr decrunch
jsr $2000
2021-04-20 03:48:41 +00:00
; /!\ execution falls through here
@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 +
2021-04-20 03:48:41 +00:00
jmp _checkPatchCount
2021-04-08 16:22:02 +00:00
+
; 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
!source "patchers/errord51.a" ; gIsLowDOS only
!source "patchers/sigcheck.a" ; gIsDiversi only
2021-05-27 02:22:36 +00:00
!source "patchers/555.a" ; gIs555 only
2017-01-08 03:35:35 +00:00
2021-04-20 03:48:41 +00:00
_checkPatchCount
2017-01-08 03:35:35 +00:00
lda gPatchCount
2021-04-20 03:48:41 +00:00
beq @noPatches
2017-01-08 03:35:35 +00:00
clc
!byte $24 ; hide next SEC
2021-04-20 03:48:41 +00:00
@noPatches
2017-01-08 03:35:35 +00:00
sec ; set carry if nothing happened
rts
2021-04-20 03:48:41 +00:00
; utility functions used by several patchers
inx0F inx
inx0E inx
inx0D inx
inx0C inx
inx0B inx
inx0A inx
inx9 inx
inx8 inx
inx7 inx
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
2021-06-11 19:06:50 +00:00
!source "id/bootfailure.a"
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)
}
2021-04-21 14:33:57 +00:00
!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
!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
!warn "ThisSlot=",ThisSlot
!warn "CheckCache=",CheckCache
2021-06-11 19:06:50 +00:00
!warn "IDBootFailure=",IDBootFailure
2017-02-13 21:20:24 +00:00
}