Jump to content


The AtariAge Forum is undergoing a major upgrade today.  The forum is currently in read-only mode except for the Announcements Forum.  Please read this important post!

Photo

Save states for Virtual Jaguar (patch)

virtualjaguar virtual jaguar save states

8 replies to this topic

#1 PvtLewis OFFLINE  

PvtLewis

    Combat Commando

  • 5 posts

Posted Sun Sep 27, 2015 2:41 AM

Thanks to Shamus et al.
I was not sure where to send this, so I will post it here.
 
Attached is a patch against the current git version. Tested only on Linux/x86-64/Qt4.
Attached File  virtualjaguar-savestates.diff.txt   86.8KB   220 downloads
 
There is a new 'Tools' menu, with Dump/Load and the option to choose from 10 save slots per game.
 
Notes:
Sometimes the audio will be screwed up after loading the save state.
Try loading the state several times, by holding down the load button/key for a second or two.
 
The escape key toggles full screen mode. (It was F9 ...)
F5/F8 are mapped to Dump/Load.
 
Fixed sample buffer overrun in DSPSampleCallback.
 
Should compile with either Qt4 or Qt5.
 
Stopped randomizing RAM contents on startup, in order to better compress the state file.


#2 sh3-rg OFFLINE  

sh3-rg

    River Patroller

  • 3,397 posts
  • doge + tie = dothemath
  • Location:BOLTON, England

Posted Sun Sep 27, 2015 4:01 AM

likes-aa-mts6b.png

 

But I do like!



#3 GroovyBee OFFLINE  

GroovyBee

    Games Developer

  • 9,821 posts
  • Busy bee!
  • Location:England

Posted Sun Sep 27, 2015 4:28 AM

Stopped randomizing RAM contents on startup, in order to better compress the state file.


This is a good feature yo have for game development. Perhaps it could be toggled on/off in some way?

#4 PvtLewis OFFLINE  

PvtLewis

    Combat Commando

  • Topic Starter
  • 5 posts

Posted Sun Sep 27, 2015 5:14 AM

This is a good feature yo have for game development. Perhaps it could be toggled on/off in some way?

 

For now if you compile it with the patch, just change the two "#if 1" to "#if 0" in jaguar.cpp

 

It should not be hard to add an option to the config file.

 

The whole first 8MB of jagMemSpace is saved in the state file.

Maybe only the first 2MB of actual RAM is necessary, but if everything is zeroed at startup then state files can be compressed to about 1-1.5MB

 

I just checked, and if you zero everything at startup, then randomize the 2MB of RAM, it only adds a few hundred KB to the state file.



#5 PvtLewis OFFLINE  

PvtLewis

    Combat Commando

  • Topic Starter
  • 5 posts

Posted Sun Sep 27, 2015 7:17 AM

Update:

I finally realized that SDL audio is running in its own thread.

This new patch adds a hack to sync dump/load of the state to the audio thread.

Now it seems that the chance of audio being broken on load has been drastically reduced.

 

Attached File  virtualjaguar-savestates-2-20150927.diff.txt   88.42KB   182 downloads

 

Also, with this patch RAM contents are randomized as in stock Virtual Jaguar.

 



#6 Shamus OFFLINE  

Shamus

    Dragonstomper

  • 669 posts
  • Moo, er, Roar!
  • Location:Ur-th

Posted Sun Sep 27, 2015 8:11 AM

This patch is quite large, and it will take some time to properly vet it; but overall, it looks good. Judging by the size of the patch, one can get an idea why I put this off for so long. ;) The second reason that I put it off is that there's no guarantee that the internal structure of the various pieces of VJ will be stable over the long term, which means that save states *may* break between official releases. :)

 

Thanks for contributing! BTW, I have to ask, why the conditional compilation for Qt 4? Is there a real need for it that I'm not seeing? I understand the transition from Qt 3 to Qt 4 was a disaster, but it seems they learned from that as the transition from Qt 4 to Qt 5 was dead simple.



#7 PvtLewis OFFLINE  

PvtLewis

    Combat Commando

  • Topic Starter
  • 5 posts

Posted Sun Sep 27, 2015 9:05 AM

This patch is quite large, and it will take some time to properly vet it; but overall, it looks good. Judging by the size of the patch, one can get an idea why I put this off for so long. ;) The second reason that I put it off is that there's no guarantee that the internal structure of the various pieces of VJ will be stable over the long term, which means that save states *may* break between official releases. :)

 

Thanks for contributing! BTW, I have to ask, why the conditional compilation for Qt 4? Is there a real need for it that I'm not seeing? I understand the transition from Qt 3 to Qt 4 was a disaster, but it seems they learned from that as the transition from Qt 4 to Qt 5 was dead simple.

 

There is no real need for it, but the debian system that I am using only has Qt4 installed.

 

All I did was include QtGui for Qt4 if the version is less than 5, like this:

#if QT_VERSION >= 0x050000
#include <QtWidgets>
#else
#include <QtGui>
#endif
 
I tried to make the save state file format flexible enough to handle slight variations between releases.
No guarantee this will work in practice...
 
The same save state files should be usable on both big endian/little endian machines, but this has not been tested.


#8 GroovyBee OFFLINE  

GroovyBee

    Games Developer

  • 9,821 posts
  • Busy bee!
  • Location:England

Posted Sun Sep 27, 2015 9:09 AM

If you put a version number in the save state file it can be decoded correctly by all future versions of VJ and VJ can use safe defaults for things the save state format didn't support at the time.

#9 PvtLewis OFFLINE  

PvtLewis

    Combat Commando

  • Topic Starter
  • 5 posts

Posted Sun Sep 27, 2015 9:41 AM

If you put a version number in the save state file it can be decoded correctly by all future versions of VJ and VJ can use safe defaults for things the save state format didn't support at the time.

There is a version number near the beginning of the file, but it is not intended to be incremented upon each release.

With the current patch, VJ will refuse to load files with version number greater than 1.

 

Data is stored in chunks with type/size fields at the beginning of each chunk.

 

New releases of VJ can use default values for new types that aren't found in a file, while old releases of VJ will skip over new types of data.

 

But if things change too much, it may be cumbersome to handle everything correctly.

In that case you can increment the version number and be done with it.







Also tagged with one or more of these keywords: virtualjaguar, virtual jaguar, save states

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users