Jump to content
IGNORED

How to avoid corrupt atari basic save file - memory safekeeping


Recommended Posts

I just saved a Turbo basic file after the memory at the end of the program was partly modified. The Program still listed alright, but after loading the saved program the loading process ends with two 'ready' messages and there seems to be no program in memory.

 

I know since early Atari days that these things can happen, of course I should have made a backup every once in a while, or better use List"d:". A day's work is lost and I will have to do it again.

 

I wonder if there is a chance to put the file right again, after all the data in the basic save file is still there and maybe there are only some wrong pointers in the file that can be reconstructed?

 

My program uses APPMHI, dpeek(14) after all the DIM statements to determine the lowest ram I can use and then still keeps 100 bytes distance for safety. But to be honest I have no clue how APPMHI can change during the program run and there must be also something like a basic return stack that can vary depending of the loop nesting depth, so how can I be safe not to destroy my basic code with my own data in memory?

Link to comment
Share on other sites

Yep, Runtime Stack sits at the top of Ram used by Basic and will grow/shrink with loop/subroutine entries.

Sometimes when reserving memory it's just a whole bunch easier to move the RAMTOP (dec 106) pointer downwards, reopen the screen and use the memory above it.

Though problems there, older OS versions can write beyond end of screen when doing a clear opertion and any OS needs that pointer to be on a 4K boundary if you want to use any graphics mode that needs >4K - ie Gr. 8 or 15.

 

The LIST then ENTER <filename> trick is handy to keep programs free of bloat ie it overcomes the 16 bytes growth of Basic Rev B and ensures unused variable names are freed up.

But if you have a SAVEd program that has corruption such that reloading gives you nothing, then that makes things somewhat harder.

I don't know if there's any utilities around that can help.

About all I could think of is to use a hex editor to change the pointers within the program data such that the last line of the program is omitted. And keep doing that until the corruption goes away.

To do that you need to know some Basic internals - books like Inside Atari Basic have the info needed there.

 

As for stopping it happening again - when reserving memory using that method, it's probably best to get your screen mode set, all arrays dimensioned before allocating memory.

Also it's safer but not necessarily more convenient to reserve memory by using strings and ADR to find where they are.

Strings will stay where they are so long as you don't change the program mid-run.

Link to comment
Share on other sites

Thanks for those hints!

A LISTed program is so much easier to restore if a file should get partly corrupted. Normally I always list to a temp file occasionally during coding, but as you know, Mr. Murphy ensures that I didn't whenever something strange happens. ;-)

Link to comment
Share on other sites

You can attempt to de-tokenize it. The only program I have is for BASIC-XE, but it will work with Atari BASIC, BXL, and Turbo, but the extended command set (in Turbo), such as DPOKE, BGET, and any other keywords not in Atari BASIC may come out wrong. It's worth a try.

 

This is a BASIC-XL program. The disk contains the BXL runtime, so just boot it, or load AUTORUN.SYS. It works in SDX if you X AUTORUN.SYS.

 

Good luck.

 

Basic XE Detokenizer v1.11 (1989-06-04)(Psycho).zip

  • Like 1
Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...