# HG changeset patch # User Michael Pavone # Date 1671815327 28800 # Node ID a98b2d0de2f106e69a940bccbf25ccf40eb599a9 # Parent bc68560b4a04fb75d8c012833c65e9363b73da9a Fix TMS9918A first line sprite bug diff -r bc68560b4a04 -r a98b2d0de2f1 vdp.c --- a/vdp.c Fri Dec 23 06:23:41 2022 -0800 +++ b/vdp.c Fri Dec 23 09:08:47 2022 -0800 @@ -4317,7 +4317,7 @@ line_change = LINE_CHANGE_MODE4; jump_start = 147; jump_dest = 233; - if (context->regs[REG_MODE_1] & BIT_MODE_4 || context->type != VDP_GENESIS) { + if ((context->regs[REG_MODE_1] & BIT_MODE_4) || context->type != VDP_GENESIS) { active_line = 0x1FF; } else { //never active unless either mode 4 or mode 5 is turned on @@ -4369,9 +4369,11 @@ if (context->hslot == buf_clear_slot) { if (mode_5) { context->cur_slot = max_draws; - } else { + } else if ((context->regs[REG_MODE_1] & BIT_MODE_4) || context->type == VDP_GENESIS) { context->cur_slot = context->sprite_index = MAX_DRAWS_H32_MODE4-1; context->sprite_draws = MAX_DRAWS_H32_MODE4; + } else { + context->sprite_draws = 0; } memset(context->linebuf, 0, LINEBUF_SIZE); } else if (context->hslot == index_reset_slot) { @@ -4398,11 +4400,11 @@ if (mode_5) { bg_index = context->regs[REG_BG_COLOR] & 0x3F; bg_color = context->colors[bg_index]; - } else if (context->regs[REG_MODE_1] & BIT_MODE_4) { + } else if ((context->regs[REG_MODE_1] & BIT_MODE_4) || context->type != VDP_GENESIS) { bg_index = 0x10 + (context->regs[REG_BG_COLOR] & 0xF); bg_color = context->colors[MODE4_OFFSET + bg_index]; } else { - bg_color = render_map_color(0, 0, 0); + bg_color = context->colors[0]; } if (context->done_composite) { uint8_t pixel = context->compositebuf[dst-context->output];