src/mame/drivers/megadriv.c
| r3765 | r3766 | |
| 1503 | 1503 | } |
| 1504 | 1504 | |
| 1505 | 1505 | /* pointers to our io data read/write functions */ |
| 1506 | | UINT8 (*megadrive_io_read_data_port_ptr)(int offset); |
| 1507 | | void (*megadrive_io_write_data_port_ptr)(int offset, UINT16 data); |
| 1506 | UINT8 (*megadrive_io_read_data_port_ptr)(running_machine *machine, int offset); |
| 1507 | void (*megadrive_io_write_data_port_ptr)(running_machine *machine, int offset, UINT16 data); |
| 1508 | 1508 | |
| 1509 | 1509 | INPUT_PORTS_START( megadri6 ) |
| 1510 | 1510 | PORT_START("PAD1") /* Joypad 1 (6 button + start + mode) NOT READ DIRECTLY */ |
| r3765 | r3766 | |
| 1817 | 1817 | } |
| 1818 | 1818 | |
| 1819 | 1819 | /************* 6 button version **************************/ |
| 1820 | | static UINT8 megadrive_io_read_data_port_6button(int portnum) |
| 1820 | static UINT8 megadrive_io_read_data_port_6button(running_machine *machine, int portnum) |
| 1821 | 1821 | { |
| 1822 | 1822 | UINT8 retdata; |
| 1823 | 1823 | |
| r3765 | r3766 | |
| 1890 | 1890 | } |
| 1891 | 1891 | /************* end 6 button version ********************************************/ |
| 1892 | 1892 | |
| 1893 | | static UINT8 megadrive_io_read_data_port_3button(int portnum) |
| 1893 | static UINT8 megadrive_io_read_data_port_3button(running_machine *machine, int portnum) |
| 1894 | 1894 | { |
| 1895 | 1895 | UINT8 retdata; |
| 1896 | 1896 | |
| r3765 | r3766 | |
| 2056 | 2056 | case 0x2: |
| 2057 | 2057 | case 0x3: |
| 2058 | 2058 | // retdata = megadrive_io_read_data_port(offset-1); |
| 2059 | | retdata = megadrive_io_read_data_port_ptr(offset-1); |
| 2059 | retdata = megadrive_io_read_data_port_ptr(space->machine, offset-1); |
| 2060 | 2060 | break; |
| 2061 | 2061 | |
| 2062 | 2062 | case 0x4: |
| r3765 | r3766 | |
| 2085 | 2085 | } |
| 2086 | 2086 | |
| 2087 | 2087 | |
| 2088 | | static void megadrive_io_write_data_port_3button(int portnum, UINT16 data) |
| 2088 | static void megadrive_io_write_data_port_3button(running_machine *machine, int portnum, UINT16 data) |
| 2089 | 2089 | { |
| 2090 | 2090 | megadrive_io_data_regs[portnum] = data; |
| 2091 | 2091 | //mame_printf_debug("Writing IO Data Register #%d data %04x\n",portnum,data); |
| r3765 | r3766 | |
| 2095 | 2095 | |
| 2096 | 2096 | /******************************6 button version*****************************/ |
| 2097 | 2097 | |
| 2098 | | static void megadrive_io_write_data_port_6button(int portnum, UINT16 data) |
| 2098 | static void megadrive_io_write_data_port_6button(running_machine *machine, int portnum, UINT16 data) |
| 2099 | 2099 | { |
| 2100 | 2100 | if (megadrive_io_ctrl_regs[portnum]&0x40) |
| 2101 | 2101 | { |
| r3765 | r3766 | |
| 2114 | 2114 | |
| 2115 | 2115 | /***************************end 6 button version ****************************/ |
| 2116 | 2116 | |
| 2117 | | static void megadrive_io_write_ctrl_port(int portnum, UINT16 data) |
| 2117 | static void megadrive_io_write_ctrl_port(running_machine *machine, int portnum, UINT16 data) |
| 2118 | 2118 | { |
| 2119 | 2119 | megadrive_io_ctrl_regs[portnum] = data; |
| 2120 | 2120 | // mame_printf_debug("Setting IO Control Register #%d data %04x\n",portnum,data); |
| 2121 | 2121 | } |
| 2122 | 2122 | |
| 2123 | | static void megadrive_io_write_tx_port(int portnum, UINT16 data) |
| 2123 | static void megadrive_io_write_tx_port(running_machine *machine, int portnum, UINT16 data) |
| 2124 | 2124 | { |
| 2125 | 2125 | megadrive_io_tx_regs[portnum] = data; |
| 2126 | 2126 | } |
| 2127 | 2127 | |
| 2128 | | static void megadrive_io_write_rx_port(int portnum, UINT16 data) |
| 2128 | static void megadrive_io_write_rx_port(running_machine *machine, int portnum, UINT16 data) |
| 2129 | 2129 | { |
| 2130 | 2130 | |
| 2131 | 2131 | } |
| 2132 | 2132 | |
| 2133 | | static void megadrive_io_write_sctrl_port(int portnum, UINT16 data) |
| 2133 | static void megadrive_io_write_sctrl_port(running_machine *machine, int portnum, UINT16 data) |
| 2134 | 2134 | { |
| 2135 | 2135 | |
| 2136 | 2136 | } |
| r3765 | r3766 | |
| 2154 | 2154 | case 0x2: |
| 2155 | 2155 | case 0x3: |
| 2156 | 2156 | // megadrive_io_write_data_port(offset-1,data); |
| 2157 | | megadrive_io_write_data_port_ptr(offset-1,data); |
| 2157 | megadrive_io_write_data_port_ptr(space->machine, offset-1,data); |
| 2158 | 2158 | break; |
| 2159 | 2159 | |
| 2160 | 2160 | case 0x4: |
| 2161 | 2161 | case 0x5: |
| 2162 | 2162 | case 0x6: |
| 2163 | | megadrive_io_write_ctrl_port(offset-4,data); |
| 2163 | megadrive_io_write_ctrl_port(space->machine,offset-4,data); |
| 2164 | 2164 | break; |
| 2165 | 2165 | |
| 2166 | 2166 | /* Serial I/O Registers */ |
| 2167 | 2167 | |
| 2168 | | case 0x7: megadrive_io_write_tx_port(0,data); break; |
| 2169 | | case 0x8: megadrive_io_write_rx_port(0,data); break; |
| 2170 | | case 0x9: megadrive_io_write_sctrl_port(0,data); break; |
| 2168 | case 0x7: megadrive_io_write_tx_port(space->machine,0,data); break; |
| 2169 | case 0x8: megadrive_io_write_rx_port(space->machine,0,data); break; |
| 2170 | case 0x9: megadrive_io_write_sctrl_port(space->machine,0,data); break; |
| 2171 | 2171 | |
| 2172 | 2172 | |
| 2173 | | case 0xa: megadrive_io_write_tx_port(1,data); break; |
| 2174 | | case 0xb: megadrive_io_write_rx_port(1,data); break; |
| 2175 | | case 0xc: megadrive_io_write_sctrl_port(1,data); break; |
| 2173 | case 0xa: megadrive_io_write_tx_port(space->machine,1,data); break; |
| 2174 | case 0xb: megadrive_io_write_rx_port(space->machine,1,data); break; |
| 2175 | case 0xc: megadrive_io_write_sctrl_port(space->machine,1,data); break; |
| 2176 | 2176 | break; |
| 2177 | 2177 | |
| 2178 | | case 0xd: megadrive_io_write_tx_port(2,data); break; |
| 2179 | | case 0xe: megadrive_io_write_rx_port(2,data); break; |
| 2180 | | case 0xf: megadrive_io_write_sctrl_port(2,data); break; |
| 2178 | case 0xd: megadrive_io_write_tx_port(space->machine,2,data); break; |
| 2179 | case 0xe: megadrive_io_write_rx_port(space->machine,2,data); break; |
| 2180 | case 0xf: megadrive_io_write_sctrl_port(space->machine,2,data); break; |
| 2181 | 2181 | break; |
| 2182 | 2182 | } |
| 2183 | 2183 | |
| r3765 | r3766 | |
| 3911 | 3911 | } |
| 3912 | 3912 | |
| 3913 | 3913 | /* emulate testmode plug */ |
| 3914 | | static UINT8 megadrive_io_read_data_port_svp(int portnum) |
| 3914 | static UINT8 megadrive_io_read_data_port_svp(running_machine *machine, int portnum) |
| 3915 | 3915 | { |
| 3916 | 3916 | if (portnum == 0 && input_port_read_safe(Machine, "MEMORY_TEST", 0x00)) |
| 3917 | 3917 | { |
| 3918 | 3918 | return (megadrive_io_data_regs[0] & 0xc0); |
| 3919 | 3919 | } |
| 3920 | | return megadrive_io_read_data_port_3button(portnum); |
| 3920 | return megadrive_io_read_data_port_3button(machine, portnum); |
| 3921 | 3921 | } |
| 3922 | 3922 | |
| 3923 | 3923 | |
| r3765 | r3766 | |
| 6821 | 6821 | ROM_LOAD( "g_virrea.bin", 0x000000, 0x200000, CRC(5a943df9) SHA1(2c08ea556c79d48e88ff5202944c161ae1b41c63) ) |
| 6822 | 6822 | ROM_END |
| 6823 | 6823 | |
| 6824 | #ifndef MESS |
| 6824 | 6825 | GAME( 1994, 32x_bios, 0, genesis_32x, megadriv, _32x, ROT0, "Sega", "32X Bios", GAME_NOT_WORKING ) |
| 6825 | 6826 | GAME( 1994, segacd, 0, genesis_scd, megadriv, megadriv,ROT0, "Sega", "Sega-CD Model 2 BIOS V2.11 (U)", GAME_NOT_WORKING ) |
| 6826 | 6827 | GAME( 1994, 32x_scd, 0, genesis_32x_scd, megadriv, _32x, ROT0, "Sega", "Sega-CD Model 2 BIOS V2.11 (U) (with 32X)", GAME_NOT_WORKING ) |
| r3765 | r3766 | |
| 6828 | 6829 | GAME( 1994, g_virrj , g_virr, megdsvp, megadriv, megadrij, ROT0, "Sega", "Virtua Racing (J) [!]", 0 ) |
| 6829 | 6830 | GAME( 1994, g_virre , g_virr, megdsvppal, megadriv, megadrie, ROT0, "Sega", "Virtua Racing (E) [!]", 0 ) |
| 6830 | 6831 | GAME( 1994, g_virrea, g_virr, megdsvppal, megadriv, megadrie, ROT0, "Sega", "Virtua Racing (E) [a1]", 0 ) |
| 6832 | #endif |
| 6831 | 6833 | |
| 6832 | 6834 | #endif |
src/mess/messdriv.c
| r3765 | r3766 | |
| 79 | 79 | //0128u5 DRIVER( megaduck ) /* Megaduck */ |
| 80 | 80 | |
| 81 | 81 | /* SEGA */ |
| 82 | | //0128u5 DRIVER( sg1000 ) /* Sega SG-1000 (Japan) */ |
| 83 | | //0128u5 DRIVER( sg1000m2 ) /* Sega SG-1000 Mark II (Japan) */ |
| 84 | | //0128u5 DRIVER( sc3000 ) /* Sega SC-3000 (Japan) */ |
| 85 | | //0128u5 DRIVER( sc3000h ) /* Sega SC-3000H (Japan) */ |
| 86 | | //0128u5 DRIVER( sf7000 ) /* Sega SC-3000 w/ SF-7000 (Japan) */ |
| 82 | DRIVER( sg1000 ) /* Sega SG-1000 (Japan) */ |
| 83 | DRIVER( sg1000m2 ) /* Sega SG-1000 Mark II (Japan) */ |
| 84 | DRIVER( sc3000 ) /* Sega SC-3000 (Japan) */ |
| 85 | DRIVER( sc3000h ) /* Sega SC-3000H (Japan) */ |
| 86 | DRIVER( sf7000 ) /* Sega SC-3000 w/ SF-7000 (Japan) */ |
| 87 | 87 | // DRIVER( omv1000 ) /* Tsukuda Original Othello Multivision FG-1000 */ |
| 88 | 88 | // DRIVER( omv2000 ) /* Tsukuda Original Othello Multivision FG-2000 */ |
| 89 | 89 | |
| 90 | | //0128u5 DRIVER( gamegear ) /* Sega GameGear */ |
| 91 | | //0128u5 DRIVER( gamegeaj ) /* Sega GameGear (Japan) */ |
| 92 | | //0128u5 DRIVER( sms ) /* Sega Master System II (NTSC) */ |
| 93 | | //0128u5 DRIVER( sms1 ) /* Sega Master System I (NTSC) */ |
| 94 | | //0128u5 DRIVER( sms1pal ) /* Sega Master System I (PAL) */ |
| 95 | | //0128u5 DRIVER( smspal ) /* Sega Master System II (PAL) */ |
| 96 | | //0128u5 DRIVER( smsj ) /* Sega Master System (Japan) with FM Chip */ |
| 97 | | //0128u5 DRIVER( sg1000m3 ) /* Sega SG-1000 Mark III (Japan) */ |
| 98 | | //0128u5 DRIVER( sms2kr ) /* Samsung Gam*Boy II (Korea) */ |
| 99 | | //0128u5 DRIVER( smssdisp ) /* Sega Master System Store Display Unit */ |
| 90 | DRIVER( gamegear ) /* Sega GameGear */ |
| 91 | DRIVER( gamegeaj ) /* Sega GameGear (Japan) */ |
| 92 | DRIVER( sms ) /* Sega Master System II (NTSC) */ |
| 93 | DRIVER( sms1 ) /* Sega Master System I (NTSC) */ |
| 94 | DRIVER( sms1pal ) /* Sega Master System I (PAL) */ |
| 95 | DRIVER( smspal ) /* Sega Master System II (PAL) */ |
| 96 | DRIVER( smsj ) /* Sega Master System (Japan) with FM Chip */ |
| 97 | DRIVER( sg1000m3 ) /* Sega SG-1000 Mark III (Japan) */ |
| 98 | DRIVER( sms2kr ) /* Samsung Gam*Boy II (Korea) */ |
| 99 | DRIVER( smssdisp ) /* Sega Master System Store Display Unit */ |
| 100 | 100 | |
| 101 | | //0128u5 DRIVER( megadrij ) /* 1988 Sega Mega Drive (Japan) */ |
| 102 | | //0128u5 DRIVER( genesis ) /* 1989 Sega Genesis (USA) */ |
| 103 | | //0128u5 DRIVER( gensvp ) /* 1993 Sega Genesis (USA w/SVP chip) */ |
| 104 | | //0128u5 DRIVER( megadriv ) /* 1990 Sega Mega Drive (Europe) */ |
| 105 | | //0128u5 DRIVER( pico ) /* 1994 Sega Pico (Europe) */ |
| 106 | | //0128u5 DRIVER( picou ) /* 1994 Sega Pico (USA) */ |
| 107 | | //0128u5 DRIVER( picoj ) /* 1993 Sega Pico (Japan) */ |
| 101 | DRIVER( megadrij ) /* 1988 Sega Mega Drive (Japan) */ |
| 102 | DRIVER( genesis ) /* 1989 Sega Genesis (USA) */ |
| 103 | DRIVER( gensvp ) /* 1993 Sega Genesis (USA w/SVP chip) */ |
| 104 | DRIVER( megadriv ) /* 1990 Sega Mega Drive (Europe) */ |
| 105 | DRIVER( pico ) /* 1994 Sega Pico (Europe) */ |
| 106 | DRIVER( picou ) /* 1994 Sega Pico (USA) */ |
| 107 | DRIVER( picoj ) /* 1993 Sega Pico (Japan) */ |
| 108 | 108 | |
| 109 | | //0128u5 DRIVER( saturnjp ) /* 1994 Sega Saturn (Japan) */ |
| 110 | | //0128u5 DRIVER( saturn ) /* 1995 Sega Saturn (USA) */ |
| 111 | | //0128u5 DRIVER( saturneu ) /* 1995 Sega Saturn (Europe) */ |
| 112 | | //0128u5 DRIVER( vsaturn ) /* JVC V-Saturn */ |
| 113 | | //0128u5 DRIVER( hisaturn ) /* Hitachi HiSaturn */ |
| 109 | DRIVER( saturnjp ) /* 1994 Sega Saturn (Japan) */ |
| 110 | DRIVER( saturn ) /* 1995 Sega Saturn (USA) */ |
| 111 | DRIVER( saturneu ) /* 1995 Sega Saturn (Europe) */ |
| 112 | DRIVER( vsaturn ) /* JVC V-Saturn */ |
| 113 | DRIVER( hisaturn ) /* Hitachi HiSaturn */ |
| 114 | 114 | |
| 115 | | //0128u5 DRIVER( dcjp ) /* 1998 Sega Dreamcast (Japan) */ |
| 116 | | //0128u5 DRIVER( dc ) /* 1999 Sega Dreamcast (USA) */ |
| 117 | | //0128u5 DRIVER( dceu ) /* 1999 Sega Dreamcast (Europe) */ |
| 118 | | //0128u5 DRIVER( dcdev ) /* 1998 Sega HKT-0120 Sega Dreamcast Development Box */ |
| 115 | DRIVER( dcjp ) /* 1998 Sega Dreamcast (Japan) */ |
| 116 | DRIVER( dc ) /* 1999 Sega Dreamcast (USA) */ |
| 117 | DRIVER( dceu ) /* 1999 Sega Dreamcast (Europe) */ |
| 118 | DRIVER( dcdev ) /* 1998 Sega HKT-0120 Sega Dreamcast Development Box */ |
| 119 | 119 | |
| 120 | 120 | /* BALLY */ |
| 121 | 121 | DRIVER( astrocde ) /* Bally Astrocade */ |
src/mess/drivers/saturn.c
| r3765 | r3766 | |
| 1550 | 1550 | if(LOG_SCU) logerror("DMA transfer END\n"); |
| 1551 | 1551 | |
| 1552 | 1552 | /*TODO: timing of this*/ |
| 1553 | | timer_set(machine, ATTOTIME_IN_USEC(300), NULL, 0, dma_lv0_ended); |
| 1553 | timer_set(space->machine, ATTOTIME_IN_USEC(300), NULL, 0, dma_lv0_ended); |
| 1554 | 1554 | |
| 1555 | 1555 | if(scu_add_tmp & 0x80000000) |
| 1556 | 1556 | { |
| r3765 | r3766 | |
| 1651 | 1651 | |
| 1652 | 1652 | if(LOG_SCU) logerror("DMA transfer END\n"); |
| 1653 | 1653 | |
| 1654 | | timer_set(machine, ATTOTIME_IN_USEC(300), NULL, 0, dma_lv1_ended); |
| 1654 | timer_set(space->machine, ATTOTIME_IN_USEC(300), NULL, 0, dma_lv1_ended); |
| 1655 | 1655 | |
| 1656 | 1656 | if(scu_add_tmp & 0x80000000) |
| 1657 | 1657 | { |
| r3765 | r3766 | |
| 1752 | 1752 | |
| 1753 | 1753 | if(LOG_SCU) logerror("DMA transfer END\n"); |
| 1754 | 1754 | |
| 1755 | | timer_set(machine, ATTOTIME_IN_USEC(300), NULL, 0, dma_lv2_ended); |
| 1755 | timer_set(space->machine, ATTOTIME_IN_USEC(300), NULL, 0, dma_lv2_ended); |
| 1756 | 1756 | |
| 1757 | 1757 | if(scu_add_tmp & 0x80000000) |
| 1758 | 1758 | { |
| r3765 | r3766 | |
| 1827 | 1827 | |
| 1828 | 1828 | }while(job_done == 0); |
| 1829 | 1829 | |
| 1830 | | timer_set(machine, ATTOTIME_IN_USEC(300), NULL, 0, dma_lv0_ended); |
| 1830 | timer_set(space->machine, ATTOTIME_IN_USEC(300), NULL, 0, dma_lv0_ended); |
| 1831 | 1831 | } |
| 1832 | 1832 | |
| 1833 | 1833 | static void dma_indirect_lv1(const address_space *space) |
| r3765 | r3766 | |
| 1896 | 1896 | |
| 1897 | 1897 | }while(job_done == 0); |
| 1898 | 1898 | |
| 1899 | | timer_set(machine, ATTOTIME_IN_USEC(300), NULL, 0, dma_lv1_ended); |
| 1899 | timer_set(space->machine, ATTOTIME_IN_USEC(300), NULL, 0, dma_lv1_ended); |
| 1900 | 1900 | } |
| 1901 | 1901 | |
| 1902 | 1902 | static void dma_indirect_lv2(const address_space *space) |
| r3765 | r3766 | |
| 1964 | 1964 | |
| 1965 | 1965 | }while(job_done == 0); |
| 1966 | 1966 | |
| 1967 | | timer_set(machine, ATTOTIME_IN_USEC(300), NULL, 0, dma_lv2_ended); |
| 1967 | timer_set(space->machine, ATTOTIME_IN_USEC(300), NULL, 0, dma_lv2_ended); |
| 1968 | 1968 | } |
| 1969 | 1969 | |
| 1970 | 1970 | |
src/mess/drivers/genesis.c
| r3765 | r3766 | |
| 51 | 51 | #include "driver.h" |
| 52 | 52 | #include "sound/2612intf.h" |
| 53 | 53 | #include "../../mame/drivers/megadriv.h" |
| 54 | | #include "deprecat.h" |
| 55 | 54 | |
| 56 | 55 | /* cart device, custom mappers & sram init */ |
| 57 | 56 | #include "includes/genesis.h" |
| r3765 | r3766 | |
| 76 | 75 | mess_io_stage[(int)(FPTR)ptr] = -1; |
| 77 | 76 | } |
| 78 | 77 | |
| 79 | | static void mess_init_6buttons_pad(void) |
| 78 | static void mess_init_6buttons_pad(running_machine *machine) |
| 80 | 79 | { |
| 81 | 80 | int i; |
| 82 | 81 | |
| r3765 | r3766 | |
| 89 | 88 | |
| 90 | 89 | /* These overwrite the MAME ones in DRIVER_INIT */ |
| 91 | 90 | /* They're needed to give the users the choice between different controllers */ |
| 92 | | static UINT8 mess_md_io_read_data_port(int portnum) |
| 91 | static UINT8 mess_md_io_read_data_port(running_machine *machine, int portnum) |
| 93 | 92 | { |
| 94 | 93 | static const char *const pad6names[2][4] = {{ "PAD1_6B", "PAD2_6B", "UNUSED", "UNUSED" }, |
| 95 | 94 | { "EXTRA1", "EXTRA2", "UNUSED", "UNUSED" }}; |
| r3765 | r3766 | |
| 103 | 102 | switch (portnum) |
| 104 | 103 | { |
| 105 | 104 | case 0: |
| 106 | | controller = (input_port_read(Machine, "CTRLSEL") & 0x0f); |
| 105 | controller = (input_port_read(machine, "CTRLSEL") & 0x0f); |
| 107 | 106 | break; |
| 108 | 107 | |
| 109 | 108 | case 1: |
| 110 | | controller = (input_port_read(Machine, "CTRLSEL") & 0xf0); |
| 109 | controller = (input_port_read(machine, "CTRLSEL") & 0xf0); |
| 111 | 110 | break; |
| 112 | 111 | |
| 113 | 112 | default: |
| r3765 | r3766 | |
| 124 | 123 | { |
| 125 | 124 | /* here we read B, C & the additional buttons */ |
| 126 | 125 | retdata = (megadrive_io_data_regs[portnum] & helper_6b) | |
| 127 | | (((input_port_read_safe(Machine, pad6names[0][portnum], 0) & 0x30) | |
| 128 | | (input_port_read_safe(Machine, pad6names[1][portnum], 0) & 0x0f)) & ~helper_6b); |
| 126 | (((input_port_read_safe(machine, pad6names[0][portnum], 0) & 0x30) | |
| 127 | (input_port_read_safe(machine, pad6names[1][portnum], 0) & 0x0f)) & ~helper_6b); |
| 129 | 128 | } |
| 130 | 129 | else |
| 131 | 130 | { |
| 132 | 131 | /* here we read B, C & the directional buttons */ |
| 133 | 132 | retdata = (megadrive_io_data_regs[portnum] & helper_6b) | |
| 134 | | ((input_port_read_safe(Machine, pad6names[0][portnum], 0) & 0x3f) & ~helper_6b); |
| 133 | ((input_port_read_safe(machine, pad6names[0][portnum], 0) & 0x3f) & ~helper_6b); |
| 135 | 134 | } |
| 136 | 135 | } |
| 137 | 136 | else |
| r3765 | r3766 | |
| 140 | 139 | { |
| 141 | 140 | /* here we read ((Start & A) >> 2) | 0x00 */ |
| 142 | 141 | retdata = (megadrive_io_data_regs[portnum] & helper_6b) | |
| 143 | | (((input_port_read_safe(Machine, pad6names[0][portnum], 0) & 0xc0) >> 2) & ~helper_6b); |
| 142 | (((input_port_read_safe(machine, pad6names[0][portnum], 0) & 0xc0) >> 2) & ~helper_6b); |
| 144 | 143 | } |
| 145 | 144 | else if (mess_io_stage[portnum]==2) |
| 146 | 145 | { |
| 147 | 146 | /* here we read ((Start & A) >> 2) | 0x0f */ |
| 148 | 147 | retdata = (megadrive_io_data_regs[portnum] & helper_6b) | |
| 149 | | ((((input_port_read_safe(Machine, pad6names[0][portnum], 0) & 0xc0) >> 2) | 0x0f) & ~helper_6b); |
| 148 | ((((input_port_read_safe(machine, pad6names[0][portnum], 0) & 0xc0) >> 2) | 0x0f) & ~helper_6b); |
| 150 | 149 | } |
| 151 | 150 | else |
| 152 | 151 | { |
| 153 | 152 | /* here we read ((Start & A) >> 2) | Up and Down */ |
| 154 | 153 | retdata = (megadrive_io_data_regs[portnum] & helper_6b) | |
| 155 | | ((((input_port_read_safe(Machine, pad6names[0][portnum], 0) & 0xc0) >> 2) | |
| 156 | | (input_port_read_safe(Machine, pad6names[0][portnum], 0) & 0x03)) & ~helper_6b); |
| 154 | ((((input_port_read_safe(machine, pad6names[0][portnum], 0) & 0xc0) >> 2) | |
| 155 | (input_port_read_safe(machine, pad6names[0][portnum], 0) & 0x03)) & ~helper_6b); |
| 157 | 156 | } |
| 158 | 157 | } |
| 159 | 158 | |
| r3765 | r3766 | |
| 168 | 167 | { |
| 169 | 168 | /* here we read B, C & the directional buttons */ |
| 170 | 169 | retdata = (megadrive_io_data_regs[portnum] & helper_3b) | |
| 171 | | (((input_port_read_safe(Machine, pad3names[portnum], 0) & 0x3f) | 0x40) & ~helper_3b); |
| 170 | (((input_port_read_safe(machine, pad3names[portnum], 0) & 0x3f) | 0x40) & ~helper_3b); |
| 172 | 171 | } |
| 173 | 172 | else |
| 174 | 173 | { |
| 175 | 174 | /* here we read ((Start & A) >> 2) | Up and Down */ |
| 176 | 175 | retdata = (megadrive_io_data_regs[portnum] & helper_3b) | |
| 177 | | ((((input_port_read_safe(Machine, pad3names[portnum], 0) & 0xc0) >> 2) | |
| 178 | | (input_port_read_safe(Machine, pad3names[portnum], 0) & 0x03) | 0x40) & ~helper_3b); |
| 176 | ((((input_port_read_safe(machine, pad3names[portnum], 0) & 0xc0) >> 2) | |
| 177 | (input_port_read_safe(machine, pad3names[portnum], 0) & 0x03) | 0x40) & ~helper_3b); |
| 179 | 178 | } |
| 180 | 179 | } |
| 181 | 180 | |
| r3765 | r3766 | |
| 183 | 182 | } |
| 184 | 183 | |
| 185 | 184 | |
| 186 | | static void mess_md_io_write_data_port(int portnum, UINT16 data) |
| 185 | static void mess_md_io_write_data_port(running_machine *machine, int portnum, UINT16 data) |
| 187 | 186 | { |
| 188 | 187 | int controller; |
| 189 | 188 | |
| 190 | 189 | switch (portnum) |
| 191 | 190 | { |
| 192 | 191 | case 0: |
| 193 | | controller = (input_port_read(Machine, "CTRLSEL") & 0x0f); |
| 192 | controller = (input_port_read(machine, "CTRLSEL") & 0x0f); |
| 194 | 193 | break; |
| 195 | 194 | |
| 196 | 195 | case 1: |
| 197 | | controller = (input_port_read(Machine, "CTRLSEL") & 0xf0); |
| 196 | controller = (input_port_read(machine, "CTRLSEL") & 0xf0); |
| 198 | 197 | break; |
| 199 | 198 | |
| 200 | 199 | default: |
| r3765 | r3766 | |
| 317 | 316 | |
| 318 | 317 | /************************************* |
| 319 | 318 | * |
| 320 | | * Machine driver |
| 319 | * machine driver |
| 321 | 320 | * |
| 322 | 321 | *************************************/ |
| 323 | 322 | |
| r3765 | r3766 | |
| 326 | 325 | MACHINE_RESET_CALL( megadriv ); |
| 327 | 326 | MACHINE_RESET_CALL( md_mappers ); |
| 328 | 327 | |
| 329 | | mess_init_6buttons_pad(); |
| 328 | mess_init_6buttons_pad(machine); |
| 330 | 329 | } |
| 331 | 330 | |
| 332 | 331 | static MACHINE_DRIVER_START( ms_megadriv ) |
| r3765 | r3766 | |
| 482 | 481 | #define PICO_PENX 1 |
| 483 | 482 | #define PICO_PENY 2 |
| 484 | 483 | |
| 485 | | static UINT16 pico_read_penpos(int pen) |
| 484 | static UINT16 pico_read_penpos(running_machine *machine, int pen) |
| 486 | 485 | { |
| 487 | 486 | UINT16 penpos = 0; |
| 488 | 487 | |
| 489 | 488 | switch (pen) |
| 490 | 489 | { |
| 491 | 490 | case PICO_PENX: |
| 492 | | penpos = input_port_read_safe(Machine, "PENX", 0); |
| 491 | penpos = input_port_read_safe(machine, "PENX", 0); |
| 493 | 492 | penpos |= 0x6; |
| 494 | 493 | penpos = penpos * 320 / 255; |
| 495 | 494 | penpos += 0x3d; |
| 496 | 495 | break; |
| 497 | 496 | case PICO_PENY: |
| 498 | | penpos = input_port_read_safe(Machine, "PENY", 0); |
| 497 | penpos = input_port_read_safe(machine, "PENY", 0); |
| 499 | 498 | penpos |= 0x6; |
| 500 | 499 | penpos = penpos * 251 / 255; |
| 501 | 500 | penpos += 0x1fc; |
| r3765 | r3766 | |
| 518 | 517 | retdata = (megadrive_region_export << 6) | (megadrive_region_pal << 5); |
| 519 | 518 | break; |
| 520 | 519 | case 1: |
| 521 | | retdata = input_port_read_safe(Machine, "PAD", 0); |
| 520 | retdata = input_port_read_safe(space->machine, "PAD", 0); |
| 522 | 521 | break; |
| 523 | 522 | |
| 524 | 523 | /* |
| r3765 | r3766 | |
| 533 | 532 | 0x2f8 - 0x3f3 (storyware) |
| 534 | 533 | */ |
| 535 | 534 | case 2: |
| 536 | | retdata = pico_read_penpos(PICO_PENX) >> 8; |
| 535 | retdata = pico_read_penpos(space->machine, PICO_PENX) >> 8; |
| 537 | 536 | break; |
| 538 | 537 | case 3: |
| 539 | | retdata = pico_read_penpos(PICO_PENX) & 0x00ff; |
| 538 | retdata = pico_read_penpos(space->machine, PICO_PENX) & 0x00ff; |
| 540 | 539 | break; |
| 541 | 540 | case 4: |
| 542 | | retdata = pico_read_penpos(PICO_PENY) >> 8; |
| 541 | retdata = pico_read_penpos(space->machine, PICO_PENY) >> 8; |
| 543 | 542 | break; |
| 544 | 543 | case 5: |
| 545 | | retdata = pico_read_penpos(PICO_PENY) & 0x00ff; |
| 544 | retdata = pico_read_penpos(space->machine, PICO_PENY) & 0x00ff; |
| 546 | 545 | break; |
| 547 | 546 | case 6: |
| 548 | 547 | /* Page register : |
| r3765 | r3766 | |
| 553 | 552 | { |
| 554 | 553 | UINT8 tmp; |
| 555 | 554 | |
| 556 | | tmp = input_port_read_safe(Machine, "PAGE", 0); |
| 555 | tmp = input_port_read_safe(space->machine, "PAGE", 0); |
| 557 | 556 | if (tmp == 2 && page_register != 0x3f) |
| 558 | 557 | { |
| 559 | 558 | page_register <<= 1; |