| |
Trifox Account closed
Registered: Mar 2006 Posts: 108 |
how to delete a file with rom routines?
hi all, how to delete a file with rom routines? |
|
| |
TNT Account closed
Registered: Oct 2004 Posts: 189 |
lda #15
ldx $ba
tay
jsr $ffba
lda #CMDLEN
ldx #<CMD
ldy #>CMD
jsr $ffbd
jsr $ffc0
lda #15
jsr $ffc3
...
CMD dc.b "S0:"
FNAME dc.b "filename"
CMDLEN = *-CMD
That should be close what you want, assuming that device you are using is somewhat compatible with 1541. |
| |
Graham Account closed
Registered: Dec 2002 Posts: 990 |
A bit of error handling would be nice, else you might get wicked crashes. |
| |
TNT Account closed
Registered: Oct 2004 Posts: 189 |
Only calls sending anything to IEC (or some other) bus in above routine are OPEN ($ffc0) and CLOSE ($ffc3), and you need to close any opened files on C64 side even if open wasn't succesful at device end. I see no crash opportunity.
Adding code to read drive status after delete is easy, just
ldx #15
jsr $ffc6 ; chkin
.loop jsr $ffcf ; chrin
jsr $ffd2 ; chrout, store in memory if you wish
lda $90 ; use "jsr READST" if you wish
beq .loop
jsr $ffcc ; clrchn
after call to $ffc0.
|
| |
Graham Account closed
Registered: Dec 2002 Posts: 990 |
Not quite correct. Some of the possible errors do not OPEN anything and executing a CLOSE would be a problem then. CHKIN/CHRIN is definitely a problem with unopened file, I had lots of crashes with those. |
| |
TNT Account closed
Registered: Oct 2004 Posts: 189 |
If he's sloppy with his opened files, then yes. Only errors not affecting kernal open file table are opening logical file #0, opening already open file, or opening more than 10 files. Attempting to open file on IEC device which doesn't exist returns error, but table is already updated.
Kernal CLOSE is no-operation if file isn't opened. CHKIN/CHRIN aren't a problem unless you use them, and my original code doesn't. CHKIN itself isn't a problem, but one should check for carry after calling it to see if file was OPENed. |