Previous 15994 Revisions Next

r1614 Sunday 27th January, 2008 at 11:24:05 UTC by Wilbert Pol
[GBCOLOR] Improved hdma length handling. Allow hdma to be enabled during mode 0.
[src/mess/video]gb.c

src/mess/video/gb.c
r1613r1614
5454static UINT8 gb_spal1[4];   /* Sprite 1 palette      */
5555static UINT8 *gb_oam;
5656UINT8 *gb_vram;
57static double lcd_time;
5857static UINT8 *gb_vram_ptr;
59static int gbc_hdma_enabled;
6058static UINT8   *gb_chrgen;   /* Character generator           */
6159static UINT8   *gb_bgdtab;   /* Background character table    */
6260static UINT8   *gb_wndtab;   /* Window character table        */
r1613r1614
10098   int oam_locked;
10199   int vram_locked;
102100   int pal_locked;
101   int hdma_enabled;
102   int hdma_possible;
103103   struct layer_struct   layer[2];
104104   emu_timer   *lcd_timer;
105105} gb_lcd;
r1613r1614
11241124   GB_LCD_STATE_LYXX_PRE_M0,
11251125   GB_LCD_STATE_LYXX_M0,
11261126   GB_LCD_STATE_LYXX_M0_SCX3,
1127   GB_LCD_STATE_LYXX_M0_HDMA,
11281127   GB_LCD_STATE_LYXX_M0_GBC_PAL,
11291128   GB_LCD_STATE_LYXX_M0_PRE_INC,
11301129   GB_LCD_STATE_LYXX_M0_INC,
r1613r1614
12591258      gbc_bgdtab = gbc_wndtab = gb_vram + 0x3C00;
12601259
12611260      /* HDMA disabled */
1262      gbc_hdma_enabled = 0;
1261      gb_lcd.hdma_enabled = 0;
1262      gb_lcd.hdma_possible = 0;
12631263
12641264      /* Make sure the VBlank interrupt is set when the first instruction gets executed */
12651265      timer_set( ATTOTIME_IN_CYCLES(1,0), NULL, 0, gb_video_init_vbl );
r1613r1614
12961296   HDMA3 = 0x1f & (dst >> 8);
12971297   HDMA4 = dst & 0xF0;
12981298   HDMA5--;
1299   if( (HDMA5 & 0x7f) == 0 ) {
1299   if( (HDMA5 & 0x7f) == 0x7f ) {
13001300      HDMA5 = 0xff;
1301      gbc_hdma_enabled = 0;
1301      gb_lcd.hdma_enabled = 0;
13021302   }
13031303}
13041304
r1613r1614
16001600         break;
16011601      case GB_LCD_STATE_LYXX_M0_GBC_PAL:
16021602         gb_lcd.pal_locked = UNLOCKED;
1603      case GB_LCD_STATE_LYXX_M0_HDMA:
1604         /* Check for HBLANK DMA */
1605         if( gbc_hdma_enabled )
1603            /* Check for HBLANK DMA */
1604         if( gb_lcd.hdma_enabled ) {
16061605            gbc_hdma(0x10);
1606//            cpunum_set_reg( 0, Z80GB_DMA_CYCLES, 36 );
1607         } else {
1608            gb_lcd.hdma_possible = 1;
1609         }
16071610         timer_adjust( gb_lcd.lcd_timer, ATTOTIME_IN_CYCLES(192 - gb_lcd.scrollx_adjust - gb_lcd.sprite_cycles,0), GB_LCD_STATE_LYXX_M0_PRE_INC, attotime_never );
16081611         break;
16091612      case GB_LCD_STATE_LYXX_M0_PRE_INC:   /* Just before incrementing the line counter go to mode 2 internally */
r1613r1614
16311634            gb_lcd.line_irq = gb_lcd.triggering_line_irq;
16321635            cpunum_set_input_line(machine, 0, LCD_INT, HOLD_LINE );
16331636         }
1637         gb_lcd.hdma_possible = 0;
16341638         /* Check if we're going into VBlank next */
16351639         if ( CURLINE == 144 ) {
16361640            timer_adjust( gb_lcd.lcd_timer, ATTOTIME_IN_CYCLES(4,0), GB_LCD_STATE_LY9X_M1, attotime_never );
r1613r1614
20472051   case 0x15:      /* HDMA5 - HBL General DMA - Mode, Length */
20482052      if( !(data & 0x80) )
20492053      {
2050         if( gbc_hdma_enabled )
2054         if( gb_lcd.hdma_enabled )
20512055         {
2052            gbc_hdma_enabled = 0;
2056            gb_lcd.hdma_enabled = 0;
20532057            data = HDMA5 & 0x80;
20542058         }
20552059         else
20562060         {
20572061            /* General DMA */
20582062            gbc_hdma( ((data & 0x7F) + 1) * 0x10 );
2059            lcd_time -= ((KEY1 & 0x80)?110:220) + (((data & 0x7F) + 1) * 7.68);
2063//            cpunum_set_reg( 0, Z80GB_DMA_CYCLES, 4 + ( ( ( data & 0x7F ) + 1 ) * 32 ) );
20602064            data = 0xff;
20612065         }
20622066      }
20632067      else
20642068      {
20652069         /* H-Blank DMA */
2066         gbc_hdma_enabled = 1;
2070         gb_lcd.hdma_enabled = 1;
20672071         data &= 0x7f;
2072         gb_vid_regs[offset] = data;
2073         /* Check if HDMA should be immediately performed */
2074         if ( gb_lcd.hdma_possible ) {
2075            gbc_hdma( 0x10 );
2076//            cpunum_set_reg( 0, Z80GB_DMA_CYCLES, 36 );
2077            gb_lcd.hdma_possible = 0;
2078         }
20682079      }
20692080      break;
20702081   case 0x28:      /* BCPS - Background palette specification */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team