trunk/src/mess/drivers/gba.c
| r245163 | r245164 | |
| 161 | 161 | else |
| 162 | 162 | { |
| 163 | 163 | // 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"); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | for (int i = 0; i < cnt; i++) |
| r245163 | r245164 | |
| 1559 | 1559 | |
| 1560 | 1560 | ch = offset / 3; |
| 1561 | 1561 | |
| 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); |
| 1563 | 1563 | |
| 1564 | 1564 | if (((offset % 3) == 2) && ((~mem_mask & 0xffff0000) == 0)) |
| 1565 | 1565 | { |
| r245163 | r245164 | |
| 1961 | 1961 | if (scanline < 160) |
| 1962 | 1962 | { |
| 1963 | 1963 | 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 | | } |
| 1970 | 1964 | |
| 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 | } |
| 1974 | 1969 | |
| 1975 | | // HBL-triggered DMA? |
| 1976 | | if ((ctrl & 0x8000) && ((ctrl & 0x3000) == 0x2000)) |
| 1970 | for (ch = 0; ch < 4; ch++) |
| 1977 | 1971 | { |
| 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 | } |
| 1979 | 1979 | } |
| 1980 | 1980 | } |
| 1981 | 1981 | |
| 1982 | m_DISPSTAT |= DISPSTAT_HBL; |
| 1983 | |
| 1982 | 1984 | m_hbl_timer->adjust(attotime::never); |
| 1983 | 1985 | } |
| 1984 | 1986 | |
| r245163 | r245164 | |
| 1995 | 1997 | if (scanline >= 160 && scanline < 227) |
| 1996 | 1998 | { |
| 1997 | 1999 | 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 | } |
| 1998 | 2022 | } |
| 1999 | 2023 | else |
| 2000 | 2024 | { |
| r245163 | r245164 | |
| 2011 | 2035 | } |
| 2012 | 2036 | } |
| 2013 | 2037 | |
| 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 | | |
| 2058 | 2038 | m_hbl_timer->adjust(machine().first_screen()->time_until_pos(scanline, 240)); |
| 2059 | 2039 | m_scan_timer->adjust(machine().first_screen()->time_until_pos(( scanline + 1 ) % 228, 0)); |
| 2060 | 2040 | } |