*/\r
\r
#include "tms9918a.h"\r
+#include "../fileio.h"\r
\r
#define ADDR_MASK (TMS9918A_VRAM_SIZE - 1)\r
\r
}\r
}\r
\r
+#define STATE_VERSION 1\r
+\r
+void TMS9918A::save_state(FILEIO* state_fio)\r
+{\r
+ state_fio->FputUint32(STATE_VERSION);\r
+ state_fio->FputInt32(this_device_id);\r
+ \r
+ state_fio->Fwrite(vram, sizeof(vram), 1);\r
+ state_fio->Fwrite(regs, sizeof(regs), 1);\r
+ state_fio->FputUint8(status_reg);\r
+ state_fio->FputUint8(read_ahead);\r
+ state_fio->FputUint8(first_byte);\r
+ state_fio->FputUint16(vram_addr);\r
+ state_fio->FputBool(latch);\r
+ state_fio->FputBool(intstat);\r
+ state_fio->FputUint16(color_table);\r
+ state_fio->FputUint16(pattern_table);\r
+ state_fio->FputUint16(name_table);\r
+ state_fio->FputUint16(sprite_pattern);\r
+ state_fio->FputUint16(sprite_attrib);\r
+ state_fio->FputUint16(color_mask);\r
+ state_fio->FputUint16(pattern_mask);\r
+#ifdef TMS9918A_SUPER_IMPOSE\r
+ state_fio->FputBool(now_super_impose);\r
+#endif\r
+}\r
+\r
+bool TMS9918A::load_state(FILEIO* state_fio)\r
+{\r
+ if(state_fio->FgetUint32() != STATE_VERSION) {\r
+ return false;\r
+ }\r
+ if(state_fio->FgetInt32() != this_device_id) {\r
+ return false;\r
+ }\r
+ state_fio->Fread(vram, sizeof(vram), 1);\r
+ state_fio->Fread(regs, sizeof(regs), 1);\r
+ status_reg = state_fio->FgetUint8();\r
+ read_ahead = state_fio->FgetUint8();\r
+ first_byte = state_fio->FgetUint8();\r
+ vram_addr = state_fio->FgetUint16();\r
+ latch = state_fio->FgetBool();\r
+ intstat = state_fio->FgetBool();\r
+ color_table = state_fio->FgetUint16();\r
+ pattern_table = state_fio->FgetUint16();\r
+ name_table = state_fio->FgetUint16();\r
+ sprite_pattern = state_fio->FgetUint16();\r
+ sprite_attrib = state_fio->FgetUint16();\r
+ color_mask = state_fio->FgetUint16();\r
+ pattern_mask = state_fio->FgetUint16();\r
+#ifdef TMS9918A_SUPER_IMPOSE\r
+ now_super_impose = state_fio->FgetBool();\r
+#endif\r
+ return true;\r
+}\r
+\r