comparison 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
comparison
equal deleted inserted replaced
1088:c0a026e974f4 1089:87597a048d38
5 #include "m68k_core.h" 5 #include "m68k_core.h"
6 #include "jaguar.h" 6 #include "jaguar.h"
7 #include "util.h" 7 #include "util.h"
8 #include "debug.h" 8 #include "debug.h"
9 #include "config.h" 9 #include "config.h"
10 #include "render.h"
10 11
11 //BIOS Area Memory map 12 //BIOS Area Memory map
12 // 10 00 00 - 10 04 00 : Video mode/ Memory control registers 13 // 10 00 00 - 10 04 00 : Video mode/ Memory control registers
13 // 10 04 00 - 10 08 00 : CLUT 14 // 10 04 00 - 10 08 00 : CLUT
14 // 10 08 00 - 10 10 00 : Line buffer A 15 // 10 08 00 - 10 10 00 : Line buffer A
236 fprintf(stderr, "Unhandled read from wave table ROM - %X\n", address); 237 fprintf(stderr, "Unhandled read from wave table ROM - %X\n", address);
237 } 238 }
238 return 0xFFFF; 239 return 0xFFFF;
239 } 240 }
240 241
242 m68k_context * sync_components(m68k_context * context, uint32_t address)
243 {
244 jaguar_context *system = context->system;
245 jag_video_run(system->video, context->current_cycle);
246 if (context->current_cycle > 0x10000000) {
247 context->current_cycle -= 0x10000000;
248 system->video->cycles -= 0x10000000;
249 }
250 return context;
251 }
252
241 253
242 void *rom0_write_m68k(uint32_t address, void *context, uint16_t value) 254 void *rom0_write_m68k(uint32_t address, void *context, uint16_t value)
243 { 255 {
256 sync_components(context, 0);
244 rom0_write_16(address, ((m68k_context *)context)->system, value); 257 rom0_write_16(address, ((m68k_context *)context)->system, value);
245 return context; 258 return context;
246 } 259 }
247 260
248 uint16_t rom0_read_m68k(uint32_t address, void *context) 261 uint16_t rom0_read_m68k(uint32_t address, void *context)
249 { 262 {
263 sync_components(context, 0);
250 return rom0_read_16(address, ((m68k_context *)context)->system); 264 return rom0_read_16(address, ((m68k_context *)context)->system);
251 } 265 }
252 266
253 void *rom0_write_m68k_b(uint32_t address, void *context, uint8_t value) 267 void *rom0_write_m68k_b(uint32_t address, void *context, uint8_t value)
254 { 268 {
269 sync_components(context, 0);
255 //seems unlikely these areas support byte access 270 //seems unlikely these areas support byte access
256 uint16_t value16 = value; 271 uint16_t value16 = value;
257 value16 |= value16 << 8; 272 value16 |= value16 << 8;
258 rom0_write_16(address, ((m68k_context *)context)->system, value16); 273 rom0_write_16(address, ((m68k_context *)context)->system, value16);
259 return context; 274 return context;
260 } 275 }
261 276
262 uint8_t rom0_read_m68k_b(uint32_t address, void *context) 277 uint8_t rom0_read_m68k_b(uint32_t address, void *context)
263 { 278 {
279 sync_components(context, 0);
264 uint16_t value = rom0_read_16(address, ((m68k_context *)context)->system); 280 uint16_t value = rom0_read_16(address, ((m68k_context *)context)->system);
265 if (address & 1) { 281 if (address & 1) {
266 return value; 282 return value;
267 } 283 }
268 return value >> 8; 284 return value >> 8;
269 }
270
271 m68k_context * sync_components(m68k_context * context, uint32_t address)
272 {
273 jaguar_context *system = context->system;
274 jag_video_run(system->video, context->current_cycle);
275 if (context->current_cycle > 0x10000000) {
276 context->current_cycle -= 0x10000000;
277 system->video->cycles -= 0x10000000;
278 }
279 return context;
280 } 285 }
281 286
282 m68k_context *handle_m68k_reset(m68k_context *context) 287 m68k_context *handle_m68k_reset(m68k_context *context)
283 { 288 {
284 puts("M68K executed RESET"); 289 puts("M68K executed RESET");
365 uint16_t *cart = load_rom(argv[2], &cart_size); 370 uint16_t *cart = load_rom(argv[2], &cart_size);
366 if (!bios_size) { 371 if (!bios_size) {
367 fatal_error("Failed to read cart from %s\n", argv[2]); 372 fatal_error("Failed to read cart from %s\n", argv[2]);
368 } 373 }
369 jaguar_context *system = init_jaguar(bios, bios_size, cart, cart_size); 374 jaguar_context *system = init_jaguar(bios, bios_size, cart, cart_size);
375 render_init(640, 480, "BlastJag", 60, 0);
370 m68k_reset(system->m68k); 376 m68k_reset(system->m68k);
371 return 0; 377 return 0;
372 } 378 }