Author : Takeda.Toshiya
Date : 2010.08.31-
- [ main ]
+ [ main pcb ]
*/
-#include "main.h"
+#include "./main.h"
#include "../upd765a.h"
#define SET_BANK(s, e, w, r) { \
if(data & 0x40) {
for(int i = 0; i < 3; i++) {
if(data & (1 << i)) {
-// emu->out_debug_log(_T("MAIN->FDC\tDRIVE=%d\n"), i);
+// this->out_debug_log(_T("MAIN->FDC\tDRIVE=%d\n"), i);
d_fdc->write_signal(SIG_UPD765A_DRVSEL, i, 3);
break;
}
break;
case 0xfc: // mz3500sm p.23
if((srqb & 2) != (data & 2)) {
-// emu->out_debug_log(_T("MAIN->SUB\tBUSREQ=%d\n"), (data&2)?1:0);
+// this->out_debug_log(_T("MAIN->SUB\tBUSREQ=%d\n"), (data&2)?1:0);
d_subcpu->write_signal(SIG_CPU_BUSREQ, data, 2);
}
srqb = data;
break;
case 0xfd: // mz3500sm p.23
if(!(sres & 0x80) && (data & 0x80)) {
-// emu->out_debug_log(_T("MAIN->SUB\tRESET\n"));
+// this->out_debug_log(_T("MAIN->SUB\tRESET\n"));
d_subcpu->reset();
}
sres = data;
{
if(id == SIG_MAIN_SACK) {
sack = ((data & mask) != 0);
-// emu->out_debug_log(_T("SUB->MAIN\tSACK=%d\n"), sack?1:0);
+// this->out_debug_log(_T("SUB->MAIN\tSACK=%d\n"), sack?1:0);
} else if(id == SIG_MAIN_SRDY) {
srdy = ((data & mask) != 0);
-// emu->out_debug_log(_T("SUB->MAIN\tSRDY=%d\n"), srdy?1:0);
+// this->out_debug_log(_T("SUB->MAIN\tSRDY=%d\n"), srdy?1:0);
} else if(id == SIG_MAIN_INTFD) {
intfd = ((data & mask) != 0);
-// emu->out_debug_log(_T("FDC->MAIN\tINTFD=%d\n"), intfd?1:0);
+// this->out_debug_log(_T("FDC->MAIN\tINTFD=%d\n"), intfd?1:0);
update_irq();
} else if(id == SIG_MAIN_INT0) {
int0 = ((data & mask) != 0);
-// emu->out_debug_log(_T("SUB->MAIN\tINT0=%d\n"), int0?1:0);
+// this->out_debug_log(_T("SUB->MAIN\tINT0=%d\n"), int0?1:0);
update_irq();
} else if(id == SIG_MAIN_INT1) {
int1 = ((data & mask) != 0);
}
}
if(next) {
-// emu->out_debug_log(_T("MAIN IRQ=%d SRC=%d\n"), next?1:0,inp);
- d_cpu->set_intr_line(true, true, 0);
+// this->out_debug_log(_T("MAIN IRQ=%d SRC=%d\n"), next?1:0,inp);
+ d_maincpu->set_intr_line(true, true, 0);
}
}
#define STATE_VERSION 2
+#include "../../statesub.h"
+
+void MAIN::decl_state()
+{
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
+ DECL_STATE_ENTRY_1D_ARRAY(common, sizeof(common));
+ DECL_STATE_ENTRY_UINT8(ma);
+ DECL_STATE_ENTRY_UINT8(ms);
+ DECL_STATE_ENTRY_UINT8(mo);
+ DECL_STATE_ENTRY_BOOL(me1);
+ DECL_STATE_ENTRY_BOOL(me2);
+ DECL_STATE_ENTRY_UINT8(srqb);
+ DECL_STATE_ENTRY_UINT8(sres);
+ DECL_STATE_ENTRY_BOOL(sack);
+ DECL_STATE_ENTRY_BOOL(srdy);
+ DECL_STATE_ENTRY_BOOL(intfd);
+ DECL_STATE_ENTRY_BOOL(int0);
+ DECL_STATE_ENTRY_BOOL(int1);
+ DECL_STATE_ENTRY_BOOL(int2);
+ DECL_STATE_ENTRY_BOOL(int3);
+ DECL_STATE_ENTRY_BOOL(int4);
+ DECL_STATE_ENTRY_BOOL(me);
+ DECL_STATE_ENTRY_BOOL(e1);
+ DECL_STATE_ENTRY_UINT8(inp);
+ DECL_STATE_ENTRY_BOOL(motor);
+ DECL_STATE_ENTRY_BOOL(drq);
+ DECL_STATE_ENTRY_BOOL(index);
+ DECL_STATE_ENTRY_BOOL(crt_400line);
+
+ leave_decl_state();
+}
+
void MAIN::save_state(FILEIO* state_fio)
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
+// state_fio->FputUint32(STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
- state_fio->Fwrite(ram, sizeof(ram), 1);
- state_fio->Fwrite(common, sizeof(common), 1);
- state_fio->FputUint8(ma);
- state_fio->FputUint8(ms);
- state_fio->FputUint8(mo);
- state_fio->FputBool(me1);
- state_fio->FputBool(me2);
- state_fio->FputUint8(srqb);
- state_fio->FputUint8(sres);
- state_fio->FputBool(sack);
- state_fio->FputBool(srdy);
- state_fio->FputBool(intfd);
- state_fio->FputBool(int0);
- state_fio->FputBool(int1);
- state_fio->FputBool(int2);
- state_fio->FputBool(int3);
- state_fio->FputBool(int4);
- state_fio->FputBool(me);
- state_fio->FputBool(e1);
- state_fio->FputUint8(inp);
- state_fio->FputBool(motor);
- state_fio->FputBool(drq);
- state_fio->FputBool(index);
- state_fio->FputBool(crt_400line);
+// state_fio->Fwrite(ram, sizeof(ram), 1);
+// state_fio->Fwrite(common, sizeof(common), 1);
+// state_fio->FputUint8(ma);
+// state_fio->FputUint8(ms);
+// state_fio->FputUint8(mo);
+// state_fio->FputBool(me1);
+// state_fio->FputBool(me2);
+// state_fio->FputUint8(srqb);
+// state_fio->FputUint8(sres);
+// state_fio->FputBool(sack);
+// state_fio->FputBool(srdy);
+// state_fio->FputBool(intfd);
+// state_fio->FputBool(int0);
+// state_fio->FputBool(int1);
+// state_fio->FputBool(int2);
+// state_fio->FputBool(int3);
+// state_fio->FputBool(int4);
+// state_fio->FputBool(me);
+// state_fio->FputBool(e1);
+// state_fio->FputUint8(inp);
+// state_fio->FputBool(motor);
+// state_fio->FputBool(drq);
+// state_fio->FputBool(index);
+// state_fio->FputBool(crt_400line);
}
bool MAIN::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != STATE_VERSION) {
- return false;
+ bool mb = false;
+ if(state_entry != NULL) {
+ mb = state_entry->load_state(state_fio);
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!mb) {
return false;
}
- state_fio->Fread(ram, sizeof(ram), 1);
- state_fio->Fread(common, sizeof(common), 1);
- ma = state_fio->FgetUint8();
- ms = state_fio->FgetUint8();
- mo = state_fio->FgetUint8();
- me1 = state_fio->FgetBool();
- me2 = state_fio->FgetBool();
- srqb = state_fio->FgetUint8();
- sres = state_fio->FgetUint8();
- sack = state_fio->FgetBool();
- srdy = state_fio->FgetBool();
- intfd = state_fio->FgetBool();
- int0 = state_fio->FgetBool();
- int1 = state_fio->FgetBool();
- int2 = state_fio->FgetBool();
- int3 = state_fio->FgetBool();
- int4 = state_fio->FgetBool();
- me = state_fio->FgetBool();
- e1 = state_fio->FgetBool();
- inp = state_fio->FgetUint8();
- motor = state_fio->FgetBool();
- drq = state_fio->FgetBool();
- index = state_fio->FgetBool();
- crt_400line = state_fio->FgetBool();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// state_fio->Fread(ram, sizeof(ram), 1);
+// state_fio->Fread(common, sizeof(common), 1);
+// ma = state_fio->FgetUint8();
+// ms = state_fio->FgetUint8();
+// mo = state_fio->FgetUint8();
+// me1 = state_fio->FgetBool();
+// me2 = state_fio->FgetBool();
+// srqb = state_fio->FgetUint8();
+// sres = state_fio->FgetUint8();
+// sack = state_fio->FgetBool();
+// srdy = state_fio->FgetBool();
+// intfd = state_fio->FgetBool();
+// int0 = state_fio->FgetBool();
+// int1 = state_fio->FgetBool();
+// int2 = state_fio->FgetBool();
+// int3 = state_fio->FgetBool();
+// int4 = state_fio->FgetBool();
+// me = state_fio->FgetBool();
+// e1 = state_fio->FgetBool();
+// inp = state_fio->FgetUint8();
+// motor = state_fio->FgetBool();
+// drq = state_fio->FgetBool();
+// index = state_fio->FgetBool();
+// crt_400line = state_fio->FgetBool();
// post process
update_bank();
return true;
}
+bool MAIN::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(common, sizeof(common), 1);
+ state_fio->StateUint8(ma);
+ state_fio->StateUint8(ms);
+ state_fio->StateUint8(mo);
+ state_fio->StateBool(me1);
+ state_fio->StateBool(me2);
+ state_fio->StateUint8(srqb);
+ state_fio->StateUint8(sres);
+ state_fio->StateBool(sack);
+ state_fio->StateBool(srdy);
+ state_fio->StateBool(intfd);
+ state_fio->StateBool(int0);
+ state_fio->StateBool(int1);
+ state_fio->StateBool(int2);
+ state_fio->StateBool(int3);
+ state_fio->StateBool(int4);
+ state_fio->StateBool(me);
+ state_fio->StateBool(e1);
+ state_fio->StateUint8(inp);
+ state_fio->StateBool(motor);
+ state_fio->StateBool(drq);
+ state_fio->StateBool(index);
+ state_fio->StateBool(crt_400line);
+
+ // post process
+ if(loading) {
+ update_bank();
+ }
+ return true;
+}