static READ16_HANDLER( wgp_adinput_r ) { int steer = 0x40; int fake = input_port_read_safe(machine, FAKE_PORT_TAG,0x00); if (!(fake & 0x10)) /* Analogue steer (the real control method) */ { /* Reduce span to 0x80 */ steer = (input_port_read_safe(machine, STEER_PORT_TAG,0x00) * 0x80) / 0x100; } else /* Digital steer */ { if (fake & 0x08) /* pressing down */ steer = 0x20; if (fake & 0x04) /* pressing up */ steer = 0x60; if (fake & 0x02) /* pressing right */ steer = 0x00; if (fake & 0x01) /* pressing left */ steer = 0x80; } switch (offset) { case 0x00: { if (fake & 0x40) /* pressing accel */ return 0xff; else return 0x00; } case 0x01: return steer; case 0x02: return 0xc0; /* steer offset, correct acc. to service mode */ case 0x03: return 0xbf; /* accel offset, correct acc. to service mode */ case 0x04: { if (fake & 0x80) /* pressing brake */ return 0xcf; else return 0xff; } case 0x05: return input_port_read_safe(machine, UNKNOWN_PORT_TAG,0x00); /* unknown */ } logerror("CPU #0 PC %06x: warning - read unmapped a/d input offset %06x\n",activecpu_get_pc(),offset); return 0xff; }
INLINE void get_crosshair_xy(running_machine *machine, int player, int *x, int *y) { static const char *const gunnames[] = { "LIGHT0_X", "LIGHT0_Y", "LIGHT1_X", "LIGHT1_Y" }; const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen); int width = visarea->max_x + 1 - visarea->min_x; int height = visarea->max_y + 1 - visarea->min_y; *x = ((input_port_read_safe(machine, gunnames[player * 2], 0x00) & 0xff) * width) / 255; *y = ((input_port_read_safe(machine, gunnames[1 + player * 2], 0x00) & 0xff) * height) / 255; }
INLINE void get_crosshair_xy(running_machine &machine, int player, int *x, int *y) { static const char *const gunnames[] = { "LIGHT0_X", "LIGHT0_Y", "LIGHT1_X", "LIGHT1_Y" }; const rectangle &visarea = machine.primary_screen->visible_area(); int width = visarea.width(); int height = visarea.height(); *x = ((input_port_read_safe(machine, gunnames[player * 2], 0x00) & 0xff) * width) / 255; *y = ((input_port_read_safe(machine, gunnames[1 + player * 2], 0x00) & 0xff) * height) / 255; }
bool sega_837_13551::switches(UINT8 *&buf, UINT8 count_players, UINT8 bytes_per_switch) { if(count_players > 2 || bytes_per_switch > 2) return false; *buf++ = input_port_read_safe(machine(), port_tag[0], 0); for(int i=0; i<count_players; i++) { UINT32 val = input_port_read_safe(machine(), port_tag[1+i], 0); for(int j=0; j<bytes_per_switch; j++) *buf++ = val >> ((1-j) << 3); } return true; }
static READ8_HANDLER( sound_io_r ) { switch (offset) { case 0x01: return (sound_port_latch[offset] & 0x7f) | input_port_read_safe(space->machine, "SOUND_SW", 0); case 0x03: return (sound_port_latch[offset] & 0xf7) | (upd7759_busy_r(devtag_get_device(space->machine, "upd7759")) ? 0x08 : 0); default: return 0; } }
bool sega_837_13551::analogs(UINT8 *&buf, UINT8 count) { if(count > 8) return false; for(int i=0; i<count; i++) { UINT16 val = input_port_read_safe(machine(), port_tag[3+i], 0x8000); *buf++ = val >> 8; *buf++ = val; } return true; }
static CUSTOM_INPUT( multiplexed_controller_r ) { int port = (FPTR)param; static const char *const cntrl[2][2] = { { "IN0-0", "IN0-1" }, { "IN1-0", "IN1-1" } }; return input_port_read_safe(field->port->machine, cntrl[port][controller_select & 0x01], 0x00); }
static READ8_HANDLER( topspeed_input_bypass_r ) { topspeed_state *state = space->machine->driver_data<topspeed_state>(); UINT8 port = tc0220ioc_port_r(state->tc0220ioc, 0); /* read port number */ int steer = 0; int analogue_steer = input_port_read_safe(space->machine, STEER_PORT_TAG, 0x00); int fake = input_port_read_safe(space->machine, FAKE_PORT_TAG, 0x00); if (!(fake & 0x10)) /* Analogue steer (the real control method) */ { steer = analogue_steer; } else /* Digital steer */ { if (fake & 0x08) /* pressing down */ steer = 0xff40; if (fake & 0x02) /* pressing right */ steer = 0x007f; if (fake & 0x01) /* pressing left */ steer = 0xff80; /* To allow hiscore input we must let you return to continuous input type while you press up */ if (fake & 0x04) /* pressing up */ steer = analogue_steer; } switch (port) { case 0x0c: return steer & 0xff; case 0x0d: return steer >> 8; default: return tc0220ioc_portreg_r(state->tc0220ioc, offset); } }
static CUSTOM_INPUT( multiplexed_controller_r ) { neogeo_state *state = field.machine().driver_data<neogeo_state>(); int port = (FPTR)param; static const char *const cntrl[2][2] = { { "IN0-0", "IN0-1" }, { "IN1-0", "IN1-1" } }; return input_port_read_safe(field.machine(), cntrl[port][state->m_controller_select & 0x01], 0x00); }
void dc_controller_device::read(UINT32 *dest) { dest[0] = 0x21000000; // Controller dest[1] = input_port_read_safe(machine(), port_tag[0], 0xff) | (input_port_read_safe(machine(), port_tag[1], 0xff) << 8) | (input_port_read_safe(machine(), port_tag[2], 0x00) << 16) | (input_port_read_safe(machine(), port_tag[3], 0x00) << 24); dest[2] = input_port_read_safe(machine(), port_tag[4], 0x80) | (input_port_read_safe(machine(), port_tag[5], 0x80) << 8) | (input_port_read_safe(machine(), port_tag[6], 0x80) << 16) | (input_port_read_safe(machine(), port_tag[7], 0x80) << 24); }
coco_rtc_type_t coco_fdc_device::real_time_clock() { coco_rtc_type_t result = (coco_rtc_type_t) input_port_read_safe(machine(), "real_time_clock", RTC_NONE); /* check to make sure we don't have any invalid values */ if (((result == RTC_DISTO) && (m_disto_msm6242 == NULL)) || ((result == RTC_CLOUD9) && (m_ds1315 == NULL))) { result = RTC_NONE; } return result; }
static READ8_HANDLER( spacduel_IN3_r ) { int res; int res1; int res2; int res3; res1 = input_port_read(space->machine(), "IN3"); res2 = input_port_read(space->machine(), "IN4"); res3 = input_port_read_safe(space->machine(), "DSW2", 0); 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; if ((res3 & OPTION_CHARGE_BY_) == 0) res |= 0x40; break; case 6: if (res1 & IN_P2) res |= 0x80; if ((res3 & OPTION_2_CREDIT_MINIMUM) == 0) res |= 0x40; break; case 7: res = (0x00 /* upright */ | (0 & 0x40)); if ((res3 & OPTION_1_PLAYER_GAME_ONLY) == 0) res |= 0x40; break; } return res; }
static READ8_HANDLER( firetrk_input_r ) { firetrk_state *state = space->machine().driver_data<firetrk_state>(); int i; /* update steering wheels */ for (i = 0; i < 2; i++) { UINT32 new_dial = input_port_read_safe(space->machine(), (i ? "STEER_2" : "STEER_1"), 0); INT32 delta = new_dial - state->m_dial[i]; if (delta != 0) { state->m_steer_flag[i] = 0; state->m_steer_dir[i] = (delta < 0) ? 1 : 0; state->m_dial[i] = state->m_dial[i] + delta; } } return ((input_port_read_safe(space->machine(), "BIT_0", 0) & (1 << offset)) ? 0x01 : 0) | ((input_port_read_safe(space->machine(), "BIT_6", 0) & (1 << offset)) ? 0x40 : 0) | ((input_port_read_safe(space->machine(), "BIT_7", 0) & (1 << offset)) ? 0x80 : 0); }
static WRITE8_HANDLER( multigam_IN0_w ) { if (data & 0x01) { return; } in_0_shift = 0; in_1_shift = 0; in_0 = input_port_read(space->machine, "P1"); in_1 = input_port_read(space->machine, "P2"); multigam_in_dsw_shift = 0; multigam_in_dsw = input_port_read_safe(space->machine, "DSW", 0); }
static TIMER_CALLBACK( adc_done_callback ) { micro3d_state *state = machine.driver_data<micro3d_state>(); switch (param) { case 0: state->m_adc_val = input_port_read_safe(machine, "THROTTLE", 0); break; case 1: state->m_adc_val = (UINT8)((255.0/100.0) * input_port_read(machine, "VOLUME") + 0.5); break; case 2: break; case 3: break; } // mc68901_int_gen(machine, GPIP3); }
static WRITE8_HANDLER( multigam_IN0_w ) { multigam_state *state = space->machine().driver_data<multigam_state>(); if (data & 0x01) { return; } state->m_in_0_shift = 0; state->m_in_1_shift = 0; state->m_in_0 = input_port_read(space->machine(), "P1"); state->m_in_1 = input_port_read(space->machine(), "P2"); state->m_in_dsw_shift = 0; state->m_in_dsw = input_port_read_safe(space->machine(), "DSW", 0); }
static READ8_HANDLER( geebee_in_r ) { int res; static const char *const portnames[] = { "SW0", "SW1", "DSW2", "PLACEHOLDER" }; // "IN1" & "IN2" are read separately when offset==3 offset &= 3; res = input_port_read_safe(space->machine, portnames[offset], 0); if (offset == 3) { res = input_port_read(space->machine, (flip_screen_get(space->machine) & 1) ? "IN2" : "IN1"); // read player 2 input in cocktail mode if (handle_joystick) { /* map digital two-way joystick to two fixed VOLIN values */ if (res & 2) return 0x9f; if (res & 1) return 0x0f; return 0x60; } } return res; }
void a800_handle_keyboard(running_machine *machine) { static int atari_last = 0xff; int i, modifiers, atari_code; char tag[64]; modifiers = 0; /* with shift ? */ if( input_code_pressed(KEYCODE_LSHIFT) || input_code_pressed(KEYCODE_RSHIFT) ) modifiers |= 1; /* with control ? */ if( input_code_pressed(KEYCODE_LCONTROL) || input_code_pressed(KEYCODE_RCONTROL) ) modifiers |= 2; for( i = 0; i < 64; i++ ) { sprintf(tag, "keyboard_%d", i / 16); if( input_port_read_safe(machine, tag, 0) & (1 << (i&15)) ) { atari_code = keys[i][modifiers]; if( atari_code != AKEY_NONE ) { if( atari_code == atari_last ) return; atari_last = atari_code; if( (atari_code & 0x3f) == AKEY_BREAK ) { pokey1_break_w(atari_code & 0x40); return; } pokey1_kbcode_w(atari_code, 1); return; } } } /* remove key pressed status bit from skstat */ pokey1_kbcode_w(AKEY_NONE, 0); atari_last = AKEY_NONE; }
static READ8_HANDLER( topgunbl_rotary_r ) { return (1 << input_port_read_safe(space->machine(), offset ? "DIAL1" : "DIAL0", 0x00)) ^ 0xff; }
static READ8_DEVICE_HANDLER( friskyt_portB_r ) { seicross_state *state = device->machine().driver_data<seicross_state>(); return (state->m_portb & 0x9f) | (input_port_read_safe(device->machine(), "DEBUG", 0) & 0x60); }
static READ8_HANDLER(atari_pia_pb_r) { return atari_input_disabled() ? 0xFF : input_port_read_safe(machine, "djoy_2_3", 0); }
static READ8_DEVICE_HANDLER( friskyt_portB_r ) { return (portb & 0x9f) | (input_port_read_safe(device->machine, "DEBUG", 0) & 0x60); }