* vrc7: Add sound save states * Try to fix some save state issues try to fix big-endian related save problems * vrc7: fix crash in some cases when loading states
This commit is contained in:
committed by
hizzlekizzle
parent
25fdf55f8f
commit
e3cf3efc69
@@ -174,6 +174,7 @@ static void VRC7IRQHook(int a) {
|
|||||||
|
|
||||||
static void StateRestore(int version) {
|
static void StateRestore(int version) {
|
||||||
Sync();
|
Sync();
|
||||||
|
OPLL_forceRefresh(VRC7Sound);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mapper85_Init(CartInfo *info) {
|
void Mapper85_Init(CartInfo *info) {
|
||||||
@@ -191,6 +192,28 @@ void Mapper85_Init(CartInfo *info) {
|
|||||||
GameStateRestore = StateRestore;
|
GameStateRestore = StateRestore;
|
||||||
VRC7_ESI();
|
VRC7_ESI();
|
||||||
AddExState(&StateRegs, ~0, 0, 0);
|
AddExState(&StateRegs, ~0, 0, 0);
|
||||||
|
|
||||||
|
/* Sound states */
|
||||||
|
AddExState(&VRC7Sound->adr, sizeof(VRC7Sound->adr), 0, "ADDR");
|
||||||
|
AddExState(&VRC7Sound->out, sizeof(VRC7Sound->out), 0, "OUT0");
|
||||||
|
AddExState(&VRC7Sound->realstep, sizeof(VRC7Sound->realstep), 0, "RTIM");
|
||||||
|
AddExState(&VRC7Sound->oplltime, sizeof(VRC7Sound->oplltime), 0, "TIME");
|
||||||
|
AddExState(&VRC7Sound->opllstep, sizeof(VRC7Sound->opllstep), 0, "STEP");
|
||||||
|
AddExState(&VRC7Sound->prev, sizeof(VRC7Sound->prev), 0, "PREV");
|
||||||
|
AddExState(&VRC7Sound->next, sizeof(VRC7Sound->next), 0, "NEXT");
|
||||||
|
AddExState(&VRC7Sound->LowFreq, sizeof(VRC7Sound->LowFreq), 0, "LFQ0");
|
||||||
|
AddExState(&VRC7Sound->HiFreq, sizeof(VRC7Sound->HiFreq), 0, "HFQ0");
|
||||||
|
AddExState(&VRC7Sound->InstVol, sizeof(VRC7Sound->InstVol), 0, "VOLI");
|
||||||
|
AddExState(&VRC7Sound->CustInst, sizeof(VRC7Sound->CustInst), 0, "CUSI");
|
||||||
|
AddExState(&VRC7Sound->slot_on_flag, sizeof(VRC7Sound->slot_on_flag), 0, "FLAG");
|
||||||
|
AddExState(&VRC7Sound->pm_phase, sizeof(VRC7Sound->pm_phase), 0, "PMPH");
|
||||||
|
AddExState(&VRC7Sound->lfo_pm, sizeof(VRC7Sound->lfo_pm), 0, "PLFO");
|
||||||
|
AddExState(&VRC7Sound->am_phase, sizeof(VRC7Sound->am_phase), 0, "AMPH");
|
||||||
|
AddExState(&VRC7Sound->lfo_am, sizeof(VRC7Sound->lfo_am), 0, "ALFO");
|
||||||
|
AddExState(&VRC7Sound->patch_number, sizeof(VRC7Sound->patch_number), 0, "PNUM");
|
||||||
|
AddExState(&VRC7Sound->key_status, sizeof(VRC7Sound->key_status), 0, "KET");
|
||||||
|
AddExState(&VRC7Sound->mask, sizeof(VRC7Sound->mask), 0, "MASK");
|
||||||
|
AddExState((uint8 *)VRC7Sound->slot, sizeof(VRC7Sound->slot), 0, "SLOT");
|
||||||
}
|
}
|
||||||
|
|
||||||
void NSFVRC7_Init(void) {
|
void NSFVRC7_Init(void) {
|
||||||
|
|||||||
@@ -31,7 +31,10 @@ void FlipByteOrder(uint8 *src, uint32 count)
|
|||||||
uint8 *start = src;
|
uint8 *start = src;
|
||||||
uint8 *end = src + count - 1;
|
uint8 *end = src + count - 1;
|
||||||
|
|
||||||
while(start < end)
|
if ((count & 1) || !count)
|
||||||
|
return; /* This shouldn't happen. */
|
||||||
|
|
||||||
|
while (count--)
|
||||||
{
|
{
|
||||||
uint8 tmp;
|
uint8 tmp;
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ static int SubWrite(memstream_t *mem, SFORMAT *sf)
|
|||||||
if(sf->s & RLSB)
|
if(sf->s & RLSB)
|
||||||
FlipByteOrder((uint8 *)sf->v, sf->s & (~RLSB));
|
FlipByteOrder((uint8 *)sf->v, sf->s & (~RLSB));
|
||||||
#endif
|
#endif
|
||||||
memstream_write(mem, (uint8 *)sf->v, sf->s & (~RLSB));
|
memstream_write(mem, (char *)sf->v, sf->s & (~RLSB));
|
||||||
|
|
||||||
/* Now restore the original byte order. */
|
/* Now restore the original byte order. */
|
||||||
#ifdef MSB_FIRST
|
#ifdef MSB_FIRST
|
||||||
@@ -176,7 +176,7 @@ static int ReadStateChunk(memstream_t *mem, SFORMAT *sf, int size)
|
|||||||
|
|
||||||
if((tmp = CheckS(sf, tsize, toa)))
|
if((tmp = CheckS(sf, tsize, toa)))
|
||||||
{
|
{
|
||||||
memstream_read(mem, (uint8 *)tmp->v, tmp->s & (~RLSB));
|
memstream_read(mem, (char *)tmp->v, tmp->s & (~RLSB));
|
||||||
|
|
||||||
#ifdef MSB_FIRST
|
#ifdef MSB_FIRST
|
||||||
if(tmp->s & RLSB)
|
if(tmp->s & RLSB)
|
||||||
@@ -213,8 +213,8 @@ static int ReadStateChunks(memstream_t *st, int32 totalsize)
|
|||||||
case 2:
|
case 2:
|
||||||
if (!ReadStateChunk(st, SFCPUC, size))
|
if (!ReadStateChunk(st, SFCPUC, size))
|
||||||
ret = 0;
|
ret = 0;
|
||||||
else
|
/* else
|
||||||
X.mooPI = X.P; /* Quick and dirty hack. */
|
X.mooPI = X.P; */ /* Quick and dirty hack. */
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (!ReadStateChunk(st, FCEUPPU_STATEINFO, size))
|
if (!ReadStateChunk(st, FCEUPPU_STATEINFO, size))
|
||||||
@@ -320,6 +320,7 @@ void ResetExState(void (*PreSave)(void), void (*PostSave)(void))
|
|||||||
SPreSave = PreSave;
|
SPreSave = PreSave;
|
||||||
SPostSave = PostSave;
|
SPostSave = PostSave;
|
||||||
SFEXINDEX = 0;
|
SFEXINDEX = 0;
|
||||||
|
SFMDATA[0].s = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddExState(void *v, uint32 s, int type, char *desc)
|
void AddExState(void *v, uint32 s, int type, char *desc)
|
||||||
|
|||||||
Reference in New Issue
Block a user