Skip to content

Commit

Permalink
Allow to load CountPerOp info from mupen64plus.ini
Browse files Browse the repository at this point in the history
The CountPerOp settings has to be adjusted for each ROM. It is easier for the
enduser when the default value is not hardcoded in mupen64plus and instead
this dynamic information is retreived from the mupen64plus.ini.
  • Loading branch information
ecsv committed Jan 22, 2014
1 parent f2247c5 commit 86fe11d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/main.c
Expand Up @@ -739,7 +739,7 @@ m64p_error main_run(void)
delay_si = ConfigGetParamBool(g_CoreConfig, "DelaySI");
count_per_op = ConfigGetParamInt(g_CoreConfig, "CountPerOp");
if (count_per_op <= 0)
count_per_op = 2;
count_per_op = ROM_PARAMS.countperop;

// initialize memory, and do byte-swapping if it's not been done yet
if (g_MemHasBeenBSwapped == 0)
Expand Down
14 changes: 14 additions & 0 deletions src/main/rom.c
Expand Up @@ -37,6 +37,7 @@
#include "util.h"

#include "memory/memory.h"
#include "r4300/r4300.h"
#include "osal/preproc.h"
#include "osd/osd.h"

Expand Down Expand Up @@ -163,6 +164,7 @@ m64p_error open_rom(const unsigned char* romimage, unsigned int size)
ROM_PARAMS.systemtype = rom_country_code_to_system_type(ROM_HEADER.Country_code);
ROM_PARAMS.vilimit = rom_system_type_to_vi_limit(ROM_PARAMS.systemtype);
ROM_PARAMS.aidacrate = rom_system_type_to_ai_dac_rate(ROM_PARAMS.systemtype);
ROM_PARAMS.countperop = COUNT_PER_OP_DEFAULT;

memcpy(ROM_PARAMS.headername, ROM_HEADER.Name, 20);
ROM_PARAMS.headername[20] = '\0';
Expand All @@ -178,6 +180,7 @@ m64p_error open_rom(const unsigned char* romimage, unsigned int size)
ROM_SETTINGS.status = entry->status;
ROM_SETTINGS.players = entry->players;
ROM_SETTINGS.rumble = entry->rumble;
ROM_PARAMS.countperop = entry->countperop;
}
else
{
Expand All @@ -187,6 +190,7 @@ m64p_error open_rom(const unsigned char* romimage, unsigned int size)
ROM_SETTINGS.status = 0;
ROM_SETTINGS.players = 0;
ROM_SETTINGS.rumble = 0;
ROM_PARAMS.countperop = COUNT_PER_OP_DEFAULT;
}

/* print out a bunch of info about the ROM */
Expand Down Expand Up @@ -355,6 +359,7 @@ void romdatabase_open(void)
search->entry.savetype = DEFAULT;
search->entry.players = DEFAULT;
search->entry.rumble = DEFAULT;
search->entry.countperop = COUNT_PER_OP_DEFAULT;

search->next_entry = NULL;
search->next_crc = NULL;
Expand Down Expand Up @@ -445,6 +450,13 @@ void romdatabase_open(void)
else
DebugMessage(M64MSG_WARNING, "ROM Database: Invalid rumble string on line %i", lineno);
}
else if(!strcmp(l.name, "CountPerOp"))
{
if (string_to_int(l.value, &value) && value > 0 && value <= 4)
search->entry.countperop = value;
else
DebugMessage(M64MSG_WARNING, "ROM Database: Invalid CountPerOp on line %i", lineno);
}
else
{
DebugMessage(M64MSG_WARNING, "ROM Database: Unknown property on line %i", lineno);
Expand Down Expand Up @@ -473,6 +485,8 @@ void romdatabase_open(void)
search->entry.players = ref->players;
if(ref->rumble!=DEFAULT)
search->entry.rumble = ref->rumble;
if (ref->countperop != COUNT_PER_OP_DEFAULT)
search->entry.countperop = ref->countperop;
}
else
DebugMessage(M64MSG_WARNING, "ROM Database: Error solving RefMD5s");
Expand Down
2 changes: 2 additions & 0 deletions src/main/rom.h
Expand Up @@ -42,6 +42,7 @@ typedef struct _rom_params
int vilimit;
int aidacrate;
char headername[21]; /* ROM Name as in the header, removing trailing whitespace */
unsigned char countperop;
} rom_params;

extern m64p_rom_header ROM_HEADER;
Expand Down Expand Up @@ -111,6 +112,7 @@ typedef struct
unsigned char savetype;
unsigned char players; /* Local players 0-4, 2/3/4 way Netplay indicated by 5/6/7. */
unsigned char rumble; /* 0 - No, 1 - Yes boolean for rumble support. */
unsigned char countperop;
} romdatabase_entry;

typedef struct _romdatabase_search
Expand Down
2 changes: 1 addition & 1 deletion src/r4300/r4300.c
Expand Up @@ -45,7 +45,7 @@

unsigned int r4300emu = 0;
int no_compiled_jump = 0;
unsigned int count_per_op = 2;
unsigned int count_per_op = COUNT_PER_OP_DEFAULT;
int llbit, rompause;
#if NEW_DYNAREC != NEW_DYNAREC_ARM
int stop;
Expand Down
1 change: 1 addition & 0 deletions src/r4300/r4300.h
Expand Up @@ -46,6 +46,7 @@ extern unsigned int last_addr;
extern char invalid_code[0x100000];
extern unsigned int jump_to_address;
extern int no_compiled_jump;
#define COUNT_PER_OP_DEFAULT 2
extern unsigned int count_per_op;

void init_blocks(void);
Expand Down

0 comments on commit 86fe11d

Please sign in to comment.