Jump to content
IGNORED

Help me save variables in flash


atari2600land

Recommended Posts

All I want to do is save the value of two variables to flash in my program. And the manual's stuff about flash is like gibberish when I read it.

What are rows? How do I convert them to variables? Why do I need to save at least 15 of them?

This is all I have so far in the way of saving two variables' values:

 

write_row: PROCEDURE
    #row(0) = lemonnumber
    #row(1) = levelnumber
    
    FOR c = 2 to 15
    #row(c)=0
    NEXT c

    FLASH WRITE FLASH.FIRST,VARPTR #row(0)
    END
    
read_row: PROCEDURE
    FLASH READ FLASH.FIRST,VARPTR #row(0)
    
    lemonnumber=#row(0)
    levelnumber=#row(1)

    FOR c = 2 to 15
    #row(c)=0
    NEXT c

    END

 

And I don't even know if this will work.

Link to comment
Share on other sites

Be sure to run the IntyBASIC compiler and jzIntv with the --jlp flag. To specify a file on disk to act as flash storage, add the flag --jlp-savegame=FILENAME, replacing FILENAME with the file you'd like to use for storage.

 

I would also recommend to compile to BIN+CFG format, not ROM format when using JLP.

 

The ROM format emulates an actual Intellicart, and it can interact strangely with JLP support. The most recent updates to jzIntv, AS1600, and IntyBASIC 1.2.9 (updated Nov 22nd, as per this post) do their best to avoid weird interactions between the ROM format and JLP. AS1600 and jzIntv warn when those interactions might happen. But even if you have the latest jzIntv, that won't help someone playing your game who hasn't updated recently.

Link to comment
Share on other sites

I tried a bin file and it works unless you exit jzINTV and start it back up again. Closing jzINTV makes everything reset? I thought the save file would save the data when jzINTV closes down and is started back up again. Is this not so?

 

It should, as long as you specify a filename in the command-line, like intvnut mentioned. You not only have to specify it when running the jzIntv in the session you want to save, but in all subsequent sessions where you want it to load the game. Otherwise, how does it know that there is saved data?

 

By the way, intvnut, perhaps there is a chance for improvement: perhaps jzIntv should take a hint from MAME and use its own default folder/file structure. In MAME, I don't have to specify save files or NVRAM files, just their location. It will look for one with the game name and a special extension (or something like that).

 

Maybe jzIntv can do the same? It could make it easier for non-technical people to use. :)

 

-dZ.

Link to comment
Share on other sites

jzIntv's entire handling of files and filenames is a mess. I have mixed emotions on having a default save location for flash save files. I didn't feel like making policy tradeoffs, so I outsourced it back to the user. That seemed reasonable when it was a feature used by 2 or 3 people.

 

 

I am using a batch file to play jzintv, so all the times I've been playing it I have been entering the same thing.

 

Update your batch file to add this flag

 

.

--jlp-savegame=lemons.jlp 

.

That'll tell jzIntv where to save the flash image. You can delete that file whenever you like to "reset" the flash image. You can look inside it with "tohex" if you're curious what's in the emulated flash. (It's pretty boring, actually.)

 

jzIntv will try to make a backup copy of the file with a ~ on the name (lemons.jlp~ in this case) whenever jzIntv starts up. That way, if you mess up the file, you can copy the backup back over the image. The backup only gets written at startup. If you want a more sophisticated backup strategy, you'll have to build it in your batch file.

Link to comment
Share on other sites

So what is the flash example supposed to do? Is it supposed to save the green numbers that come up on the screen when 2 is pressed? I added that line in my batch file, and it makes the file, but it's not reading it. Whenever 2 is pressed, it says "Invalid JLP command."

Link to comment
Share on other sites

As best as I can tell, here's what it does:

  1. Pressing 1 reads the current contents of a flash row, and shows the values in white.
  2. Pressing 2 generates a set of random values and attempts to write them to flash. (This write may or may not succeed.) It also prints these numbers in green.
  3. Pressing 3 erases the flash sector that contains this row. (There are 8 rows to a sector; erase will erase them all.)

So, if you start with blank flash, and press 1, you should get a bunch of 65535s. Flash erases to all 1s.

 

If you press 2 once, and then press 1, you should see the same set of numbers in green and white. If you press 2 a second time, you'll see a new set of numbers. If you now press 1, you should see the first set that was saved, not the new set you attempted to save.

 

JLP doesn't let you overwrite a non-empty row.

 

If you press 3 and then 1, you'll erase the sector, and then see that it's erased (65535). Now if you press 2, and then press 1, you'll see you can save a new set of numbers to flash. (But again, only once until you erase them again.)

Link to comment
Share on other sites

Don't forget to download the latest jzintv version, the previous one had some bugs.

 

Specify the Flash size in command-line, forgot the argument name. Otherwise jzintv will choke with invalid read/write.

 

Also your #row array should be Dim'ed as DIM #row (96)

Link to comment
Share on other sites

I've never specified anything on the command line, other than the save file itself. jzintv works fine for me. I'm not sure what you're referring to, here.

 

 

If you just say "jlp = 1" without adding "jlp_flash = #" (or "jlpflash"; both spellings are supported), older jzIntv set the flash capacity to 0. Thus, any attempt to read or write flash was considered "out of range."

 

 

Make sure you run your game from the bin file, as the ROM format doesn't include this info.

 

The latest version of AS1600 and jzIntv do have support for that now. It's working better than before, but it isn't perfect. I still recommend BIN+CFG as the most fully-supported option for JLP development.

 

post-14113-0-02915500-1514709005_thumb.png

  • Like 1
Link to comment
Share on other sites

THERE. I successfully programmed it to save three variables, then turn of jzintv, turn it back on again and have the three variables still be there. Can I test this on an LTO Flash! and have it work like it does in jzINTV?

 

Congrats! It should work exactly the same :)

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...