CPCWiki forum

General Category => Programming => Topic started by: Shining on 05:36, 14 June 16

Title: Question on save-file using firmware in ASM
Post by: Shining on 05:36, 14 June 16
Currently I'm saving files using the firmware-routines cas_out_open, cas_out_direct and cas_out_close to disk.
The files, I'm saving, are for a highscore table so the same file is saved from time to time. I've marked the file as a system-file in the catalogue, so that it is not visible when typing cat.


But now, when I overwrite the file using the above functions, the new file is visible and the system makes a .bak-file out of the old-one.


Is there an easy way to:
1: Prevent the .bak-files to be created
2: Save a file as system file (or is there another firmware-routine to set this status to an existing file)


THANKS!
Title: Re: Question on save-file using firmware in ASM
Post by: TFM on 18:09, 14 June 16
Well, I never use firmware, so I don't remember details... But it may helps if you delete the old file before you save the new one. So no BAK file will be there. Also you can save to another user number, so people will not see the file (immediately).


Title: Re: Question on save-file using firmware in ASM
Post by: Shining on 19:06, 14 June 16
Or perhaps someone has an example to save a file without firmware ?


The only thing I use the firmware for is for saving and loading. So I have to clean up memory, enable fimrware, save or load, disable the firmware and put my stuff back...
Title: Re: Question on save-file using firmware in ASM
Post by: SOS on 19:12, 14 June 16
Quote from: Shining on 19:06, 14 June 16
Or perhaps someone has an example to save a file without firmware ?
It's a little bit dangerous, it will not run on IDE-Solutions like ACMEDOS, ImpDOS and i don't think it will be run on Albireo,...
Lost compatibility, only for a highscore-save?
You can crypt the file and put a checksum on it.
Title: Re: Question on save-file using firmware in ASM
Post by: arnoldemu on 07:11, 15 June 16
@Shining (http://www.cpcwiki.eu/forum/index.php?action=profile;u=922): Does this code work?


ld b,end_filename-filename
ld hl,filename
ld de,&c000
call cas_out_open
ld hl,buffer
ld bc,length
ld a,2
call cas_out_direct
call cas_out_close
ret

;; FILE.BIN but with bit 7 set on extension bytes
filename:
defb "FILE."
defb 'B'+&80
defb 'I'+&80
defb 'N'
end_filename:

It sets bit 7 of the extension. This may solve saving the file with system and hidden.
Title: Re: Question on save-file using firmware in ASM
Post by: SOS on 07:37, 15 June 16
In ACMEDOS you will get a "bad filename".
Title: Re: Question on save-file using firmware in ASM
Post by: Shining on 14:50, 15 June 16
I was aware that in the catalog entry, the highest bit of the second letter marks the file as hidden/system so your idea was good. Unfortunately it did not work. Interesting was that AMSDOS accepted the patched filename and ignored the highest bit.
Title: Re: Question on save-file using firmware in ASM
Post by: TFM on 17:03, 15 June 16
In this case @SyX (http://www.cpcwiki.eu/forum/index.php?action=profile;u=324) could update ACMEDOS to accept the 8. bit set to 1 too. Make it more compatible.  :)
Title: Re: Question on save-file using firmware in ASM
Post by: Shining on 11:04, 16 June 16
I've now changed my approach and put the relevant files to a different user-number. Will be much easier and I finally want to finish the game...
Powered by SMFPacks Menu Editor Mod