# HG changeset patch # User Michael Pavone # Date 1494047310 25200 # Node ID 6372de4da1799799910d4199318e22f7d43cbd3b # Parent 033dda2d45984cab336de7e1cb1e4c72fbd2d885 Fix vscroll latching when full screen vscroll is used in combination with the window plane on the left side of the screen diff -r 033dda2d4598 -r 6372de4da179 vdp.c --- a/vdp.c Thu May 04 22:47:51 2017 -0700 +++ b/vdp.c Fri May 05 22:08:30 2017 -0700 @@ -1052,6 +1052,26 @@ v_offset_mask = 0x7; vscroll_shift = 3; } + //TODO: Further research on vscroll latch behavior and the "first column bug" + if (!column) { + if (context->regs[REG_MODE_3] & BIT_VSCROLL) { + if (context->regs[REG_MODE_4] & BIT_H40) { + //Based on observed behavior documented by Eke-Eke, I'm guessing the VDP + //ends up fetching the last value on the VSRAM bus in the H40 case + //getting the last latched value should be close enough for now + if (!vsram_off) { + context->vscroll_latch[0] = context->vscroll_latch[1]; + } + } else { + //supposedly it's always forced to 0 in the H32 case + context->vscroll_latch[0] = context->vscroll_latch[1] = 0; + } + } else { + context->vscroll_latch[vsram_off] = context->vsram[vsram_off]; + } + } else if (context->regs[REG_MODE_3] & BIT_VSCROLL) { + context->vscroll_latch[vsram_off] = context->vsram[column - 2 + vsram_off]; + } if (!vsram_off) { uint16_t left_col, right_col; if (context->regs[REG_WINDOW_H] & WINDOW_RIGHT) { @@ -1106,26 +1126,6 @@ vscroll <<= 1; vscroll |= 1; } - //TODO: Further research on vscroll latch behavior and the "first column bug" - if (!column) { - if (context->regs[REG_MODE_3] & BIT_VSCROLL) { - if (context->regs[REG_MODE_4] & BIT_H40) { - //Based on observed behavior documented by Eke-Eke, I'm guessing the VDP - //ends up fetching the last value on the VSRAM bus in the H40 case - //getting the last latched value should be close enough for now - if (!vsram_off) { - context->vscroll_latch[0] = context->vscroll_latch[1]; - } - } else { - //supposedly it's always forced to 0 in the H32 case - context->vscroll_latch[0] = context->vscroll_latch[1] = 0; - } - } else { - context->vscroll_latch[vsram_off] = context->vsram[vsram_off]; - } - } else if (context->regs[REG_MODE_3] & BIT_VSCROLL) { - context->vscroll_latch[vsram_off] = context->vsram[column - 2 + vsram_off]; - } vscroll &= context->vscroll_latch[vsram_off] + line; context->v_offset = vscroll & v_offset_mask; //printf("%s | line %d, vsram: %d, vscroll: %d, v_offset: %d\n",(vsram_off ? "B" : "A"), line, context->vsram[context->regs[REG_MODE_3] & 0x4 ? column : 0], vscroll, context->v_offset);