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 > Formatting a disk from Basic
2005-12-15 11:36
Cruzer

Registered: Dec 2001
Posts: 1048
Formatting a disk from Basic

Anyone knows how to format a disk in basic, without using any cartridge-specific commands? IIRC it's something with "open".
2005-12-15 11:44
Zyron

Registered: Jan 2002
Posts: 2381
open15,8,15
print#15,"n:name"
close15

or something like that
2005-12-15 11:44
JackAsser

Registered: Jun 2002
Posts: 2014
OPEN 1,8,15,"N:DISKNAME,ID":CLOSE 1

(IIRC)
2005-12-15 11:49
Zyron

Registered: Jan 2002
Posts: 2381
What I suggested only makes a fast format since I forgot ,id
Anyway, the way JackAsser suggested seems better.
2005-12-15 11:56
Cruzer

Registered: Dec 2001
Posts: 1048
That's like the quickest answer ever! Thanks!
2005-12-15 12:19
Clarence

Registered: Mar 2004
Posts: 121
I'am suspecting some killer CML-Sports stuff coming up soon...? ;)
2005-12-15 13:08
Graham
Account closed

Registered: Dec 2002
Posts: 990
No chance, he just formatted the disk.
2005-12-15 13:56
Scout

Registered: Dec 2002
Posts: 1570
Quote: No chance, he just formatted the disk.

:D
2005-12-15 23:11
Wanderer
Account closed

Registered: Apr 2003
Posts: 478
Quote: :D

As mentioned, without the ",id" it will only erase the contents of the directory (track 18). The other tracks will not be formatted.

I've had many bad experiences with the emulator lately, with files corrupting. I religiously do a validation after saving code over and over and I also avoid "save and replace" (eg. save "@0:blah,8"). I've always been told save and replace could cause corruption and you know what, it does!! Despite making backups of source code for my last two demos, the original source files were garbled.

open1,8,15,"v0":close1 will validate a disk
open1,8,15,"i0":close 1 will initialize a disk

The zero is optional and dates back from the time where drives were numbered 0 and 1 (like PET drives)

2005-12-15 23:13
Zyron

Registered: Jan 2002
Posts: 2381
I've always used save "@:name" & never had any problems with it.
2005-12-16 02:30
Nafcom

Registered: Apr 2002
Posts: 588
Quote: I've always used save "@:name" & never had any problems with it.

But I experience the same as Wanderer, but only very rarely.
2005-12-16 02:55
Oswald

Registered: Apr 2002
Posts: 5094
wanderer,

replacing files with original 1541 dos is bugges, I've experienced it on the real thing. if you really have to attach an AR, and that will do it fine.


Vice.. I've noticed that it doesnt handles files correctly when a new file is created on the attached .d64 ( PRG* it doesnt close the file until you deattch the d64). That was a year or more ago, not sure if this bug still exists, but when making a new file within vice I always deattach and reattach the d64 to make sure.
2005-12-16 06:03
JackAsser

Registered: Jun 2002
Posts: 2014
@Wanderer: "I've had many bad experiences with the emulator lately". Hmmm... so you're basically saying that you're coding on the real thing, but on an emulator, that is, u're not cross-compiling. Ever considered simply use Save Snapshot in the VICE menu instead of fiddeling with disks etc?
I atleast always do that when I want to save f.e. a BASIC program or whatever. It's not until I wish to transfer the code to the real thing or distribute it as a .d64/.prg I actually save to disk.
2005-12-16 06:24
Wanderer
Account closed

Registered: Apr 2003
Posts: 478
I use CCGS, which I've become accustomed to. It's a mess really.

I save my data files in the monitor but they can't be loaded from a .d64 file, only from the monitor (where they are stored in the CCGS root directory).

Then I have to import the data files using the D64 editor, link them, and I have the final product.

However with CCGS (which has an option to allow instant write on the D64 file so as not to keep it open) it still corrupts.

I have tried the snapshot option, and it works great... but I am somewhat convinced that it also snapshots the D64 file. I'm not 100% certain but I can recall a time where I loaded my snapshot and went to the disk directory to find an outdated file instead of the newer one.

I'd love it if I could save data files direct to D64 file so I could link them. I tried Vice once or twice and it works good but I'm not sure I can save direct to the disk file?? If so I may consider switching.

In a related/unrelated note, you have to be careful with the D64 editor and the "wipe" file option. I once "wiped" a SCR-atched file that was crosslinked with a real file. This occurs when you scratch a file and it's sectors become occupied with a valid file - d64 says they are crosslinked. If you WIPE the old file (which shows as SCRATCHED) so as to avoid getting that crosslink message it will actually fill in the sectors with 0 bytes. Ouch! Thus your valid file gets erased.

2005-12-16 15:57
QuasaR

Registered: Dec 2001
Posts: 145
VICE only updates the D64-file if it's detached (IIRC there was a option to update the file after every write but I'm not sure...)
The old SAVE"@:XZY",8 mostly didn't work because the 1541-DOS first wrote the file and then scratched it afterwards, so when there were too less blocks left on the disc, the file went corrupt.
2005-12-16 20:06
Oswald

Registered: Apr 2002
Posts: 5094
with save"@:xxx" I had a problem when the new file was overwritten on an older existing one. So when loading "somefilealreadyondisksinceages" It loaded "filesavedwith@:" instead....
2005-12-17 13:53
Graham
Account closed

Registered: Dec 2002
Posts: 990
Hehe, only stupid Action Replay folks use @:, FC3 users can continue to work during file deleting :)
2005-12-17 14:10
chatGPZ

Registered: Dec 2001
Posts: 11386
and FC3 users definetly need those extra seconds i guess! :=)
2005-12-17 14:36
Graham
Account closed

Registered: Dec 2002
Posts: 990
They do? On small files the FC3 is actually faster than an AR6 due to less drive upload time and no full track access :P
2005-12-17 20:15
Oswald

Registered: Apr 2002
Posts: 5094
graham: guess what, @: is a commodore dos, and no AR only feature. hope it helped your mental health today, to call us stupid AR folks.
2005-12-17 21:34
Graham
Account closed

Registered: Dec 2002
Posts: 990
Oswald: Yes, @ is a DOS command but you know what it does? It first saves the file to disk and then deletes the old file.
2005-12-18 03:00
Wanderer
Account closed

Registered: Apr 2003
Posts: 478
Quote: Oswald: Yes, @ is a DOS command but you know what it does? It first saves the file to disk and then deletes the old file.

The @ command is a DOS command which Commodore implemented with the evil intent to corrupt source code files, thus causing agony and frustration for programmers worldwide. How many times have I lost code due to the Save and Replace operation? Too many.

2005-12-18 09:16
hollowman

Registered: Dec 2001
Posts: 474
Quote: The @ command is a DOS command which Commodore implemented with the evil intent to corrupt source code files, thus causing agony and frustration for programmers worldwide. How many times have I lost code due to the Save and Replace operation? Too many.



i stopped using it after losing sourcecode for the first time =)
2005-12-18 14:28
Graham
Account closed

Registered: Dec 2002
Posts: 990
Ofcourse some people like some risk in their lives, and the @ command is very good for that.
2005-12-18 16:59
MagerValp

Registered: Dec 2001
Posts: 1078
Yeah, I have an old source disk that's been nuked by @:... If you do, it's actually possible to recover all the files, since only the directory is corrupt. By following all the sector links with a recursive algorithm you can reconstruct file chains. My d64 library is probably a good starting place if you feel like writing a recovery utility:

http://www.paradroid.net/diskimage/
2005-12-18 17:11
Cruzer

Registered: Dec 2001
Posts: 1048
damn, just formatted the wrong disk by mistake. guess it's back to square one :)
2005-12-18 17:24
iopop

Registered: Dec 2001
Posts: 317
Quote: Yeah, I have an old source disk that's been nuked by @:... If you do, it's actually possible to recover all the files, since only the directory is corrupt. By following all the sector links with a recursive algorithm you can reconstruct file chains. My d64 library is probably a good starting place if you feel like writing a recovery utility:

http://www.paradroid.net/diskimage/


Broken disks is shit. For some reason, which I cant remember right now, I had to code such a tool at lcp this year..
2005-12-19 08:19
Wanderer
Account closed

Registered: Apr 2003
Posts: 478
Quote: Broken disks is shit. For some reason, which I cant remember right now, I had to code such a tool at lcp this year..

I know that the track/sectors follow a pattern (eg. 2/14 2/4, 2/13. 2/3). I've been able to resurrect a few programs with a sector editor.

It goes without saying that if you do lose a file due to scratching it, you can put a value of 130 in the directory to restore it. Everyone must know this already :) I remember being given disks (as a youth) with games and the first thing I'd do was check it for deleting files. I was able to restore a few games this way.

Back on topic though, save and replace sucks. If not for that, I'd still have my missing level for my Jailbreak game. *sigh*

I lost a few vital things that way...
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
Didi/Laxity
goerp/F4CG/HF
MCM/ONSLAUGHT
lA-sTYLe/Quantum
Guests online: 120
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 The Demo Coder  (9.6)
6 Edge of Disgrace  (9.6)
7 What Is The Matrix 2  (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 Coders
1 Axis  (9.8)
2 Graham  (9.8)
3 Lft  (9.8)
4 Crossbow  (9.8)
5 HCL  (9.8)

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