mirror of
https://github.com/a2-4am/passport.git
synced 2025-01-11 16:30:22 +00:00
Merge pull request #25 from peterferrie/master
create image on RAM disk if available
This commit is contained in:
commit
28ff54ed44
@ -2,10 +2,10 @@
|
||||
; YE OLDE GRAND UNIFIED MEMORY MAP
|
||||
;
|
||||
; 02D8..038D - clobbered by Optimum reader
|
||||
; 0800..08FF - clobbered by all boot tracers
|
||||
; 0900..09FF - clobbered by Special Delivery tracer
|
||||
; 0A00..0AFF - backup of zero page during Special Delivery tracer
|
||||
; 0B00..0BFF - unused
|
||||
; 0800..08FF - clobbered by all boot tracers and RAM disk
|
||||
; 0900..09FF - clobbered by Special Delivery tracer and RAM disk
|
||||
; 0A00..0AFF - backup of zero page during Special Delivery tracer, used by RAM disk
|
||||
; 0B00..0BFF - used by RAM disk
|
||||
; 0C00..0CFF - clobbered by Special Delivery tracer
|
||||
; 0D00..0FFF - unused
|
||||
; 1000..1FFF - data buffer for current track
|
||||
@ -122,6 +122,7 @@ SaveProDOS
|
||||
ldx #$41
|
||||
ldy #$01
|
||||
jsr CopyMemory
|
||||
SaveGlobal
|
||||
lda #$BF
|
||||
ldx #$42
|
||||
ldy #$01
|
||||
|
322
src/mli.a
322
src/mli.a
@ -10,6 +10,7 @@ CMD_READ = $CA ; read an open file
|
||||
CMD_WRITE = $CB ; write to an open file
|
||||
CMD_CLOSE = $CC ; close an open file
|
||||
CMD_SETMARK = $CE ; change position in an open file
|
||||
CMD_SETEOF = $D0 ; set file size
|
||||
|
||||
; MLI parameter counts
|
||||
PC_CREATE = $07
|
||||
@ -23,9 +24,14 @@ PC_READ = $04
|
||||
PC_WRITE = $04
|
||||
PC_CLOSE = $01
|
||||
PC_SETMARK = $02
|
||||
PC_SETEOF = $02
|
||||
|
||||
PRODOSMLI = $BF00 ; [callable] MLI entry point
|
||||
|
||||
!ct "lcase.ct"
|
||||
RAMFileName !text "PASSPORTTMP.DSK"
|
||||
RAMFileName_e
|
||||
|
||||
; MLI error codes
|
||||
ERR_FNF = $46
|
||||
ERR_EOF = $4C
|
||||
@ -45,20 +51,20 @@ ERR_EOF = $4C
|
||||
!zone {
|
||||
WriteTrackMLI
|
||||
jsr SwapProDOS
|
||||
lda gUsingRAMDisk
|
||||
beq +
|
||||
jsr ReorderBuffer
|
||||
lda #$81 ; 'write block' command
|
||||
+ lda #$81 ; 'write block' command
|
||||
sta mlicmd
|
||||
lda DRIVE ; ProDOS "unit number" is
|
||||
sec
|
||||
sbc #$30
|
||||
sbc #$31
|
||||
lsr ; DSSS0000, where D is the
|
||||
asl ; drive number (0=drive 1,
|
||||
asl ; 1=drive 2) and SSS is
|
||||
asl ; the slot number (1-7).
|
||||
asl ; "Beneath Apple ProDOS"
|
||||
asl ; page 6-19
|
||||
asl
|
||||
asl
|
||||
lda #00 ; drive number (0=drive 1,
|
||||
ror ; 1=drive 2) and SSS is
|
||||
; the slot number (1-7).
|
||||
; "Beneath Apple ProDOS"
|
||||
; page 6-19
|
||||
sta mliparam+1
|
||||
lda SLOT
|
||||
sec
|
||||
@ -67,8 +73,7 @@ WriteTrackMLI
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
clc
|
||||
adc mliparam+1
|
||||
ora mliparam+1
|
||||
sta mliparam+1
|
||||
lda #$00
|
||||
sta mliparam+2 ; lo byte of data buffer
|
||||
@ -85,23 +90,31 @@ WriteTrackMLI
|
||||
lda #BASEPAGE ; hi byte of data buffer
|
||||
sta mliparam+3
|
||||
.writeloop
|
||||
lda gUsingRAMDisk
|
||||
beq +
|
||||
lda mlicmd
|
||||
ldy #$03 ; parameter count
|
||||
jsr mli
|
||||
bcs .writeerr
|
||||
inc mliparam+3 ; 2 pages per block
|
||||
- inc mliparam+3 ; 2 pages per block
|
||||
inc mliparam+3
|
||||
inc mliparam+4
|
||||
dec .blockcount
|
||||
bne .writeloop
|
||||
clc
|
||||
bcc .writedone
|
||||
|
||||
+ jsr WriteToRAMFile
|
||||
bcc -
|
||||
|
||||
.writeerr
|
||||
.writedone
|
||||
php
|
||||
pha
|
||||
lda gUsingRAMDisk
|
||||
beq +
|
||||
jsr ReorderBuffer
|
||||
jsr SwapProDOS
|
||||
+ jsr SwapProDOS
|
||||
pla
|
||||
plp
|
||||
rts
|
||||
@ -327,7 +340,6 @@ LoadFile1Shot
|
||||
; in: caller has filled @mliparam with address of
|
||||
; pathname, address of data buffer, and maximum
|
||||
; data length
|
||||
; A = file reference number
|
||||
; out: if C set, open failed and A contains error code
|
||||
; if C clear, open succeeded and A contains
|
||||
; file reference number
|
||||
@ -437,6 +449,27 @@ WriteFile
|
||||
rts
|
||||
}
|
||||
|
||||
;-------------------------------
|
||||
; set file size in an open file via ProDOS MLI
|
||||
;
|
||||
; in: A = file reference number
|
||||
; caller has filled @mliparam+2/+3/+4 with
|
||||
; new file size
|
||||
; out: if C set, set_eof call failed and A contains error code
|
||||
; if C clear, set_eof call succeeded and A contains
|
||||
; the same file reference number that was passed in
|
||||
;-------------------------------
|
||||
!zone {
|
||||
SetEOF
|
||||
sta mliparam+1 ; store file reference number
|
||||
lda #CMD_SETEOF ; MLI set_eof command
|
||||
ldy #PC_SETEOF ; number of params for 'set_eof' cmd
|
||||
jsr mli
|
||||
bcs .exit
|
||||
lda mliparam+1 ; if no error, return file refnum
|
||||
.exit rts
|
||||
}
|
||||
|
||||
;-------------------------------
|
||||
; close an open file
|
||||
; in: A = file reference number
|
||||
@ -491,6 +524,227 @@ DeleteFile
|
||||
jsr mli
|
||||
rts
|
||||
|
||||
;-------------------------------
|
||||
; CreateRAMFile - create image file on RAM disk
|
||||
; if RAM disk is in use
|
||||
; in: nothing (assumes that prefix is set to /RAM)
|
||||
; out: if C set, write failed (A contains MLI error code)
|
||||
; if C clear, write succeeded (A is clobbered)
|
||||
; all other flags clobbered
|
||||
; all registers clobbered
|
||||
;-------------------------------
|
||||
!zone {
|
||||
CreateRAMFile
|
||||
lda gUsingRAMDisk
|
||||
bne .done
|
||||
|
||||
;existing file being reused?
|
||||
|
||||
lda gRAMDiskRef
|
||||
bne .done
|
||||
|
||||
;no, create a new one
|
||||
|
||||
lda OnlineReturn
|
||||
tay
|
||||
clc
|
||||
adc #(RAMFileName_e-RAMFileName)+1
|
||||
sta RAMPath
|
||||
tax
|
||||
lda #$2F
|
||||
sta RAMPath+1,y
|
||||
- lda OnlineReturn,y
|
||||
sta RAMPath,y
|
||||
dey
|
||||
bne -
|
||||
ldy #(RAMFileName_e-RAMFileName)
|
||||
- lda RAMFileName-1,y
|
||||
sta RAMPath,x
|
||||
dex
|
||||
dey
|
||||
bne -
|
||||
jsr DeleteRAMFile
|
||||
jsr CreateFile
|
||||
bcs .createfail
|
||||
lda #0
|
||||
sta mliparam+3
|
||||
lda #8
|
||||
sta mliparam+4
|
||||
jsr OpenFile
|
||||
bcs .openfail
|
||||
|
||||
sta gRAMDiskRef
|
||||
|
||||
;140kb
|
||||
|
||||
ldx #0
|
||||
stx mliparam+2
|
||||
ldx #$30
|
||||
stx mliparam+3
|
||||
ldx #2
|
||||
stx mliparam+4
|
||||
jsr SetEOF
|
||||
|
||||
;update file buffer array
|
||||
|
||||
php
|
||||
jsr SaveGlobal
|
||||
plp
|
||||
bcc .done
|
||||
|
||||
lda gRAMDiskRef
|
||||
jsr CloseFile
|
||||
|
||||
.openfail
|
||||
pha
|
||||
jsr DeleteRAMFile
|
||||
pla
|
||||
sec
|
||||
|
||||
.createfail
|
||||
ldx #FALSE
|
||||
stx gUsingRAMDisk
|
||||
|
||||
.done
|
||||
rts
|
||||
|
||||
RAMPath !byte $d1
|
||||
!fill 17
|
||||
!fill RAMFileName_e-RAMFileName
|
||||
|
||||
}
|
||||
|
||||
;-------------------------------
|
||||
; WriteToRAMFile - write memory to image file on RAM disk
|
||||
; if RAM disk is in use
|
||||
; in: called has filled @mliparam
|
||||
; with block number and write address
|
||||
; out: if error, C set and A contains error code
|
||||
; if success, C clear
|
||||
; all other flags clobbered
|
||||
; all registers clobbered
|
||||
;-------------------------------
|
||||
!zone {
|
||||
WriteToRAMFile
|
||||
lda mliparam+2
|
||||
pha
|
||||
lda mliparam+3
|
||||
pha
|
||||
|
||||
lda mliparam+4
|
||||
sta .tmpparm4
|
||||
asl
|
||||
sta mliparam+3
|
||||
lda mliparam+5
|
||||
sta .tmpparm5
|
||||
rol
|
||||
sta mliparam+4
|
||||
lda #0
|
||||
sta mliparam+2
|
||||
lda gRAMDiskRef
|
||||
jsr SetMark
|
||||
tax
|
||||
pla
|
||||
sta mliparam+3
|
||||
pla
|
||||
sta mliparam+2
|
||||
txa
|
||||
bcs .done
|
||||
lda #0
|
||||
sta mliparam+4
|
||||
lda #2
|
||||
sta mliparam+5
|
||||
lda gRAMDiskRef
|
||||
jsr WriteFile
|
||||
|
||||
.done
|
||||
pha
|
||||
lda .tmpparm4
|
||||
sta mliparam+4
|
||||
lda .tmpparm5
|
||||
sta mliparam+5
|
||||
pla
|
||||
rts
|
||||
|
||||
.tmpparm4 !byte 0
|
||||
.tmpparm5 !byte 0
|
||||
}
|
||||
|
||||
;-------------------------------
|
||||
; WriteRAMToDisk - write image file in RAM to physical disk
|
||||
; if RAM disk is in use
|
||||
; in: nothing
|
||||
; out: if error, C set and A contains error code
|
||||
; if success, C clear
|
||||
; all other flags clobbered
|
||||
; all registers clobbered
|
||||
;-------------------------------
|
||||
!zone {
|
||||
WriteRAMToDisk
|
||||
lda #0
|
||||
sta mliparam+2
|
||||
sta mliparam+3
|
||||
sta mliparam+4
|
||||
jsr SwapProDOS
|
||||
lda gRAMDiskRef
|
||||
jsr SetMark
|
||||
jsr SwapProDOS
|
||||
|
||||
;prevent track write from calling RAM again
|
||||
|
||||
lda #FALSE
|
||||
sta gUsingRAMDisk
|
||||
|
||||
- lda #0
|
||||
sta mliparam+2
|
||||
sta mliparam+4
|
||||
lda #$10
|
||||
sta mliparam+3
|
||||
sta mliparam+5
|
||||
jsr SwapProDOS
|
||||
lda gRAMDiskRef
|
||||
jsr ReadFile
|
||||
jsr SwapProDOS
|
||||
inc gTrack
|
||||
jsr WriteTrackMLI
|
||||
lda gTrack
|
||||
cmp #$22
|
||||
bne -
|
||||
|
||||
lda #TRUE
|
||||
sta gUsingRAMDisk
|
||||
|
||||
.done
|
||||
rts
|
||||
}
|
||||
|
||||
;-------------------------------
|
||||
; (Close)DeleteRAMFile - (close and) remove image file on RAM disk
|
||||
; if RAM disk is in use
|
||||
; in: nothing
|
||||
; out: if error, C set and A contains error code
|
||||
; if success, C clear
|
||||
; all other flags clobbered
|
||||
; all registers clobbered
|
||||
;-------------------------------
|
||||
!zone {
|
||||
CloseDeleteRAMFile
|
||||
lda gRAMDiskRef
|
||||
jsr CloseFile
|
||||
lda #0
|
||||
sta gRAMDiskRef
|
||||
DeleteRAMFile
|
||||
lda #<RAMPath
|
||||
sta mliparam+1
|
||||
lda #>RAMPath
|
||||
sta mliparam+2
|
||||
jsr DeleteFile
|
||||
|
||||
.done
|
||||
rts
|
||||
}
|
||||
|
||||
|
||||
;-------------------------------
|
||||
; change current directory (set prefix)
|
||||
; using ProDOS MLI
|
||||
@ -542,6 +796,36 @@ Online
|
||||
jsr mli
|
||||
rts
|
||||
|
||||
;-------------------------------
|
||||
; query volume information
|
||||
; using ProDOS MLI
|
||||
; in: nothing (queries last fetched volume)
|
||||
; out: if error, C set and A contains error code
|
||||
; if success, C clear and MLI buffer is filled
|
||||
; (access, file type, block count, dates and times)
|
||||
;-------------------------------
|
||||
GetVolumeInfo
|
||||
lda OnlineReturn
|
||||
and #$0F
|
||||
tax
|
||||
inx
|
||||
stx OnlineReturn
|
||||
tay
|
||||
- lda OnlineReturn,y
|
||||
sta VolumeName,y
|
||||
dey
|
||||
bne -
|
||||
lda #$2F ;'/'
|
||||
sta VolumeName
|
||||
lda #<OnlineReturn
|
||||
sta mliparam+1
|
||||
lda #>OnlineReturn
|
||||
sta mliparam+2
|
||||
lda #CMD_GETFILEINFO
|
||||
ldy #PC_GETFILEINFO
|
||||
jsr mli
|
||||
rts
|
||||
|
||||
;-------------------------------
|
||||
; low-level MLI wrapper
|
||||
; in: A = MLI command code
|
||||
@ -560,8 +844,12 @@ mli sta mlicmd ; store command code
|
||||
mlicmd !byte 00 ; command number
|
||||
!word mliparam ; address of parameter table
|
||||
rts
|
||||
mliparam !byte $FE,$FE,$FE,$FE,$FE
|
||||
mliparam !byte $FE,$FE,$FE,$FE
|
||||
filetype !byte $FE ; file type (set by MLI get_file_info)
|
||||
auxtype ; auxiliary file type (2 bytes, set by MLI get_file_info)
|
||||
refnum !byte $FE ; file refnum (set by MLI open)
|
||||
mlilen !byte $FE,$FE ; file length (set by MLI read)
|
||||
!byte $FE,$FE,$FE,$FE
|
||||
; used by createfile
|
||||
blocks !byte $FE,$FE ; blocks used (set by getvolumeinfo)
|
||||
; member is also used by createfile
|
||||
!byte $FE,$FE,$FE,$FE,$FE,$FE,$FE,$FE
|
||||
; used by get_file_info
|
||||
|
@ -95,7 +95,7 @@ flag = $FF ; byte
|
||||
}
|
||||
|
||||
; Application constants (not zero addresses)
|
||||
RELBASE = $5F00 ; address to move Passport code
|
||||
RELBASE = $5D00 ; 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
|
||||
@ -209,7 +209,6 @@ ResetVector
|
||||
MainMenu
|
||||
ldx #$FF
|
||||
txs
|
||||
jsr TEXT
|
||||
jsr ClearScreen
|
||||
lda #s_header
|
||||
jsr PrintByID
|
||||
@ -248,6 +247,7 @@ MainMenu
|
||||
+
|
||||
cmp #k_crack
|
||||
bne .getkey
|
||||
jsr CreateRAMFile
|
||||
lda #%11000000
|
||||
|
||||
; note: execution falls through here
|
||||
@ -482,6 +482,13 @@ nextsector
|
||||
lda #s_passdemuf
|
||||
bne .passprint ; always branches
|
||||
.passcrack
|
||||
lda gUsingRAMDisk
|
||||
cmp #FALSE
|
||||
beq .skipram
|
||||
lda #s_writing
|
||||
jsr PrintByID
|
||||
jsr WriteRAMToDisk
|
||||
.skipram
|
||||
lda gPatchCount
|
||||
beq .passcrack0
|
||||
lda #s_passcrack
|
||||
@ -551,8 +558,12 @@ TheEnd
|
||||
CleanExit
|
||||
jsr SwapProDOS
|
||||
lda gChangedPrefs
|
||||
bne .doquit
|
||||
bne .checkRAM
|
||||
jsr SavePrefs
|
||||
.checkRAM
|
||||
lda gRAMDiskRef
|
||||
beq .doquit
|
||||
jsr CloseFile ; leave it behind in case it's wanted
|
||||
.doquit
|
||||
jsr MLI
|
||||
!byte $65
|
||||
@ -595,8 +606,11 @@ WriteTrackNA ; entry point used by Special Delivery tracer
|
||||
bpl .done ; verify mode -> no write
|
||||
lda gSaidWriting
|
||||
beq .write
|
||||
lda #s_writeram ; only print "writing to" message once
|
||||
ldx gUsingRAMDisk
|
||||
beq +
|
||||
lda #s_writing ; only print "writing to" message once
|
||||
jsr PrintByID
|
||||
+ jsr PrintByID
|
||||
lda #TRUE
|
||||
sta gSaidWriting
|
||||
.write
|
||||
@ -828,6 +842,12 @@ gOnAClearDayYouCanReadForever
|
||||
; 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"
|
||||
}
|
||||
|
@ -273,7 +273,7 @@
|
||||
;read replaced page
|
||||
|
||||
.domerge
|
||||
lda #9 ; $900-9FF
|
||||
lda #21 ; $2100-21FF
|
||||
sta gAddress+1
|
||||
ldy #<gRWTSParams
|
||||
lda #>gRWTSParams
|
||||
@ -283,7 +283,7 @@
|
||||
|
||||
ldy #$86
|
||||
- lda $300,y
|
||||
sta $900,y
|
||||
sta $2000,y
|
||||
dey
|
||||
cpy #$FF
|
||||
bne -
|
||||
@ -294,14 +294,14 @@
|
||||
lda #1
|
||||
sta gTrack
|
||||
sta gSector
|
||||
dec gAddress+1 ; and $800-8FF
|
||||
dec gAddress+1 ; and $2000-20FF
|
||||
ldy #<gRWTSParams
|
||||
lda #>gRWTSParams
|
||||
jsr $BD00
|
||||
|
||||
;write replaced block
|
||||
|
||||
lda #8 ; $800-9FF
|
||||
lda #$20 ; $2000-21FF
|
||||
sta mliparam+3 ; hi byte of data buffer
|
||||
dec mliparam+4 ; lo byte of block number
|
||||
jsr SwapProDOS
|
||||
|
67
src/slots.a
67
src/slots.a
@ -79,12 +79,6 @@ NextSlot
|
||||
|
||||
!zone {
|
||||
ScanForRAMDisk
|
||||
rts
|
||||
|
||||
lda #$00
|
||||
sta $0800
|
||||
sta $0801
|
||||
|
||||
lda #$00
|
||||
sta iunit
|
||||
- lda iunit
|
||||
@ -94,12 +88,63 @@ ScanForRAMDisk
|
||||
beq .done
|
||||
cmp #$80
|
||||
beq -
|
||||
pha
|
||||
and #$70
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
sta .driverbase+1
|
||||
lsr
|
||||
tay
|
||||
pla
|
||||
ldx DiskIIArray-1,y
|
||||
bne -
|
||||
jsr GetVolumeName
|
||||
bcs -
|
||||
lda #<VolumeName
|
||||
sta $0800
|
||||
lda #>VolumeName
|
||||
sta $0801
|
||||
lda OnlineReturn
|
||||
beq -
|
||||
jsr GetVolumeInfo
|
||||
|
||||
;watch for RAM disk type
|
||||
|
||||
lda filetype
|
||||
and #$0F
|
||||
cmp #$0F
|
||||
bne -
|
||||
|
||||
.driverbase
|
||||
ldx #$d1
|
||||
lda $BF11,x
|
||||
sta .drivercode+2
|
||||
and #$f0
|
||||
cmp #$c0
|
||||
bne +
|
||||
|
||||
;RAMFactor detection
|
||||
;looks like a SmartPort device
|
||||
|
||||
.drivercode
|
||||
lda $d100
|
||||
cmp #$c9
|
||||
bne -
|
||||
|
||||
+
|
||||
;check free space
|
||||
;need at least $118 blocks
|
||||
|
||||
sec
|
||||
lda auxtype
|
||||
sbc blocks
|
||||
tax
|
||||
lda auxtype+1
|
||||
sbc blocks+1
|
||||
cmp #1
|
||||
bcc -
|
||||
bne +
|
||||
cpx #$18
|
||||
bcc -
|
||||
+ lda #TRUE
|
||||
sta gUsingRAMDisk
|
||||
.done
|
||||
jmp $ff59
|
||||
rts
|
||||
}
|
||||
|
@ -101,7 +101,8 @@ s_laureate = $52
|
||||
s_bbf9 = $53
|
||||
s_micrograms = $54
|
||||
s_cmpbne0 = $55
|
||||
STRINGCOUNT = $56
|
||||
s_writeram = $56
|
||||
STRINGCOUNT = $57
|
||||
|
||||
!zone {
|
||||
StringTable
|
||||
@ -191,6 +192,7 @@ StringTable
|
||||
!word .bbf9
|
||||
!word .micrograms
|
||||
!word .cmpbne0
|
||||
!word .writeram
|
||||
;
|
||||
; Text can contain substitution strings, which
|
||||
; are replaced by current values at runtime. Each
|
||||
@ -479,4 +481,6 @@ StringTable
|
||||
.cmpbne0
|
||||
!text "T%t,S%0 RWTS accepts any value for the",$8D
|
||||
!text "first address epilogue nibble.",$8D,00
|
||||
.writeram
|
||||
!text "Writing to RAM disk",$8D,00
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user