Mercurial > repos > blastem
comparison blastem.c @ 333:f16136a3835d
Update Z80 vint timing
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 14 May 2013 00:40:10 -0700 |
parents | 1b00258b1f29 |
children | 14a937097c2b |
comparison
equal
deleted
inserted
replaced
332:671a5be51522 | 333:f16136a3835d |
---|---|
160 #endif | 160 #endif |
161 | 161 |
162 void sync_z80(z80_context * z_context, uint32_t mclks) | 162 void sync_z80(z80_context * z_context, uint32_t mclks) |
163 { | 163 { |
164 if (z80_enabled && !reset && !busreq) { | 164 if (z80_enabled && !reset && !busreq) { |
165 genesis_context * gen = z_context->system; | |
165 if (need_reset) { | 166 if (need_reset) { |
166 z80_reset(z_context); | 167 z80_reset(z_context); |
167 need_reset = 0; | 168 need_reset = 0; |
168 } | 169 } |
169 z_context->sync_cycle = mclks / MCLKS_PER_Z80; | 170 z_context->sync_cycle = mclks / MCLKS_PER_Z80; |
171 uint32_t vint_cycle = vdp_next_vint_z80(gen->vdp) / MCLKS_PER_Z80; | |
170 while (z_context->current_cycle < z_context->sync_cycle) { | 172 while (z_context->current_cycle < z_context->sync_cycle) { |
171 if (z_context->iff1 && z_context->current_cycle < ZVINT_CYCLE) { | 173 if (z_context->iff1 && z_context->current_cycle < ZVINT_CYCLE) { |
172 z_context->int_cycle = ZVINT_CYCLE; | 174 z_context->int_cycle = vint_cycle; |
173 } | 175 } |
174 z_context->target_cycle = z_context->sync_cycle < z_context->int_cycle ? z_context->sync_cycle : z_context->int_cycle; | 176 z_context->target_cycle = z_context->sync_cycle < z_context->int_cycle ? z_context->sync_cycle : z_context->int_cycle; |
175 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); | 177 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); |
176 z80_run(z_context); | 178 z80_run(z_context); |
177 dprintf("Z80 ran to cycle %d\n", z_context->current_cycle); | 179 dprintf("Z80 ran to cycle %d\n", z_context->current_cycle); |