# HG changeset patch # User Michael Pavone # Date 1664659649 25200 # Node ID 48f718126099b27d0599034defd95a58ac414a49 # Parent 8e8db914120912641859cba97238e79f3271977a Fix minor regression in Landstalker caused by changes to when CRAM lookup is done diff -r 8e8db9141209 -r 48f718126099 vdp.c --- a/vdp.c Wed Sep 21 23:16:39 2022 -0700 +++ b/vdp.c Sat Oct 01 14:27:29 2022 -0700 @@ -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; } }