}
}
-#ifdef USE_DEBUGGER
+//#ifdef USE_DEBUGGER
void TMS9918A::get_debug_regs_info(_TCHAR *buffer, size_t buffer_len)
{
my_stprintf_s(buffer, buffer_len,
regs[0], regs[1], regs[2], regs[3], regs[4], regs[5], regs[6], regs[7],
vram_addr, status_reg);
}
-#endif
+//#endif
#define STATE_VERSION 1
-#include "../statesub.h"
-
-void TMS9918A::decl_state()
+bool TMS9918A::process_state(FILEIO* state_fio, bool loading)
{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_1D_ARRAY(vram, _VRAM_SIZE * sizeof(uint8_t));
- DECL_STATE_ENTRY_1D_ARRAY(regs, sizeof(regs));
- DECL_STATE_ENTRY_UINT8(status_reg);
- DECL_STATE_ENTRY_UINT8(read_ahead);
- DECL_STATE_ENTRY_UINT8(first_byte);
- DECL_STATE_ENTRY_UINT16(vram_addr);
- DECL_STATE_ENTRY_BOOL(latch);
- DECL_STATE_ENTRY_BOOL(intstat);
- DECL_STATE_ENTRY_UINT16(color_table);
- DECL_STATE_ENTRY_UINT16(pattern_table);
- DECL_STATE_ENTRY_UINT16(name_table);
- DECL_STATE_ENTRY_UINT16(sprite_pattern);
- DECL_STATE_ENTRY_UINT16(sprite_attrib);
- DECL_STATE_ENTRY_UINT16(color_mask);
- DECL_STATE_ENTRY_UINT16(pattern_mask);
-//#ifdef TMS9918A_SUPER_IMPOSE
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ //state_fio->StateBuffer(vram, sizeof(vram), 1);
+ state_fio->StateBuffer(vram, _VRAM_SIZE, 1);
+ state_fio->StateBuffer(regs, sizeof(regs), 1);
+ state_fio->StateUint8(status_reg);
+ state_fio->StateUint8(read_ahead);
+ state_fio->StateUint8(first_byte);
+ state_fio->StateUint16(vram_addr);
+ state_fio->StateBool(latch);
+ state_fio->StateBool(intstat);
+ state_fio->StateUint16(color_table);
+ state_fio->StateUint16(pattern_table);
+ state_fio->StateUint16(name_table);
+ state_fio->StateUint16(sprite_pattern);
+ state_fio->StateUint16(sprite_attrib);
+ state_fio->StateUint16(color_mask);
+ state_fio->StateUint16(pattern_mask);
if(_tms9918a_super_impose) {
- DECL_STATE_ENTRY_BOOL(now_super_impose);
- }
-//#endif
-
- leave_decl_state();
-}
-void TMS9918A::save_state(FILEIO* state_fio)
-{
- if(state_entry != NULL) {
- state_entry->save_state(state_fio);
+ state_fio->StateBool(now_super_impose);
}
-
-// state_fio->FputUint32(STATE_VERSION);
-// state_fio->FputInt32(this_device_id);
-
-// state_fio->Fwrite(vram, _VRAM_SIZE * sizeof(uint8_t), 1);
-// state_fio->Fwrite(regs, sizeof(regs), 1);
-// state_fio->FputUint8(status_reg);
-// state_fio->FputUint8(read_ahead);
-// state_fio->FputUint8(first_byte);
-// state_fio->FputUint16(vram_addr);
-// state_fio->FputBool(latch);
-// state_fio->FputBool(intstat);
-// state_fio->FputUint16(color_table);
-// state_fio->FputUint16(pattern_table);
-// state_fio->FputUint16(name_table);
-// state_fio->FputUint16(sprite_pattern);
-// state_fio->FputUint16(sprite_attrib);
-// state_fio->FputUint16(color_mask);
-// state_fio->FputUint16(pattern_mask);
-//#ifdef TMS9918A_SUPER_IMPOSE
-// if(_tms9918a_super_impose) {
-// state_fio->FputBool(now_super_impose);
-// }
-//#endif
-}
-bool TMS9918A::load_state(FILEIO* state_fio)
-{
- 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;
-// }
-// state_fio->Fread(vram, _VRAM_SIZE * sizeof(uint8_t), 1);
-// state_fio->Fread(regs, sizeof(regs), 1);
-// status_reg = state_fio->FgetUint8();
-// read_ahead = state_fio->FgetUint8();
-// first_byte = state_fio->FgetUint8();
-// vram_addr = state_fio->FgetUint16();
-// latch = state_fio->FgetBool();
-// intstat = state_fio->FgetBool();
-// color_table = state_fio->FgetUint16();
-// pattern_table = state_fio->FgetUint16();
-// name_table = state_fio->FgetUint16();
-// sprite_pattern = state_fio->FgetUint16();
-// sprite_attrib = state_fio->FgetUint16();
-// color_mask = state_fio->FgetUint16();
-// pattern_mask = state_fio->FgetUint16();
-//#ifdef TMS9918A_SUPER_IMPOSE
-// if(_tms9918a_super_impose) {
-// now_super_impose = state_fio->FgetBool();
-// }
-//#endif
- return true;
+ return true;
}
void write_signal(int id, uint32_t data, uint32_t mask);
//#endif
void event_vline(int v, int clock);
-#ifdef USE_DEBUGGER
+//#ifdef USE_DEBUGGER
uint32_t get_debug_data_addr_mask()
{
- return TMS9918A_VRAM_SIZE - 1;
+ return _VRAM_SIZE - 1;
}
void write_debug_data8(uint32_t addr, uint32_t data)
{
- vram[addr & (TMS9918A_VRAM_SIZE - 1)] = data;
+ vram[addr & (_VRAM_SIZE - 1)] = data;
}
uint32_t read_debug_data8(uint32_t addr)
{
- return vram[addr & (TMS9918A_VRAM_SIZE - 1)];
+ return vram[addr & (_VRAM_SIZE - 1)];
}
void get_debug_regs_info(_TCHAR *buffer, size_t buffer_len);
-#endif
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+//#endif
+ bool process_state(FILEIO* state_fio, bool loading);
+
// unique functions
void set_context_irq(DEVICE* device, int id, uint32_t mask)
{
#define STATE_VERSION 2
-#include "../statesub.h"
-
-void TMS9995::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
+bool TMS9995::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
#ifdef USE_DEBUGGER
- DECL_STATE_ENTRY_UINT64(total_count);
+ state_fio->StateUint64(total_count);
#endif
- DECL_STATE_ENTRY_INT32(count);
- DECL_STATE_ENTRY_INT32(period);
- DECL_STATE_ENTRY_UINT16(WP);
- DECL_STATE_ENTRY_UINT16(PC);
- DECL_STATE_ENTRY_UINT16(prevPC);
- DECL_STATE_ENTRY_UINT16(ST);
- DECL_STATE_ENTRY_1D_ARRAY(RAM, sizeof(RAM));
- DECL_STATE_ENTRY_UINT8(irq_level);
- DECL_STATE_ENTRY_UINT8(int_state);
- DECL_STATE_ENTRY_UINT8(int_latch);
- DECL_STATE_ENTRY_BOOL(int_pending);
- DECL_STATE_ENTRY_BOOL(int_enabled);
- DECL_STATE_ENTRY_UINT16(dec_count);
- DECL_STATE_ENTRY_UINT16(dec_interval);
- DECL_STATE_ENTRY_INT32(dec_timer);
- DECL_STATE_ENTRY_BOOL(dec_enabled);
- DECL_STATE_ENTRY_UINT16(mode);
- DECL_STATE_ENTRY_UINT8(lastparity);
- DECL_STATE_ENTRY_BOOL(nmi);
- DECL_STATE_ENTRY_BOOL(mid);
- DECL_STATE_ENTRY_BOOL(idle);
-
- leave_decl_state();
-}
-
-void TMS9995::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);
+ state_fio->StateInt32(count);
+ state_fio->StateInt32(period);
+ state_fio->StateUint16(WP);
+ state_fio->StateUint16(PC);
+ state_fio->StateUint16(prevPC);
+ state_fio->StateUint16(ST);
+ state_fio->StateBuffer(RAM, sizeof(RAM), 1);
+ state_fio->StateUint8(irq_level);
+ state_fio->StateUint8(int_state);
+ state_fio->StateUint8(int_latch);
+ state_fio->StateBool(int_pending);
+ state_fio->StateBool(int_enabled);
+ state_fio->StateUint16(dec_count);
+ state_fio->StateUint16(dec_interval);
+ state_fio->StateInt32(dec_timer);
+ state_fio->StateBool(dec_enabled);
+ state_fio->StateUint16(mode);
+ state_fio->StateUint8(lastparity);
+ state_fio->StateBool(nmi);
+ state_fio->StateBool(mid);
+ state_fio->StateBool(idle);
-//#ifdef USE_DEBUGGER
-// state_fio->FputUint64(total_count);
-//#endif
-// state_fio->FputInt32(count);
-// state_fio->FputInt32(period);
-// state_fio->FputUint16(WP);
-// state_fio->FputUint16(PC);
-// state_fio->FputUint16(prevPC);
-// state_fio->FputUint16(ST);
-// state_fio->Fwrite(RAM, sizeof(RAM), 1);
-// DECL_STATE_ENTRY_UINT8(irq_level);
-// DECL_STATE_ENTRY_UINT8(int_state);
-// state_fio->FputUint8(int_latch);
-// state_fio->FputBool(int_pending);
-// state_fio->FputBool(int_enabled);
-// state_fio->FputUint16(dec_count);
-// state_fio->FputUint16(dec_interval);
-// state_fio->FputInt32(dec_timer);
-// state_fio->FputBool(dec_enabled);
-// state_fio->FputUint16(mode);
-// state_fio->FputUint8(lastparity);
-// state_fio->FputBool(nmi);
-// state_fio->FputBool(mid);
-// state_fio->FputBool(idle);
-}
-
-bool TMS9995::load_state(FILEIO* state_fio)
-{
- 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;
-// }
#ifdef USE_DEBUGGER
-// total_count = prev_total_count = state_fio->FgetUint64();
- prev_total_count = total_count;
+ // post process
+ if(loading) {
+ prev_total_count = total_count;
+ }
#endif
-// count = state_fio->FgetInt32();
-// period = state_fio->FgetInt32();
-// WP = state_fio->FgetUint16();
-// PC = state_fio->FgetUint16();
-// prevPC = state_fio->FgetUint16();
-// ST = state_fio->FgetUint16();
-// state_fio->Fread(RAM, sizeof(RAM), 1);
-// irq_level = state_fio->FgetUint8();
-// int_state = state_fio->FgetUint8();
-// int_latch = state_fio->FgetUint8();
-// int_pending = state_fio->FgetBool();
-// int_enabled = state_fio->FgetBool();
-// dec_count = state_fio->FgetUint16();
-// dec_interval = state_fio->FgetUint16();
-// dec_timer = state_fio->FgetInt32();
-// dec_enabled = state_fio->FgetBool();
-// mode = state_fio->FgetUint16();
-// lastparity = state_fio->FgetUint8();
-// nmi = state_fio->FgetBool();
-// mid = state_fio->FgetBool();
-// idle = state_fio->FgetBool();
- return true;
+ return true;
}
-
void get_debug_regs_info(_TCHAR *buffer, size_t buffer_len);
int debug_dasm(uint32_t pc, _TCHAR *buffer, size_t buffer_len);
#endif
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void set_context_mem(DEVICE* device)
{
#define STATE_VERSION 1
-#include "../statesub.h"
-
-void UPD16434::decl_state()
+bool UPD16434::process_state(FILEIO* state_fio, bool loading)
{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_UINT8(pointer);
- DECL_STATE_ENTRY_UINT8(mode);
- DECL_STATE_ENTRY_1D_ARRAY(imem, sizeof(imem));
-
- leave_decl_state();
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(pointer);
+ state_fio->StateUint8(mode);
+ state_fio->StateBuffer(imem, sizeof(imem), 1);
+ return true;
}
-void UPD16434::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);
-
-// state_fio->FputUint8(pointer);
-// state_fio->FputUint8(mode);
-// state_fio->Fwrite(imem, sizeof(imem), 1);
-}
-
-bool UPD16434::load_state(FILEIO* state_fio)
-{
- 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;
-// }
-// pointer = state_fio->FgetUint8();
-// mode = state_fio->FgetUint8();
-// state_fio->Fread(imem, sizeof(imem), 1);
- return true;
-}
-
// common functions
void initialize();
void reset();
- void decl_state();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void data(uint8_t data);