mirror of https://github.com/stella-emu/stella.git
Fixed sound problems when saving and then reloading a state file. Now
the contents of the TIA sound registers are saved/loaded with the state, resulting in a much more consistent state file. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@118 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
7824e7b2c5
commit
ddaab4dcae
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: TIA.cxx,v 1.16 2002-10-09 04:38:11 bwmott Exp $
|
||||
// $Id: TIA.cxx,v 1.17 2002-10-31 20:46:06 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -366,6 +366,20 @@ bool TIA::save(Serializer& out)
|
|||
|
||||
out.putBool(myDumpEnabled);
|
||||
out.putLong(myDumpDisabledCycle);
|
||||
|
||||
// Save the sample stuff ...
|
||||
string soundDevice = "TIASound";
|
||||
out.putString(soundDevice);
|
||||
out.putLong(mySampleRate);
|
||||
|
||||
uInt8 reg1, reg2, reg3, reg4, reg5, reg6;
|
||||
Tia_get_registers(®1, ®2, ®3, ®4, ®5, ®6);
|
||||
out.putLong(reg1);
|
||||
out.putLong(reg2);
|
||||
out.putLong(reg3);
|
||||
out.putLong(reg4);
|
||||
out.putLong(reg5);
|
||||
out.putLong(reg6);
|
||||
}
|
||||
catch(char *msg)
|
||||
{
|
||||
|
@ -460,6 +474,22 @@ bool TIA::load(Deserializer& in)
|
|||
|
||||
myDumpEnabled = in.getBool();
|
||||
myDumpDisabledCycle = (Int32) in.getLong();
|
||||
|
||||
// Load the sample stuff ...
|
||||
string soundDevice = "TIASound";
|
||||
if(in.getString() != soundDevice)
|
||||
return false;
|
||||
|
||||
mySampleRate = (uInt32) in.getLong();
|
||||
|
||||
uInt8 reg1 = 0, reg2 = 0, reg3 = 0, reg4 = 0, reg5 = 0, reg6 = 0;
|
||||
reg1 = (uInt8) in.getLong();
|
||||
reg1 = (uInt8) in.getLong();
|
||||
reg1 = (uInt8) in.getLong();
|
||||
reg1 = (uInt8) in.getLong();
|
||||
reg1 = (uInt8) in.getLong();
|
||||
reg1 = (uInt8) in.getLong();
|
||||
Tia_set_registers(reg1, reg2, reg3, reg4, reg5, reg6);
|
||||
}
|
||||
catch(char *msg)
|
||||
{
|
||||
|
|
|
@ -613,6 +613,55 @@ void Tia_process (register unsigned char *buffer, register uint16 n)
|
|||
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Module: Tia_get_registers() */
|
||||
/* Purpose: Returns the 6 TIA sound registers for use in state */
|
||||
/* loading and saving. */
|
||||
/* */
|
||||
/* Author: Stephen Anthony */
|
||||
/* Date: October 31, 2002 */
|
||||
/* */
|
||||
/* Inputs: reg .. reg6 - pointers to the variables where the registers */
|
||||
/* will be placed */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
void Tia_get_registers (unsigned char *reg1, unsigned char *reg2, unsigned char *reg3,
|
||||
unsigned char *reg4, unsigned char *reg5, unsigned char *reg6)
|
||||
{
|
||||
*reg1 = AUDC[0];
|
||||
*reg2 = AUDC[1];
|
||||
*reg3 = AUDF[0];
|
||||
*reg4 = AUDF[1];
|
||||
*reg5 = AUDV[0];
|
||||
*reg6 = AUDV[1];
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Module: Tia_set_registers() */
|
||||
/* Purpose: Sets the 6 TIA sound registers for use in state */
|
||||
/* loading and saving. */
|
||||
/* */
|
||||
/* Author: Stephen Anthony */
|
||||
/* Date: October 31, 2002 */
|
||||
/* */
|
||||
/* Inputs: reg .. reg6 - the registers to be set */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
void Tia_set_registers (unsigned char reg1, unsigned char reg2, unsigned char reg3,
|
||||
unsigned char reg4, unsigned char reg5, unsigned char reg6)
|
||||
{
|
||||
AUDC[0] = reg1;
|
||||
AUDC[1] = reg2;
|
||||
AUDF[0] = reg3;
|
||||
AUDF[1] = reg4;
|
||||
AUDV[0] = reg5;
|
||||
AUDV[1] = reg6;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -47,6 +47,11 @@ void Tia_process_2 (register unsigned char *buffer,
|
|||
void Tia_process (register unsigned char *buffer,
|
||||
register unsigned int n);
|
||||
|
||||
void Tia_get_registers (unsigned char *reg1, unsigned char *reg2, unsigned char *reg3,
|
||||
unsigned char *reg4, unsigned char *reg5, unsigned char *reg6);
|
||||
void Tia_set_registers (unsigned char reg1, unsigned char reg2, unsigned char reg3,
|
||||
unsigned char reg4, unsigned char reg5, unsigned char reg6);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue