Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user Gabezcommodore ! (Registered 2025-07-24) You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > The good old 1541 save @:bug - question
2025-01-27 21:32
aeeben

Registered: May 2002
Posts: 46
The good old 1541 save @:bug - question

Finally googled the 1541 replace-save bug - so all the three conditions listed here must be met to make it corrupt data:
https://www.c64-wiki.com/wiki/REPLACE

-> If I'm saving a game state or program settings or something, and it's only 1 or 2 blocks, it should be always safe to use KERNAL save with @:filename, because condition #2 ("One or more blocks must get marked as occupied on at least three tracks") is never met?

Please correct if wrong. Please confirm if right :)

@-save slowly rot my programming disks as a kid, so I learned to never use it!
2025-01-27 21:34
chatGPZ

Registered: Dec 2001
Posts: 11540
This has been discussed to death - and as usual the wiki page isn't the end of the story.

Just don't use it. Ever.

(your example is missing another bad case: when there are less blocks free than you are 'overwriting' -> boom)
2025-01-27 21:47
TheRyk

Registered: Mar 2009
Posts: 2503
Quoting chatGPZ
...
Just don't use it. Ever.
...

Yeah, i.e. if chatGPZ meant save"@:..." not c64-wiki ;)
2025-01-27 21:48
chatGPZ

Registered: Dec 2001
Posts: 11540
of course :D
2025-01-27 21:52
TheRyk

Registered: Mar 2009
Posts: 2503
Quoting 'TS'
so I learned to never use it!


And I wouldn't rely on ALL of the 3 conditions having to be fulfilled for making error happen...

Apart from direct mode and BASIC, where it's of course easier/shorter than doing it properly with all the OPEN-CLOSE-hankypanky, I don't see any advantage leading to recommending anyone risking SAVE"@..." at all
2025-01-27 21:58
chatGPZ

Registered: Dec 2001
Posts: 11540
save/scratch/rename is the way to go indeed. there is no reason to try to work around that bug - there has to be enough blocks free for this in either case.
2025-01-27 22:32
Fungus

Registered: Sep 2002
Posts: 756
I traced it out once, and what happened was the 1541 allocates the block in the bam, then when it goes to update the directory, it re-reads the bam into the same buffer and the bam is then corrupted.
2025-01-27 22:38
chatGPZ

Registered: Dec 2001
Posts: 11540
That is _one_ of the many problems that exist in various DOS versions :) (The wiki page tries to explain some of the others, but is written in a very confusing and slightly misinforming way imho)
2025-01-28 11:17
Frantic

Registered: Mar 2003
Posts: 1661
Is a simple and relatively up-to-date (drive-code-wise) library available somewhere, with fastload/fastsave/fastsave-overwrite/read-dir functionality for use in tools ?
2025-01-28 14:04
chatGPZ

Registered: Dec 2001
Posts: 11540
Krills can only overwrite iirc (creating files is a bit complex...)
2025-01-28 14:31
Frantic

Registered: Mar 2003
Posts: 1661
I will pay 5 SEK to the person who creates such a library, and 5 SEK more if the code is fairly independent of super specific features of some particular assembler.
 
... 1 post hidden. Click here to view all posts....
 
Previous - 1 | 2 - Next
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
iAN CooG/HVSC
GuyGavin/HF
Copyfault/Extend^tsn..
zscs
Edhellon/Resource
oziphantom
hedning/G★P
Guests online: 55
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Codeboys & Endians  (9.7)
4 Mojo  (9.7)
5 Coma Light 13  (9.6)
6 Harminc  (9.6)
7 Edge of Disgrace  (9.6)
8 Comaland 100%  (9.6)
9 Wonderland XIV  (9.6)
10 Signal Carnival  (9.6)
Top onefile Demos
1 Morphing Starball  (9.9)
2 Nine  (9.8)
3 Layers  (9.6)
4 Cubic Dream  (9.6)
5 Party Elk 2  (9.6)
6 Copper Booze  (9.5)
7 Scan and Spin  (9.5)
8 Onscreen 5k  (9.5)
9 Grey  (9.5)
10 Dawnfall V1.1  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Censor Design  (9.3)
4 Oxyron  (9.3)
5 Artline Designs  (9.3)
Top Coders
1 Axis  (9.8)
2 Sailor  (9.8)
3 BitBuster  (9.8)
4 Lft  (9.8)
5 Graham  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2025
Page generated in: 0.091 sec.