From 5d5e6ea7f25eaa8ae27169a4943d8ea253fb38b7 Mon Sep 17 00:00:00 2001 From: AdAstra-LD <76622070+AdAstra-LD@users.noreply.github.com> Date: Tue, 2 Aug 2022 18:45:29 +0200 Subject: [PATCH] Fixed overworld table read for all languages [HGSS] --- DS_Map/RomInfo.cs | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/DS_Map/RomInfo.cs b/DS_Map/RomInfo.cs index b0bdaa8..cd7c886 100644 --- a/DS_Map/RomInfo.cs +++ b/DS_Map/RomInfo.cs @@ -502,14 +502,38 @@ namespace DSPRE { string ov1Path = DSUtils.GetOverlayPath(1); uint ov1Address = DSUtils.GetOverlayRAMAddress(1); - using (DSUtils.EasyReader bReader = new DSUtils.EasyReader(ov1Path, 0x1F92FC - (ov1Address - DSUtils.ARM9.address))) { // read the pointer at 0x021F92FC and adjust accordingly below - uint ramAddress = bReader.ReadUInt32(); - - if (ramAddress >= RomInfo.synthOverlayLoadAddress) { // if the pointer shows the table was moved to the synthetic overlay - OWTableOffset = ramAddress - RomInfo.synthOverlayLoadAddress; + int ramAddrOfPointer; + switch (gameLanguage) { + case gLangEnum.Italian: + ramAddrOfPointer = 0x021F929C; + break; + case gLangEnum.French: + case gLangEnum.Spanish: + ramAddrOfPointer = 0x021F931C; + break; + case gLangEnum.German: + ramAddrOfPointer = 0x021F92DC; + break; + case gLangEnum.Japanese: + ramAddrOfPointer = 0x021F86C4; + break; + default: + ramAddrOfPointer = 0x021F92FC; + break; + } + + using (DSUtils.EasyReader bReader = new DSUtils.EasyReader(ov1Path, ramAddrOfPointer - ov1Address)) { // read the pointer at the specified ram address and adjust accordingly below + uint ramAddressOfTable = bReader.ReadUInt32(); + if (ramAddressOfTable >= 0x03000000) { + MessageBox.Show("Something went wrong reading the Overworld configuration table.\nOverworld sprites in the Event Editor will be " + + "displayed incorrectly or not displayed at all.", "Decompression error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (ramAddressOfTable >= RomInfo.synthOverlayLoadAddress) { // if the pointer shows the table was moved to the synthetic overlay + OWTableOffset = ramAddressOfTable - RomInfo.synthOverlayLoadAddress; OWtablePath = gameDirs[DirNames.synthOverlay].unpackedDir + "\\" + ROMToolboxDialog.expandedARMfileID.ToString("D4"); } else { - OWTableOffset = ramAddress - ov1Address; + OWTableOffset = ramAddressOfTable - ov1Address; OWtablePath = ov1Path; } }