static READ8_HANDLER(read_a00x) { switch(offset) { case 0x02: return reg_a002; case 0x04: return readinputportbytag("A004"); case 0x05: return readinputportbytag("A005"); case 0x0c: return input_port_0_r(0); // stats / reset case 0x0e: return readinputportbytag("A00E");// coin/reset } if(offset==0x00) //muxed with A002? { switch(reg_a002&0x3f) { case 0x3b: return input_port_2_r(0);//bet10 / pay out case 0x3e: return input_port_3_r(0);//TODO : trace f564 case 0x3d: return input_port_4_r(0); default: logerror("A000 read with mux=0x%02x\n",reg_a002&0x3f); } } return 0xff; }
static READ32_HANDLER( analog_port1_r ) { #if (HACK_TMEK_CONTROLS) int pots[4]; compute_fake_pots(pots); return (pots[2] << 24) | (pots[1] << 8); #else return (readinputportbytag("IN6") << 24) | (readinputportbytag("IN7") << 8); #endif }
static READ8_HANDLER( triothep_control_r ) { switch (trio_control_select) { case 0: return readinputportbytag("IN0"); /* Player 1 */ case 1: return readinputportbytag("IN1"); /* Player 2 */ case 2: return readinputportbytag("DSW1"); /* Dip 1 */ case 3: return readinputportbytag("DSW2"); /* Dip 2 */ case 4: return readinputportbytag("IN2"); /* VBL */ } return 0xff; }
static READ8_HANDLER( control_data_r ) { switch (control_port_select) { case 0xfe: return readinputportbytag("IN0"); /* Player 1 */ case 0xfd: return readinputportbytag("IN1"); /* Player 2 */ case 0xfb: return readinputportbytag("IN2"); /* Coins */ case 0xf7: return readinputportbytag("DSW2"); /* Dip 2 */ case 0xef: return readinputportbytag("DSW1"); /* Dip 1 */ } return 0xff; }
static UINT16 amiga_read_joy1dat(void) { if ( readinputportbytag("config") & 0x10 ) { /* Joystick */ return readinputportbytag_safe("JOY1DAT", 0xffff); } else { /* Mouse */ int input; input = ( readinputportbytag("P1MOUSEX") & 0xff ); input |= ( readinputportbytag("P1MOUSEY") & 0xff ) << 8; return input; } }
INPUT_PORTS_END static READ8_HANDLER(adc_r) { switch(offset) { case 0: return readinputportbytag("analog_bank"); case 1: return readinputportbytag("analog_pitch"); case 2: return readinputportbytag("analog_missile"); case 3: return readinputportbytag("analog_hover"); default: return 0; } }
static UINT32 astrof_p2_controls_r(void *param) { UINT32 ret; /* on an upright cabinets, a single set of controls is connected to both sets of pins on the edge connector */ if (readinputportbytag("CAB")) ret = readinputportbytag("P2"); else ret = readinputportbytag("P1"); return ret; }
static UINT32 tempest_knob_r(void *param) { UINT32 ret; if (tempest_player_select) { ret = readinputportbytag(TEMPEST_KNOB_P2_TAG); } else { ret = readinputportbytag(TEMPEST_KNOB_P1_TAG); } return ret; }
static READ16_HANDLER( karnov_control_r ) { switch (offset<<1) { case 0: /* Player controls */ return ( readinputportbytag("IN0") + (readinputportbytag("IN1")<<8)); case 2: /* Start buttons & VBL */ return readinputportbytag("IN2"); case 4: /* Dipswitch A & B */ return ( readinputportbytag("DSW1") + (readinputportbytag("DSW2")<<8)); case 6: /* i8751 return values */ return i8751_return; } return ~0; }
static UINT32 tempest_buttons_r(void *param) { UINT32 ret; if (tempest_player_select) { ret = readinputportbytag(TEMPEST_BUTTONS_P2_TAG); } else { ret = readinputportbytag(TEMPEST_BUTTONS_P1_TAG); } return ret; }
static READ16_HANDLER( coin_chip_r ) { if (offset == 1) return readinputportbytag("COINCHIP"); logerror("%06x:coin_chip_r(%02x) & %04x\n", activecpu_get_pc(), offset, mem_mask ^ 0xffff); return 0xffff; }
static READ32_HANDLER( special_port2_r ) { int temp = readinputportbytag("IN2"); temp ^= 0x0001; /* /A2DRDY always high for now */ temp ^= 0x0008; /* A2D.EOC always high for now */ return (temp << 16) | temp; }
ROM_END READ16_HANDLER( ssf2ghw_dsw_r ) { static const char *dswname[3] = { "DSWA", "DSWB", "DSWC" }; return readinputportbytag(dswname[offset]); }
static READ32_HANDLER( special_port3_r ) { int temp = readinputportbytag("IN3"); if (atarigen_video_int_state) temp ^= 0x0001; if (atarigen_scanline_int_state) temp ^= 0x0002; return (temp << 16) | temp; }
static INTERRUPT_GEN( coin_nmi ) { UINT32 coin = readinputportbytag("COIN"); UINT32 service = readinputportbytag("SERVICE"); /* both the coin input and the serice credit generates an NMI */ if (coin || service) cpunum_set_input_line(0, INPUT_LINE_NMI, PULSE_LINE); /* the coin input is also connected to the coin counter */ if (coin) { coin_counter_w(0, 1); coin_counter_w(0, 0); } }
INLINE void compute_fake_pots(int *pots) { int fake = readinputportbytag("FAKE"); pots[0] = pots[1] = pots[2] = pots[3] = 0x80; if (fake & 0x01) /* up */ { if (fake & 0x04) /* up and left */ pots[3] = 0x00; else if (fake & 0x08) /* up and right */ pots[1] = 0x00; else /* up only */ pots[1] = pots[3] = 0x00; } else if (fake & 0x02) /* down */ { if (fake & 0x04) /* down and left */ pots[3] = 0xff; else if (fake & 0x08) /* down and right */ pots[1] = 0xff; else /* down only */ pots[1] = pots[3] = 0xff; } else if (fake & 0x04) /* left only */ pots[1] = 0xff, pots[3] = 0x00; else if (fake & 0x08) /* right only */ pots[3] = 0xff, pots[1] = 0x00; }
static READ8_HANDLER( spacduel_IN3_r ) { int res; int res1; int res2; res1 = readinputportbytag("IN3"); res2 = readinputportbytag("IN4"); res = 0x00; switch (offset & 0x07) { case 0: if (res1 & IN_SHIELD) res |= 0x80; if (res1 & IN_FIRE) res |= 0x40; break; case 1: /* Player 2 */ if (res2 & IN_SHIELD) res |= 0x80; if (res2 & IN_FIRE) res |= 0x40; break; case 2: if (res1 & IN_LEFT) res |= 0x80; if (res1 & IN_RIGHT) res |= 0x40; break; case 3: /* Player 2 */ if (res2 & IN_LEFT) res |= 0x80; if (res2 & IN_RIGHT) res |= 0x40; break; case 4: if (res1 & IN_THRUST) res |= 0x80; if (res1 & IN_P1) res |= 0x40; break; case 5: /* Player 2 */ if (res2 & IN_THRUST) res |= 0x80; break; case 6: if (res1 & IN_P2) res |= 0x80; break; case 7: res = (0x00 /* upright */ | (0 & 0x40)); break; } return res; }
static MACHINE_RESET( aquarium ) { UINT16 *RAM = (UINT16 *)memory_region(REGION_CPU1); int data = readinputportbytag("FAKE"); /* Language : 0x0000 = Japanese - Other value = English */ RAM[0x000a5c/2] = data; }
static int cidelsa_in_ef(void) { /* EF1 CDP1869 _PRD EF2 Test EF3 Coin 2 EF4 Coin 1 */ return (cdp1869_prd & 0x01) + (readinputportbytag("EF") & 0xfe); }
static READ16_HANDLER( horekid_IN2_r ) { int data = readinputportbytag("IN1"); if (!(data & 0x40)) // FAKE button 3 for "Debug Mode" { data &= 0x40; data |= ~0x30; } return data; }
void paddle_callback (int param) { int port7 = readinputportbytag("IN7"); int port8 = readinputportbytag("IN8"); if (port7 == 0) JoyStat[0] = 0; else if (port7 & 0x08) JoyStat[0] = -1; else JoyStat[0] = 1; if (port8 == 0) JoyStat[1] = 0; else if (port8 & 0x08) JoyStat[1] = -1; else JoyStat[1] = 1; if (JoyStat[0] || JoyStat[1]) cpunum_set_input_line(0, 0, HOLD_LINE); }
static READ16_HANDLER( syvalion_input_bypass_r ) { /* Bypass TC0220IOC controller for analog input */ UINT8 port = TC0220IOC_port_r(0); /* read port number */ switch( port ) { case 0x08: /* trackball y coords bottom 8 bits for 2nd player */ return readinputportbytag(P2TRACKY_PORT_TAG); case 0x09: /* trackball y coords top 8 bits for 2nd player */ if (readinputportbytag(P2TRACKY_PORT_TAG) & 0x80) /* y- direction (negative value) */ return 0xff; else /* y+ direction (positive value) */ return 0x00; case 0x0a: /* trackball x coords bottom 8 bits for 2nd player */ return readinputportbytag(P2TRACKX_PORT_TAG); case 0x0b: /* trackball x coords top 8 bits for 2nd player */ if (readinputportbytag(P2TRACKX_PORT_TAG) & 0x80) /* x- direction (negative value) */ return 0xff; else /* x+ direction (positive value) */ return 0x00; case 0x0c: /* trackball y coords bottom 8 bits for 1st player */ return readinputportbytag(P1TRACKY_PORT_TAG); case 0x0d: /* trackball y coords top 8 bits for 1st player */ if (readinputportbytag(P1TRACKY_PORT_TAG) & 0x80) /* y- direction (negative value) */ return 0xff; else /* y+ direction (positive value) */ return 0x00; case 0x0e: /* trackball x coords bottom 8 bits for 1st player */ return readinputportbytag(P1TRACKX_PORT_TAG); case 0x0f: /* trackball x coords top 8 bits for 1st player */ if (readinputportbytag(P1TRACKX_PORT_TAG) & 0x80) /* x- direction (negative value) */ return 0xff; else /* x+ direction (positive value) */ return 0x00; default: return TC0220IOC_portreg_r( offset ); } }
MACHINE_DRIVER_END /*************************************************************************** Amiga specific stuff ***************************************************************************/ static UINT8 amiga_cia_0_portA_r( void ) { UINT8 ret = readinputportbytag("CIA0PORTA") & 0xc0; /* Gameport 1 and 0 buttons */ ret |= amiga_fdc_status_r(); return ret; }
static UINT32 get_joystick(void* param) { UINT8 joy = readinputportbytag(param) & 3; if (joy == 1) { return (da_latch < 8) ? 1 : 0; } if (joy == 2) { return 0; } return 1; }
/* handle fake button for speed cheat */ static READ8_HANDLER( konami_IN1_r ) { int res; static int cheat = 0; static int bits[] = { 0xee, 0xff, 0xbb, 0xaa }; res = readinputportbytag("IN1"); if ((res & 0x80) == 0) { res |= 0x55; res &= bits[cheat]; cheat = (cheat+1)%4; } return res; }
AM_RANGE(0xd000, 0xffff) AM_ROM ADDRESS_MAP_END /*************************************************************************** These games don't have VBlank interrupts. Interrupts are still used by the game: but they are related to coin slots. ***************************************************************************/ static INTERRUPT_GEN( astrof_interrupt ) { if (readinputportbytag("FAKE") & 1) /* Coin */ cpunum_set_input_line(0, INPUT_LINE_NMI, PULSE_LINE); }
ADDRESS_MAP_END INTERRUPT_GEN( brkthru_interrupt ) { if (cpu_getiloops() == 0) { if (nmi_enable) cpunum_set_input_line(0, INPUT_LINE_NMI, PULSE_LINE); } else { /* generate IRQ on coin insertion */ if ((readinputportbytag("IN2") & 0xe0) != 0xe0) cpunum_set_input_line(0, 0, HOLD_LINE); } }
ADDRESS_MAP_END static INTERRUPT_GEN( tagteam_interrupt ) { static int coin; int port; port = readinputportbytag("IN0") & 0xc0; if (port != 0xc0) /* Coin */ { if (coin == 0) { coin = 1; cpunum_set_input_line(0, INPUT_LINE_NMI, PULSE_LINE); } } else coin = 0; }
static UINT8 arcadia_cia_0_portb_r(void) { return readinputportbytag("CIA0PORTB"); }
static READ8_HANDLER( tunhunt_button_r ) { int data = readinputportbytag("IN0"); return ((data>>offset)&1)?0x00:0x80; }