Naomi: got rid of in-lst input mapping

This commit is contained in:
Flyinghead 2018-12-13 16:08:59 +01:00
parent a6881a46ac
commit 05177b2231
3 changed files with 39 additions and 157 deletions

View File

@ -98,8 +98,6 @@ enum MapleDeviceRV
MDRS_JVSReply = 0x87, // JVS I/O
};
NaomiInputMapping Naomi_Mapping;
#define SWAP32(a) ((((a) & 0xff) << 24) | (((a) & 0xff00) << 8) | (((a) >> 8) & 0xff00) | (((a) >> 24) & 0xff))
//fill in the info
@ -1341,6 +1339,33 @@ extern u8 rt[4], lt[4];
char EEPROM[0x100];
bool EEPROM_loaded = false;
static u16 getJoystickXAxis()
{
return (joyx[0] + 128) << 8;
}
static u16 getJoystickYAxis()
{
return (joyy[0] + 128) << 8;
}
static u16 getLeftTriggerAxis()
{
return lt[0] << 8;
}
static u16 getRightTriggerAxis()
{
return rt[0] << 8;
}
NaomiInputMapping Naomi_Mapping = {
{ getJoystickXAxis, getJoystickYAxis, getRightTriggerAxis, getLeftTriggerAxis },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0 },
{ 0x40, 0x01, 0x02, 0x80, 0x20, 0x10, 0x08, 0x04, 0, 0x80, 0x40, 0, 0 },
// SERVICE BTN1 BTN0 START UP DOWN LEFT RIGHT BTN2 BTN3
};
/*
* Sega JVS I/O board
*/

View File

@ -35,143 +35,6 @@ char naomi_game_id[33];
InputDescriptors *naomi_game_inputs;
u8 *naomi_default_eeprom;
extern s8 joyx[4],joyy[4];
extern u8 rt[4], lt[4];
static std::string trim(const std::string s)
{
std::string r(s);
while (!r.empty() && r[0] == ' ')
r.erase(0, 1);
while (!r.empty() && r[r.size() - 1] == ' ')
r.erase(r.size() - 1);
return r;
}
static u16 getJoystickXAxis()
{
return (joyx[0] + 128) << 8;
}
static u16 getJoystickYAxis()
{
return (joyy[0] + 128) << 8;
}
static u16 getLeftTriggerAxis()
{
return lt[0] << 8;
}
static u16 getRightTriggerAxis()
{
return rt[0] << 8;
}
static NaomiInputMapping naomi_default_mapping = {
{ getJoystickXAxis, getJoystickYAxis, getRightTriggerAxis, getLeftTriggerAxis },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0 },
{ 0x40, 0x01, 0x02, 0x80, 0x20, 0x10, 0x08, 0x04, 0, 0x80, 0x40, 0, 0 },
};
static void parse_comment(const char *line)
{
std::string s(line + 1);
s = trim(s);
if (strncmp(s.c_str(), "input-mapping:", 14))
return;
s.erase(0, 14);
s = trim(s);
while (!s.empty())
{
size_t p = s.find_first_of(",");
if (p == -1)
p = s.size();
std::string mapping = s.substr(0, p);
size_t eq = mapping.find_first_of("=");
if (eq == -1 || eq == mapping.size() - 1)
printf("Warning: unparseable mapping %s\n", mapping.c_str());
else
{
std::string dc_key = trim(mapping.substr(0, eq));
std::string naomi_key = trim(mapping.substr(eq + 1));
if (!strncmp(naomi_key.c_str(), "axis_", 5))
{
int axis = naomi_key[5] - '0';
if (axis >= 4)
printf("Warning: invalid axis number %d\n", axis);
else
{
getNaomiAxisFP fp = NULL;
if (dc_key == "axis_x")
fp = &getJoystickXAxis;
else if (dc_key == "axis_y")
fp = &getJoystickYAxis;
else if (dc_key == "axis_trigger_left")
fp = &getLeftTriggerAxis;
else if (dc_key == "axis_trigger_right")
fp = &getRightTriggerAxis;
else
printf("Warning: invalid controller axis %s\n", dc_key.c_str());
if (fp != NULL)
Naomi_Mapping.axis[axis] = fp;
}
}
else
{
int byte = naomi_key[0] - '0';
size_t colon = naomi_key.find_first_of(":");
if (colon == -1 || colon == naomi_key.size() - 1)
printf("Warning: unparseable naomi key %s\n", naomi_key.c_str());
else
{
int value = atoi(naomi_key.substr(colon + 1).c_str());
int dc_btnnum = -1;
if (dc_key == "x")
dc_btnnum = 10;
else if (dc_key == "y")
dc_btnnum = 9;
else if (dc_key == "a")
dc_btnnum = 2;
else if (dc_key == "b")
dc_btnnum = 1;
else if (dc_key == "c")
dc_btnnum = 0;
else if (dc_key == "d")
dc_btnnum = 11;
else if (dc_key == "z")
dc_btnnum = 8;
else if (dc_key == "up")
dc_btnnum = 4;
else if (dc_key == "down")
dc_btnnum = 5;
else if (dc_key == "left")
dc_btnnum = 6;
else if (dc_key == "right")
dc_btnnum = 7;
else if (dc_key == "start")
dc_btnnum = 3;
else
printf("Warning: unparseable dc key %s\n", dc_key.c_str());
if (dc_btnnum != -1)
{
Naomi_Mapping.button_mapping_byte[dc_btnnum] = byte;
Naomi_Mapping.button_mapping_mask[dc_btnnum] = value;
printf("Button %d: mapped to %d:%d\n", dc_btnnum, Naomi_Mapping.button_mapping_byte[dc_btnnum], Naomi_Mapping.button_mapping_mask[dc_btnnum]);
}
}
}
}
if (p == s.size())
break;
s = trim(s.substr(p + 1));
}
}
extern RomChip sys_rom;
static bool naomi_LoadBios(const char *filename, Archive *child_archive, Archive *parent_archive, int region)
@ -495,8 +358,6 @@ bool naomi_cart_LoadRom(char* file)
strncpy(t, file, sizeof(t));
t[sizeof(t) - 1] = '\0';
Naomi_Mapping = naomi_default_mapping;
vector<string> files;
vector<u32> fstart;
vector<u32> fsize;
@ -561,23 +422,19 @@ bool naomi_cart_LoadRom(char* file)
while (line)
{
if (line[0] == '#')
parse_comment(line);
else
char filename[512];
u32 addr, sz;
if (sscanf(line, "\"%[^\"]\",%x,%x", filename, &addr, &sz) == 3)
{
char filename[512];
u32 addr, sz;
if (sscanf(line, "\"%[^\"]\",%x,%x", filename, &addr, &sz) == 3)
{
files.push_back(filename);
fstart.push_back(addr);
fsize.push_back(sz);
setsize += sz;
RomSize = max(RomSize, (addr + sz));
}
else if (line[0] != 0 && line[0] != '\n' && line[0] != '\r')
printf("Warning: invalid line in .lst file: %s\n", line);
files.push_back(filename);
fstart.push_back(addr);
fsize.push_back(sz);
setsize += sz;
RomSize = max(RomSize, (addr + sz));
}
else if (line[0] != 0 && line[0] != '\n' && line[0] != '\r')
printf("Warning: invalid line in .lst file: %s\n", line);
line = fgets(t, 512, fl);
}
fclose(fl);

View File

@ -3984,7 +3984,7 @@ Games[] =
0x5504,
"naomi",
M4,
REGION_EXPORT,
REGION_JAPAN,
{
{ "fpr-24413.ic8", 0x0000000, 0x4000000 },
{ "fpr-24414.ic9", 0x4000000, 0x4000000 },