void PSG::reset()
{
+ touch_sound();
memset(ch, 0, sizeof(ch));
}
-void PSG::write_io8(uint32 addr, uint32 data)
+void PSG::write_io8(uint32_t addr, uint32_t data)
{
+ touch_sound();
ch[addr & 3].period = 0x3f - (data & 0x3f);
}
-void PSG::init(int rate)
+void PSG::initialize_sound(int rate)
{
diff = (int)(1.3 * (double)CPU_CLOCKS / (double)rate + 0.5);
}
-void PSG::mix(int32* buffer, int cnt)
+void PSG::mix(int32_t* buffer, int cnt)
{
// create sound buffer
for(int i = 0; i < cnt; i++) {
#define STATE_VERSION 1
-void PSG::save_state(FILEIO* state_fio)
+#include "../../statesub.h"
+
+void PSG::decl_state()
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_INT32_STRIDE((ch[0].period), 3, sizeof(ch[0]));
- for(int i = 0; i < 3; i++) {
- state_fio->FputInt32(ch[i].period);
+ leave_decl_state();
+}
+
+void PSG::save_state(FILEIO* state_fio)
+{
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
}
+// state_fio->FputUint32(STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
+
+// for(int i = 0; i < 3; i++) {
+// state_fio->FputInt32(ch[i].period);
+// }
}
bool PSG::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != STATE_VERSION) {
+ bool mb = false;
+ if(state_entry != NULL) {
+ mb = state_entry->load_state(state_fio);
+ }
+ if(!mb) {
+ return false;
+ }
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// for(int i = 0; i < 3; i++) {
+// ch[i].period = state_fio->FgetInt32();
+// }
+ return true;
+}
+
+bool PSG::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!state_fio->StateCheckInt32(this_device_id)) {
return false;
}
for(int i = 0; i < 3; i++) {
- ch[i].period = state_fio->FgetInt32();
+ state_fio->StateInt32(ch[i].period);
}
return true;
}
-