diff vdp.c @ 65:aef6302770c2

Fix issue in which VDP would have trouble emptying FIFO because the VDP cycle count got reset at end of frame.
author Mike Pavone <pavone@retrodev.com>
date Wed, 19 Dec 2012 22:15:16 -0800
parents a6dd5b7a971b
children 108e587165c0
line wrap: on
line diff
--- 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