Skip to content

Commit

Permalink
Randomizer can now handle B2 roms
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienntindall committed Jul 29, 2022
1 parent ae1d3ff commit aeaf795
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 7 deletions.
24 changes: 24 additions & 0 deletions files/Blocks_BW2_Seasons/SeasonScripts/B2SeasonLock_english.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Offset,New
200556,0
200557,32
200558,247
200559,70
200561,0
200562,0
200563,0
200564,0
200565,0
200566,0
200567,0
200568,0
200569,0
200570,0
200571,0
200572,0
200573,0
200575,0
200577,0
200578,0
200579,0
200580,0
200581,0
24 changes: 24 additions & 0 deletions files/Blocks_BW2_Seasons/SeasonScripts/B2SeasonLock_german.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Offset,New
200428,0
200429,32
200430,247
200431,70
200433,0
200434,0
200435,0
200436,0
200437,0
200438,0
200439,0
200440,0
200441,0
200442,0
200443,0
200444,0
200445,0
200447,0
200449,0
200450,0
200451,0
200452,0
200453,0
Binary file modified map_randomizer_bw2.exe
Binary file not shown.
8 changes: 5 additions & 3 deletions src/Gen5/RomHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,18 @@ void UnpackRom(string romPath, string arm9) {

unsigned char lang;

bin.seekp(0xE);
bin.seekp(0xE); //I don't know where the language flag actually is in this game so a random bit will have to work lol

bin.read((char*) &lang, 2);

switch(lang) {
case 62:
case 62: //W2
case 35: //B2
cout << "English rom detected" << endl;
langExt = "_english.csv";
break;
case 227:
case 227: //W2
case 171: //B2
cout << "Deutsche ROM erkannt" << endl;
langExt = "_german.csv";
break;
Expand Down
3 changes: 3 additions & 0 deletions src/Gen5/RomHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ using std::string;

#define ARM9_DEC "tools\\blz.exe"
#define W2_PATH "white2_rom\\"
#define B2_PATH "black2_rom\\"
#define OUT_PATH "randomized_roms\\"
#define W2_DATA "./files/Blocks_W2/"
#define B2_DATA "./files/Blocks_B2/"
#define BW2_DATA_SHARED "./files/Blocks_BW2_Shared/"
#define SPRINGSUMMER_DATA "./files/Blocks_BW2_Seasons/SpringSummer/"
#define AUTUMN_DATA "./files/Blocks_BW2_Seasons/Autumn/"
Expand All @@ -33,6 +35,7 @@ enum Seasons {
//File change locations
#define BW2_UNIVERSAL "files\\bw2_script_universal.csv"
#define SEASON_LOCK_BASE_W2 "files\\Blocks_BW2_Seasons\\SeasonScripts\\W2SeasonLock"
#define SEASON_LOCK_BASE_B2 "files\\Blocks_BW2_Seasons\\SeasonScripts\\B2SeasonLock"

void LockSeason(string changesPath, const char season);
void UnpackRom(string path, string arm9);
Expand Down
10 changes: 6 additions & 4 deletions src/Gen5/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ static int getSeason(string* seasonInput){
}
}

static void HandleRandomization(string directory, string data, string arm9) {
static void HandleRandomization(string directory, string data, string season_path) {
generator = mt19937(time(NULL));
srand(time(NULL));
for(const auto & file : recursive_directory_iterator(directory)) {
flag = true;
string pstr = file.path().string();
UnpackRom(pstr, arm9);
UnpackRom(pstr, "");
UnpackFieldNarc();
string seedInput;
string seasonInput;
Expand Down Expand Up @@ -115,7 +115,7 @@ static void HandleRandomization(string directory, string data, string arm9) {
}
ClearData();
}
LockSeason(string(SEASON_LOCK_BASE_W2), season);
LockSeason(season_path, season);
pstr = pstr.substr(pstr.find_last_of("\\") + 1, pstr.length()-4) + "_map_randomized";
GenerateLogFile(OUT_PATH + pstr + ".log");
SetWarps();
Expand All @@ -129,7 +129,9 @@ static void HandleRandomization(string directory, string data, string arm9) {
int main() {
ClearTempData();
//W2
HandleRandomization(W2_PATH, W2_DATA, "");
HandleRandomization(W2_PATH, W2_DATA, string(SEASON_LOCK_BASE_W2));
//B2
HandleRandomization(B2_PATH, B2_DATA, string(SEASON_LOCK_BASE_B2));
if(!flag) {
cout << "No rom detected, please refer to HowToUse.txt" << endl;
}
Expand Down

0 comments on commit aeaf795

Please sign in to comment.