Unverified Commit 34f5ec60 authored by flyinghead's avatar flyinghead Committed by GitHub
Browse files

Merge pull request #557 from hiddenasbestos/ascii_stick

Arcade Stick support
parents 36099ac7 aa109dab
......@@ -246,6 +246,11 @@ void mcfg_CreateDevices()
mcfg_Create(MDT_SegaVMU, bus, 0);
break;
case MDT_AsciiStick:
mcfg_Create(MDT_AsciiStick, bus, 5);
mcfg_Create(MDT_SegaVMU, bus, 0);
break;
}
}
}
......
......@@ -20,6 +20,7 @@
const char* maple_sega_controller_name = "Dreamcast Controller";
const char* maple_sega_twinstick_name = "Twin Stick";
const char* maple_sega_vmu_name = "Visual Memory";
const char* maple_ascii_stick_name = "ASCII STICK";
const char* maple_sega_kbd_name = "Emulated Dreamcast Keyboard";
const char* maple_sega_mouse_name = "Emulated Dreamcast Mouse";
const char* maple_sega_dreameye_name_1 = "Dreamcast Camera Flash Devic";
......@@ -351,10 +352,10 @@ struct maple_sega_twinstick: maple_base
wstr(maple_sega_brand,60);
//2
w16(0x01AE);
w16(0x00DC);
//2
w16(0x01F4);
w16(0x012C);
return MDRS_DeviceStatus;
......@@ -385,6 +386,83 @@ struct maple_sega_twinstick: maple_base
}
};
/*
Ascii Stick (Arcade Stick)
No error checking of any kind, but works just fine
*/
struct maple_ascii_stick: maple_base
{
virtual MapleDeviceType get_device_type()
{
return MDT_AsciiStick;
}
virtual u32 dma( u32 cmd )
{
//printf("maple_sega_twinstick::dma Called 0x%X;Command %d\n",device_instance->port,Command);
switch ( cmd )
{
case MDC_DeviceRequest:
//caps
//4
w32(MFID_0_Input);
//struct data
//3*4
w32( 0xff070000 );
w32( 0 );
w32( 0 );
//1 area code
w8(0xFF);
//1 direction
w8(0);
//30
wstr(maple_ascii_stick_name,30);
//60
wstr(maple_sega_brand,60);
//2
w16(0x010E);
//2
w16(0x0172);
return MDRS_DeviceStatus;
case MDCF_GetCondition:
{
PlainJoystickState pjs;
config->GetInput(&pjs);
//caps
//4
w32(MFID_0_Input);
//state data
//2 key code
w16(pjs.kcode | 0xF800 ); // or with key bits
//unused/reserved, 6
w16(0);
w32(0x80808080);
}
return MDRS_DataTransfer;
default:
//printf("UNKNOWN MAPLE COMMAND %d\n",cmd);
return MDRE_UnknownCmd;
}
}
};
/*
Sega Dreamcast Visual Memory Unit
This is pretty much done (?)
......@@ -2642,6 +2720,10 @@ maple_device* maple_Create(MapleDeviceType type)
rv=new maple_sega_twinstick();
break;
case MDT_AsciiStick:
rv=new maple_ascii_stick();
break;
case MDT_Microphone:
rv=new maple_microphone();
break;
......
......@@ -7,6 +7,8 @@ enum MapleDeviceType
MDT_SegaVMU,
MDT_Microphone,
MDT_PurupuruPack,
MDT_AsciiStick,
MDT_Keyboard,
MDT_Mouse,
MDT_LightGun,
......
......@@ -33,6 +33,7 @@ char slash = '/';
#define RETRO_DEVICE_TWINSTICK RETRO_DEVICE_SUBCLASS( RETRO_DEVICE_JOYPAD, 1 )
#define RETRO_DEVICE_TWINSTICK_SATURN RETRO_DEVICE_SUBCLASS( RETRO_DEVICE_JOYPAD, 2 )
#define RETRO_DEVICE_ASCIISTICK RETRO_DEVICE_SUBCLASS( RETRO_DEVICE_JOYPAD, 3 )
#define RETRO_ENVIRONMENT_RETROARCH_START_BLOCK 0x800000
......@@ -507,7 +508,8 @@ void retro_set_environment(retro_environment_t cb)
static const struct retro_controller_description ports_default[] =
{
{ "Gamepad", RETRO_DEVICE_JOYPAD },
{ "Controller", RETRO_DEVICE_JOYPAD },
{ "Arcade Stick", RETRO_DEVICE_ASCIISTICK },
{ "Keyboard", RETRO_DEVICE_KEYBOARD },
{ "Mouse", RETRO_DEVICE_MOUSE },
{ "Light Gun", RETRO_DEVICE_LIGHTGUN },
......@@ -516,10 +518,10 @@ void retro_set_environment(retro_environment_t cb)
{ 0 },
};
static const struct retro_controller_info ports[] = {
{ ports_default, 6 },
{ ports_default, 6 },
{ ports_default, 6 },
{ ports_default, 6 },
{ ports_default, 7 },
{ ports_default, 7 },
{ ports_default, 7 },
{ ports_default, 7 },
{ 0 },
};
environ_cb(RETRO_ENVIRONMENT_SET_CONTROLLER_INFO, (void*)ports);
......@@ -1660,6 +1662,20 @@ static void set_input_descriptors()
desc[descriptor_index++] = { i, RETRO_DEVICE_TWINSTICK, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Special" };
break;
case MDT_AsciiStick:
desc[descriptor_index++] = { i, RETRO_DEVICE_TWINSTICK, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "Stick Left" };
desc[descriptor_index++] = { i, RETRO_DEVICE_TWINSTICK, 0, RETRO_DEVICE_ID_JOYPAD_UP, "Stick Up" };
desc[descriptor_index++] = { i, RETRO_DEVICE_TWINSTICK, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "Stick Down" };
desc[descriptor_index++] = { i, RETRO_DEVICE_TWINSTICK, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "Stick Right" };
desc[descriptor_index++] = { i, RETRO_DEVICE_TWINSTICK, 0, RETRO_DEVICE_ID_JOYPAD_B, "A" };
desc[descriptor_index++] = { i, RETRO_DEVICE_TWINSTICK, 0, RETRO_DEVICE_ID_JOYPAD_A, "B" };
desc[descriptor_index++] = { i, RETRO_DEVICE_TWINSTICK, 0, RETRO_DEVICE_ID_JOYPAD_X, "Y" };
desc[descriptor_index++] = { i, RETRO_DEVICE_TWINSTICK, 0, RETRO_DEVICE_ID_JOYPAD_Y, "X" };
desc[descriptor_index++] = { i, RETRO_DEVICE_TWINSTICK, 0, RETRO_DEVICE_ID_JOYPAD_L, "C" };
desc[descriptor_index++] = { i, RETRO_DEVICE_TWINSTICK, 0, RETRO_DEVICE_ID_JOYPAD_R, "Z" };
desc[descriptor_index++] = { i, RETRO_DEVICE_TWINSTICK, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" };
break;
case MDT_LightGun:
desc[descriptor_index++] = { i, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT, "D-Pad Left" };
desc[descriptor_index++] = { i, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP, "D-Pad Up" };
......@@ -2146,6 +2162,9 @@ void retro_set_controller_port_device(unsigned in_port, unsigned device)
case RETRO_DEVICE_TWINSTICK_SATURN:
maple_devices[in_port] = MDT_TwinStick;
break;
case RETRO_DEVICE_ASCIISTICK:
maple_devices[in_port] = MDT_AsciiStick;
break;
case RETRO_DEVICE_KEYBOARD:
maple_devices[in_port] = MDT_Keyboard;
break;
......@@ -2651,6 +2670,54 @@ void UpdateInputState(u32 port)
}
break;
case MDT_AsciiStick:
{
kcode[port] = 0xFFFF; // active-low
// stick
setDeviceButtonStateDirect(port, RETRO_DEVICE_ASCIISTICK, RETRO_DEVICE_ID_JOYPAD_UP, 4 );
setDeviceButtonStateDirect(port, RETRO_DEVICE_ASCIISTICK, RETRO_DEVICE_ID_JOYPAD_DOWN, 5 );
setDeviceButtonStateDirect(port, RETRO_DEVICE_ASCIISTICK, RETRO_DEVICE_ID_JOYPAD_LEFT, 6 );
setDeviceButtonStateDirect(port, RETRO_DEVICE_ASCIISTICK, RETRO_DEVICE_ID_JOYPAD_RIGHT, 7 );
// buttons
setDeviceButtonStateDirect(port, RETRO_DEVICE_ASCIISTICK, RETRO_DEVICE_ID_JOYPAD_B, 2 ); // A
setDeviceButtonStateDirect(port, RETRO_DEVICE_ASCIISTICK, RETRO_DEVICE_ID_JOYPAD_A, 1 ); // B
setDeviceButtonStateDirect(port, RETRO_DEVICE_ASCIISTICK, RETRO_DEVICE_ID_JOYPAD_Y, 10 ); // X
setDeviceButtonStateDirect(port, RETRO_DEVICE_ASCIISTICK, RETRO_DEVICE_ID_JOYPAD_X, 9 ); // Y
// Z
{
uint32_t dc_key = 1 << 8; // Z
bool is_down = input_cb(port, RETRO_DEVICE_ASCIISTICK, 0, RETRO_DEVICE_ID_JOYPAD_L) ||
input_cb(port, RETRO_DEVICE_ASCIISTICK, 0, RETRO_DEVICE_ID_JOYPAD_L2);
if (is_down)
kcode[port] &= ~dc_key;
else
kcode[port] |= dc_key;
}
// C
{
uint32_t dc_key = 1 << 0; // C
bool is_down = input_cb(port, RETRO_DEVICE_ASCIISTICK, 0, RETRO_DEVICE_ID_JOYPAD_R) ||
input_cb(port, RETRO_DEVICE_ASCIISTICK, 0, RETRO_DEVICE_ID_JOYPAD_R2);
if (is_down)
kcode[port] &= ~dc_key;
else
kcode[port] |= dc_key;
}
setDeviceButtonStateDirect(port, RETRO_DEVICE_ASCIISTICK, RETRO_DEVICE_ID_JOYPAD_START, 3 ); // Start
// unused inputs
lt[port]=0;
rt[port]=0;
joyx[port]=0;
joyy[port]=0;
}
break;
case MDT_TwinStick:
{
kcode[port] = 0xFFFF; // active-low
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment