static READ16_HANDLER( syvalion_input_bypass_r ) { /* Bypass TC0220IOC controller for analog input */ data8_t port = TC0220IOC_port_r(0); /* read port number */ switch( port ) { case 0x08: /* trackball y coords bottom 8 bits for 2nd player */ return input_port_7_r(0); case 0x09: /* trackball y coords top 8 bits for 2nd player */ if (input_port_7_r(0) & 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 input_port_6_r(0); case 0x0b: /* trackball x coords top 8 bits for 2nd player */ if (input_port_6_r(0) & 0x80) /* x- direction (negative value) */ return 0xff; else /* x+ direction (positive value) */ return 0x00; case 0x0c: /* trackball y coords bottom 8 bits for 2nd player */ return input_port_5_r(0); case 0x0d: /* trackball y coords top 8 bits for 1st player */ if (input_port_5_r(0) & 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 input_port_4_r(0); case 0x0f: /* trackball x coords top 8 bits for 1st player */ if (input_port_4_r(0) & 0x80) /* x- direction (negative value) */ return 0xff; else /* x+ direction (positive value) */ return 0x00; default: return TC0220IOC_portreg_r( offset ); } }
/*************************************************************************** Steering When D7 is high, the steering wheel has moved. If D6 is low, it moved left. If D6 is high, it moved right. Be sure to keep returning a direction until steering_reset is called, because D6 and D7 are apparently checked at different times, and a change in-between can affect the direction you move. ***************************************************************************/ static int nitedrvr_steering(void) { static int last_val=0; int this_val; int delta; this_val=input_port_5_r(0); delta=this_val-last_val; last_val=this_val; if (delta>128) delta-=256; else if (delta<-128) delta+=256; /* Divide by four to make our steering less sensitive */ nitedrvr_steering_buf+=(delta/4); if (nitedrvr_steering_buf>0) { nitedrvr_steering_buf--; nitedrvr_steering_val=0xC0; } else if (nitedrvr_steering_buf<0) { nitedrvr_steering_buf++; nitedrvr_steering_val=0x80; } else { nitedrvr_steering_val=0x00; } return nitedrvr_steering_val; }
/*************************************************************************** Steering When D7 is low, the steering wheel has moved. If D6 is low, it moved left. If D6 is high, it moved right. Be sure to keep returning a direction until steering_reset is called, because D6 and D7 are apparently checked at different times, and a change in-between can affect the direction you move. ***************************************************************************/ int sprint2_steering1(int offset) { static int last_val=0; int this_val; int delta; this_val=input_port_5_r(0); delta=this_val-last_val; last_val=this_val; if (delta>128) delta-=256; else if (delta<-128) delta+=256; /* Divide by four to make our steering less sensitive */ sprint2_steering_buf1+=(delta/4); if (sprint2_steering_buf1>0) { sprint2_steering_buf1--; sprint2_steering_val1=0x7F; } else if (sprint2_steering_buf1<0) { sprint2_steering_buf1++; sprint2_steering_val1=0x3F; } return sprint2_steering_val1; }
static READ_HANDLER( sichuan2_dsw1_r ) { int ret = input_port_3_r(0); /* Based on the coin mode fill in the upper bits */ if (input_port_4_r(0) & 0x04) { /* Mode 1 */ ret |= (input_port_5_r(0) << 4); } else { /* Mode 2 */ ret |= (input_port_5_r(0) & 0xf0); } return ret; }
AM_RANGE(0xf000, 0xffff) AM_RAM /* work ram */ ADDRESS_MAP_END static READ8_HANDLER(mux_r) { /* 76543210 xxxx - input port #2 xxxx - dip switches (2x8 bits) (multiplexed) */ int retval=input_port_2_r(0)&0x0f; switch(mux_port&0x30) { case 0x00: retval|=((input_port_4_r(0)&1)<<4)|((input_port_4_r(0)&0x10)<<1)|((input_port_5_r(0)&1)<<6)|((input_port_5_r(0)&0x10)<<3);break; case 0x10: retval|=((input_port_4_r(0)&2)<<3)|((input_port_4_r(0)&0x20) )|((input_port_5_r(0)&2)<<5)|((input_port_5_r(0)&0x20)<<2);break; case 0x20: retval|=((input_port_4_r(0)&4)<<2)|((input_port_4_r(0)&0x40)>>1)|((input_port_5_r(0)&4)<<4)|((input_port_5_r(0)&0x40)<<1);break; case 0x30: retval|=((input_port_4_r(0)&8)<<1)|((input_port_4_r(0)&0x80)>>2)|((input_port_5_r(0)&8)<<3)|((input_port_5_r(0)&0x80) );break; } return retval; }
static READ8_HANDLER( leprechn_input_port_r ) { switch (input_port_select) { case 0x01: return input_port_0_r(0); case 0x02: return input_port_2_r(0); case 0x04: return input_port_3_r(0); case 0x08: return input_port_1_r(0); case 0x40: return input_port_5_r(0); case 0x80: return input_port_4_r(0); } return 0xff; }
static void ar_coin_hack(void) { if(input_port_5_r(0)&1) { if(coin_stat==0) { coin_stat=1; if(mainram[0]==0) { mainram[0]=0x80; } mainram[0x234]++; } } else { coin_stat=0; } }
static READ_HANDLER( liberatr_input_port_0_r ) { int res ; int xdelta, ydelta; /* CTRLD selects whether we're reading the stick or the coins, see memory map */ if(*liberatr_ctrld) { /* mouse support */ xdelta = input_port_4_r(0); ydelta = input_port_5_r(0); res = ( ((ydelta << 4) & 0xf0) | (xdelta & 0x0f) ); } else { res = input_port_0_r(offset); } return res; }
/********************************************************************* Vectrex configuration (mainly 3D Imager) *********************************************************************/ void vectrex_configuration(void) { unsigned char cport = input_port_5_r (0); /* Vectrex 'dipswitch' configuration */ /* Imager control */ if (cport & 0x01) /* Imager enabled */ { if (vectrex_imager_status == 0) vectrex_imager_status = cport & 0x01; vector_add_point_function = cport & 0x02 ? vectrex_add_point_stereo: vectrex_add_point; switch ((cport>>2) & 0x07) { case 0x00: imager_colors[0]=imager_colors[1]=imager_colors[2]=VC_BLACK; break; case 0x01: imager_colors[0]=imager_colors[1]=imager_colors[2]=VC_DARKRED; break; case 0x02: imager_colors[0]=imager_colors[1]=imager_colors[2]=VC_GREEN; break; case 0x03: imager_colors[0]=imager_colors[1]=imager_colors[2]=VC_BLUE; break; case 0x04: /* mine3 has a different color sequence */ if (vectrex_imager_angles == minestorm_3d_angles) { imager_colors[0]=VC_GREEN; imager_colors[1]=VC_RED; } else { imager_colors[0]=VC_RED; imager_colors[1]=VC_GREEN; } imager_colors[2]=VC_BLUE; break; } switch ((cport>>5) & 0x07) { case 0x00: imager_colors[3]=imager_colors[4]=imager_colors[5]=VC_BLACK; break; case 0x01: imager_colors[3]=imager_colors[4]=imager_colors[5]=VC_DARKRED; break; case 0x02: imager_colors[3]=imager_colors[4]=imager_colors[5]=VC_GREEN; break; case 0x03: imager_colors[3]=imager_colors[4]=imager_colors[5]=VC_BLUE; break; case 0x04: if (vectrex_imager_angles == minestorm_3d_angles) { imager_colors[3]=VC_GREEN; imager_colors[4]=VC_RED; } else { imager_colors[3]=VC_RED; imager_colors[4]=VC_GREEN; } imager_colors[5]=VC_BLUE; break; } } else {
static READ8_HANDLER(ay_port_a_r) { /* bits 76------ latches ? 0x40 should be ok for prebillian but not for hot smash*/ return (rand()&0xc0)|input_port_5_r(0); }