pack T00 analyzers

define a global page for shared content
make nib table global
autoclear filters instead of case-by-case
cache IDs in global variables where useful
merge some near-duplicated routines
optimise sector reordering
allow cancel when writing from RAM
pack universal RWTS dynamically to allow easier modification
consolidate output when modifying sequential nibble table entries
make Standard Delivery accept a parameter to specify table
switch unpacker to Exomizer for cross-platform support
make relbase dynamic for easier building
makefile for windows
This commit is contained in:
Peter Ferrie 2017-11-08 21:47:12 -08:00
parent 015103f468
commit f7ede6ef84
36 changed files with 1333 additions and 912 deletions

View File

@ -11,15 +11,24 @@
# third-party tools required to build
# https://sourceforge.net/projects/acme-crossass/
ACME=`which acme`
ACME=acme
# https://sourceforge.net/projects/applecommander/
AC=bin/AppleCommander.jar
# https://bitbucket.org/magli143/exomizer/wiki/Home
EXOMIZER=exomizer
BUILDDISK=build/passport.po
asm:
mkdir -p build
cd src && $(ACME) passport.a && cd -
cd src/mods && $(ACME) universalrwts.a
$(EXOMIZER) raw -q build/universalrwts.bin -o build/universalrwts.tmp
printf "\xB8\x00" | cat - build/universalrwts.tmp > build/universalrwts.pak
cd src/mods && $(ACME) t00only.a
$(EXOMIZER) raw -q build/t00only.bin -o build/t00only.tmp
printf "\x20\x00" | cat - build/t00only.tmp > build/t00only.pak
cd src && $(ACME) passport.a 2> ../build/relbase.log
cd src && $(ACME) -DRELBASE=`cat ../build/relbase.log | cut -d"=" -f2 | cut -d"(" -f2 | cut -d")" -f1` passport.a
cp res/work.po $(BUILDDISK)
java -jar $(AC) -p $(BUILDDISK) "PASSPORT.SYSTEM" sys 0x2000 < build/PASSPORT.SYSTEM

View File

@ -1,6 +0,0 @@
to create the compressed universalrwts.a:
1. acme --cpu 6502 --setpc 0 -o universalrwts.bin universalrwts.org
2. appack c universalrwts.bin universalrwts.pak
3. use a sector editor to remove the first #$18 bytes of the universalrwts.pak file
4. convert the binary back to ACME-compatible text (!byte, '$' for hex, no trailing commas)
5. save in universalrwts.a

View File

@ -191,10 +191,10 @@ IsEEEF
;-------------------------------
IsSyncBytes
lda #$FD
sta nibtableff
sta gNIBTableFF
jsr IsUnformatted
lda #$3F
sta nibtableff
sta gNIBTableFF
rts
;-------------------------------
@ -216,7 +216,7 @@ IsUnformatted
ldy #$00
nibloop ldx $C0EC
bpl nibloop
lda nibtable,x
lda gNIBTable,x
bpl +
inc unform
bne +

177
src/apicode.a Normal file
View File

@ -0,0 +1,177 @@
;-------------------------------
; globally-accessible variables
; in fixed position to allow
; compressed code to work
; offsets must match t00defs.a
;-------------------------------
;gNIBTable
!byte $80,$81,$82,$83,$84,$85,$86,$87,$88,$89,$8A,$8B,$8C,$8D,$8E,$8F
!byte $90,$91,$92,$93,$94,$95,$00,$01,$98,$99,$02,$03,$9C,$04,$05,$06
!byte $A0,$A1,$A2,$A3,$A4,$A5,$07,$08,$A8,$A9,$AA,$09,$0A,$0B,$0C,$0D
!byte $B0,$B1,$0E,$0F,$10,$11,$12,$13,$B8,$14,$15,$16,$17,$18,$19,$1A
!byte $C0,$C1,$C2,$C3,$C4,$C5,$C6,$C7,$C8,$C9,$CA,$1B,$CC,$1C,$1D,$1E
!byte $D0,$D1,$D2,$1F,$D4,$D5,$20,$21,$D8,$22,$23,$24,$25,$26,$27,$28
!byte $E0,$E1,$E2,$E3,$E4,$29,$2A,$2B,$E8,$2C,$2D,$2E,$2F,$30,$31,$32
!byte $F0,$F1,$33,$34,$35,$36,$37,$38,$F8,$39,$3A,$3B,$3C,$3D,$3E
;gNIBTableFF
!byte $3F
;jConstructStandardDelivery
jmp ConstructStandardDelivery
;jCopyUniversalAnywhere
jmp CopyUniversalAnywhere
;jCopyMemory
jmp CopyMemory
;jCallRWTS
jmp $FF59 ; modified at runtime
;jSearchTrack
jmp SearchTrack
;jPrintByID
jmp PrintByID
;jmodify
jmp modify
;jcompare
jmp compare
;gDisplayBytes
!fill 10 ; array of ten bytes for use as
; substitution strings
;gRAMDiskRef
!byte 00 ; handle of RAM disk
; non-zero if open
;gUsingRAMDisk
!byte FALSE ; 0=true, 1=false
;gOnAClearDayYouCanReadForever
!byte FALSE ; 0=true, 1=false
; retry reads with a captured RWTS forever,
; instead of falling back to built-in RWTS
; compile-time flag, no way to change at runtime
FIRSTFILTER
;gIsDatasoft
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
;gIsLaureate
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
;gAdventureInternational
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in TraceDOS33c() after tracing DOS 3.3-shaped RWTS
;gIsMilliken1
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in TraceDOS33c() after tracing DOS 3.3-shaped RWTS
;gIs8b3
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
;gPossibleD5D5F7
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
;gIsMECC4
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
;gIsMECC3
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
;gIsMECC2
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
;gIsMECC1
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
;gIsMECCFastloader
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
;gIsOptimum
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
;gPossibleGamco
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in SkipTrack() after reading T22
;gIsEA
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
;gIsDavidDOS
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
;gIsProtDOS
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
;gIsPascal
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
;gIsProDOS
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
;gIsRWTS
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in AnalyzeT00() after reading T00
;gIsMaster
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in AnalyzeT00() after reading T00
;gIsBoot1
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in AnalyzeT00() after reading T00
;gIsBoot0
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
;gIsDOS32
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
LASTFILTER
;gLastTrack
!byte 00 ; int
; the last track that we should try to read
; (assuming reading from T22 down to T00)
; reset to 0 before each operation, but some
; disks (like DOS3.3P) will change it because
; they write out the first few DOS tracks
; manually before seeking up to T22 to convert
; the rest of the disk
;gChangedPrefs
!byte FALSE ; 0=true, 1=false
; whether we should try to write the configuration file
; when the program exits
; set to #TRUE when changing slots
;gSaidWriting
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set to #TRUE after we print WRITING TO S%s,D%d
;gTriedUniv
!byte FALSE ; 0=true, 1=false
; whether or not we've already tried the built-in RWTS
; (and therefore a read error is fatal)
; reset before each operation
;gPatchCount
!byte 00 ; int
; number of patches we've applied to this disk
; reset before each operation
; incremented in modify()
;gMode
!byte %00000000 ; bit 7 0=verify, 1=see bit 6
; bit 6 0=demuffin, 1=crack
; set based on main menu choice

158
src/apidefs.a Normal file
View File

@ -0,0 +1,158 @@
TRUE = $00 ; Lots of code assumes this is $00
; so it can branch with BEQ, so
; don't change it either!
FALSE = $01
;-------------------------------
;Standard Delivery table indexes
;-------------------------------
ID_DOS33p = $00
ID_DOS32 = $01
ID_DOS32LO = $02
; Zero-page addresses we use for variables
nibsrcindex = $EC ; byte
nibdestindex = $ED ; byte
prbuf = $EE ; word
unform = $F0 ; word
nibcount = $F2 ; byte
modtmp = $F3 ; byte
modsrc = $F4 ; word
moddest = $F6 ; word
cmp1 = $F8 ; word
cmp2 = $FA ; word
counter = $FC ; byte
tmp = $FC ; byte
iunit = $FC ; byte
tmpa = $FC ; byte
tmpx = $FD ; byte
tmpy = $FE ; byte
flag = $FF ; byte
; Application constants (not zero addresses)
!ifdef RELBASE {
!set VERBOSE = $00 ; override for make script
} else {
RELBASE = $2000 ; dummy assignment for first build
; to allow calculation of proper value
}
LOWPOINT = $4300 ; lowest available address for code
BASEPAGE = $10 ; Special Delivery tracer assumes
; this is $10, so don't change it!
;-------------------------------
; globally-accessible variables
; in fixed position to allow
; compressed code to work
;-------------------------------
APIEND = $B600
gMode = APIEND-$01 ; byte
gPatchCount = gMode-$01 ; byte
gTriedUniv = gPatchCount-$01 ; byte
gSaidWriting = gTriedUniv-$01 ; byte
gChangedPrefs = gSaidWriting-$01 ; byte
gLastTrack = gChangedPrefs-$01 ; byte
;FIRSTFILTER ; add new gIs* below this line
gIsDOS32 = gLastTrack-$01 ; byte
gIsBoot0 = gIsDOS32-$01 ; byte
gIsBoot1 = gIsBoot0-$01 ; byte
gIsMaster = gIsBoot1-$01 ; byte
gIsRWTS = gIsMaster-$01 ; byte
gIsProDOS = gIsRWTS-$01 ; byte
gIsPascal = gIsProDOS-$01 ; byte
gIsProtDOS = gIsPascal-$01 ; byte
gIsDavidDOS = gIsProtDOS-$01 ; byte
gIsEA = gIsDavidDOS-$01 ; byte
gPossibleGamco = gIsEA-$01 ; byte
gIsOptimum = gPossibleGamco-$01 ; byte
gIsMECCFastloader = gIsOptimum-$01 ; byte
gIsMECC1 = gIsMECCFastloader-$01 ; byte
gIsMECC2 = gIsMECC1-$01 ; byte
gIsMECC3 = gIsMECC2-$01 ; byte
gIsMECC4 = gIsMECC3-$01 ; byte
gPossibleD5D5F7 = gIsMECC4-$01 ; byte
gIs8b3 = gPossibleD5D5F7-$01 ; byte
gIsMilliken1 = gIs8b3-$01 ; byte
gAdventureInternational = gIsMilliken1-$01 ; byte
gIsLaureate = gAdventureInternational-$01 ; byte
gIsDatasoft = gIsLaureate-$01 ; byte
;LASTFILTER ; add new gIs* above this line
gOnAClearDayYouCanReadForever = gIsDatasoft-$01 ; byte
gUsingRAMDisk = gOnAClearDayYouCanReadForever-$01 ; byte
gRAMDiskRef = gUsingRAMDisk-$01 ; byte
gDisplayBytes = gRAMDiskRef-$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
modify = jmodify
PrintByID = jPrintByID
SearchTrack = jSearchTrack
CallRWTS = jCallRWTS
CopyMemory = jCopyMemory
CopyUniversalAnywhere = jCopyUniversalAnywhere
ConstructStandardDelivery = jConstructStandardDelivery
}
!ifdef VERBOSE {
!if VERBOSE=1 {
!warn "gMode=",gMode
!warn "gPatchCount=",gPatchCount
!warn "gTriedUniv=",gTriedUniv
!warn "gSaidWriting=",gSaidWriting
!warn "gChangedPrefs=",gChangedPrefs
!warn "gLastTrack=",gLastTrack
!warn "gIsDOS32=",gIsDOS32
!warn "gIsBoot0=",gIsBoot0
!warn "gIsBoot1=",gIsBoot1
!warn "gIsMaster=",gIsMaster
!warn "gIsRWTS=",gIsRWTS
!warn "gIsProDOS=",gIsProDOS
!warn "gIsPascal=",gIsPascal
!warn "gIsProtDOS=",gIsProtDOS
!warn "gIsDavidDOS=",gIsDavidDOS
!warn "gIsEA=",gIsEA
!warn "gPossibleGamco=",gPossibleGamco
!warn "gIsOptimum=",gIsOptimum
!warn "gIsMECCFastloader=",gIsMECCFastloader
!warn "gIsMECC1=",gIsMECC1
!warn "gIsMECC2=",gIsMECC2
!warn "gIsMECC3=",gIsMECC3
!warn "gIsMECC4=",gIsMECC4
!warn "gPossibleD5D5F7=",gPossibleD5D5F7
!warn "gIs8b3=",gIs8b3
!warn "gIsMilliken1=",gIsMilliken1
!warn "gAdventureInternational=",gAdventureInternational
!warn "gIsLaureate=",gIsLaureate
!warn "gIsDatasoft=",gIsDatasoft
!warn "gOnAClearDayYouCanReadForever=",gOnAClearDayYouCanReadForever
!warn "gUsingRAMDisk=",gUsingRAMDisk
!warn "gRAMDiskRef=",gRAMDiskRef
!warn "gDisplayBytes=",gDisplayBytes
!warn "jcompare=",jcompare
!warn "jmodify=",jmodify
!warn "jPrintByID=",jPrintByID
!warn "jSearchTrack=",jSearchTrack
!warn "jCallRWTS=",jCallRWTS
!warn "jCopyMemory=",jCopyMemory
!warn "jCopyUniversalAnywhere=",jCopyUniversalAnywhere
!warn "jConstructStandardDelivery=",jConstructStandardDelivery
!warn "gNIBTableFF=",gNIBTableFF
!warn "gNIBTable=",gNIBTable
!warn "gNIBTableBase=",gNIBTableBase
}
}

View File

@ -11,23 +11,12 @@ IDBootloader
; Reset all per-disk globals.
; These are used as filters later so irrelevant patchers can be skipped.
;
ldx #(LASTFILTER-FIRSTFILTER)
lda #FALSE
sta gIsDOS32
sta gIsBoot0
sta gIsBoot1
sta gIsMaster
sta gIsRWTS
sta gIsProDOS
sta gIsPascal
sta gIsProtDOS
sta gIsDavidDOS
sta gIsEA
sta gIsMECCFastloader
sta gPossibleGamco
sta gPossibleD5D5F7
sta gAdventureInternational
lda #$00
sta gLastTrack
- sta FIRSTFILTER-1,x
dex
bne -
stx gLastTrack
;
; Quick sanity check -- only recognized values for $0800
; are 1 or 2 for regular disks, and 5 for possible Electronic Arts.
@ -84,6 +73,8 @@ IDBootloader
bcs +
lda #s_jsr8b3
jsr PrintByID
lda #TRUE
sta gIs8b3
jmp Trace8B3
;
; Try to identify all the different MECC fastloader variants.
@ -99,15 +90,23 @@ IDBootloader
bcs .notmecc
jsr IDMECC1
bcs +
lda #TRUE
sta gIsMECC1
jmp foundmecc1
+ jsr IDMECC2
bcs +
lda #TRUE
sta gIsMECC2
jmp foundmecc2
+ jsr IDMECC3
bcs +
lda #TRUE
sta gIsMECC3
jmp foundmecc3
+ jsr IDMECC4
bcs .notmecc
lda #TRUE
sta gIsMECC4
jmp foundmecc4
.notmecc
;
@ -127,6 +126,8 @@ IDBootloader
bcs +
lda #s_laureate
jsr PrintByID
lda #TRUE
sta gIsLaureate
lda #$0B
jsr PrereadT00Partial
bcs +
@ -213,7 +214,9 @@ IDBootloader
bcs +
lda #s_datasoftb0
jsr PrintByID
bcc .useuniv ; always branches
lda #TRUE
sta gIsDatasoft
beq .useuniv ; always branches
;
; Micrograms bootloader
;
@ -243,71 +246,6 @@ IDBootloader
jmp UseUniversal
}
;-------------------------------
; AnalyzeT00
; set additional flags based on contents of track $00
;
; in: Track $00 in data buffer
; out: gIsBoot1, gIsMaster, gIsRWTS set to #TRUE or #FALSE
; all flags clobbered
; all registers clobbered
;-------------------------------
!zone {
AnalyzeT00
lda #$01
ldx #$00
ldy #$38
jsr compare ; if T00,S01,$00 ==
!byte $8E,$E9,$B7,$8E,$F7,$B7,$A9,$01
!byte $8D,$F8,$B7,$8D,$EA,$B7,$AD,$E0
!byte $B7,$8D,$E1,$B7,$A9,$02,$8D,$EC
!byte $B7,$A9,$04,$8D,$ED,$B7,$AC,$E7
!byte $B7,$88,$8C,$F1,$B7,$A9,$01,$8D
!byte $F4,$B7,$8A,$4A,$4A,$4A,$4A,$AA
!byte $A9,$00,$9D,$F8,$04,$9D,$78,$04
ldx #TRUE
bcc .boot1
ldx #FALSE
.boot1
stx gIsBoot1
lda #$01
ldx #$00
ldy #$38
jsr compare ; if T00,S01,$00 ==
!byte $8E,$E9,$37,$8E,$F7,$37,$A9,$01
!byte $8D,$F8,$37,$8D,$EA,$37,$AD,$E0
!byte $37,$8D,$E1,$37,$A9,$02,$8D,$EC
!byte $37,$A9,$04,$8D,$ED,$37,$AC,$E7
!byte $37,$88,$8C,$F1,$37,$A9,$01,$8D
!byte $F4,$37,$8A,$4A,$4A,$4A,$4A,$AA
!byte $A9,$00,$9D,$F8,$04,$9D,$78,$04
ldx #TRUE
bcc .master
ldx #FALSE
.master
stx gIsMaster
lda #$07
ldx #$00
ldy #$40
jsr compare ; if T00,S07,$00 ==
!byte $84,$48,$85,$49,$A0,$02,$8C,$F8
!byte $06,$A0,$04,$8C,$F8,$04,$A0,$01
!byte $B1,$48,$AA,$A0,$0F,$D1,$48,$F0
!byte $1B,$8A,$48,$B1,$48,$AA,$68,$48
!byte $91,$48,$BD,$8E,$C0,$A0,$08,$BD
!byte $8C,$C0,$DD,$8C,$C0,$D0,$F6,$88
!byte $D0,$F8,$68,$AA,$BD,$8E,$C0,$BD
!byte $8C,$C0,$A0,$08,$BD,$8C,$C0,$48
ldx #TRUE
bcc .rwts
ldx #FALSE
.rwts
stx gIsRWTS
rts
}
!zone {
PrereadT00
lda #$0F

View File

@ -34,8 +34,12 @@ IDMilliken1
jsr compare
!byte $A9,$AE,$8D,$00,$04,$4C,$99,$AD
!byte $AE,$F8,$05,$BD,$89,$C0
bcs +
lda #TRUE
sta gIsMilliken1
bcc .exit
+
; variant 2 (seen in The Writing Workshop)
ldy #$0B
jsr compare

View File

@ -154,11 +154,11 @@ TraceDOS32LO
sta b4bbmodify+2
sta b4bbmodify2+2
adc #$04 ; $BD or $3D
sta callrwts+2
sta jCallRWTS+2
adc #$02 ; $BF or $3F
sta b4bbcompare+1
lda #$00
sta callrwts+1
sta jCallRWTS+1
; set up final trace
@ -178,7 +178,7 @@ TraceDOS32LO
.fail jmp FatalError
TraceDOS32d
lda callrwts+2
lda jCallRWTS+2
ldx #$00 ; check for "STY $48;STA $49"
ldy #$04 ; at RWTS entry point
jsr CompareMemory ; (e.g. $BD00 or $3D00)
@ -187,7 +187,7 @@ TraceDOS32d
lda #$FA
sta modsrc
lda callrwts+2
lda jCallRWTS+2
sec
sbc #$05
sta modsrc+1
@ -240,7 +240,7 @@ TraceDOS32d
sta gIsDOS32
; check for MUSE sector doubling RWTS
lda callrwts+2
lda jCallRWTS+2
ldx #$09
ldy #$02
jsr CompareMemory
@ -265,7 +265,7 @@ FFer
bne +
iny
bne -
ldy callrwts+2
ldy jCallRWTS+2
dey
sty .G+2
dey

View File

@ -69,13 +69,13 @@ _Inspect1a
dex
stx .x3+1
stx .x4+1
stx callrwts+2
stx jCallRWTS+2
jsr ProtectedDOS ; check for a specific (encrypted)
; bootloader called "Protected DOS"
bcs .notprotdos
jmp ADStyle
.notprotdos
lda callrwts+2
lda jCallRWTS+2
ldx #$00 ; check for "STY $48;STA $49"
ldy #$04 ; at RWTS entry point
jsr CompareMemory ; (e.g. $BD00 or $3D00)

View File

@ -142,8 +142,7 @@ SDsuccess
; copy Standard Delivery bootloader into place for T00,S00
lda #<SD_DOS33p
ldx #>SD_DOS33p
ldx #ID_DOS33p
jsr ConstructStandardDelivery
lda #s_bootwrite
jsr PrintByID
@ -205,9 +204,9 @@ skipsectors
; set up RWTS entry point
lda #$D5
sta callrwts+1
sta jCallRWTS+1
lda #$36
sta callrwts+2
sta jCallRWTS+2
; read the rest of the disk with the original RWTS

View File

@ -98,9 +98,9 @@ _restore3
; Set up RWTS entry point
;
lda #$00
sta callrwts+1
sta jCallRWTS+1
lda #$BD
sta callrwts+2
sta jCallRWTS+2
;
; Read the rest of the disk with the original RWTS
;

View File

@ -79,6 +79,7 @@ ClearTSBuffer
; in: A = source address (high)
; X = destination address (high)
; Y = number of pages to copy
; C = dest direction (set: +, clear: -)
; out: all flags and registers clobbered
;-------------------------------
!zone {
@ -87,6 +88,10 @@ SwapMemory
sta .source2+2
stx .dest1+2
stx .dest2+2
lda #$FF
adc #0
ora #1
sta .destadjust+1
ldx #$00
.source1 lda $FF00,x
pha
@ -98,13 +103,36 @@ SwapMemory
bne .source1
inc .source1+2
inc .source2+2
inc .dest1+2
inc .dest2+2
lda .dest1+2
clc
.destadjust
adc #$D1
sta .dest1+2
sta .dest2+2
dey
bne .source1
rts
}
;-------------------------------
; ReorderBuffer - convert data
; buffer between ProDOS and
; DOS 3.3 ordering (use after
; read or before write under
; ProDOS)
; in: none
; out: all flags clobbered
; all registers clobbered
;-------------------------------
!zone {
ReorderBuffer
lda #BASEPAGE+1
ldx #BASEPAGE+$0E
ldy #$07
clc
jmp SwapMemory
}
;-------------------------------
; SaveProDOS
; saves memory pages used by ProDOS
@ -142,14 +170,17 @@ SwapProDOS
lda #$00
ldx #$40
ldy #$01
sec
jsr SwapMemory
lda #$03
ldx #$41
ldy #$01
sec
jsr SwapMemory
lda #$BF
ldx #$42
ldy #$01
sec
jsr SwapMemory
rts
@ -176,58 +207,38 @@ SwapProDOS
; 0123456789ABCDEF
; 07E6D5C4B3A2918F
; in: track buffer has data in logical sector order
; out: A,Y clobbered
; X preserved
; out: A,X,Y clobbered
;-------------------------------
!zone {
ReorderLogicalToPhysical
ldy #$00
- lda $1100,y
pha
lda $1200,y
pha
lda $1300,y
pha
lda $1400,y
pha
lda $1600,y
pha
lda $1700,y
pha
lda $1800,y
pha
lda $1900,y
pha
lda $1b00,y
pha
lda $1c00,y
pha
lda $1d00,y
pha
- ldx $1800,y
lda $1e00,y
sta $1800,y
pla
sta $1100,y
pla
sta $1900,y
pla
sta $1200,y
pla
sta $1300,y
pla
sta $1b00,y
pla
sta $1400,y
pla
sta $1c00,y
pla
sta $1d00,y
pla
sta $1600,y
pla
lda $1200,y
sta $1e00,y
pla
lda $1b00,y
sta $1200,y
txa
sta $1b00,y
ldx $1100,y
lda $1d00,y
sta $1100,y
lda $1400,y
sta $1d00,y
lda $1700,y
sta $1400,y
txa
sta $1700,y
ldx $1900,y
lda $1c00,y
sta $1900,y
lda $1600,y
sta $1c00,y
lda $1300,y
sta $1600,y
txa
sta $1300,y
iny
bne -
rts

View File

@ -54,9 +54,7 @@ WriteTrackMLI
lda gUsingRAMDisk
beq +
jsr ReorderBuffer
+ lda #$81 ; 'write block' command
sta mlicmd
lda DRIVE ; ProDOS "unit number" is
+ lda DRIVE ; ProDOS "unit number" is
sec
sbc #$31
lsr ; DSSS0000, where D is the
@ -90,7 +88,7 @@ WriteTrackMLI
.writeloop
lda gUsingRAMDisk
beq +
lda mlicmd
lda #$81 ; 'write block' command
ldy #$03 ; parameter count
jsr mli
bcs .writeerr
@ -119,46 +117,6 @@ WriteTrackMLI
.blockcount !byte $FF
}
;-------------------------------
; ReorderBuffer - convert data
; buffer between ProDOS and
; DOS 3.3 ordering (use after
; read or before write under
; ProDOS)
; in: none
; out: all flags clobbered
; all registers clobbered
; @cmp1, @cmp2 clobbered
;-------------------------------
!zone {
ReorderBuffer
lda #$00
sta cmp1
sta cmp2
tay
lda #$01
clc
adc #BASEPAGE
sta cmp1+1
lda #$0E
clc
adc #BASEPAGE
sta cmp2+1
ldx #$07
.L lda (cmp1),y
pha
lda (cmp2),y
sta (cmp1),y
pla
sta (cmp2),y
iny
bne .L
inc cmp1+1
dec cmp2+1
dex
bne .L
rts
}
;-------------------------------
; SaveFile1Shot
@ -497,13 +455,13 @@ accessbits = $C3 ; full access
CreateFile
lda #accessbits
sta mliparam+3 ; access bits (full access)
lda #1
sta mliparam+7 ; storage type (file)
lda #0
sta mliparam+8 ; creation date (current)
sta mliparam+9
sta mliparam+10 ; creation time (current)
sta mliparam+11
ldy #1
sty mliparam+7 ; storage type (file)
dey
sty mliparam+8 ; creation date (current)
sty mliparam+9
sty mliparam+10 ; creation time (current)
sty mliparam+11
lda #CMD_CREATE ; MLI create command
ldy #PC_CREATE ; number of parameters for 'create' command
jsr mli
@ -706,6 +664,8 @@ WriteRAMToDisk
jsr IncProgress
jsr WriteTrackMLI
bcs .exit
lda KEY
bmi .cancel
inc gTrack
lda gTrack
cmp #$23
@ -715,8 +675,13 @@ WriteRAMToDisk
lda #TRUE
sta gUsingRAMDisk
clc
.exit
rts
.cancel
jmp Cancel
}
;-------------------------------

View File

@ -61,13 +61,12 @@ modify
bne .src
lda #$8D
jsr PrintA
bvc +
.mod
lda (modsrc),y
dey
bmi .exit
sta (moddest),y
clv
bvc .mod ; unconditional branch
+ lda (modsrc),y
dey
bpl .mod
.exit
inc gPatchCount
.exitnomod

118
src/mods/t00only.a Normal file
View File

@ -0,0 +1,118 @@
!cpu 6502
*=$2000
!to "../../build/t00only.bin",plain
MODULE=1
!source "../apidefs.a"
!source "../strings/enid.a"
WILDCARD = $97 ; from compare.a
;-------------------------------
; AnalyzeT00
; set additional flags based on contents of track $00
;
; in: Track $00 in data buffer
; out: gIsBoot1, gIsMaster, gIsRWTS set to #TRUE or #FALSE
; all flags clobbered
; all registers clobbered
;-------------------------------
!zone {
AnalyzeT00
lda #$01
ldx #$00
ldy #$38
jsr compare ; if T00,S01,$00 ==
!byte $8E,$E9,$B7,$8E,$F7,$B7,$A9,$01
!byte $8D,$F8,$B7,$8D,$EA,$B7,$AD,$E0
!byte $B7,$8D,$E1,$B7,$A9,$02,$8D,$EC
!byte $B7,$A9,$04,$8D,$ED,$B7,$AC,$E7
!byte $B7,$88,$8C,$F1,$B7,$A9,$01,$8D
!byte $F4,$B7,$8A,$4A,$4A,$4A,$4A,$AA
!byte $A9,$00,$9D,$F8,$04,$9D,$78,$04
ldx #TRUE
bcc .boot1
ldx #FALSE
.boot1
stx gIsBoot1
lda #$01
ldx #$00
ldy #$38
jsr compare ; if T00,S01,$00 ==
!byte $8E,$E9,$37,$8E,$F7,$37,$A9,$01
!byte $8D,$F8,$37,$8D,$EA,$37,$AD,$E0
!byte $37,$8D,$E1,$37,$A9,$02,$8D,$EC
!byte $37,$A9,$04,$8D,$ED,$37,$AC,$E7
!byte $37,$88,$8C,$F1,$37,$A9,$01,$8D
!byte $F4,$37,$8A,$4A,$4A,$4A,$4A,$AA
!byte $A9,$00,$9D,$F8,$04,$9D,$78,$04
ldx #TRUE
bcc .master
ldx #FALSE
.master
stx gIsMaster
lda #$07
ldx #$00
ldy #$40
jsr compare ; if T00,S07,$00 ==
!byte $84,$48,$85,$49,$A0,$02,$8C,$F8
!byte $06,$A0,$04,$8C,$F8,$04,$A0,$01
!byte $B1,$48,$AA,$A0,$0F,$D1,$48,$F0
!byte $1B,$8A,$48,$B1,$48,$AA,$68,$48
!byte $91,$48,$BD,$8E,$C0,$A0,$08,$BD
!byte $8C,$C0,$DD,$8C,$C0,$D0,$F6,$88
!byte $D0,$F8,$68,$AA,$BD,$8E,$C0,$BD
!byte $8C,$C0,$A0,$08,$BD,$8C,$C0,$48
ldx #TRUE
bcc .rwts
ldx #FALSE
.rwts
stx gIsRWTS
}
!source "../patchers/sunburst.a"
!source "../patchers/jmpbcf0.a"
!source "../patchers/jmpbeb1.a"
!source "../patchers/jmpbeca.a"
!source "../patchers/jmpb660.a"
!source "../patchers/jmpb720.a"
!source "../patchers/bademu.a"
!source "../patchers/bademu2.a"
!source "../patchers/rwts.a"
!source "../patchers/rwtslog.a"
!source "../patchers/mecc1.a"
!source "../patchers/mecc2.a"
!source "../patchers/mecc3.a"
!source "../patchers/mecc4.a"
!source "../patchers/rol1e.a"
!source "../patchers/jmpb4bb.a"
!source "../patchers/jmpb4bbhi.a"
!source "../patchers/thunder.a"
!source "../patchers/jsrbb03.a"
!source "../patchers/davidbb03.a"
!source "../patchers/rwtsswap.a"
!source "../patchers/rwtsswap2.a"
!source "../patchers/border.a"
!source "../patchers/jmpae8e.a"
!source "../patchers/jmpbbfe.a"
!source "../patchers/datasoft.a"
!source "../patchers/nibtable.a"
!source "../patchers/diskvol.a"
!source "../patchers/c9ff.a"
!source "../patchers/milliken.a"
!source "../patchers/methods.a"
!source "../patchers/jsr8b3.a"
!source "../patchers/laureate.a"
!source "../patchers/pascalrwts.a"
!source "../patchers/micrograms.a"
!source "../patchers/dos32.a"
!source "../patchers/dos32dlm.a"
;add only above this line
rts
!if * > $4000 {
!serious "code is too large to fit in available space!"
}

View File

@ -1,3 +1,8 @@
!cpu 6502
*=$B800
!to "../../build/universalrwts.bin",plain
;-------------------------------
; Universal RWTS
; a modified DOS 3.3-style RWTS that reads 16-sector (6-and-2 encoded) disks
@ -17,13 +22,6 @@
; will crash.
;-------------------------------
UNIV_A1 = $B956 ; must LSR before setting
UNIV_A2 = $B95F
UNIV_A3 = $B968
UNIV_D1 = $B8E7
UNIV_D2 = $B8F1
UNIV_D3 = $B8FC
universalrwts
!byte $A2,$00,$A0,$02,$88,$B1,$3E,$4A,$3E,$00,$BC,$4A,$3E,$00,$BC,$99
!byte $00,$BB,$E8,$E0,$56,$90,$ED,$A2,$00,$98,$D0,$E8,$A2,$55,$BD,$00
@ -57,7 +55,6 @@ universalrwts
!byte $38,$20,$EE,$B9,$B9,$11,$BA,$20,$00,$BA,$A5,$27,$18,$20,$F1,$B9
!byte $B9,$1D,$BA,$20,$00,$BA,$E6,$26,$D0,$C3,$20,$00,$BA,$18,$AD,$78
!byte $04,$29,$03,$2A,$05,$2B,$AA,$BD,$80,$C0,$A6,$2B,$60,$AA,$A0,$A0
nibtable
!byte $A2,$11,$CA,$D0,$FD,$E6,$46,$D0,$02,$E6,$47,$38,$E9,$01,$D0,$F0
!byte $60,$01,$30,$28,$24,$20,$1E,$1D,$1C,$1C,$1C,$1C,$1C,$70,$2C,$26
!byte $22,$1F,$1E,$1D,$1C,$1C,$1C,$1C,$1C,$96,$97,$9A,$9B,$9D,$9E,$9F
@ -69,15 +66,15 @@ nibtable
; these $FF bytes (at $BA80..$BA95) are used by the
; routine that checks whether a track is formatted
!byte $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
!byte $FF,$FF,$FF,$FF,$FF,$FF,$00,$01,$98,$99,$02,$03,$9C,$04,$05,$06
!byte $A0,$A1,$A2,$A3,$A4,$A5,$07,$08,$A8,$A9,$AA,$09,$0A,$0B,$0C,$0D
!byte $B0,$B1,$0E,$0F,$10,$11,$12,$13,$B8,$14,$15,$16,$17,$18,$19,$1A
!byte $C0,$C1,$C2,$C3,$C4,$C5,$C6,$C7,$C8,$C9,$CA,$1B,$CC,$1C,$1D,$1E
!byte $D0,$D1,$D2,$1F,$D4,$D5,$20,$21,$D8,$22,$23,$24,$25,$26,$27,$28
!byte $E0,$E1,$E2,$E3,$E4,$29,$2A,$2B,$E8,$2C,$2D,$2E,$2F,$30,$31,$32
!byte $F0,$F1,$33,$34,$35,$36,$37,$38,$F8,$39,$3A,$3B,$3C,$3D,$3E
nibtableff
!byte $3F
; the nibble table that lives at $BA96 is copied into here from another location
; after being potentially modified because of protection
!byte $FF,$FF,$FF,$FF,$FF,$FF,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00

View File

@ -1,11 +0,0 @@
nibtable=*-$80
!byte $80,$81,$82,$83,$84,$85,$86,$87,$88,$89,$8A,$8B,$8C,$8D,$8E,$8F
!byte $90,$91,$92,$93,$94,$95,$00,$01,$98,$99,$02,$03,$9C,$04,$05,$06
!byte $A0,$A1,$A2,$A3,$A4,$A5,$07,$08,$A8,$A9,$AA,$09,$0A,$0B,$0C,$0D
!byte $B0,$B1,$0E,$0F,$10,$11,$12,$13,$B8,$14,$15,$16,$17,$18,$19,$1A
!byte $C0,$C1,$C2,$C3,$C4,$C5,$C6,$C7,$C8,$C9,$CA,$1B,$CC,$1C,$1D,$1E
!byte $D0,$D1,$D2,$1F,$D4,$D5,$20,$21,$D8,$22,$23,$24,$25,$26,$27,$28
!byte $E0,$E1,$E2,$E3,$E4,$29,$2A,$2B,$E8,$2C,$2D,$2E,$2F,$30,$31,$32
!byte $F0,$F1,$33,$34,$35,$36,$37,$38,$F8,$39,$3A,$3B,$3C,$3D,$3E
nibtableff
!byte $3F

View File

@ -29,6 +29,10 @@
;
;-------------------------------
!ifndef VERBOSE {
VERBOSE = $00 ; set to $01 to display API label addresses
}
; Supported languages
; (each has its own localized strings file
; and its own output filename)
@ -72,55 +76,25 @@ COUT = $FDED
PR0 = $FE89
IN0 = $FE93
; Zero-page addresses we use for variables
!ifdef PASS2 {
} else {
;unpacker variables, no need to change these
src = $3c ; word
dst = $3e ; word
ecx = $40 ; word
last = $42 ; word
tmpu = $44 ; word
;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
nibsrcindex = $EC ; byte
nibdestindex = $ED ; byte
prbuf = $EE ; word
unform = $F0 ; word
nibcount = $F2 ; byte
modtmp = $F3 ; byte
modsrc = $F4 ; word
moddest = $F6 ; word
cmp1 = $F8 ; word
cmp2 = $FA ; word
counter = $FC ; byte
tmp = $FC ; byte
iunit = $FC ; byte
tmpa = $FC ; byte
tmpx = $FD ; byte
tmpy = $FE ; byte
flag = $FF ; byte
}
; Application constants (not zero addresses)
RELBASE = $5600 ; address to move Passport code
; so that it's out of the way
LOWPOINT = $4300 ; lowest available address for code
BASEPAGE = $10 ; Special Delivery tracer assumes
; this is $10, so don't change it!
TRUE = $00 ; Lots of code assumes this is $00
; so it can branch with BEQ, so
; don't change it either!
FALSE = $01
!source "apidefs.a"
ldx #$00
FM lda FirstMover + ((255 + LastMover - FirstMover) & $FF00),x
FM lda LastMover - 256,x
sta $B500,x
inx
bne FM
dec FM+2
dec FM+5
lda FM+2
cmp #$1F
lda FM+5
cmp #(>RELBASE)-((>(RELBASE+255))->RELBASE)-1
bne FM
jmp OneTimeSetup
@ -266,7 +240,6 @@ MainMenu
Action
sta gMode
bit gMode
bpl +
jsr CreateRAMFile
+ jsr ResetProgress
@ -280,7 +253,7 @@ Action
sta gTrack
sta gSector
sta gPatchCount
sta callrwts+1
sta jCallRWTS+1
lda #$08
sta gAddress+1
jsr ClearScreen
@ -518,22 +491,20 @@ CopyUniversal
pha
lda #$B8
CopyUniversalAnywhere
sta dst+1
sta universalrwts
clc
adc #$02
sta .cu+2
lda #$00
sta dst
lda #>universalrwts
sta src+1
sta _byte_hi
lda #<universalrwts
sta src
jsr Unpack
sta callrwts+1
sta _byte_lo
jsr decrunch
sta jCallRWTS+1
lda #$BD
sta callrwts+2
sta jCallRWTS+2
ldy #$96
.culoop lda nibtable,y
.culoop lda gNIBTable,y
.cu sta $d100,y ; set at runtime
iny
bne .culoop
@ -698,47 +669,14 @@ ChangeSector
;-------------------------------
AnalyzeTrack
lda gTrack
beq _applyToT00
jmp _applyToAll
bne _applyToAll
_applyToT00
jsr AnalyzeT00 ; /src/id/inspect0
!source "patchers/sunburst.a"
!source "patchers/jmpbcf0.a"
!source "patchers/jmpbeb1.a"
!source "patchers/jmpbeca.a"
!source "patchers/jmpb660.a"
!source "patchers/jmpb720.a"
!source "patchers/bademu.a"
!source "patchers/bademu2.a"
!source "patchers/rwts.a"
!source "patchers/rwtslog.a"
!source "patchers/mecc1.a"
!source "patchers/mecc2.a"
!source "patchers/mecc3.a"
!source "patchers/mecc4.a"
!source "patchers/rol1e.a"
!source "patchers/jmpb4bb.a"
!source "patchers/jmpb4bbhi.a"
!source "patchers/thunder.a"
!source "patchers/jsrbb03.a"
!source "patchers/davidbb03.a"
!source "patchers/rwtsswap.a"
!source "patchers/rwtsswap2.a"
!source "patchers/border.a"
!source "patchers/jmpae8e.a"
!source "patchers/jmpbbfe.a"
!source "patchers/datasoft.a"
!source "patchers/nibtable.a"
!source "patchers/diskvol.a"
!source "patchers/c9ff.a"
!source "patchers/milliken.a"
!source "patchers/methods.a"
!source "patchers/jsr8b3.a"
!source "patchers/laureate.a"
!source "patchers/pascalrwts.a"
!source "patchers/micrograms.a"
!source "patchers/dos32.a"
!source "patchers/dos32dlm.a"
lda #>AnalyzeT00
sta _byte_hi
lda #<AnalyzeT00
sta _byte_lo
jsr decrunch
jsr $2000
_applyToAll
!source "patchers/universale7.a"
!source "patchers/a6bc95.a" ; gIsPascal only
@ -773,122 +711,23 @@ _applyToAll
sec ; set carry if nothing happened
rts
;
; Global variables
;
gTriedUniv
!byte FALSE ; 0=true, 1=false
; whether or not we've already tried the built-in RWTS
; (and therefore a read error is fatal)
; reset before each operation
gMode
!byte %00000000 ; bit 7 0=verify, 1=see bit 6
; bit 6 0=demuffin, 1=crack
; set based on main menu choice
gPatchCount
!byte 00 ; int
; number of patches we've applied to this disk
; reset before each operation
; incremented in modify()
gSaidWriting
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set to #TRUE after we print WRITING TO S%s,D%d
gChangedPrefs
!byte FALSE ; 0=true, 1=false
; whether we should try to write the configuration file
; when the program exits
; set to #TRUE when changing slots
gLastTrack
!byte 00 ; int
; the last track that we should try to read
; (assuming reading from T22 down to T00)
; reset to 0 before each operation, but some
; disks (like DOS3.3P) will change it because
; they write out the first few DOS tracks
; manually before seeking up to T22 to convert
; the rest of the disk
gIsDOS32
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
gIsBoot0
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
gIsBoot1
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in AnalyzeT00() after reading T00
gIsMaster
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in AnalyzeT00() after reading T00
gIsRWTS
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in AnalyzeT00() after reading T00
gIsProDOS
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
gIsPascal
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
gIsProtDOS
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
gIsDavidDOS
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
gIsEA
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
gPossibleGamco
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in SkipTrack() after reading T22
gIsOptimum
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
gIsMECCFastloader
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
gPossibleD5D5F7
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
gAdventureInternational
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in TraceDOS33c() after tracing DOS 3.3-shaped RWTS
gOnAClearDayYouCanReadForever
!byte FALSE ; 0=true, 1=false
; retry reads with a captured RWTS forever,
; instead of falling back to built-in RWTS
; compile-time flag, no way to change at runtime
gUsingRAMDisk
!byte FALSE ; 0=true, 1=false
gRAMDiskRef
!byte 00 ; handle of RAM disk
; non-zero if open
!source "universalrwts.a"
universalrwts
!bin "../build/universalrwts.pak"
!source "unpack.a"
!source "nibtable.a"
AnalyzeT00 ; placeholder to identify stack of packed data
!bin "../build/t00only.pak"
!source "apicode.a"
}
LastMover
!if ($B500 - ((255 + LastMover - FirstMover) & $FF00)) != RELBASE {
!serious "RELBASE requires adjustment to ", ($B500 - ((255 + LastMover - FirstMover) & $FF00))
}
!if ($B500 - ((255 + LastMover - FirstMover) & $FF00)) < LOWPOINT {
!serious "code is too large to fit in available space!"
!if RELBASE = $2000 {
!ifdef PASS2 {
} else { ;PASS2
!set PASS2=1
!warn "RELBASE = ", $B600 - (LastMover - FirstMover)
}
} else {
!if ($B600 - (LastMover - FirstMover)) < LOWPOINT {
!serious "code is too large to fit in available space!"
}
}

View File

@ -4,8 +4,8 @@
; e.g. Video Title Shop, Tomahawk //e
;-------------------------------
!zone {
jsr IDDatasoft
bcs .exit
lda gIsDatasoft
bne .exit
ldy #$06
jsr SearchTrack

View File

@ -10,7 +10,7 @@
; sector 1
lda callrwts+2
lda jCallRWTS+2
sta .cr+1
sec
sbc #$06 ; #$B7 or #$37
@ -55,13 +55,11 @@
.cr lda #$d1 ; set at runtime
cmp #$3D
beq +
lda #<SD_DOS32
ldx #>SD_DOS32
ldx #ID_DOS32
jsr ConstructStandardDelivery
jmp ++
+ lda #<SD_DOS32LO
ldx #>SD_DOS32LO
+ ldx #ID_DOS32LO
jsr ConstructStandardDelivery
++ lda #s_bootwrite

View File

@ -9,9 +9,9 @@
; e.g. English Achievement I
;-------------------------------
!zone {
jsr ID8b3
bcs .exit
bcc +
lda gIs8b3
bne .exit
beq +
.sectors
!byte $00,$00,$02,$02,$02,$02,$02,$02,$02,$02

View File

@ -4,9 +4,9 @@
; but generally DOS-shaped
;-------------------------------
!zone {
jsr IDLaureate
bcs .exit
bcc +
lda gIsLaureate
bne .exit
beq +
.sectors
!byte $04,$04,$04,$04,$04,$04,$04,$04,$04,$05,$05,$05,$05,$05,$05,$05,$06,$06,$06

View File

@ -5,10 +5,9 @@
; e.g. Word Munchers
;-------------------------------
!zone {
jsr IDMECC
bcs .exit
jsr IDMECC1
bcs .exit
lda gIsMECCFastloader
ora gIsMECC1
bne .exit
lda #$0B
ldx #$08
ldy #$01

View File

@ -5,10 +5,9 @@
; e.g. Phonics Prime Time series
;-------------------------------
!zone {
jsr IDMECC
bcs .exit
jsr IDMECC2
bcs .exit
lda gIsMECCFastloader
ora gIsMECC2
bne .exit
lda #$07
ldx #$83
ldy #$01

View File

@ -5,10 +5,9 @@
; e.g. Word Munchers v1.1
;-------------------------------
!zone {
jsr IDMECC
bcs .exit
jsr IDMECC3
bcs .exit
lda gIsMECCFastloader
ora gIsMECC3
bne .exit
lda #$0A
ldx #$E8
ldy #$01

View File

@ -5,10 +5,9 @@
; e.g. A-201 Conquering Whole Numbers
;-------------------------------
!zone {
jsr IDMECC
bcs .exit
jsr IDMECC4
bcs .exit
lda gIsMECCFastloader
ora gIsMECC4
bne .exit
lda #$08
ldx #$83
ldy #$01

View File

@ -7,8 +7,8 @@
; The Writing Workshop, Math Sequences
;-------------------------------
!zone {
jsr IDMilliken1
bcs .exit
lda gIsMilliken1
bne .exit
lda #$01
ldx #$48
ldy #$02

View File

@ -8,22 +8,6 @@
_nibtable
jmp .checkread
.readdata
!byte $00,$01
!byte $98,$99,$02,$03,$9C,$04,$05,$06
!byte $A0,$A1,$A2,$A3,$A4,$A5,$07,$08
!byte $A8,$A9,$AA,$09,$0A,$0B,$0C,$0D
!byte $B0,$B1,$0E,$0F,$10,$11,$12,$13
!byte $B8,$14,$15,$16,$17,$18,$19,$1A
!byte $C0,$C1,$C2,$C3,$C4,$C5,$C6,$C7
!byte $C8,$C9,$CA,$1B,$CC,$1C,$1D,$1E
!byte $D0,$D1,$D2,$1F,$D4,$D5,$20,$21
!byte $D8,$22,$23,$24,$25,$26,$27,$28
!byte $E0,$E1,$E2,$E3,$E4,$29,$2A,$2B
!byte $E8,$2C,$2D,$2E,$2F,$30,$31,$32
!byte $F0,$F1,$33,$34,$35,$36,$37,$38
!byte $F8,$39,$3A,$3B,$3C,$3D,$3E,$3F
.writedata
!byte $96,$97,$9A,$9B,$9D,$9E,$9F,$A6
!byte $A7,$AB,$AC,$AD,$AE,$AF,$B2,$B3
@ -80,59 +64,103 @@ _nibtable
jmp .exit2
.fixread
lda #$00
sta nibsrcindex
lda #$6A
sta .loopcheck+1
lda #$96
sta nibdestindex
.read
ldx nibsrcindex
lda .readdata,x
sta .nibcmpr
sta .nibmodr
lda #$04
ldx nibdestindex
ldy #$01
jsr compare
.nibcmpr !byte $FF
bcc .nomodr
lda #$04
ldx nibdestindex
ldy #$01
jsr modify
.nibmodr !byte $FF
.nomodr
inc nibsrcindex
inc nibdestindex
bne .read
rts
ldx #<(gNIBTableBase+$16)
ldy #>(gNIBTableBase+$16)
bne .common
.fixwrite
lda #$40
sta .loopcheck+1
lda #$29
ldx #<.writedata
ldy #>.writedata
.common
sta nibdestindex
stx .nibload1+1
sty .nibload1+2
stx .nibload2+1
sty .nibload2+2
lda #$00
sta nibsrcindex
lda #$29
.modloop
ldy nibsrcindex
ldx nibdestindex
;loop while match succeeds
.nibload1
lda $D1D1,y
cmp (BASEPAGE*256)+$400,x
beq .nibcheck
;count mismatches until match or end
inx
iny
cpy .loopcheck+1
bne .nibload1
;if we saw mismatches...
.nibcheck
cpy nibsrcindex
beq .advance
;remember where
txa
pha
tya
pha
;determine how many
sec
sbc nibsrcindex
pha
tax
;construct dynamic data to apply mods
lda #$20
sta $300
lda #<modify
sta $301
lda #>modify
sta $302
lda #$60
sta $303,x
.nibdec
dex
dey
.nibload2
lda $D1D1,y
sta $303,x
txa
bne .nibdec
pla
tay
lda #$04
ldx nibdestindex
jsr $300
;restore position, then resume
pla
sta nibsrcindex
pla
sta nibdestindex
.write
ldx nibsrcindex
lda .writedata,x
sta .nibcmpw
sta .nibmodw
lda #$04
ldx nibdestindex
ldy #$01
jsr compare
.nibcmpw !byte $FF
bcc .nomodw
lda #$04
ldx nibdestindex
ldy #$01
jsr modify
.nibmodw !byte $FF
.nomodw
.advance
inc nibsrcindex
inc nibdestindex
lda nibsrcindex
cmp #$40
bne .write
.loopcheck
cmp #$D1
bcc .modloop
rts
.exit2
}

View File

@ -1,7 +1,5 @@
kForceLower !byte $FF ; AND mask for lowercase letters
; (set at program startup)
gDisplayBytes !fill 10 ; array of ten bytes for use as
; substitution strings
;-------------------------------
; PrintByID

View File

@ -2,8 +2,8 @@
; ReadSector
; high-level function to read a single sector.
; in: gIsProtDOS is TRUE or FALSE
; if gProtDOS is FALSE, callrwts+2 has been set to
; the RWTS entry point (e.g. $BD or $3D)
; if gProtDOS is FALSE, jCallRWTS has been set to
; the RWTS entry point (e.g. $BDxx or $3Dxx)
; out: all registers clobbered
; C clear if read was successful
; C set if read failed
@ -33,7 +33,7 @@ ReadSector
setuprwts
ldy #<gRWTSParams
lda #>gRWTSParams
callrwts jsr $FF00 ; modified at runtime
jsr jCallRWTS
bcc endread
lda gOnAClearDayYouCanReadForever
beq setuprwts
@ -88,7 +88,7 @@ PreReadSector
!zone {
cmp #kSectorCustomDOS32B4BB
bne +
ldx callrwts+2
ldx jCallRWTS+2
dex
dex
dex

View File

@ -13,7 +13,26 @@
;-------------------------------
!zone {
ConstructStandardDelivery
sta .A+1
dex
beq .construct32
dex
beq .construct32lo
.construct33p
lda #<SD_DOS33p
ldx #>SD_DOS33p
bne +
.construct32
lda #<SD_DOS32
ldx #>SD_DOS32
bne +
.construct32lo
lda #<SD_DOS32LO
ldx #>SD_DOS32LO
+ sta .A+1
stx .A+2
ldx #$00
txa

View File

@ -11,107 +11,7 @@ k_slot = "S"
k_quit = "Q"
; <Esc> will also quit
;
; String IDs
; (pass in accumulator to PrintByID)
;
s_header = $00
s_mainmenu = $01
s_progbar = $02
s_reading = $03
s_diskrwts = $04
s_bb00 = $05
s_sunburst = $06
s_optimum = $07
s_builtin = $08
s_switch = $09
s_writing = $0A
s_unformat = $0B
s_f7 = $0C
s_sync = $0D
s_optbad = $0E
s_pass = $0F
s_passdemuf = $10
s_passcrack = $11
s_passcrack0 = $12
s_fail = $13
s_fatal0000 = $14
s_fatal220f = $15
s_done = $16
s_noslot6 = $17
s_writeerr = $18
s_writeioerr = $19
s_writenodev = $1A
s_writeprot = $1B
s_othermli = $1C
s_canttrace = $1D
s_canceled = $1E
s_bademu = $1F
s_reset = $20
s_modify = $21
s_modifyto = $22
s_dosb0 = $23
s_prodosb0 = $24
s_pascalb0 = $25
s_mecc = $26
s_sierra = $27
s_a6bc95 = $28
s_jmpbcf0 = $29
s_rol1e = $2A
s_runhello = $2B
s_e7 = $2C
s_jmpb4bb = $2D
s_jmpb400 = $2E
s_jmpbeca = $2F
s_jsrbb03 = $30
s_thunder = $31
s_jmpae8e = $32
s_diskvol = $33
s_d5d5f7 = $34
s_construct= $35
s_datasoftb0 = $36
s_datasoft = $37
s_lsr6a = $38
s_bcs08 = $39
s_jmpb660 = $3A
s_protdos = $3B
s_protdosw = $3C
s_protserial = $3D
s_fbff = $3E
s_encoded44 = $3F
s_encoded53 = $40
s_specdel = $41
s_bytrack = $42
s_a5count = $43
s_restart = $44
s_corrupter= $45
s_eab0 = $46
s_eatrk6 = $47
s_eeef = $48
s_poke = $49
s_bootcounter = $4A
s_milliken = $4B
s_jsr8b3 = $4C
s_daviddos = $4D
s_quickdos = $4E
s_diversidos = $4F
s_prontodos = $50
s_jmpb412 = $51
s_laureate = $52
s_bbf9 = $53
s_micrograms = $54
s_cmpbne0 = $55
s_writeram = $56
s_d5timing = $57
s_advint = $58
s_dos32b0 = $59
s_bootwrite = $5A
s_rwtswrite = $5B
s_rdos = $5C
s_sra = $5D
s_muse = $5E
STRINGCOUNT = $5F
!source "strings/enid.a"
!zone {
StringTable
!word .header

100
src/strings/enid.a Normal file
View File

@ -0,0 +1,100 @@
;
; String IDs
; (pass in accumulator to PrintByID)
;
s_header = $00
s_mainmenu = $01
s_progbar = $02
s_reading = $03
s_diskrwts = $04
s_bb00 = $05
s_sunburst = $06
s_optimum = $07
s_builtin = $08
s_switch = $09
s_writing = $0A
s_unformat = $0B
s_f7 = $0C
s_sync = $0D
s_optbad = $0E
s_pass = $0F
s_passdemuf = $10
s_passcrack = $11
s_passcrack0 = $12
s_fail = $13
s_fatal0000 = $14
s_fatal220f = $15
s_done = $16
s_noslot6 = $17
s_writeerr = $18
s_writeioerr = $19
s_writenodev = $1A
s_writeprot = $1B
s_othermli = $1C
s_canttrace = $1D
s_canceled = $1E
s_bademu = $1F
s_reset = $20
s_modify = $21
s_modifyto = $22
s_dosb0 = $23
s_prodosb0 = $24
s_pascalb0 = $25
s_mecc = $26
s_sierra = $27
s_a6bc95 = $28
s_jmpbcf0 = $29
s_rol1e = $2A
s_runhello = $2B
s_e7 = $2C
s_jmpb4bb = $2D
s_jmpb400 = $2E
s_jmpbeca = $2F
s_jsrbb03 = $30
s_thunder = $31
s_jmpae8e = $32
s_diskvol = $33
s_d5d5f7 = $34
s_construct= $35
s_datasoftb0 = $36
s_datasoft = $37
s_lsr6a = $38
s_bcs08 = $39
s_jmpb660 = $3A
s_protdos = $3B
s_protdosw = $3C
s_protserial = $3D
s_fbff = $3E
s_encoded44 = $3F
s_encoded53 = $40
s_specdel = $41
s_bytrack = $42
s_a5count = $43
s_restart = $44
s_corrupter= $45
s_eab0 = $46
s_eatrk6 = $47
s_eeef = $48
s_poke = $49
s_bootcounter = $4A
s_milliken = $4B
s_jsr8b3 = $4C
s_daviddos = $4D
s_quickdos = $4E
s_diversidos = $4F
s_prontodos = $50
s_jmpb412 = $51
s_laureate = $52
s_bbf9 = $53
s_micrograms = $54
s_cmpbne0 = $55
s_writeram = $56
s_d5timing = $57
s_advint = $58
s_dos32b0 = $59
s_bootwrite = $5A
s_rwtswrite = $5B
s_rdos = $5C
s_sra = $5D
s_muse = $5E
STRINGCOUNT = $5F

View File

@ -1,113 +0,0 @@
;-------------------------------
; Universal RWTS
; a modified DOS 3.3-style RWTS that reads 16-sector (6-and-2 encoded) disks
; - address prologue "D4 AA 96" or "D5 AA 96"
; - any address epilogue
; - data prologue "D5 AA AD"
; - any data epilogue
;
; It verifies the data field checksum byte, but it ignores the address field
; checksum. It waits longer than a normal RWTS to find an address prologue --
; long enough that it will find the prologue even if there is only one sector
; on a track.
;
; It must be loaded at $B800. It uses the standard RWTS entry point at $BD00.
;
; Write support has been disabled. Any attempt to pass $02 or $04 RWTS commands
; will crash.
;-------------------------------
UNIV_A1 = $B956 ; must LSR before setting
UNIV_A2 = $B95F
UNIV_A3 = $B968
UNIV_D1 = $B8E7
UNIV_D2 = $B8F1
UNIV_D3 = $B8FC
universalrwts
!byte $A2,$E0,$A0,$07,$02,$88,$B1,$3E,$4A,$2E,$0A,$BC,$04,$1C,$99,$00
!byte $BB,$E8,$E0,$56,$90,$ED,$C7,$2E,$98,$D0,$9E,$A6,$55,$BD,$24,$18
!byte $29,$3F,$9D,$0A,$CA,$10,$00,$F5,$60,$38,$86,$27,$8E,$78,$06,$1C
!byte $BD,$8D,$C0,$FB,$F3,$18,$30,$7C,$AD,$2A,$85,$26,$0F,$A9,$FF,$9D
!byte $8F,$E7,$1D,$8C,$F0,$48,$68,$EA,$A0,$60,$04,$0A,$20,$B9,$B8,$88
!byte $0F,$D0,$F8,$A9,$D5,$1D,$FC,$75,$42,$AA,$22,$AD,$03,$98,$A0,$56
!byte $D0,$03,$B9,$00,$5C,$59,$FF,$BB,$AA,$BD,$29,$BA,$1B,$A6,$27,$9D
!byte $85,$60,$66,$52,$EB,$A5,$26,$EA,$70,$59,$A9,$15,$AE,$A1,$B0,$16
!byte $30,$50,$BB,$C8,$D0,$46,$EA,$3D,$20,$E5,$82,$DE,$72,$4B,$EB,$2D
!byte $DE,$B4,$0B,$FC,$06,$29,$60,$18,$DE,$D0,$66,$7C,$7A,$70,$A0,$06
!byte $A2,$56,$CA,$30,$FB,$77,$65,$5E,$CC,$2A,$00,$04,$91,$3E,$C8,$C4
!byte $26,$D8,$C0,$34,$20,$88,$30,$F0,$61,$5B,$10,$FB,$49,$7F,$D5,$2A
!byte $F4,$EA,$0A,$3D,$C9,$AA,$28,$F2,$92,$84,$0B,$7B,$AD,$38,$E7,$A9
!byte $05,$88,$84,$26,$BC,$10,$0E,$8B,$1E,$BA,$A4,$A8,$FF,$F8,$D0,$56
!byte $EE,$11,$91,$91,$2A,$EE,$10,$41,$D9,$E9,$13,$49,$39,$C3,$CF,$05
!byte $EA,$61,$0A,$5C,$38,$9B,$D0,$F7,$66,$1D,$4C,$04,$E6,$4A,$F0,$F3
!byte $16,$87,$4A,$C9,$6A,$E5,$EF,$74,$6E,$23,$09,$96,$18,$D8,$A0,$03
!byte $DC,$85,$27,$A9,$0F,$2A,$21,$3C,$13,$08,$25,$38,$C2,$2C,$0F,$45
!byte $27,$88,$46,$E7,$A8,$A6,$85,$5C,$4E,$00,$18,$60,$86,$2B,$85,$03
!byte $2A,$CD,$78,$04,$F0,$53,$1B,$79,$26,$AD,$12,$0F,$82,$38,$E5,$2A
!byte $C0,$33,$B0,$07,$49,$FF,$60,$EE,$1C,$90,$05,$69,$FE,$63,$CE,$0E
!byte $C5,$26,$CA,$02,$40,$4E,$C9,$0C,$01,$B0,$01,$A8,$38,$20,$EE,$B9
!byte $C4,$11,$BA,$ED,$40,$AD,$A5,$27,$18,$F8,$F1,$C8,$18,$1D,$48,$9B
!byte $0C,$D0,$C3,$0F,$18,$C0,$83,$29,$03,$2A,$05,$2B,$90,$62,$1D,$80
!byte $C0,$A6,$9D,$60,$DC,$A0,$40,$A2,$11,$CA,$D0,$FD,$E6,$74,$46,$74
!byte $02,$0F,$47,$38,$E9,$01,$67,$F0,$60,$40,$30,$28,$24,$20,$14,$1E
!byte $1D,$1C,$01,$02,$70,$2C,$26,$22,$1F,$98,$0C,$96,$97,$00,$9A,$9B
!byte $9D,$9E,$9F,$A6,$A7,$AB,$00,$AC,$AD,$AE,$AF,$B2,$B3,$B4,$B5,$00
!byte $B6,$B7,$B9,$BA,$BB,$BC,$BD,$BE,$00,$BF,$CB,$CD,$CE,$CF,$D3,$D6
!byte $D7,$00,$D9,$DA,$DB,$DC,$DD,$DE,$DF,$E5,$00,$E6,$E7,$E9,$EA,$EB
!byte $EC,$ED,$EE,$00,$EF,$F2,$F3,$F4,$F5,$F6,$F7,$F9,$03,$FA,$FB,$FC
!byte $FD,$FE,$FF,$85,$3A,$01,$21,$FF,$DB,$80,$01,$98,$99,$00,$02,$03
!byte $9C,$04,$05,$06,$A0,$A1,$01,$A2,$A3,$A4,$A5,$07,$08,$A8,$30,$07
!byte $09,$00,$0A,$0B,$0C,$0D,$B0,$B1,$0E,$0F,$00,$10,$11,$12,$13,$B8
!byte $14,$15,$16,$00,$17,$18,$19,$1A,$C0,$C1,$C2,$C3,$00,$C4,$C5,$C6
!byte $C7,$C8,$C9,$CA,$1B,$00,$CC,$1C,$1D,$1E,$D0,$D1,$D2,$1F,$4C,$D4
!byte $82,$02,$21,$D8,$22,$23,$24,$40,$5E,$27,$28,$00,$E0,$E1,$E2,$E3
!byte $E4,$29,$2A,$2B,$00,$E8,$2C,$2D,$2E,$2F,$30,$31,$32,$00,$F0,$F1
!byte $33,$34,$35,$36,$37,$38,$00,$F8,$39,$3A,$3B,$3C,$3D,$3E,$3F,$E1
!byte $4E,$01,$EE,$96,$72,$27,$5E,$E6,$22,$42,$DD,$0D,$20,$C3,$BC,$07
!byte $F9,$8D,$42,$0E,$EA,$C1,$FE,$F0,$75,$27,$CB,$FC,$59,$0B,$96,$11
!byte $A5,$41,$FD,$C4,$02,$44,$11,$3F,$09,$FD,$45,$F3,$97,$90,$48,$4A
!byte $05,$3E,$BB,$19,$0C,$68,$09,$54,$D4,$81,$DE,$5C,$34,$EB,$89,$18
!byte $77,$0C,$43,$27,$22,$DD,$6D,$EA,$02,$54,$B4,$08,$DE,$20,$10,$60
!byte $88,$A5,$0E,$E8,$91,$A0,$94,$CA,$96,$06,$4F,$7F,$1F,$C8,$10,$D0
!byte $A3,$A3,$E0,$A0,$A5,$85,$1D,$A4,$84,$48,$1E,$49,$04,$02,$8C,$F8
!byte $C3,$69,$04,$73,$0A,$F4,$01,$2C,$B1,$48,$15,$0E,$0F,$D1,$A3,$F0
!byte $1B,$8A,$CE,$17,$7E,$68,$7B,$91,$C6,$CB,$A0,$08,$CE,$80,$4F,$D0
!byte $F6,$BA,$E0,$29,$68,$AA,$77,$22,$15,$DB,$D2,$04,$F1,$F8,$05,$42
!byte $1C,$03,$06,$EE,$26,$66,$89,$30,$06,$72,$38,$99,$36,$3C,$C8,$B4
!byte $0A,$5E,$C7,$F3,$C1,$3C,$85,$47,$B7,$C0,$24,$A6,$10,$AB,$67,$06
!byte $9C,$28,$DE,$05,$08,$6A,$80,$B7,$BD,$8A,$C0,$3A,$B0,$03,$BA,$8B
!byte $8F,$66,$35,$28,$E1,$D0,$0B,$A0,$07,$65,$9D,$8D,$7E,$FA,$AE,$94
!byte $06,$87,$58,$FA,$5A,$3E,$BE,$28,$83,$11,$A4,$47,$10,$0D,$F1,$12
!byte $88,$63,$9E,$20,$F7,$F0,$F3,$FA,$0C,$C2,$36,$F0,$5A,$C9,$E0,$0C
!byte $58,$6A,$6C,$08,$7A,$64,$B8,$06,$A0,$30,$8C,$78,$05,$69,$F6,$44
!byte $0C,$B9,$90,$24,$CE,$16,$10,$59,$F3,$E0,$01,$48,$A9,$60,$20,$95
!byte $BE,$FA,$83,$D1,$F0,$28,$D7,$D5,$8D,$1F,$D3,$F8,$66,$9F,$68,$09
!byte $58,$4C,$AB,$0B,$A4,$2E,$CC,$A5,$4B,$1C,$0C,$26,$98,$4B,$68,$DF
!byte $4C,$83,$D0,$E5,$F0,$CA,$C0,$A9,$40,$28,$3F,$4C,$48,$F9,$75,$39
!byte $75,$AF,$B9,$A5,$3D,$9D,$A5,$2F,$D4,$0E,$AB,$07,$68,$F0,$08,$C5
!byte $9E,$98,$82,$20,$D0,$7F,$E1,$60,$05,$F6,$A8,$B9,$B8,$BF,$3E,$C5
!byte $2D,$01,$97,$28,$90,$1C,$20,$DC,$EE,$87,$82,$8E,$97,$A2,$03,$86
!byte $26,$DB,$C2,$DC,$40,$18,$24,$38,$A0,$0D,$92,$2B,$30,$88,$C0,$FA
!byte $2A,$B8,$90,$90,$DD,$1F,$10,$B0,$EE,$A4,$4D,$87,$3C,$6A,$68,$D0
!byte $08,$0A,$20,$6B,$32,$BE,$4E,$E6,$60,$E3,$C9,$CB,$8E,$CB,$B9,$07
!byte $12,$24,$35,$30,$03,$7C,$F4,$8D,$C6,$14,$A5,$2A,$19,$20,$05,$99
!byte $3A,$10,$03,$E0,$1C,$4C,$A0,$B9,$8A,$64,$4A,$03,$A8,$85,$D1,$22
!byte $32,$6A,$43,$1C,$14,$61,$68,$0A,$23,$E2,$60,$4A,$51,$84,$B1,$41
!byte $C7,$03,$47,$3E,$A4,$56,$A0,$12,$44,$12,$99,$FF,$BB,$5D,$38,$B8
!byte $50,$06,$A9,$55,$50,$D4,$D4,$28,$85,$4D,$45,$47,$41,$EF,$F0,$0D
!byte $BF,$F9,$43,$A5,$24,$A3,$30,$12,$D0,$05,$38,$44,$1D,$F0,$19,$90
!byte $27,$B0,$F5,$A5,$A1,$C2,$F1,$57,$BF,$93,$EC,$E6,$F6,$4E,$04,$C9
!byte $23,$90,$D3,$18,$84,$8D,$22,$BB,$38,$93,$BC,$3E,$A5,$3F,$80,$80
!byte $D0,$02,$A4,$45,$20,$56,$15,$BC,$B0,$6B,$CB,$75,$13,$66,$E6,$3F
!byte $01,$91,$C9,$10,$90,$EC,$30,$16,$84,$F5,$50,$4D,$99,$A8,$BF,$19
!byte $88,$10,$FA,$47,$87,$E2,$92,$03,$50,$FE,$CA,$FC,$F1,$5E,$10,$23
!byte $14,$F0,$15,$FC,$28,$C5,$82,$E4,$E9,$50,$01,$88,$C9,$05,$05,$B0
!byte $11,$38,$60,$1E,$19,$75,$E7,$11,$37,$86,$42,$28,$20,$0B,$3D,$C9
!byte $0F,$D4,$15,$8C,$84,$61,$EB,$4C,$A4,$2D,$B9,$8B,$B0,$30,$DD,$0C
!byte $30,$BF,$C6,$14,$3F,$10,$CA,$9D,$1B,$D0,$0A,$8C,$3F,$F3,$E5,$76
!byte $C4,$04,$18,$60,$A2,$22,$A0,$0D,$0B,$09,$00,$07,$05,$03,$01,$0E
!byte $0C,$0A,$08,$00,$06,$04,$02,$0F,$20,$93,$FE,$AD,$34,$81,$C0,$07
!byte $0E,$C4,$8D,$01,$E0,$4C,$44,$B7,$65,$85,$E4,$63,$AA,$F8,$70,$CE
!byte $06,$71,$D4,$84,$06,$5B,$A7,$8C,$B7,$0F,$38,$7E,$AE,$8F,$9B,$B3
!byte $9A,$C1,$16,$A3,$BA,$8E,$83,$10,$A9,$09,$4C,$85,$EE,$00

View File

@ -1,177 +1,436 @@
;aPLib data decompressor for Apple II
;Peter Ferrie (peter.ferrie@gmail.com)
;assemble using ACME
;dst<src
!zone {
Unpack ;unpacker entrypoint
lda #0
sta last
sta ecx+1
; This source code is altered and is not the original version found on
; the Exomizer homepage.
; It contains modifications made by Krill/Plush to depack a packed file
; crunched forward and to work with his loader.
literal
jsr getput
ldy #2
;
; Copyright (c) 2002 - 2005 Magnus Lind.
;
; This software is provided 'as-is', without any express or implied warranty.
; In no event will the authors be held liable for any damages arising from
; the use of this software.
;
; Permission is granted to anyone to use this software for any purpose,
; including commercial applications, and to alter it and redistribute it
; freely, subject to the following restrictions:
;
; 1. The origin of this software must not be misrepresented; you must not
; claim that you wrote the original software. If you use this software in a
; product, an acknowledgment in the product documentation would be
; appreciated but is not required.
;
; 2. Altered source versions must be plainly marked as such, and must not
; be misrepresented as being the original software.
;
; 3. This notice may not be removed or altered from any distribution.
;
; 4. The names of this software and/or it's copyright holders may not be
; used to endorse or promote products derived from this software without
; specific prior written permission.
;
; -------------------------------------------------------------------
; The decruncher jsr:s to the get_crunched_byte address when it wants to
; read a crunched byte. This subroutine has to preserve x and y register and,
; if FORWARD_DECRUNCHING = 0, must not modify the state of the carry flag.
; -------------------------------------------------------------------
;.import get_crunched_byte
; -------------------------------------------------------------------
; this function is the heart of the decruncher.
; It initializes the decruncher zeropage locations and precalculates the
; decrunch tables and decrunches the data
; This function will not change the interrupt status bit and it will not
; modify the memory configuration.
; -------------------------------------------------------------------
;.export decrunch
nexttag
jsr getbit
bcc literal
jsr getbit
bcc codepair
jsr getbit
bcs onebyte
jsr getsrc
lsr
beq donedepacking
ldx #0
stx ecx
rol ecx
stx last+1
tax
bne domatch_with_2inc
; -------------------------------------------------------------------
; if literal sequences is not used (the data was crunched with the -c
; flag) then the following line can be uncommented for shorter code.
;LITERAL_SEQUENCES_NOT_USED=1
getbit
asl last
bne .stillbitsleft
jsr getsrc
asl
sta last
inc last
; -------------------------------------------------------------------
; set this flag to 0 if the data are depacked backwards,
; and non-0 otherwise
; -------------------------------------------------------------------
FORWARD_DECRUNCHING=1
.stillbitsleft
; -------------------------------------------------------------------
; zero page addresses used
; -------------------------------------------------------------------
zp_len_lo = $a7
donedepacking
rts
zp_src_lo = $ae
zp_src_hi = zp_src_lo + 1
onebyte
ldy #1
sty ecx
iny
lda #0
sta tmpu+1
lda #$10
zp_bits_hi = $fc
.getmorebits
pha
jsr getbit
pla
rol
bcc .getmorebits
bne domatch
jsr putdst
zp_bitbuf = $fd
zp_dest_lo = zp_bitbuf + 1 ; dest addr lo
zp_dest_hi = zp_bitbuf + 2 ; dest addr hi
linktag
bne nexttag
tabl_bi = decrunch_table
tabl_lo = decrunch_table + 52
tabl_hi = decrunch_table + 104
codepair
jsr getgamma
- jsr dececx
dey
bne -
tay
ora ecx+1
beq +
; -------------------------------------------------------------------
; no code below this comment has to be modified in order to generate
; a working decruncher of this source file.
; However, you may want to relocate the tables last in the file to a
; more suitable address.
; -------------------------------------------------------------------
normalcodepair
dey
sty last+1
jsr getsrc
tax
!byte $a9
+ iny
jsr getgamma
cpy #$7d
bcs domatch_with_2inc
cpy #5
bcs domatch_with_inc
txa
bmi domatch_new_lastpos
; -------------------------------------------------------------------
; jsr this label to decrunch, it will in turn init the tables and
; call the decruncher
; no constraints on register content, however the
; decimal flag has to be #0 (it almost always is, otherwise do a cld)
decrunch:
; -------------------------------------------------------------------
; init zeropage, x and y regs.
;
ldy #0
ldx #3
init_zp:
jsr get_crunched_byte
sta zp_bitbuf - 1,x
dex
bne init_zp
; -------------------------------------------------------------------
; calculate tables (50 bytes)
; x and y must be #0 when entering
;
nextone:
inx
tya
bne domatch_new_lastpos
and #$0f
beq shortcut ; start with new sequence
domatch_with_2inc
inc ecx
bne domatch_with_inc
inc ecx+1
txa ; this clears reg a
lsr ; and sets the carry flag
ldx tabl_bi-1,y
rolle:
rol
rol zp_bits_hi
dex
bpl rolle ; c = 0 after this (rol zp_bits_hi)
domatch_with_inc
inc ecx
bne domatch_new_lastpos
inc ecx+1
adc tabl_lo-1,y
tax
domatch_new_lastpos
domatch_lastpos
ldy #1
lda last+1
sta tmpu+1
lda zp_bits_hi
adc tabl_hi-1,y
shortcut:
sta tabl_hi,y
txa
sta tabl_lo,y
domatch
sta tmpu
lda src+1
pha
lda src
pha
lda dst
sec
sbc tmpu
sta src
lda dst+1
sbc tmpu+1
sta src+1
- jsr getput
jsr dececx
ora ecx+1
bne -
pla
sta src
pla
sta src+1
bne linktag
ldx #4
jsr get_bits ; clears x-reg.
sta tabl_bi,y
iny
cpy #52
bne nextone
beq begin
getgamma
lda #1
sta ecx
sta ecx+1
dec ecx+1
.getgammaloop
jsr getbit
rol ecx
rol ecx+1
jsr getbit
bcs .getgammaloop
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
dececx
lda ecx
bne +
dec ecx+1
+ dec ecx
lda ecx
rts
getput
jsr getsrc
putdst
sty tmpu
ldy #0
sta (dst), y
ldy tmpu
inc dst
bne +
inc dst+1
+ rts
getsrc
sty tmpu
ldy #0
lda (src), y
ldy tmpu
inc src
bne +
inc src+1
+ rts
; -------------------------------------------------------------------
; get bits (29 bytes)
;
; args:
; x = number of bits to get
; returns:
; a = #bits_lo
; x = #0
; c = 0
; z = 1
; zp_bits_hi = #bits_hi
; notes:
; y is untouched
; -------------------------------------------------------------------
get_bits:
lda #$00
sta zp_bits_hi
cpx #$01
bcc bits_done
bits_next:
lsr zp_bitbuf
bne ok
pha
!IF FORWARD_DECRUNCHING = 0 {
literal_get_byte:
jsr get_crunched_byte
bcc literal_byte_gotten
} ELSE {
jsr get_crunched_byte
;; sec
}
ror
sta zp_bitbuf
pla
ok:
rol
rol zp_bits_hi
dex
bne bits_next
bits_done:
rts
!IF FORWARD_DECRUNCHING {
; -------------------------------------------------------------------
; literal sequence handling
;
literal_start:
ldx #$10 ; these 16 bits
jsr get_bits; tell the length of the sequence
ldx zp_bits_hi
literal_start1: ; if literal byte, a = 1, zp_bits_hi = 0
sta zp_len_lo
!byte $2c ; skip next instruction
; -------------------------------------------------------------------
; main copy loop
; x = length hi
; y = length lo
;
copy_start:
stx zp_bits_hi
ldy #$00
copy_next:
!IFNDEF LITERAL_SEQUENCES_NOT_USED {
bcs +
jsr get_crunched_byte
clc
!byte $2c; skip next instruction
+
}
lda (zp_src_lo),y
sta (zp_dest_lo),y
iny
bne +
dex
inc <zp_dest_hi
inc zp_src_hi
+ tya
eor zp_len_lo
bne copy_next
txa
bne copy_next
tya
clc
adc <zp_dest_lo
sta <zp_dest_lo
bcc +
inc <zp_dest_hi
+
} ELSE {
; -------------------------------------------------------------------
; main copy loop
; x = length hi
; y = length lo
; (18(16) bytes)
;
copy_next_hi:
dex
dec zp_dest_hi
dec zp_src_hi
copy_next:
dey
!IFNDEF LITERAL_SEQUENCES_NOT_USED {
bcc literal_get_byte
}
lda (zp_src_lo),y
literal_byte_gotten: ; y = 0 when this label is jumped to
sta (zp_dest_lo),y
copy_start:
tya
bne copy_next
txa
bne copy_next_hi
}
; -------------------------------------------------------------------
; decruncher entry point, needs calculated tables (21(13) bytes)
; x and y must be #0 when entering
;
begin:
!IFNDEF LITERAL_SEQUENCES_NOT_USED {
inx
jsr get_bits
tay
bne literal_start1; if bit set, get a literal byte
} ELSE {
dey
}
getgamma:
inx
jsr bits_next
lsr
iny
bcc getgamma
!IFDEF LITERAL_SEQUENCES_NOT_USED {
beq literal_start
}
cpy #$11
!IFNDEF LITERAL_SEQUENCES_NOT_USED {
!IF FORWARD_DECRUNCHING {
beq bits_done ; gamma = 17 : end of file
bcs literal_start ; gamma = 18 : literal sequence
; gamma = 1..16: sequence
} ELSE {
bcc sequence_start; gamma = 1..16: sequence
beq bits_done ; gamma = 17 : end of file
; gamma = 18 : literal sequence
; -------------------------------------------------------------------
; literal sequence handling (13(2) bytes)
;
ldx #$10 ; these 16 bits
jsr get_bits; tell the length of the sequence
literal_start1: ; if literal byte, a = 1, zp_bits_hi = 0
sta zp_len_lo
ldx zp_bits_hi
ldy #0
bcc literal_start; jmp
sequence_start:
}
} ELSE {
bcs bits_done
}
; -------------------------------------------------------------------
; calulate length of sequence (zp_len) (11 bytes)
;
ldx tabl_bi - 1,y
jsr get_bits
adc tabl_lo - 1,y ; we have now calculated zp_len_lo
sta zp_len_lo
; -------------------------------------------------------------------
; now do the hibyte of the sequence length calculation (6 bytes)
lda zp_bits_hi
adc tabl_hi - 1,y ; c = 0 after this.
pha
; -------------------------------------------------------------------
; here we decide what offset table to use (20 bytes)
; x is 0 here
;
bne nots123
ldy zp_len_lo
cpy #$04
bcc size123
nots123:
ldy #$03
size123:
ldx tabl_bit - 1,y
jsr get_bits
adc tabl_off - 1,y ; c = 0 after this.
tay ; 1 <= y <= 52 here
; -------------------------------------------------------------------
!IF FORWARD_DECRUNCHING = 0 {
; Here we do the dest_lo -= len_lo subtraction to prepare zp_dest
; but we do it backwards: a - b == (b - a - 1) ^ ~0 (C-syntax)
; (16(16) bytes)
lda zp_len_lo
literal_start:
sbc zp_dest_lo
bcc noborrow
dec zp_dest_hi
noborrow:
eor #$ff
sta zp_dest_lo
cpy #$01 ; y < 1 then literal
!IFNDEF LITERAL_SEQUENCES_NOT_USED {
bcc pre_copy
} ELSE {
bcc literal_get_byte
}
}
; -------------------------------------------------------------------
; calulate absolute offset (zp_src)
;
ldx tabl_bi,y
jsr get_bits
adc tabl_lo,y
bcc skipcarry
inc zp_bits_hi
!IF FORWARD_DECRUNCHING {
skipcarry:
sec
eor #$ff
adc <zp_dest_lo
sta zp_src_lo
lda <zp_dest_hi
sbc zp_bits_hi
sbc tabl_hi,y
sta zp_src_hi
} ELSE {
clc
skipcarry:
adc zp_dest_lo
sta zp_src_lo
lda zp_bits_hi
adc tabl_hi,y
adc zp_dest_hi
sta zp_src_hi
}
; -------------------------------------------------------------------
; prepare for copy loop (8(6) bytes)
;
pla
tax
!IFNDEF LITERAL_SEQUENCES_NOT_USED {
sec
!IF FORWARD_DECRUNCHING = 0 {
pre_copy:
literal_start:
ldy zp_len_lo
}
jmp copy_start
} ELSE {
ldy zp_len_lo
bcc copy_start
}
; -------------------------------------------------------------------
; two small static tables (6(6) bytes)
;
tabl_bit:
!byte 2,4,4
tabl_off:
!byte 48,32,16
; -------------------------------------------------------------------
; end of decruncher
; -------------------------------------------------------------------
; -------------------------------------------------------------------
; this 156 byte table area may be relocated. It may also be clobbered
; by other data between decrunches.
; -------------------------------------------------------------------
decrunch_table=$200;;:
;; !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; !byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;; !byte 0,0,0,0,0,0,0,0,0,0,0,0
; -------------------------------------------------------------------
; end of decruncher
; -------------------------------------------------------------------

39
winmake.bat Normal file
View File

@ -0,0 +1,39 @@
0</* :
@echo off
if "%1" equ "clean" (
echo y|1>nul rd build /s
goto :EOF
)
2>nul md build
cd src\mods
acme universalrwts.a
cd ..\..\build
exomize raw -q universalrwts.bin -o universalrwts.tmp
cscript /nologo //e:jscript %~f0 "b8" "00"
1>nul copy /b tmp+universalrwts.tmp universalrwts.pak
cd ..\src\mods
acme t00only.a
cd ..\..\build
exomize raw -q t00only.bin -o t00only.tmp
cscript /nologo //e:jscript %~f0 "20" "00"
1>nul copy /b tmp+t00only.tmp t00only.pak
cd ..\src
for /f "tokens=*" %%q in ('2^>^&1 acme passport.a') do set _make=%%q
acme -DRELBASE=$%_make:~-5,4% passport.a
set _make=
cd ..
1>nul copy res\work.po build\passport.po
java -jar bin\AppleCommander.jar -p build\passport.po "PASSPORT.SYSTEM" sys 0x2000 < build\PASSPORT.SYSTEM
goto :EOF
*/
new ActiveXObject("scripting.filesystemobject").createtextfile("tmp").write(String.fromCharCode(parseInt(WScript.arguments(0),16),String.fromCharCode(parseInt(WScript.arguments(1),16))))
/*
bat/jscript hybrid make script for Windows environments
a qkumba monstrosity from 2017-10-16
requires ACME, Exomizer, Apple Commander, Java
https://sourceforge.net/projects/acme-crossass/
https://sourceforge.net/projects/applecommander/
https://bitbucket.org/magli143/exomizer/wiki/Home
https://java.com/en/download/
requires ACME, Exomizer, Java to be in path
*/