passport/src/passport.a

505 lines
16 KiB
Plaintext
Raw Permalink Normal View History

2017-01-08 03:35:35 +00:00
;-------------------------------
; Passport
; a 4am hack
; (c) 2016-2022 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.
;
;-------------------------------
2021-06-12 00:55:18 +00:00
!cpu 6502
!ifdef RELBASE {
*=RELBASE
} else {
*=$2000
}
!ifndef VERBOSE {
VERBOSE = $00 ; set to $01 to display API label addresses
}
!to "../build/passport.tmp",plain
2021-06-11 19:19:41 +00:00
!ct "lcase.ct"
2017-01-08 03:35:35 +00:00
2021-06-19 00:50:19 +00:00
Relocatable
!bin "../build/t00only.pak"
2021-06-19 00:50:19 +00:00
NonRelocatable
2021-06-19 00:54:26 +00:00
!source "apidefs.a"
2021-06-19 00:50:19 +00:00
!source "strings/en.a"
!source "id/dos33.a"
2021-06-20 04:18:55 +00:00
!source "id/dos32.a"
!source "id/dos32lo.a"
2021-06-19 00:50:19 +00:00
!source "id/prodos.a"
!source "id/pascal.a"
2021-06-20 04:18:55 +00:00
!source "id/rdos16.a"
2021-06-19 00:50:19 +00:00
!source "id/jsr8b3.a"
!source "id/mecc.a"
!source "id/datasoft.a"
!source "id/tsr.a"
!source "id/protecteddos.a"
!source "id/encode44.a"
!source "id/encode53.a"
!source "id/ea.a"
!source "id/milliken.a"
!source "id/daviddos.a"
!source "id/quickdos.a"
!source "id/diversidos.a"
!source "id/prontodos.a"
!source "id/laureate.a"
!source "id/micrograms.a"
!source "id/volumename.a"
!source "id/dinkeydos.a"
!source "id/advent.a"
2022-06-24 17:44:26 +00:00
!source "id/baudville.a"
!source "id/enlightenment.a"
2021-06-19 00:50:19 +00:00
!source "id/panglosdos.a"
!source "id/davidson.a"
!source "id/holle.a"
!source "id/phoenix.a"
!source "id/jmp600.a"
2021-06-19 00:50:19 +00:00
!source "id/555.a"
2021-07-11 04:51:32 +00:00
!source "id/trace32.a"
!source "id/trace8b3.a"
!source "id/trace33p.a"
!source "id/trace.a" ; \__ execution falls through
!source "universalstyle.a" ; /
!source "id/trace33.a" ; \__ execution falls through
!source "adstyle.a" ; /
!source "crackme.a" ; /
2021-06-19 01:41:37 +00:00
!source "id/inspect0.a"
2021-06-19 00:50:19 +00:00
!source "print.a"
!source "compare.a"
!source "modify.a"
!source "sectormap.a"
!source "write.a"
!source "mli.a"
!source "ramdisk.a"
2021-07-11 04:51:32 +00:00
!source "harddisk.a" ; \__ execution falls through
!source "memory.a" ; /
2021-06-19 00:50:19 +00:00
!source "slots.a"
!source "prefs.a"
2021-06-19 00:54:26 +00:00
!source "prefs.save.a"
2021-06-19 00:50:19 +00:00
!source "keys.a"
!source "cffa.a"
!source "progress.a"
2021-07-11 04:51:32 +00:00
!source "rwts.a" ; \__ execution falls through
!source "memory.clear.a" ; /
2021-06-19 00:50:19 +00:00
!source "standarddelivery.a"
2021-06-12 00:55:18 +00:00
MainMenu
jsr Cleanup ; RAM/HD files might be left open after Ctrl-Reset
2017-01-08 03:35:35 +00:00
jsr ClearScreen
jsr MoveT00PakLow
@refreshMainMenu
2017-01-08 03:35:35 +00:00
jsr PrintByID
!byte s_header
2017-01-08 03:35:35 +00:00
jsr PrintByID
!byte s_mainmenu
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
sta +
2021-04-14 16:40:53 +00:00
jsr PrintByID
+ !byte $FD ; SMC
@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 #0
sta HPOS
sta VPOS
jsr $FBC1
2017-01-08 03:35:35 +00:00
lda #TRUE
sta gChangedPrefs
beq @refreshMainMenu ; 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 CreateFileOnHardDisk
bcc @printReading
jmp FatalWriteError ; failed to create target file on hard disk
; this is fatal
2021-06-12 00:45:10 +00:00
@idBootloader
jmp IDBootloader ; /src/id/inspect0
@notHardDrive
+MaybeCreateFileOnRAMDisk
@printReading
2017-01-08 03:35:35 +00:00
jsr PrintByID
!byte s_reading
lda #$B2
ldx #$00
ldy #$06
jsr ClearMemory
jsr CopyUniversal
jsr IgnoreAddressChecksum
jsr ReadSector
2021-06-12 00:45:10 +00:00
bcc @idBootloader
2021-06-11 19:19:41 +00:00
jsr IDBootFailure ; /src/id/bootfailure
2021-06-12 00:45:10 +00:00
bcc @idBootloader
2017-01-08 03:35:35 +00:00
jsr PrintByID
!byte s_fatal0000
2021-06-12 00:45:10 +00:00
; /!\ execution falls through here
2017-01-08 03:35:35 +00:00
TheEnd
2021-06-12 00:55:18 +00:00
jsr Cleanup
2017-01-08 03:35:35 +00:00
jsr PrintByID
!byte s_done
2017-01-08 03:35:35 +00:00
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
jsr PrintByID
!byte s_reading
; /!\ 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
jsr PrintByID
!byte s_restart
jsr RestartProgress
jsr IncProgress
jmp ReadWithRWTS
2018-05-29 01:15:45 +00:00
2021-04-20 03:48:41 +00:00
;-------------------------------
2021-06-12 00:55:18 +00:00
; Cleanup
2021-04-20 03:48:41 +00:00
;
; Cleans up open files (if any)
2021-06-12 00:55:18 +00:00
; Also turns off slot 6 drive motor
2021-04-20 03:48:41 +00:00
;
; in: ProDOS is NOT in memory
; out: ProDOS is NOT in memory
; all registers and flags clobbered
;-------------------------------
2021-06-12 00:55:18 +00:00
Cleanup
lda $C0E8
2021-04-20 03:48:41 +00:00
lda gHardDiskRef
ora gRAMDiskRef
2021-06-19 00:50:19 +00:00
bne +
rts
2021-06-19 03:51:12 +00:00
+ jsr SwapProDOS ; ProDOS out -> in
2021-04-20 03:48:41 +00:00
jsr DeleteFileOnRAMDisk
2021-06-19 00:50:19 +00:00
+CloseFileOnHardDisk
jmp SwapProDOS ; ProDOS in -> out
2021-04-20 03:48:41 +00:00
;-------------------------------
; 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
2021-06-12 00:55:18 +00:00
jsr Cleanup
+SavePrefs
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
2021-06-19 04:46:17 +00:00
; out: everything clobbered
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
bit gMode
bpl @applyToAll ; only run track 0 modules in crack mode
lda T00PakPtr+1
sta _byte_hi
lda T00PakPtr
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
2021-06-14 14:56:40 +00:00
!source "patchers/t11diskvol.a" ; T11 only
2017-12-26 16:44:19 +00:00
!source "patchers/t02volumename.a" ; T02 && gIsBoot0 only
2021-04-08 16:22:02 +00:00
bit gMode
bmi +
2021-06-19 04:46:17 +00:00
rts
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"
!source "patchers/d5d5f7.a" ; gIsPascal || gIsBoot0 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/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/jmp2012.a" ; T02 only
!source "patchers/advint.a" ; gAdventureInternational only
2017-11-25 16:22:25 +00:00
!source "patchers/jmpb4bb.a" ; T02 only
!source "patchers/dos32muse.a" ; T01 && gIsDOS32 only
2021-06-14 14:56:40 +00:00
!source "patchers/sra.a" ; gIsDOS32 || gIsBoot0 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/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
2020-07-22 23:01:07 +00:00
!source "patchers/tsr.a" ; T04 && gIsTSR only
!source "patchers/woodbury.a" ; gPossibleWoodbury only
!source "patchers/b4bbbasic.a" ; gPossibleB4BBBasic only
!source "patchers/sigcheck.a" ; gPossibleSigCheck only
!source "patchers/errord51.a" ; gIsLowDOS only
!source "patchers/enlightenment.a" ; gIsEnlightenment && T02 only
2021-06-16 17:36:20 +00:00
;
; DOS 3.3-specific patchers
;
lda gIsBoot0
beq +
jmp _endDOS33Patchers
+
!source "patchers/hallabs.a" ; gIsBoot0 && T01 only
!source "patchers/harvey.a" ; gIsBoot0 && T01 only
!source "patchers/microlearn.a" ; gIsBoot0 && T01 only
2021-06-16 17:36:20 +00:00
!source "patchers/jmpb400.a" ; gIsBoot0 && T02 only
!source "patchers/jmpb412.a" ; gIsBoot0 && T02 only
!source "patchers/mak.a" ; gIsBoot0 && T02 only
2021-06-16 17:36:20 +00:00
!source "patchers/jsr8635.a" ; gIsBoot0 only
!source "patchers/sierra.a" ; gIsBoot0 only
!source "patchers/probs5.a" ; gIsBoot0 only
!source "patchers/didatech.a" ; gIsBoot0 && gIsDidatech only
2021-06-16 17:36:20 +00:00
_endDOS33Patchers
;
; Diversi-DOS-specific patchers
;
lda gIsDiversi
bne _endDiversiPatchers
!source "patchers/pdi.a" ; gIsDiversi only
_endDiversiPatchers
;
; ProDOS-specific patchers
;
lda gIsProDOS
beq +
jmp _endProDOSPatchers
+
!source "patchers/bbf9.a" ; gIsProDOS only
!source "patchers/fbffencrypted.a" ; gIsProDOS only
!source "patchers/e7everywhere.encrypted.a" ; gIsProDOS only
!source "patchers/pfs.prodos.a" ; gIsProDOS && T05 only
2021-06-16 17:36:20 +00:00
!source "patchers/leisure.a" ; gIsProDOS && T22 only
!source "patchers/memory.config.a" ; gIsProDOS only
!source "patchers/origin.a" ; gIsProDOS only
!source "patchers/polarware.a" ; gIsProDOS only
!source "patchers/prodos6a.a" ; gIsProDOS only
!source "patchers/prodosmecc.a" ; gIsProDOS only
!source "patchers/prodosrwts.a" ; gIsProDOS only
_endProDOSPatchers
;
; Pascal-specific patchers
;
lda gIsPascal
beq +
jmp _endPascalPatchers
+
!source "patchers/a5count.a" ; gIsPascal only
!source "patchers/a6bc95.a" ; gIsPascal only
!source "patchers/fbffpascal.a" ; gIsPascal only
!source "patchers/pfs.pascal.a" ; gIsPascal only
2021-06-16 17:36:20 +00:00
_endPascalPatchers
2021-06-19 04:46:17 +00:00
; /!\ execution falls through here because why not
2017-01-08 03:35:35 +00:00
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
2021-07-11 15:12:04 +00:00
;
; Patchers that are called manually
;
!source "patchers/choplifter.a"
!source "patchers/555.a"
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-21 14:33:16 +00:00
!source "id/bootfailure.a"
nop
nop
2021-06-21 15:24:21 +00:00
!source "wholetrack.a"
!source "apicode.a" ; /!\ must be last
2017-01-30 22:10:41 +00:00
!if RELBASE = $2000 {
!ifdef PASS2 {
} else { ;PASS2
!set PASS2=1
2021-06-19 00:50:19 +00:00
!warn "RELBASE = ", HIGHPOINT - (* - Relocatable)
}
} else {
2021-06-19 00:50:19 +00:00
!if (HIGHPOINT - (* - NonRelocatable)) < LOWPOINT {
; code before NonRelocatable is moved and tracked, so it can be below LOWPOINT
!serious "My spoon is too big (", HIGHPOINT - (* - NonRelocatable), ") is below minimum (", LOWPOINT, ")!"
2021-04-08 16:22:02 +00:00
} else {
2021-06-19 00:50:19 +00:00
!warn "LowPoint=", NonRelocatable
}
2021-06-19 00:50:19 +00:00
!warn "ThisSlot=",ThisSlot
!warn "PrintByID=",PrintByID
2021-04-21 14:33:57 +00:00
!warn "WaitForKey=",WaitForKey
2021-06-19 00:50:19 +00:00
!warn "CleanExit=",CleanExit
2021-04-21 14:33:57 +00:00
!warn "OpenFile=",OpenFile
!warn "ReadFile=",ReadFile
!warn "CloseFile=",CloseFile
!warn "GetVolumeName=",GetVolumeName
!warn "GetVolumeInfo=",GetVolumeInfo
!warn "PREFSVER=",PREFSVER
2021-06-19 00:50:19 +00:00
!warn "PREFSFILE=",PREFSFILE
!warn "SLOT=",SLOT
!warn "DRIVE=",DRIVE
2021-06-19 01:13:59 +00:00
!warn "MainMenu=",MainMenu
!warn "CheckCache=",CheckCache
2017-02-13 21:20:24 +00:00
}