remove a lot of silly analog hacks and replace with devices/joyprocess.c's ProcessAnalog(). suprnova, seta, segae, taitol, taitoz, nemesis, foodf, namcos2. also, hook up / fix player#2's analog input
This commit is contained in:
parent
28ce543c03
commit
9180171763
|
@ -1243,18 +1243,9 @@ static struct BurnDIPInfo HcrashDIPList[]=
|
|||
|
||||
STDDIPINFO(Hcrash)
|
||||
|
||||
static UINT32 scalerange(UINT32 x, UINT32 in_min, UINT32 in_max, UINT32 out_min, UINT32 out_max) {
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
}
|
||||
|
||||
static UINT8 konamigt_read_wheel()
|
||||
{
|
||||
INT16 Temp = 0x80 + (DrvAnalogPort0 / 16); // - for reversed, + for normal
|
||||
if (Temp < 0x3f) Temp = 0x3f; // clamping for happy scalerange()
|
||||
if (Temp > 0xbf) Temp = 0xbf;
|
||||
Temp = scalerange(Temp, 0x3f, 0xbf, 0x00, 0x7f);
|
||||
|
||||
return Temp;
|
||||
return ProcessAnalog(DrvAnalogPort0, 0, 0, 0x00, 0x7f);
|
||||
}
|
||||
|
||||
static UINT16 konamigt_read_analog(int /*Offset*/)
|
||||
|
|
|
@ -173,36 +173,18 @@ static INT32 dip_read(INT32 offset)
|
|||
return ((DrvDips[0] >> (offset & 7))&1) << 7;
|
||||
}
|
||||
|
||||
static UINT32 scalerange(UINT32 x, UINT32 in_min, UINT32 in_max, UINT32 out_min, UINT32 out_max) {
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
}
|
||||
|
||||
static UINT8 ananice(INT16 anaval)
|
||||
{
|
||||
INT16 Temp = 0x7f - (anaval / 16); // - for reversed, + for normal
|
||||
if (Temp < 0x3f) Temp = 0x3f; // clamping for happy scalerange()
|
||||
if (Temp > 0xbf) Temp = 0xbf;
|
||||
Temp = scalerange(Temp, 0x3f, 0xbf, 0x00, 0xff);
|
||||
|
||||
// deadzones
|
||||
// 0x7f is center, 0x01 right, 0xfe left. 0x7f +-10 is noise.
|
||||
if (!(Temp < 0x7f-10 || Temp > 0x7f+10)) Temp = 0x7f;
|
||||
|
||||
return Temp;
|
||||
}
|
||||
|
||||
static UINT16 analog_read()
|
||||
{
|
||||
INT32 analog[4] = { DrvAnalogPort0, DrvAnalogPort2, DrvAnalogPort1, DrvAnalogPort3 };
|
||||
#if 0
|
||||
switch (analog_select) {
|
||||
case 0: bprintf(0, _T("p1 X: %02X\n"), ananice(analog[analog_select])); break;
|
||||
//case 1: bprintf(0, _T("p2 X: %02X\n"), ananice(analog[analog_select])); break;
|
||||
case 2: bprintf(0, _T("p1 Y: %02X\n"), ananice(analog[analog_select])); break;
|
||||
//case 3: bprintf(0, _T("p2 Y: %02X\n"), ananice(analog[analog_select])); break;
|
||||
case 0: bprintf(0, _T("p1 X: %02X\n"), ProcessAnalog(analog[analog_select], 1, 1, 0x00, 0xff)); break;
|
||||
//case 1: bprintf(0, _T("p2 X: %02X\n"), ProcessAnalog(analog[analog_select], 1, 1, 0x00, 0xff)); break;
|
||||
case 2: bprintf(0, _T("p1 Y: %02X\n"), ProcessAnalog(analog[analog_select], 1, 1, 0x00, 0xff)); break;
|
||||
//case 3: bprintf(0, _T("p2 Y: %02X\n"), ProcessAnalog(analog[analog_select], 1, 1, 0x00, 0xff)); break;
|
||||
}
|
||||
#endif
|
||||
return ananice(analog[analog_select]);
|
||||
return ProcessAnalog(analog[analog_select], 1, 1, 0x00, 0xff);
|
||||
}
|
||||
|
||||
static UINT8 __fastcall foodf_read_byte(UINT32 address)
|
||||
|
|
|
@ -1003,18 +1003,9 @@ static INT32 AnalogClipEx(INT16 p)
|
|||
return p;
|
||||
}
|
||||
|
||||
static UINT32 scalerange(UINT32 x, UINT32 in_min, UINT32 in_max, UINT32 out_min, UINT32 out_max) {
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
}
|
||||
|
||||
static UINT8 luckywldsteer()
|
||||
{
|
||||
UINT8 Temp = 0x7f + (AnalogClip(DrvAnalogPort0) >> 4);
|
||||
UINT8 Temp2 = 0;
|
||||
|
||||
Temp2 = scalerange(Temp, 0x3f, 0xc0, 0x00, 0xff);
|
||||
|
||||
return Temp2;
|
||||
return ProcessAnalog(DrvAnalogPort0, 0, 0, 0x00, 0xff);
|
||||
}
|
||||
|
||||
static void mcu_analog_ctrl_write(UINT8 data)
|
||||
|
|
|
@ -4370,26 +4370,9 @@ UINT8 __fastcall kamenrid_read_byte(UINT32 address)
|
|||
//-----------------------------------------------------------------------------------------------------------------------------------
|
||||
// krzybowl, madshark
|
||||
|
||||
static UINT32 scalerange_skns(UINT32 x, UINT32 in_min, UINT32 in_max, UINT32 out_min, UINT32 out_max) {
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
}
|
||||
|
||||
static UINT16 ananice(INT16 anaval)
|
||||
{
|
||||
if (anaval > 1024) anaval = 1024;
|
||||
if (anaval < -1024) anaval = -1024; // clamp huge values so don't overflow INT8 conversion
|
||||
UINT8 Temp = 0x7f - (anaval >> 4); // convert to INT8, but store in UINT8
|
||||
if (Temp < 0x01) Temp = 0x01;
|
||||
if (Temp > 0xfe) Temp = 0xfe;
|
||||
UINT16 pad = scalerange_skns(Temp, 0x3f, 0xc0, 0x01, 0xff);
|
||||
if (pad > 0xff) pad = 0xff;
|
||||
if (pad > 0x75 && pad < 0x85) pad = 0x7f; // dead zone
|
||||
return pad;
|
||||
}
|
||||
|
||||
static void trackball_input_tick() // krzybowl, usclssic
|
||||
{
|
||||
INT32 padx = ananice(DrvAnalogPort0) - 0x7f;
|
||||
INT32 padx = ProcessAnalog(DrvAnalogPort0, 1, 1, 0x01, 0xff) - 0x7f;
|
||||
|
||||
if (usclssic) {
|
||||
padx /= 16;
|
||||
|
@ -4405,7 +4388,7 @@ static void trackball_input_tick() // krzybowl, usclssic
|
|||
track_x += padx;
|
||||
}
|
||||
|
||||
INT32 pady = ananice(DrvAnalogPort1) - 0x7f;
|
||||
INT32 pady = ProcessAnalog(DrvAnalogPort1, 1, 1, 0x01, 0xff) - 0x7f;
|
||||
|
||||
if (usclssic) {
|
||||
pady /= 16;
|
||||
|
|
|
@ -66,17 +66,19 @@ static INT32 sprite_kludge_y;
|
|||
static UINT8 DrvJoy1[32];
|
||||
static UINT8 DrvDips[2];
|
||||
static UINT32 DrvInputs[3];
|
||||
static INT32 DrvAnalogPort0 = 0;
|
||||
static INT32 DrvAnalogPort1 = 0;
|
||||
static INT16 DrvAnalogPort0 = 0;
|
||||
static INT16 DrvAnalogPort1 = 0;
|
||||
static UINT8 DrvReset;
|
||||
|
||||
static UINT8 PaddleX[2] = { 0, 0 };
|
||||
|
||||
static INT32 sixtyhz = 0;
|
||||
|
||||
static INT32 nGfxLen0 = 0;
|
||||
static INT32 nRedrawTiles = 0;
|
||||
static UINT32 speedhack_address = ~0;
|
||||
static UINT32 speedhack_pc[2] = { 0, 0 };
|
||||
static UINT8 m_region = 0; /* 0 Japan, 1 Europe, 2 Asia, 3 USA, 4 Korea */
|
||||
static UINT8 region = 0; /* 0 Japan, 1 Europe, 2 Asia, 3 USA, 4 Korea */
|
||||
static UINT32 Vblokbrk = 0;
|
||||
static struct BurnRomInfo emptyRomDesc[] = {
|
||||
{ "", 0, 0, 0 },
|
||||
|
@ -771,7 +773,7 @@ static void __fastcall suprnova_write_byte(UINT32 address, UINT8 data)
|
|||
// case 0x01800003:// sengeki writes here... puzzloop complains (security...)
|
||||
{
|
||||
hit.disconnect=1; /* hit2 stuff */
|
||||
switch (m_region) /* 0 Japan, 1 Europe, 2 Asia, 3 USA, 4 Korea */
|
||||
switch (region) /* 0 Japan, 1 Europe, 2 Asia, 3 USA, 4 Korea */
|
||||
{
|
||||
case 0:
|
||||
if (data == 0) hit.disconnect= 0;
|
||||
|
@ -972,7 +974,7 @@ static INT32 DrvDoReset()
|
|||
|
||||
YMZ280BReset();
|
||||
|
||||
hit.disconnect = (m_region != 2) ? 1 : 0;
|
||||
hit.disconnect = (region != 2) ? 1 : 0;
|
||||
|
||||
suprnova_alt_enable_sprites = 0;
|
||||
bright_spc_g_trans = bright_spc_r_trans = bright_spc_b_trans = 0;
|
||||
|
@ -985,6 +987,8 @@ static INT32 DrvDoReset()
|
|||
nRedrawTiles = 1;
|
||||
olddepths[0] = olddepths[1] = 0xff;
|
||||
|
||||
PaddleX[0] = PaddleX[1] = 0;
|
||||
|
||||
HiscoreReset();
|
||||
|
||||
Sh2SetEatCycles((DrvDips[1] & 1) ? 4 : 1);
|
||||
|
@ -1075,7 +1079,7 @@ static INT32 DrvInit(INT32 bios)
|
|||
if (DrvLoad(1)) return 1;
|
||||
|
||||
if (BurnLoadRom(DrvSh2BIOS, 0x00080 + bios, 1)) return 1; // bios
|
||||
m_region = bios;
|
||||
region = bios;
|
||||
BurnSwapEndian(DrvSh2BIOS, 0x80000);
|
||||
BurnSwapEndian(DrvSh2ROM, 0x200000);
|
||||
}
|
||||
|
@ -1628,22 +1632,11 @@ static INT32 DrvDraw()
|
|||
return 0;
|
||||
}
|
||||
|
||||
static UINT32 scalerange_skns(UINT32 x, UINT32 in_min, UINT32 in_max, UINT32 out_min, UINT32 out_max) {
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
}
|
||||
|
||||
static UINT8 Paddle_X = 0;
|
||||
|
||||
static UINT8 Paddle_incdec(UINT32 PaddlePortnum) {
|
||||
UINT8 Temp;
|
||||
|
||||
Temp = 0x7f + (PaddlePortnum >> 4);
|
||||
if (Temp < 0x01) Temp = 0x01;
|
||||
if (Temp > 0xfe) Temp = 0xfe;
|
||||
Temp = scalerange_skns(Temp, 0x3f, 0xbe, 0x01, 0xfe);
|
||||
if (Temp > 0x90) Paddle_X-=15;
|
||||
if (Temp < 0x70) Paddle_X+=15;
|
||||
return Paddle_X;
|
||||
static UINT8 Paddle_incdec(UINT32 PaddlePortnum, UINT32 player) {
|
||||
UINT8 Temp = ProcessAnalog(PaddlePortnum, 0, 1, 0x01, 0xff);
|
||||
if (Temp > 0x90) PaddleX[player]-=15;
|
||||
if (Temp < 0x70) PaddleX[player]+=15;
|
||||
return PaddleX[player];
|
||||
}
|
||||
|
||||
static INT32 DrvFrame()
|
||||
|
@ -1659,7 +1652,7 @@ static INT32 DrvFrame()
|
|||
}
|
||||
|
||||
DrvInputs[1] = 0x0000ff00 | DrvDips[0];
|
||||
DrvInputs[1] |= Paddle_incdec(DrvAnalogPort0) << 24;
|
||||
DrvInputs[1] |= (Paddle_incdec(DrvAnalogPort0, 0) << 24) | (Paddle_incdec(DrvAnalogPort1, 1) << 16);
|
||||
DrvInputs[2] = 0xffffffff;
|
||||
}
|
||||
|
||||
|
@ -1668,7 +1661,6 @@ static INT32 DrvFrame()
|
|||
INT32 nInterleave = 262;
|
||||
|
||||
for (INT32 i = 0; i < nInterleave; i++) {
|
||||
//Sh2Run(nTotalCycles / nInterleave);
|
||||
nCyclesDone += Sh2Run(((i + 1) * nTotalCycles / nInterleave) - nCyclesDone);
|
||||
|
||||
if (i == 1) {
|
||||
|
@ -1739,6 +1731,7 @@ static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
|
|||
SCAN_VAR(bright_v3_b);
|
||||
SCAN_VAR(use_spc_bright);
|
||||
SCAN_VAR(use_v3_bright);
|
||||
SCAN_VAR(PaddleX);
|
||||
}
|
||||
|
||||
if (nAction & ACB_NVRAM) {
|
||||
|
|
|
@ -350,41 +350,22 @@ static void __fastcall systeme_main_write(UINT16 address, UINT8 data)
|
|||
}
|
||||
}
|
||||
|
||||
static UINT32 scalerange(UINT32 x, UINT32 in_min, UINT32 in_max, UINT32 out_min, UINT32 out_max) {
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
}
|
||||
|
||||
|
||||
static UINT8 scale_wheel(UINT32 PaddlePortnum) {
|
||||
UINT8 Temp;
|
||||
|
||||
Temp = 0x7f + (PaddlePortnum >> 4);
|
||||
if (Temp < 0x01) Temp = 0x01;
|
||||
if (Temp > 0xfe) Temp = 0xfe;
|
||||
Temp = scalerange(Temp, 0x3f, 0xbe, 0x20, 0xe0);
|
||||
return Temp;
|
||||
}
|
||||
|
||||
static UINT8 scale_accel(UINT32 PaddlePortnum) {
|
||||
UINT8 Temp;
|
||||
|
||||
Temp = PaddlePortnum >> 4;
|
||||
UINT8 Temp = PaddlePortnum >> 4;
|
||||
if (Temp < 0x08) Temp = 0x00; // sometimes default for digital button -> analog is "1"
|
||||
if (Temp > 0x30) Temp = 0xff;
|
||||
|
||||
return Temp;
|
||||
}
|
||||
|
||||
|
||||
static UINT8 __fastcall hangonjr_port_f8_read(UINT8 port)
|
||||
{
|
||||
UINT8 temp = 0;
|
||||
//bprintf(0, _T("Wheel %.04X Accel %.04X\n"), scale_wheel(DrvWheel), scale_accel(DrvAccel));
|
||||
|
||||
if (port_fa_last == 0x08) /* 0000 1000 */ /* Angle */
|
||||
temp = scale_wheel(DrvWheel);
|
||||
if (port_fa_last == 0x08)
|
||||
temp = ProcessAnalog(DrvWheel, 0, 0, 0x20, 0xe0);
|
||||
|
||||
if (port_fa_last == 0x09) /* 0000 1001 */ /* Accel */
|
||||
if (port_fa_last == 0x09)
|
||||
temp = scale_accel(DrvAccel);
|
||||
|
||||
return temp;
|
||||
|
|
|
@ -1900,29 +1900,12 @@ static void __fastcall horshoes_main_write(UINT16 address, UINT8 data)
|
|||
}
|
||||
|
||||
// horshoes trackball stuff
|
||||
static UINT32 scalerange(UINT32 x, UINT32 in_min, UINT32 in_max, UINT32 out_min, UINT32 out_max) {
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
}
|
||||
|
||||
static UINT16 ananice(INT16 anaval)
|
||||
{
|
||||
if (anaval > 1024) anaval = 1024;
|
||||
if (anaval < -1024) anaval = -1024; // clamp huge values so don't overflow INT8 conversion
|
||||
UINT8 Temp = 0x7f - (anaval >> 4);
|
||||
if (Temp < 0x01) Temp = 0x01;
|
||||
if (Temp > 0xfe) Temp = 0xfe;
|
||||
UINT16 pad = scalerange(Temp, 0x3f, 0xc0, 0x01, 0xff);
|
||||
if (pad > 0xff) pad = 0xff;
|
||||
if (pad > 0x75 && pad < 0x85) pad = 0x7f;
|
||||
return pad;
|
||||
}
|
||||
|
||||
static void trackball_tick()
|
||||
{
|
||||
INT32 padx = ananice(DrvAnalogPort0) - 0x7f;
|
||||
INT32 padx = ProcessAnalog(DrvAnalogPort0, 1, 1, 0x00, 0xff) - 0x80;
|
||||
track_x -= padx/2; // (-=) reversed :)
|
||||
|
||||
INT32 pady = ananice(DrvAnalogPort1) - 0x7f;
|
||||
INT32 pady = ProcessAnalog(DrvAnalogPort1, 1, 1, 0x00, 0xff) - 0x80;
|
||||
track_y += pady/2;
|
||||
}
|
||||
|
||||
|
@ -1938,22 +1921,22 @@ static UINT8 __fastcall horshoes_main_read(UINT16 address)
|
|||
return BurnYM2203Read(0, address & 1);
|
||||
|
||||
case 0xa800:
|
||||
return (track_y - track_y_last) & 0xff; // tracky_lo_r
|
||||
return (track_y - track_y_last) & 0xff;
|
||||
|
||||
case 0xa802: track_y_last = track_y;
|
||||
return 0; // tracky_reset_r
|
||||
case 0xa802: track_y_last = track_y; // reset y
|
||||
return 0;
|
||||
|
||||
case 0xa803: track_x_last = track_x;
|
||||
return 0; // trackx_reset_r
|
||||
case 0xa803: track_x_last = track_x; // reset x
|
||||
return 0;
|
||||
|
||||
case 0xa804:
|
||||
return (track_y - track_y_last) >> 8; // tracky_hi_r
|
||||
return (track_y - track_y_last) >> 8;
|
||||
|
||||
case 0xa808:
|
||||
return (track_x - track_x_last) & 0xff; // trackx_lo_r
|
||||
return (track_x - track_x_last) & 0xff;
|
||||
|
||||
case 0xa80c:
|
||||
return (track_x - track_x_last) >> 8; // trackx_hi_r
|
||||
return (track_x - track_x_last) >> 8;
|
||||
}
|
||||
|
||||
return fhawk_main_read(address);
|
||||
|
|
|
@ -4080,44 +4080,17 @@ static const UINT8 nightstr_stick[128]=
|
|||
0x46,0x47,0x48,0x49,0xb8
|
||||
};
|
||||
|
||||
static UINT32 scalerange(UINT32 x, UINT32 in_min, UINT32 in_max, UINT32 out_min, UINT32 out_max) {
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
}
|
||||
|
||||
static UINT8 ananice(INT16 anaval, INT32 reversed, INT32 deadzone, UINT8 scalemin, UINT8 scalemax)
|
||||
{
|
||||
INT32 DeadZone = (deadzone) ? 10 : 0;
|
||||
INT16 Temp = (reversed) ? (0x7f - (anaval / 16)) : (0x7f + (anaval / 16)); // - for reversed, + for normal
|
||||
|
||||
if (deadzone) { // deadzones
|
||||
// 0x7f is center, 0x3f right, 0xbe left. 0x7f +-10 is noise.
|
||||
if (!(Temp < 0x7f-DeadZone || Temp > 0x7f+DeadZone)) {
|
||||
Temp = 0x7f; // we hit a dead-zone, return mid-range
|
||||
} else {
|
||||
// so we don't jump between 0x7f (center) and next value
|
||||
if (Temp < 0x7f-DeadZone) Temp += DeadZone;
|
||||
else if (Temp > 0x7f+DeadZone) Temp -= DeadZone;
|
||||
}
|
||||
}
|
||||
|
||||
if (Temp < 0x3f + DeadZone) Temp = 0x3f + DeadZone; // clamping for happy scalerange()
|
||||
if (Temp > 0xbe - DeadZone) Temp = 0xbe - DeadZone;
|
||||
Temp = scalerange(Temp, 0x3f + DeadZone, 0xbe - DeadZone, scalemin, scalemax);
|
||||
|
||||
return Temp;
|
||||
}
|
||||
|
||||
static UINT8 NightstrStickRead(INT32 Offset)
|
||||
{
|
||||
switch (Offset) { // p0: 3f - be p1: bf - 40
|
||||
case 0x00: {
|
||||
UINT8 Temp = ananice(TaitoAnalogPort0, 0, 0, 0x00, 0xff);
|
||||
UINT8 Temp = ProcessAnalog(TaitoAnalogPort0, 0, 0, 0x00, 0xff);
|
||||
//bprintf(0, _T("Port0-temp[%X] scaled[%X]\n"), Temp, Temp2);
|
||||
return nightstr_stick[(Temp * 0x64) / 0x100];
|
||||
}
|
||||
|
||||
case 0x01: {
|
||||
UINT8 Temp = ananice(TaitoAnalogPort1, 1, 0, 0x00, 0xff);
|
||||
UINT8 Temp = ProcessAnalog(TaitoAnalogPort1, 1, 0, 0x00, 0xff);
|
||||
return nightstr_stick[(Temp * 0x64) / 0x100];
|
||||
}
|
||||
|
||||
|
@ -4322,7 +4295,7 @@ void __fastcall Racingb68K1WriteWord(UINT32 a, UINT16 d)
|
|||
|
||||
static UINT8 SciSteerRead(INT32 Offset)
|
||||
{
|
||||
INT32 Steer = 0xFF80 + ananice(TaitoAnalogPort0, 0, 1, 0x20, 0xe0);
|
||||
INT32 Steer = 0xFF80 + ProcessAnalog(TaitoAnalogPort0, 0, 1, 0x20, 0xe0);
|
||||
|
||||
switch (Offset) {
|
||||
case 0x04: {
|
||||
|
|
Loading…
Reference in New Issue