void MB61VH010::do_pset(uint32_t addr)
{
int i;
- uint32_t raddr = addr; // Use banked ram.
uint8_t bitmask[4] = {0};
uint8_t srcdata[4] = {0};
const uint8_t mask_p[4] = {mask_reg, mask_reg, mask_reg, mask_reg};
- int planes_b = planes;
uint32_t *pbm = (uint32_t *)bitmask;
uint32_t *pmp = (uint32_t *)mask_p;
uint32_t *psd = (uint32_t *)srcdata;
- for(i = 0; i < 4; i++) { // planes_b
+ for(i = 0; i < 4; i++) { // planes
//if((bank_disable_reg & (1 << i)) != 0) {
if(disable_flags[i]) continue;
//}
void MB61VH010::do_compare(uint32_t addr)
{
- uint32_t offset = 0x4000;
uint8_t r, g, b;
uint8_t disables = ~bank_disable_reg;
int xcount;
int ycount;
//bool updated = false;
- uint16_t tmp8a;
- uint8_t vmask[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
+ static const uint8_t vmask[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
double usec;
oldaddr = 0xffffffff;
alu_addr = 0xffffffff;
mask_reg = 0xff;
//if(total_bytes >= 8) { // Only greater than 8bytes.
usec = (double)total_bytes / 16.0;
- if(eventid_busy >= 0) cancel_event(this, eventid_busy) ;
- register_event(this, EVENT_MB61VH010_BUSY_OFF, usec, false, &eventid_busy);
- //} else {
- // busy_flag = false;
- //}
+ if(usec < 1.0) {
+ busy_flag = false; // ToDo
+ } else {
+ if(eventid_busy >= 0) cancel_event(this, eventid_busy) ;
+ register_event(this, EVENT_MB61VH010_BUSY_OFF, usec, false, &eventid_busy);
+ }
}
}
}
-#define STATE_VERSION 1
-void MB61VH010::save_state(FILEIO *state_fio)
-{
- int i;
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
- this->out_debug_log(_T("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);
+#define STATE_VERSION 2
- state_fio->FputUint32_BE(total_bytes);
- state_fio->FputUint32_BE(oldaddr);
- state_fio->FputUint32_BE(alu_addr);
+bool MB61VH010::decl_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->StateValue(command_reg);
+ state_fio->StateValue(color_reg);
+ state_fio->StateValue(mask_reg);
+ state_fio->StateValue(cmp_status_reg);
+ state_fio->StateValue(bank_disable_reg);
+ state_fio->StateValue(multi_page);
+ state_fio->StateValue(direct_access_offset);
+
+ state_fio->StateArray(cmp_color_data, sizeof(cmp_color_data), 1);
+ state_fio->StateArray(tile_reg, sizeof(tile_reg), 1);
+
+ state_fio->StateValue(line_addr_offset.d);
+ state_fio->StateValue(line_pattern.d);
+ state_fio->StateValue(line_xbegin.d);
+ state_fio->StateValue(line_ybegin.d);
+ state_fio->StateValue(line_xend.d);
+ state_fio->StateValue(line_yend.d);
+
+ state_fio->StateValue(busy_flag);
+ state_fio->StateValue(line_style.d);
+
+ state_fio->StateValue(total_bytes);
+ state_fio->StateValue(oldaddr);
+ state_fio->StateValue(alu_addr);
+
+ state_fio->StateValue(planes);
+ state_fio->StateValue(is_400line);
+ state_fio->StateValue(screen_width);
+ state_fio->StateValue(screen_height);
+
+ state_fio->StateValue(eventid_busy);
- state_fio->FputUint32_BE(planes);
- state_fio->FputBool(is_400line);
- state_fio->FputUint32_BE(screen_width);
- state_fio->FputUint32_BE(screen_height);
+ return true;
+}
- state_fio->FputUint16_BE(line_style.w.l);
- }
-
+void MB61VH010::save_state(FILEIO *state_fio)
+{
+ decl_state(state_fio, false);
+ out_debug_log(_T("Save State: MB61VH010 : id=%d ver=%d\n"), this_device_id, STATE_VERSION);
}
bool MB61VH010::load_state(FILEIO *state_fio)
{
- uint32_t version = state_fio->FgetUint32();
- int i;
- this->out_debug_log(_T("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();
- // Update
- for(i = 0; i < 4; i++) {
- disable_flags[i] = ((bank_disable_reg & (1 << i)) != 0) ? true : false;
- }
- for(i = 0; i < 4; i++) {
- multi_flags[i] = (((1 << i) & multi_page) != 0) ? true : false;
- }
+ bool mb = decl_state(state_fio, true);
+ out_debug_log(_T("Load State: MB61VH010 : id=%d stat=%s"), this_device_id, (mb) ? _T("OK") : _T("NG"));
+ if(!mb) return false;
+
+ line_style.w.h = 0;
+ // Update
+ for(int i = 0; i < 4; i++) {
+ disable_flags[i] = ((bank_disable_reg & (1 << i)) != 0) ? true : false;
}
- if(version != STATE_VERSION) return false;
- return true;
+ for(int i = 0; i < 4; i++) {
+ multi_flags[i] = (((1 << i) & multi_page) != 0) ? true : false;
+ }
+
+ return true;
}