changeset 1123:d5412f76accc

Fix inactive start line for Mode 4 in vdp_next_hint. Fix an off by one error in the range of registers allowed to be written in Mode 4
author Michael Pavone <pavone@retrodev.com>
date Tue, 27 Dec 2016 13:26:14 -0800
parents d4bef26d0977
children e4deab85f9ac
files vdp.c
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/vdp.c	Tue Dec 27 13:11:07 2016 -0800
+++ b/vdp.c	Tue Dec 27 13:26:14 2016 -0800
@@ -2180,7 +2180,7 @@
 		if ((value & 0xC000) == 0x8000) {
 			//Register write
 			uint8_t reg = (value >> 8) & 0x1F;
-			if (reg < (mode_5 ? VDP_REGS : 0xA)) {
+			if (reg < (mode_5 ? VDP_REGS : 0xB)) {
 				//printf("register %d set to %X\n", reg, value & 0xFF);
 				if (reg == REG_MODE_1 && (value & BIT_HVC_LATCH) && !(context->regs[reg] & BIT_HVC_LATCH)) {
 					context->hv_latch = vdp_hv_counter_read(context);
@@ -2535,7 +2535,9 @@
 	if (context->flags2 & FLAG2_HINT_PENDING) {
 		return context->pending_hint_start;
 	}
-	uint32_t inactive_start = context->latched_mode & BIT_PAL ? PAL_INACTIVE_START : NTSC_INACTIVE_START;
+	uint32_t inactive_start = (context->regs[REG_MODE_2] & BIT_MODE_5)
+		? (context->latched_mode & BIT_PAL ? PAL_INACTIVE_START : NTSC_INACTIVE_START)
+		: MODE4_INACTIVE_START;
 	uint32_t hint_line;
 	if (context->vcounter + context->hint_counter >= inactive_start) {
 		if (context->regs[REG_HINT] > inactive_start) {