changeset 2244:e6bad7bd8751

merge
author Michael Pavone <pavone@retrodev.com>
date Tue, 22 Nov 2022 23:07:41 -0800
parents 0d1d5dccdd28 (current diff) 31fc1186ffbb (diff)
children d220305e81b9
files vdp.c
diffstat 2 files changed, 22 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/m68k_core.c	Tue Nov 22 17:57:02 2022 -0800
+++ b/m68k_core.c	Tue Nov 22 23:07:41 2022 -0800
@@ -1037,14 +1037,18 @@
 			memmap_chunk const *chunk = find_map_chunk(address, &opts->gen, 0, NULL);
 			if (!chunk) {
 				code_ptr start = code->cur;
-				defer_translation(&opts->gen, address, opts->retrans_stub);
+				translate_out_of_bounds(opts, address);
 				code_ptr after = code->cur;
 				map_native_address(context, address, start, 2, after-start);
 				break;
 			}
 			if (!(chunk->flags & MMAP_READ)) {
 				code_ptr start = code->cur;
-				defer_translation(&opts->gen, address, opts->retrans_stub);
+				if (chunk->flags & MMAP_CODE) {
+					defer_translation(&opts->gen, address, opts->retrans_stub);
+				} else {
+					translate_out_of_bounds(opts, address);
+				}
 				code_ptr after = code->cur;
 				map_native_address(context, address, start, 2, after-start);
 				break;
--- a/vdp.c	Tue Nov 22 17:57:02 2022 -0800
+++ b/vdp.c	Tue Nov 22 23:07:41 2022 -0800
@@ -117,6 +117,7 @@
 				context->state = ACTIVE;
 			} else if (context->vcounter == 0x1FF) {
 				context->state = PREPARING;
+				memset(context->compositebuf, 0, sizeof(context->compositebuf));
 			}
 		}
 	} else {
@@ -137,6 +138,7 @@
 			}
 			else if (context->vcounter == 0x1FF) {
 				context->state = PREPARING;
+				memset(context->compositebuf, 0, sizeof(context->compositebuf));
 			}
 		}
 	}
@@ -190,7 +192,7 @@
 	}
 
 	if (!static_table_init_done) {
-		
+
 		for (uint16_t mode4_addr = 0; mode4_addr < 0x4000; mode4_addr++)
 		{
 			uint16_t mode5_addr = mode4_addr & 0x3DFD;
@@ -2351,7 +2353,9 @@
 		} else {\
 			*(dst++) = context->colors[(*(src++) & 0xC0) | bgindex];\
 		}\
-		if (slot != (BG_START_SLOT + LINEBUF_SIZE/2)) {\
+		if (slot == (BG_START_SLOT + LINEBUF_SIZE/2)) {\
+			context->done_composite = NULL;\
+		} else {\
 			if ((*src & 0x3F) | test_layer) {\
 				*(dst++) = context->colors[*(src++)];\
 			} else {\
@@ -2368,7 +2372,9 @@
 		} else {\
 			*(dst++) = context->colors[(*(src++) & 0xC0) | bgindex];\
 		}\
-		if (slot != (BG_START_SLOT + (256+HORIZ_BORDER)/2)) {\
+		if (slot == (BG_START_SLOT + (256+HORIZ_BORDER)/2)) {\
+			context->done_composite = NULL;\
+		} else {\
 			if ((*src & 0x3F) | test_layer) {\
 				*(dst++) = context->colors[*(src++)];\
 			} else {\
@@ -3526,7 +3532,7 @@
 	}
 	uint32_t *dst;
 	uint8_t *debug_dst;
-	if (context->output && context->hslot >= BG_START_SLOT && context->hslot < bg_end_slot) {
+	if (context->output && context->hslot >= BG_START_SLOT && context->hslot <= bg_end_slot) {
 		dst = context->output + 2 * (context->hslot - BG_START_SLOT);
 		debug_dst = context->layer_debug_buf + 2 * (context->hslot - BG_START_SLOT);
 	} else {
@@ -3541,9 +3547,6 @@
 		if (context->hslot == BG_START_SLOT && context->output) {
 			dst = context->output + (context->hslot - BG_START_SLOT) * 2;
 			debug_dst = context->layer_debug_buf + 2 * (context->hslot - BG_START_SLOT);
-		} else if (context->hslot == bg_end_slot) {
-			advance_output_line(context);
-			dst = NULL;
 		}
 		//this will need some tweaking to properly interact with 128K mode,
 		//but this should be good enough for now
@@ -3621,22 +3624,7 @@
 				*(dst++) = bg_color;
 				*(debug_dst++) = DBG_SRC_BG;
 			}
-			if (context->done_composite) {
-				uint8_t pixel = context->compositebuf[dst-context->output];
-				if (!(pixel & 0x3F | test_layer)) {
-					pixel = pixel & 0xC0 | bg_index;
-				}
-				*(dst++) = context->colors[pixel];
-				if ((dst - context->output) == (context->done_composite - context->compositebuf)) {
-					context->done_composite = NULL;
-					memset(context->compositebuf, 0, sizeof(context->compositebuf));
-				}
-			} else {
-				*(dst++) = bg_color;
-				*(debug_dst++) = DBG_SRC_BG;
-			}
-
-			if (context->hslot == (bg_end_slot-1)) {
+			if (context->hslot != bg_end_slot) {
 				if (context->done_composite) {
 					uint8_t pixel = context->compositebuf[dst-context->output];
 					if (!(pixel & 0x3F | test_layer)) {
@@ -3653,6 +3641,10 @@
 				}
 			}
 		}
+		if (context->hslot == bg_end_slot) {
+			advance_output_line(context);
+			dst = NULL;
+		}
 
 		if (!is_refresh(context, context->hslot)) {
 			external_slot(context);
@@ -3679,6 +3671,7 @@
 			vdp_advance_line(context);
 			if (context->vcounter == active_line) {
 				context->state = PREPARING;
+				memset(context->compositebuf, 0, sizeof(context->compositebuf));
 				return;
 			}
 		}