changeset 1087:6433d4d05934

Added placeholder code for video output hardware/object processor
author Michael Pavone <pavone@retrodev.com>
date Fri, 07 Oct 2016 18:27:38 -0700
parents f0a1e0a2263c
children c0a026e974f4
files Makefile jag_video.c jag_video.h jaguar.c jaguar.h
diffstat 5 files changed, 52 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Thu Oct 06 22:25:12 2016 -0700
+++ b/Makefile	Fri Oct 07 18:27:38 2016 -0700
@@ -160,7 +160,7 @@
 	$(CC) -o $@ $^ $(LDFLAGS)
 	$(FIXUP) ./$@
 	
-blastjag$(EXE) : jaguar.o render_sdl.o $(M68KOBJS) $(TRANSOBJS) $(CONFIGOBJS)
+blastjag$(EXE) : jaguar.o jag_video.o render_sdl.o $(M68KOBJS) $(TRANSOBJS) $(CONFIGOBJS)
 	$(CC) -o $@ $^ $(LDFLAGS)
 
 dis$(EXE) : dis.o 68kinst.o tern.o vos_program_module.o
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jag_video.c	Fri Oct 07 18:27:38 2016 -0700
@@ -0,0 +1,13 @@
+#include <stdint.h>
+#include <stdlib.h>
+#include "jag_video.h"
+
+jag_video *jag_video_init(void)
+{
+	return calloc(1, sizeof(jag_video));
+}
+
+void jag_video_run(jag_video *context, uint32_t target_cycle)
+{
+	context->cycles = target_cycle;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jag_video.h	Fri Oct 07 18:27:38 2016 -0700
@@ -0,0 +1,22 @@
+#ifndef JAG_VIDEO_H_
+#define JAG_VIDEO_H_
+
+#define JAG_VIDEO_REGS 0x2E
+#define LINEBUFFER_WORDS 720
+
+typedef struct {
+	uint16_t regs[JAG_VIDEO_REGS];
+	
+	uint16_t     clut[256];
+	uint16_t     line_buffer_a[LINEBUFFER_WORDS];
+	uint16_t     line_buffer_b[LINEBUFFER_WORDS];
+	uint16_t     *write_line_buffer;
+	uint16_t     *read_line_buffer;
+	
+	uint32_t cycles;
+} jag_video;
+
+jag_video *jag_video_init(void);
+void jag_video_run(jag_video *context, uint32_t target_cycle);
+
+#endif //JAG_VIDEO_H_
--- a/jaguar.c	Thu Oct 06 22:25:12 2016 -0700
+++ b/jaguar.c	Fri Oct 07 18:27:38 2016 -0700
@@ -102,25 +102,25 @@
 			} else if (address < 0x100800) {
 				//CLUT
 				address = address >> 1 & 255;
-				system->clut[address] = value;
+				system->video->clut[address] = value;
 			} else {
 				//Line buffer A
 				address = address >> 1 & 0x3FF;
 				if (address < LINEBUFFER_WORDS) {
-					system->line_buffer_a[address] = value;
+					system->video->line_buffer_a[address] = value;
 				}
 			}
 		} else if (address < 0x101800) {
 			//Line buffer B
 			address = address >> 1 & 0x3FF;
 			if (address < LINEBUFFER_WORDS) {
-				system->line_buffer_b[address] = value;
+				system->video->line_buffer_b[address] = value;
 			}
 		} else if (address < 0x102100) {
 			//Write Line Buffer
 			address = address >> 1 & 0x3FF;
 			if (address < LINEBUFFER_WORDS) {
-				system->write_line_buffer[address] = value;
+				system->video->write_line_buffer[address] = value;
 			}
 		} else {
 			//GPU/Blitter registers
@@ -180,25 +180,25 @@
 			} else if (address < 0x100800) {
 				//CLUT
 				address = address >> 1 & 255;
-				return system->clut[address];
+				return system->video->clut[address];
 			} else {
 				//Line buffer A
 				address = address >> 1 & 0x3FF;
 				if (address < LINEBUFFER_WORDS) {
-					return system->line_buffer_a[address];
+					return system->video->line_buffer_a[address];
 				}
 			}
 		} else if (address < 0x101800) {
 			//Line buffer B
 			address = address >> 1 & 0x3FF;
 			if (address < LINEBUFFER_WORDS) {
-				return system->line_buffer_b[address];
+				return system->video->line_buffer_b[address];
 			}
 		} else if (address < 0x102100) {
 			//Write Line Buffer
 			address = address >> 1 & 0x3FF;
 			if (address < LINEBUFFER_WORDS) {
-				return system->write_line_buffer[address];
+				return system->video->write_line_buffer[address];
 			}
 		} else {
 			//GPU/Blitter registers
@@ -270,8 +270,11 @@
 
 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;
 }
@@ -309,6 +312,7 @@
 	init_m68k_opts(opts, jag_m68k_map, 8, 2);
 	system->m68k = init_68k_context(opts, handle_m68k_reset);
 	system->m68k->system = system;
+	system->video = jag_video_init();
 	return system;
 }
 
--- a/jaguar.h	Thu Oct 06 22:25:12 2016 -0700
+++ b/jaguar.h	Fri Oct 07 18:27:38 2016 -0700
@@ -1,13 +1,15 @@
 #ifndef JAGUAR_H_
 #define JAGUAR_H_
 
-#define DRAM_WORDS (4*1024*1024)
-#define LINEBUFFER_WORDS 720
+#define DRAM_WORDS (1*1024*1024)
 #define GPU_RAM_BYTES 4096
 #define DSP_RAM_BYTES 8192
 
+#include "jag_video.h"
+
 typedef struct {
 	m68k_context *m68k;
+	jag_video    *video;
 	uint16_t     *bios;
 	uint16_t     *cart;
 	uint32_t     bios_size;
@@ -20,11 +22,6 @@
 	uint16_t     dram[DRAM_WORDS];
 	uint32_t     gpu_local[GPU_RAM_BYTES / sizeof(uint32_t)];
 	uint32_t     dsp_local[DSP_RAM_BYTES / sizeof(uint32_t)];
-	uint16_t     clut[256];
-	uint16_t     line_buffer_a[LINEBUFFER_WORDS];
-	uint16_t     line_buffer_b[LINEBUFFER_WORDS];
-	uint16_t     *write_line_buffer;
-	uint16_t     *read_line_buffer;
 	
 	uint8_t      memcon_written;
 } jaguar_context;