add joyprocess device
This commit is contained in:
parent
b6ea1abef8
commit
6248ad8492
|
@ -87,7 +87,7 @@ depobj := $(drvobj) \
|
|||
burn.o burn_gun.o burn_led.o burn_memory.o burn_sound.o burn_sound_c.o cheat.o debug_track.o hiscore.o load.o \
|
||||
tiles_generic.o timer.o vector.o \
|
||||
\
|
||||
8255ppi.o 8257dma.o eeprom.o nmk004.o kaneko_tmap.o pandora.o seibusnd.o sknsspr.o slapstic.o t5182.o timekpr.o tms34061.o \
|
||||
8255ppi.o 8257dma.o eeprom.o joyprocess.o nmk004.o kaneko_tmap.o pandora.o seibusnd.o sknsspr.o slapstic.o t5182.o timekpr.o tms34061.o \
|
||||
v3021.o vdc.o tms9928a.o \
|
||||
\
|
||||
ay8910.o burn_y8950.o burn_ym2151.o burn_ym2203.o burn_ym2413.o burn_ym2608.o burn_ym2610.o burn_ym2612.o \
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
#include "burnint.h"
|
||||
#include "joyprocess.h"
|
||||
|
||||
#define INPUT_4WAY 2
|
||||
#define INPUT_CLEAROPPOSITES 4
|
||||
#define INPUT_MAKEACTIVELOW 8
|
||||
|
||||
void ProcessJoystick(UINT8 *input, INT8 playernum, INT8 up_bit, INT8 down_bit, INT8 left_bit, INT8 right_bit, UINT8 flags)
|
||||
{
|
||||
// Limitation: this only works on the first 4 bits - active high to start with
|
||||
// grep ProcessJoystick in drv/pre90s for examples
|
||||
|
||||
static INT32 fourway[4] = { 0, 0, 0, 0 }; // 4-way buffer
|
||||
static UINT8 DrvInputPrev[4] = { 0, 0, 0, 0 }; // 4-way buffer
|
||||
|
||||
UINT8 ud = (1 << up_bit) | (1 << down_bit);
|
||||
UINT8 rl = (1 << right_bit) | (1 << left_bit);
|
||||
|
||||
if (flags & INPUT_4WAY) {
|
||||
playernum &= 3; // just incase.
|
||||
if(*input != DrvInputPrev[playernum]) {
|
||||
fourway[playernum] = *input & 0xf;
|
||||
|
||||
if((fourway[playernum] & rl) && (fourway[playernum] & ud))
|
||||
fourway[playernum] ^= (fourway[playernum] & (DrvInputPrev[playernum] & 0xf));
|
||||
|
||||
if((fourway[playernum] & rl) && (fourway[playernum] & ud)) // if it starts out diagonally, pick a direction
|
||||
fourway[playernum] &= (rand()&1) ? rl : ud;
|
||||
}
|
||||
|
||||
DrvInputPrev[playernum] = *input;
|
||||
|
||||
*input = fourway[playernum] | (DrvInputPrev[playernum] & 0xf0); // preserve the unprocessed/other bits
|
||||
}
|
||||
|
||||
if (flags & INPUT_CLEAROPPOSITES) {
|
||||
if ((*input & rl) == rl) {
|
||||
*input &= ~rl;
|
||||
}
|
||||
if ((*input & ud) == ud) {
|
||||
*input &= ~ud;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & INPUT_MAKEACTIVELOW) {
|
||||
*input = 0xff - *input;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
#define INPUT_4WAY 2
|
||||
#define INPUT_CLEAROPPOSITES 4
|
||||
#define INPUT_MAKEACTIVELOW 8
|
||||
|
||||
void ProcessJoystick(UINT8 *input, INT8 playernum, INT8 up_bit, INT8 down_bit, INT8 left_bit, INT8 right_bit, UINT8 flags);
|
||||
|
Loading…
Reference in New Issue