Discussion

Persistent RAM

2

Benimo12 2022-06-04 23:13

I’ve been playing around with persistent RAM today since I finally figured out how it works and I was wondering if you can make an entire game out of it (not just player coordinates but also which cells collide, where other entities are located, which cells are collectibles, etc.)
I was wondering that because I wanted to create a framework that looks for all necessary variables from the “wrote battery” and inserts the values of the variables back into the source code.

Something like what a save would do except that the entire game depends on the “wrote battery”


was8bit 2022-06-05 04:28

PERSIST memory is designed to save game stats or high scores, or ANY other kind of data you want to be available as a player quits a game, then starts the game later... with proper use of PERSIST memory, the player can continue playing their game where they last left off when they last quit their game


was8bit 2022-06-05 04:33

Also, the maximum size of PERSIST is exactly equal to the BG0 and BG1 active memory

IF you are clever to figure out how to use both backgrounds to store your game status, this makes it super easy to let the player pick up where they last left their game...

Otherwise, use PEEK and POKE to store and retrieve variables between games


Benimo12 2022-06-05 07:33

Yes, yes, using PEEK and POKE. The maximum amount of values or variables that can be stored is exactly 1000 if I’m not mistaken, I can use about 500 for the framework and leave the rest.
My plan is to use the variables as a director for what code should run and when it should run.


was8bit 2022-06-05 07:41 (Edited)

The # of variables you may store depends on the SIZE of value you choose to use...

Also, YOU must handle the proper storage and retrieval

The easiest is to restrict values to 0-255... this gives you 4,096 variables to store...

Example:

POKE $E000,gold
to store amount of golf

GOLD=PEEK($E000)
To retrieve amount of gold

POKE($E000+37,wheat)
to store wheat into space #37

WHEAT=PEEK($E000+37)
To retrieve wheat amount from space #37


was8bit 2022-06-05 07:45 (Edited)

Now, IF you simply want storage space that refreshes each game, use WORKING RAM $A000 to $DFFF, with 16,384 of memory space...

As this wouldn't be saved from game to game, it would probably just be easier to use regular variables in an array..

DIM COMMAND(1000)

Would set you up for a series of 1,000 commands...

DIM COMMAND(19,15)

Would store a command for each cell location on the screen....


Benimo12 2022-06-05 11:15

Dude answered my next question before I even asked it


was8bit 2022-06-05 11:58

:)


Benimo12 2022-06-05 19:01

Thank you


was8bit 2022-06-06 05:15

:D


Log in to reply.