diff options
-rw-r--r-- | kamek_pal.x | 1 | ||||
-rw-r--r-- | src/tilesetfixer.cpp | 18 | ||||
-rw-r--r-- | tilesetfixer.yaml | 6 |
3 files changed, 16 insertions, 9 deletions
diff --git a/kamek_pal.x b/kamek_pal.x index 184eaef..a00b9e9 100644 --- a/kamek_pal.x +++ b/kamek_pal.x @@ -885,6 +885,7 @@ SECTIONS { BGDatClass = 0x8042A0D0; instance__10BGDatClass = 0x8042A0D0; GetTilesetName__FPvii = 0x800813F0; + OriginalTilesetLoadingThing = 0x80083560; getTilesetName__10BGDatClassFii = 0x800813F0; diff --git a/src/tilesetfixer.cpp b/src/tilesetfixer.cpp index 71bea9d..2fdb99e 100644 --- a/src/tilesetfixer.cpp +++ b/src/tilesetfixer.cpp @@ -3,14 +3,20 @@ const char *GetTilesetName(void *cls, int areaNum, int slotNum); -void DoFixes(int slotNumber); +void DoFixes(int areaNumber, int slotNumber); void SwapObjData(u8 *data, int slotNumber); +extern "C" void *OriginalTilesetLoadingThing(void *, void *, int, int); + // Main hook -void TilesetFixerHack() { - for (int i = 1; i < 4; i++) { - DoFixes(i); +void *TilesetFixerHack(void *cls, void *heap, int areaNum, int layerNum) { + if (layerNum == 0) { + for (int i = 1; i < 4; i++) { + DoFixes(areaNum, i); + } } + + return OriginalTilesetLoadingThing(cls, heap, areaNum, layerNum); } @@ -23,9 +29,9 @@ struct ObjLookupEntry { }; -void DoFixes(int slotNumber) { +void DoFixes(int areaNumber, int slotNumber) { // This is where it all starts - const char *tsName = GetTilesetName(BGDatClass, GetAreaNum(), slotNumber); + const char *tsName = GetTilesetName(BGDatClass, areaNumber, slotNumber); if (tsName == 0 || tsName[0] == 0) { return; diff --git a/tilesetfixer.yaml b/tilesetfixer.yaml index 409c443..e3850dd 100644 --- a/tilesetfixer.yaml +++ b/tilesetfixer.yaml @@ -3,7 +3,7 @@ source_files: [../src/tilesetfixer.cpp] hooks: - name: TilesetFixHack type: branch_insn - branch_type: b - src_addr_pal: 0x80081694 - target_func: 'TilesetFixerHack(void)' + branch_type: bl + src_addr_pal: 0x80081718 + target_func: 'TilesetFixerHack(void *, void *, int, int)' |