Jump to content
Sign in to follow this  
mariuszw

Saving / reading files from assembler program (game)

Recommended Posts

Hi,

 

Total Eclipse port I am working now has a functionality to save and then load game state in C64 version. User is asked for file name and device, so it is actually possible to have several save states and also save them on both disk and cassette.

 

I am looking for information about how to implement similar functionality on Atari 8bit. I don't plan to make cassette support, but I would like to have disk support (I believe it will work on all SIO2* devices).

 

Please note that game uses all RAM and disables OS. So I guess some workaround will be needed to enable OS for the time of saving and loading data and disable it again after data is saved/loaded. I also guess that some state of computer (zero page contents?) would have to be preserved for that to work.

 

Thanks in advance for all information. Code samples will be really appreciated :)

 

Mariusz.

Share this post


Link to post
Share on other sites

Using Dos compatible disks is likely out of the question then.

 

The alternative as used by many games is just use a formatted disk and have numerous slots for save points. As a safety measure have a sector that contains some "magic numbers" so you can verify it's a proper save disk before writing to it.

 

To do so you'll need to be using the built in SIO routines of the OS. As such you need the DCB area low in Page 3, you need various SIO/IRQ related work variables that are spread throughout Page 0, 3 and 3.

You also need most of the OS IRQ vectors intact, these live down the low end of Page 2.

 

So long as you can spare a block of Ram somewhere, not sure how much needed but likely a bit more than 100 bytes if you need to save/restore the SIO related items just mentioned.

Possibly also a 128 byte buffer area to be able to read sectors though you could probably use the bottom half of the stack for that.

 

Then of course your load/save routines. The advantage there is so long as you can identify code within the C64 version you could just replace it with your own. Whether you'd fit the required code within the same space though... ?

 

But no doubt the C64 version does some degree of processing on the filename, since you'd be limited to save slots it becomes much easier to just get the user to select a save slot rather than identify a file so that might reclaim some programming space.

Share this post


Link to post
Share on other sites

or use xbios library:

- ataridos filesystem and family,

- no os rom usage

- no zeropage usage

- full reloc lib

- configurable lib, takes 1kb

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...