mirror of
https://github.com/isledecomp/LEGOIslandRebuilder.git
synced 2024-11-27 17:45:42 -05:00
preliminary august support
This commit is contained in:
parent
8482721b12
commit
d9205c5f6b
1 changed files with 62 additions and 18 deletions
|
@ -276,19 +276,60 @@ namespace Rebuilder
|
||||||
Write(fs, str_bytes, pos);
|
Write(fs, str_bytes, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Patch(string dir)
|
private bool ApproxEqual(float a, float b)
|
||||||
{
|
{
|
||||||
using (FileStream lego1dll = File.Open(dir + "/LEGO1.DLL", FileMode.Open, FileAccess.Write))
|
return Math.Abs(a - b) < 0.0001;
|
||||||
using (FileStream isleexe = File.Open(dir + "/ISLE.EXE", FileMode.Open, FileAccess.Write))
|
}
|
||||||
|
|
||||||
|
private bool IncompatibleBuildMessage(string incompatibilities)
|
||||||
{
|
{
|
||||||
|
return (MessageBox.Show("The following patches you've chosen are not compatible with this version of LEGO Island:\n\n" + incompatibilities + "\nContinue?", "Compatibility", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool Patch(string dir)
|
||||||
|
{
|
||||||
|
string incompatibilities = "";
|
||||||
|
|
||||||
|
using (FileStream lego1dll = File.Open(dir + "/LEGO1.DLL", FileMode.Open, FileAccess.ReadWrite))
|
||||||
|
using (FileStream isleexe = File.Open(dir + "/ISLE.EXE", FileMode.Open, FileAccess.ReadWrite))
|
||||||
|
{
|
||||||
|
// Crude check if the build is September or August
|
||||||
|
lego1dll.Position = 0x54083;
|
||||||
|
bool aug_build = (lego1dll.ReadByte() == 0x7E);
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (aug_build)
|
||||||
|
{
|
||||||
|
Console.WriteLine("August build detected");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("September build detected");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Write turn/movement speed hack (this frees up 12 bytes of code)
|
// Write turn/movement speed hack (this frees up 12 bytes of code)
|
||||||
Write(lego1dll, new byte[] { 0x7E, 0x04, 0x2B, 0xD1, 0xEB, 0x0C, 0x89, 0xC8, 0xF7, 0xD8, 0x39, 0xD0, 0x7E, 0x2F, 0x01, 0xCA, 0x29, 0xCE, 0x89, 0x54, 0x24, 0x04, 0xDB, 0x44, 0x24, 0x04, 0x89, 0x74, 0x24, 0x04, 0xDA, 0x74, 0x24, 0x04, 0x3D, 0xF0, 0x00, 0x00, 0x00, 0x74, 0x0A, 0xC7, 0x44, 0x24, 0x04 }, 0x54323);
|
long turn_speed_offset = aug_build ? 0x54083 : 0x54323;
|
||||||
|
Write(lego1dll, new byte[] { 0x7E, 0x04, 0x2B, 0xD1, 0xEB, 0x0C, 0x89, 0xC8, 0xF7, 0xD8, 0x39, 0xD0, 0x7E, 0x2F, 0x01, 0xCA, 0x29, 0xCE, 0x89, 0x54, 0x24, 0x04, 0xDB, 0x44, 0x24, 0x04, 0x89, 0x74, 0x24, 0x04, 0xDA, 0x74, 0x24, 0x04, 0x3D, 0xF0, 0x00, 0x00, 0x00, 0x74, 0x0A, 0xC7, 0x44, 0x24, 0x04 }, turn_speed_offset);
|
||||||
WriteFloat(lego1dll, (float)turn_speed_control.Value);
|
WriteFloat(lego1dll, (float)turn_speed_control.Value);
|
||||||
Write(lego1dll, new byte[] { 0xEB, 0x08, 0xC7, 0x44, 0x24, 0x04 });
|
Write(lego1dll, new byte[] { 0xEB, 0x08, 0xC7, 0x44, 0x24, 0x04 });
|
||||||
WriteFloat(lego1dll, (float)movement_speed_control.Value);
|
WriteFloat(lego1dll, (float)movement_speed_control.Value);
|
||||||
Write(lego1dll, new byte[] { 0xD8, 0x4C, 0x24, 0x04, 0xD8, 0x4C, 0x24, 0x14, 0xD9, 0x5C, 0x24, 0x04, 0xD9, 0x44, 0x24, 0x04, 0x5E, 0x83, 0xC4, 0x04, 0xC2, 0x0C, 0x00, 0xC7, 0x44, 0x24, 0x04, 0x00, 0x00, 0x00, 0x00, 0xD9, 0x44, 0x24, 0x04, 0x5E, 0x83, 0xC4, 0x04, 0xC2, 0x0C, 0x00, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 });
|
Write(lego1dll, new byte[] { 0xD8, 0x4C, 0x24, 0x04, 0xD8, 0x4C, 0x24, 0x14, 0xD9, 0x5C, 0x24, 0x04, 0xD9, 0x44, 0x24, 0x04, 0x5E, 0x83, 0xC4, 0x04, 0xC2, 0x0C, 0x00, 0xC7, 0x44, 0x24, 0x04, 0x00, 0x00, 0x00, 0x00, 0xD9, 0x44, 0x24, 0x04, 0x5E, 0x83, 0xC4, 0x04, 0xC2, 0x0C, 0x00, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 });
|
||||||
|
|
||||||
|
//
|
||||||
|
// TODO: The redirect_saves and run_fullscreen hacks could probably be done easier by redirecting Lego Island's registry reading to HKCU rather than HKLM.
|
||||||
|
// We'd free up a lot of bytes of code that way (at least with redirect_saves).
|
||||||
|
//
|
||||||
|
// Also find a solution for the August build
|
||||||
|
//
|
||||||
|
|
||||||
if (redirect_saves.Checked)
|
if (redirect_saves.Checked)
|
||||||
|
{
|
||||||
|
if (aug_build)
|
||||||
|
{
|
||||||
|
incompatibilities += redirect_saves.Text + "\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// Write patch to write saves to "AppData" instead of "Program Files"
|
// Write patch to write saves to "AppData" instead of "Program Files"
|
||||||
Write(lego1dll, new byte[] { 0xE9, 0x61, 0x9B, 0x09, 0x00 }, 0x39300);
|
Write(lego1dll, new byte[] { 0xE9, 0x61, 0x9B, 0x09, 0x00 }, 0x39300);
|
||||||
|
@ -299,6 +340,7 @@ namespace Rebuilder
|
||||||
Directory.CreateDirectory(new_save_dir);
|
Directory.CreateDirectory(new_save_dir);
|
||||||
WriteString(lego1dll, new_save_dir);
|
WriteString(lego1dll, new_save_dir);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (stay_active_when_window_is_defocused.Checked)
|
if (stay_active_when_window_is_defocused.Checked)
|
||||||
|
@ -307,10 +349,10 @@ namespace Rebuilder
|
||||||
Write(isleexe, new byte[] { 0x90, 0x90, 0x90 }, 0x1363);
|
Write(isleexe, new byte[] { 0x90, 0x90, 0x90 }, 0x1363);
|
||||||
|
|
||||||
// Write DirectSound flags to allow audio to play while the window is defocused
|
// Write DirectSound flags to allow audio to play while the window is defocused
|
||||||
WriteByte(lego1dll, 0x80, 0xB120B);
|
WriteByte(lego1dll, 0x80, aug_build ? 0xB48FB : 0xB120B);
|
||||||
WriteByte(lego1dll, 0x80, 0x5B96);
|
WriteByte(lego1dll, 0x80, 0x5B96);
|
||||||
WriteByte(lego1dll, 0x80, 0xB1201);
|
WriteByte(lego1dll, 0x80, aug_build ? 0xB48F1 : 0xB1201);
|
||||||
WriteByte(lego1dll, 0x80, 0xADD43);
|
WriteByte(lego1dll, 0x80, aug_build ? 0xAD7D3 : 0xADD43);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This operation skips the registry check so full screen/window mode can be set without entering the registry
|
// This operation skips the registry check so full screen/window mode can be set without entering the registry
|
||||||
|
@ -337,6 +379,8 @@ namespace Rebuilder
|
||||||
WriteInt32(isleexe, (Int32)res_height.Value-1, 0x4D7);
|
WriteInt32(isleexe, (Int32)res_height.Value-1, 0x4D7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return string.IsNullOrEmpty(incompatibilities) || IncompatibleBuildMessage(incompatibilities);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsValidDir(string dir)
|
private bool IsValidDir(string dir)
|
||||||
|
@ -347,7 +391,7 @@ namespace Rebuilder
|
||||||
private void ToggleAdvanced(object sender, EventArgs e)
|
private void ToggleAdvanced(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
advanced_grid.Visible = advanced_button.Checked;
|
advanced_grid.Visible = advanced_button.Checked;
|
||||||
CenterToScreen();
|
//CenterToScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ToggleOverrideResolution(Object sender, EventArgs e)
|
private void ToggleOverrideResolution(Object sender, EventArgs e)
|
||||||
|
@ -440,7 +484,7 @@ namespace Rebuilder
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Patch(temp_path);
|
if (!Patch(temp_path)) return;
|
||||||
|
|
||||||
// Set new EXE's compatibility mode to 256-colors
|
// Set new EXE's compatibility mode to 256-colors
|
||||||
using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers", true))
|
using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers", true))
|
||||||
|
@ -449,11 +493,11 @@ namespace Rebuilder
|
||||||
|
|
||||||
if (run_fullscreen.Checked)
|
if (run_fullscreen.Checked)
|
||||||
{
|
{
|
||||||
key.SetValue(temp_path + "\\ISLE.EXE", "DWM8And16BitMitigation");
|
key.SetValue(temp_path + "\\ISLE.EXE", "HIGHDPIAWARE DWM8And16BitMitigation");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
key.SetValue(temp_path + "\\ISLE.EXE", "DWM8And16BitMitigation 256COLOR");
|
key.SetValue(temp_path + "\\ISLE.EXE", "HIGHDPIAWARE DWM8And16BitMitigation 256COLOR");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue