SlashRAM !raw "/RAM" SlashRAM_e RAMFileName !raw "PASSPORTTMP.DSK" RAMFileName_e ;------------------------------- ; ScanForRAMAndHardDisks ; scan all slots for things that look like RAM disks or hard drives ; ; in: X=0 ; out: HardDriveArray populated ; RAMDiskImagePath possibly populated (if a suitable RAM disk was found) ; all registers and flags clobbered ;------------------------------- ScanForRAMAndHardDisks stx iunit @nextunit lda iunit clc adc #$10 sta iunit bne + rts + cmp #$80 beq @nextunit pha and #$70 lsr lsr lsr lsr tay pla ldx DiskIIArray-1, y bne @nextunit ; ScanForDiskII already detected that this slot is a floppy drive, so skip it jsr GetVolumeName bcs @nextunit ; can't get a volume name, so skip it lda OnlineReturn and #$0F beq @nextunit ; volume name length=0 means an error occurred, so skip it jsr GetVolumeInfo lda filetype and #$0F cmp #$0F bne @nextunit ; ProDOS volume type says this isn't a directory, so skip it lda access and #$02 beq @nextunit ; volume is not writeable, so skip it ; check free space on volume (need at least $118 blocks) lda auxtype sec sbc blocks tax lda auxtype+1 sbc blocks+1 cmp #1 bcc @nextunit ; not enough free space, so skip it bne + cpx #$18 bcc @nextunit ; not enough free space, so skip it + ; check if this volume is a RAM disk ; if so, we will use it as temporary storage when writing to a disk in a disk drive ; (writing to a file on the RAM disk, then writing that to the target disk all at once) jsr .IsRAMDisk bne @foundHardDrive lda RAMDiskImagePath bne @nextunit ; we already found a suitable RAM disk, so skip this one ; now that we've found the first suitable RAM disk, construct ; the full path of the RAM disk image file and store it in ; RAMDiskImagePath jsr .ConstructRAMDiskImagePath beq @nextunit ; always branches @foundHardDrive lda iunit pha lsr lsr lsr lsr tay pla sta HardDiskArray-1, y bne @nextunit ; always branches .IsRAMDisk ; in: @OnlineReturn+@VolumeName contains length+name of a ProDOS volume ; out: Z=1 if volume is a suitable RAM disk ; Z=0 otherwise ; all other registers and flags clobbered lda OnlineReturn and #$0F cmp #4 beq + cmp #5 bne @exit ; volume name isn't the right length for a supported RAM disk + ; due to limitations of the ProDOS API, we settle for checking if the volume name = ; 'RAM' or 'RAMn' where n is a slot number, which covers the common cases ('RAM3' for ; third-party memory cards, 'RAM5' on a IIgs) ldy #(SlashRAM_e-SlashRAM) - lda SlashRAM-1, y cmp VolumeName-1, y bne @exit ; volume name does not match 'RAM' or 'RAMn' pattern dey bne - @exit rts .ConstructRAMDiskImagePath ; in: @OnlineReturn+@VolumeName contains length+name of RAM disk ; out: Z=1 ; Y=0 ; all other registers and flags clobbered lda OnlineReturn and #$0F tay clc adc #(RAMFileName_e-RAMFileName)+1 sta RAMDiskImagePath tax lda #$2F sta RAMDiskImagePath+1, y - lda OnlineReturn, y sta RAMDiskImagePath, y dey bne - ldy #(RAMFileName_e-RAMFileName) - lda RAMFileName-1, y sta RAMDiskImagePath, x dex dey bne - rts