| |
Bacchus
Registered: Jan 2002 Posts: 155 |
Drive code: Detect missing disk...
I have detecting missing *device* covered. This logics work really well:https://codebase64.org/doku.php?id=base:reading_the_error_chann..
Also, checking if a file exists, one would expect that a plain Open would do the job, but you basically need to read the first byte and checking the Status. But then you have established that.
But what is the easiest way to detect if the device contains a disk? Let's say we have established that there is a disk in the drive. I can start reading a file, but then I don't know if the error will tell me if the file or the entire disk is missing.
Should I do a block read, start reading the directory or what is the general suggestion?
/Bacchus |
|
... 14 posts hidden. Click here to view all posts.... |
| |
Bacchus
Registered: Jan 2002 Posts: 155 |
Quote: If you rely on the kernal calls, then using a directory routine and to read a valid byte and check $90 might do the trick.
So basically a getbyte from the filename "$", and one could tell already from the first byte if there was a byte or not?
I do know how to drivecode, but I want to select the route of the least resistance here.
/Bacchus |
| |
Comos
Registered: May 2004 Posts: 73 |
Quote: So basically a getbyte from the filename "$", and one could tell already from the first byte if there was a byte or not?
I do know how to drivecode, but I want to select the route of the least resistance here.
/Bacchus
Read just one byte and check bit 1 of $90, 1 = Timeout on read, which in simple would mean there is no disk inserted since we are accessing the lower level - the directory.
If you do this check on a file, then you won't be able to determinate, if the file is simply not present or there is no disk inserted,since in both cases you'll get the same bit set.
Ofcourse this method is not perfect for some detailed error handling.
If you would like to go the way to read out the error channel, then you have to do something in advance like running the init "I" command and then read out the error channel. |
| |
Count Zero
Registered: Jan 2003 Posts: 1878 |
Quoting BacchusSo basically a getbyte from the filename "$", and one could tell already from the first byte if there was a byte or not?
A drive such as a SD2IEC could easily fool for an inserted disc in such a case - so it likely depends on the used loader/saver compatibility in the end unless you determine the drivetype as well or stick to plain kernal routines. hm? |
| |
Krill
Registered: Apr 2002 Posts: 2940 |
The clean way is still to read the error channel.
Why is this not an option? :) |
| |
Mason
Registered: Dec 2001 Posts: 461 |
Sorry for my vague memory, but it's many years ago I did it
I reckon you can load a byte from a file or the directory. If it doesn't work I reckon $90 is set as a status |
| |
chatGPZ
Registered: Dec 2001 Posts: 11290 |
Quote:Why is this not an option?
head bump? |
| |
Krill
Registered: Apr 2002 Posts: 2940 |
Quoting GroepazQuote:Why is this not an option? head bump? If head bump is to be avoided, actual drive code is required*. =) (And then you'll run into problems on exotic drives.)
* Turn on motor, wait for sync, stop on timeout. |
| |
Bacchus
Registered: Jan 2002 Posts: 155 |
Quote: Read just one byte and check bit 1 of $90, 1 = Timeout on read, which in simple would mean there is no disk inserted since we are accessing the lower level - the directory.
If you do this check on a file, then you won't be able to determinate, if the file is simply not present or there is no disk inserted,since in both cases you'll get the same bit set.
Ofcourse this method is not perfect for some detailed error handling.
If you would like to go the way to read out the error channel, then you have to do something in advance like running the init "I" command and then read out the error channel.
This is a Kernal only scenario. Would love to see it work on any drive. Codebase has a routine for device detection that it claim is less portable, which I guess means that it risk not working on alternative Kernals, but I would like to assume it works on exotic drives. ($BA is assumed to be right when calling this)
My conclusion here is basically;
jsr TestDevice // Should detect Device not found
bcc !+
jmp DeviceNotPresent // Device not present
!: jsr TestDisk // Should detect Disk not present
bcc !+
jmp DiskNotPresent // Disk not present
!: jsr TestFiles // Load the filenames - Handle file not found
The routines that are used would be:
TestDevice:
lda #$00
sta $02a1
sta $90 // clear status flags
lda $ba // device number
jsr $ffb1 // call listen
lda #$6f // secondary address 15 (command channel)
jsr $ff93 // call seclsn (second)
jsr $ffae // call unlsn
lda $90 // get status flags
bne NotPresent // device not present
clc
rts
NotPresent: sec
rts
TestDisk: lda #1
ldx #<DirName
ldy #>DirName
jsr setnam
lda #$02
ldx $ba // last used device number
// bne !+
// ldx #$08 // default to device 8
!: ldy #$02 // $01 means: load to address stored in file
jsr setlfs // call SETLFS - OK with no vectors
jsr open
ldx #$02
jmp chkin
jsr chrin // Get a byte
jsr readst
jsr DoClose
bne Error
clc // Directory - first byte - loaded fine
rts
Error: sec // DIrectory - first byte - didn't load properly
rts
DoClose: pha
lda #$02
jsr close
jsr clrchn
pla
rts
.encoding "screencode_mixed"
DirName: .text "$"
.encoding "screencode_mixed"
=> Any errors found in that?
=> Should I call to init the drive at any point? If so, would that be the command "U:", "UJ", "U9" or a "plain" "I"?
/Bacchus |
| |
Bacchus
Registered: Jan 2002 Posts: 155 |
@krill Ok, gotch - this is not "drive code" - it's computer code, accessing the drive. I know how to push stuff to the drive end execute it and this is not that.
This is Pure computer, pure kernal and working with data on the drive, ensuring I capture ALL and ANY relevant error scenario, and also make it work across as many drives as possibly.
I know the stuff that you make in relations to drives. This is not making the fastest sport car. This is making the Volvo totally solid. ;-)
/Bacchus |
| |
Bacchus
Registered: Jan 2002 Posts: 155 |
Bugger - there was a jmp chkin that should be a jsr. Sorry about that...
/Bacchus |
Previous - 1 | 2 | 3 - Next |