src/mess/video/gb.c
| r1291 | r1292 | |
| 1142 | 1142 | GB_LCD_STATE_LYXX_M3=1, |
| 1143 | 1143 | GB_LCD_STATE_LYXX_M0, |
| 1144 | 1144 | GB_LCD_STATE_LYXX_M0_2, |
| 1145 | GB_LCD_STATE_LYXX_M0_PRE_INC, |
| 1145 | 1146 | GB_LCD_STATE_LYXX_M0_INC, |
| 1146 | 1147 | GB_LCD_STATE_LY00_M2, |
| 1147 | 1148 | GB_LCD_STATE_LYXX_M2, |
| r1291 | r1292 | |
| 1176 | 1177 | /* Check for HBLANK DMA */ |
| 1177 | 1178 | if( gbc_hdma_enabled ) |
| 1178 | 1179 | gbc_hdma(0x10); |
| 1179 | | mame_timer_adjust( gb_lcd.lcd_timer, MAME_TIME_IN_CYCLES(200 - 10 * gb_lcd.sprCount,0), GB_LCD_STATE_LYXX_M0_INC, time_never ); |
| 1180 | mame_timer_adjust( gb_lcd.lcd_timer, MAME_TIME_IN_CYCLES(196 - 10 * gb_lcd.sprCount,0), GB_LCD_STATE_LYXX_M0_PRE_INC, time_never ); |
| 1180 | 1181 | break; |
| 1182 | case GB_LCD_STATE_LYXX_M0_PRE_INC: /* Just before incrementing the line counter go to mode 2 internally */ |
| 1183 | if ( CURLINE < 143 ) { |
| 1184 | gb_lcd.mode = 2; |
| 1185 | if ( ! gb_lcd.mode_irq ) { |
| 1186 | if ( ( LCDSTAT & 0x20 ) && ( LCDSTAT & 0x40 ) && ( CMPLINE == CURLINE + 1 ) ) { |
| 1187 | gb_lcd.mode_irq = 1; |
| 1188 | cpunum_set_input_line( 0, LCD_INT, HOLD_LINE ); |
| 1189 | } |
| 1190 | } |
| 1191 | } |
| 1192 | mame_timer_adjust( gb_lcd.lcd_timer, MAME_TIME_IN_CYCLES(4,0), GB_LCD_STATE_LYXX_M0_INC, time_never ); |
| 1193 | break; |
| 1181 | 1194 | case GB_LCD_STATE_LYXX_M0_INC: /* Increment LY, stay in M0 for 4 more cycles */ |
| 1182 | 1195 | gb_increment_scanline(); |
| 1183 | 1196 | gb_lcd.delayed_line_irq = gb_lcd.line_irq; |
| 1184 | 1197 | gb_lcd.line_irq = ( ( CMPLINE == CURLINE ) && ( LCDSTAT & 0x40 ) ) ? 1 : 0; |
| 1185 | | if ( ! gb_lcd.delayed_line_irq && gb_lcd.line_irq ) { |
| 1198 | if ( ! gb_lcd.delayed_line_irq && gb_lcd.line_irq && ! ( LCDSTAT & 0x20 ) ) { |
| 1186 | 1199 | cpunum_set_input_line( 0, LCD_INT, HOLD_LINE ); |
| 1187 | 1200 | } |
| 1188 | 1201 | /* Reset LY==LYC STAT bit */ |
| r1291 | r1292 | |
| 1194 | 1207 | /* Internally switch to mode 2 */ |
| 1195 | 1208 | gb_lcd.mode = 2; |
| 1196 | 1209 | /* Generate lcd interrupt if requested */ |
| 1197 | | if ( ( ! gb_lcd.delayed_line_irq || ! ( LCDSTAT & 0x40 ) ) && ( LCDSTAT & 0x20 ) ) { |
| 1210 | if ( ! gb_lcd.mode_irq && ( LCDSTAT & 0x20 ) && |
| 1211 | ( ( ! gb_lcd.line_irq && ! gb_lcd.delayed_line_irq ) || ! ( LCDSTAT & 0x40 ) ) ) { |
| 1212 | gb_lcd.mode_irq = 1; |
| 1198 | 1213 | cpunum_set_input_line( 0, LCD_INT, HOLD_LINE ); |
| 1214 | } else { |
| 1215 | gb_lcd.mode_irq = 0; |
| 1199 | 1216 | } |
| 1200 | 1217 | mame_timer_adjust( gb_lcd.lcd_timer, MAME_TIME_IN_CYCLES(4,0), GB_LCD_STATE_LYXX_M2, time_never ); |
| 1201 | 1218 | } |
| r1291 | r1292 | |
| 1215 | 1232 | /* Update STAT register to the correct state */ |
| 1216 | 1233 | LCDSTAT = (LCDSTAT & 0xFC) | 0x02; |
| 1217 | 1234 | /* Generate lcd interrupt if requested */ |
| 1218 | | if ( gb_lcd.delayed_line_irq && gb_lcd.line_irq ) { |
| 1235 | if ( ( gb_lcd.delayed_line_irq && gb_lcd.line_irq && ! ( LCDSTAT & 0x20 ) ) || |
| 1236 | ( !gb_lcd.mode_irq && ! gb_lcd.line_irq && ! gb_lcd.delayed_line_irq && ( LCDSTAT & 0x20 ) ) ) { |
| 1219 | 1237 | cpunum_set_input_line( 0, LCD_INT, HOLD_LINE ); |
| 1220 | 1238 | } |
| 1221 | 1239 | /* Check if LY==LYC STAT bit should be set */ |