diff vdp.c @ 884:252dfd29831d

Selecting a second game from the menu now works
author Michael Pavone <pavone@retrodev.com>
date Fri, 13 Nov 2015 22:56:59 -0800
parents ac65086c031e
children e64168bb2b25
line wrap: on
line diff
--- a/vdp.c	Fri Nov 13 19:15:37 2015 -0800
+++ b/vdp.c	Fri Nov 13 22:56:59 2015 -0800
@@ -140,6 +140,19 @@
 	}
 }
 
+void vdp_free(vdp_context *context)
+{
+	free(context->vdpmem);
+	free(context->linebuf);
+	if (headless) {
+		free(context->oddbuf);
+		free(context->evenbuf);
+	} else {
+		render_free_surfaces(context);
+	}
+	free(context);
+}
+
 int is_refresh(vdp_context * context, uint32_t slot)
 {
 	if (context->regs[REG_MODE_4] & BIT_H40) {
@@ -847,7 +860,7 @@
 						src |= DBG_HILIGHT;
 						colors += CRAM_SIZE*2;
 					}
-					
+
 					uint32_t outpixel;
 					if (context->debug) {
 						outpixel = context->debugcolors[src];
@@ -949,7 +962,7 @@
 	} else if (!(context->latched_mode & BIT_PAL) &&  context->vcounter == 0xEB) {
 		context->vcounter = 0x1E5;
 	}
-	
+
 	if (context->vcounter > (context->latched_mode & BIT_PAL ? PAL_INACTIVE_START : NTSC_INACTIVE_START)) {
 		context->hint_counter = context->regs[REG_HINT];
 	} else if (context->hint_counter) {
@@ -1020,7 +1033,7 @@
 			vdp_advance_line(context);\
 		}\
 		CHECK_LIMIT
-		
+
 #define SPRITE_RENDER_H40(slot) \
 	case slot:\
 		render_sprite_cells( context);\
@@ -1038,7 +1051,7 @@
 			}\
 		}\
 		CHECK_ONLY
-		
+
 #define SPRITE_RENDER_H32(slot) \
 	case slot:\
 		render_sprite_cells( context);\
@@ -1051,7 +1064,7 @@
 		}\
 		context->cycles += slot_cycles;\
 		CHECK_ONLY
-			
+
 
 void vdp_h40(vdp_context * context, uint32_t target_cycles)
 {
@@ -1684,7 +1697,7 @@
 			line > inactive_start
 			&& line < 0x1FF
 		)
-		|| (line == inactive_start 
+		|| (line == inactive_start
 			&& (
 				slot >= (context->regs[REG_MODE_4] & BIT_H40 ? VBLANK_START_H40 : VBLANK_START_H32)
 				|| slot < (context->regs[REG_MODE_4] & BIT_H40 ? LINE_CHANGE_H40 : LINE_CHANGE_H32)