Skip to content

Commit

Permalink
Added Menu button to Config Input
Browse files Browse the repository at this point in the history
  • Loading branch information
infval committed May 24, 2018
1 parent 245dd69 commit 8f778ed
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 18 deletions.
2 changes: 1 addition & 1 deletion browser/browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ char* Browser(int files_too, int menu_id, int filtered) {

gsKit_clear(gsGlobal, GS_SETREG_RGBAQ(0x00,0x00,0x00,0x80,0x00));

browser_primitive("PSMS Reloaded New v0.6", "Browser", &BG_TEX,
browser_primitive("PSMS Reloaded New v0.6.2", "Browser", &BG_TEX,
menu_x1, menu_y1, menu_x2, menu_y2);

for (i=0; i<n; i++) { //display list
Expand Down
2 changes: 1 addition & 1 deletion browser/browser.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ typedef struct {
char elfpath[1024];
char savepath[1024];
//char skinpath[1024];
u16 PlayerInput[2][9];
u16 PlayerInput[2][10];
int autofire_pattern;
} vars;

Expand Down
25 changes: 16 additions & 9 deletions browser/cnfsettings.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ void Load_Global_CNF(char *CNF_path_p)
else if(!strcmp(name,"JOY1_2")) { Settings.PlayerInput[0][6] = (u16)strtoul(value,NULL,16); }
else if(!strcmp(name,"JOY1_Turbo1")) { Settings.PlayerInput[0][7] = (u16)strtoul(value,NULL,16); }
else if(!strcmp(name,"JOY1_Turbo2")) { Settings.PlayerInput[0][8] = (u16)strtoul(value,NULL,16); }
else if(!strcmp(name,"JOY1_Menu")) { Settings.PlayerInput[0][9] = (u16)strtoul(value,NULL,16); }
//Player 2 Settings
else if(!strcmp(name,"JOY2_Start")) { Settings.PlayerInput[1][0] = (u16)strtoul(value,NULL,16); }
else if(!strcmp(name,"JOY2_Up")) { Settings.PlayerInput[1][1] = (u16)strtoul(value,NULL,16); }
Expand All @@ -160,6 +161,7 @@ void Load_Global_CNF(char *CNF_path_p)
else if(!strcmp(name,"JOY2_2")) { Settings.PlayerInput[1][6] = (u16)strtoul(value,NULL,16); }
else if(!strcmp(name,"JOY2_Turbo1")) { Settings.PlayerInput[1][7] = (u16)strtoul(value,NULL,16); }
else if(!strcmp(name,"JOY2_Turbo2")) { Settings.PlayerInput[1][8] = (u16)strtoul(value,NULL,16); }
else if(!strcmp(name,"JOY2_Menu")) { Settings.PlayerInput[1][9] = (u16)strtoul(value,NULL,16); }
}

//Set so only first player controls emulator controls
Expand Down Expand Up @@ -445,6 +447,7 @@ void Save_Global_CNF(char *CNF_path_p)
"JOY1_2 = 0x%04x\r\n"
"JOY1_Turbo1 = 0x%04x\r\n"
"JOY1_Turbo2 = 0x%04x\r\n"
"JOY1_Menu = 0x%04x\r\n"
";Player 2 Controls\r\n"
"JOY2_Start = 0x%04x\r\n"
"JOY2_Up = 0x%04x\r\n"
Expand All @@ -455,6 +458,7 @@ void Save_Global_CNF(char *CNF_path_p)
"JOY2_2 = 0x%04x\r\n"
"JOY2_Turbo1 = 0x%04x\r\n"
"JOY2_Turbo2 = 0x%04x\r\n"
"JOY2_Menu = 0x%04x\r\n"
"# ------------------------------------------------------------\r\n"
"# End-Of-File for PSMS.CNF\r\n"
"%n", //NB: The %n specifier causes NO output, but only a measurement
Expand All @@ -477,6 +481,7 @@ void Save_Global_CNF(char *CNF_path_p)
Settings.PlayerInput[0][6],
Settings.PlayerInput[0][7],
Settings.PlayerInput[0][8],
Settings.PlayerInput[0][9],
Settings.PlayerInput[1][0],
Settings.PlayerInput[1][1],
Settings.PlayerInput[1][2],
Expand All @@ -486,6 +491,7 @@ void Save_Global_CNF(char *CNF_path_p)
Settings.PlayerInput[1][6],
Settings.PlayerInput[1][7],
Settings.PlayerInput[1][8],
Settings.PlayerInput[1][9],
&CNF_size);
// Note that the final argument above measures accumulated string size,
// used for fioWrite below, so it's not one of the config variables.
Expand Down Expand Up @@ -526,15 +532,16 @@ void Default_Global_CNF(void)

int player;
for (player = 0; player < 2; player++) {
Settings.PlayerInput[player][0] = PAD_START; // PAUSE/START
Settings.PlayerInput[player][1] = PAD_UP; // UP
Settings.PlayerInput[player][2] = PAD_DOWN; // DOWN
Settings.PlayerInput[player][3] = PAD_LEFT; // LEFT
Settings.PlayerInput[player][4] = PAD_RIGHT; // RIGHT
Settings.PlayerInput[player][5] = PAD_SQUARE; // BUTTON1
Settings.PlayerInput[player][6] = PAD_CROSS; // BUTTON2
Settings.PlayerInput[player][7] = PAD_L1; // Rapid BUTTON1
Settings.PlayerInput[player][8] = PAD_R1; // Rapid BUTTON2
Settings.PlayerInput[player][0] = PAD_START; // PAUSE/START
Settings.PlayerInput[player][1] = PAD_UP; // UP
Settings.PlayerInput[player][2] = PAD_DOWN; // DOWN
Settings.PlayerInput[player][3] = PAD_LEFT; // LEFT
Settings.PlayerInput[player][4] = PAD_RIGHT; // RIGHT
Settings.PlayerInput[player][5] = PAD_SQUARE; // BUTTON1
Settings.PlayerInput[player][6] = PAD_CROSS; // BUTTON2
Settings.PlayerInput[player][7] = PAD_TRIANGLE; // Rapid BUTTON1
Settings.PlayerInput[player][8] = PAD_CIRCLE; // Rapid BUTTON2
Settings.PlayerInput[player][9] = PAD_L1; // Menu
}
}

Expand Down
28 changes: 22 additions & 6 deletions browser/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extern int snd_sample;

#define SND_RATE 48000

int statenum=0;
int statenum = 0;
u8 power_off = 0;

/************************************/
Expand Down Expand Up @@ -204,8 +204,8 @@ int menu_input(int port, int center_screen) {
if (new_pad[port] & PAD_CROSS) {
selected = 1;
}
if ((new_pad[port] == PAD_TRIANGLE) && !center_screen) {
//if ((new_pad[port] == Settings.PlayerInput[port][0]) && !center_screen) {
if ((new_pad[port] == PAD_TRIANGLE || (new_pad[port] == Settings.PlayerInput[port][9] && Settings.PlayerInput[port][9] != PAD_CROSS))
&& !center_screen) {
selected = 2;
}
}
Expand Down Expand Up @@ -710,9 +710,10 @@ static void padbuttonToStr(u16 button, char button_name[9])
strcpy(button_name, buttons[i]);
}

#define CONTROLS_N 12
#define CONTROLS_BUTTON_N 9
#define CONTROLS_N 13
#define CONTROLS_BUTTON_N 10
#define CONTROLS_OFFSET (CONTROLS_N - CONTROLS_BUTTON_N)
#define CONTROLS_MENU_BUTTON_I 9

static void Ingame_Menu_Controls()
{
Expand Down Expand Up @@ -740,7 +741,8 @@ static void Ingame_Menu_Controls()
{ "Button1 | " },
{ "Button2 | " },
{ "Turbo 1 | " },
{ "Turbo 2 | " }
{ "Turbo 2 | " },
{ " Menu | " }
};
char options_state[CONTROLS_N][16] = { { 0 } };
char options_buffer[32+16] = { 0 };
Expand Down Expand Up @@ -844,6 +846,20 @@ static void Ingame_Menu_Controls()
break;
}
}
// Menu
if (Settings.PlayerInput[player][CONTROLS_MENU_BUTTON_I] == 0) {
u16 used_buttons = 0;
for (b = 0; b < CONTROLS_BUTTON_N; b++) {
used_buttons |= Settings.PlayerInput[player][b];
}
for (b = 0; b < 16; b++) {
if (!(used_buttons & (1 << b))) {
Settings.PlayerInput[player][CONTROLS_MENU_BUTTON_I] = 1 << b;
padbuttonToStr(Settings.PlayerInput[player][CONTROLS_MENU_BUTTON_I], options_state[CONTROLS_MENU_BUTTON_I + CONTROLS_OFFSET]);
break;
}
}
}
padbuttonToStr(Settings.PlayerInput[player][i], options_state[i + CONTROLS_OFFSET]);
}
is_changing_button ^= 1;
Expand Down
2 changes: 1 addition & 1 deletion psms.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ void update_input()
pad2_connected = 1;
} else pad2_connected = 0;

if((new_pad[0] & PAD_TRIANGLE)) {
if((new_pad[0] & Settings.PlayerInput[0][9])) {
if(sound) SjPCM_Pause();
Ingame_Menu();
if(sound) SjPCM_Play();
Expand Down

0 comments on commit 8f778ed

Please sign in to comment.