Previous 199869 Revisions Next

r36652 Thursday 26th March, 2015 at 02:55:51 UTC by R. Belmont
(MESS) gba: vblank at line 160, don't do HIRQ or HDMA during Vblank.  This fixes raster effects and glitches in dozens if not hundreds of games. [R. Belmont, endrift]
[src/mess/drivers]gba.c

trunk/src/mess/drivers/gba.c
r245163r245164
161161   else
162162   {
163163//      if (dst >= 0x6000000 && dst <= 0x6017fff)
164//          printf("DMA exec: ch %d from %08x to %08x, mode %04x, count %04x (PC %x) (%s)\n", (int)ch, src, dst, ctrl, cnt, activecpu_get_pc(), ((ctrl>>10) & 1) ? "32" : "16");
164//      printf("DMA exec: ch %d from %08x to %08x, mode %04x, count %04x (%s)\n", (int)ch, src, dst, ctrl, cnt, ((ctrl>>10) & 1) ? "32" : "16");
165165   }
166166
167167   for (int i = 0; i < cnt; i++)
r245163r245164
15591559
15601560            ch = offset / 3;
15611561
1562//              printf("%08x: DMA(%d): %x to reg %d (mask %08x)\n", activecpu_get_pc(), ch, data, offset%3, ~mem_mask);
1562//            printf("%08x: DMA(%d): %x to reg %d (mask %08x)\n", space.device().safe_pc(), ch, data, offset%3, ~mem_mask);
15631563
15641564            if (((offset % 3) == 2) && ((~mem_mask & 0xffff0000) == 0))
15651565            {
r245163r245164
19611961   if (scanline < 160)
19621962   {
19631963      draw_scanline(scanline);
1964   }
1965   m_DISPSTAT |= DISPSTAT_HBL;
1966   if ((m_DISPSTAT & DISPSTAT_HBL_IRQ_EN ) != 0)
1967   {
1968      request_irq(INT_HBL);
1969   }
19701964
1971   for (ch = 0; ch < 4; ch++)
1972   {
1973      ctrl = m_dma_regs[(ch*3)+2]>>16;
1965      if ((m_DISPSTAT & DISPSTAT_HBL_IRQ_EN ) != 0)
1966      {
1967         request_irq(INT_HBL);
1968      }
19741969
1975      // HBL-triggered DMA?
1976      if ((ctrl & 0x8000) && ((ctrl & 0x3000) == 0x2000))
1970      for (ch = 0; ch < 4; ch++)
19771971      {
1978         dma_exec(ch);
1972         ctrl = m_dma_regs[(ch*3)+2]>>16;
1973
1974         // HBL-triggered DMA?
1975         if ((ctrl & 0x8000) && ((ctrl & 0x3000) == 0x2000))
1976         {
1977            dma_exec(ch);
1978         }
19791979      }
19801980   }
19811981
1982   m_DISPSTAT |= DISPSTAT_HBL;
1983
19821984   m_hbl_timer->adjust(attotime::never);
19831985}
19841986
r245163r245164
19951997   if (scanline >= 160 && scanline < 227)
19961998   {
19971999      m_DISPSTAT |= DISPSTAT_VBL;
2000
2001      // VBL IRQ and DMA on line 160
2002      if (scanline == 160)
2003      {
2004         int ch, ctrl;
2005
2006         if (m_DISPSTAT & DISPSTAT_VBL_IRQ_EN)
2007         {
2008            request_irq(INT_VBL);
2009         }
2010
2011         for (ch = 0; ch < 4; ch++)
2012         {
2013            ctrl = m_dma_regs[(ch*3)+2]>>16;
2014
2015            // VBL-triggered DMA?
2016            if ((ctrl & 0x8000) && ((ctrl & 0x3000) == 0x1000))
2017            {
2018               dma_exec(ch);
2019            }
2020         }
2021      }
19982022   }
19992023   else
20002024   {
r245163r245164
20112035      }
20122036   }
20132037
2014   // exiting VBL, handle interrupts and DMA triggers
2015   if (scanline == 224)
2016   {
2017      // FIXME: some games are very picky with this trigger!
2018      // * Mario & Luigi SuperStar Saga loses pieces of gfx for 225-227.
2019      // * Driver 2 does not work with values > 217.
2020      // * Prince of Persia Sands of Time, Rayman Hoodlum's Revenge, Rayman 3 breaks for large
2021      //   values (say > 200, but exact threshold varies).
2022      // * Scooby-Doo Unmasked and Mystery Mayhem have problems with large values (missing dialogue
2023      //   text).
2024      // * Nicktoons Racign does not start with 227; and it resets before going to the race with
2025      //   values > 206.
2026      // * Phil of Future does not start for values > 221.
2027      // * Sabrina Teenage Witch does not even reach the Ubi Soft logo if we use the VBL exit value
2028      //   227; it does not display title screen graphics when using 225-226; the intro is broken
2029      //   with anything between 207-224.
2030      // * Anstoss Action and Ueki no Housoku have broken graphics for values > 223.
2031      // However, taking smaller values breaks raster effects in a LOT of games (e.g. Castlevania
2032      // series, Final Fantasy series, Tales of Phantasia, Banjo Pilot, NES 'collections' by Hudson,
2033      // Jaleco and Technos, plus tons of racing games, which show garbage in the lower half of the
2034      // screen with smaller values).
2035      // Already choosing 224 instead of 227 makes some glitches to appear in the bottom scanlines.
2036      // Other test cases are EA Sport games (like FIFA or Madden) which have various degrees of
2037      // glitchness depending on the value used here.
2038      // More work on IRQs is definitely necessary!
2039      int ch, ctrl;
2040
2041      if (m_DISPSTAT & DISPSTAT_VBL_IRQ_EN)
2042      {
2043         request_irq(INT_VBL);
2044      }
2045
2046      for (ch = 0; ch < 4; ch++)
2047      {
2048         ctrl = m_dma_regs[(ch*3)+2]>>16;
2049
2050         // VBL-triggered DMA?
2051         if ((ctrl & 0x8000) && ((ctrl & 0x3000) == 0x1000))
2052         {
2053            dma_exec(ch);
2054         }
2055      }
2056   }
2057
20582038   m_hbl_timer->adjust(machine().first_screen()->time_until_pos(scanline, 240));
20592039   m_scan_timer->adjust(machine().first_screen()->time_until_pos(( scanline + 1 ) % 228, 0));
20602040}


Previous 199869 Revisions Next


© 1997-2024 The MAME Team