diff jaguar.c @ 1089:87597a048d38

Initial implementation of video output hardware
author Michael Pavone <pavone@retrodev.com>
date Wed, 12 Oct 2016 09:39:52 -0700
parents c0a026e974f4
children a68274a25e2f
line wrap: on
line diff
--- a/jaguar.c	Sat Oct 08 23:49:20 2016 -0700
+++ b/jaguar.c	Wed Oct 12 09:39:52 2016 -0700
@@ -7,6 +7,7 @@
 #include "util.h"
 #include "debug.h"
 #include "config.h"
+#include "render.h"
 
 //BIOS Area Memory map
 // 10 00 00 - 10 04 00 : Video mode/ Memory control registers
@@ -238,20 +239,34 @@
 	return 0xFFFF;
 }
 
+m68k_context * sync_components(m68k_context * context, uint32_t address)
+{
+	jaguar_context *system = context->system;
+	jag_video_run(system->video, context->current_cycle);
+	if (context->current_cycle > 0x10000000) {
+		context->current_cycle -= 0x10000000;
+		system->video->cycles -= 0x10000000;
+	}
+	return context;
+}
+
 
 void *rom0_write_m68k(uint32_t address, void *context, uint16_t value)
 {
+	sync_components(context, 0);
 	rom0_write_16(address, ((m68k_context *)context)->system, value);
 	return context;
 }
 
 uint16_t rom0_read_m68k(uint32_t address, void *context)
 {
+	sync_components(context, 0);
 	return rom0_read_16(address, ((m68k_context *)context)->system);
 }
 
 void *rom0_write_m68k_b(uint32_t address, void *context, uint8_t value)
 {
+	sync_components(context, 0);
 	//seems unlikely these areas support byte access
 	uint16_t value16 = value;
 	value16 |= value16 << 8;
@@ -261,6 +276,7 @@
 
 uint8_t rom0_read_m68k_b(uint32_t address, void *context)
 {
+	sync_components(context, 0);
 	uint16_t value = rom0_read_16(address, ((m68k_context *)context)->system);
 	if (address & 1) {
 		return value;
@@ -268,17 +284,6 @@
 	return value >> 8;
 }
 
-m68k_context * sync_components(m68k_context * context, uint32_t address)
-{
-	jaguar_context *system = context->system;
-	jag_video_run(system->video, context->current_cycle);
-	if (context->current_cycle > 0x10000000) {
-		context->current_cycle -= 0x10000000;
-		system->video->cycles -= 0x10000000;
-	}
-	return context;
-}
-
 m68k_context *handle_m68k_reset(m68k_context *context)
 {
 	puts("M68K executed RESET");
@@ -367,6 +372,7 @@
 		fatal_error("Failed to read cart from %s\n", argv[2]);
 	}
 	jaguar_context *system = init_jaguar(bios, bios_size, cart, cart_size);
+	render_init(640, 480, "BlastJag", 60, 0);
 	m68k_reset(system->m68k);
 	return 0;
 }