Mercurial > repos > blastem
comparison jag_video.c @ 1097:faa3a4617f62
Get Jaguar video interrupt working
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 05 Nov 2016 00:23:11 -0700 |
parents | a68274a25e2f |
children | 4a726e339d6f |
comparison
equal
deleted
inserted
replaced
1096:1ab30d427db8 | 1097:faa3a4617f62 |
---|---|
184 OBJ_SCALED, | 184 OBJ_SCALED, |
185 OBJ_GPU, | 185 OBJ_GPU, |
186 OBJ_BRANCH, | 186 OBJ_BRANCH, |
187 OBJ_STOP | 187 OBJ_STOP |
188 }; | 188 }; |
189 | |
190 uint32_t jag_cycles_to_halfline(jag_video *context, uint32_t target) | |
191 { | |
192 uint32_t cycles = context->regs[VID_HPERIOD] - (context->regs[VID_HCOUNT & 0x3FF]); | |
193 uint32_t num_lines; | |
194 if (context->regs[VID_VCOUNT] < target) { | |
195 num_lines = target - 1 - context->regs[VID_VCOUNT]; | |
196 } else { | |
197 num_lines = target + context->regs[VID_VPERIOD] - context->regs[VID_VCOUNT]; | |
198 } | |
199 cycles += num_lines * context->regs[VID_HPERIOD]; | |
200 return cycles; | |
201 } | |
202 | |
203 uint32_t jag_next_vid_interrupt(jag_video *context) | |
204 { | |
205 if (context->regs[VID_VINT] > context->regs[VID_VPERIOD]) { | |
206 return 0xFFFFFFF; | |
207 } | |
208 return context->cycles + jag_cycles_to_halfline(context, context->regs[VID_VINT]); | |
209 } | |
189 | 210 |
190 void op_run(jag_video *context) | 211 void op_run(jag_video *context) |
191 { | 212 { |
192 while (context->op.cycles < context->cycles) | 213 while (context->op.cycles < context->cycles) |
193 { | 214 { |
545 //increment half-line counter | 566 //increment half-line counter |
546 if (context->regs[VID_VCOUNT] == context->regs[VID_VPERIOD]) { | 567 if (context->regs[VID_VCOUNT] == context->regs[VID_VPERIOD]) { |
547 context->regs[VID_VCOUNT] = 0; | 568 context->regs[VID_VCOUNT] = 0; |
548 } else { | 569 } else { |
549 context->regs[VID_VCOUNT]++; | 570 context->regs[VID_VCOUNT]++; |
571 if (context->regs[VID_VCOUNT] == context->regs[VID_VINT]) { | |
572 context->cpu_int_pending |= BIT_CPU_VID_INT_ENABLED; | |
573 } | |
550 } | 574 } |
551 } else { | 575 } else { |
552 context->regs[VID_HCOUNT]++; | 576 context->regs[VID_HCOUNT]++; |
553 } | 577 } |
554 | 578 |