Skip to content

Commit

Permalink
Add Autofire Pattern option
Browse files Browse the repository at this point in the history
Autofire Patterns: 1 on, 1 off; 1 on, 2 off; 1 on, 3 off; 1 on, 4 off; 1 on, 5 off.
Move "4-Players Adaptor" option to "Configure Input".
  • Loading branch information
infval committed Apr 20, 2018
1 parent bbbf0dc commit 093aa3f
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 50 deletions.
4 changes: 2 additions & 2 deletions src/drivers/ps2/browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extern GSFONTM *gsFontM;
/************************************/
/* Pad Variables */
/************************************/
extern u32 old_pad[2];
extern u32 old_pad[4];
static struct padButtonStatus buttons[2];

extern int defaultx, defaulty;
Expand Down Expand Up @@ -639,7 +639,7 @@ char* Browser(int files_too, int menu_id)
if (selection != oldselect) {

gsKit_clear(gsGlobal, GS_SETREG_RGBAQ(0x00, 0x00, 0x00, 0x80, 0x00));
browser_primitive("FCEUltra PS2 B0.93 [x.3.0]", "Browser", &BG_TEX, menu_x1, menu_y1, menu_x2, menu_y2);
browser_primitive("FCEUltra PS2 B0.93 [x.3.1]", "Browser", &BG_TEX, menu_x1, menu_y1, menu_x2, menu_y2);

if (selection > max_item) {
list_offset = text_line - (selection - max_item) * FONT_HEIGHT;
Expand Down
46 changes: 25 additions & 21 deletions src/drivers/ps2/cnfsettings.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,16 @@ void Load_Global_CNF(char *CNF_path_p)
for (var_cnt = 0; get_CNF_string(&CNF_p, &name, &value); var_cnt++) {
// A variable was found, now we dispose of its value.
printf("Found variable \"%s\" with value \"%s\"\r\n", name, value);
if (!strcmp(name, "OffsetX")) { Settings.offset_x = atoi(value); }
else if (!strcmp(name, "OffsetY")) { Settings.offset_y = atoi(value); }
else if (!strcmp(name, "Display")) { Settings.display = atoi(value); }
else if (!strcmp(name, "Emulation")) { Settings.emulation = atoi(value); }
else if (!strcmp(name, "Interlace")) { Settings.interlace = atoi(value); }
else if (!strcmp(name, "Filter")) { Settings.filter = atoi(value); }
else if (!strcmp(name, "AspectRatio")) { Settings.aspect_ratio = atoi(value); }
else if (!strcmp(name, "Sound")) { Settings.sound = atoi(value); }
else if (!strcmp(name, "Palette")) { Settings.current_palette = atoi(value); }
if (!strcmp(name, "OffsetX")) { Settings.offset_x = atoi(value); }
else if (!strcmp(name, "OffsetY")) { Settings.offset_y = atoi(value); }
else if (!strcmp(name, "Display")) { Settings.display = atoi(value); }
else if (!strcmp(name, "Emulation")) { Settings.emulation = atoi(value); }
else if (!strcmp(name, "Interlace")) { Settings.interlace = atoi(value); }
else if (!strcmp(name, "Filter")) { Settings.filter = atoi(value); }
else if (!strcmp(name, "AspectRatio")) { Settings.aspect_ratio = atoi(value); }
else if (!strcmp(name, "Sound")) { Settings.sound = atoi(value); }
else if (!strcmp(name, "AutofirePattern")) { Settings.autofire_pattern = atoi(value); }
else if (!strcmp(name, "Palette")) { Settings.current_palette = atoi(value); }
else if (!strcmp(name, "Elfpath")) { strcpy(Settings.elfpath, value); }
else if (!strcmp(name, "Savepath")) { strcpy(Settings.savepath, value); }
else if (!strcmp(name, "Skinpath")) { strcpy(Settings.skinpath, value); }
Expand Down Expand Up @@ -447,18 +448,19 @@ void Save_Global_CNF(char *CNF_path_p)
"# FCEULTRA.CNF == Configuration file for the emulator FCEUltra\r\n"
"# CNF Handling Code (c)2006 Ronald Andersson aka dlanor \r\n"
"# ------------------------------------------------------------\r\n"
"OffsetX = %d\r\n"
"OffsetY = %d\r\n"
"Display = %d\r\n"
"Emulation = %d\r\n"
"Interlace = %d\r\n"
"Filter = %d\r\n"
"AspectRatio = %d\r\n"
"Sound = %d\r\n"
"Palette = %d\r\n"
"Elfpath = %s\r\n"
"Savepath = %s\r\n"
"Skinpath = %s\r\n"
"OffsetX = %d\r\n"
"OffsetY = %d\r\n"
"Display = %d\r\n"
"Emulation = %d\r\n"
"Interlace = %d\r\n"
"Filter = %d\r\n"
"AspectRatio = %d\r\n"
"Sound = %d\r\n"
"AutofirePattern = %d\r\n"
"Palette = %d\r\n"
"Elfpath = %s\r\n"
"Savepath = %s\r\n"
"Skinpath = %s\r\n"
";Player 1 Controls\r\n"
"JOY1_Menu = 0x%04x\r\n"
"JOY1_SaveState = 0x%04x\r\n"
Expand Down Expand Up @@ -519,6 +521,7 @@ void Save_Global_CNF(char *CNF_path_p)
Settings.filter,
Settings.aspect_ratio,
Settings.sound,
Settings.autofire_pattern,
Settings.current_palette,
temp1,
temp2,
Expand Down Expand Up @@ -632,6 +635,7 @@ void Default_Global_CNF()
Settings.aspect_ratio = 0; // Full Screen
Settings.sound = 2; // 22050Hz
Settings.input_4p_adaptor = 0; // False
Settings.autofire_pattern = 0; // 0 - 1-on, 1-off
Settings.current_palette = 0; // 0 - Default
strcpy(Settings.elfpath, "mc0:/BOOT/BOOT.ELF");
strcpy(Settings.savepath, "mc0:/FCEUMM/");
Expand Down
57 changes: 35 additions & 22 deletions src/drivers/ps2/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern GSTEXTURE MENU_TEX;
/************************************/
/* Pad Variables */
/************************************/
extern u32 old_pad[2];
extern u32 old_pad[4];
static struct padButtonStatus buttons[2];
extern u8 fdsswap;

Expand Down Expand Up @@ -538,9 +538,9 @@ void Ingame_Menu()
{ "Filtering: "},
{ "Aspect Ratio: "},
{ "Sound: " },
{ "4-Players Adaptor: " },
{ "Configure Input >" },
{ "---" },
{ "---" },
{ "Reset Game" },
{ "Exit Game" },
{ "Exit Menu" },
Expand Down Expand Up @@ -574,10 +574,6 @@ void Ingame_Menu()
sprintf(options_state[i], "%dHz", SND_GetCurrSampleRate());
break;
case 6:
if (Settings.input_4p_adaptor)
strcpy(options_state[i], "On");
else
strcpy(options_state[i], "Off");
break;
case 7:
break;
Expand Down Expand Up @@ -686,19 +682,9 @@ void Ingame_Menu()
option_changed = 1;
break;
case 6:
Settings.input_4p_adaptor ^= 1;
if (Settings.input_4p_adaptor) {
FCEUI_SetInputFC(SIFC_4PLAYER, NULL, 0);
strcpy(options_state[i], "On");
}
else {
FCEUI_SetInputFC(SIFC_NONE, NULL, 0);
strcpy(options_state[i], "Off");
}
option_changed = 1;
Ingame_Menu_Controls();
break;
case 7:
Ingame_Menu_Controls();
break;
case 8:
break;
Expand Down Expand Up @@ -805,8 +791,8 @@ void padbuttonToStr(u16 button, char button_name[9])
strcpy(button_name, buttons[i]);
}

#define CONTROLS_N 12
#define CONTROLS_OFFSET 2
#define CONTROLS_N 14
#define CONTROLS_OFFSET (CONTROLS_N - 10)

void Ingame_Menu_Controls()
{
Expand All @@ -824,6 +810,8 @@ void Ingame_Menu_Controls()

char options[CONTROLS_N][32] = {
{ "< Back" },
{ "Autofire Pattern: "},
{ "4-Players Adaptor: " },
{ "Player: "},
{ "Joy A | " },
{ "Joy B | " },
Expand All @@ -843,7 +831,12 @@ void Ingame_Menu_Controls()
int is_changing_button = 0;
u32 new_button = 0;

strcpy(options_state[1], "1");
sprintf(options_state[1], "1 on, %d off", Settings.autofire_pattern + 1);
if (Settings.input_4p_adaptor)
strcpy(options_state[2], "On");
else
strcpy(options_state[2], "Off");
strcpy(options_state[3], "1");
for (i = 0; i < 10; i++) {
padbuttonToStr(Settings.PlayerInput[player][i + 5], options_state[i + CONTROLS_OFFSET]);
}
Expand All @@ -870,11 +863,11 @@ void Ingame_Menu_Controls()
strcat(buffer, options_state[i]);
if (selection == i) {
//font_print(gsGlobal, menu_x1+10.0f, text_line + i*FONT_HEIGHT, 2, DarkYellowFont, options[i]);
printXY(buffer, menu_x1+10, text_line + i*FONT_HEIGHT, 4, FCEUSkin.highlight, 1, 0);
printXY(buffer, menu_x1+10, FONT_HEIGHT + text_line + i*FONT_HEIGHT, 4, FCEUSkin.highlight, 1, 0);
}
else {
//font_print(gsGlobal, menu_x1+10.0f, text_line + i*FONT_HEIGHT, 2, WhiteFont, options[i]);
printXY(buffer, menu_x1+10, text_line + i*FONT_HEIGHT, 4, FCEUSkin.textcolor, 1, 0);
printXY(buffer, menu_x1+10, FONT_HEIGHT + text_line + i*FONT_HEIGHT, 4, FCEUSkin.textcolor, 1, 0);
}
}

Expand All @@ -893,6 +886,26 @@ void Ingame_Menu_Controls()
return;
}
else if (i == 1) {
Settings.autofire_pattern++;
if (Settings.autofire_pattern >= 5) {
Settings.autofire_pattern = 0;
}
sprintf(options_state[1], "1 on, %d off", Settings.autofire_pattern + 1);
option_changed = 1;
}
else if (i == 2) {
Settings.input_4p_adaptor ^= 1;
if (Settings.input_4p_adaptor) {
FCEUI_SetInputFC(SIFC_4PLAYER, NULL, 0);
strcpy(options_state[i], "On");
}
else {
FCEUI_SetInputFC(SIFC_NONE, NULL, 0);
strcpy(options_state[i], "Off");
}
option_changed = 1;
}
else if (i == 3) {
player++;
if (player >= 4) {
player = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/drivers/ps2/ps2fceu.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ typedef struct {
u8 emulation;
u8 interlace;
u8 filter;
u8 aspect_ratio;
int aspect_ratio;
u8 sound;
char elfpath[1024];
char savepath[1024];
char skinpath[1024];
u16 PlayerInput[4][15];
u8 input_4p_adaptor;
int autofire_pattern;
int current_palette;
} vars;

Expand Down
8 changes: 4 additions & 4 deletions src/drivers/ps2/ps2input.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,20 +246,20 @@ static unsigned char Get_PS2Input(int mport)
}
// Turbo A
if (paddata[mport] & Settings.PlayerInput[mport][13]) {
rapid_a[mport] ^= 1;
if (rapid_a[mport]) {
if (!rapid_a[mport]) {
P |= JOY_A;
}
rapid_a[mport] = (rapid_a[mport] + 1) % (Settings.autofire_pattern + 2);
}
if (!(paddata[mport] & Settings.PlayerInput[mport][13]) && rapid_a[mport]) {
rapid_a[mport] = 0;
}
// Turbo B
if (paddata[mport] & Settings.PlayerInput[mport][14]) {
rapid_b[mport] ^= 1;
if (rapid_b[mport]) {
if (!rapid_b[mport]) {
P |= JOY_B;
}
rapid_b[mport] = (rapid_b[mport] + 1) % (Settings.autofire_pattern + 2);
}
if (!(paddata[mport] & Settings.PlayerInput[mport][14]) && rapid_b[mport]) {
rapid_b[mport] = 0;
Expand Down

0 comments on commit 093aa3f

Please sign in to comment.