[libgens] Vdp::updateVdpLines(): 224/240 is M2, not M3.
authorDavid Korth <gerbilsoft@gerbilsoft.com>
Tue, 29 Mar 2016 04:33:17 +0000 (00:33 -0400)
committerDavid Korth <gerbilsoft@gerbilsoft.com>
Tue, 29 Mar 2016 04:33:17 +0000 (00:33 -0400)
This fixes "World Series Baseball" inadvertently activating 240-line
mode, since it was setting M3 (H/V counter stop), and likely fixes
games that actually used 240-line mode.

VdpReg.cpp, VdpPrivate::updateVdpMode():
- Check the newly-calculated VDP_Mode instead of Set2 when determining
  if the NTSC V30 roll values should be reset.
- Only do the above check if VDP_Mode has actually changed.

src/libgens/Vdp/Vdp.cpp
src/libgens/Vdp/VdpReg.cpp

index bbb3223..e9105b9 100644 (file)
@@ -225,7 +225,7 @@ void Vdp::updateVdpLines(bool resetCurrent)
        // the VDP code isn't used at all in Gens/GS II during "idle".
        if (d->VDP_Mode & VdpTypes::VDP_MODE_M5) {
                // Mode 5. Must be either 224 lines or 240 lines.
-               if (d->VDP_Mode & VdpTypes::VDP_MODE_M3)
+               if (d->VDP_Mode & VdpTypes::VDP_MODE_M2)
                        LineOffset = 2; // 240 lines.
                else
                        LineOffset = 1; // 224 lines.
index 9eea1f5..0922931 100644 (file)
@@ -47,12 +47,6 @@ void VdpPrivate::updateVdpMode(void)
                    ((Set1 & 0x04) << 1) |      // M4/PSEL
                    ((Set2 & 0x04) << 2));      // M5
 
-       if (!(Set2 & 0x08)) {
-               // V28 mode. Reset the NTSC V30 roll values.
-               q->VDP_Lines.NTSC_V30.Offset = 0;
-               q->VDP_Lines.NTSC_V30.VBlank_Div = 0;
-       }
-
        // If the VDP mode has changed, CRam needs to be updated.
        if (prevVdpMode != VDP_Mode) {
                // Update the VDP mode variables.
@@ -67,6 +61,13 @@ void VdpPrivate::updateVdpMode(void)
                // Set the M5/M4 bits.
                // NOTE: The AND is probably not necessary...
                palette.setM5M4bits((VDP_Mode >> 3) & 0x03);
+
+               if (!(VDP_Mode & VdpTypes::VDP_MODE_M2)) {
+                       // V28 mode. Reset the NTSC V30 roll values.
+                       // TODO: Also if changed from NTSC to PAL?
+                       q->VDP_Lines.NTSC_V30.Offset = 0;
+                       q->VDP_Lines.NTSC_V30.VBlank_Div = 0;
+               }
        }
 
        // Initialize Vdp::VDP_Lines.