src/mess/machine/pokemini.c
| r8691 | r8692 | |
| 491 | 491 | int index = data & 0x07; |
| 492 | 492 | int cycles = ( pm_reg[0x19] & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 493 | 493 | |
| 494 | | timer_adjust_periodic(timers.timer1, attotime_zero, 0, cputag_clocks_to_attotime(device->machine, "maincpu", cycles)); |
| 494 | timer_adjust_periodic(timers.timer1, attotime_zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | /* Check for prescaler change for the high counter */ |
| r8691 | r8692 | |
| 500 | 500 | int index = ( data >> 4 ) & 0x07; |
| 501 | 501 | int cycles = ( pm_reg[0x19] & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 502 | 502 | |
| 503 | | timer_adjust_periodic(timers.timer1_hi, attotime_zero, 0, cputag_clocks_to_attotime(device->machine, "maincpu", cycles)); |
| 503 | timer_adjust_periodic(timers.timer1_hi, attotime_zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | /* Check if timer1 low should be enabled */ |
| r8691 | r8692 | |
| 541 | 541 | int index = pm_reg[0x18] & 0x07; |
| 542 | 542 | int cycles = ( data & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 543 | 543 | |
| 544 | | timer_adjust_periodic(timers.timer1, attotime_zero, 0, cputag_clocks_to_attotime(device->machine, "maincpu", cycles)); |
| 544 | timer_adjust_periodic(timers.timer1, attotime_zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | /* Check for prescaler change for the low counter */ |
| r8691 | r8692 | |
| 550 | 550 | int index = ( pm_reg[0x18] >> 4 ) & 0x07; |
| 551 | 551 | int cycles = ( data & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 552 | 552 | |
| 553 | | timer_adjust_periodic(timers.timer1_hi, attotime_zero, 0, cputag_clocks_to_attotime(device->machine, "maincpu", cycles)); |
| 553 | timer_adjust_periodic(timers.timer1_hi, attotime_zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | { |
| r8691 | r8692 | |
| 620 | 620 | int index = data & 0x07; |
| 621 | 621 | int cycles = ( pm_reg[0x1B] & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 622 | 622 | |
| 623 | | timer_adjust_periodic(timers.timer2, attotime_zero, 0, cputag_clocks_to_attotime(device->machine, "maincpu", cycles)); |
| 623 | timer_adjust_periodic(timers.timer2, attotime_zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | /* Check for prescaler change for the high counter */ |
| r8691 | r8692 | |
| 629 | 629 | int index = ( data >> 4 ) & 0x07; |
| 630 | 630 | int cycles = ( pm_reg[0x1B] & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 631 | 631 | |
| 632 | | timer_adjust_periodic(timers.timer2_hi, attotime_zero, 0, cputag_clocks_to_attotime(device->machine, "maincpu", cycles)); |
| 632 | timer_adjust_periodic(timers.timer2_hi, attotime_zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | /* Check if timer2 low should be enabled */ |
| r8691 | r8692 | |
| 666 | 666 | int index = pm_reg[0x1A] & 0x07; |
| 667 | 667 | int cycles = ( data & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 668 | 668 | |
| 669 | | timer_adjust_periodic(timers.timer2, attotime_zero, 0, cputag_clocks_to_attotime(device->machine, "maincpu", cycles)); |
| 669 | timer_adjust_periodic(timers.timer2, attotime_zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 670 | 670 | |
| 671 | 671 | if ( ( pm_reg[0x1A] & 0x08 ) && ( pm_reg[0x38] & 0x04 ) && |
| 672 | 672 | ( ( ( pm_reg[0x19] & 0x10 ) && ( data & 0x01 ) ) || |
| r8691 | r8692 | |
| 686 | 686 | int index = ( pm_reg[0x1A] >> 4 ) & 0x07; |
| 687 | 687 | int cycles = ( data & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 688 | 688 | |
| 689 | | timer_adjust_periodic(timers.timer2_hi, attotime_zero, 0, cputag_clocks_to_attotime(device->machine, "maincpu", cycles)); |
| 689 | timer_adjust_periodic(timers.timer2_hi, attotime_zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 690 | 690 | |
| 691 | 691 | if ( ( pm_reg[0x1A] & 0x80 ) && ( pm_reg[0x39] & 0x04 ) && ! ( pm_reg[0x38] & 0x80 ) && |
| 692 | 692 | ( ( ( pm_reg[0x19] & 0x10 ) && ( data & 0x02 ) ) || |
| r8691 | r8692 | |
| 720 | 720 | int index = data & 0x07; |
| 721 | 721 | int cycles = ( pm_reg[0x1D] & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 722 | 722 | |
| 723 | | timer_adjust_periodic(timers.timer3, attotime_zero, 0, cputag_clocks_to_attotime(device->machine, "maincpu", cycles)); |
| 723 | timer_adjust_periodic(timers.timer3, attotime_zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 724 | 724 | } |
| 725 | 725 | |
| 726 | 726 | /* Check for prescaler change for the high counter */ |
| r8691 | r8692 | |
| 729 | 729 | int index = ( data >> 4 ) & 0x07; |
| 730 | 730 | int cycles = ( pm_reg[0x1D] & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 731 | 731 | |
| 732 | | timer_adjust_periodic(timers.timer3_hi, attotime_zero, 0, cputag_clocks_to_attotime(device->machine, "maincpu", cycles)); |
| 732 | timer_adjust_periodic(timers.timer3_hi, attotime_zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | /* Check if timer2 low should be enabled */ |
| r8691 | r8692 | |
| 766 | 766 | int index = pm_reg[0x1C] & 0x07; |
| 767 | 767 | int cycles = ( data & 0x01 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 768 | 768 | |
| 769 | | timer_adjust_periodic(timers.timer3, attotime_zero, 0, cputag_clocks_to_attotime(device->machine, "maincpu", cycles)); |
| 769 | timer_adjust_periodic(timers.timer3, attotime_zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 770 | 770 | |
| 771 | 771 | if ( ( pm_reg[0x1C] & 0x08 ) && ( pm_reg[0x48] & 0x04 ) && |
| 772 | 772 | ( ( ( pm_reg[0x19] & 0x10 ) && ( data & 0x01 ) ) || |
| r8691 | r8692 | |
| 786 | 786 | int index = ( pm_reg[0x1C] >> 4 ) & 0x07; |
| 787 | 787 | int cycles = ( data & 0x02 ) ? timer_to_cycles_slow[index] : timer_to_cycles_fast[index]; |
| 788 | 788 | |
| 789 | | timer_adjust_periodic(timers.timer3_hi, attotime_zero, 0, cputag_clocks_to_attotime(device->machine, "maincpu", cycles)); |
| 789 | timer_adjust_periodic(timers.timer3_hi, attotime_zero, 0, device->machine->device<cpu_device>("maincpu")->cycles_to_attotime(cycles)); |
| 790 | 790 | |
| 791 | 791 | if ( ( pm_reg[0x1C] & 0x80 ) && ( pm_reg[0x49] & 0x04 ) && ! ( pm_reg[0x48] & 0x80 ) && |
| 792 | 792 | ( ( ( pm_reg[0x19] & 0x10 ) && ( data & 0x02 ) ) || |
| r8691 | r8692 | |
| 1606 | 1606 | /* Set up the PRC */ |
| 1607 | 1607 | prc.max_frame_count = 2; |
| 1608 | 1608 | prc.count_timer = timer_alloc(machine, pokemini_prc_counter_callback, NULL ); |
| 1609 | | timer_adjust_periodic( prc.count_timer, attotime_zero, 0, cputag_clocks_to_attotime(machine, "maincpu", 55640 / 65) ); |
| 1609 | timer_adjust_periodic( prc.count_timer, attotime_zero, 0, machine->device<cpu_device>("maincpu")->cycles_to_attotime(55640 / 65) ); |
| 1610 | 1610 | } |
| 1611 | 1611 | |
src/mess/video/gb.c
| r8691 | r8692 | |
| 362 | 362 | if ( ( LCDSTAT & 0x03 ) == 0x03 ) |
| 363 | 363 | { |
| 364 | 364 | /* Calculate number of pixels to render based on time still left on the timer */ |
| 365 | | UINT32 cycles_to_go = cputag_attotime_to_clocks(machine, "maincpu", timer_timeleft( gb_lcd.lcd_timer ) ); |
| 365 | UINT32 cycles_to_go = machine->device<cpu_device>("maincpu")->attotime_to_cycles(timer_timeleft( gb_lcd.lcd_timer ) ); |
| 366 | 366 | int l = 0; |
| 367 | 367 | |
| 368 | 368 | if ( gb_lcd.start_x < 0 ) |
| r8691 | r8692 | |
| 684 | 684 | if ( ( LCDSTAT & 0x03 ) == 0x03 ) |
| 685 | 685 | { |
| 686 | 686 | /* Calcuate number of pixels to render based on time still left on the timer */ |
| 687 | | UINT32 cycles_to_go = cputag_attotime_to_clocks(machine, "maincpu", timer_timeleft( gb_lcd.lcd_timer ) ); |
| 687 | UINT32 cycles_to_go = machine->device<cpu_device>("maincpu")->attotime_to_cycles(timer_timeleft( gb_lcd.lcd_timer ) ); |
| 688 | 688 | int l = 0; |
| 689 | 689 | |
| 690 | 690 | if ( gb_lcd.start_x < 0 ) |
| r8691 | r8692 | |
| 990 | 990 | if ( ( LCDSTAT & 0x03 ) == 0x03 ) |
| 991 | 991 | { |
| 992 | 992 | /* Calcuate number of pixels to render based on time still left on the timer */ |
| 993 | | UINT32 cycles_to_go = cputag_attotime_to_clocks(machine, "maincpu", timer_timeleft( gb_lcd.lcd_timer ) ); |
| 993 | UINT32 cycles_to_go = machine->device<cpu_device>("maincpu")->attotime_to_cycles(timer_timeleft( gb_lcd.lcd_timer ) ); |
| 994 | 994 | int l = 0; |
| 995 | 995 | |
| 996 | 996 | if ( gb_lcd.start_x < 0 ) |
| r8691 | r8692 | |
| 1344 | 1344 | switch( mode ) |
| 1345 | 1345 | { |
| 1346 | 1346 | case GB_VIDEO_DMG: |
| 1347 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 456), 0); |
| 1347 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(456), 0); |
| 1348 | 1348 | |
| 1349 | 1349 | /* set the scanline update function */ |
| 1350 | 1350 | update_scanline = gb_update_scanline; |
| r8691 | r8692 | |
| 1367 | 1367 | memcpy( gb_lcd.gb_oam->base(), mgb_oam_fingerprint, 0x100 ); |
| 1368 | 1368 | |
| 1369 | 1369 | /* Make sure the VBlank interrupt is set when the first instruction gets executed */ |
| 1370 | | timer_set(machine, cputag_clocks_to_attotime(machine, "maincpu", 1), NULL, 0, gb_video_init_vbl ); |
| 1370 | timer_set(machine, machine->device<cpu_device>("maincpu")->cycles_to_attotime(1), NULL, 0, gb_video_init_vbl ); |
| 1371 | 1371 | |
| 1372 | 1372 | /* Initialize some video registers */ |
| 1373 | 1373 | gb_video_w( space, 0x0, 0x91 ); /* LCDCONT */ |
| r8691 | r8692 | |
| 1378 | 1378 | CURLINE = gb_lcd.current_line = 0; |
| 1379 | 1379 | LCDSTAT = ( LCDSTAT & 0xF8 ) | 0x05; |
| 1380 | 1380 | gb_lcd.mode = 1; |
| 1381 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 60), GB_LCD_STATE_LY00_M0); |
| 1381 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(60), GB_LCD_STATE_LY00_M0); |
| 1382 | 1382 | |
| 1383 | 1383 | break; |
| 1384 | 1384 | case GB_VIDEO_SGB: |
| r8691 | r8692 | |
| 1472 | 1472 | gb_lcd.mode_irq = 0; |
| 1473 | 1473 | } |
| 1474 | 1474 | } |
| 1475 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 4), GB_LCD_STATE_LYXX_M0); |
| 1475 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0); |
| 1476 | 1476 | break; |
| 1477 | 1477 | case GB_LCD_STATE_LYXX_M0: /* Switch to mode 0 */ |
| 1478 | 1478 | /* update current scanline */ |
| r8691 | r8692 | |
| 1497 | 1497 | if ( ( SCROLLX & 0x03 ) == 0x03 ) |
| 1498 | 1498 | { |
| 1499 | 1499 | gb_lcd.scrollx_adjust += 4; |
| 1500 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 4), GB_LCD_STATE_LYXX_M0_SCX3); |
| 1500 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_SCX3); |
| 1501 | 1501 | break; |
| 1502 | 1502 | } |
| 1503 | 1503 | case GB_LCD_STATE_LYXX_M0_SCX3: |
| r8691 | r8692 | |
| 1507 | 1507 | { |
| 1508 | 1508 | cputag_set_input_line( machine, "maincpu", LCD_INT, ASSERT_LINE ); |
| 1509 | 1509 | } |
| 1510 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 196 - gb_lcd.scrollx_adjust - gb_lcd.sprite_cycles), GB_LCD_STATE_LYXX_M0_PRE_INC); |
| 1510 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(196 - gb_lcd.scrollx_adjust - gb_lcd.sprite_cycles), GB_LCD_STATE_LYXX_M0_PRE_INC); |
| 1511 | 1511 | break; |
| 1512 | 1512 | case GB_LCD_STATE_LYXX_M0_PRE_INC: /* Just before incrementing the line counter go to mode 2 internally */ |
| 1513 | 1513 | if ( CURLINE < 143 ) |
| r8691 | r8692 | |
| 1530 | 1530 | } |
| 1531 | 1531 | } |
| 1532 | 1532 | } |
| 1533 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 4), GB_LCD_STATE_LYXX_M0_INC); |
| 1533 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_INC); |
| 1534 | 1534 | break; |
| 1535 | 1535 | case GB_LCD_STATE_LYXX_M0_INC: /* Increment LY, stay in M0 for 4 more cycles */ |
| 1536 | 1536 | gb_increment_scanline(); |
| r8691 | r8692 | |
| 1547 | 1547 | /* Check if we're going into VBlank next */ |
| 1548 | 1548 | if ( CURLINE == 144 ) |
| 1549 | 1549 | { |
| 1550 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 4), GB_LCD_STATE_LY9X_M1); |
| 1550 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1); |
| 1551 | 1551 | } |
| 1552 | 1552 | else |
| 1553 | 1553 | { |
| r8691 | r8692 | |
| 1560 | 1560 | gb_lcd.mode_irq = 1; |
| 1561 | 1561 | cputag_set_input_line( machine, "maincpu", LCD_INT, ASSERT_LINE ); |
| 1562 | 1562 | } |
| 1563 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 4), GB_LCD_STATE_LYXX_M2); |
| 1563 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M2); |
| 1564 | 1564 | } |
| 1565 | 1565 | break; |
| 1566 | 1566 | case GB_LCD_STATE_LY00_M2: /* Switch to mode 2 on line #0 */ |
| r8691 | r8692 | |
| 1576 | 1576 | /* Check for regular compensation of x-scroll register */ |
| 1577 | 1577 | gb_lcd.scrollx_adjust = ( SCROLLX & 0x04 ) ? 4 : 0; |
| 1578 | 1578 | /* Mode 2 lasts approximately 80 clock cycles */ |
| 1579 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 80), GB_LCD_STATE_LYXX_M3); |
| 1579 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3); |
| 1580 | 1580 | break; |
| 1581 | 1581 | case GB_LCD_STATE_LYXX_M2: /* Switch to mode 2 */ |
| 1582 | 1582 | /* Update STAT register to the correct state */ |
| r8691 | r8692 | |
| 1598 | 1598 | /* Check for regular compensation of x-scroll register */ |
| 1599 | 1599 | gb_lcd.scrollx_adjust = ( SCROLLX & 0x04 ) ? 4 : 0; |
| 1600 | 1600 | /* Mode 2 last for approximately 80 clock cycles */ |
| 1601 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 80), GB_LCD_STATE_LYXX_M3); |
| 1601 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3); |
| 1602 | 1602 | break; |
| 1603 | 1603 | case GB_LCD_STATE_LYXX_M3: /* Switch to mode 3 */ |
| 1604 | 1604 | gb_select_sprites(); |
| r8691 | r8692 | |
| 1609 | 1609 | gb_lcd.vram_locked = LOCKED; |
| 1610 | 1610 | /* Check for compensations of x-scroll register */ |
| 1611 | 1611 | /* Mode 3 lasts for approximately 172+cycles needed to handle sprites clock cycles */ |
| 1612 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 168 + gb_lcd.scrollx_adjust + gb_lcd.sprite_cycles), GB_LCD_STATE_LYXX_PRE_M0); |
| 1612 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(168 + gb_lcd.scrollx_adjust + gb_lcd.sprite_cycles), GB_LCD_STATE_LYXX_PRE_M0); |
| 1613 | 1613 | gb_lcd.start_x = -1; |
| 1614 | 1614 | break; |
| 1615 | 1615 | case GB_LCD_STATE_LY9X_M1: /* Switch to or stay in mode 1 */ |
| r8691 | r8692 | |
| 1635 | 1635 | { |
| 1636 | 1636 | cputag_set_input_line( machine, "maincpu", LCD_INT, ASSERT_LINE ); |
| 1637 | 1637 | } |
| 1638 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 452), GB_LCD_STATE_LY9X_M1_INC); |
| 1638 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(452), GB_LCD_STATE_LY9X_M1_INC); |
| 1639 | 1639 | break; |
| 1640 | 1640 | case GB_LCD_STATE_LY9X_M1_INC: /* Increment scanline counter */ |
| 1641 | 1641 | gb_increment_scanline(); |
| r8691 | r8692 | |
| 1651 | 1651 | LCDSTAT &= 0xFB; |
| 1652 | 1652 | if ( gb_lcd.current_line == 153 ) |
| 1653 | 1653 | { |
| 1654 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 4), GB_LCD_STATE_LY00_M1); |
| 1654 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1); |
| 1655 | 1655 | } |
| 1656 | 1656 | else |
| 1657 | 1657 | { |
| 1658 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 4), GB_LCD_STATE_LY9X_M1); |
| 1658 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1); |
| 1659 | 1659 | } |
| 1660 | 1660 | break; |
| 1661 | 1661 | case GB_LCD_STATE_LY00_M1: /* we stay in VBlank but current line counter should already be incremented */ |
| r8691 | r8692 | |
| 1676 | 1676 | gb_lcd.triggering_line_irq = ( ( CMPLINE == CURLINE ) && ( LCDSTAT & 0x40 ) ) ? 1 : 0; |
| 1677 | 1677 | gb_lcd.line_irq = 0; |
| 1678 | 1678 | LCDSTAT &= 0xFB; |
| 1679 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 4/*8*/), GB_LCD_STATE_LY00_M1_1); |
| 1679 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4/*8*/), GB_LCD_STATE_LY00_M1_1); |
| 1680 | 1680 | break; |
| 1681 | 1681 | case GB_LCD_STATE_LY00_M1_1: |
| 1682 | 1682 | if ( ! gb_lcd.delayed_line_irq && gb_lcd.triggering_line_irq ) |
| r8691 | r8692 | |
| 1684 | 1684 | gb_lcd.line_irq = gb_lcd.triggering_line_irq; |
| 1685 | 1685 | cputag_set_input_line( machine, "maincpu", LCD_INT, ASSERT_LINE ); |
| 1686 | 1686 | } |
| 1687 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 4), GB_LCD_STATE_LY00_M1_2); |
| 1687 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1_2); |
| 1688 | 1688 | break; |
| 1689 | 1689 | case GB_LCD_STATE_LY00_M1_2: /* Rest of line #0 during VBlank */ |
| 1690 | 1690 | if ( gb_lcd.delayed_line_irq && gb_lcd.triggering_line_irq ) |
| r8691 | r8692 | |
| 1696 | 1696 | { |
| 1697 | 1697 | LCDSTAT |= 0x04; |
| 1698 | 1698 | } |
| 1699 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 444), GB_LCD_STATE_LY00_M0); |
| 1699 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(444), GB_LCD_STATE_LY00_M0); |
| 1700 | 1700 | break; |
| 1701 | 1701 | case GB_LCD_STATE_LY00_M0: /* The STAT register seems to go to 0 for about 4 cycles */ |
| 1702 | 1702 | /* Set Mode 0 lcdstat */ |
| 1703 | 1703 | gb_lcd.mode = 0; |
| 1704 | 1704 | LCDSTAT = ( LCDSTAT & 0xFC ); |
| 1705 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 4), GB_LCD_STATE_LY00_M2); |
| 1705 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M2); |
| 1706 | 1706 | break; |
| 1707 | 1707 | } |
| 1708 | 1708 | } |
| r8691 | r8692 | |
| 1713 | 1713 | { |
| 1714 | 1714 | update_scanline( machine ); |
| 1715 | 1715 | } |
| 1716 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 456), 0); |
| 1716 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(456), 0); |
| 1717 | 1717 | } |
| 1718 | 1718 | } |
| 1719 | 1719 | |
| r8691 | r8692 | |
| 1744 | 1744 | gb_lcd.mode_irq = 0; |
| 1745 | 1745 | } |
| 1746 | 1746 | } |
| 1747 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 4), GB_LCD_STATE_LYXX_M0); |
| 1747 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0); |
| 1748 | 1748 | break; |
| 1749 | 1749 | case GB_LCD_STATE_LYXX_M0: /* Switch to mode 0 */ |
| 1750 | 1750 | /* update current scanline */ |
| r8691 | r8692 | |
| 1770 | 1770 | if ( ( SCROLLX & 0x03 ) == 0x03 ) |
| 1771 | 1771 | { |
| 1772 | 1772 | gb_lcd.scrollx_adjust += 4; |
| 1773 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 4), GB_LCD_STATE_LYXX_M0_SCX3); |
| 1773 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_SCX3); |
| 1774 | 1774 | break; |
| 1775 | 1775 | } |
| 1776 | 1776 | case GB_LCD_STATE_LYXX_M0_SCX3: |
| r8691 | r8692 | |
| 1785 | 1785 | { |
| 1786 | 1786 | gb_lcd.pal_locked = UNLOCKED; |
| 1787 | 1787 | } |
| 1788 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 4), GB_LCD_STATE_LYXX_M0_GBC_PAL); |
| 1788 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_GBC_PAL); |
| 1789 | 1789 | break; |
| 1790 | 1790 | case GB_LCD_STATE_LYXX_M0_GBC_PAL: |
| 1791 | 1791 | gb_lcd.pal_locked = UNLOCKED; |
| r8691 | r8692 | |
| 1799 | 1799 | { |
| 1800 | 1800 | gb_lcd.hdma_possible = 1; |
| 1801 | 1801 | } |
| 1802 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 192 - gb_lcd.scrollx_adjust - gb_lcd.sprite_cycles), GB_LCD_STATE_LYXX_M0_PRE_INC); |
| 1802 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(192 - gb_lcd.scrollx_adjust - gb_lcd.sprite_cycles), GB_LCD_STATE_LYXX_M0_PRE_INC); |
| 1803 | 1803 | break; |
| 1804 | 1804 | case GB_LCD_STATE_LYXX_M0_PRE_INC: /* Just before incrementing the line counter go to mode 2 internally */ |
| 1805 | 1805 | gb_lcd.cmp_line = CMPLINE; |
| r8691 | r8692 | |
| 1822 | 1822 | } |
| 1823 | 1823 | } |
| 1824 | 1824 | } |
| 1825 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 4), GB_LCD_STATE_LYXX_M0_INC); |
| 1825 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M0_INC); |
| 1826 | 1826 | break; |
| 1827 | 1827 | case GB_LCD_STATE_LYXX_M0_INC: /* Increment LY, stay in M0 for 4 more cycles */ |
| 1828 | 1828 | gb_increment_scanline(); |
| r8691 | r8692 | |
| 1838 | 1838 | /* Check if we're going into VBlank next */ |
| 1839 | 1839 | if ( CURLINE == 144 ) |
| 1840 | 1840 | { |
| 1841 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 4), GB_LCD_STATE_LY9X_M1); |
| 1841 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1); |
| 1842 | 1842 | } |
| 1843 | 1843 | else |
| 1844 | 1844 | { |
| r8691 | r8692 | |
| 1851 | 1851 | gb_lcd.mode_irq = 1; |
| 1852 | 1852 | cputag_set_input_line( machine, "maincpu", LCD_INT, ASSERT_LINE ); |
| 1853 | 1853 | } |
| 1854 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 4), GB_LCD_STATE_LYXX_M2); |
| 1854 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LYXX_M2); |
| 1855 | 1855 | } |
| 1856 | 1856 | break; |
| 1857 | 1857 | case GB_LCD_STATE_LY00_M2: /* Switch to mode 2 on line #0 */ |
| r8691 | r8692 | |
| 1867 | 1867 | /* Check for regular compensation of x-scroll register */ |
| 1868 | 1868 | gb_lcd.scrollx_adjust = ( SCROLLX & 0x04 ) ? 4 : 0; |
| 1869 | 1869 | /* Mode 2 lasts approximately 80 clock cycles */ |
| 1870 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 80), GB_LCD_STATE_LYXX_M3); |
| 1870 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3); |
| 1871 | 1871 | break; |
| 1872 | 1872 | case GB_LCD_STATE_LYXX_M2: /* Switch to mode 2 */ |
| 1873 | 1873 | /* Update STAT register to the correct state */ |
| r8691 | r8692 | |
| 1892 | 1892 | /* Check for regular compensation of x-scroll register */ |
| 1893 | 1893 | gb_lcd.scrollx_adjust = ( SCROLLX & 0x04 ) ? 4 : 0; |
| 1894 | 1894 | /* Mode 2 last for approximately 80 clock cycles */ |
| 1895 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 80), GB_LCD_STATE_LYXX_M3); |
| 1895 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3); |
| 1896 | 1896 | break; |
| 1897 | 1897 | case GB_LCD_STATE_LYXX_M3: /* Switch to mode 3 */ |
| 1898 | 1898 | gb_select_sprites(); |
| r8691 | r8692 | |
| 1904 | 1904 | gb_lcd.pal_locked = LOCKED; |
| 1905 | 1905 | /* Check for compensations of x-scroll register */ |
| 1906 | 1906 | /* Mode 3 lasts for approximately 172+cycles needed to handle sprites clock cycles */ |
| 1907 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 168 + gb_lcd.scrollx_adjust + gb_lcd.sprite_cycles), GB_LCD_STATE_LYXX_PRE_M0); |
| 1907 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(168 + gb_lcd.scrollx_adjust + gb_lcd.sprite_cycles), GB_LCD_STATE_LYXX_PRE_M0); |
| 1908 | 1908 | gb_lcd.start_x = -1; |
| 1909 | 1909 | break; |
| 1910 | 1910 | case GB_LCD_STATE_LY9X_M1: /* Switch to or stay in mode 1 */ |
| r8691 | r8692 | |
| 1934 | 1934 | { |
| 1935 | 1935 | cputag_set_input_line( machine, "maincpu", LCD_INT, ASSERT_LINE ); |
| 1936 | 1936 | } |
| 1937 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 452), GB_LCD_STATE_LY9X_M1_INC); |
| 1937 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(452), GB_LCD_STATE_LY9X_M1_INC); |
| 1938 | 1938 | break; |
| 1939 | 1939 | case GB_LCD_STATE_LY9X_M1_INC: /* Increment scanline counter */ |
| 1940 | 1940 | gb_increment_scanline(); |
| r8691 | r8692 | |
| 1948 | 1948 | } |
| 1949 | 1949 | if ( gb_lcd.current_line == 153 ) |
| 1950 | 1950 | { |
| 1951 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 4), GB_LCD_STATE_LY00_M1); |
| 1951 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1); |
| 1952 | 1952 | } |
| 1953 | 1953 | else |
| 1954 | 1954 | { |
| 1955 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 4), GB_LCD_STATE_LY9X_M1); |
| 1955 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY9X_M1); |
| 1956 | 1956 | } |
| 1957 | 1957 | break; |
| 1958 | 1958 | case GB_LCD_STATE_LY00_M1: /* we stay in VBlank but current line counter should already be incremented */ |
| r8691 | r8692 | |
| 1977 | 1977 | gb_lcd.triggering_line_irq = ( ( CMPLINE == CURLINE ) && ( LCDSTAT & 0x40 ) ) ? 1 : 0; |
| 1978 | 1978 | gb_lcd.line_irq = 0; |
| 1979 | 1979 | LCDSTAT &= 0xFB; |
| 1980 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 4), GB_LCD_STATE_LY00_M1_1); |
| 1980 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1_1); |
| 1981 | 1981 | break; |
| 1982 | 1982 | case GB_LCD_STATE_LY00_M1_1: |
| 1983 | 1983 | if ( ! gb_lcd.delayed_line_irq && gb_lcd.triggering_line_irq ) |
| r8691 | r8692 | |
| 1985 | 1985 | gb_lcd.line_irq = gb_lcd.triggering_line_irq; |
| 1986 | 1986 | cputag_set_input_line( machine, "maincpu", LCD_INT, ASSERT_LINE ); |
| 1987 | 1987 | } |
| 1988 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 4), GB_LCD_STATE_LY00_M1_2); |
| 1988 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M1_2); |
| 1989 | 1989 | break; |
| 1990 | 1990 | case GB_LCD_STATE_LY00_M1_2: /* Rest of line #0 during VBlank */ |
| 1991 | 1991 | if ( gb_lcd.delayed_line_irq && gb_lcd.triggering_line_irq ) |
| r8691 | r8692 | |
| 2001 | 2001 | { |
| 2002 | 2002 | LCDSTAT &= ~0x04; |
| 2003 | 2003 | } |
| 2004 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 444), GB_LCD_STATE_LY00_M0); |
| 2004 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(444), GB_LCD_STATE_LY00_M0); |
| 2005 | 2005 | break; |
| 2006 | 2006 | case GB_LCD_STATE_LY00_M0: /* The STAT register seems to go to 0 for about 4 cycles */ |
| 2007 | 2007 | /* Set Mode 0 lcdstat */ |
| 2008 | 2008 | gb_lcd.mode = 0; |
| 2009 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 4), GB_LCD_STATE_LY00_M2); |
| 2009 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(4), GB_LCD_STATE_LY00_M2); |
| 2010 | 2010 | break; |
| 2011 | 2011 | } |
| 2012 | 2012 | } |
| r8691 | r8692 | |
| 2017 | 2017 | { |
| 2018 | 2018 | update_scanline( machine ); |
| 2019 | 2019 | } |
| 2020 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 456), 0); |
| 2020 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(456), 0); |
| 2021 | 2021 | } |
| 2022 | 2022 | } |
| 2023 | 2023 | |
| r8691 | r8692 | |
| 2041 | 2041 | } |
| 2042 | 2042 | } |
| 2043 | 2043 | gb_lcd.state = GB_LCD_STATE_LY00_M2; |
| 2044 | | timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 80), GB_LCD_STATE_LYXX_M3); |
| 2044 | timer_adjust_oneshot(gb_lcd.lcd_timer, machine->device<cpu_device>("maincpu")->cycles_to_attotime(80), GB_LCD_STATE_LYXX_M3); |
| 2045 | 2045 | } |
| 2046 | 2046 | |
| 2047 | 2047 | READ8_HANDLER( gb_video_r ) |
src/mess/drivers/px8.c
| r8691 | r8692 | |
| 460 | 460 | state->ier = data; |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | | /*------------------------------------------------- |
| 464 | | krtn_read - read keyboard return |
| 465 | | -------------------------------------------------*/ |
| 463 | ///*------------------------------------------------- |
| 464 | // krtn_read - read keyboard return |
| 465 | //-------------------------------------------------*/ |
| 466 | // |
| 467 | //static UINT8 krtn_read(running_machine *machine) |
| 468 | //{ |
| 469 | // px8_state *state = (px8_state *)machine->driver_data; |
| 470 | // UINT8 data = 0xff; |
| 471 | // |
| 472 | // switch (state->ksc) |
| 473 | // { |
| 474 | // case 0: data = input_port_read(machine, "KSC0"); break; |
| 475 | // case 1: data = input_port_read(machine, "KSC1"); break; |
| 476 | // case 2: data = input_port_read(machine, "KSC2"); break; |
| 477 | // case 3: data = input_port_read(machine, "KSC3"); break; |
| 478 | // case 4: data = input_port_read(machine, "KSC4"); break; |
| 479 | // case 5: data = input_port_read(machine, "KSC5"); break; |
| 480 | // case 6: data = input_port_read(machine, "KSC6"); break; |
| 481 | // case 7: data = input_port_read(machine, "KSC7"); break; |
| 482 | // case 8: data = input_port_read(machine, "KSC8"); break; |
| 483 | // case 9: data = input_port_read(machine, "SW4"); break; |
| 484 | // } |
| 485 | // |
| 486 | // return data; |
| 487 | //} |
| 488 | // |
| 489 | ///*------------------------------------------------- |
| 490 | // krtn_0_3_r - keyboard return 0..3 read |
| 491 | //-------------------------------------------------*/ |
| 492 | // |
| 493 | //static READ8_HANDLER( krtn_0_3_r ) |
| 494 | //{ |
| 495 | // return krtn_read(space->machine) & 0x0f; |
| 496 | //} |
| 497 | // |
| 498 | ///*------------------------------------------------- |
| 499 | // krtn_4_7_r - keyboard return 4..7 read |
| 500 | //-------------------------------------------------*/ |
| 501 | // |
| 502 | //static READ8_HANDLER( krtn_4_7_r ) |
| 503 | //{ |
| 504 | // return krtn_read(space->machine) >> 4; |
| 505 | //} |
| 506 | // |
| 507 | ///*------------------------------------------------- |
| 508 | // ksc_w - keyboard scan write |
| 509 | //-------------------------------------------------*/ |
| 510 | // |
| 511 | //static WRITE8_HANDLER( ksc_w ) |
| 512 | //{ |
| 513 | // px8_state *state = (px8_state *)space->machine->driver_data; |
| 514 | // |
| 515 | // state->ksc = data; |
| 516 | //} |
| 466 | 517 | |
| 467 | | static UINT8 krtn_read(running_machine *machine) |
| 468 | | { |
| 469 | | px8_state *state = (px8_state *)machine->driver_data; |
| 470 | | UINT8 data = 0xff; |
| 471 | | |
| 472 | | switch (state->ksc) |
| 473 | | { |
| 474 | | case 0: data = input_port_read(machine, "KSC0"); break; |
| 475 | | case 1: data = input_port_read(machine, "KSC1"); break; |
| 476 | | case 2: data = input_port_read(machine, "KSC2"); break; |
| 477 | | case 3: data = input_port_read(machine, "KSC3"); break; |
| 478 | | case 4: data = input_port_read(machine, "KSC4"); break; |
| 479 | | case 5: data = input_port_read(machine, "KSC5"); break; |
| 480 | | case 6: data = input_port_read(machine, "KSC6"); break; |
| 481 | | case 7: data = input_port_read(machine, "KSC7"); break; |
| 482 | | case 8: data = input_port_read(machine, "KSC8"); break; |
| 483 | | case 9: data = input_port_read(machine, "SW4"); break; |
| 484 | | } |
| 485 | | |
| 486 | | return data; |
| 487 | | } |
| 488 | | |
| 489 | | /*------------------------------------------------- |
| 490 | | krtn_0_3_r - keyboard return 0..3 read |
| 491 | | -------------------------------------------------*/ |
| 492 | | |
| 493 | | static READ8_HANDLER( krtn_0_3_r ) |
| 494 | | { |
| 495 | | return krtn_read(space->machine) & 0x0f; |
| 496 | | } |
| 497 | | |
| 498 | | /*------------------------------------------------- |
| 499 | | krtn_4_7_r - keyboard return 4..7 read |
| 500 | | -------------------------------------------------*/ |
| 501 | | |
| 502 | | static READ8_HANDLER( krtn_4_7_r ) |
| 503 | | { |
| 504 | | return krtn_read(space->machine) >> 4; |
| 505 | | } |
| 506 | | |
| 507 | | /*------------------------------------------------- |
| 508 | | ksc_w - keyboard scan write |
| 509 | | -------------------------------------------------*/ |
| 510 | | |
| 511 | | static WRITE8_HANDLER( ksc_w ) |
| 512 | | { |
| 513 | | px8_state *state = (px8_state *)space->machine->driver_data; |
| 514 | | |
| 515 | | state->ksc = data; |
| 516 | | } |
| 517 | | |
| 518 | 518 | /*************************************************************************** |
| 519 | 519 | MEMORY MAPS |
| 520 | 520 | ***************************************************************************/ |
| r8691 | r8692 | |
| 573 | 573 | ADDRESS_MAP( px8_sub_io ) |
| 574 | 574 | -------------------------------------------------*/ |
| 575 | 575 | |
| 576 | | static ADDRESS_MAP_START( px8_sub_io, ADDRESS_SPACE_IO, 8 ) |
| 577 | | // AM_RANGE(0x00, 0x00) AM_READWRITE() |
| 578 | | AM_RANGE(0x01, 0x01) AM_READ(krtn_0_3_r) |
| 579 | | // AM_RANGE(0x02, 0x02) AM_WRITE() |
| 580 | | AM_RANGE(0x03, 0x03) AM_WRITE(ksc_w) |
| 581 | | // AM_RANGE(0x04, 0x04) AM_WRITE() |
| 582 | | AM_RANGE(0x05, 0x05) AM_READ(krtn_4_7_r) |
| 583 | | // AM_RANGE(0x06, 0x06) AM_READ() |
| 584 | | // AM_RANGE(0x07, 0x07) AM_WRITE() |
| 585 | | ADDRESS_MAP_END |
| 576 | //static ADDRESS_MAP_START( px8_sub_io, ADDRESS_SPACE_IO, 8 ) |
| 577 | //// AM_RANGE(0x00, 0x00) AM_READWRITE() |
| 578 | // AM_RANGE(0x01, 0x01) AM_READ(krtn_0_3_r) |
| 579 | //// AM_RANGE(0x02, 0x02) AM_WRITE() |
| 580 | // AM_RANGE(0x03, 0x03) AM_WRITE(ksc_w) |
| 581 | //// AM_RANGE(0x04, 0x04) AM_WRITE() |
| 582 | // AM_RANGE(0x05, 0x05) AM_READ(krtn_4_7_r) |
| 583 | //// AM_RANGE(0x06, 0x06) AM_READ() |
| 584 | //// AM_RANGE(0x07, 0x07) AM_WRITE() |
| 585 | //ADDRESS_MAP_END |
| 586 | 586 | |
| 587 | 587 | /*************************************************************************** |
| 588 | 588 | INPUT PORTS |
src/mess/drivers/tandy2k.c
| r8691 | r8692 | |
| 198 | 198 | logerror("Address Control %02x\n", data); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | | static READ8_HANDLER( keyboard_x0_r ) |
| 202 | | { |
| 203 | | /* |
| 201 | //static READ8_HANDLER( keyboard_x0_r ) |
| 202 | //{ |
| 203 | // /* |
| 204 | // |
| 205 | // bit description |
| 206 | // |
| 207 | // 0 X0 |
| 208 | // 1 X1 |
| 209 | // 2 X2 |
| 210 | // 3 X3 |
| 211 | // 4 X4 |
| 212 | // 5 X5 |
| 213 | // 6 X6 |
| 214 | // 7 X7 |
| 215 | // |
| 216 | // */ |
| 217 | // |
| 218 | // tandy2k_state *state = (tandy2k_state *)space->machine->driver_data; |
| 219 | // |
| 220 | // UINT8 data = 0xff; |
| 221 | // |
| 222 | // if (!BIT(state->keylatch, 0)) data &= input_port_read(space->machine, "Y0"); |
| 223 | // if (!BIT(state->keylatch, 1)) data &= input_port_read(space->machine, "Y1"); |
| 224 | // if (!BIT(state->keylatch, 2)) data &= input_port_read(space->machine, "Y2"); |
| 225 | // if (!BIT(state->keylatch, 3)) data &= input_port_read(space->machine, "Y3"); |
| 226 | // if (!BIT(state->keylatch, 4)) data &= input_port_read(space->machine, "Y4"); |
| 227 | // if (!BIT(state->keylatch, 5)) data &= input_port_read(space->machine, "Y5"); |
| 228 | // if (!BIT(state->keylatch, 6)) data &= input_port_read(space->machine, "Y6"); |
| 229 | // if (!BIT(state->keylatch, 7)) data &= input_port_read(space->machine, "Y7"); |
| 230 | // if (!BIT(state->keylatch, 8)) data &= input_port_read(space->machine, "Y8"); |
| 231 | // if (!BIT(state->keylatch, 9)) data &= input_port_read(space->machine, "Y9"); |
| 232 | // if (!BIT(state->keylatch, 10)) data &= input_port_read(space->machine, "Y10"); |
| 233 | // if (!BIT(state->keylatch, 11)) data &= input_port_read(space->machine, "Y11"); |
| 234 | // |
| 235 | // return ~data; |
| 236 | //} |
| 237 | // |
| 238 | //static WRITE8_HANDLER( keyboard_y0_w ) |
| 239 | //{ |
| 240 | // /* |
| 241 | // |
| 242 | // bit description |
| 243 | // |
| 244 | // 0 Y0 |
| 245 | // 1 Y1 |
| 246 | // 2 Y2 |
| 247 | // 3 Y3 |
| 248 | // 4 Y4 |
| 249 | // 5 Y5 |
| 250 | // 6 Y6 |
| 251 | // 7 Y7 |
| 252 | // |
| 253 | // */ |
| 254 | // |
| 255 | // tandy2k_state *state = (tandy2k_state *)space->machine->driver_data; |
| 256 | // |
| 257 | // /* keyboard row select */ |
| 258 | // state->keylatch = (state->keylatch & 0xff00) | data; |
| 259 | //} |
| 260 | // |
| 261 | //static WRITE8_HANDLER( keyboard_y8_w ) |
| 262 | //{ |
| 263 | // /* |
| 264 | // |
| 265 | // bit description |
| 266 | // |
| 267 | // 0 Y8 |
| 268 | // 1 Y9 |
| 269 | // 2 Y10 |
| 270 | // 3 Y11 |
| 271 | // 4 LED 2 |
| 272 | // 5 LED 1 |
| 273 | // 6 |
| 274 | // 7 |
| 275 | // |
| 276 | // */ |
| 277 | // |
| 278 | // tandy2k_state *state = (tandy2k_state *)space->machine->driver_data; |
| 279 | // |
| 280 | // /* keyboard row select */ |
| 281 | // state->keylatch = ((data & 0x0f) << 8) | (state->keylatch & 0xff); |
| 282 | //} |
| 204 | 283 | |
| 205 | | bit description |
| 206 | | |
| 207 | | 0 X0 |
| 208 | | 1 X1 |
| 209 | | 2 X2 |
| 210 | | 3 X3 |
| 211 | | 4 X4 |
| 212 | | 5 X5 |
| 213 | | 6 X6 |
| 214 | | 7 X7 |
| 215 | | |
| 216 | | */ |
| 217 | | |
| 218 | | tandy2k_state *state = (tandy2k_state *)space->machine->driver_data; |
| 219 | | |
| 220 | | UINT8 data = 0xff; |
| 221 | | |
| 222 | | if (!BIT(state->keylatch, 0)) data &= input_port_read(space->machine, "Y0"); |
| 223 | | if (!BIT(state->keylatch, 1)) data &= input_port_read(space->machine, "Y1"); |
| 224 | | if (!BIT(state->keylatch, 2)) data &= input_port_read(space->machine, "Y2"); |
| 225 | | if (!BIT(state->keylatch, 3)) data &= input_port_read(space->machine, "Y3"); |
| 226 | | if (!BIT(state->keylatch, 4)) data &= input_port_read(space->machine, "Y4"); |
| 227 | | if (!BIT(state->keylatch, 5)) data &= input_port_read(space->machine, "Y5"); |
| 228 | | if (!BIT(state->keylatch, 6)) data &= input_port_read(space->machine, "Y6"); |
| 229 | | if (!BIT(state->keylatch, 7)) data &= input_port_read(space->machine, "Y7"); |
| 230 | | if (!BIT(state->keylatch, 8)) data &= input_port_read(space->machine, "Y8"); |
| 231 | | if (!BIT(state->keylatch, 9)) data &= input_port_read(space->machine, "Y9"); |
| 232 | | if (!BIT(state->keylatch, 10)) data &= input_port_read(space->machine, "Y10"); |
| 233 | | if (!BIT(state->keylatch, 11)) data &= input_port_read(space->machine, "Y11"); |
| 234 | | |
| 235 | | return ~data; |
| 236 | | } |
| 237 | | |
| 238 | | static WRITE8_HANDLER( keyboard_y0_w ) |
| 239 | | { |
| 240 | | /* |
| 241 | | |
| 242 | | bit description |
| 243 | | |
| 244 | | 0 Y0 |
| 245 | | 1 Y1 |
| 246 | | 2 Y2 |
| 247 | | 3 Y3 |
| 248 | | 4 Y4 |
| 249 | | 5 Y5 |
| 250 | | 6 Y6 |
| 251 | | 7 Y7 |
| 252 | | |
| 253 | | */ |
| 254 | | |
| 255 | | tandy2k_state *state = (tandy2k_state *)space->machine->driver_data; |
| 256 | | |
| 257 | | /* keyboard row select */ |
| 258 | | state->keylatch = (state->keylatch & 0xff00) | data; |
| 259 | | } |
| 260 | | |
| 261 | | static WRITE8_HANDLER( keyboard_y8_w ) |
| 262 | | { |
| 263 | | /* |
| 264 | | |
| 265 | | bit description |
| 266 | | |
| 267 | | 0 Y8 |
| 268 | | 1 Y9 |
| 269 | | 2 Y10 |
| 270 | | 3 Y11 |
| 271 | | 4 LED 2 |
| 272 | | 5 LED 1 |
| 273 | | 6 |
| 274 | | 7 |
| 275 | | |
| 276 | | */ |
| 277 | | |
| 278 | | tandy2k_state *state = (tandy2k_state *)space->machine->driver_data; |
| 279 | | |
| 280 | | /* keyboard row select */ |
| 281 | | state->keylatch = ((data & 0x0f) << 8) | (state->keylatch & 0xff); |
| 282 | | } |
| 283 | | |
| 284 | 284 | /* Memory Maps */ |
| 285 | 285 | |
| 286 | 286 | static ADDRESS_MAP_START( tandy2k_mem, ADDRESS_SPACE_PROGRAM, 16 ) |
| r8691 | r8692 | |
| 319 | 319 | // AM_RANGE(0x0026e, 0x0027f) AM_DEVREADWRITE8(WD1010_TAG, wd1010_r, wd1010_w, 0x00ff) |
| 320 | 320 | ADDRESS_MAP_END |
| 321 | 321 | |
| 322 | | static ADDRESS_MAP_START( keyboard_io, ADDRESS_SPACE_IO, 8 ) |
| 323 | | AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_WRITE(keyboard_y0_w) |
| 324 | | AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_WRITE(keyboard_y8_w) |
| 325 | | AM_RANGE(MCS48_PORT_BUS, MCS48_PORT_BUS) AM_READ(keyboard_x0_r) |
| 326 | | ADDRESS_MAP_END |
| 322 | //static ADDRESS_MAP_START( keyboard_io, ADDRESS_SPACE_IO, 8 ) |
| 323 | // AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_WRITE(keyboard_y0_w) |
| 324 | // AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_WRITE(keyboard_y8_w) |
| 325 | // AM_RANGE(MCS48_PORT_BUS, MCS48_PORT_BUS) AM_READ(keyboard_x0_r) |
| 326 | //ADDRESS_MAP_END |
| 327 | 327 | |
| 328 | 328 | /* Input Ports */ |
| 329 | 329 | |
src/mess/drivers/trs80m2.c
| r8691 | r8692 | |
| 323 | 323 | bankswitch(space->machine); |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | | static READ8_HANDLER( keyboard_busy_r ) |
| 327 | | { |
| 328 | | trs80m2_state *state = (trs80m2_state *)space->machine->driver_data; |
| 326 | //static READ8_HANDLER( keyboard_busy_r ) |
| 327 | //{ |
| 328 | // trs80m2_state *state = (trs80m2_state *)space->machine->driver_data; |
| 329 | // |
| 330 | // return state->kbirq; |
| 331 | //} |
| 332 | // |
| 333 | //static READ8_HANDLER( keyboard_data_r ) |
| 334 | //{ |
| 335 | // trs80m2_state *state = (trs80m2_state *)space->machine->driver_data; |
| 336 | // |
| 337 | // static const char *const KEY_ROW[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7", "ROW8", "ROW9", "ROW10", "ROW11" }; |
| 338 | // |
| 339 | // return input_port_read(space->machine, KEY_ROW[state->key_latch]); |
| 340 | //} |
| 341 | // |
| 342 | //static WRITE8_HANDLER( keyboard_ctrl_w ) |
| 343 | //{ |
| 344 | // /* |
| 345 | // |
| 346 | // bit description |
| 347 | // |
| 348 | // 0 DATA |
| 349 | // 1 CLOCK |
| 350 | // 2 LED |
| 351 | // 3 |
| 352 | // 4 LED |
| 353 | // 5 |
| 354 | // 6 |
| 355 | // 7 |
| 356 | // |
| 357 | // */ |
| 358 | // |
| 359 | // trs80m2_state *state = (trs80m2_state *)space->machine->driver_data; |
| 360 | // |
| 361 | // int kbdata = BIT(data, 0); |
| 362 | // int kbclk = BIT(data, 1); |
| 363 | // |
| 364 | // if (state->key_bit == 8) |
| 365 | // { |
| 366 | // if (!state->kbdata && kbdata) |
| 367 | // { |
| 368 | // /* trigger keyboard interrupt */ |
| 369 | // state->kbirq = 0; |
| 370 | // z80ctc_trg3_w(state->z80ctc, state->kbirq); |
| 371 | // } |
| 372 | // } |
| 373 | // else |
| 374 | // { |
| 375 | // if (!state->kbclk && kbclk) |
| 376 | // { |
| 377 | // /* shift in keyboard data bit */ |
| 378 | // state->key_data <<= 1; |
| 379 | // state->key_data |= kbdata; |
| 380 | // state->key_bit++; |
| 381 | // } |
| 382 | // } |
| 383 | // |
| 384 | // state->kbdata = kbdata; |
| 385 | // state->kbclk = kbclk; |
| 386 | //} |
| 387 | // |
| 388 | //static WRITE8_HANDLER( keyboard_latch_w ) |
| 389 | //{ |
| 390 | // /* |
| 391 | // |
| 392 | // bit description |
| 393 | // |
| 394 | // 0 D |
| 395 | // 1 C |
| 396 | // 2 B |
| 397 | // 3 A |
| 398 | // 4 |
| 399 | // 5 |
| 400 | // 6 |
| 401 | // 7 |
| 402 | // |
| 403 | // */ |
| 404 | // |
| 405 | // trs80m2_state *state = (trs80m2_state *)space->machine->driver_data; |
| 406 | // |
| 407 | // state->key_latch = BITSWAP8(data, 7, 6, 5, 4, 0, 1, 2, 3) & 0x0f; |
| 408 | //} |
| 329 | 409 | |
| 330 | | return state->kbirq; |
| 331 | | } |
| 332 | | |
| 333 | | static READ8_HANDLER( keyboard_data_r ) |
| 334 | | { |
| 335 | | trs80m2_state *state = (trs80m2_state *)space->machine->driver_data; |
| 336 | | |
| 337 | | static const char *const KEY_ROW[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5", "ROW6", "ROW7", "ROW8", "ROW9", "ROW10", "ROW11" }; |
| 338 | | |
| 339 | | return input_port_read(space->machine, KEY_ROW[state->key_latch]); |
| 340 | | } |
| 341 | | |
| 342 | | static WRITE8_HANDLER( keyboard_ctrl_w ) |
| 343 | | { |
| 344 | | /* |
| 345 | | |
| 346 | | bit description |
| 347 | | |
| 348 | | 0 DATA |
| 349 | | 1 CLOCK |
| 350 | | 2 LED |
| 351 | | 3 |
| 352 | | 4 LED |
| 353 | | 5 |
| 354 | | 6 |
| 355 | | 7 |
| 356 | | |
| 357 | | */ |
| 358 | | |
| 359 | | trs80m2_state *state = (trs80m2_state *)space->machine->driver_data; |
| 360 | | |
| 361 | | int kbdata = BIT(data, 0); |
| 362 | | int kbclk = BIT(data, 1); |
| 363 | | |
| 364 | | if (state->key_bit == 8) |
| 365 | | { |
| 366 | | if (!state->kbdata && kbdata) |
| 367 | | { |
| 368 | | /* trigger keyboard interrupt */ |
| 369 | | state->kbirq = 0; |
| 370 | | z80ctc_trg3_w(state->z80ctc, state->kbirq); |
| 371 | | } |
| 372 | | } |
| 373 | | else |
| 374 | | { |
| 375 | | if (!state->kbclk && kbclk) |
| 376 | | { |
| 377 | | /* shift in keyboard data bit */ |
| 378 | | state->key_data <<= 1; |
| 379 | | state->key_data |= kbdata; |
| 380 | | state->key_bit++; |
| 381 | | } |
| 382 | | } |
| 383 | | |
| 384 | | state->kbdata = kbdata; |
| 385 | | state->kbclk = kbclk; |
| 386 | | } |
| 387 | | |
| 388 | | static WRITE8_HANDLER( keyboard_latch_w ) |
| 389 | | { |
| 390 | | /* |
| 391 | | |
| 392 | | bit description |
| 393 | | |
| 394 | | 0 D |
| 395 | | 1 C |
| 396 | | 2 B |
| 397 | | 3 A |
| 398 | | 4 |
| 399 | | 5 |
| 400 | | 6 |
| 401 | | 7 |
| 402 | | |
| 403 | | */ |
| 404 | | |
| 405 | | trs80m2_state *state = (trs80m2_state *)space->machine->driver_data; |
| 406 | | |
| 407 | | state->key_latch = BITSWAP8(data, 7, 6, 5, 4, 0, 1, 2, 3) & 0x0f; |
| 408 | | } |
| 409 | | |
| 410 | 410 | /* Memory Maps */ |
| 411 | 411 | |
| 412 | 412 | static ADDRESS_MAP_START( z80_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| r8691 | r8692 | |
| 429 | 429 | AM_RANGE(0xff, 0xff) AM_READWRITE(nmi_r, nmi_w) |
| 430 | 430 | ADDRESS_MAP_END |
| 431 | 431 | |
| 432 | | static ADDRESS_MAP_START( trs80m2_keyboard_io, ADDRESS_SPACE_IO, 8 ) |
| 433 | | AM_RANGE(MCS48_PORT_T1, MCS48_PORT_T1) AM_READ(keyboard_busy_r) |
| 434 | | AM_RANGE(MCS48_PORT_P0, MCS48_PORT_P0) AM_READ(keyboard_data_r) |
| 435 | | AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_WRITE(keyboard_ctrl_w) |
| 436 | | AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_WRITE(keyboard_latch_w) |
| 437 | | ADDRESS_MAP_END |
| 432 | //static ADDRESS_MAP_START( trs80m2_keyboard_io, ADDRESS_SPACE_IO, 8 ) |
| 433 | // AM_RANGE(MCS48_PORT_T1, MCS48_PORT_T1) AM_READ(keyboard_busy_r) |
| 434 | // AM_RANGE(MCS48_PORT_P0, MCS48_PORT_P0) AM_READ(keyboard_data_r) |
| 435 | // AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_WRITE(keyboard_ctrl_w) |
| 436 | // AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_WRITE(keyboard_latch_w) |
| 437 | //ADDRESS_MAP_END |
| 438 | 438 | |
| 439 | | static ADDRESS_MAP_START( m68000_mem, ADDRESS_SPACE_PROGRAM, 16 ) |
| 440 | | ADDRESS_MAP_END |
| 439 | //static ADDRESS_MAP_START( m68000_mem, ADDRESS_SPACE_PROGRAM, 16 ) |
| 440 | //ADDRESS_MAP_END |
| 441 | 441 | |
| 442 | 442 | /* Input Ports */ |
| 443 | 443 | |