comparison blastem.c @ 402:de2c085ce174

Assert z80 interrupt longer so that they are not missed when they should not be
author Mike Pavone <pavone@retrodev.com>
date Sat, 15 Jun 2013 23:50:59 -0700
parents c26e48a93fa3
children 88fa2ad53e64
comparison
equal deleted inserted replaced
401:f54af24aad1d 402:de2c085ce174
168 #else 168 #else
169 #define dprintf 169 #define dprintf
170 #define dputs 170 #define dputs
171 #endif 171 #endif
172 172
173 #define Z80_VINT_DURATION 128
174
173 void sync_z80(z80_context * z_context, uint32_t mclks) 175 void sync_z80(z80_context * z_context, uint32_t mclks)
174 { 176 {
175 if (z80_enabled && !reset && !busreq) { 177 if (z80_enabled && !reset && !busreq) {
176 genesis_context * gen = z_context->system; 178 genesis_context * gen = z_context->system;
177 if (need_reset) { 179 if (need_reset) {
179 need_reset = 0; 181 need_reset = 0;
180 } 182 }
181 z_context->sync_cycle = mclks / MCLKS_PER_Z80; 183 z_context->sync_cycle = mclks / MCLKS_PER_Z80;
182 uint32_t vint_cycle = vdp_next_vint_z80(gen->vdp) / MCLKS_PER_Z80; 184 uint32_t vint_cycle = vdp_next_vint_z80(gen->vdp) / MCLKS_PER_Z80;
183 while (z_context->current_cycle < z_context->sync_cycle) { 185 while (z_context->current_cycle < z_context->sync_cycle) {
184 if (z_context->iff1 && z_context->current_cycle < vint_cycle) { 186 if (z_context->iff1 && z_context->current_cycle < (vint_cycle + Z80_VINT_DURATION)) {
185 z_context->int_cycle = vint_cycle < z_context->int_enable_cycle ? z_context->int_enable_cycle : vint_cycle; 187 z_context->int_cycle = vint_cycle < z_context->int_enable_cycle ? z_context->int_enable_cycle : vint_cycle;
186 } 188 }
187 z_context->target_cycle = z_context->sync_cycle < z_context->int_cycle ? z_context->sync_cycle : z_context->int_cycle; 189 z_context->target_cycle = z_context->sync_cycle < z_context->int_cycle ? z_context->sync_cycle : z_context->int_cycle;
188 dprintf("Running Z80 from cycle %d to cycle %d. Native PC: %p\n", z_context->current_cycle, z_context->sync_cycle, z_context->native_pc); 190 dprintf("Running Z80 from cycle %d to cycle %d. Native PC: %p\n", z_context->current_cycle, z_context->sync_cycle, z_context->native_pc);
189 z80_run(z_context); 191 z80_run(z_context);