convert RDOS13 to 16 sectors + support SSI protection

also re-enable RAM disk after cancel
This commit is contained in:
Peter Ferrie 2018-09-26 10:20:03 -07:00
parent 51f62dcc99
commit 2fb3c16c83
15 changed files with 316 additions and 33 deletions

View File

@ -24,7 +24,7 @@ asm:
cd src/mods && $(ACME) universalrwts.a cd src/mods && $(ACME) universalrwts.a
$(EXOMIZER) raw -q build/universalrwts.bin -o build/universalrwts.tmp $(EXOMIZER) raw -q build/universalrwts.bin -o build/universalrwts.tmp
printf "\xB8\x00" | cat - build/universalrwts.tmp > build/universalrwts.pak printf "\xB8\x00" | cat - build/universalrwts.tmp > build/universalrwts.pak
cd src/mods && $(ACME) t00only.a cd src/mods && $(ACME) -r ../../build/t00only.lst t00only.a
$(EXOMIZER) raw -q build/t00only.bin -o build/t00only.tmp $(EXOMIZER) raw -q build/t00only.bin -o build/t00only.tmp
printf "\x20\x00" | cat - build/t00only.tmp > build/t00only.pak printf "\x20\x00" | cat - build/t00only.tmp > build/t00only.pak
cd src && $(ACME) -r ../build/passport.lst passport.a 2> ../build/relbase.log cd src && $(ACME) -r ../build/passport.lst passport.a 2> ../build/relbase.log

View File

@ -54,6 +54,10 @@
; set in IDBootloader() after reading T00,S00 ; set in IDBootloader() after reading T00,S00
FIRSTFILTER FIRSTFILTER
;gIsRDOS
!byte FALSE ; 0=true, 1=false
; reset before each operation
; set in IDBootloader() after reading T00,S00
;gIsDavidson ;gIsDavidson
!byte FALSE ; 0=true, 1=false !byte FALSE ; 0=true, 1=false
; reset before each operation ; reset before each operation

View File

@ -10,6 +10,7 @@ FALSE = $01
ID_DOS33p = $00 ID_DOS33p = $00
ID_DOS32 = $01 ID_DOS32 = $01
ID_DOS32LO = $02 ID_DOS32LO = $02
ID_RDOS13 = $03
;------------------------------- ;-------------------------------
;MECC fast-load variants ;MECC fast-load variants
@ -48,6 +49,7 @@ RELBASE = $2000 ; dummy assignment for first build
; to allow calculation of proper value ; to allow calculation of proper value
} }
LOWPOINT = $4300 ; lowest available address for code LOWPOINT = $4300 ; lowest available address for code
HIGHPOINT = $B200 ; highest available address+1 for code
BASEPAGE = $10 ; Special Delivery tracer assumes BASEPAGE = $10 ; Special Delivery tracer assumes
; this is $10, so don't change it! ; this is $10, so don't change it!
@ -57,7 +59,7 @@ BASEPAGE = $10 ; Special Delivery tracer assumes
; compressed code to work ; compressed code to work
;------------------------------- ;-------------------------------
APIEND = $B600 APIEND = HIGHPOINT
gMode = APIEND-$01 ; byte gMode = APIEND-$01 ; byte
gPatchCount = gMode-$01 ; byte gPatchCount = gMode-$01 ; byte
gTriedUniv = gPatchCount-$01 ; byte gTriedUniv = gPatchCount-$01 ; byte
@ -95,9 +97,10 @@ gForceDiskVol = gPolarwareTamperCheck-$01 ; byte
gIsAdvent = gForceDiskVol-$01 ; byte gIsAdvent = gForceDiskVol-$01 ; byte
gIsPanglosDOS = gIsAdvent-$01 ; byte gIsPanglosDOS = gIsAdvent-$01 ; byte
gIsDavidson = gIsPanglosDOS-$01 ; byte gIsDavidson = gIsPanglosDOS-$01 ; byte
gIsRDOS13 = gIsDavidson-$01 ; byte
;LASTFILTER ; add new gIs* above this line ;LASTFILTER ; add new gIs* above this line
;gMECCFastloadType is a special case integer whose default value cannot be #FALSE ;gMECCFastloadType is a special case integer whose default value cannot be #FALSE
gMECCFastloadType = gIsDavidson-$01 ; byte gMECCFastloadType = gIsRDOS13-$01 ; byte
gOnAClearDayYouCanReadForever = gMECCFastloadType-$01 ; byte gOnAClearDayYouCanReadForever = gMECCFastloadType-$01 ; byte
gUsingRAMDisk = gOnAClearDayYouCanReadForever-$01 ; byte gUsingRAMDisk = gOnAClearDayYouCanReadForever-$01 ; byte
@ -164,6 +167,7 @@ ConstructStandardDelivery = jConstructStandardDelivery
!warn "gIsAdvent=",gIsAdvent !warn "gIsAdvent=",gIsAdvent
!warn "gIsPanglosDOS=",gIsPanglosDOS !warn "gIsPanglosDOS=",gIsPanglosDOS
!warn "gIsDavidson=",gIsDavidson !warn "gIsDavidson=",gIsDavidson
!warn "gIsRDOS13=",gIsRDOS13
!warn "gOnAClearDayYouCanReadForever=",gOnAClearDayYouCanReadForever !warn "gOnAClearDayYouCanReadForever=",gOnAClearDayYouCanReadForever
!warn "gUsingRAMDisk=",gUsingRAMDisk !warn "gUsingRAMDisk=",gUsingRAMDisk
!warn "gRAMDiskRef=",gRAMDiskRef !warn "gRAMDiskRef=",gRAMDiskRef

View File

@ -143,8 +143,11 @@ TraceDOS32LO
cmp #$B6 cmp #$B6
beq + beq +
cmp #$36 cmp #$36
beq +
cmp #$B2 ;RDOS
bne .fail bne .fail
+ clc
+ php
; ;
; set up RWTS entry point and other self-modified vectors ; set up RWTS entry point and other self-modified vectors
; that depend on where the RWTS is in memory ; that depend on where the RWTS is in memory
@ -177,7 +180,32 @@ TraceDOS32LO
.fail jmp FatalError .fail jmp FatalError
.RDOSPatch
lda #$B3
ldx #$00 ; check for "JMP $B974;LDY #$00"
ldy #$05 ; at RWTS entry point
jsr CompareMemory ; (i.e. $B300)
!byte $4C,$74,$B9,$A0,$00
bcs .fail
lda #TRUE
sta gIsRDOS13
lda #s_rdos13
jsr PrintByID
lda #<.RDOS13Hook
sta jCallRWTS+1
lda #>.RDOS13Hook
sta jCallRWTS+2
lda #$C9 ; override address prologue to avoid reliance on $48
sta $BC75
lda #$D4
sta $BC76
bne .patchmap
TraceDOS32d TraceDOS32d
plp
bcc .RDOSPatch
lda jCallRWTS+2 lda jCallRWTS+2
ldx #$00 ; check for "STY $48;STA $49" ldx #$00 ; check for "STY $48;STA $49"
ldy #$04 ; at RWTS entry point ldy #$04 ; at RWTS entry point
@ -205,6 +233,8 @@ TraceDOS32d
; if data prologue is not found ; if data prologue is not found
sta (modsrc),y sta (modsrc),y
.patchmap
; skip sectors $0D, $0E, and $0F on all tracks ; skip sectors $0D, $0E, and $0F on all tracks
; since this is a 13-sector disk ; since this is a 13-sector disk
@ -226,6 +256,16 @@ TraceDOS32d
dex dex
bpl .A bpl .A
; set flag for patcher
lda #TRUE
sta gIsDOS32
;retain track 00 for RDOS because we can
ldy gIsRDOS13
beq +
; skip T00,S00-S0A ; skip T00,S00-S0A
; since we're going to construct our own bootloader later ; since we're going to construct our own bootloader later
@ -234,11 +274,6 @@ TraceDOS32d
dey dey
bpl - bpl -
; set flag for patcher
lda #TRUE
sta gIsDOS32
; check for MUSE sector doubling RWTS ; check for MUSE sector doubling RWTS
lda jCallRWTS+2 lda jCallRWTS+2
ldx #$09 ldx #$09
@ -279,8 +314,34 @@ FFer
iny iny
cpy #$9A cpy #$9A
bne .G bne .G
clc - clc
rts rts
+ sec + sec
rts rts
.RDOS13Hook
ldx _sector
stx $BAF6
lda _track
sta $BAF5
bne +
cpx #$0C
beq - ;lie that T00S0C exists
;standard 13-sector prologue on T00
;because we can't decode the 16-sector version
lda #$D5
sta $BC76
lda #$B5
sta $BC8B
+ lda gAddress
sta $BAF7
lda gAddress+1
sta $BAF8
ldx #1
stx $B718 ;count of sectors (low part)
dex
stx $B719 ;count of sectors (high part)
jmp $BA00
} }

View File

@ -12,8 +12,8 @@
; 2000..35FF - clobbered by Special Delivery tracer ; 2000..35FF - clobbered by Special Delivery tracer
; 3600..3FFF - clobbered by lomem DOS 3.3 / Special Delivery tracers ; 3600..3FFF - clobbered by lomem DOS 3.3 / Special Delivery tracers
; 4000..42FF - backup of zero page, page 3, page $BF (SaveProDOS, SwapProDOS) ; 4000..42FF - backup of zero page, page 3, page $BF (SaveProDOS, SwapProDOS)
; 4300..B5FF - program code ; 4300..B1FF - program code
; B600..BFFF - clobbered by DOS 3.3 boot tracer ; B200..BFFF - clobbered by DOS boot tracer (RDOS is B200+, DOS 3.x is B600+)
;------------------------------- ;-------------------------------

View File

@ -680,14 +680,16 @@ WriteRAMToDisk
bne - bne -
jsr IncProgress jsr IncProgress
lda #TRUE
sta gUsingRAMDisk
clc clc
.exit .exit
lda #TRUE
sta gUsingRAMDisk
rts rts
.cancel .cancel
lda #TRUE
sta gUsingRAMDisk
jmp Cancel jmp Cancel
} }

View File

@ -108,6 +108,7 @@ AnalyzeT00
!source "../patchers/dos32dlm.a" !source "../patchers/dos32dlm.a"
!source "../patchers/microfun.a" !source "../patchers/microfun.a"
!source "../patchers/panglosdos.a" !source "../patchers/panglosdos.a"
!source "../patchers/rdos13.a"
;add only above this line ;add only above this line
rts rts

View File

@ -4,7 +4,7 @@
;------------------------------- ;-------------------------------
; Passport ; Passport
; a 4am hack ; a 4am hack
; (c) 2016-7 by 4am ; (c) 2016-8 by 4am
; ;
; Permission is hereby granted, free of charge, to any ; Permission is hereby granted, free of charge, to any
; person obtaining a copy of this software and associated ; person obtaining a copy of this software and associated
@ -88,7 +88,7 @@ UNIV_D3 = $B8FC
ldx #$00 ldx #$00
FM lda LastMover - 256,x FM lda LastMover - 256,x
sta $B500,x sta HIGHPOINT-$100,x
inx inx
bne FM bne FM
dec FM+2 dec FM+2
@ -375,6 +375,9 @@ ReadWithRWTS
.read .read
lda KEY lda KEY
bpl checksector bpl checksector
bit STROBE
cmp #$e0 ;ignore backtick (MAME debug break)
beq checksector
jmp Cancel jmp Cancel
checksector checksector
lda $FFFF ; status of current sector in sector map (modified above) lda $FFFF ; status of current sector in sector map (modified above)
@ -796,6 +799,7 @@ _applyToAll
!source "patchers/advent.a" ; gIsAdvent only !source "patchers/advent.a" ; gIsAdvent only
!source "patchers/davidsonforth.a" ; gIsDavidson only !source "patchers/davidsonforth.a" ; gIsDavidson only
!source "patchers/davidsonasm.a" ; gIsDavidson only !source "patchers/davidsonasm.a" ; gIsDavidson only
!source "patchers/ssi.a" ; gIsRDOS13 only
lda gPatchCount lda gPatchCount
beq .nopatches beq .nopatches
@ -818,10 +822,10 @@ LastMover
!ifdef PASS2 { !ifdef PASS2 {
} else { ;PASS2 } else { ;PASS2
!set PASS2=1 !set PASS2=1
!warn "RELBASE = ", $B600 - (LastMover - FirstMover) !warn "RELBASE = ", HIGHPOINT - (LastMover - FirstMover)
} }
} else { } else {
!if ($B600 - (LastMover - FirstMover)) < LOWPOINT { !if (HIGHPOINT - (LastMover - FirstMover)) < LOWPOINT {
!serious "code is too large to fit in available space!" !serious "code is too large to fit in available space!"
} }
} }

View File

@ -7,8 +7,8 @@
bpl .exit bpl .exit
lda gIsDOS32 lda gIsDOS32
bne .exit bne .exit
bit gMode ; nothing to do here in verify-only mode lda gIsRDOS13
bpl .exit beq .exit
; sector 1 ; sector 1
@ -54,21 +54,15 @@
; sector 0 ; sector 0
ldx #ID_DOS32LO
.cr lda #$d1 ; set at runtime .cr lda #$d1 ; set at runtime
cmp #$3D cmp #$3D
beq + beq +
ldx #ID_DOS32 ldx #ID_DOS32
jsr ConstructStandardDelivery + jsr ConstructStandardDelivery
jmp ++
+ ldx #ID_DOS32LO
jsr ConstructStandardDelivery
++ bit gMode ; do not print in verify mode
bpl +++
lda #s_bootwrite lda #s_bootwrite
jsr PrintByID jsr PrintByID
+++ inc gPatchCount inc gPatchCount
.exit .exit
} }

157
src/patchers/rdos13.a Normal file
View File

@ -0,0 +1,157 @@
;-------------------------------
; #RDOS13
; patch RDOS to be 16-sector compatible
;
; module by qkumba
;-------------------------------
!zone {
bit gMode ; nothing to do here in verify-only mode
bpl .jmpexit
ldy gIsRDOS13
beq .okay
.jmpexit
jmp .exit
.okay
;build 6-and-2 denibbilisation table for reading
ldx #$16
-- stx $48
txa
asl
bit $48
beq +
ora $48
eor #$ff
and #$7e
- bcs +
lsr
bne -
tya
sta (BASEPAGE * $100) + $6B9 - $16, x
;and 6-and-2 nibbilisation table for writing
txa
ora #$80
sta (BASEPAGE * $100) + $B70, y
iny
+ inx
bpl --
lda #8
ldx #$C9
ldy #3
jsr modify
!byte $20,$2A,$BB ;JSR $BB2A
;enable 16-sector address prologue
lda #$0A
ldx #$75
ldy #2
jsr modify
!byte $C9,$D5 ;CMP #$D5
lda #$0A
ldx #$8B
ldy #1
jsr modify
!byte $96
;replace 6-and-2 encoder routine
;and introduce DOS-order lookup
lda #9
ldx #0
ldy #$41
jsr modify
!byte $A2,$00 ;LDX #$00
!byte $A0,$02 ;LDY #$00
!byte $88 ;DEY
!byte $B1,$3E ;LDA ($3E),Y
!byte $4A ;LSR
!byte $3E,$00,$BF ;ROL $BF00,X
!byte $4A ;LSR
!byte $3E,$00,$BF ;ROL $BF00,X
!byte $99,$00,$BE ;STA $BE00,Y
!byte $E8 ;INX
!byte $E0,$56 ;CPX #$56
!byte $90,$ED ;BCC $BC04
!byte $A2,$00 ;LDX #$00
!byte $98 ;TYA
!byte $D0,$E8 ;BNE $BC04
!byte $A2,$55 ;LDX #$55
!byte $BD,$00,$BF ;LDA $BF00,X
!byte $29,$3F ;AND #$3F
!byte $9D,$00,$BF ;STA $BF00,X
!byte $CA ;DEX
!byte $10,$F5 ;BPL $BC1E
!byte $60 ;RTS
!byte $AC,$F6,$BA ;LDY $BAF6
!byte $B9,$31,$BB ;LDA $BB31,Y
!byte $60 ;RTS
!byte $00,$0D,$0B,$09,$07,$05,$03,$01
!byte $0E,$0C,$0A,$08,$06,$04,$02,$0F
lda #$9
ldx #$89
ldy #3
jsr modify
!byte $04 ;sync delay
!byte $48 ;PHA
!byte $68 ;PLA
;replace 6-and-2 decoder routine
lda #$0A
ldx #$16
ldy #1
jsr modify
!byte $56
lda #$0A
ldx #$2B
ldy #2
jsr modify
!byte $23,$B8
lda #$0A
ldx #$3C
ldy #2
jsr modify
!byte $23,$B8
lda #$0A
ldx #$4C
ldy #2
jsr modify
!byte $23,$B8
lda #$0A
ldx #$C1
ldy #$18
jsr modify
!byte $A0,$00 ;LDY #$00
!byte $A2,$56 ;LDX #$56
!byte $CA ;DEX
!byte $30,$FB ;BMI $BCC3
!byte $B9,$00,$BE ;LDA $BE00,Y
!byte $5E,$00,$BF ;LSR $BF00,X
!byte $2A ;ROL
!byte $5E,$00,$BF ;LSR $BF00,X
!byte $2A ;ROL
!byte $91,$3E ;STA ($3E),Y
!byte $C8 ;INY
!byte $D0,$ED ;BNE $BCC5
!byte $60 ;RTS
ldx #ID_RDOS13
jsr ConstructStandardDelivery
lda #s_bootwrite
jsr PrintByID
.exit
}

33
src/patchers/ssi.a Normal file
View File

@ -0,0 +1,33 @@
;-------------------------------
; #SSI Weak-bit protection
;
; module by qkumba
;-------------------------------
!zone {
bit gMode ; nothing to do here in verify-only mode
bpl .exit
ldy gIsRDOS13
bne .exit
ldy #$0D
jsr SearchTrack
!byte $F0,$17 ; BEQ *+$19
!byte $20,$65,$BC; JSR $BC65
!byte $B0,$F7 ; BCS *-7
!byte $C1,$00 ; CMP ($00,X)
!byte $C1,$00 ; CMP ($00,X)
!byte $EA ; NOP
!byte $EA ; NOP
bcs .exit
sta gDisplayBytes
pha
lda #s_ssi
jsr PrintByID
pla
ldy #$01
jsr modify
!byte $D0 ; BNE
.exit
}

View File

@ -17,6 +17,8 @@ ConstructStandardDelivery
beq .construct32 beq .construct32
dex dex
beq .construct32lo beq .construct32lo
dex
beq .constructrdos
.construct33p .construct33p
lda #<SD_DOS33p lda #<SD_DOS33p
@ -31,6 +33,11 @@ ConstructStandardDelivery
.construct32lo .construct32lo
lda #<SD_DOS32LO lda #<SD_DOS32LO
ldx #>SD_DOS32LO ldx #>SD_DOS32LO
bne +
.constructrdos
lda #<SD_RDOS13
ldx #>SD_RDOS13
+ sta .A+1 + sta .A+1
stx .A+2 stx .A+2
@ -136,3 +143,11 @@ SD_DOS32LO
; track 2 ; track 2
!byte $2A,$00,$00,$00,$35,$34,$33,$32,$31,$30,$2F,$2E,$2D,$2C,$2B,$00 !byte $2A,$00,$00,$00,$35,$34,$33,$32,$31,$30,$2F,$2E,$2D,$2C,$2B,$00
!byte $C0 !byte $C0
SD_RDOS13
; exit via JMP $B300
!byte $00,$B3
; track 0
!byte $00,$00,$00,$BD,$BC,$BB,$BA,$B9,$B8,$B7,$B6,$B5,$B4,$B3
!byte $C0

View File

@ -119,6 +119,8 @@ StringTable
!word .advent !word .advent
!word .gathering !word .gathering
!word .davidson !word .davidson
!word .rdos13
!word .ssi
; ;
; Text can contain substitution strings, which ; Text can contain substitution strings, which
; are replaced by current values at runtime. Each ; are replaced by current values at runtime. Each
@ -144,7 +146,7 @@ StringTable
; can be set directly before calling PrintByID. ; can be set directly before calling PrintByID.
; ;
.header .header
!text "Passport by 4am 2018-09-25",$00 !text "Passport by 4am 2018-09-26",$00
.mainmenu .mainmenu
!text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D !text "________________________________________",$8D,$8D,$8D,$8D,$8D,$8D,$8D
!text " " !text " "
@ -422,7 +424,7 @@ StringTable
.rwtswrite .rwtswrite
!text "T00,S02 Writing built-in RWTS",$8D,$00 !text "T00,S02 Writing built-in RWTS",$8D,$00
.rdos .rdos
!text "T00,S00 Found RDOS bootloader",$8D,$00 !text "T00,S00 Found RDOS 16-sector bootloader",$8D,$00
.sra .sra
!text "T%t,S%0 Found SRA protection check",$8D,$00 !text "T%t,S%0 Found SRA protection check",$8D,$00
.muse .muse
@ -446,4 +448,8 @@ StringTable
!text "Gathering per-file encryption keys",$8D,$00 !text "Gathering per-file encryption keys",$8D,$00
.davidson .davidson
!text "T%t Found Davidson & Associates disk",$8D,$00 !text "T%t Found Davidson & Associates disk",$8D,$00
.rdos13
!text "T00,S00 Found RDOS 13-sector bootloader",$8D,$00
.ssi
!text "T%t,S%0 Found SSI protection check",$8D,$00
} }

View File

@ -106,4 +106,6 @@ s_microfun = $64
s_advent = $65 s_advent = $65
s_gathering = $66 s_gathering = $66
s_davidson = $67 s_davidson = $67
STRINGCOUNT = $68 s_rdos13 = $68
s_ssi = $69
STRINGCOUNT = $6A

View File

@ -15,7 +15,7 @@ cd ..\..\build
cscript /nologo //e:jscript %~f0 "b8" "00" cscript /nologo //e:jscript %~f0 "b8" "00"
1>nul copy /b tmp+universalrwts.tmp universalrwts.pak 1>nul copy /b tmp+universalrwts.tmp universalrwts.pak
cd ..\src\mods cd ..\src\mods
%ACME% t00only.a %ACME% -r ..\..\build\t00only.lst t00only.a
cd ..\..\build cd ..\..\build
%EXOMIZER% raw -q t00only.bin -o t00only.tmp %EXOMIZER% raw -q t00only.bin -o t00only.tmp
cscript /nologo //e:jscript %~f0 "20" "00" cscript /nologo //e:jscript %~f0 "20" "00"