Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > how to delete a file with rom routines?
2006-07-19 19:08
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?
2006-07-19 19:24
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.
2006-07-19 20:44
Graham
Account closed

Registered: Dec 2002
Posts: 990
A bit of error handling would be nice, else you might get wicked crashes.
2006-07-19 21:06
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.
2006-07-19 21:43
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.
2006-07-19 22:27
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.
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Guests online: 166
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 X-Mas Demo 2024  (9.5)
7 Dawnfall V1.1  (9.5)
8 Rainbow Connection  (9.5)
9 Onscreen 5k  (9.5)
10 Morph  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Organizers
1 Burglar  (9.9)
2 Sixx  (9.8)
3 hedning  (9.7)
4 Irata  (9.7)
5 Tim  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.033 sec.