Wednesday, 27 October 2010

Saving games

The CD32 only have 1024 bytes of non-volatile RAM for saving purposes that's a really tiny amount of memory to store the data of a Role Playing Game such as Phantasie II.

During the game, the save command is available when the party is located in a town and when it's getting out of a dungeon, so for the party location a single byte will be sufficient (with a bit to specify the saving type (town/dungeon) and an index to determine the actual dungeon's or town's number (or just a simple index into a table).

Towns items stocks need to be saved as well, they take 180 bytes and there's 9 towns so 180 * 9 = 1620 bytes, we already exceeded the amount of memory we have at our disposal !

Most characters data need to be saved, if we avoid the calculated values and use bit fields for spells and runes we can have approximatively 109 bytes per character which gives 654 bytes for a whole party of 6 characters.

Discover the world by stepping on it

The original Apple II version had the wilderness & dungeons tiles hidden until the party stepped on them, in order to save the progression of the player the OUTTx & DNGx were updated with all the values of the tiles (including the newly uncovered ones).

While this is a nice feature I'd like to keep as it adds a real sense of discovery to a game i can hardly save all the states of all the wilderness & dungeon tiles with the rest of the data.

Assuming i'll use bits to save each state i would have to cram 2359 bytes of data (with possibly high entropy later in the game when many of the locations would have been visited) together with the rest of information inside the saving slot, which could be a problem.

A problem which will be eliminated simply by not saving the states (although I'll need to perform some more accurate tests i don't think there'll be enough room left to save them).

So a restored game will have all it's tiles covered again, while this may sound unfair (maybe it is) i always found that roaming a place or level which was already visited and which topography is all uncovered spoils a bit of the fun & beside: the only other solution would be to play it with WinUAE & use states files (talk about spoiling the fun).

Another small issue concerning the covered tiles was the water ones, on the Apple II there was no way to know (or maybe i missed some extra feature) when a newly uncovered part of the wilderness would be the ocean & that was kinda frustrating as characters could sink and die (or manage to swim) when moving onto one, to avoid that i think the best way is uncover the tile & ask the player if the party should go ahead & try to swim or just stop moving when the party is about to step on such tile.

So now we're left with approximatively 1+1620+654 = 2275 bytes for a game save which is more than the 1024 bytes that we don't even have because there's an overhead of 24 bytes for the NVRAM header and 7 for our entry so 993 bytes it shall be...

Obviously, the game needs to include it's own packer and depacker which needs to be good & fast enough to fit our requirements, a primary test i did with packfire (tiny model) showed that default data for the towns and 6 characters with random names pack into approximatively into 523 bytes, i assume it will grow but probably not beyond 993 bytes (crossing fingers there) otherwise I'll have to ditch the towns items infos (which could lead to a major cheating issue).

Greetings to Commodore.

No comments:

Post a Comment