changeset 344:b46771135442

Handle busack across frame boundary
author Mike Pavone <pavone@retrodev.com>
date Sun, 19 May 2013 11:38:15 -0700
parents 467bfa17004a
children 29d2ca563499
files blastem.c runtime.S
diffstat 2 files changed, 25 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/blastem.c	Sat May 18 11:44:42 2013 -0700
+++ b/blastem.c	Sun May 19 11:38:15 2013 -0700
@@ -208,6 +208,14 @@
 		vdp_adjust_cycles(v_context, mclks_per_frame);
 		io_adjust_cycles(&gamepad_1, context->current_cycle, mclks_per_frame/MCLKS_PER_68K);
 		io_adjust_cycles(&gamepad_2, context->current_cycle, mclks_per_frame/MCLKS_PER_68K);
+		if (busack_cycle != CYCLE_NEVER) {
+			if (busack_cycle > mclks_per_frame/MCLKS_PER_68K) {
+				busack_cycle -= mclks_per_frame/MCLKS_PER_68K;
+			} else {
+				busack_cycle = CYCLE_NEVER;
+				busack = new_busack;
+			}
+		}
 		context->current_cycle -= mclks_per_frame/MCLKS_PER_68K;
 		if (z_context->current_cycle >= mclks_per_frame/MCLKS_PER_Z80) {
 			z_context->current_cycle -= mclks_per_frame/MCLKS_PER_Z80;
@@ -257,6 +265,14 @@
 						vdp_adjust_cycles(v_context, mclks_per_frame);
 						io_adjust_cycles(&gamepad_1, v_context->cycles/MCLKS_PER_68K, mclks_per_frame/MCLKS_PER_68K);
 						io_adjust_cycles(&gamepad_2, v_context->cycles/MCLKS_PER_68K, mclks_per_frame/MCLKS_PER_68K);
+						if (busack_cycle != CYCLE_NEVER) {
+							if (busack_cycle > mclks_per_frame/MCLKS_PER_68K) {
+								busack_cycle -= mclks_per_frame/MCLKS_PER_68K;
+							} else {
+								busack_cycle = CYCLE_NEVER;
+								busack = new_busack;
+							}
+						}
 					}
 				}
 				context->current_cycle = v_context->cycles / MCLKS_PER_68K;
@@ -274,6 +290,14 @@
 							vdp_adjust_cycles(v_context, mclks_per_frame);
 							io_adjust_cycles(&gamepad_1, v_context->cycles/MCLKS_PER_68K, mclks_per_frame/MCLKS_PER_68K);
 							io_adjust_cycles(&gamepad_2, v_context->cycles/MCLKS_PER_68K, mclks_per_frame/MCLKS_PER_68K);
+							if (busack_cycle != CYCLE_NEVER) {
+								if (busack_cycle > mclks_per_frame/MCLKS_PER_68K) {
+									busack_cycle -= mclks_per_frame/MCLKS_PER_68K;
+								} else {
+									busack_cycle = CYCLE_NEVER;
+									busack = new_busack;
+								}
+							}
 						}
 					}
 					if (blocked < 0) {
--- a/runtime.S	Sat May 18 11:44:42 2013 -0700
+++ b/runtime.S	Sun May 19 11:38:15 2013 -0700
@@ -485,11 +485,8 @@
 	jnb do_limit
 	add $4, %eax
 	ret
-do_limit:
-	
+do_limit:	
 	call handle_cycle_limit
-	pop %rdi
-	pop %rcx
 	add $4, %eax
 	ret