Mercurial > repos > blastem
comparison vdp.c @ 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 |
comparison
equal
deleted
inserted
replaced
1122:d4bef26d0977 | 1123:d5412f76accc |
---|---|
2178 } else { | 2178 } else { |
2179 uint8_t mode_5 = context->regs[REG_MODE_2] & BIT_MODE_5; | 2179 uint8_t mode_5 = context->regs[REG_MODE_2] & BIT_MODE_5; |
2180 if ((value & 0xC000) == 0x8000) { | 2180 if ((value & 0xC000) == 0x8000) { |
2181 //Register write | 2181 //Register write |
2182 uint8_t reg = (value >> 8) & 0x1F; | 2182 uint8_t reg = (value >> 8) & 0x1F; |
2183 if (reg < (mode_5 ? VDP_REGS : 0xA)) { | 2183 if (reg < (mode_5 ? VDP_REGS : 0xB)) { |
2184 //printf("register %d set to %X\n", reg, value & 0xFF); | 2184 //printf("register %d set to %X\n", reg, value & 0xFF); |
2185 if (reg == REG_MODE_1 && (value & BIT_HVC_LATCH) && !(context->regs[reg] & BIT_HVC_LATCH)) { | 2185 if (reg == REG_MODE_1 && (value & BIT_HVC_LATCH) && !(context->regs[reg] & BIT_HVC_LATCH)) { |
2186 context->hv_latch = vdp_hv_counter_read(context); | 2186 context->hv_latch = vdp_hv_counter_read(context); |
2187 } | 2187 } |
2188 if (reg == REG_BG_COLOR) { | 2188 if (reg == REG_BG_COLOR) { |
2533 return 0xFFFFFFFF; | 2533 return 0xFFFFFFFF; |
2534 } | 2534 } |
2535 if (context->flags2 & FLAG2_HINT_PENDING) { | 2535 if (context->flags2 & FLAG2_HINT_PENDING) { |
2536 return context->pending_hint_start; | 2536 return context->pending_hint_start; |
2537 } | 2537 } |
2538 uint32_t inactive_start = context->latched_mode & BIT_PAL ? PAL_INACTIVE_START : NTSC_INACTIVE_START; | 2538 uint32_t inactive_start = (context->regs[REG_MODE_2] & BIT_MODE_5) |
2539 ? (context->latched_mode & BIT_PAL ? PAL_INACTIVE_START : NTSC_INACTIVE_START) | |
2540 : MODE4_INACTIVE_START; | |
2539 uint32_t hint_line; | 2541 uint32_t hint_line; |
2540 if (context->vcounter + context->hint_counter >= inactive_start) { | 2542 if (context->vcounter + context->hint_counter >= inactive_start) { |
2541 if (context->regs[REG_HINT] > inactive_start) { | 2543 if (context->regs[REG_HINT] > inactive_start) { |
2542 return 0xFFFFFFFF; | 2544 return 0xFFFFFFFF; |
2543 } | 2545 } |