src/mess/includes/gba.h
| r5377 | r5378 | |
| 110 | 110 | /* driver state */ |
| 111 | 111 | typedef struct |
| 112 | 112 | { |
| 113 | | UINT16 DISPCNT, GRNSWAP, DISPSTAT; |
| 113 | UINT32 DISPSTAT; |
| 114 | UINT16 DISPCNT, GRNSWAP; |
| 114 | 115 | UINT16 BG0CNT, BG1CNT, BG2CNT, BG3CNT; |
| 115 | 116 | UINT16 BG0HOFS, BG0VOFS, BG1HOFS, BG1VOFS, BG2HOFS, BG2VOFS, BG3HOFS, BG3VOFS; |
| 116 | 117 | UINT16 BG2PA, BG2PB, BG2PC, BG2PD, BG2X, BG2Y, BG3PA, BG3PB, BG3PC, BG3PD, BG3X, BG3Y; |
src/mess/drivers/gba.c
| r5377 | r5378 | |
| 518 | 518 | } |
| 519 | 519 | break; |
| 520 | 520 | case 0x0004/4: |
| 521 | | retval = gba_state->DISPSTAT | (video_screen_get_vpos(machine->primary_screen)<<16); |
| 521 | retval = (gba_state->DISPSTAT & 0xffff) | (video_screen_get_vpos(machine->primary_screen)<<16); |
| 522 | 522 | break; |
| 523 | 523 | case 0x0008/4: |
| 524 | 524 | if( (mem_mask) & 0x0000ffff ) |
| r5377 | r5378 | |
| 1007 | 1007 | } |
| 1008 | 1008 | break; |
| 1009 | 1009 | case 0x0004/4: |
| 1010 | | if( (mem_mask) & 0x0000ffff ) |
| 1011 | | { |
| 1012 | | // printf("DISPSTAT (%08x) = %04x (%08x)\n", 0x04000000 + ( offset << 2 ), data & 0x0000ffff, ~mem_mask ); |
| 1013 | | gba_state->DISPSTAT = ( gba_state->DISPSTAT & ~mem_mask ) | ( data & mem_mask ) ; |
| 1014 | | } |
| 1010 | // printf("DISPSTAT (%08x) = %04x (%08x)\n", 0x04000000 + ( offset << 2 ), data & 0x0000ffff, mem_mask ); |
| 1011 | COMBINE_DATA(&gba_state->DISPSTAT); |
| 1015 | 1012 | break; |
| 1016 | 1013 | case 0x0008/4: |
| 1017 | 1014 | if( (mem_mask) & 0x0000ffff ) |
| r5377 | r5378 | |
| 1827 | 1824 | { |
| 1828 | 1825 | int ch, ctrl; |
| 1829 | 1826 | gba_state *gba_state = machine->driver_data; |
| 1830 | | |
| 1827 | |
| 1831 | 1828 | gba_draw_scanline(machine, video_screen_get_vpos(machine->primary_screen)); // we are now in hblank |
| 1832 | 1829 | gba_state->DISPSTAT |= DISPSTAT_HBL; |
| 1833 | 1830 | if ((gba_state->DISPSTAT & DISPSTAT_HBL_IRQ_EN ) != 0) |
| r5377 | r5378 | |
| 1859 | 1856 | |
| 1860 | 1857 | scanline = video_screen_get_vpos(machine->primary_screen); |
| 1861 | 1858 | |
| 1859 | // VBL is set for scanlines 160 through 226 (but not 227, which is the last line) |
| 1860 | if (scanline >= 160 && scanline < 227) |
| 1861 | { |
| 1862 | gba_state->DISPSTAT |= DISPSTAT_VBL; |
| 1863 | } |
| 1864 | else |
| 1865 | { |
| 1866 | gba_state->DISPSTAT &= ~DISPSTAT_VBL; |
| 1867 | } |
| 1868 | |
| 1862 | 1869 | // handle VCNT match interrupt/flag |
| 1863 | 1870 | if (scanline == ((gba_state->DISPSTAT >> 8) & 0xff)) |
| 1864 | 1871 | { |
| r5377 | r5378 | |
| 1869 | 1876 | } |
| 1870 | 1877 | } |
| 1871 | 1878 | |
| 1872 | | // scanline zero means not in VBL anymore |
| 1873 | | if (scanline == 0) |
| 1879 | // entering VBL, handle interrupts and DMA triggers |
| 1880 | if (scanline == 160) |
| 1874 | 1881 | { |
| 1875 | | gba_state->DISPSTAT &= ~DISPSTAT_VBL; |
| 1876 | | } |
| 1877 | | else if (scanline == 160) // scanline 160 means entering VBL |
| 1878 | | { |
| 1879 | 1882 | int ch, ctrl; |
| 1880 | 1883 | |
| 1881 | | gba_state->DISPSTAT |= DISPSTAT_VBL; |
| 1882 | | // printf("DISPSTAT %x %x\n", gba_state->DISPSTAT, gba_state->DISPSTAT & DISPSTAT_VBL_IRQ_EN); |
| 1883 | | if ((gba_state->DISPSTAT & DISPSTAT_VBL_IRQ_EN) != 0) |
| 1884 | if (gba_state->DISPSTAT & DISPSTAT_VBL_IRQ_EN) |
| 1884 | 1885 | { |
| 1885 | 1886 | gba_request_irq(machine, INT_VBL); |
| 1886 | 1887 | } |
| r5377 | r5378 | |
| 1921 | 1922 | gba_state->RCNT = 0x8000; |
| 1922 | 1923 | gba_state->JOYSTAT = 0x0002; |
| 1923 | 1924 | |
| 1924 | | timer_adjust_oneshot(gba_state->scan_timer, video_screen_get_time_until_pos(machine->primary_screen, 1, 0), 0); |
| 1925 | timer_adjust_oneshot(gba_state->scan_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); |
| 1925 | 1926 | timer_adjust_oneshot(gba_state->hbl_timer, attotime_never, 0); |
| 1926 | 1927 | timer_adjust_oneshot(gba_state->dma_timer[0], attotime_never, 0); |
| 1927 | 1928 | timer_adjust_oneshot(gba_state->dma_timer[1], attotime_never, 1); |
| r5377 | r5378 | |
| 1948 | 1949 | /* create a timer to fire scanline functions */ |
| 1949 | 1950 | gba_state->scan_timer = timer_alloc(machine, perform_scan, 0); |
| 1950 | 1951 | gba_state->hbl_timer = timer_alloc(machine, perform_hbl, 0); |
| 1951 | | timer_adjust_oneshot(gba_state->scan_timer, video_screen_get_time_until_pos(machine->primary_screen, 1, 0), 0); |
| 1952 | timer_adjust_oneshot(gba_state->scan_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0); |
| 1952 | 1953 | |
| 1953 | 1954 | /* and one for each DMA channel */ |
| 1954 | 1955 | gba_state->dma_timer[0] = timer_alloc(machine, dma_complete, 0); |