Previous 15994 Revisions Next

r5378 Sunday 9th August, 2009 at 04:00:37 UTC by R. Belmont
GBA: corrected handling of VBL status flag
[src/mess/drivers]gba.c
[src/mess/includes]gba.h

src/mess/includes/gba.h
r5377r5378
110110/* driver state */
111111typedef struct
112112{
113   UINT16 DISPCNT,   GRNSWAP, DISPSTAT;
113   UINT32 DISPSTAT;
114   UINT16 DISPCNT,   GRNSWAP;
114115   UINT16 BG0CNT, BG1CNT, BG2CNT, BG3CNT;
115116   UINT16 BG0HOFS, BG0VOFS, BG1HOFS, BG1VOFS, BG2HOFS, BG2VOFS, BG3HOFS, BG3VOFS;
116117   UINT16 BG2PA, BG2PB, BG2PC, BG2PD, BG2X, BG2Y, BG3PA, BG3PB, BG3PC, BG3PD, BG3X, BG3Y;
src/mess/drivers/gba.c
r5377r5378
518518         }
519519         break;
520520      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);
522522         break;
523523      case 0x0008/4:
524524         if( (mem_mask) & 0x0000ffff )
r5377r5378
10071007         }
10081008         break;
10091009      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);
10151012         break;
10161013      case 0x0008/4:
10171014         if( (mem_mask) & 0x0000ffff )
r5377r5378
18271824{
18281825   int ch, ctrl;
18291826   gba_state *gba_state = machine->driver_data;
1830
1827   
18311828   gba_draw_scanline(machine, video_screen_get_vpos(machine->primary_screen));   // we are now in hblank
18321829   gba_state->DISPSTAT |= DISPSTAT_HBL;
18331830   if ((gba_state->DISPSTAT & DISPSTAT_HBL_IRQ_EN ) != 0)
r5377r5378
18591856
18601857   scanline = video_screen_get_vpos(machine->primary_screen);
18611858
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
18621869   // handle VCNT match interrupt/flag
18631870   if (scanline == ((gba_state->DISPSTAT >> 8) & 0xff))
18641871   {
r5377r5378
18691876      }
18701877   }
18711878
1872   // scanline zero means not in VBL anymore
1873   if (scanline == 0)
1879   // entering VBL, handle interrupts and DMA triggers
1880   if (scanline == 160)
18741881   {
1875      gba_state->DISPSTAT &= ~DISPSTAT_VBL;
1876   }
1877   else if (scanline == 160)   // scanline 160 means entering VBL
1878   {
18791882      int ch, ctrl;
18801883
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)
18841885      {
18851886         gba_request_irq(machine, INT_VBL);
18861887      }
r5377r5378
19211922   gba_state->RCNT = 0x8000;
19221923   gba_state->JOYSTAT = 0x0002;
19231924
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);
19251926   timer_adjust_oneshot(gba_state->hbl_timer, attotime_never, 0);
19261927   timer_adjust_oneshot(gba_state->dma_timer[0], attotime_never, 0);
19271928   timer_adjust_oneshot(gba_state->dma_timer[1], attotime_never, 1);
r5377r5378
19481949   /* create a timer to fire scanline functions */
19491950   gba_state->scan_timer = timer_alloc(machine, perform_scan, 0);
19501951   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);
19521953
19531954   /* and one for each DMA channel */
19541955   gba_state->dma_timer[0] = timer_alloc(machine, dma_complete, 0);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team