X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;ds=sidebyside;f=source%2Fsrc%2Fvm%2Fpv1000%2Fpsg.cpp;h=120880c10903781a4bfe86a78454d775f9f76d31;hb=411218144c2e1cc0f97b53d8469bed1325de05c2;hp=0bd4fdef1b363409fd4f6664841b318ce47607ce;hpb=2fc3688fce9d88e48aebd26b694fd2bb143a2574;p=csp-qt%2Fcommon_source_project-fm7.git diff --git a/source/src/vm/pv1000/psg.cpp b/source/src/vm/pv1000/psg.cpp index 0bd4fdef1..120880c10 100644 --- a/source/src/vm/pv1000/psg.cpp +++ b/source/src/vm/pv1000/psg.cpp @@ -15,20 +15,22 @@ 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++) { @@ -60,27 +62,61 @@ void PSG::set_volume(int ch, int decibel_l, int decibel_r) #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; } -