+ if(planes >= 4) planes = 4;
+}
+
+#define STATE_VERSION 1
+void MB61VH010::save_state(FILEIO *state_fio)
+{
+ int i;
+ state_fio->FputUint32(STATE_VERSION);
+ state_fio->FputInt32(this_device_id);
+ p_emu->out_debug_log("Save State: MB61VH010 : id=%d ver=%d\n", this_device_id, STATE_VERSION);
+
+ { // V1
+ state_fio->FputUint8(command_reg);
+ state_fio->FputUint8(color_reg);
+ state_fio->FputUint8(mask_reg);
+ state_fio->FputUint8(cmp_status_reg);
+ for(i = 0; i < 8; i++) state_fio->FputUint8(cmp_color_data[i]);
+ state_fio->FputUint8(bank_disable_reg);
+ for(i = 0; i < 4; i++) state_fio->FputUint8(tile_reg[i]);
+ state_fio->FputUint8(multi_page);
+
+ state_fio->FputUint32_BE(line_addr_offset.d);
+ state_fio->FputUint16_BE(line_pattern.w.l);
+ state_fio->FputUint16_BE(line_xbegin.w.l);
+ state_fio->FputUint16_BE(line_ybegin.w.l);
+ state_fio->FputUint16_BE(line_xend.w.l);
+ state_fio->FputUint16_BE(line_yend.w.l);
+
+ state_fio->FputBool(busy_flag);
+ state_fio->FputInt32_BE(eventid_busy);
+
+ state_fio->FputUint32_BE(total_bytes);
+ state_fio->FputUint32_BE(oldaddr);
+ state_fio->FputUint32_BE(alu_addr);
+
+ state_fio->FputUint32_BE(planes);
+ state_fio->FputBool(is_400line);
+ state_fio->FputUint32_BE(screen_width);
+ state_fio->FputUint32_BE(screen_height);
+
+ state_fio->FputUint16_BE(line_style.w.l);
+ }
+
+}
+
+bool MB61VH010::load_state(FILEIO *state_fio)
+{
+ uint32_t version = state_fio->FgetUint32();
+ int i;
+ p_emu->out_debug_log("Load State: MB61VH010 : id=%d ver=%d\n", this_device_id, version);
+ if(this_device_id != state_fio->FgetInt32()) return false;
+ if(version >= 1) {
+ command_reg = state_fio->FgetUint8();
+ color_reg = state_fio->FgetUint8();
+ mask_reg = state_fio->FgetUint8();
+ cmp_status_reg = state_fio->FgetUint8();
+ for(i = 0; i < 8; i++) cmp_color_data[i] = state_fio->FgetUint8();
+ bank_disable_reg = state_fio->FgetUint8();
+ for(i = 0; i < 4; i++) tile_reg[i] = state_fio->FgetUint8();
+ multi_page = state_fio->FgetUint8();
+
+ line_addr_offset.d = state_fio->FgetUint32_BE();
+ line_pattern.d = 0;
+ line_xbegin.d = 0;
+ line_ybegin.d = 0;
+ line_xend.d = 0;
+ line_yend.d = 0;
+
+ line_pattern.w.l = state_fio->FgetUint16_BE();
+ line_xbegin.w.l = state_fio->FgetUint16_BE();
+ line_ybegin.w.l = state_fio->FgetUint16_BE();
+ line_xend.w.l = state_fio->FgetUint16_BE();
+ line_yend.w.l = state_fio->FgetUint16_BE();
+
+ busy_flag = state_fio->FgetBool();
+ eventid_busy = state_fio->FgetInt32_BE();
+
+ total_bytes = state_fio->FgetUint32_BE();
+ oldaddr = state_fio->FgetUint32_BE();
+ alu_addr = state_fio->FgetUint32_BE();
+
+ planes = state_fio->FgetUint32_BE();
+ is_400line = state_fio->FgetBool();
+ screen_width = state_fio->FgetUint32_BE();
+ screen_height = state_fio->FgetUint32_BE();
+
+ line_style.d = 0;
+ line_style.w.l = state_fio->FgetUint16_BE();
+ }
+ if(version != STATE_VERSION) return false;
+ return true;