# HG changeset patch # User Mike Pavone # Date 1355984116 28800 # Node ID aef6302770c2f4728207a7e20e0b5058a52b81da # Parent 2b1a65f4b85d7f1c4d6982dc0ca5fd90b282d794 Fix issue in which VDP would have trouble emptying FIFO because the VDP cycle count got reset at end of frame. diff -r 2b1a65f4b85d -r aef6302770c2 vdp.c --- a/vdp.c Wed Dec 19 21:25:39 2012 -0800 +++ b/vdp.c Wed Dec 19 22:15:16 2012 -0800 @@ -195,7 +195,7 @@ //printf("VRAM Write: %X to %X\n", start->value, context->address ^ 1); context->vdpmem[context->address ^ 1] = start->value; } else { - //printf("VRAM Write: %X to %X\n", start->value >> 8, context->address); + //printf("VRAM Write High: %X to %X\n", start->value >> 8, context->address); context->vdpmem[context->address] = start->value >> 8; start->partial = 1; //skip auto-increment and removal of entry from fifo @@ -920,9 +920,9 @@ { //printf("data port write: %X\n", value); context->flags &= ~FLAG_PENDING; - /*if (context->fifo_cur == context->fifo_end) { + if (context->fifo_cur == context->fifo_end) { printf("FIFO full, waiting for space before next write at cycle %X\n", context->cycles); - }*/ + } while (context->fifo_cur == context->fifo_end) { vdp_run_context(context, context->cycles + ((context->latched_mode & BIT_H40) ? 16 : 20)); } @@ -981,6 +981,18 @@ return value; } +void vdp_adjust_cycles(vdp_context * context, uint32_t deduction) +{ + context->cycles -= deduction; + for(fifo_entry * start = (context->fifo_end - FIFO_SIZE); start < context->fifo_cur; start++) { + if (start->cycle >= deduction) { + start->cycle -= deduction; + } else { + start->cycle = 0; + } + } +} + #define GST_VDP_REGS 0xFA #define GST_VDP_MEM 0x12478 diff -r 2b1a65f4b85d -r aef6302770c2 vdp.h --- a/vdp.h Wed Dec 19 21:25:39 2012 -0800 +++ b/vdp.h Wed Dec 19 22:15:16 2012 -0800 @@ -107,5 +107,6 @@ void vdp_data_port_write(vdp_context * context, uint16_t value); uint16_t vdp_control_port_read(vdp_context * context); uint16_t vdp_data_port_read(vdp_context * context); +void vdp_adjust_cycles(vdp_context * context, uint32_t deduction); #endif //VDP_H_