src/mame/video/ppu2c0x.c
| r3941 | r3942 | |
| 25 | 25 | ******************************************************************************/ |
| 26 | 26 | |
| 27 | 27 | #include "driver.h" |
| 28 | | #include "deprecat.h" |
| 29 | 28 | #include "profiler.h" |
| 30 | 29 | #include "video/ppu2c0x.h" |
| 31 | 30 | |
| r3941 | r3942 | |
| 113 | 112 | /* chips state - allocated at init time */ |
| 114 | 113 | static ppu2c0x_chip *chips = 0; |
| 115 | 114 | |
| 116 | | static void update_scanline(int num ); |
| 115 | static void update_scanline(running_machine *machine, int num ); |
| 117 | 116 | |
| 118 | 117 | static TIMER_CALLBACK( scanline_callback ); |
| 119 | 118 | static TIMER_CALLBACK( hblank_callback ); |
| r3941 | r3942 | |
| 382 | 381 | int blanked = ( ppu_regs[PPU_CONTROL1] & ( PPU_CONTROL1_BACKGROUND | PPU_CONTROL1_SPRITES ) ) == 0; |
| 383 | 382 | int vblank = ((this_ppu->scanline >= PPU_VBLANK_FIRST_SCANLINE-1) && (this_ppu->scanline < this_ppu->scanlines_per_frame-1)) ? 1 : 0; |
| 384 | 383 | |
| 385 | | // update_scanline (num); |
| 384 | // update_scanline (machine, num); |
| 386 | 385 | |
| 387 | 386 | if (this_ppu->hblank_callback_proc) |
| 388 | | (*this_ppu->hblank_callback_proc) (num, this_ppu->scanline, vblank, blanked); |
| 387 | (*this_ppu->hblank_callback_proc) (machine, num, this_ppu->scanline, vblank, blanked); |
| 389 | 388 | |
| 390 | 389 | timer_adjust_oneshot(chips[num].hblank_timer, attotime_never, num); |
| 391 | 390 | } |
| r3941 | r3942 | |
| 397 | 396 | |
| 398 | 397 | // Actually fire the VMI |
| 399 | 398 | if (intf->nmi_handler[num]) |
| 400 | | (*intf->nmi_handler[num]) (num, ppu_regs); |
| 399 | (*intf->nmi_handler[num]) (machine, num, ppu_regs); |
| 401 | 400 | |
| 402 | 401 | timer_adjust_oneshot(chips[num].nmi_timer, attotime_never, num); |
| 403 | 402 | } |
| 404 | 403 | |
| 405 | | static void draw_background(const int num, UINT8 *line_priority ) |
| 404 | static void draw_background(running_machine *machine, int num, UINT8 *line_priority ) |
| 406 | 405 | { |
| 407 | 406 | /* cache some values locally */ |
| 408 | 407 | bitmap_t *bitmap = chips[num].bitmap; |
| r3941 | r3942 | |
| 541 | 540 | } |
| 542 | 541 | } |
| 543 | 542 | |
| 544 | | static void draw_sprites(const int num, UINT8 *line_priority ) |
| 543 | static void draw_sprites(running_machine *machine, int num, UINT8 *line_priority ) |
| 545 | 544 | { |
| 546 | 545 | /* cache some values locally */ |
| 547 | 546 | bitmap_t *bitmap = chips[num].bitmap; |
| r3941 | r3942 | |
| 727 | 726 | * Scanline Rendering and Update |
| 728 | 727 | * |
| 729 | 728 | *************************************/ |
| 730 | | static void render_scanline(int num) |
| 729 | static void render_scanline(running_machine *machine, int num) |
| 731 | 730 | { |
| 732 | 731 | UINT8 line_priority[VISIBLE_SCREEN_WIDTH]; |
| 733 | 732 | int *ppu_regs = &chips[num].regs[0]; |
| r3941 | r3942 | |
| 743 | 742 | |
| 744 | 743 | /* see if we need to render the background */ |
| 745 | 744 | if ( ppu_regs[PPU_CONTROL1] & PPU_CONTROL1_BACKGROUND ) |
| 746 | | draw_background(num, line_priority ); |
| 745 | draw_background(machine, num, line_priority ); |
| 747 | 746 | else |
| 748 | 747 | { |
| 749 | 748 | bitmap_t *bitmap = chips[num].bitmap; |
| r3941 | r3942 | |
| 768 | 767 | |
| 769 | 768 | /* if sprites are on, draw them */ |
| 770 | 769 | if ( ppu_regs[PPU_CONTROL1] & PPU_CONTROL1_SPRITES ) |
| 771 | | draw_sprites( num, line_priority ); |
| 770 | draw_sprites( machine, num, line_priority ); |
| 772 | 771 | |
| 773 | 772 | /* done updating, whew */ |
| 774 | 773 | profiler_mark(PROFILER_END); |
| 775 | 774 | } |
| 776 | 775 | |
| 777 | | static void update_scanline(int num ) |
| 776 | static void update_scanline(running_machine *machine, int num ) |
| 778 | 777 | { |
| 779 | 778 | ppu2c0x_chip* this_ppu; |
| 780 | 779 | int scanline = chips[num].scanline; |
| r3941 | r3942 | |
| 793 | 792 | this_ppu->refresh_data |= ( this_ppu->refresh_latch & 0x041f ); |
| 794 | 793 | |
| 795 | 794 | //logerror(" updating refresh_data: %04x (scanline: %d)\n", this_ppu->refresh_data, this_ppu->scanline); |
| 796 | | render_scanline( num ); |
| 795 | render_scanline( machine, num ); |
| 797 | 796 | } |
| 798 | 797 | else |
| 799 | 798 | { |
| r3941 | r3942 | |
| 867 | 866 | |
| 868 | 867 | /* if a callback is available, call it */ |
| 869 | 868 | if ( this_ppu->scanline_callback_proc ) |
| 870 | | (*this_ppu->scanline_callback_proc)( num, this_ppu->scanline, vblank, blanked ); |
| 869 | (*this_ppu->scanline_callback_proc)( machine, num, this_ppu->scanline, vblank, blanked ); |
| 871 | 870 | |
| 872 | 871 | /* update the scanline that just went by */ |
| 873 | | update_scanline( num ); |
| 872 | update_scanline( machine, num ); |
| 874 | 873 | |
| 875 | 874 | /* increment our scanline count */ |
| 876 | 875 | this_ppu->scanline++; |
| r3941 | r3942 | |
| 1027 | 1026 | * PPU Registers Read |
| 1028 | 1027 | * |
| 1029 | 1028 | *************************************/ |
| 1030 | | int ppu2c0x_r( int num, offs_t offset ) |
| 1029 | int ppu2c0x_r( const address_space *space, offs_t offset, int num ) |
| 1031 | 1030 | { |
| 1032 | 1031 | ppu2c0x_chip* this_ppu; |
| 1033 | 1032 | |
| r3941 | r3942 | |
| 1100 | 1099 | * PPU Registers Write |
| 1101 | 1100 | * |
| 1102 | 1101 | *************************************/ |
| 1103 | | void ppu2c0x_w( int num, offs_t offset, UINT8 data ) |
| 1102 | void ppu2c0x_w( const address_space *space, offs_t offset, UINT8 data, int num ) |
| 1104 | 1103 | { |
| 1105 | 1104 | ppu2c0x_chip* this_ppu; |
| 1106 | 1105 | int color_base; |
| r3941 | r3942 | |
| 1123 | 1122 | |
| 1124 | 1123 | #ifdef MAME_DEBUG |
| 1125 | 1124 | if (this_ppu->scanline <= PPU_BOTTOM_VISIBLE_SCANLINE) |
| 1126 | | logerror(" PPU register %d write %02x during non-vblank scanline %d (MAME %d, beam pos: %d)\n", offset, data, this_ppu->scanline, video_screen_get_vpos(Machine->primary_screen), video_screen_get_hpos(Machine->primary_screen)); |
| 1125 | { |
| 1126 | const device_config *screen = space->machine->primary_screen; |
| 1127 | logerror(" PPU register %d write %02x during non-vblank scanline %d (MAME %d, beam pos: %d)\n", offset, data, this_ppu->scanline, video_screen_get_vpos(screen), video_screen_get_hpos(screen)); |
| 1128 | } |
| 1127 | 1129 | #endif |
| 1128 | 1130 | |
| 1129 | 1131 | switch( offset & 7 ) |
| r3941 | r3942 | |
| 1225 | 1227 | |
| 1226 | 1228 | /* if there's a callback, call it now */ |
| 1227 | 1229 | if ( this_ppu->vidaccess_callback_proc ) |
| 1228 | | data = (*this_ppu->vidaccess_callback_proc)( num, tempAddr, data ); |
| 1230 | data = (*this_ppu->vidaccess_callback_proc)( space->machine, num, tempAddr, data ); |
| 1229 | 1231 | |
| 1230 | 1232 | /* see if it's on the chargen portion */ |
| 1231 | 1233 | if ( tempAddr < 0x2000 ) |
| r3941 | r3942 | |
| 1329 | 1331 | for (i = 0; i < SPRITERAM_SIZE; i++) |
| 1330 | 1332 | { |
| 1331 | 1333 | UINT8 spriteData = memory_read_byte(space, address + i); |
| 1332 | | ppu2c0x_w (num, PPU_SPRITE_DATA, spriteData); |
| 1334 | ppu2c0x_w (space, PPU_SPRITE_DATA, spriteData, num); |
| 1333 | 1335 | } |
| 1334 | 1336 | |
| 1335 | 1337 | // should last 513 CPU cycles. |
| r3941 | r3942 | |
| 1415 | 1417 | int count = num_pages * 0x400; |
| 1416 | 1418 | int rom_start = bank * bank_size * 16; |
| 1417 | 1419 | |
| 1418 | | memcpy( &chips[num].videomem[vram_start], &memory_region( Machine, intf->vrom_region[num] )[rom_start], count ); |
| 1420 | memcpy( &chips[num].videomem[vram_start], &memory_region( chips[num].machine, intf->vrom_region[num] )[rom_start], count ); |
| 1419 | 1421 | } |
| 1420 | 1422 | } |
| 1421 | 1423 | |
| r3941 | r3942 | |
| 1644 | 1646 | |
| 1645 | 1647 | READ8_HANDLER( ppu2c0x_0_r ) |
| 1646 | 1648 | { |
| 1647 | | return ppu2c0x_r( 0, offset ); |
| 1649 | return ppu2c0x_r( space, offset, 0 ); |
| 1648 | 1650 | } |
| 1649 | 1651 | |
| 1650 | 1652 | READ8_HANDLER( ppu2c0x_1_r ) |
| 1651 | 1653 | { |
| 1652 | | return ppu2c0x_r( 1, offset ); |
| 1654 | return ppu2c0x_r( space, offset, 1 ); |
| 1653 | 1655 | } |
| 1654 | 1656 | |
| 1655 | 1657 | WRITE8_HANDLER( ppu2c0x_0_w ) |
| 1656 | 1658 | { |
| 1657 | | ppu2c0x_w( 0, offset, data ); |
| 1659 | ppu2c0x_w( space, offset, data, 0 ); |
| 1658 | 1660 | } |
| 1659 | 1661 | |
| 1660 | 1662 | WRITE8_HANDLER( ppu2c0x_1_w ) |
| 1661 | 1663 | { |
| 1662 | | ppu2c0x_w( 1, offset, data ); |
| 1664 | ppu2c0x_w( space, offset, data, 1 ); |
| 1663 | 1665 | } |
src/mess/machine/nes_mmc.c
| r3941 | r3942 | |
| 23 | 23 | really MMC3, Mapper 9 is MMC2 and Mapper 10 is MMC4. Makes perfect sense, right? |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | | #include <string.h> |
| 27 | | |
| 28 | 26 | #include "cpu/m6502/m6502.h" |
| 29 | 27 | #include "video/ppu2c0x.h" |
| 30 | | #include "osdepend.h" |
| 31 | | #include "deprecat.h" |
| 32 | 28 | #include "driver.h" |
| 33 | 29 | #include "includes/nes.h" |
| 34 | 30 | #include "nes_mmc.h" |
| r3941 | r3942 | |
| 617 | 613 | ppu2c0x_set_videorom_bank(0, chr_page ^ 7, 1, MMC3_chr_base * 64 | ( MMC3_chr[5] & ( MMC3_chr_mask * 64 ) ), 1); |
| 618 | 614 | } |
| 619 | 615 | |
| 620 | | static void mapper4_irq ( int num, int scanline, int vblank, int blanked ) |
| 616 | static void mapper4_irq ( running_machine *machine, int num, int scanline, int vblank, int blanked ) |
| 621 | 617 | { |
| 622 | 618 | if ((scanline < PPU_BOTTOM_VISIBLE_SCANLINE) /*|| (scanline == ppu_scanlines_per_frame-1)*/) |
| 623 | 619 | { |
| r3941 | r3942 | |
| 632 | 628 | |
| 633 | 629 | if (IRQ_enable && !blanked && (IRQ_count == 0) && priorCount) |
| 634 | 630 | { |
| 635 | | logerror("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline, video_screen_get_vpos(Machine->primary_screen), video_screen_get_hpos(Machine->primary_screen)); |
| 636 | | cpu_set_input_line(Machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 631 | logerror("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline, video_screen_get_vpos(machine->primary_screen), video_screen_get_hpos(machine->primary_screen)); |
| 632 | cpu_set_input_line(machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 637 | 633 | // timer_adjust_oneshot(nes_irq_timer, cpu_clocks_to_attotime(machine->cpu[0], 4), 0); |
| 638 | 634 | } |
| 639 | 635 | } |
| r3941 | r3942 | |
| 826 | 822 | } |
| 827 | 823 | } |
| 828 | 824 | |
| 829 | | static void mapper5_irq ( int num, int scanline, int vblank, int blanked ) |
| 825 | static void mapper5_irq ( running_machine *machine, int num, int scanline, int vblank, int blanked ) |
| 830 | 826 | { |
| 831 | 827 | #if 1 |
| 832 | 828 | if (scanline == 0) |
| r3941 | r3942 | |
| 838 | 834 | if (scanline == IRQ_count) |
| 839 | 835 | { |
| 840 | 836 | if (IRQ_enable) |
| 841 | | cpu_set_input_line(Machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 837 | cpu_set_input_line(machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 842 | 838 | |
| 843 | 839 | IRQ_status = 0xff; |
| 844 | 840 | } |
| r3941 | r3942 | |
| 1578 | 1574 | } |
| 1579 | 1575 | } |
| 1580 | 1576 | |
| 1581 | | static void bandai_irq ( int num, int scanline, int vblank, int blanked ) |
| 1577 | static void bandai_irq ( running_machine *machine, int num, int scanline, int vblank, int blanked ) |
| 1582 | 1578 | { |
| 1583 | 1579 | /* 114 is the number of cycles per scanline */ |
| 1584 | 1580 | /* TODO: change to reflect the actual number of cycles spent */ |
| r3941 | r3942 | |
| 1587 | 1583 | { |
| 1588 | 1584 | if (IRQ_count <= 114) |
| 1589 | 1585 | { |
| 1590 | | cpu_set_input_line(Machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 1586 | cpu_set_input_line(machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 1591 | 1587 | } |
| 1592 | 1588 | IRQ_count -= 114; |
| 1593 | 1589 | } |
| r3941 | r3942 | |
| 1713 | 1709 | } |
| 1714 | 1710 | } |
| 1715 | 1711 | |
| 1716 | | static void jaleco_irq ( int num, int scanline, int vblank, int blanked ) |
| 1712 | static void jaleco_irq ( running_machine *machine, int num, int scanline, int vblank, int blanked ) |
| 1717 | 1713 | { |
| 1718 | 1714 | if (scanline <= PPU_BOTTOM_VISIBLE_SCANLINE) |
| 1719 | 1715 | { |
| r3941 | r3942 | |
| 1727 | 1723 | { |
| 1728 | 1724 | if ((IRQ_count & 0x0f) == 0x00) |
| 1729 | 1725 | /* rollover every 0x10 */ |
| 1730 | | cpu_set_input_line(Machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 1726 | cpu_set_input_line(machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 1731 | 1727 | } |
| 1732 | 1728 | else if (IRQ_mode & 0x04) |
| 1733 | 1729 | { |
| 1734 | 1730 | if ((IRQ_count & 0x0ff) == 0x00) |
| 1735 | 1731 | /* rollover every 0x100 */ |
| 1736 | | cpu_set_input_line(Machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 1732 | cpu_set_input_line(machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 1737 | 1733 | } |
| 1738 | 1734 | else if (IRQ_mode & 0x02) |
| 1739 | 1735 | { |
| 1740 | 1736 | if ((IRQ_count & 0x0fff) == 0x000) |
| 1741 | 1737 | /* rollover every 0x1000 */ |
| 1742 | | cpu_set_input_line(Machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 1738 | cpu_set_input_line(machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 1743 | 1739 | } |
| 1744 | 1740 | else if (IRQ_count == 0) |
| 1745 | 1741 | /* rollover at 0x10000 */ |
| 1746 | | cpu_set_input_line(Machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 1742 | cpu_set_input_line(machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 1747 | 1743 | } |
| 1748 | 1744 | } |
| 1749 | 1745 | else |
| r3941 | r3942 | |
| 1955 | 1951 | } |
| 1956 | 1952 | } |
| 1957 | 1953 | |
| 1958 | | static void namcot_irq ( int num, int scanline, int vblank, int blanked ) |
| 1954 | static void namcot_irq ( running_machine *machine, int num, int scanline, int vblank, int blanked ) |
| 1959 | 1955 | { |
| 1960 | 1956 | IRQ_count ++; |
| 1961 | 1957 | /* Increment & check the IRQ scanline counter */ |
| 1962 | 1958 | if (IRQ_enable && (IRQ_count == 0x7fff)) |
| 1963 | 1959 | { |
| 1964 | | cpu_set_input_line(Machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 1960 | cpu_set_input_line(machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 1965 | 1961 | } |
| 1966 | 1962 | } |
| 1967 | 1963 | |
| r3941 | r3942 | |
| 2015 | 2011 | } |
| 2016 | 2012 | } |
| 2017 | 2013 | |
| 2018 | | static void fds_irq ( int num, int scanline, int vblank, int blanked ) |
| 2014 | static void fds_irq ( running_machine *machine, int num, int scanline, int vblank, int blanked ) |
| 2019 | 2015 | { |
| 2020 | 2016 | if (IRQ_enable_latch) |
| 2021 | | cpu_set_input_line(Machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 2017 | cpu_set_input_line(machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 2022 | 2018 | |
| 2023 | 2019 | /* Increment & check the IRQ scanline counter */ |
| 2024 | 2020 | if (IRQ_enable) |
| 2025 | 2021 | { |
| 2026 | 2022 | if (IRQ_count <= 114) |
| 2027 | 2023 | { |
| 2028 | | cpu_set_input_line(Machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 2024 | cpu_set_input_line(machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 2029 | 2025 | IRQ_enable = 0; |
| 2030 | 2026 | nes_fds.status0 |= 0x01; |
| 2031 | 2027 | } |
| r3941 | r3942 | |
| 2129 | 2125 | LOG_FDS(("fds_w, address: %04x, data: %02x\n", offset + 0x4020, data)); |
| 2130 | 2126 | } |
| 2131 | 2127 | |
| 2132 | | static void konami_irq ( int num, int scanline, int vblank, int blanked ) |
| 2128 | static void konami_irq ( running_machine *machine, int num, int scanline, int vblank, int blanked ) |
| 2133 | 2129 | { |
| 2134 | 2130 | /* Increment & check the IRQ scanline counter */ |
| 2135 | 2131 | if (IRQ_enable && (++IRQ_count == 0x100)) |
| 2136 | 2132 | { |
| 2137 | 2133 | IRQ_count = IRQ_count_latch; |
| 2138 | 2134 | IRQ_enable = IRQ_enable_latch; |
| 2139 | | cpu_set_input_line(Machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 2135 | cpu_set_input_line(machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 2140 | 2136 | } |
| 2141 | 2137 | } |
| 2142 | 2138 | |
| r3941 | r3942 | |
| 2796 | 2792 | prg32 (space, data); |
| 2797 | 2793 | } |
| 2798 | 2794 | |
| 2799 | | static void mapper40_irq ( int num, int scanline, int vblank, int blanked ) |
| 2795 | static void mapper40_irq ( running_machine *machine, int num, int scanline, int vblank, int blanked ) |
| 2800 | 2796 | { |
| 2801 | 2797 | /* Decrement & check the IRQ scanline counter */ |
| 2802 | 2798 | if (IRQ_enable) |
| 2803 | 2799 | { |
| 2804 | 2800 | if (--IRQ_count == 0) |
| 2805 | 2801 | { |
| 2806 | | cpu_set_input_line(Machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 2802 | cpu_set_input_line(machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 2807 | 2803 | } |
| 2808 | 2804 | } |
| 2809 | 2805 | } |
| r3941 | r3942 | |
| 3241 | 3237 | } |
| 3242 | 3238 | } |
| 3243 | 3239 | |
| 3244 | | static void irem_irq ( int num, int scanline, int vblank, int blanked ) |
| 3240 | static void irem_irq ( running_machine *machine, int num, int scanline, int vblank, int blanked ) |
| 3245 | 3241 | { |
| 3246 | 3242 | /* Increment & check the IRQ scanline counter */ |
| 3247 | 3243 | if (IRQ_enable) |
| 3248 | 3244 | { |
| 3249 | 3245 | if (--IRQ_count == 0) |
| 3250 | | cpu_set_input_line(Machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 3246 | cpu_set_input_line(machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 3251 | 3247 | } |
| 3252 | 3248 | } |
| 3253 | 3249 | |
| r3941 | r3942 | |
| 3316 | 3312 | chr8 (data & 0x03); |
| 3317 | 3313 | } |
| 3318 | 3314 | |
| 3319 | | static void sunsoft_irq ( int num, int scanline, int vblank, int blanked ) |
| 3315 | static void sunsoft_irq ( running_machine *machine, int num, int scanline, int vblank, int blanked ) |
| 3320 | 3316 | { |
| 3321 | 3317 | /* 114 is the number of cycles per scanline */ |
| 3322 | 3318 | /* TODO: change to reflect the actual number of cycles spent */ |
| r3941 | r3942 | |
| 3325 | 3321 | { |
| 3326 | 3322 | if (IRQ_count <= 114) |
| 3327 | 3323 | { |
| 3328 | | cpu_set_input_line(Machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 3324 | cpu_set_input_line(machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 3329 | 3325 | } |
| 3330 | 3326 | IRQ_count -= 114; |
| 3331 | 3327 | } |
| r3941 | r3942 | |
| 4309 | 4305 | } |
| 4310 | 4306 | } |
| 4311 | 4307 | |
| 4312 | | static void mapper182_irq( int num, int scanline, int vblank, int blanked ) |
| 4308 | static void mapper182_irq( running_machine *machine, int num, int scanline, int vblank, int blanked ) |
| 4313 | 4309 | { |
| 4314 | 4310 | if ((scanline < PPU_BOTTOM_VISIBLE_SCANLINE) /*|| (scanline == ppu_scanlines_per_frame-1)*/) |
| 4315 | 4311 | { |
| r3941 | r3942 | |
| 4324 | 4320 | |
| 4325 | 4321 | if (IRQ_enable && !blanked && (IRQ_count == 0) && priorCount) |
| 4326 | 4322 | { |
| 4327 | | logerror("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline, video_screen_get_vpos(Machine->primary_screen), video_screen_get_hpos(Machine->primary_screen)); |
| 4328 | | cpu_set_input_line(Machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 4323 | logerror("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline, video_screen_get_vpos(machine->primary_screen), video_screen_get_hpos(machine->primary_screen)); |
| 4324 | cpu_set_input_line(machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 4329 | 4325 | } |
| 4330 | 4326 | } |
| 4331 | 4327 | } |
| r3941 | r3942 | |
| 4815 | 4811 | } |
| 4816 | 4812 | } |
| 4817 | 4813 | |
| 4818 | | static void mapper248_irq( int num, int scanline, int vblank, int blanked ) |
| 4814 | static void mapper248_irq( running_machine *machine, int num, int scanline, int vblank, int blanked ) |
| 4819 | 4815 | { |
| 4820 | 4816 | if ((scanline < PPU_BOTTOM_VISIBLE_SCANLINE) /*|| (scanline == ppu_scanlines_per_frame-1)*/) |
| 4821 | 4817 | { |
| r3941 | r3942 | |
| 4830 | 4826 | |
| 4831 | 4827 | if (IRQ_enable && !blanked && (IRQ_count == 0) && priorCount) |
| 4832 | 4828 | { |
| 4833 | | logerror("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline, video_screen_get_vpos(Machine->primary_screen), video_screen_get_hpos(Machine->primary_screen)); |
| 4834 | | cpu_set_input_line(Machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 4829 | logerror("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline, video_screen_get_vpos(machine->primary_screen), video_screen_get_hpos(machine->primary_screen)); |
| 4830 | cpu_set_input_line(machine->cpu[0], M6502_IRQ_LINE, HOLD_LINE); |
| 4835 | 4831 | } |
| 4836 | 4832 | } |
| 4837 | 4833 | } |
| r3941 | r3942 | |
| 4846 | 4842 | // 1 = no mapper found |
| 4847 | 4843 | // 2 = mapper not supported |
| 4848 | 4844 | */ |
| 4849 | | int mapper_reset (int mapperNum) |
| 4845 | int mapper_reset (running_machine *machine, int mapperNum) |
| 4850 | 4846 | { |
| 4851 | | const address_space *space = cpu_get_address_space( Machine->cpu[0], ADDRESS_SPACE_PROGRAM ); |
| 4847 | const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM ); |
| 4852 | 4848 | int err = 0; |
| 4853 | 4849 | const mmc *mapper; |
| 4854 | 4850 | |
| r3941 | r3942 | |
| 4861 | 4857 | ppu2c0x_set_hblank_callback (0, mapper ? mapper->mmc_hblank : NULL); |
| 4862 | 4858 | |
| 4863 | 4859 | if (!nes_irq_timer) |
| 4864 | | nes_irq_timer = timer_alloc(Machine, nes_irq_callback, NULL); |
| 4860 | nes_irq_timer = timer_alloc(machine, nes_irq_callback, NULL); |
| 4865 | 4861 | |
| 4866 | 4862 | mapper_warning = 0; |
| 4867 | 4863 | /* 8k mask */ |