diff options
39 files changed, 8437 insertions, 8225 deletions
diff --git a/NewerProject.yaml b/NewerProject.yaml index c4bece4..b2f7718 100644 --- a/NewerProject.yaml +++ b/NewerProject.yaml @@ -1,25 +1,26 @@ ----
-output_dir: "NewerASM"
-code_address: 0x808D9000
-modules:
- - processed/prolog.yaml
- - processed/bugfixes.yaml
- - processed/worldmap.yaml
- - processed/levelnames.yaml
- - processed/animtiles.yaml
- - processed/spritetex.yaml
-# - processed/gakenoko.yaml
- - processed/poweruphax.yaml
-# - processed/heapbar.yaml
- - processed/tilegod.yaml
- - processed/linegod.yaml
- - processed/tilesetfixer.yaml
- - processed/switchblock.yaml
- - processed/eventblock.yaml
-# - processed/msgbox.yaml
-# - processed/replay.yaml
- - processed/growup.yaml
- - processed/levelspecial.yaml
- - processed/eventlooper.yaml
- - processed/spritespawner.yaml
- - processed/compression.yaml
+output_dir: "NewerASM" +code_address: 0x808D9000 +modules: + - processed/prolog.yaml + - processed/bugfixes.yaml + - processed/worldmap.yaml + - processed/levelnames.yaml + - processed/animtiles.yaml + - processed/spritetex.yaml +# - processed/gakenoko.yaml + - processed/poweruphax.yaml +# - processed/heapbar.yaml + - processed/tilegod.yaml + - processed/linegod.yaml + - processed/tilesetfixer.yaml + - processed/switchblock.yaml + - processed/eventblock.yaml +# - processed/msgbox.yaml +# - processed/replay.yaml + - processed/growup.yaml + - processed/levelspecial.yaml + - processed/eventlooper.yaml + - processed/spritespawner.yaml + - processed/spriteswapper.yaml + - processed/compression.yaml + - processed/crowdclapper.yaml diff --git a/crowdclapper.yaml b/crowdclapper.yaml new file mode 100644 index 0000000..b7adea4 --- /dev/null +++ b/crowdclapper.yaml @@ -0,0 +1,9 @@ +--- +source_files: [../src/crowdclapper.s] +hooks: + + - name: CrowdClapperEventActivate + type: branch_insn + branch_type: bl + src_addr_pal: 0x80872778 + target_func: 'CrowdClapperEventActivate' diff --git a/eventlooper.yaml b/eventlooper.yaml index b47d21d..f634307 100644 --- a/eventlooper.yaml +++ b/eventlooper.yaml @@ -1,15 +1,15 @@ ----
-# Replaces EN_HELPOS
-
-source_files: [../src/eventlooper.cpp]
-hooks:
- - name: eventlooper_Create
- type: add_func_pointer
- src_addr_pal: 0x80AEE18C
- target_func: 'EventLooper_Create(EventLooper *)'
-
- - name: eventlooper_Execute
- type: add_func_pointer
- src_addr_pal: 0x80AEE1A4
- target_func: 'EventLooper_Execute(EventLooper *)'
+--- +# Replaces EN_HELPOS + +source_files: [../src/eventlooper.cpp] +hooks: + - name: eventlooper_Create + type: add_func_pointer + src_addr_pal: 0x80AEE18C + target_func: 'EventLooper_Create(EventLooper *)' + + - name: eventlooper_Execute + type: add_func_pointer + src_addr_pal: 0x80AEE1A4 + target_func: 'EventLooper_Execute(EventLooper *)'
\ No newline at end of file diff --git a/growup.yaml b/growup.yaml index c7238ae..94790e1 100644 --- a/growup.yaml +++ b/growup.yaml @@ -1,82 +1,82 @@ ----
-source_files: [../src/growup.s]
-hooks:
+--- +source_files: [../src/growup.s] +hooks: # After Actor onCreate - - name: Global_Size
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x800951EC
- target_func: 'ModifyGlobalSizes'
+ - name: Global_Size + type: branch_insn + branch_type: bl + src_addr_pal: 0x800951EC + target_func: 'ModifyGlobalSizes' # Active Physics Init from Struct - - name: Global_Collisions
- type: branch_insn
- branch_type: b
- src_addr_pal: 0x8008C3E0
- target_func: 'ModifyCollision'
+ - name: Global_Collisions + type: branch_insn + branch_type: b + src_addr_pal: 0x8008C3E0 + target_func: 'ModifyCollision' # Update Object Positions Based on Speed Values -# - name: Global_Speed_Updates
-# type: branch_insn
-# branch_type: b
-# src_addr_pal: 0x8006CD00
-# target_func: 'ModifySpeedUpdates'
+# - name: Global_Speed_Updates +# type: branch_insn +# branch_type: b +# src_addr_pal: 0x8006CD00 +# target_func: 'ModifySpeedUpdates' - - name: Global_Speed_UpdatesA
- type: branch_insn
- branch_type: b
- src_addr_pal: 0x80065620
- target_func: 'ModifySpeedUpdatesA'
+ - name: Global_Speed_UpdatesA + type: branch_insn + branch_type: b + src_addr_pal: 0x80065620 + target_func: 'ModifySpeedUpdatesA' - - name: Global_Speed_UpdatesB
- type: branch_insn
- branch_type: b
- src_addr_pal: 0x80095730
- target_func: 'ModifySpeedUpdatesB'
+ - name: Global_Speed_UpdatesB + type: branch_insn + branch_type: b + src_addr_pal: 0x80095730 + target_func: 'ModifySpeedUpdatesB' # Loading Patches -# - name: Global_SizeLoader_X
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x800684B8
-# target_func: 'ModifyLoadSizeX'
+# - name: Global_SizeLoader_X +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x800684B8 +# target_func: 'ModifyLoadSizeX' # -# - name: Global_SizeLoader_Y
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x800684C0
-# target_func: 'ModifyLoadSizeY'
- - -# - name: Global_SizeLoader
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80068930
-# target_func: 'ModifyLoadSize'
+# - name: Global_SizeLoader_Y +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x800684C0 +# target_func: 'ModifyLoadSizeY' + + +# - name: Global_SizeLoader +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80068930 +# target_func: 'ModifyLoadSize' # -# - name: Global_SizeLoaderNull
-# type: patch
-# data: "600000006000000060000000600000006000000060000000600000006000000060000000600000006000000060000000600000006000000060000000600000006000000060000000600000006000000060000000600000006000000060000000600000006000000060000000600000006000000060000000"
-# addr_pal: 0x80068934
- -# - name: GlobalSizeA
-# type: patch
-# data: '38600001'
-# addr_pal: 0x80064540
+# - name: Global_SizeLoaderNull +# type: patch +# data: "600000006000000060000000600000006000000060000000600000006000000060000000600000006000000060000000600000006000000060000000600000006000000060000000600000006000000060000000600000006000000060000000600000006000000060000000600000006000000060000000" +# addr_pal: 0x80068934 + +# - name: GlobalSizeA +# type: patch +# data: '38600001' +# addr_pal: 0x80064540 # -# - name: GlobalSizeB
-# type: patch
-# data: '4E800020'
-# addr_pal: 0x80064544
+# - name: GlobalSizeB +# type: patch +# data: '4E800020' +# addr_pal: 0x80064544 @@ -84,58 +84,58 @@ hooks: # Stand On Top Special Collisions Inits # -# - name: Global_StandonTopA
-# type: branch_insn
-# branch_type: b
-# src_addr_pal: 0x800DB27C
-# target_func: 'ModifyStandOnTopInitA'
+# - name: Global_StandonTopA +# type: branch_insn +# branch_type: b +# src_addr_pal: 0x800DB27C +# target_func: 'ModifyStandOnTopInitA' # -# - name: Global_StandonTopB
-# type: branch_insn
-# branch_type: b
-# src_addr_pal: 0x800DB294
-# target_func: 'ModifyStandOnTopInitB'
+# - name: Global_StandonTopB +# type: branch_insn +# branch_type: b +# src_addr_pal: 0x800DB294 +# target_func: 'ModifyStandOnTopInitB' # -# - name: Global_StandonTopC
-# type: branch_insn
-# branch_type: b
-# src_addr_pal: 0x800DB30C
-# target_func: 'ModifyStandOnTopInitC'
+# - name: Global_StandonTopC +# type: branch_insn +# branch_type: b +# src_addr_pal: 0x800DB30C +# target_func: 'ModifyStandOnTopInitC' # -# - name: Global_StandonTopD
-# type: branch_insn
-# branch_type: b
-# src_addr_pal: 0x800DB32C
-# target_func: 'ModifyStandOnTopInitD'
+# - name: Global_StandonTopD +# type: branch_insn +# branch_type: b +# src_addr_pal: 0x800DB32C +# target_func: 'ModifyStandOnTopInitD' # Rideable Actor Inits - - name: Global_RiderA
- type: branch_insn
- branch_type: b
- src_addr_pal: 0x800DB690
+ - name: Global_RiderA + type: branch_insn + branch_type: b + src_addr_pal: 0x800DB690 target_func: 'ModifyRiderInitA' - - name: Global_RiderB
- type: branch_insn
- branch_type: b
- src_addr_pal: 0x800DB6B4
+ - name: Global_RiderB + type: branch_insn + branch_type: b + src_addr_pal: 0x800DB6B4 target_func: 'ModifyRiderInitB' - - name: Global_RiderC
- type: branch_insn
- branch_type: b
- src_addr_pal: 0x800DB6E8
- target_func: 'ModifyRiderInitC'
+ - name: Global_RiderC + type: branch_insn + branch_type: b + src_addr_pal: 0x800DB6E8 + target_func: 'ModifyRiderInitC' - - name: Global_RiderD
- type: branch_insn
- branch_type: b
- src_addr_pal: 0x800DB6FC
- target_func: 'ModifyRiderInitD'
+ - name: Global_RiderD + type: branch_insn + branch_type: b + src_addr_pal: 0x800DB6FC + target_func: 'ModifyRiderInitD' @@ -147,207 +147,207 @@ hooks: ## Below are enemy specific hacks to fix issues that arise when resizing - - name: FixingPipeSpawnerGoomba
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80ABB6A8
+ - name: FixingPipeSpawnerGoomba + type: branch_insn + branch_type: bl + src_addr_pal: 0x80ABB6A8 target_func: 'InheritSettings_C' - - name: FixingPipeSpawnerGoombaB
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80ABB6D0
+ - name: FixingPipeSpawnerGoombaB + type: branch_insn + branch_type: bl + src_addr_pal: 0x80ABB6D0 target_func: 'InheritSettings_D' - - name: FixingPipeSpawnerBobomb
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80ABB758
+ - name: FixingPipeSpawnerBobomb + type: branch_insn + branch_type: bl + src_addr_pal: 0x80ABB758 target_func: 'InheritSettings_B' -
+ -# - name: FixingBlockHit
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x800883A4
+# - name: FixingBlockHit +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x800883A4 # target_func: 'InheritSettings_B' # # -# - name: FixingBlockHitB
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80088938
+# - name: FixingBlockHitB +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80088938 # target_func: 'InheritSettings_C' - - name: FixingMegaGoombaAA
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A5AAA8
+ - name: FixingMegaGoombaAA + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A5AAA8 target_func: 'InheritSettings' - - name: FixingMegaGoombaAB
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A5AAC4
+ - name: FixingMegaGoombaAB + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A5AAC4 target_func: 'InheritSettings' - - name: FixingMegaGoombaBA
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A5AB44
+ - name: FixingMegaGoombaBA + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A5AB44 target_func: 'InheritSettings' - - name: FixingMegaGoombaBB
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A5AB80
+ - name: FixingMegaGoombaBB + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A5AB80 target_func: 'InheritSettings' - - name: FixingMegaGoombaBC
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A5AB9C
+ - name: FixingMegaGoombaBC + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A5AB9C target_func: 'InheritSettings' - - name: FixingMegaGoombaBD
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A5ABB8
+ - name: FixingMegaGoombaBD + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A5ABB8 target_func: 'InheritSettings' - - name: FixingLargeGoombaAA
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A6A208
+ - name: FixingLargeGoombaAA + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A6A208 target_func: 'InheritSettings' - - name: FixingLargeGoombaAB
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A6A22C
+ - name: FixingLargeGoombaAB + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A6A22C target_func: 'InheritSettings' - - name: FixingLargeGoombaBA
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A6A2A8
+ - name: FixingLargeGoombaBA + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A6A2A8 target_func: 'InheritSettings' - - name: FixingLargeGoombaBB
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A6A2CC
+ - name: FixingLargeGoombaBB + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A6A2CC target_func: 'InheritSettings' - - name: Piranha_Collisions
- type: patch
- data: "41C00000"
- addr_pal: 0x802EE81C
+ - name: Piranha_Collisions + type: patch + data: "41C00000" + addr_pal: 0x802EE81C - - name: GlobalZOrderDeath
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x800980A4
+ - name: GlobalZOrderDeath + type: branch_insn + branch_type: bl + src_addr_pal: 0x800980A4 target_func: 'GlobalZOrderDeath' - - name: PokeyZOrderDeath
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A9ED2C
+ - name: PokeyZOrderDeath + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A9ED2C target_func: 'PokeyZOrderDeath' - - name: PokeyZOrderDeathFreeze
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A9EE58
+ - name: PokeyZOrderDeathFreeze + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A9EE58 target_func: 'PokeyZOrderDeathFreeze' - - name: PokeyZOrderDamage
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x800A18E8
+ - name: PokeyZOrderDamage + type: branch_insn + branch_type: bl + src_addr_pal: 0x800A18E8 target_func: 'PokeyZOrderDamage' - - name: GabonRockZOrderDeath
- type: branch_insn
- branch_type: b
- src_addr_pal: 0x807FAAAC
+ - name: GabonRockZOrderDeath + type: branch_insn + branch_type: b + src_addr_pal: 0x807FAAAC target_func: 'GabonRockZOrderDeath' - - name: GabonRockZOrderDeathDrop
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x807FA9C0
+ - name: GabonRockZOrderDeathDrop + type: branch_insn + branch_type: bl + src_addr_pal: 0x807FA9C0 target_func: 'GabonRockZOrderDeathDrop' # -# - name: Projectile_Lakitu
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80AB7A28
+# - name: Projectile_Lakitu +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80AB7A28 # target_func: 'LakituBomb' # # -# - name: Projectile_LakituTwo
-# type: patch
-# data: "6000000060000000"
-# addr_pal: 0x80A37BF4
+# - name: Projectile_LakituTwo +# type: patch +# data: "6000000060000000" +# addr_pal: 0x80A37BF4 # -# - name: Projectile_LakituThree
-# type: patch
-# data: "60000000"
-# addr_pal: 0x80A37CDC
+# - name: Projectile_LakituThree +# type: patch +# data: "60000000" +# addr_pal: 0x80A37CDC # -# - name: Projectile_LakituFour
-# type: patch
-# data: "60000000"
-# addr_pal: 0x80A37D00
+# - name: Projectile_LakituFour +# type: patch +# data: "60000000" +# addr_pal: 0x80A37D00 # -# - name: Projectile_LakituFive
-# type: patch
-# data: "60000000"
-# addr_pal: 0x80A37B0C
+# - name: Projectile_LakituFive +# type: patch +# data: "60000000" +# addr_pal: 0x80A37B0C # -# - name: Projectile_Pirahna
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80029640
-# target_func: 'PiranhaFireType'
+# - name: Projectile_Pirahna +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80029640 +# target_func: 'PiranhaFireType' # -# - name: Projectile_PiranhaPos
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x8002964C
-# target_func: 'PiranhaFirePos'
+# - name: Projectile_PiranhaPos +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x8002964C +# target_func: 'PiranhaFirePos' # -# - name: Projectile_PirahnaB
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80A33300
-# target_func: 'PiranhaFireType'
- - -# - name: PipeGenerator
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80ABB76C
-# target_func: 'PipeGeneratorSpawn'
+# - name: Projectile_PirahnaB +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80A33300 +# target_func: 'PiranhaFireType' + + +# - name: PipeGenerator +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80ABB76C +# target_func: 'PipeGeneratorSpawn' # 809EA268 - Broozer physics struct diff --git a/include/game.h b/include/game.h index 81f4e69..8bc0dc2 100644 --- a/include/game.h +++ b/include/game.h @@ -1,2038 +1,2038 @@ -#ifndef __KAMEK_GAME_H
-#define __KAMEK_GAME_H
-
-//#define offsetof(type, member) ((__std(size_t)) &(((type *) 0)->member))
-
-#include <common.h>
-#include <rvl/mtx.h>
-#include <rvl/GXEnum.h>
-#include <rvl/vifuncs.h>
-#include <rvl/arc.h>
-#define offsetof(type, member) ((u32) &(((type *) 0)->member))
-
-
-extern "C" {
-int strlen(const char *str);
-
-float atan(float x);
-float atan2(float y, float x);
-
-float cos(float x);
-float sin(float x);
-}
-
-bool DVD_Start();
-bool DVD_End();
-bool DVD_StillLoading(void *dvdclass2);
-void DVD_LoadFile(void *dvdclass, char *folder, char *file, void *callbackData);
-void DVD_FreeFile(void *dvdclass2, char *file);
-
-extern void *DVDClass;
-
-inline void *GetDVDClass() {
- return DVDClass;
-}
-
-inline void *GetDVDClass2() {
- return (void*)(((u32)GetDVDClass())+4);
-}
-
-void *DVD_GetFile(void *dvdclass2, const char *arc, const char *file);
-void *DVD_GetFile(void *dvdclass2, const char *arc, const char *file, u32 *length);
-
-
-extern int Player_Active[4];
-extern int Player_ID[4];
-extern int Player_Powerup[4];
-extern int Player_Flags[4];
-extern int Player_Lives[4];
-extern int Player_Coins[4];
-
-struct StartLevelInfo {
- int maybeUnused;
- unsigned char unk1; // 0x04
- unsigned char unk2; // 0x05
- unsigned char unk3; // 0x06
- unsigned char unk4; // 0x07
- unsigned int purpose; // 0x08
- unsigned char world1; // 0x0C
- unsigned char level1; // 0x0D
- unsigned char world2; // 0x0E
- unsigned char level2; // 0x0F
-};
-
-extern void *GameMgr;
-inline void *GetGameMgr() {
- return GameMgr;
-}
-
-bool QueryPlayerAvailability(int id);
-void DoStartLevel(void *gameMgr, StartLevelInfo *sl);
-void SetSomeConditionShit(int world, int level, unsigned int bits);
-
-bool IsWideScreen();
-
-#define GAMEMGR_GET_AFC(gmgr) (*((bool*)(((u32)(gmgr))+0xAFC)))
-
-
-#define COND_COIN1 1
-#define COND_COIN2 2
-#define COND_COIN3 4
-#define COND_NORMAL 0x10
-#define COND_SECRET 0x20
-#define COND_SGNORMAL 0x80
-#define COND_SGSECRET 0x100
-
-class SaveFirstBlock {
-public:
- char titleID[4]; // 0x00
- u8 field_00; // 0x04
- u8 field_01; // 0x05
- u8 current_file; // 0x06
- u8 field_03; // 0x07
- u16 freemode_fav[10][0x2A]; // 0x08
- u16 coinbtl_fav[10][0x2A]; // 0x350
- u16 bitfield; // 0x698
- u16 field_69A; // 0x69A
- u32 checksum; // 0x69C
-};
-
-class SaveBlock {
-public:
- u8 field_00; // 0x00
- u8 field_01; // 0x01
- u8 bitfield; // 0x02
- u8 current_world; // 0x03
- u8 field_04; // 0x04
- u8 current_path_node; // 0x05
- u8 field_06; // 0x06
- u8 switch_on; // 0x07
- u8 field_08; // 0x08
- u8 powerups_available[7]; // 0x09
- u8 toad_level_idx[10]; // 0x10
- u8 player_continues[4]; // 0x1A
- u8 player_coins[4]; // 0x1E
- u8 player_lives[4]; // 0x22
- u8 player_flags[4]; // 0x26
- u8 player_type[4]; // 0x2A
- u8 player_powerup[4]; // 0x2E
- u8 worlds_available[10]; // 0x32
- u32 ambush_countdown[10]; // 0x3C
- u16 field_64; // 0x64
- u16 credits_hiscore; // 0x66
- u16 score; // 0x68
- u32 completions[10][0x2A]; // 0x6C
- u8 hint_movie_bought[70]; // 0x6FC
- u8 toad_location[10]; // 0x742
- u8 field_74C[10][4]; // 0x74C
- u8 field_774[10][4]; // 0x774
- u8 field_79C[10][4]; // 0x79C
- u8 death_counts[10][0x2A]; // 0x7C4
- u8 death_count_3_4_switch; // 0x968
- u8 pad[0x13]; // 0x969
- u32 checksum; // 0x97C
-
- u32 GetLevelCondition(int world, int level);
- bool CheckLevelCondition(int world, int level, int cond);
- bool CheckIfCoinCollected(int world, int level, int num);
-};
-
-class SaveFile {
-public:
- u32 field_00;
- u32 field_04;
- u32 field_08;
- u32 field_0C;
- u32 field_10;
- u32 field_14;
- u32 field_18;
- u32 field_1C;
-
- // Real Savefile starts here
- SaveFirstBlock header;
- SaveBlock blocks[3];
- SaveBlock quickSave[3];
-
- SaveBlock *GetBlock(int id);
- SaveBlock *GetQSBlock(int id);
-
- bool CheckIfWriting(); // 0x800E0540
-};
-
-class SaveHandler {
-public:
- u8 unknown[0x70];
- u32 CurrentState;
- u32 CurrentError;
- u32 field_7C;
-};
-
-extern SaveFile *SaveFileInstance;
-extern SaveHandler *SaveHandlerInstance;
-
-inline SaveFile *GetSaveFile() {
- return SaveFileInstance;
-}
-
-inline SaveHandler *GetSaveHandler() {
- return SaveHandlerInstance;
-}
-
-#define WPAD_DOWN 0x0001 // Actually Left, but rotated
-#define WPAD_UP 0x0002 // Actually Right, but rotated
-#define WPAD_RIGHT 0x0004 // Actually Down, but rotated
-#define WPAD_LEFT 0x0008 // Actually Up, but rotated
-#define WPAD_PLUS 0x0010
-#define WPAD_TWO 0x0100
-#define WPAD_ONE 0x0200
-#define WPAD_B 0x0400
-#define WPAD_A 0x0800
-#define WPAD_MINUS 0x1000
-#define WPAD_HOME 0x8000
-
-struct RemoconMngClass {
- void *vtable;
- void *controllers[4];
-};
-
-/*
- * Ok, here's how the remocon/wiimote shit works:
- * Remocon is a NSMB-specific class, it handles the different control methods
- * and D-pad directions and such automatically.
- *
- * Wiimote is a generic class (part of EGG) -- well it's not actually called
- * that, but who cares. It handles different types of controllers. Only
- * query it if whatever you're accessing is control type dependent.
- */
-
-extern RemoconMngClass *RemoconMng;
-extern int ActiveWiimoteID;
-extern void *ActiveWiimote;
-
-inline RemoconMngClass *GetRemoconMng() {
- return RemoconMng;
-}
-
-inline int GetActiveWiimoteID() {
- return ActiveWiimoteID;
-}
-
-inline void *GetActiveRemocon() {
- return GetRemoconMng()->controllers[GetActiveWiimoteID()];
-}
-
-inline void *GetActiveWiimote() {
- return ActiveWiimote;
-}
-
-inline unsigned int Remocon_GetButtons(void *self) {
- return *((unsigned int*)((u32)self+0x18));
-}
-
-inline unsigned int Remocon_GetPressed(void *self) {
- return *((unsigned int*)((u32)self+0x1C));
-}
-
-typedef bool (*__Wiimote_TestButtons_type)(void*, unsigned int);
-inline bool Wiimote_TestButtons(void *self, unsigned int btns) {
- VF_BEGIN(__Wiimote_TestButtons_type, self, 8, 0)
- return VF_CALL(self, btns);
- VF_END;
-}
-
-int SearchForIndexOfPlayerID(int id);
-
-bool CheckIfContinueShouldBeActivated();
-
-bool CheckIfMenuShouldBeCancelledForSpecifiedWiimote(int num);
-
-void StartTitleScreenStage(bool realDemo, int sceneParam);
-
-bool CheckIfWeCantDoStuff();
-
-u32 QueryGlobal5758(u32 check);
-
-void SaveGame(void *classDoesntMatter, bool isQuick);
-
-#include <actors.h>
-void *CreateParentedObject(short classID, void *parent, int settings, char something);
-void *CreateChildObject(short classID, void *parent, int settings, int unk1, int unk2);
-
-
-#define WIPE_FADE 0
-#define WIPE_CIRCLE 1
-#define WIPE_BOWSER 2
-#define WIPE_WAVY 3
-#define WIPE_MARIO 4
-#define WIPE_CIRCLE_s 5
-
-void ActivateWipe(int type);
-
-typedef void (*ScreenDrawFunc)();
-
-extern ScreenDrawFunc *CurrentDrawFunc;
-void WorldMapDrawFunc();
-void GameSetupDrawFunc();
-
-void GameSetup__LoadScene(void *self); // 0x80919560
-void FreeScene(int id);
-
-void WpadShit(int unk); // 0x8016F780
-
-void *BgTexMng__LoadAnimTile(void *self, int tileset, short tile, char *name, char *delays, char reverse); // 0x80087B60
-
-extern void *GameHeaps[];
-
-
-class dFlagMgr_c {
-public:
- dFlagMgr_c();
-
- enum ActionFlag {
- ACTIVATE = 1,
- TICKS = 2
- };
-
- u64 flags;
- float _8[64], _108[64];
- u8 _208[64];
- u64 _248[64];
- u8 _448[64];
-
- u32 ticksRemainingForAction[64];
- u8 actionFlag[64];
- u32 _5C8[64]; // somehow sound related?! assigned by last param to set(); only checked for == 0
- u8 _6C8; // assigned -1 by FlagMgr, and other values by the Switch object, nothing else though
-
- void setup(bool isNewLevel);
- void applyAndClearAllTimedActions(); // only used when setup(true) is called
- void execute();
-
- void set(u8 number, int delay, bool activate, bool reverseEffect, bool makeNoise, u32 unknown=0);
-
- u8 findLowestFlagInSet(u32 unk, u64 set);
-
- void setSpecial(u8 number, float to8, float to108, u8 to208, u32 unk, u64 to248);
- float get8(u8 number);
- float get108(u8 number);
- u8 get208(u8 number);
- u64 get248(u8 number);
- u8 get448(u8 number);
-
- // convenience inline functions which may or may not actually exist in Nintendo's original code
- u64 mask(u8 number) { return (u64)1 << number; }
- bool active(u8 number) { return (flags & mask(number)) != 0; }
- bool inactive(u8 number) { return (flags & mask(number)) == 0; }
-
- static dFlagMgr_c *instance;
-};
-
-
-namespace nw4r {
-
-namespace ut {
- // this isn't 100% accurate because it doesn't use templates
- // or detail::LinkListImpl, but oh well
- // I don't need the methods anyway.
-
- class LinkListNode {
- public:
- LinkListNode *next;
- LinkListNode *prev;
- };
-
- class LinkList {
- public:
- int count;
- LinkListNode initialNode;
- };
-
- class Color : public GXColor { };
-
- class Rect {
- public:
- f32 left;
- f32 top;
- f32 right;
- f32 bottom;
- };
-
- template <class T>
- class TagProcessorBase { };
-}
-
-namespace lyt {
- class Pane; // forward declaration
- class DrawInfo;
-
- class AnimTransform; // I'll do these later
- class AnimResource;
- class AnimationLink;
- class ResourceAccessor;
- class GroupContainer;
-
- class Layout {
- public:
- Layout();
- virtual ~Layout();
-
- virtual bool Build(const void *data, ResourceAccessor *resAcc);
-
- virtual AnimTransform *CreateAnimTransform();
- virtual AnimTransform *CreateAnimTransform(const void *data, ResourceAccessor *resAcc);
- virtual AnimTransform *CreateAnimTransform(const AnimResource &res, ResourceAccessor *resAcc);
-
- virtual void BindAnimation(AnimTransform *anim);
- virtual void UnbindAnimation(AnimTransform *anim);
- virtual void UnbindAllAnimation();
- virtual bool BindAnimationAuto(const AnimResource &res, ResourceAccessor *resAcc);
-
- virtual void SetAnimationEnable(AnimTransform *anim, bool unk);
-
- virtual void CalculateMtx(const DrawInfo &info);
-
- virtual void/*?*/ Draw(const DrawInfo &info);
- virtual void/*?*/ Animate(ulong flag);
-
- virtual void/*?*/ SetTagProcessor(ut::TagProcessorBase<wchar_t> *tagProc);
-
- ut::LinkList animations;
-
- Pane *rootPane;
- GroupContainer *groupContainer;
-
- float width;
- float height;
- };
-
-
- class DrawInfo {
- public:
- DrawInfo();
- virtual ~DrawInfo();
-
- Mtx matrix;
- float left;
- float top;
- float right;
- float bottom;
- float scaleX;
- float scaleY;
- float alpha;
- u8 _50; // this is actually a bitfield. todo: investigate how CW handles bitfields, and so on
- };
-
-
- class Material {
- public:
- // ...
- };
-
- class Pane {
- public:
- //Pane(nw4r::lyt::res::Pane const *); // todo: this struct
- Pane(void *);
- virtual ~Pane();
-
- virtual void *GetRuntimeTypeInfo() const;
- virtual void CalculateMtx(const DrawInfo &info);
-
- virtual void Draw(const DrawInfo &info);
- virtual void DrawSelf(const DrawInfo &info);
- virtual void Animate(ulong flag);
- virtual void AnimateSelf(ulong flag);
-
- virtual ut::Color GetVtxColor(ulong id) const;
- virtual void SetVtxColor(ulong id, ut::Color color);
- virtual uchar GetColorElement(ulong id) const;
- virtual void SetColorElement(ulong id, uchar value);
- virtual uchar GetVtxColorElement(ulong id) const;
- virtual void SetVtxColorElement(ulong id, uchar value);
-
- virtual Pane *FindPaneByName(const char *name, bool recursive);
- virtual Material *FindMaterialByName(const char *name, bool recursive);
-
- virtual void/*?*/ BindAnimation(AnimTransform *anim, bool unk1, bool unk2);
- virtual void UnbindAnimation(AnimTransform *anim, bool unk);
- virtual void UnbindAllAnimation(bool unk);
- virtual void UnbindAnimationSelf(AnimTransform *anim);
-
- virtual ut::LinkListNode *FindAnimationLinkSelf(AnimTransform *anim);
- virtual ut::LinkListNode *FindAnimationLinkSelf(const AnimResource &anim);
-
- virtual void SetAnimationEnable(AnimTransform *anim, bool unk1, bool unk2);
- virtual void SetAnimationEnable(const AnimResource &anim, bool unk1, bool unk2);
-
- virtual ulong GetMaterialNum() const;
- virtual Material *GetMaterial() const;
- virtual Material *GetMaterial(ulong id) const;
-
- virtual void LoadMtx(const DrawInfo &info);
-
- void AppendChild(Pane *child);
-
- ut::Rect GetPaneRect(const DrawInfo &info) const;
-
- ut::LinkListNode *AddAnimationLink(AnimationLink *link);
-
- Vec2 GetVtxPos() const;
-
-
- ut::LinkListNode parentLink;
- Pane *parent;
-
- ut::LinkList children;
- ut::LinkList animations;
-
- Material *material;
-
- Vec trans;
- Vec rotate;
- Vec2 scale;
- Vec2 size;
-
- Mtx calcMtx;
- Mtx effectiveMtx;
-
- float _B4;
-
- u8 alpha;
- u8 effectiveAlpha;
- u8 origin;
- u8 flag;
-
- char name[0x11];
- char userdata[8];
-
- u8 _D5;
- u8 paneIsOwnedBySomeoneElse;
- u8 _D7;
- };
-
- class TextBox : public Pane {
- public:
- TextBox(void *, void *); // todo: TextBox((res::TextBox const *,ResBlockSet const &))
- ~TextBox();
-
- void *GetRuntimeTypeInfo() const;
-
- void DrawSelf(const DrawInfo &info);
-
- ut::Color GetVtxColor(ulong id) const;
- void SetVtxColor(ulong id, ut::Color color);
- uchar GetVtxColorElement(ulong id) const;
- void SetVtxColorElement(ulong id, uchar value);
-
- virtual void LoadMtx(const DrawInfo &info);
-
- virtual void AllocStringBuffer(u16 size);
- virtual void FreeStringBuffer();
-
- virtual u16 SetString(const wchar_t *str, u16 destOffset = 0);
- virtual u16 SetString(const wchar_t *str, u16 destOffset, u16 length);
-
- wchar_t *stringBuf;
-
- ut::Color colour1, colour2;
- void *font; // actually a ut::ResFont or whatever
-
- float fontSizeX, fontSizeY;
- float lineSpace, charSpace;
-
- void *tagProc; // actually a TagProcessor
-
- u16 bufferLength;
- u16 stringLength;
-
- u8 alignment;
- u8 flags;
- };
-}
-
-
-
-namespace g3d {
-struct CameraData
-{
-enum Flag
- {
-FLAG_CAMERA_LOOKAT = 0x00000001,
-FLAG_CAMERA_ROTATE = 0x00000002,
-FLAG_CAMERA_AIM = 0x00000004,
-MASK_CAMERA = 0x00000007,
-
-FLAG_CMTX_VALID = 0x00000008,
-
-FLAG_PROJ_FLUSTUM = 0x00000010,
-FLAG_PROJ_PERSP = 0x00000020,
-FLAG_PROJ_ORTHO = 0x00000040,
-MASK_PROJ = 0x00000070,
-
-FLAG_PMTX_VALID = 0x00000080,
-
-FLAG_VIEWPORT_JITTER_ABOVE = 0x00000100
- };
-
-Mtx cameraMtx;
-Mtx44 projMtx;
-
-u32 flags;
-
-VEC3 cameraPos;
-VEC3 cameraUp;
-VEC3 cameraTarget;
-VEC3 cameraRotate;
-f32 cameraTwist;
-
-GXProjectionType projType;
-f32 projFovy;
-f32 projAspect;
-f32 projNear;
-f32 projFar;
-f32 projTop;
-f32 projBottom;
-f32 projLeft;
-f32 projRight;
-
-f32 lightScaleS;
-f32 lightScaleT;
-f32 lightTransS;
-f32 lightTransT;
-
-VEC2 viewportOrigin;
-VEC2 viewportSize;
-f32 viewportNear;
-f32 viewportFar;
-
-u32 scissorX;
-u32 scissorY;
-u32 scissorWidth;
-u32 scissorHeight;
-
-s32 scissorOffsetX;
-s32 scissorOffsetY;
-};
-
-/* Correct camera
-cameraMtx:
-1.0 0.0 0.0 -0.0
-0.0 1.0 0.0 -0.0
-0.0 0.0 1.0 -6000.0
-
-projMtx:
-0.002345 0.000000 0.000000 -1.000000
-0.000000 0.004386 0.000000 -1.000000
-0.000000 0.000000 -0.000005 -0.500000
-0.000000 0.000000 0.000000 1.000000
-
-flags: 000000C9 : FLAG_CAMERA_LOOKAT | FLAG_CMTX_VALID | FLAG_PROJ_ORTHO | FLAG_PMTX_VALID
-
-cameraPos: {0, 0, 15}
-cameraUp: {0, 1, 0}
-cameraTarget: {0, 0, 0}
-cameraRotate: {0, 0, 0}
-cameraTwist: 0
-
-projType: 1
-projFovy: 60
-projAspect: 1.333333
-projNear: -100000
-projFar: 100000
-projTop: 456
-projBottom: 0
-projLeft: 0
-projRight: 853
-
-lightScaleS: 0.5
-lightScaleT: 0.5
-lightTransS: 0.5
-lightTransT: 0.5
-
-viewportOrigin: {0,0}
-viewportSize: {640,456}
-viewportNear: 0
-viewportFar: 1
-
-scissorX: 0
-scissorY: 0
-scissorWidth: 0x280
-scissorHeight: 0x1C8
-
-scissorOffsetX: 0
-scissorOffsetY: 0
-*/
-
-class Camera {
-public:
- enum PostureType { POSTURE_LOOKAT, POSTURE_ROTATE, POSTURE_AIM };
- struct PostureInfo
- {
- PostureType tp;
- VEC3 cameraUp;
- VEC3 cameraTarget;
- VEC3 cameraRotate;
- f32 cameraTwist;
- };
-private:
- CameraData *data;
-public:
- Camera(CameraData *pCamera);
- void Init();
- void Init(u16 efbWidth, u16 efbHeight, u16 xfbWidth, u16 xfbHeight, u16 viWidth, u16 viHeight);
- //void SetPosition(f32 x, f32 y, f32 z);
- void SetPosition(const VEC3 &pos);
- //void GetPosition(f32 *px, f32 *py, f32 *pz) const;
- void GetPosition(VEC3 *pPos) const;
- void SetPosture(const PostureInfo &info);
- //void GetPosture(PostureInfo *info) const;
- void SetCameraMtxDirectly(const Mtx &mtx);
- void GetCameraMtx(Mtx *pMtx) const;
- void SetOrtho(f32 top, f32 bottom, f32 left, f32 right, f32 near, f32 far);
- //void SetFrustum(f32 top, f32 bottom, f32 left, f32 right, f32 near, f32 far);
- void SetPerspective(f32 fovy, f32 aspect, f32 near, f32 far);
- void SetProjectionMtxDirectly(const Mtx44 *pMtx);
- void GetProjectionMtx(Mtx44 *pMtx) const;
- //GXProjectionType GetProjectionType() const;
- void SetScissor(u32 xOrigin, u32 yOrigin, u32 width, u32 height);
- void SetScissorBoxOffset(s32 xOffset, s32 yOffset);
- //void GetScissor(u32 *xOrigin, u32 *yOrigin, u32 *width, u32 *height);
- void SetViewport(f32 xOrigin, f32 yOrigin, f32 width, f32 height);
- //void SetViewport(f32 xOrigin, f32 yOrigin, f32 width, f32 height, f32 near, f32 far);
- void SetViewportZRange(f32 near, f32 far);
- void SetViewportJitter(u32 field);
- //void SetViewportJitter(f32 xOrigin, f32 yOrigin, f32 width, f32 height, f32 near, f32 far, u32 field);
- void GetViewport(f32 *xOrigin, f32 *yOrigin, f32 *width, f32 *height, f32 *near, f32 *far) const;
- void GXSetViewport() const;
- void GXSetProjection() const;
- void GXSetScissor() const;
- void GXSetScissorBoxOffset() const;
-};
-
-namespace G3DState {
- GXRenderModeObj *GetRenderModeObj();
-}
-}
-}
-
-
-nw4r::g3d::CameraData *GetCameraByID(int id);
-
-int GetCurrentCameraID(); // 80164C80
-void SetCurrentCameraID(int id); // 80164C90
-
-void LinkScene(int id); // 80164D50
-void UnlinkScene(int id); // 80164CD0
-
-void SceneCalcWorld(int sceneID); // 80164E10
-void SceneCameraStuff(int sceneID); // 80164EA0
-
-void CalcMaterial(); // 80164E90
-void DrawOpa(); // 80164F70
-void DrawXlu(); // 80164F80
-
-bool ChangeAlphaUpdate(bool enable); // 802D3270
-
-void DoSpecialDrawing1(); // 8006CAE0
-void DoSpecialDrawing2(); // 8006CB40
-
-void SetupLYTDrawing(); // 80163360
-void ClearLayoutDrawList(); // 801632B0
-
-void DrawAllLayoutsBeforeX(int x); // 80163440
-void DrawAllLayoutsAfterX(int x); // 801634D0
-void DrawAllLayoutsAfterXandBeforeY(int x, int y); // 80163560
-
-void RenderEffects(int v1, int v2); // 80093F10
-
-void RemoveAllFromScnRoot(); // 80164FB0
-void Reset3DState(); // 80165000
-
-extern "C" void GXDrawDone(); // 801C4FE0
-
-
-
-namespace m2d {
- class Base_c /*: public nw4r::ut::Link what's this? */ {
- public:
- u32 _00;
- u32 _04;
-
- Base_c();
- virtual ~Base_c();
- virtual void draw(); // don't call this directly
-
- void scheduleForDrawing();
-
- u8 drawOrder;
- };
-
- class Simple_c : public Base_c {
- public:
- nw4r::lyt::Layout layout;
- nw4r::lyt::DrawInfo drawInfo;
-
- u32 _84;
- float _88;
- float _8C;
- float _90;
- u32 _94;
-
- Simple_c();
- ~Simple_c();
-
- void draw();
- virtual void _vf10();
- virtual void _vf14();
- };
-}
-
-
-
-namespace EGG {
- class Frustum {
- public:
- GXProjectionType projType;
- int isCentered;
- float width;
- float height;
- float fovy;
- float dunno;
- float near;
- float far;
- float center_x_maybe;
- float center_y_maybe;
- float x_direction;
- float unk2;
- float unk3;
- short some_flag_bit;
-
-
- // isCentered might actually be isNotCentered, dunno
- Frustum(GXProjectionType projType, Vec2 size, bool isCentered, float near, float far); // 802C6D20
- Frustum(Frustum &f); // 802C6D90
- virtual ~Frustum(); // 802C75F0
-
- virtual void loadDirectly(); // 802C7050
- virtual void loadIntoCamera(nw4r::g3d::Camera cam); // 802C7070
-
- void setOrtho(float top, float bottom, float left, float right, float near, float far); // 802C6DD0
-
- void setFovy(float newFovy); // 802C6F60
-
- void getCenterPointsBasedOnPos(float x, float y, float *destX, float *destY); // 802C6FD0
-
- // no idea what this does
- float getSomethingForPerspective(float blah); // 802C7020
-
-
- protected:
- // not all of these might be protected, dunno
-
- void copyAllFields(Frustum &f); // 802C6EE0
-
- void saveSomething(float f1, float f2, float f3, float f4); // 802C70C0
- void loadSomething(float *f1, float *f2, float *f3, float *f4); // 802C70E0
-
- void loadPerspective(); // 802C7110
- void loadOrtho(); // 802C7140
-
- void setCameraPerspective(nw4r::g3d::Camera cam); // 802C7170
- void setCameraOrtho(nw4r::g3d::Camera cam); // 802C71E0
-
- void getPerspectiveProjMtx(Mtx44 *mtx); // 802C7250
- void getPerspectiveProjv(float *ptr); // 802C72E0
- void getOrthoProjv(float *ptr); // 802C73A0
-
- void getOrthoVars(float *top, float *bottom, float *left, float *right); // 802C7480
- };
-}
-
-
-class TileRenderer {
-public:
- TileRenderer();
- ~TileRenderer();
-
- TileRenderer *list1, *list2;
- u16 tileNumber;
- u8 unkFlag, someBool;
- float x, y, z;
- float scale;
- s16 rotation;
- u8 unkByte;
-
- u16 getTileNum();
- bool getSomeBool();
- void setSomeBool(u8 value);
-
- float getX();
- float getY();
- float getZ();
- void setPosition(float x, float y);
- void setPosition(float x, float y, float z);
-
- u8 getUnkFlag();
-
- void setVars(float scale); // sets unkFlag=1, rotation=0, unkByte=0
- void setVars(float scale, s16 rotation); // sets unkFlag=2, unkByte=0
-
- float getScale();
- float getRotationFloat();
- s16 getRotation();
-
- u8 getUnkByte();
-
- class List {
- public:
- u32 count;
- TileRenderer *first, *last; // order?
-
- void add(TileRenderer *r);
- void remove(TileRenderer *r);
- void removeAll();
-
- List();
- ~List();
- };
-};
-
-class dActor_c; // forward declaration
-
-class Physics {
-public:
- struct Unknown {
- Unknown();
- ~Unknown();
-
- float x, y;
- };
-
- struct Info {
- float x1, y1, x2, y2; // Might be distance to center/edge like APhysics
- void *otherCallback1, *otherCallback2, *otherCallback3;
- };
-
- Physics();
- ~Physics();
-
- dActor_c *owner;
- Physics *next, *prev;
- u32 _C, _10, _14, _18, _1C, _20, _24, _28, _2C, _30, _34, _38, _3C;
- void *otherCallback1, *otherCallback2, *otherCallback3;
- void *callback1, *callback2, *callback3;
- float lastX, lastY;
- Unknown unkArray[4];
- float x, y;
- float _88, _8C, _90;
- Vec lastActorPosition;
- float _A0, _A4, last_A0, last_A4, _B0, _B4;
- u32 _B8;
- s16 *ptrToRotationShort;
- s16 currentRotation;
- s16 rotDiff;
- s16 rotDiffAlt;
- u32 isRound;
- u32 _CC;
- u32 flagsMaybe;
- u32 _D4, _D8;
- u8 isAddedToList, _DD, layer;
- u32 id;
-
- void addToList();
- void removeFromList();
-
- void baseSetup(dActor_c *actor, u32 t_40, u32 t_44, u32 t_48, u8 t_DD, u8 layer);
-
- // note: Scale can be a null pointer (in that case, it'll use 1.0)
- void setup(dActor_c *actor,
- float x1, float y1, float x2, float y2,
- void *otherCB1, void *otherCB2, void *otherCB3,
- u8 t_DD, u8 layer, Vec2 *scale = 0);
-
- void setup(dActor_c *actor,
- Vec2 *p1, Vec2 *p2,
- void *otherCB1, void *otherCB2, void *otherCB3,
- u8 t_DD, u8 layer, Vec2 *scale = 0);
-
- void setup(dActor_c *actor, Info *pInfo, u8 t_DD, u8 layer, Vec2 *scale = 0);
-
- // radius might be diameter? dunno
- void setupRound(dActor_c *actor,
- float x, float y, float radius,
- void *otherCB1, void *otherCB2, void *otherCB3,
- u8 t_DD, u8 layer);
-
- void setRect(float x1, float y1, float x2, float y2, Vec2 *scale = 0);
- void setRect(Vec2 *p1, Vec2 *p2, Vec2 *scale = 0);
-
- void setX(float value);
- void setY(float value);
- void setWidth(float value);
- void setHeight(float value);
-
- void setPtrToRotation(s16 *ptr);
-
- void update();
-
- // todo: more stuff that might not be relevant atm
-};
-
-
-class ActivePhysics {
-public:
- struct Info; // forward declaration
- typedef void (*Callback)(Info *self, Info *other);
-
- struct Info {
- float xDistToCenter;
- float yDistToCenter;
- float xDistToEdge;
- float yDistToEdge;
- u8 category1;
- u8 category2;
- u32 bitfield1;
- u32 bitfield2;
- u16 unkShort1C;
- Callback callback;
- };
-
- ActivePhysics();
- virtual ~ActivePhysics();
-
- dActor_c *owner; // should be dStageActor? dunno
- u32 _8;
- u32 _C;
- ActivePhysics *listPrev, *listNext;
- u32 _18;
- Info info;
- u32 _40, _44, _48, _4C;
- float firstFloatArray[8];
- float secondFloatArray[8];
- Vec2 positionOfLastCollision;
- u16 result1;
- u16 result2;
- u16 result3;
- u8 collisionCheckType;
- u8 chainlinkMode;
- u8 layer;
- u8 someFlagByte;
- u8 isLinkedIntoList;
-};
-
-
-#include <statelib.h>
-
-class dActorState_c;
-class dActorMultiState_c;
-
-
-class AcStateMgrBase {
-public:
- virtual ~AcStateMgrBase();
-
- u32 cls1, cls2, cls3;
- dActorMultiState_c *owner;
- u32 unkZero;
-
- StateMgr<dActorMultiState_c> manager;
-
- // All these are passed straight through to the manager
- virtual void _vfC();
- virtual void _vf10();
- virtual void _vf14();
- virtual void _vf18();
- virtual void _vf1C();
- virtual void _vf20();
- virtual void _vf24();
- virtual void _vf28();
- virtual void _vf2C();
-};
-
-class AcStateMgr : public AcStateMgrBase {
-public:
- ~AcStateMgr();
-};
-
-class MultiStateMgrBase {
-public:
- virtual ~MultiStateMgrBase();
-
- AcStateMgr s1, s2;
- AcStateMgr *ptrToStateMgr;
-
- virtual void _vfC(); // calls vfC on ptrToStateMgr
- virtual void execute(); // calls vf10 on ptrToStateMgr
- virtual void _vf14(); // if (isSecondStateMgr()) { disableSecond(); } else { ptrToStateMgr->_vf14(); }
- virtual void setState(StateBase *state); // calls vf18 on ptrToStateMgr
- virtual void _vf1C(); // calls vf1C on ptrToStateMgr
- virtual void _vf20(); // calls vf20 on ptrToStateMgr
- virtual void _vf24(); // calls vf24 on ptrToStateMgr
- virtual StateBase *getCurrentState(); // calls vf28 on ptrToStateMgr
- virtual void _vf2C(); // calls vf2C on ptrToStateMgr
- virtual void enableSecond(); // sets ptrToStateMgr to s2, calls vf18 on it
- virtual void disableSecond(); // if (isSecondStateMgr()) { ptrToStateMgr->vf14(); ptrToStateMgr = &s1; }
- virtual bool isSecondStateMgr();
- virtual void _vf3C(); // calls vf28 on s1
-};
-
-class MultiStateMgr : public MultiStateMgrBase {
-public:
- // what the fuck does this do
- ~MultiStateMgr();
-};
-
-
-struct LinkListEntry {
- LinkListEntry *prev;
- LinkListEntry *next;
- void *owned_obj;
-};
-
-
-struct LinkList {
- LinkListEntry *first;
- LinkListEntry *last;
- // PTMF goes here, but I don't know how to represent it
-};
-
-
-struct OrderedLinkListEntry : LinkListEntry {
- u16 order;
- u16 _;
-};
-
-
-struct TreeNode {
- TreeNode *parent;
- TreeNode *child;
- TreeNode *prev;
- TreeNode *next;
- void *owned_obj;
-};
-
-
-struct Tree {
- TreeNode *firstNode;
- // PTMF goes here, but I don't know how to represent it
-};
-
-
-typedef bool (*ChainedFunc)(void*);
-
-class FunctionChain {
-public:
- ChainedFunc *functions;
- u16 count;
- u16 current;
-
- void setup(ChainedFunc *functions, u16 count); // 8015F740
-};
-
-
-class fBase_c {
-public:
- u32 id;
- u32 settings;
- u16 name;
- u8 _A;
- u8 _B;
- u8 _C;
- u8 _D;
- u8 base_type;
- u8 _F;
- TreeNode link_connect;
- OrderedLinkListEntry link_execute;
- OrderedLinkListEntry link_draw;
- LinkListEntry link_IDlookup;
- u32 _50;
- u32 _54;
- u32 _58;
- u32 heap;
-
- fBase_c();
-
- virtual int onCreate();
- virtual int beforeCreate();
- virtual int afterCreate(int);
-
- virtual int onDelete();
- virtual int beforeDelete();
- virtual int afterDelete(int);
-
- virtual int onExecute();
- virtual int beforeExecute();
- virtual int afterExecute(int);
-
- virtual int onDraw();
- virtual int beforeDraw();
- virtual int afterDraw(int);
-
- virtual void willBeDeleted();
-
- virtual bool moreHeapShit(u32 size, void *parentHeap);
- virtual bool createHeap(u32 size, void *parentHeap);
- virtual void heapCreated();
-
- virtual ~fBase_c();
-
- void Delete();
-
- fBase_c *GetParent();
- fBase_c *GetChild();
- fBase_c *GetNext();
-
- bool hasUninitialisedProcesses(); // 80162B60
-};
-
-class dBase_c : public fBase_c {
-public:
- u32 _64;
- const char *explanation_string;
- const char *name_string;
-
- dBase_c();
-
- int beforeCreate();
- int afterCreate(int);
- int beforeDelete();
- int afterDelete(int);
- int beforeExecute();
- int afterExecute(int);
- int beforeDraw();
- int afterDraw(int);
-
- ~dBase_c();
-
- virtual const char *GetExplanationString();
-};
-
-class dScene_c : public dBase_c {
-public:
- FunctionChain *ptrToInitChain;
-
- dScene_c();
-
- int beforeCreate();
- int afterCreate(int);
- int beforeDelete();
- int afterDelete(int);
- int beforeExecute();
- int afterExecute(int);
- int beforeDraw();
- int afterDraw(int);
-
- ~dScene_c();
-
-
- void setInitChain(FunctionChain &initChain) {
- ptrToInitChain = &initChain;
- }
-};
-
-class dActor_c : public dBase_c {
-public:
- LinkListEntry link_actor;
- Mtx matrix;
- Vec pos;
- Vec last_pos;
- Vec pos_delta;
- Vec _D0;
- Vec scale;
- Vec speed;
- Vec max_speed;
- S16Vec rot;
- S16Vec _106;
- u32 _10C;
- u32 _110;
- float y_speed_inc;
- u32 _118;
- float x_speed_inc;
- u32 _120;
- bool visible;
-
- dActor_c();
-
- virtual void specialDraw1();
- virtual void specialDraw2();
- virtual int _vf58();
- virtual void _vf5C();
-
- ~dActor_c();
-};
-
-class dStageActor_c : public dActor_c {
-public:
- u8 _125;
- u32 _128, _12C, _130, _134, _138, _13C;
- float _140;
- u32 _144;
- ActivePhysics aPhysics;
- u8 classAt1EC[236];
- u32 _2D8;
- u8 classAt2DC[0x34];
- u32 _310, _314;
- float spriteSomeRectX, spriteSomeRectY;
- float _320, _324, _328, _32C, _330, _334, _338, _33C, _340, _344;
- u8 direction;
- u8 currentZoneID;
- u8 _34A, _34B;
- u8 *spriteByteStorage;
- u16 *spriteShortStorage;
- u16 spriteEventNum;
- u64 spriteEventMask;
- u32 _360;
- u16 spriteSomeFlag;
- u8 _366, _367;
- u32 _368;
- u8 _36C, _36D;
- Vec somethingRelatedToScale;
- u32 _37C, _380, _384, _388;
- u8 _38C, _38D, enableFlag, currentLayerID;
- u8 _390, _391, _392, _padding;
-
- dStageActor_c();
-
- int beforeCreate();
- int afterCreate(int);
- int beforeDelete();
- int afterDelete(int);
- int beforeExecute();
- int afterExecute(int);
- int beforeDraw();
- int afterDraw(int);
-
- const char *GetExplanationString();
-
- virtual bool _vf60(); // does stuff with BG_GM
- virtual void kill(); // nullsub here, defined in StageActor. probably no params
- virtual int _vf68(); // params unknown. return (1) might be bool
- virtual u8 *_vf6C(); // returns byte 0x38D
- virtual Vec2 _vf70(); // returns Vec Actor.pos + Vec Actor.field_D0
- virtual int _vf74(); // params unknown. return (1) might be bool
- virtual void _vf78(); // params unknown. nullsub
- virtual void _vf7C(); // params unknown. nullsub
- virtual void eatIn(); // copies Actor.scale into StageActor.somethingRelatedToScale
- virtual void disableEatIn(); // params unknown. nullsub
- virtual void _vf88(); // params unknown. nullsub
- virtual bool _vf8C(void *other); // dAcPy_c/daPlBase_c? return (1) is probably bool. seems related to EatOut. uses vfA4
- virtual bool _vf90(dStageActor_c *other); // does something with scores
- virtual void _vf94(void *other); // dAcPy_c/daPlBase_c? modifies This's position
- virtual void removeMyActivePhysics();
- virtual void addMyActivePhysics();
- virtual void returnRegularScale(); // the reverse of vf80, yay
- virtual void _vfA4(void *other); // AcPy/PlBase? similar to vf94 but not quite the same
- virtual float _vfA8(void *other); // AcPy/PlBase? what DOES this do...? does a bit of float math
- virtual void _vfAC(void *other); // copies somethingRelatedToScale into scale, then multiplies scale by vfA8's return
- virtual void _vfB0(); // plays Wm_en_burst_s at actor position
- virtual void _vfB4(); // params unknown. nullsub
- virtual void _vfB8(); // params unknown. nullsub
- virtual void _vfBC(); // params unknown. nullsub
- virtual void _vfC0(); // params unknown. nullsub
- virtual void _vfC4(); // params unknown. nullsub
- virtual void _vfC8(Vec2 *p); // does stuff including effects and playing PLAYER_SE_OBJ/GROUP_BOOT/SE_OBJ_CMN_SPLASH
- virtual void _vfCC(Vec2 *p); // mostly same as vfC8, but uses PLAYER_SE_OBJ/GROUP_BOOT/SE_OBJ_CMN_SPLASH_LAVA
- virtual void _vfD0(Vec2 *p); // mostly same as vfC8, but uses PLAYER_SE_OBJ/GROUP_BOOT/SE_OBJ_CMN_SPLASH_POISON
-
- // I'll add methods as I need them
- void checkZoneBoundaries(u32 flags); // I think this method is for that, anyway
-
- ~dStageActor_c();
-
-
- static void create(Actors type, u32 settings, Vec *pos, S16Vec *rot, u8 layer);
- static void createChild(Actors type, u32 settings, Vec *pos, S16Vec *rot, u8 layer);
-};
+#ifndef __KAMEK_GAME_H +#define __KAMEK_GAME_H + +//#define offsetof(type, member) ((__std(size_t)) &(((type *) 0)->member)) + +#include <common.h> +#include <rvl/mtx.h> +#include <rvl/GXEnum.h> +#include <rvl/vifuncs.h> +#include <rvl/arc.h> +#define offsetof(type, member) ((u32) &(((type *) 0)->member)) + + +extern "C" { +int strlen(const char *str); + +float atan(float x); +float atan2(float y, float x); + +float cos(float x); +float sin(float x); +} + +bool DVD_Start(); +bool DVD_End(); +bool DVD_StillLoading(void *dvdclass2); +void DVD_LoadFile(void *dvdclass, char *folder, char *file, void *callbackData); +void DVD_FreeFile(void *dvdclass2, char *file); + +extern void *DVDClass; + +inline void *GetDVDClass() { + return DVDClass; +} + +inline void *GetDVDClass2() { + return (void*)(((u32)GetDVDClass())+4); +} + +void *DVD_GetFile(void *dvdclass2, const char *arc, const char *file); +void *DVD_GetFile(void *dvdclass2, const char *arc, const char *file, u32 *length); + + +extern int Player_Active[4]; +extern int Player_ID[4]; +extern int Player_Powerup[4]; +extern int Player_Flags[4]; +extern int Player_Lives[4]; +extern int Player_Coins[4]; + +struct StartLevelInfo { + int maybeUnused; + unsigned char unk1; // 0x04 + unsigned char unk2; // 0x05 + unsigned char unk3; // 0x06 + unsigned char unk4; // 0x07 + unsigned int purpose; // 0x08 + unsigned char world1; // 0x0C + unsigned char level1; // 0x0D + unsigned char world2; // 0x0E + unsigned char level2; // 0x0F +}; + +extern void *GameMgr; +inline void *GetGameMgr() { + return GameMgr; +} + +bool QueryPlayerAvailability(int id); +void DoStartLevel(void *gameMgr, StartLevelInfo *sl); +void SetSomeConditionShit(int world, int level, unsigned int bits); + +bool IsWideScreen(); + +#define GAMEMGR_GET_AFC(gmgr) (*((bool*)(((u32)(gmgr))+0xAFC))) + + +#define COND_COIN1 1 +#define COND_COIN2 2 +#define COND_COIN3 4 +#define COND_NORMAL 0x10 +#define COND_SECRET 0x20 +#define COND_SGNORMAL 0x80 +#define COND_SGSECRET 0x100 + +class SaveFirstBlock { +public: + char titleID[4]; // 0x00 + u8 field_00; // 0x04 + u8 field_01; // 0x05 + u8 current_file; // 0x06 + u8 field_03; // 0x07 + u16 freemode_fav[10][0x2A]; // 0x08 + u16 coinbtl_fav[10][0x2A]; // 0x350 + u16 bitfield; // 0x698 + u16 field_69A; // 0x69A + u32 checksum; // 0x69C +}; + +class SaveBlock { +public: + u8 field_00; // 0x00 + u8 field_01; // 0x01 + u8 bitfield; // 0x02 + u8 current_world; // 0x03 + u8 field_04; // 0x04 + u8 current_path_node; // 0x05 + u8 field_06; // 0x06 + u8 switch_on; // 0x07 + u8 field_08; // 0x08 + u8 powerups_available[7]; // 0x09 + u8 toad_level_idx[10]; // 0x10 + u8 player_continues[4]; // 0x1A + u8 player_coins[4]; // 0x1E + u8 player_lives[4]; // 0x22 + u8 player_flags[4]; // 0x26 + u8 player_type[4]; // 0x2A + u8 player_powerup[4]; // 0x2E + u8 worlds_available[10]; // 0x32 + u32 ambush_countdown[10]; // 0x3C + u16 field_64; // 0x64 + u16 credits_hiscore; // 0x66 + u16 score; // 0x68 + u32 completions[10][0x2A]; // 0x6C + u8 hint_movie_bought[70]; // 0x6FC + u8 toad_location[10]; // 0x742 + u8 field_74C[10][4]; // 0x74C + u8 field_774[10][4]; // 0x774 + u8 field_79C[10][4]; // 0x79C + u8 death_counts[10][0x2A]; // 0x7C4 + u8 death_count_3_4_switch; // 0x968 + u8 pad[0x13]; // 0x969 + u32 checksum; // 0x97C + + u32 GetLevelCondition(int world, int level); + bool CheckLevelCondition(int world, int level, int cond); + bool CheckIfCoinCollected(int world, int level, int num); +}; + +class SaveFile { +public: + u32 field_00; + u32 field_04; + u32 field_08; + u32 field_0C; + u32 field_10; + u32 field_14; + u32 field_18; + u32 field_1C; + + // Real Savefile starts here + SaveFirstBlock header; + SaveBlock blocks[3]; + SaveBlock quickSave[3]; + + SaveBlock *GetBlock(int id); + SaveBlock *GetQSBlock(int id); + + bool CheckIfWriting(); // 0x800E0540 +}; + +class SaveHandler { +public: + u8 unknown[0x70]; + u32 CurrentState; + u32 CurrentError; + u32 field_7C; +}; + +extern SaveFile *SaveFileInstance; +extern SaveHandler *SaveHandlerInstance; + +inline SaveFile *GetSaveFile() { + return SaveFileInstance; +} + +inline SaveHandler *GetSaveHandler() { + return SaveHandlerInstance; +} + +#define WPAD_DOWN 0x0001 // Actually Left, but rotated +#define WPAD_UP 0x0002 // Actually Right, but rotated +#define WPAD_RIGHT 0x0004 // Actually Down, but rotated +#define WPAD_LEFT 0x0008 // Actually Up, but rotated +#define WPAD_PLUS 0x0010 +#define WPAD_TWO 0x0100 +#define WPAD_ONE 0x0200 +#define WPAD_B 0x0400 +#define WPAD_A 0x0800 +#define WPAD_MINUS 0x1000 +#define WPAD_HOME 0x8000 + +struct RemoconMngClass { + void *vtable; + void *controllers[4]; +}; + +/* + * Ok, here's how the remocon/wiimote shit works: + * Remocon is a NSMB-specific class, it handles the different control methods + * and D-pad directions and such automatically. + * + * Wiimote is a generic class (part of EGG) -- well it's not actually called + * that, but who cares. It handles different types of controllers. Only + * query it if whatever you're accessing is control type dependent. + */ + +extern RemoconMngClass *RemoconMng; +extern int ActiveWiimoteID; +extern void *ActiveWiimote; + +inline RemoconMngClass *GetRemoconMng() { + return RemoconMng; +} + +inline int GetActiveWiimoteID() { + return ActiveWiimoteID; +} + +inline void *GetActiveRemocon() { + return GetRemoconMng()->controllers[GetActiveWiimoteID()]; +} + +inline void *GetActiveWiimote() { + return ActiveWiimote; +} + +inline unsigned int Remocon_GetButtons(void *self) { + return *((unsigned int*)((u32)self+0x18)); +} + +inline unsigned int Remocon_GetPressed(void *self) { + return *((unsigned int*)((u32)self+0x1C)); +} + +typedef bool (*__Wiimote_TestButtons_type)(void*, unsigned int); +inline bool Wiimote_TestButtons(void *self, unsigned int btns) { + VF_BEGIN(__Wiimote_TestButtons_type, self, 8, 0) + return VF_CALL(self, btns); + VF_END; +} + +int SearchForIndexOfPlayerID(int id); + +bool CheckIfContinueShouldBeActivated(); + +bool CheckIfMenuShouldBeCancelledForSpecifiedWiimote(int num); + +void StartTitleScreenStage(bool realDemo, int sceneParam); + +bool CheckIfWeCantDoStuff(); + +u32 QueryGlobal5758(u32 check); + +void SaveGame(void *classDoesntMatter, bool isQuick); + +#include <actors.h> +void *CreateParentedObject(short classID, void *parent, int settings, char something); +void *CreateChildObject(short classID, void *parent, int settings, int unk1, int unk2); + + +#define WIPE_FADE 0 +#define WIPE_CIRCLE 1 +#define WIPE_BOWSER 2 +#define WIPE_WAVY 3 +#define WIPE_MARIO 4 +#define WIPE_CIRCLE_s 5 + +void ActivateWipe(int type); + +typedef void (*ScreenDrawFunc)(); + +extern ScreenDrawFunc *CurrentDrawFunc; +void WorldMapDrawFunc(); +void GameSetupDrawFunc(); + +void GameSetup__LoadScene(void *self); // 0x80919560 +void FreeScene(int id); + +void WpadShit(int unk); // 0x8016F780 + +void *BgTexMng__LoadAnimTile(void *self, int tileset, short tile, char *name, char *delays, char reverse); // 0x80087B60 + +extern void *GameHeaps[]; + + +class dFlagMgr_c { +public: + dFlagMgr_c(); + + enum ActionFlag { + ACTIVATE = 1, + TICKS = 2 + }; + + u64 flags; + float _8[64], _108[64]; + u8 _208[64]; + u64 _248[64]; + u8 _448[64]; + + u32 ticksRemainingForAction[64]; + u8 actionFlag[64]; + u32 _5C8[64]; // somehow sound related?! assigned by last param to set(); only checked for == 0 + u8 _6C8; // assigned -1 by FlagMgr, and other values by the Switch object, nothing else though + + void setup(bool isNewLevel); + void applyAndClearAllTimedActions(); // only used when setup(true) is called + void execute(); + + void set(u8 number, int delay, bool activate, bool reverseEffect, bool makeNoise, u32 unknown=0); + + u8 findLowestFlagInSet(u32 unk, u64 set); + + void setSpecial(u8 number, float to8, float to108, u8 to208, u32 unk, u64 to248); + float get8(u8 number); + float get108(u8 number); + u8 get208(u8 number); + u64 get248(u8 number); + u8 get448(u8 number); + + // convenience inline functions which may or may not actually exist in Nintendo's original code + u64 mask(u8 number) { return (u64)1 << number; } + bool active(u8 number) { return (flags & mask(number)) != 0; } + bool inactive(u8 number) { return (flags & mask(number)) == 0; } + + static dFlagMgr_c *instance; +}; + + +namespace nw4r { + +namespace ut { + // this isn't 100% accurate because it doesn't use templates + // or detail::LinkListImpl, but oh well + // I don't need the methods anyway. + + class LinkListNode { + public: + LinkListNode *next; + LinkListNode *prev; + }; + + class LinkList { + public: + int count; + LinkListNode initialNode; + }; + + class Color : public GXColor { }; + + class Rect { + public: + f32 left; + f32 top; + f32 right; + f32 bottom; + }; + + template <class T> + class TagProcessorBase { }; +} + +namespace lyt { + class Pane; // forward declaration + class DrawInfo; + + class AnimTransform; // I'll do these later + class AnimResource; + class AnimationLink; + class ResourceAccessor; + class GroupContainer; + + class Layout { + public: + Layout(); + virtual ~Layout(); + + virtual bool Build(const void *data, ResourceAccessor *resAcc); + + virtual AnimTransform *CreateAnimTransform(); + virtual AnimTransform *CreateAnimTransform(const void *data, ResourceAccessor *resAcc); + virtual AnimTransform *CreateAnimTransform(const AnimResource &res, ResourceAccessor *resAcc); + + virtual void BindAnimation(AnimTransform *anim); + virtual void UnbindAnimation(AnimTransform *anim); + virtual void UnbindAllAnimation(); + virtual bool BindAnimationAuto(const AnimResource &res, ResourceAccessor *resAcc); + + virtual void SetAnimationEnable(AnimTransform *anim, bool unk); + + virtual void CalculateMtx(const DrawInfo &info); + + virtual void/*?*/ Draw(const DrawInfo &info); + virtual void/*?*/ Animate(ulong flag); + + virtual void/*?*/ SetTagProcessor(ut::TagProcessorBase<wchar_t> *tagProc); + + ut::LinkList animations; + + Pane *rootPane; + GroupContainer *groupContainer; + + float width; + float height; + }; + + + class DrawInfo { + public: + DrawInfo(); + virtual ~DrawInfo(); + + Mtx matrix; + float left; + float top; + float right; + float bottom; + float scaleX; + float scaleY; + float alpha; + u8 _50; // this is actually a bitfield. todo: investigate how CW handles bitfields, and so on + }; + + + class Material { + public: + // ... + }; + + class Pane { + public: + //Pane(nw4r::lyt::res::Pane const *); // todo: this struct + Pane(void *); + virtual ~Pane(); + + virtual void *GetRuntimeTypeInfo() const; + virtual void CalculateMtx(const DrawInfo &info); + + virtual void Draw(const DrawInfo &info); + virtual void DrawSelf(const DrawInfo &info); + virtual void Animate(ulong flag); + virtual void AnimateSelf(ulong flag); + + virtual ut::Color GetVtxColor(ulong id) const; + virtual void SetVtxColor(ulong id, ut::Color color); + virtual uchar GetColorElement(ulong id) const; + virtual void SetColorElement(ulong id, uchar value); + virtual uchar GetVtxColorElement(ulong id) const; + virtual void SetVtxColorElement(ulong id, uchar value); + + virtual Pane *FindPaneByName(const char *name, bool recursive); + virtual Material *FindMaterialByName(const char *name, bool recursive); + + virtual void/*?*/ BindAnimation(AnimTransform *anim, bool unk1, bool unk2); + virtual void UnbindAnimation(AnimTransform *anim, bool unk); + virtual void UnbindAllAnimation(bool unk); + virtual void UnbindAnimationSelf(AnimTransform *anim); + + virtual ut::LinkListNode *FindAnimationLinkSelf(AnimTransform *anim); + virtual ut::LinkListNode *FindAnimationLinkSelf(const AnimResource &anim); + + virtual void SetAnimationEnable(AnimTransform *anim, bool unk1, bool unk2); + virtual void SetAnimationEnable(const AnimResource &anim, bool unk1, bool unk2); + + virtual ulong GetMaterialNum() const; + virtual Material *GetMaterial() const; + virtual Material *GetMaterial(ulong id) const; + + virtual void LoadMtx(const DrawInfo &info); + + void AppendChild(Pane *child); + + ut::Rect GetPaneRect(const DrawInfo &info) const; + + ut::LinkListNode *AddAnimationLink(AnimationLink *link); + + Vec2 GetVtxPos() const; + + + ut::LinkListNode parentLink; + Pane *parent; + + ut::LinkList children; + ut::LinkList animations; + + Material *material; + + Vec trans; + Vec rotate; + Vec2 scale; + Vec2 size; + + Mtx calcMtx; + Mtx effectiveMtx; + + float _B4; + + u8 alpha; + u8 effectiveAlpha; + u8 origin; + u8 flag; + + char name[0x11]; + char userdata[8]; + + u8 _D5; + u8 paneIsOwnedBySomeoneElse; + u8 _D7; + }; + + class TextBox : public Pane { + public: + TextBox(void *, void *); // todo: TextBox((res::TextBox const *,ResBlockSet const &)) + ~TextBox(); + + void *GetRuntimeTypeInfo() const; + + void DrawSelf(const DrawInfo &info); + + ut::Color GetVtxColor(ulong id) const; + void SetVtxColor(ulong id, ut::Color color); + uchar GetVtxColorElement(ulong id) const; + void SetVtxColorElement(ulong id, uchar value); + + virtual void LoadMtx(const DrawInfo &info); + + virtual void AllocStringBuffer(u16 size); + virtual void FreeStringBuffer(); + + virtual u16 SetString(const wchar_t *str, u16 destOffset = 0); + virtual u16 SetString(const wchar_t *str, u16 destOffset, u16 length); + + wchar_t *stringBuf; + + ut::Color colour1, colour2; + void *font; // actually a ut::ResFont or whatever + + float fontSizeX, fontSizeY; + float lineSpace, charSpace; + + void *tagProc; // actually a TagProcessor + + u16 bufferLength; + u16 stringLength; + + u8 alignment; + u8 flags; + }; +} + + + +namespace g3d { +struct CameraData +{ +enum Flag + { +FLAG_CAMERA_LOOKAT = 0x00000001, +FLAG_CAMERA_ROTATE = 0x00000002, +FLAG_CAMERA_AIM = 0x00000004, +MASK_CAMERA = 0x00000007, + +FLAG_CMTX_VALID = 0x00000008, + +FLAG_PROJ_FLUSTUM = 0x00000010, +FLAG_PROJ_PERSP = 0x00000020, +FLAG_PROJ_ORTHO = 0x00000040, +MASK_PROJ = 0x00000070, + +FLAG_PMTX_VALID = 0x00000080, + +FLAG_VIEWPORT_JITTER_ABOVE = 0x00000100 + }; + +Mtx cameraMtx; +Mtx44 projMtx; + +u32 flags; + +VEC3 cameraPos; +VEC3 cameraUp; +VEC3 cameraTarget; +VEC3 cameraRotate; +f32 cameraTwist; + +GXProjectionType projType; +f32 projFovy; +f32 projAspect; +f32 projNear; +f32 projFar; +f32 projTop; +f32 projBottom; +f32 projLeft; +f32 projRight; + +f32 lightScaleS; +f32 lightScaleT; +f32 lightTransS; +f32 lightTransT; + +VEC2 viewportOrigin; +VEC2 viewportSize; +f32 viewportNear; +f32 viewportFar; + +u32 scissorX; +u32 scissorY; +u32 scissorWidth; +u32 scissorHeight; + +s32 scissorOffsetX; +s32 scissorOffsetY; +}; + +/* Correct camera +cameraMtx: +1.0 0.0 0.0 -0.0 +0.0 1.0 0.0 -0.0 +0.0 0.0 1.0 -6000.0 + +projMtx: +0.002345 0.000000 0.000000 -1.000000 +0.000000 0.004386 0.000000 -1.000000 +0.000000 0.000000 -0.000005 -0.500000 +0.000000 0.000000 0.000000 1.000000 + +flags: 000000C9 : FLAG_CAMERA_LOOKAT | FLAG_CMTX_VALID | FLAG_PROJ_ORTHO | FLAG_PMTX_VALID + +cameraPos: {0, 0, 15} +cameraUp: {0, 1, 0} +cameraTarget: {0, 0, 0} +cameraRotate: {0, 0, 0} +cameraTwist: 0 + +projType: 1 +projFovy: 60 +projAspect: 1.333333 +projNear: -100000 +projFar: 100000 +projTop: 456 +projBottom: 0 +projLeft: 0 +projRight: 853 + +lightScaleS: 0.5 +lightScaleT: 0.5 +lightTransS: 0.5 +lightTransT: 0.5 + +viewportOrigin: {0,0} +viewportSize: {640,456} +viewportNear: 0 +viewportFar: 1 + +scissorX: 0 +scissorY: 0 +scissorWidth: 0x280 +scissorHeight: 0x1C8 + +scissorOffsetX: 0 +scissorOffsetY: 0 +*/ + +class Camera { +public: + enum PostureType { POSTURE_LOOKAT, POSTURE_ROTATE, POSTURE_AIM }; + struct PostureInfo + { + PostureType tp; + VEC3 cameraUp; + VEC3 cameraTarget; + VEC3 cameraRotate; + f32 cameraTwist; + }; +private: + CameraData *data; +public: + Camera(CameraData *pCamera); + void Init(); + void Init(u16 efbWidth, u16 efbHeight, u16 xfbWidth, u16 xfbHeight, u16 viWidth, u16 viHeight); + //void SetPosition(f32 x, f32 y, f32 z); + void SetPosition(const VEC3 &pos); + //void GetPosition(f32 *px, f32 *py, f32 *pz) const; + void GetPosition(VEC3 *pPos) const; + void SetPosture(const PostureInfo &info); + //void GetPosture(PostureInfo *info) const; + void SetCameraMtxDirectly(const Mtx &mtx); + void GetCameraMtx(Mtx *pMtx) const; + void SetOrtho(f32 top, f32 bottom, f32 left, f32 right, f32 near, f32 far); + //void SetFrustum(f32 top, f32 bottom, f32 left, f32 right, f32 near, f32 far); + void SetPerspective(f32 fovy, f32 aspect, f32 near, f32 far); + void SetProjectionMtxDirectly(const Mtx44 *pMtx); + void GetProjectionMtx(Mtx44 *pMtx) const; + //GXProjectionType GetProjectionType() const; + void SetScissor(u32 xOrigin, u32 yOrigin, u32 width, u32 height); + void SetScissorBoxOffset(s32 xOffset, s32 yOffset); + //void GetScissor(u32 *xOrigin, u32 *yOrigin, u32 *width, u32 *height); + void SetViewport(f32 xOrigin, f32 yOrigin, f32 width, f32 height); + //void SetViewport(f32 xOrigin, f32 yOrigin, f32 width, f32 height, f32 near, f32 far); + void SetViewportZRange(f32 near, f32 far); + void SetViewportJitter(u32 field); + //void SetViewportJitter(f32 xOrigin, f32 yOrigin, f32 width, f32 height, f32 near, f32 far, u32 field); + void GetViewport(f32 *xOrigin, f32 *yOrigin, f32 *width, f32 *height, f32 *near, f32 *far) const; + void GXSetViewport() const; + void GXSetProjection() const; + void GXSetScissor() const; + void GXSetScissorBoxOffset() const; +}; + +namespace G3DState { + GXRenderModeObj *GetRenderModeObj(); +} +} +} + + +nw4r::g3d::CameraData *GetCameraByID(int id); + +int GetCurrentCameraID(); // 80164C80 +void SetCurrentCameraID(int id); // 80164C90 + +void LinkScene(int id); // 80164D50 +void UnlinkScene(int id); // 80164CD0 + +void SceneCalcWorld(int sceneID); // 80164E10 +void SceneCameraStuff(int sceneID); // 80164EA0 + +void CalcMaterial(); // 80164E90 +void DrawOpa(); // 80164F70 +void DrawXlu(); // 80164F80 + +bool ChangeAlphaUpdate(bool enable); // 802D3270 + +void DoSpecialDrawing1(); // 8006CAE0 +void DoSpecialDrawing2(); // 8006CB40 + +void SetupLYTDrawing(); // 80163360 +void ClearLayoutDrawList(); // 801632B0 + +void DrawAllLayoutsBeforeX(int x); // 80163440 +void DrawAllLayoutsAfterX(int x); // 801634D0 +void DrawAllLayoutsAfterXandBeforeY(int x, int y); // 80163560 + +void RenderEffects(int v1, int v2); // 80093F10 + +void RemoveAllFromScnRoot(); // 80164FB0 +void Reset3DState(); // 80165000 + +extern "C" void GXDrawDone(); // 801C4FE0 + + + +namespace m2d { + class Base_c /*: public nw4r::ut::Link what's this? */ { + public: + u32 _00; + u32 _04; + + Base_c(); + virtual ~Base_c(); + virtual void draw(); // don't call this directly + + void scheduleForDrawing(); + + u8 drawOrder; + }; + + class Simple_c : public Base_c { + public: + nw4r::lyt::Layout layout; + nw4r::lyt::DrawInfo drawInfo; + + u32 _84; + float _88; + float _8C; + float _90; + u32 _94; + + Simple_c(); + ~Simple_c(); + + void draw(); + virtual void _vf10(); + virtual void _vf14(); + }; +} + + + +namespace EGG { + class Frustum { + public: + GXProjectionType projType; + int isCentered; + float width; + float height; + float fovy; + float dunno; + float near; + float far; + float center_x_maybe; + float center_y_maybe; + float x_direction; + float unk2; + float unk3; + short some_flag_bit; + + + // isCentered might actually be isNotCentered, dunno + Frustum(GXProjectionType projType, Vec2 size, bool isCentered, float near, float far); // 802C6D20 + Frustum(Frustum &f); // 802C6D90 + virtual ~Frustum(); // 802C75F0 + + virtual void loadDirectly(); // 802C7050 + virtual void loadIntoCamera(nw4r::g3d::Camera cam); // 802C7070 + + void setOrtho(float top, float bottom, float left, float right, float near, float far); // 802C6DD0 + + void setFovy(float newFovy); // 802C6F60 + + void getCenterPointsBasedOnPos(float x, float y, float *destX, float *destY); // 802C6FD0 + + // no idea what this does + float getSomethingForPerspective(float blah); // 802C7020 + + + protected: + // not all of these might be protected, dunno + + void copyAllFields(Frustum &f); // 802C6EE0 + + void saveSomething(float f1, float f2, float f3, float f4); // 802C70C0 + void loadSomething(float *f1, float *f2, float *f3, float *f4); // 802C70E0 + + void loadPerspective(); // 802C7110 + void loadOrtho(); // 802C7140 + + void setCameraPerspective(nw4r::g3d::Camera cam); // 802C7170 + void setCameraOrtho(nw4r::g3d::Camera cam); // 802C71E0 + + void getPerspectiveProjMtx(Mtx44 *mtx); // 802C7250 + void getPerspectiveProjv(float *ptr); // 802C72E0 + void getOrthoProjv(float *ptr); // 802C73A0 + + void getOrthoVars(float *top, float *bottom, float *left, float *right); // 802C7480 + }; +} + + +class TileRenderer { +public: + TileRenderer(); + ~TileRenderer(); + + TileRenderer *list1, *list2; + u16 tileNumber; + u8 unkFlag, someBool; + float x, y, z; + float scale; + s16 rotation; + u8 unkByte; + + u16 getTileNum(); + bool getSomeBool(); + void setSomeBool(u8 value); + + float getX(); + float getY(); + float getZ(); + void setPosition(float x, float y); + void setPosition(float x, float y, float z); + + u8 getUnkFlag(); + + void setVars(float scale); // sets unkFlag=1, rotation=0, unkByte=0 + void setVars(float scale, s16 rotation); // sets unkFlag=2, unkByte=0 + + float getScale(); + float getRotationFloat(); + s16 getRotation(); + + u8 getUnkByte(); + + class List { + public: + u32 count; + TileRenderer *first, *last; // order? + + void add(TileRenderer *r); + void remove(TileRenderer *r); + void removeAll(); + + List(); + ~List(); + }; +}; + +class dActor_c; // forward declaration + +class Physics { +public: + struct Unknown { + Unknown(); + ~Unknown(); + + float x, y; + }; + + struct Info { + float x1, y1, x2, y2; // Might be distance to center/edge like APhysics + void *otherCallback1, *otherCallback2, *otherCallback3; + }; + + Physics(); + ~Physics(); + + dActor_c *owner; + Physics *next, *prev; + u32 _C, _10, _14, _18, _1C, _20, _24, _28, _2C, _30, _34, _38, _3C; + void *otherCallback1, *otherCallback2, *otherCallback3; + void *callback1, *callback2, *callback3; + float lastX, lastY; + Unknown unkArray[4]; + float x, y; + float _88, _8C, _90; + Vec lastActorPosition; + float _A0, _A4, last_A0, last_A4, _B0, _B4; + u32 _B8; + s16 *ptrToRotationShort; + s16 currentRotation; + s16 rotDiff; + s16 rotDiffAlt; + u32 isRound; + u32 _CC; + u32 flagsMaybe; + u32 _D4, _D8; + u8 isAddedToList, _DD, layer; + u32 id; + + void addToList(); + void removeFromList(); + + void baseSetup(dActor_c *actor, u32 t_40, u32 t_44, u32 t_48, u8 t_DD, u8 layer); + + // note: Scale can be a null pointer (in that case, it'll use 1.0) + void setup(dActor_c *actor, + float x1, float y1, float x2, float y2, + void *otherCB1, void *otherCB2, void *otherCB3, + u8 t_DD, u8 layer, Vec2 *scale = 0); + + void setup(dActor_c *actor, + Vec2 *p1, Vec2 *p2, + void *otherCB1, void *otherCB2, void *otherCB3, + u8 t_DD, u8 layer, Vec2 *scale = 0); + + void setup(dActor_c *actor, Info *pInfo, u8 t_DD, u8 layer, Vec2 *scale = 0); + + // radius might be diameter? dunno + void setupRound(dActor_c *actor, + float x, float y, float radius, + void *otherCB1, void *otherCB2, void *otherCB3, + u8 t_DD, u8 layer); + + void setRect(float x1, float y1, float x2, float y2, Vec2 *scale = 0); + void setRect(Vec2 *p1, Vec2 *p2, Vec2 *scale = 0); + + void setX(float value); + void setY(float value); + void setWidth(float value); + void setHeight(float value); + + void setPtrToRotation(s16 *ptr); + + void update(); + + // todo: more stuff that might not be relevant atm +}; + + +class ActivePhysics { +public: + struct Info; // forward declaration + typedef void (*Callback)(Info *self, Info *other); + + struct Info { + float xDistToCenter; + float yDistToCenter; + float xDistToEdge; + float yDistToEdge; + u8 category1; + u8 category2; + u32 bitfield1; + u32 bitfield2; + u16 unkShort1C; + Callback callback; + }; + + ActivePhysics(); + virtual ~ActivePhysics(); + + dActor_c *owner; // should be dStageActor? dunno + u32 _8; + u32 _C; + ActivePhysics *listPrev, *listNext; + u32 _18; + Info info; + u32 _40, _44, _48, _4C; + float firstFloatArray[8]; + float secondFloatArray[8]; + Vec2 positionOfLastCollision; + u16 result1; + u16 result2; + u16 result3; + u8 collisionCheckType; + u8 chainlinkMode; + u8 layer; + u8 someFlagByte; + u8 isLinkedIntoList; +}; + + +#include <statelib.h> + +class dActorState_c; +class dActorMultiState_c; + + +class AcStateMgrBase { +public: + virtual ~AcStateMgrBase(); + + u32 cls1, cls2, cls3; + dActorMultiState_c *owner; + u32 unkZero; + + StateMgr<dActorMultiState_c> manager; + + // All these are passed straight through to the manager + virtual void _vfC(); + virtual void _vf10(); + virtual void _vf14(); + virtual void _vf18(); + virtual void _vf1C(); + virtual void _vf20(); + virtual void _vf24(); + virtual void _vf28(); + virtual void _vf2C(); +}; + +class AcStateMgr : public AcStateMgrBase { +public: + ~AcStateMgr(); +}; + +class MultiStateMgrBase { +public: + virtual ~MultiStateMgrBase(); + + AcStateMgr s1, s2; + AcStateMgr *ptrToStateMgr; + + virtual void _vfC(); // calls vfC on ptrToStateMgr + virtual void execute(); // calls vf10 on ptrToStateMgr + virtual void _vf14(); // if (isSecondStateMgr()) { disableSecond(); } else { ptrToStateMgr->_vf14(); } + virtual void setState(StateBase *state); // calls vf18 on ptrToStateMgr + virtual void _vf1C(); // calls vf1C on ptrToStateMgr + virtual void _vf20(); // calls vf20 on ptrToStateMgr + virtual void _vf24(); // calls vf24 on ptrToStateMgr + virtual StateBase *getCurrentState(); // calls vf28 on ptrToStateMgr + virtual void _vf2C(); // calls vf2C on ptrToStateMgr + virtual void enableSecond(); // sets ptrToStateMgr to s2, calls vf18 on it + virtual void disableSecond(); // if (isSecondStateMgr()) { ptrToStateMgr->vf14(); ptrToStateMgr = &s1; } + virtual bool isSecondStateMgr(); + virtual void _vf3C(); // calls vf28 on s1 +}; + +class MultiStateMgr : public MultiStateMgrBase { +public: + // what the fuck does this do + ~MultiStateMgr(); +}; + + +struct LinkListEntry { + LinkListEntry *prev; + LinkListEntry *next; + void *owned_obj; +}; + + +struct LinkList { + LinkListEntry *first; + LinkListEntry *last; + // PTMF goes here, but I don't know how to represent it +}; + + +struct OrderedLinkListEntry : LinkListEntry { + u16 order; + u16 _; +}; + + +struct TreeNode { + TreeNode *parent; + TreeNode *child; + TreeNode *prev; + TreeNode *next; + void *owned_obj; +}; + + +struct Tree { + TreeNode *firstNode; + // PTMF goes here, but I don't know how to represent it +}; + + +typedef bool (*ChainedFunc)(void*); + +class FunctionChain { +public: + ChainedFunc *functions; + u16 count; + u16 current; + + void setup(ChainedFunc *functions, u16 count); // 8015F740 +}; + + +class fBase_c { +public: + u32 id; + u32 settings; + u16 name; + u8 _A; + u8 _B; + u8 _C; + u8 _D; + u8 base_type; + u8 _F; + TreeNode link_connect; + OrderedLinkListEntry link_execute; + OrderedLinkListEntry link_draw; + LinkListEntry link_IDlookup; + u32 _50; + u32 _54; + u32 _58; + u32 heap; + + fBase_c(); + + virtual int onCreate(); + virtual int beforeCreate(); + virtual int afterCreate(int); + + virtual int onDelete(); + virtual int beforeDelete(); + virtual int afterDelete(int); + + virtual int onExecute(); + virtual int beforeExecute(); + virtual int afterExecute(int); + + virtual int onDraw(); + virtual int beforeDraw(); + virtual int afterDraw(int); + + virtual void willBeDeleted(); + + virtual bool moreHeapShit(u32 size, void *parentHeap); + virtual bool createHeap(u32 size, void *parentHeap); + virtual void heapCreated(); + + virtual ~fBase_c(); + + void Delete(); + + fBase_c *GetParent(); + fBase_c *GetChild(); + fBase_c *GetNext(); + + bool hasUninitialisedProcesses(); // 80162B60 +}; + +class dBase_c : public fBase_c { +public: + u32 _64; + const char *explanation_string; + const char *name_string; + + dBase_c(); + + int beforeCreate(); + int afterCreate(int); + int beforeDelete(); + int afterDelete(int); + int beforeExecute(); + int afterExecute(int); + int beforeDraw(); + int afterDraw(int); + + ~dBase_c(); + + virtual const char *GetExplanationString(); +}; + +class dScene_c : public dBase_c { +public: + FunctionChain *ptrToInitChain; + + dScene_c(); + + int beforeCreate(); + int afterCreate(int); + int beforeDelete(); + int afterDelete(int); + int beforeExecute(); + int afterExecute(int); + int beforeDraw(); + int afterDraw(int); + + ~dScene_c(); + + + void setInitChain(FunctionChain &initChain) { + ptrToInitChain = &initChain; + } +}; + +class dActor_c : public dBase_c { +public: + LinkListEntry link_actor; + Mtx matrix; + Vec pos; + Vec last_pos; + Vec pos_delta; + Vec _D0; + Vec scale; + Vec speed; + Vec max_speed; + S16Vec rot; + S16Vec _106; + u32 _10C; + u32 _110; + float y_speed_inc; + u32 _118; + float x_speed_inc; + u32 _120; + bool visible; + + dActor_c(); + + virtual void specialDraw1(); + virtual void specialDraw2(); + virtual int _vf58(); + virtual void _vf5C(); + + ~dActor_c(); +}; + +class dStageActor_c : public dActor_c { +public: + u8 _125; + u32 _128, _12C, _130, _134, _138, _13C; + float _140; + u32 _144; + ActivePhysics aPhysics; + u8 classAt1EC[236]; + u32 _2D8; + u8 classAt2DC[0x34]; + u32 _310, _314; + float spriteSomeRectX, spriteSomeRectY; + float _320, _324, _328, _32C, _330, _334, _338, _33C, _340, _344; + u8 direction; + u8 currentZoneID; + u8 _34A, _34B; + u8 *spriteByteStorage; + u16 *spriteShortStorage; + u16 spriteEventNum; + u64 spriteEventMask; + u32 _360; + u16 spriteSomeFlag; + u8 _366, _367; + u32 _368; + u8 _36C, _36D; + Vec somethingRelatedToScale; + u32 _37C, _380, _384, _388; + u8 _38C, _38D, enableFlag, currentLayerID; + u8 _390, _391, _392, _padding; + + dStageActor_c(); + + int beforeCreate(); + int afterCreate(int); + int beforeDelete(); + int afterDelete(int); + int beforeExecute(); + int afterExecute(int); + int beforeDraw(); + int afterDraw(int); + + const char *GetExplanationString(); + + virtual bool _vf60(); // does stuff with BG_GM + virtual void kill(); // nullsub here, defined in StageActor. probably no params + virtual int _vf68(); // params unknown. return (1) might be bool + virtual u8 *_vf6C(); // returns byte 0x38D + virtual Vec2 _vf70(); // returns Vec Actor.pos + Vec Actor.field_D0 + virtual int _vf74(); // params unknown. return (1) might be bool + virtual void _vf78(); // params unknown. nullsub + virtual void _vf7C(); // params unknown. nullsub + virtual void eatIn(); // copies Actor.scale into StageActor.somethingRelatedToScale + virtual void disableEatIn(); // params unknown. nullsub + virtual void _vf88(); // params unknown. nullsub + virtual bool _vf8C(void *other); // dAcPy_c/daPlBase_c? return (1) is probably bool. seems related to EatOut. uses vfA4 + virtual bool _vf90(dStageActor_c *other); // does something with scores + virtual void _vf94(void *other); // dAcPy_c/daPlBase_c? modifies This's position + virtual void removeMyActivePhysics(); + virtual void addMyActivePhysics(); + virtual void returnRegularScale(); // the reverse of vf80, yay + virtual void _vfA4(void *other); // AcPy/PlBase? similar to vf94 but not quite the same + virtual float _vfA8(void *other); // AcPy/PlBase? what DOES this do...? does a bit of float math + virtual void _vfAC(void *other); // copies somethingRelatedToScale into scale, then multiplies scale by vfA8's return + virtual void _vfB0(); // plays Wm_en_burst_s at actor position + virtual void _vfB4(); // params unknown. nullsub + virtual void _vfB8(); // params unknown. nullsub + virtual void _vfBC(); // params unknown. nullsub + virtual void _vfC0(); // params unknown. nullsub + virtual void _vfC4(); // params unknown. nullsub + virtual void _vfC8(Vec2 *p); // does stuff including effects and playing PLAYER_SE_OBJ/GROUP_BOOT/SE_OBJ_CMN_SPLASH + virtual void _vfCC(Vec2 *p); // mostly same as vfC8, but uses PLAYER_SE_OBJ/GROUP_BOOT/SE_OBJ_CMN_SPLASH_LAVA + virtual void _vfD0(Vec2 *p); // mostly same as vfC8, but uses PLAYER_SE_OBJ/GROUP_BOOT/SE_OBJ_CMN_SPLASH_POISON + + // I'll add methods as I need them + void checkZoneBoundaries(u32 flags); // I think this method is for that, anyway + + ~dStageActor_c(); + + + static void create(Actors type, u32 settings, Vec *pos, S16Vec *rot, u8 layer); + static void createChild(Actors type, u32 settings, Vec *pos, S16Vec *rot, u8 layer); +}; class dAc_Py_c : public dStageActor_c { public: u8 data[0x1164 - 0x394]; - ActivePhysics bPhysics;
- ActivePhysics cPhysics;
- ActivePhysics dPhysics;
+ ActivePhysics bPhysics; + ActivePhysics cPhysics; + ActivePhysics dPhysics; ActivePhysics ePhysics; - dAc_Py_c();
+ dAc_Py_c(); - int beforeCreate();
- int afterCreate(int);
- int beforeDelete();
- int afterDelete(int);
- int beforeExecute();
- int afterExecute(int);
- int beforeDraw();
+ int beforeCreate(); + int afterCreate(int); + int beforeDelete(); + int afterDelete(int); + int beforeExecute(); + int afterExecute(int); + int beforeDraw(); int afterDraw(int); -
- ~dAc_Py_c();
+ + ~dAc_Py_c(); +}; + + +/* TODO +class dActorState_c : public dStageActor_c { +public: + ~dActorState_c(); + + virtual void _vfD4(); + virtual void _vfD8(); + virtual void _vfDC(); +}; +*/ + + +class dActorMultiState_c : public dStageActor_c { +public: + ~dActorMultiState_c(); + + MultiStateMgr acState; + + virtual void doStateChange(StateBase *state); // might return bool? overridden by dEn_c + virtual void _vfD8(); // nullsub ?? + virtual void _vfDC(); // nullsub ?? + virtual void _vfE0(); // nullsub ?? +}; + + +class dEn_c : public dActorMultiState_c { +public: + float _414, _418, _41C, _420; + void *nextState; + u32 _428, _42C; + u8 _430, _431, isDead; + u32 _434; + u16 _438; + u32 _43C; + Vec velocity1, velocity2; + u8 _458, _459, _45A, _45B, _45C, _45D, _45E; + u32 _460; + Vec initialScale; + float _470; + u32 _474, _478; + dEn_c *_47C; + u32 _480; + u8 classAt484[0x4EC - 0x484]; + u32 _4EC; + float _4F0, _4F4, _4F8; + u32 flags_4FC; + u16 counter_500, counter_502; + u16 counter_504[4]; + u16 counter_50C; + u32 _510, _514, _518; + void *_51C; + dEn_c *_520; + u32 _524, _528, _52C, _530; + + dEn_c(); + + int afterCreate(int); + int beforeExecute(int); + int afterExecute(int); + int beforeDraw(int); + + void kill(); + + void eatIn(); + void disableEatIn(); + bool _vf8C(void *other); // AcPy/PlBase? + void _vfAC(); + void _vfCC(Vec2 *p); + void _vfD0(Vec2 *p); + + void doStateChange(StateBase *state); // might return bool, dunno + + // Now here's where the fun starts. + + virtual bool preSpriteCollision(ActivePhysics *apThis, ActivePhysics *apOther); + virtual bool prePlayerCollision(ActivePhysics *apThis, ActivePhysics *apOther); + virtual bool preYoshiCollision(ActivePhysics *apThis, ActivePhysics *apOther); + + virtual bool stageActorCollision(ActivePhysics *apThis, ActivePhysics *apOther); + + virtual void spriteCollision(ActivePhysics *apThis, ActivePhysics *apOther); + virtual void playerCollision(ActivePhysics *apThis, ActivePhysics *apOther); + virtual void yoshiCollision(ActivePhysics *apThis, ActivePhysics *apOther); + + // WHAT A MESS + virtual void collisionCat3_StarPower(ActivePhysics *apThis, ActivePhysics *apOther); + virtual void collisionCat5_Mario(ActivePhysics *apThis, ActivePhysics *apOther); + virtual void _vf108(ActivePhysics *apThis, ActivePhysics *apOther); + virtual void collisionCatD_GroundPound(ActivePhysics *apThis, ActivePhysics *apOther); + virtual void _vf110(ActivePhysics *apThis, ActivePhysics *apOther); + virtual void collisionCat8_FencePunch(ActivePhysics *apThis, ActivePhysics *apOther); + virtual void collisionCat7_WMWaggleWater(ActivePhysics *apThis, ActivePhysics *apOther); + virtual void collisionCat7_WMWaggleWaterYoshi(ActivePhysics *apThis, ActivePhysics *apOther); + virtual void _vf120(ActivePhysics *apThis, ActivePhysics *apOther); + virtual void collisionCatA_PenguinMario(ActivePhysics *apThis, ActivePhysics *apOther); + virtual void collisionCat11_PipeCannon(ActivePhysics *apThis, ActivePhysics *apOther); + virtual void collisionCat9_RollingObject(ActivePhysics *apThis, ActivePhysics *apOther); + virtual void collisionCat1_Fireball_E_Explosion(ActivePhysics *apThis, ActivePhysics *apOther); + virtual void collisionCat2_IceBall_15_YoshiIce(ActivePhysics *apThis, ActivePhysics *apOther); + virtual void collisionCat13_Hammer(ActivePhysics *apThis, ActivePhysics *apOther); + virtual void collisionCat14_YoshiFire(ActivePhysics *apThis, ActivePhysics *apOther); + + virtual void _vf140(dStageActor_c *actor); + virtual void _vf144(int something); + virtual void _vf148(); // deletes actors held by Class484 and other stuff + virtual void _vf14C(); // deletes actors held by Class484 and makes an En Coin Jump + virtual u32 _vf150(); // reads some bits from a value in Class1EC + virtual void eatenByYoshiProbably(); // nullsub, params unknown + virtual void playHpdpSound1(); // plays PLAYER_SE_EMY/GROUP_BOOT/SE_EMY_DOWN_HPDP_S or _H + virtual void playEnemyDownSound1(); + virtual void playEnemyDownComboSound(void *player); // AcPy_c/daPlBase_c? + virtual void playHpdpSound2(); // plays PLAYER_SE_EMY/GROUP_BOOT/SE_EMY_DOWN_HPDP_S or _H + virtual void _vf168(); // nullsub, params unknown + + // State Functions + virtual void dieFumi_Begin(); // does something involving looping thruogh players + virtual void dieFumi_Execute(); // does movement and some other stuff + virtual void dieFumi_End(); // nullsub + virtual void dieFall_Begin(); // does something involving looping thruogh players + virtual void dieFall_Execute(); // does movement and some other stuff + virtual void dieFall_End(); // nullsub + virtual void dieBigFall_Begin(); // calls vf178 [dieFall_Begin] + virtual void dieBigFall_Execute(); // does movement and some other stuff (but less than 170 and 17C) + virtual void dieBigFall_End(); // calls vf180 [dieFall_End] + virtual void dieSmoke_Begin(); // spawns Wm_en_burst_m effect and then removeMyActivePhysics + virtual void dieSmoke_Execute(); // deletes actor with r4=1 + virtual void dieSmoke_End(); // nullsub + virtual void dieYoshiFumi_Begin(); // spawns Wm_mr_yoshistep effect and then removeMyActivePhysics + virtual void dieYoshiFumi_Execute(); // deletes actor with r4=1 + virtual void dieYoshiFumi_End(); // nullsub + virtual void dieIceVanish_Begin(); // lots of weird stuff + virtual void dieIceVanish_Execute(); // deletes actor with r4=1 + virtual void dieIceVanish_End(); // nullsub + virtual void dieGoal_Begin(); // nullsub + virtual void dieGoal_Execute(); // nullsub + virtual void dieGoal_End(); // nullsub + virtual void dieOther_Begin(); // deletes actor with r4=1 + virtual void dieOther_Execute(); // nullsub + virtual void dieOther_End(); // nullsub + virtual void eatIn_Begin(); // nullsub + virtual void eatIn_Execute(); // changes to EatNow on one condition, otherwise calls vfAC + virtual void eatIn_End(); // nullsub + virtual void eatNow_Begin(); // nullsub + virtual void eatNow_Execute(); // nullsub + virtual void eatNow_End(); // nullsub + virtual void eatOut_Begin(); // nullsub + virtual void eatOut_Execute(); // nullsub + virtual void eatOut_End(); // nullsub + virtual void hitSpin_Begin(); // nullsub + virtual void hitSpin_Execute(); // nullsub + virtual void hitSpin_End(); // nullsub + virtual void ice_Begin(); // does stuff with Class484 and lots of vf's + virtual void ice_Execute(); // tons of stuff with Class484 + virtual void ice_End(); // sets a field in Class484 to 0 + + virtual void spawnHitEffectAtPosition(Vec2 pos); + virtual void doSomethingWithHardHitAndSoftHitEffects(Vec pos); + virtual void playEnemyDownSound2(); + virtual void add2ToYSpeed(); + virtual bool _vf218(); // stuff with floats and camera + virtual void _vf21C(); // does stuff with the speeds + virtual void _vf220(void *other); // some type of actor, PlBase? calls vf3F4 on other with r4=this, r5=0 + virtual void _vf224(); // stores a couple of values into the struct at 464 + virtual void _vf228(); // more fun stuff with 464 and floats + virtual bool _vf22C(); // does stuff involving ICE_ACTORs and arrays + virtual void _vf230(); // "relatedToPlayerOrYoshiCollision" apparently. nullsub, params unknown for now. + virtual void _vf234(); // nullsub, params unknown + virtual void _vf238(); // calls vf34 on class394, params unknown + virtual void _vf23C(); // nullsub, params unknown + virtual void _vf240(); // nullsub, params unknown + virtual int _vf244(); // returns 0. might be bool. params unknown + virtual int _vf248(int something); // does some math involving field510 and [7,7,4,0] and param + virtual void _vf24C(void *other); // deals with something in the class involving the bahp flag + virtual void _vf250(void *other); + virtual void _vf254(void *other); + virtual void _vf258(void *other); + virtual void _vf25C(void *other); // calls vf250 + virtual void _vf260(void *other); // AcPy/PlBase? plays the SE_EMY_FUMU_%d sounds based on some value + virtual void _vf264(dStageActor_c *other); // if other is player or yoshi, do Wm_en_hit and a few other things + virtual void _vf268(void *other); // AcPy/PlBase? plays the SE_EMY_DOWN_SPIN_%d sounds based on some value + virtual void spawnHitEffectAtPositionAgain(Vec2 pos); + virtual void playMameStepSound(); // SE_EMY_MAME_STEP at actor position + virtual void _vf274(); // nullsub, params unknown + virtual void _vf278(void *other); // AcPy/PlBase? plays the SE_EMY_YOSHI_FUMU_%d sounds based on some value + virtual void _vf27C(); // nullsub, params unknown + + ~dEn_c(); }; -
-
-/* TODO
-class dActorState_c : public dStageActor_c {
-public:
- ~dActorState_c();
-
- virtual void _vfD4();
- virtual void _vfD8();
- virtual void _vfDC();
-};
-*/
-
-
-class dActorMultiState_c : public dStageActor_c {
-public:
- ~dActorMultiState_c();
-
- MultiStateMgr acState;
-
- virtual void doStateChange(StateBase *state); // might return bool? overridden by dEn_c
- virtual void _vfD8(); // nullsub ??
- virtual void _vfDC(); // nullsub ??
- virtual void _vfE0(); // nullsub ??
-};
-
-
-class dEn_c : public dActorMultiState_c {
-public:
- float _414, _418, _41C, _420;
- void *nextState;
- u32 _428, _42C;
- u8 _430, _431, isDead;
- u32 _434;
- u16 _438;
- u32 _43C;
- Vec velocity1, velocity2;
- u8 _458, _459, _45A, _45B, _45C, _45D, _45E;
- u32 _460;
- Vec initialScale;
- float _470;
- u32 _474, _478;
- dEn_c *_47C;
- u32 _480;
- u8 classAt484[0x4EC - 0x484];
- u32 _4EC;
- float _4F0, _4F4, _4F8;
- u32 flags_4FC;
- u16 counter_500, counter_502;
- u16 counter_504[4];
- u16 counter_50C;
- u32 _510, _514, _518;
- void *_51C;
- dEn_c *_520;
- u32 _524, _528, _52C, _530;
-
- dEn_c();
-
- int afterCreate(int);
- int beforeExecute(int);
- int afterExecute(int);
- int beforeDraw(int);
-
- void kill();
-
- void eatIn();
- void disableEatIn();
- bool _vf8C(void *other); // AcPy/PlBase?
- void _vfAC();
- void _vfCC(Vec2 *p);
- void _vfD0(Vec2 *p);
-
- void doStateChange(StateBase *state); // might return bool, dunno
-
- // Now here's where the fun starts.
-
- virtual bool preSpriteCollision(ActivePhysics *apThis, ActivePhysics *apOther);
- virtual bool prePlayerCollision(ActivePhysics *apThis, ActivePhysics *apOther);
- virtual bool preYoshiCollision(ActivePhysics *apThis, ActivePhysics *apOther);
-
- virtual bool stageActorCollision(ActivePhysics *apThis, ActivePhysics *apOther);
-
- virtual void spriteCollision(ActivePhysics *apThis, ActivePhysics *apOther);
- virtual void playerCollision(ActivePhysics *apThis, ActivePhysics *apOther);
- virtual void yoshiCollision(ActivePhysics *apThis, ActivePhysics *apOther);
-
- // WHAT A MESS
- virtual void collisionCat3_StarPower(ActivePhysics *apThis, ActivePhysics *apOther);
- virtual void collisionCat5_Mario(ActivePhysics *apThis, ActivePhysics *apOther);
- virtual void _vf108(ActivePhysics *apThis, ActivePhysics *apOther);
- virtual void collisionCatD_GroundPound(ActivePhysics *apThis, ActivePhysics *apOther);
- virtual void _vf110(ActivePhysics *apThis, ActivePhysics *apOther);
- virtual void collisionCat8_FencePunch(ActivePhysics *apThis, ActivePhysics *apOther);
- virtual void collisionCat7_WMWaggleWater(ActivePhysics *apThis, ActivePhysics *apOther);
- virtual void collisionCat7_WMWaggleWaterYoshi(ActivePhysics *apThis, ActivePhysics *apOther);
- virtual void _vf120(ActivePhysics *apThis, ActivePhysics *apOther);
- virtual void collisionCatA_PenguinMario(ActivePhysics *apThis, ActivePhysics *apOther);
- virtual void collisionCat11_PipeCannon(ActivePhysics *apThis, ActivePhysics *apOther);
- virtual void collisionCat9_RollingObject(ActivePhysics *apThis, ActivePhysics *apOther);
- virtual void collisionCat1_Fireball_E_Explosion(ActivePhysics *apThis, ActivePhysics *apOther);
- virtual void collisionCat2_IceBall_15_YoshiIce(ActivePhysics *apThis, ActivePhysics *apOther);
- virtual void collisionCat13_Hammer(ActivePhysics *apThis, ActivePhysics *apOther);
- virtual void collisionCat14_YoshiFire(ActivePhysics *apThis, ActivePhysics *apOther);
-
- virtual void _vf140(dStageActor_c *actor);
- virtual void _vf144(int something);
- virtual void _vf148(); // deletes actors held by Class484 and other stuff
- virtual void _vf14C(); // deletes actors held by Class484 and makes an En Coin Jump
- virtual u32 _vf150(); // reads some bits from a value in Class1EC
- virtual void eatenByYoshiProbably(); // nullsub, params unknown
- virtual void playHpdpSound1(); // plays PLAYER_SE_EMY/GROUP_BOOT/SE_EMY_DOWN_HPDP_S or _H
- virtual void playEnemyDownSound1();
- virtual void playEnemyDownComboSound(void *player); // AcPy_c/daPlBase_c?
- virtual void playHpdpSound2(); // plays PLAYER_SE_EMY/GROUP_BOOT/SE_EMY_DOWN_HPDP_S or _H
- virtual void _vf168(); // nullsub, params unknown
-
- // State Functions
- virtual void dieFumi_Begin(); // does something involving looping thruogh players
- virtual void dieFumi_Execute(); // does movement and some other stuff
- virtual void dieFumi_End(); // nullsub
- virtual void dieFall_Begin(); // does something involving looping thruogh players
- virtual void dieFall_Execute(); // does movement and some other stuff
- virtual void dieFall_End(); // nullsub
- virtual void dieBigFall_Begin(); // calls vf178 [dieFall_Begin]
- virtual void dieBigFall_Execute(); // does movement and some other stuff (but less than 170 and 17C)
- virtual void dieBigFall_End(); // calls vf180 [dieFall_End]
- virtual void dieSmoke_Begin(); // spawns Wm_en_burst_m effect and then removeMyActivePhysics
- virtual void dieSmoke_Execute(); // deletes actor with r4=1
- virtual void dieSmoke_End(); // nullsub
- virtual void dieYoshiFumi_Begin(); // spawns Wm_mr_yoshistep effect and then removeMyActivePhysics
- virtual void dieYoshiFumi_Execute(); // deletes actor with r4=1
- virtual void dieYoshiFumi_End(); // nullsub
- virtual void dieIceVanish_Begin(); // lots of weird stuff
- virtual void dieIceVanish_Execute(); // deletes actor with r4=1
- virtual void dieIceVanish_End(); // nullsub
- virtual void dieGoal_Begin(); // nullsub
- virtual void dieGoal_Execute(); // nullsub
- virtual void dieGoal_End(); // nullsub
- virtual void dieOther_Begin(); // deletes actor with r4=1
- virtual void dieOther_Execute(); // nullsub
- virtual void dieOther_End(); // nullsub
- virtual void eatIn_Begin(); // nullsub
- virtual void eatIn_Execute(); // changes to EatNow on one condition, otherwise calls vfAC
- virtual void eatIn_End(); // nullsub
- virtual void eatNow_Begin(); // nullsub
- virtual void eatNow_Execute(); // nullsub
- virtual void eatNow_End(); // nullsub
- virtual void eatOut_Begin(); // nullsub
- virtual void eatOut_Execute(); // nullsub
- virtual void eatOut_End(); // nullsub
- virtual void hitSpin_Begin(); // nullsub
- virtual void hitSpin_Execute(); // nullsub
- virtual void hitSpin_End(); // nullsub
- virtual void ice_Begin(); // does stuff with Class484 and lots of vf's
- virtual void ice_Execute(); // tons of stuff with Class484
- virtual void ice_End(); // sets a field in Class484 to 0
-
- virtual void spawnHitEffectAtPosition(Vec2 pos);
- virtual void doSomethingWithHardHitAndSoftHitEffects(Vec pos);
- virtual void playEnemyDownSound2();
- virtual void add2ToYSpeed();
- virtual bool _vf218(); // stuff with floats and camera
- virtual void _vf21C(); // does stuff with the speeds
- virtual void _vf220(void *other); // some type of actor, PlBase? calls vf3F4 on other with r4=this, r5=0
- virtual void _vf224(); // stores a couple of values into the struct at 464
- virtual void _vf228(); // more fun stuff with 464 and floats
- virtual bool _vf22C(); // does stuff involving ICE_ACTORs and arrays
- virtual void _vf230(); // "relatedToPlayerOrYoshiCollision" apparently. nullsub, params unknown for now.
- virtual void _vf234(); // nullsub, params unknown
- virtual void _vf238(); // calls vf34 on class394, params unknown
- virtual void _vf23C(); // nullsub, params unknown
- virtual void _vf240(); // nullsub, params unknown
- virtual int _vf244(); // returns 0. might be bool. params unknown
- virtual int _vf248(int something); // does some math involving field510 and [7,7,4,0] and param
- virtual void _vf24C(void *other); // deals with something in the class involving the bahp flag
- virtual void _vf250(void *other);
- virtual void _vf254(void *other);
- virtual void _vf258(void *other);
- virtual void _vf25C(void *other); // calls vf250
- virtual void _vf260(void *other); // AcPy/PlBase? plays the SE_EMY_FUMU_%d sounds based on some value
- virtual void _vf264(dStageActor_c *other); // if other is player or yoshi, do Wm_en_hit and a few other things
- virtual void _vf268(void *other); // AcPy/PlBase? plays the SE_EMY_DOWN_SPIN_%d sounds based on some value
- virtual void spawnHitEffectAtPositionAgain(Vec2 pos);
- virtual void playMameStepSound(); // SE_EMY_MAME_STEP at actor position
- virtual void _vf274(); // nullsub, params unknown
- virtual void _vf278(void *other); // AcPy/PlBase? plays the SE_EMY_YOSHI_FUMU_%d sounds based on some value
- virtual void _vf27C(); // nullsub, params unknown
-
- ~dEn_c();
-};
-
-
-class daEnBlockMain_c : public dEn_c {
-public:
- Physics physics;
- float _618, _61C, _620;
- u32 _624, _628, _62C;
- float initialY;
- float _634, _638, _63C, _640;
- u32 countdown, _648, _64C;
- u32 _650, _654, _658, _65C;
- u16 _660;
- u8 _662, _663, _664, _665, _666, _667;
- u8 _668, _669, _66A, _66B, _66C, _66D, _66E, _66F;
- u8 _670, _671, _672, _673;
- u8 _674;
- u8 _675, _676, _677, _678, _679, _67A, _67B, _67C;
- u8 _67D, _67E, _67F, _680;
- u32 _684;
- u8 _688, isGroundPound, anotherFlag, _68B, _68C, _68D, _68E, _68F;
- u32 _690;
- u8 _694;
-
- // Regular methods
- void blockInit(float initialY);
- void blockUpdate();
- u8 blockResult();
-
- virtual void calledWhenUpMoveBegins();
- virtual void calledWhenDownMoveBegins();
-
- virtual void calledWhenUpMoveExecutes();
- virtual void calledWhenUpMoveDiffExecutes();
- virtual void calledWhenDownMoveExecutes();
- virtual void calledWhenDownMoveEndExecutes();
- virtual void calledWhenDownMoveDiffExecutes();
- virtual void calledWhenDownMoveDiffEndExecutes();
-
- virtual void updateScale(bool movingDown);
-
- // State functions
- virtual void upMove_Begin();
- virtual void upMove_Execute();
- virtual void upMove_End();
- virtual void downMove_Begin();
- virtual void downMove_Execute();
- virtual void downMove_End();
- virtual void downMoveEnd_Begin();
- virtual void downMoveEnd_Execute();
- virtual void downMoveEnd_End();
- virtual void upMove_Diff_Begin();
- virtual void upMove_Diff_Execute();
- virtual void upMove_Diff_End();
- virtual void downMove_Diff_Begin();
- virtual void downMove_Diff_Execute();
- virtual void downMove_Diff_End();
- virtual void downMove_DiffEnd_Begin();
- virtual void downMove_DiffEnd_Execute();
- virtual void downMove_DiffEnd_End();
-
- static void *PhysicsCallback1;
- static void *PhysicsCallback2;
- static void *PhysicsCallback3;
- static void *OPhysicsCallback1;
- static void *OPhysicsCallback2;
- static void *OPhysicsCallback3;
-
- static State<daEnBlockMain_c> StateID_UpMove;
- static State<daEnBlockMain_c> StateID_DownMove;
- static State<daEnBlockMain_c> StateID_DownMoveEnd;
- static State<daEnBlockMain_c> StateID_UpMove_Diff;
- static State<daEnBlockMain_c> StateID_DownMove_Diff;
- static State<daEnBlockMain_c> StateID_DownMove_DiffEnd;
-
- ~daEnBlockMain_c();
-};
-
-
-class dBgGm_c {
-public:
- // TODO TODO TODO TODO TODO
- static dBgGm_c *instance;
-
- TileRenderer::List *getTileRendererList(int index);
-};
-
-
-class dPlayerModelBase_c {
- // dunno what's public and what's private here
- // don't really care
-public:
- dPlayerModelBase_c(u8 player_id); // 800D5420
- virtual ~dPlayerModelBase_c(); // 800D55D0
-
- char allocator[28]; // actually a mHeapAllocatorSubclass but I don't have that
- u32 _20;
- u32 _24;
- char someAnimation[2][0x38]; // actually PlayerAnim's
- char yetAnotherAnimation[40]; // actually m3d::banm_c afaics -- is it even 40 bytes?
- Vec someVector[2]; // maybe not an array
- Vec headOffs;
- Vec scale;
- u8 player_id_1;
- u8 player_id_2;
- u8 powerup_id;
- u8 powerup_tex;
- int current_anim;
- int last_anim_maybe;
- u32 _15C;
- int someFlags;
- u32 _164;
- u32 _168; // related to jump_strings
- u32 _16C;
- u32 _170;
- u32 _174;
- u8 _178;
- char padding[3]; // not needed?
- u32 model_visibility_flags_maybe;
- u32 mode_maybe;
- float _184;
- float _188;
- u32 _18C;
- char someArray[6][12]; // some unknown class/struct
- char _1D8[0x24];
- short _1FC;
- short _1FE;
- short _200;
- char padding_[2]; // not needed?
- u32 _204;
- u32 _208;
-
- virtual int _vf0C(); // 800D6DA0
- virtual void prepare(); // 800D5720
- virtual void finaliseModel(); // 800D5740
- virtual void update(); // 800D5750
- virtual void update3DStuff(); // 800D5760
- virtual void _vf20(); // 800D6D90
- virtual void draw(); // 800D5C70
- virtual int getCurrentModel(); // 800D5870
- virtual int getCurrentResFile(); // 800D62D0
- virtual void setPowerup(u8 powerup_id); // 800D5730
- virtual void setPowerupTexture(); // 800D5CC0
- virtual void _vf38(); // 800D6D80
- virtual void _vf3C(); // 800BD750
- virtual void _vf40(); // 800D6D70
- virtual void _vf44(); // 800D6D60
- virtual void _vf48(); // 800BD740
- virtual void _vf4C(); // 800BD730
- virtual void getModelMatrix(u32 unk, MtxPtr dest); // 800D5820
- virtual int _vf54(); // 80318D0C
- virtual bool _vf58(int type, char *buf, bool unk); // 800D6930
- virtual void startAnimation(int id, float frame, float unk, float updateRate); // 800D5EC0
- virtual int _vf60(); // 800D6920
- virtual void _vf64(int id, float unk1, float unk2, float unk3); // 800D62F0
- virtual void _vf68(int id, float unk); // 800D63E0
- virtual void _vf6C(); // 800D62E0
- virtual void _vf70(); // 800D6690
- virtual void _vf74(); // 800D66A0
- virtual void _vf78(); // 800D66B0
- virtual void SomethingRelatedToPenguinAnims(); // 800D66C0
- virtual void _vf80(); // 800D6A20
- virtual void _vf84(float frame); // 800D5D00
- virtual void _vf88(float frame); // 800D5D70
- virtual void _vf8C(float updateRate); // 800D5D80
- virtual void setUpdateRateForAnim1(float updateRate); // 800D5DF0
- virtual void _vf94(); // 800D6D40
- virtual int _vf98(); // 800D6D30
- virtual void _vf9C(); // 800D6D20
- virtual int _vfA0(); // 800D6D10
- virtual void _vfA4(); // 800D6D00
- virtual int _vfA8(); // 800D6CF0
- virtual void _vfAC(bool blah); // 800BD720
-
- // I won't even bother with non-virtual functions....
-};
-
-
-class dPlayerModelHandler_c {
-public:
- dPlayerModelHandler_c(u8 player_id); // 800D6DB0
- virtual ~dPlayerModelHandler_c(); // 800D6EF0
-
- dPlayerModelBase_c *mdlClass; // might be dPlayerModel_c ?
-
- int loadModel(u8 player_id, int powerup_id, int unk); // 800D6EE0
- void update(); // 800D6F80
- void setMatrix(Mtx matrix); // 800D6FA0
- void setSRT(Vec position, S16Vec rotation, Vec scale); // 800D7030
- void callVF20(); // 800D70F0
- void draw(); // 800D7110
-
-private:
- int hasMatrix; // might be bool ?
-
- void allocPlayerClass(u8 player_id); // 800D6E00
-};
-
-
-class mTexture_c {
-public:
- mTexture_c(); // 802C0D20
- mTexture_c(u16 width, u16 height, GXTexFmt format); // 802C0D70
-
- // vtable is at 80350450
- virtual ~mTexture_c(); // 802C0DB0
- virtual void setFlagTo1(); // 802C0E20
-
- void setImageBuffer(void *buffer); // 802C0E30
- void load(GXTexMapID id); // 802C0E50
- void makeTexObj(GXTexObj *obj); // 802C0E90
- void flushDC(); // 802C0F10
-
- void makeRadialGradient(); // 802C0F60 parameters unknown yet
- void makeLinearGradient(int type, char size, u16 startPos, u16 endPos,
- GXColor begin, GXColor end, bool startAtCenter); // 802C1120
- // "type" should be enum once I figure it out
- // reverse might not be accurate
-
- void allocateBuffer(/* EGG::Heap */void *heap = 0); // 802C14D0
-
- void plotPixel(u16 x, u16 y, GXColor pixel); // 802C1570
-
-
- u16 width;
- u16 height;
- u8 flags;
- u8 format;
- u8 wrapS;
- u8 wrapT;
- u8 minFilter;
- u8 magFilter;
-
-private:
- void *buffer;
- void *myBuffer;
-};
-
-
-class dDvdLoader_c {
-public:
- dDvdLoader_c(); // 8008F140
- virtual ~dDvdLoader_c(); // 8008F170
-
- void *load(const char *filename, u8 unk = 0, void *heap = 0); // 8008F1B0
-
- bool close(); // 8008F2B0 -- Frees command, DON'T USE THIS unless you free the buffer yourself
- bool unload(); // 8008F310 -- Frees command and buffer, USE THIS
-
- int size;
- void *command; // really mDvd_toMainRam_c
- void *heap; // really EGG::Heap
- void *buffer;
-
-private:
- virtual void freeBuffer(); // 8008F380
- void freeCommand(); // 8008F3F0
-};
-
-
-
-namespace nw4r {
- namespace ut {
- class CharWriter {
- public:
- CharWriter();
- ~CharWriter();
-
- void SetupGX();
-
- void SetFontSize(float w, float h);
- void SetFontSize(float v);
- float GetFontWidth() const;
- float GetFontHeight() const;
- float GetFontAscent() const;
- float GetFontDescent() const;
-
- // returns width
- float Print(ushort character);
-
- void PrintGlyph(float, float, float, /* nw4r::ut::Glyph const & */ void*);
-
- void UpdateVertexColor();
-
- private:
- void SetupGXWithColorMapping(Color c1, Color c2);
-
- public:
- Color colors[8]; // todo: document
- u32 modeOfSomeKind;
- float scaleX;
- float scaleY;
- float posX;
- float posY;
- float posZ;
- GXTexFilter minFilt;
- GXTexFilter magFilt;
- u16 completelyUnknown;
- u8 alpha;
- u8 isFixedWidth;
- float fixedWidthValue;
- /* ResFont* */ void *font;
- };
-
- // actually TextWriterBase<w>, but ...
- class TextWriter : public CharWriter {
- public:
- TextWriter();
- ~TextWriter();
-
- float GetLineHeight() const;
-
- // left out most of these to avoid all the format string vararg bullshit
- float CalcStringWidth(wchar_t const *string, int length) const;
-
- float Print(wchar_t const *string, int length);
-
- float CalcLineWidth(wchar_t const *string, int length);
-
- float GetLineSpace() const;
-
- bool IsDrawFlagSet(ulong, ulong) const;
-
- float _4C;
- float charSpace;
- float somethingRelatedToLineHeight;
- u32 _58;
- u32 drawFlag;
- void *tagProcessorMaybe;
- };
- }
-}
-
-// More layout crap
-// This file REALLY needs to be reorganised.
-
-namespace nw4r {
-namespace lyt {
-
- class ResourceAccessor {
- public:
- ResourceAccessor();
- virtual ~ResourceAccessor();
-
- virtual void *GetResource(u32 dirKey, const char *filename, u32 *sizePtr) = 0;
- virtual void *GetFont(const char *name);
- };
-
- class ArcResourceAccessor : public ResourceAccessor {
- public:
- ArcResourceAccessor();
- ~ArcResourceAccessor();
-
- bool Attach(void *data, const char *rootDirName);
- void *GetResource(u32 dirKey, const char *filename, u32 *sizePtr);
- void *GetFont(const char *name);
-
- ARCHandle arc;
- u32 unk_20;
- ut::LinkList list; // 0x24
- char rootDirName[0x80]; // 0x30
- // class ends at 0xB0
- };
-
-}
-}
-
-namespace m2d {
- class ResAcc_c {
- public:
- ResAcc_c();
- virtual ~ResAcc_c();
- virtual void initialSetup();
-
- nw4r::lyt::ResourceAccessor *resAccPtr; // 0x04
- u32 unk_08; // 0x08
- nw4r::lyt::ArcResourceAccessor resAcc; // 0x0C
- // class ends at 0xBC
- };
-
- class ResAccLoader_c : public ResAcc_c {
- public:
- ResAccLoader_c();
- ~ResAccLoader_c();
-
- void *buffer;
- dDvdLoader_c loader; // 0xC0
- // ends at 0xD4
-
- bool loadArc(const char *path);
- bool loadArc(const char *path, u8 unk);
- void free();
- };
-
- class EmbedLayoutBase_c : public Base_c {
- public:
- EmbedLayoutBase_c();
- ~EmbedLayoutBase_c();
-
- void draw(); // don't call this directly
-
- virtual void update();
- virtual bool build(const char *brlytPath, ResAcc_c *resAcc = 0);
-
- nw4r::lyt::Pane *getRootPane();
- nw4r::lyt::Pane *findPaneByName(const char *name) const;
- nw4r::lyt::TextBox *findTextBoxByName(const char *name) const;
- nw4r::lyt::Pane *findPictureByName(const char *name) const; // TODO: change to others
- nw4r::lyt::Pane *findWindowByName(const char *name) const;
-
- void animate();
- void calculateMtx();
-
- nw4r::lyt::Layout layout; // 0x10 -- actually m2d::Layout_c but I'll add that later
- nw4r::lyt::DrawInfo drawInfo; // 0x30
- void *unk_84; // 0x84 -- a ResAcc? referenced in Build()
- float posX; // 0x88
- float posY; // 0x8C
- float clipX; // 0x90
- float clipY; // 0x94
- float clipWidth; // 0x98
- float clipHeight; // 0x9C
- bool clippingEnabled; // 0xA0
- u32 hasAnimations; // 0xA4
- u32 unk_A8; // 0xA8
- };
-
- class EmbedLayout_c : public EmbedLayoutBase_c {
- public:
- EmbedLayout_c();
- ~EmbedLayout_c();
-
- bool build(const char *brlytPath, ResAcc_c *resAcc = 0);
-
- bool loadArc(const char *name, bool isLangSpecific);
- bool loadArc(const char *name, u8 unk, bool isLangSpecific);
-
- bool loadArcForRegion(const char *name); // uses EU/Layout/$name
-
- // there's also a NedEU one, but should it really be listed here...?
-
- bool free();
-
- // does NSMBW even use consts? I have no idea. maybe not
-
- void getPanes(const char **names, nw4r::lyt::Pane *output, int count) const;
- void getWindows(const char **names, nw4r::lyt::Pane *output, int count) const; // TODO: change to others
- void getPictures(const char **names, nw4r::lyt::Pane *output, int count) const;
- void getTextBoxes(const char **names, nw4r::lyt::TextBox *output, int count) const;
-
- void setLangStrings(const char **names, const int *msgIDs, int category, int count);
-
- void loadAnimations(const char **names, int count);
- void loadGroups(const char **names, int *animLinkIDs, int count);
-
- void enableNonLoopAnim(int num, bool goToLastFrame = false);
- void enableLoopAnim(int num);
- void resetAnim(int num, bool goToLastFrame = false);
- void disableAnim(int num);
- void disableAllAnimations();
-
- bool isAnimOn(int num = -1);
- bool isAnyAnimOn();
-
- void execAnimations();
-
- ResAccLoader_c loader; // 0xAC
- void *brlanHandlers; // 0x180
- void *grpHandlers; // 0x184
- bool *animsEnabled; // 0x188
- int brlanCount; // 0x18C
- int grpCount; // 0x190
- int lastAnimTouched; // 0x194
-
- private:
- void fixTextBoxesRecursively(nw4r::lyt::Pane *pane);
- };
-}
-
-
-#endif
-
+ + +class daEnBlockMain_c : public dEn_c { +public: + Physics physics; + float _618, _61C, _620; + u32 _624, _628, _62C; + float initialY; + float _634, _638, _63C, _640; + u32 countdown, _648, _64C; + u32 _650, _654, _658, _65C; + u16 _660; + u8 _662, _663, _664, _665, _666, _667; + u8 _668, _669, _66A, _66B, _66C, _66D, _66E, _66F; + u8 _670, _671, _672, _673; + u8 _674; + u8 _675, _676, _677, _678, _679, _67A, _67B, _67C; + u8 _67D, _67E, _67F, _680; + u32 _684; + u8 _688, isGroundPound, anotherFlag, _68B, _68C, _68D, _68E, _68F; + u32 _690; + u8 _694; + + // Regular methods + void blockInit(float initialY); + void blockUpdate(); + u8 blockResult(); + + virtual void calledWhenUpMoveBegins(); + virtual void calledWhenDownMoveBegins(); + + virtual void calledWhenUpMoveExecutes(); + virtual void calledWhenUpMoveDiffExecutes(); + virtual void calledWhenDownMoveExecutes(); + virtual void calledWhenDownMoveEndExecutes(); + virtual void calledWhenDownMoveDiffExecutes(); + virtual void calledWhenDownMoveDiffEndExecutes(); + + virtual void updateScale(bool movingDown); + + // State functions + virtual void upMove_Begin(); + virtual void upMove_Execute(); + virtual void upMove_End(); + virtual void downMove_Begin(); + virtual void downMove_Execute(); + virtual void downMove_End(); + virtual void downMoveEnd_Begin(); + virtual void downMoveEnd_Execute(); + virtual void downMoveEnd_End(); + virtual void upMove_Diff_Begin(); + virtual void upMove_Diff_Execute(); + virtual void upMove_Diff_End(); + virtual void downMove_Diff_Begin(); + virtual void downMove_Diff_Execute(); + virtual void downMove_Diff_End(); + virtual void downMove_DiffEnd_Begin(); + virtual void downMove_DiffEnd_Execute(); + virtual void downMove_DiffEnd_End(); + + static void *PhysicsCallback1; + static void *PhysicsCallback2; + static void *PhysicsCallback3; + static void *OPhysicsCallback1; + static void *OPhysicsCallback2; + static void *OPhysicsCallback3; + + static State<daEnBlockMain_c> StateID_UpMove; + static State<daEnBlockMain_c> StateID_DownMove; + static State<daEnBlockMain_c> StateID_DownMoveEnd; + static State<daEnBlockMain_c> StateID_UpMove_Diff; + static State<daEnBlockMain_c> StateID_DownMove_Diff; + static State<daEnBlockMain_c> StateID_DownMove_DiffEnd; + + ~daEnBlockMain_c(); +}; + + +class dBgGm_c { +public: + // TODO TODO TODO TODO TODO + static dBgGm_c *instance; + + TileRenderer::List *getTileRendererList(int index); +}; + + +class dPlayerModelBase_c { + // dunno what's public and what's private here + // don't really care +public: + dPlayerModelBase_c(u8 player_id); // 800D5420 + virtual ~dPlayerModelBase_c(); // 800D55D0 + + char allocator[28]; // actually a mHeapAllocatorSubclass but I don't have that + u32 _20; + u32 _24; + char someAnimation[2][0x38]; // actually PlayerAnim's + char yetAnotherAnimation[40]; // actually m3d::banm_c afaics -- is it even 40 bytes? + Vec someVector[2]; // maybe not an array + Vec headOffs; + Vec scale; + u8 player_id_1; + u8 player_id_2; + u8 powerup_id; + u8 powerup_tex; + int current_anim; + int last_anim_maybe; + u32 _15C; + int someFlags; + u32 _164; + u32 _168; // related to jump_strings + u32 _16C; + u32 _170; + u32 _174; + u8 _178; + char padding[3]; // not needed? + u32 model_visibility_flags_maybe; + u32 mode_maybe; + float _184; + float _188; + u32 _18C; + char someArray[6][12]; // some unknown class/struct + char _1D8[0x24]; + short _1FC; + short _1FE; + short _200; + char padding_[2]; // not needed? + u32 _204; + u32 _208; + + virtual int _vf0C(); // 800D6DA0 + virtual void prepare(); // 800D5720 + virtual void finaliseModel(); // 800D5740 + virtual void update(); // 800D5750 + virtual void update3DStuff(); // 800D5760 + virtual void _vf20(); // 800D6D90 + virtual void draw(); // 800D5C70 + virtual int getCurrentModel(); // 800D5870 + virtual int getCurrentResFile(); // 800D62D0 + virtual void setPowerup(u8 powerup_id); // 800D5730 + virtual void setPowerupTexture(); // 800D5CC0 + virtual void _vf38(); // 800D6D80 + virtual void _vf3C(); // 800BD750 + virtual void _vf40(); // 800D6D70 + virtual void _vf44(); // 800D6D60 + virtual void _vf48(); // 800BD740 + virtual void _vf4C(); // 800BD730 + virtual void getModelMatrix(u32 unk, MtxPtr dest); // 800D5820 + virtual int _vf54(); // 80318D0C + virtual bool _vf58(int type, char *buf, bool unk); // 800D6930 + virtual void startAnimation(int id, float frame, float unk, float updateRate); // 800D5EC0 + virtual int _vf60(); // 800D6920 + virtual void _vf64(int id, float unk1, float unk2, float unk3); // 800D62F0 + virtual void _vf68(int id, float unk); // 800D63E0 + virtual void _vf6C(); // 800D62E0 + virtual void _vf70(); // 800D6690 + virtual void _vf74(); // 800D66A0 + virtual void _vf78(); // 800D66B0 + virtual void SomethingRelatedToPenguinAnims(); // 800D66C0 + virtual void _vf80(); // 800D6A20 + virtual void _vf84(float frame); // 800D5D00 + virtual void _vf88(float frame); // 800D5D70 + virtual void _vf8C(float updateRate); // 800D5D80 + virtual void setUpdateRateForAnim1(float updateRate); // 800D5DF0 + virtual void _vf94(); // 800D6D40 + virtual int _vf98(); // 800D6D30 + virtual void _vf9C(); // 800D6D20 + virtual int _vfA0(); // 800D6D10 + virtual void _vfA4(); // 800D6D00 + virtual int _vfA8(); // 800D6CF0 + virtual void _vfAC(bool blah); // 800BD720 + + // I won't even bother with non-virtual functions.... +}; + + +class dPlayerModelHandler_c { +public: + dPlayerModelHandler_c(u8 player_id); // 800D6DB0 + virtual ~dPlayerModelHandler_c(); // 800D6EF0 + + dPlayerModelBase_c *mdlClass; // might be dPlayerModel_c ? + + int loadModel(u8 player_id, int powerup_id, int unk); // 800D6EE0 + void update(); // 800D6F80 + void setMatrix(Mtx matrix); // 800D6FA0 + void setSRT(Vec position, S16Vec rotation, Vec scale); // 800D7030 + void callVF20(); // 800D70F0 + void draw(); // 800D7110 + +private: + int hasMatrix; // might be bool ? + + void allocPlayerClass(u8 player_id); // 800D6E00 +}; + + +class mTexture_c { +public: + mTexture_c(); // 802C0D20 + mTexture_c(u16 width, u16 height, GXTexFmt format); // 802C0D70 + + // vtable is at 80350450 + virtual ~mTexture_c(); // 802C0DB0 + virtual void setFlagTo1(); // 802C0E20 + + void setImageBuffer(void *buffer); // 802C0E30 + void load(GXTexMapID id); // 802C0E50 + void makeTexObj(GXTexObj *obj); // 802C0E90 + void flushDC(); // 802C0F10 + + void makeRadialGradient(); // 802C0F60 parameters unknown yet + void makeLinearGradient(int type, char size, u16 startPos, u16 endPos, + GXColor begin, GXColor end, bool startAtCenter); // 802C1120 + // "type" should be enum once I figure it out + // reverse might not be accurate + + void allocateBuffer(/* EGG::Heap */void *heap = 0); // 802C14D0 + + void plotPixel(u16 x, u16 y, GXColor pixel); // 802C1570 + + + u16 width; + u16 height; + u8 flags; + u8 format; + u8 wrapS; + u8 wrapT; + u8 minFilter; + u8 magFilter; + +private: + void *buffer; + void *myBuffer; +}; + + +class dDvdLoader_c { +public: + dDvdLoader_c(); // 8008F140 + virtual ~dDvdLoader_c(); // 8008F170 + + void *load(const char *filename, u8 unk = 0, void *heap = 0); // 8008F1B0 + + bool close(); // 8008F2B0 -- Frees command, DON'T USE THIS unless you free the buffer yourself + bool unload(); // 8008F310 -- Frees command and buffer, USE THIS + + int size; + void *command; // really mDvd_toMainRam_c + void *heap; // really EGG::Heap + void *buffer; + +private: + virtual void freeBuffer(); // 8008F380 + void freeCommand(); // 8008F3F0 +}; + + + +namespace nw4r { + namespace ut { + class CharWriter { + public: + CharWriter(); + ~CharWriter(); + + void SetupGX(); + + void SetFontSize(float w, float h); + void SetFontSize(float v); + float GetFontWidth() const; + float GetFontHeight() const; + float GetFontAscent() const; + float GetFontDescent() const; + + // returns width + float Print(ushort character); + + void PrintGlyph(float, float, float, /* nw4r::ut::Glyph const & */ void*); + + void UpdateVertexColor(); + + private: + void SetupGXWithColorMapping(Color c1, Color c2); + + public: + Color colors[8]; // todo: document + u32 modeOfSomeKind; + float scaleX; + float scaleY; + float posX; + float posY; + float posZ; + GXTexFilter minFilt; + GXTexFilter magFilt; + u16 completelyUnknown; + u8 alpha; + u8 isFixedWidth; + float fixedWidthValue; + /* ResFont* */ void *font; + }; + + // actually TextWriterBase<w>, but ... + class TextWriter : public CharWriter { + public: + TextWriter(); + ~TextWriter(); + + float GetLineHeight() const; + + // left out most of these to avoid all the format string vararg bullshit + float CalcStringWidth(wchar_t const *string, int length) const; + + float Print(wchar_t const *string, int length); + + float CalcLineWidth(wchar_t const *string, int length); + + float GetLineSpace() const; + + bool IsDrawFlagSet(ulong, ulong) const; + + float _4C; + float charSpace; + float somethingRelatedToLineHeight; + u32 _58; + u32 drawFlag; + void *tagProcessorMaybe; + }; + } +} + +// More layout crap +// This file REALLY needs to be reorganised. + +namespace nw4r { +namespace lyt { + + class ResourceAccessor { + public: + ResourceAccessor(); + virtual ~ResourceAccessor(); + + virtual void *GetResource(u32 dirKey, const char *filename, u32 *sizePtr) = 0; + virtual void *GetFont(const char *name); + }; + + class ArcResourceAccessor : public ResourceAccessor { + public: + ArcResourceAccessor(); + ~ArcResourceAccessor(); + + bool Attach(void *data, const char *rootDirName); + void *GetResource(u32 dirKey, const char *filename, u32 *sizePtr); + void *GetFont(const char *name); + + ARCHandle arc; + u32 unk_20; + ut::LinkList list; // 0x24 + char rootDirName[0x80]; // 0x30 + // class ends at 0xB0 + }; + +} +} + +namespace m2d { + class ResAcc_c { + public: + ResAcc_c(); + virtual ~ResAcc_c(); + virtual void initialSetup(); + + nw4r::lyt::ResourceAccessor *resAccPtr; // 0x04 + u32 unk_08; // 0x08 + nw4r::lyt::ArcResourceAccessor resAcc; // 0x0C + // class ends at 0xBC + }; + + class ResAccLoader_c : public ResAcc_c { + public: + ResAccLoader_c(); + ~ResAccLoader_c(); + + void *buffer; + dDvdLoader_c loader; // 0xC0 + // ends at 0xD4 + + bool loadArc(const char *path); + bool loadArc(const char *path, u8 unk); + void free(); + }; + + class EmbedLayoutBase_c : public Base_c { + public: + EmbedLayoutBase_c(); + ~EmbedLayoutBase_c(); + + void draw(); // don't call this directly + + virtual void update(); + virtual bool build(const char *brlytPath, ResAcc_c *resAcc = 0); + + nw4r::lyt::Pane *getRootPane(); + nw4r::lyt::Pane *findPaneByName(const char *name) const; + nw4r::lyt::TextBox *findTextBoxByName(const char *name) const; + nw4r::lyt::Pane *findPictureByName(const char *name) const; // TODO: change to others + nw4r::lyt::Pane *findWindowByName(const char *name) const; + + void animate(); + void calculateMtx(); + + nw4r::lyt::Layout layout; // 0x10 -- actually m2d::Layout_c but I'll add that later + nw4r::lyt::DrawInfo drawInfo; // 0x30 + void *unk_84; // 0x84 -- a ResAcc? referenced in Build() + float posX; // 0x88 + float posY; // 0x8C + float clipX; // 0x90 + float clipY; // 0x94 + float clipWidth; // 0x98 + float clipHeight; // 0x9C + bool clippingEnabled; // 0xA0 + u32 hasAnimations; // 0xA4 + u32 unk_A8; // 0xA8 + }; + + class EmbedLayout_c : public EmbedLayoutBase_c { + public: + EmbedLayout_c(); + ~EmbedLayout_c(); + + bool build(const char *brlytPath, ResAcc_c *resAcc = 0); + + bool loadArc(const char *name, bool isLangSpecific); + bool loadArc(const char *name, u8 unk, bool isLangSpecific); + + bool loadArcForRegion(const char *name); // uses EU/Layout/$name + + // there's also a NedEU one, but should it really be listed here...? + + bool free(); + + // does NSMBW even use consts? I have no idea. maybe not + + void getPanes(const char **names, nw4r::lyt::Pane *output, int count) const; + void getWindows(const char **names, nw4r::lyt::Pane *output, int count) const; // TODO: change to others + void getPictures(const char **names, nw4r::lyt::Pane *output, int count) const; + void getTextBoxes(const char **names, nw4r::lyt::TextBox *output, int count) const; + + void setLangStrings(const char **names, const int *msgIDs, int category, int count); + + void loadAnimations(const char **names, int count); + void loadGroups(const char **names, int *animLinkIDs, int count); + + void enableNonLoopAnim(int num, bool goToLastFrame = false); + void enableLoopAnim(int num); + void resetAnim(int num, bool goToLastFrame = false); + void disableAnim(int num); + void disableAllAnimations(); + + bool isAnimOn(int num = -1); + bool isAnyAnimOn(); + + void execAnimations(); + + ResAccLoader_c loader; // 0xAC + void *brlanHandlers; // 0x180 + void *grpHandlers; // 0x184 + bool *animsEnabled; // 0x188 + int brlanCount; // 0x18C + int grpCount; // 0x190 + int lastAnimTouched; // 0x194 + + private: + void fixTextBoxesRecursively(nw4r::lyt::Pane *pane); + }; +} + + +#endif + diff --git a/kamek_pal.x b/kamek_pal.x index 1692927..dbb213f 100644 --- a/kamek_pal.x +++ b/kamek_pal.x @@ -1,10 +1,10 @@ -OUTPUT_FORMAT ("binary")
-
-/*MEMORY {
- loader_section : ORIGIN = 0x80001800, LENGTH = 0x1800
-}*/
-
-SECTIONS {
+OUTPUT_FORMAT ("binary") + +/*MEMORY { + loader_section : ORIGIN = 0x80001800, LENGTH = 0x1800 +}*/ + +SECTIONS { GetSpecificPlayerActor = 0x8005F900; Actor_SearchByID = 0x80162E40; TimeStopFlag = 0x80429FDA; @@ -17,6 +17,7 @@ SECTIONS { AlwaysDrawFlag = 0x80064540; AlwaysDrawBranch = 0x80064544; GenerateRandomNumber = 0x800B2EE0; + OneofManySoundPlayers = 0x800CE9B0; _savefpr_14 = 0x802DCF98; _savefpr_15 = 0x802DCF9C; diff --git a/poweruphax.yaml b/poweruphax.yaml index 550d58c..281c9ea 100644 --- a/poweruphax.yaml +++ b/poweruphax.yaml @@ -1,598 +1,601 @@ ----
-source_files: [../src/poweruphax.S]
-hooks:
- - name: GetInfoFromDumbTable
- type: branch_insn
- branch_type: b
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x80142650
- target_func: 'GetInfoFromDumbTable'
-
- - name: FukidashiFix
- type: branch_insn
- branch_type: b
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x800B1A50
- target_func: 'FukidashiFix'
-
- - name: PlayerGetHeightFix
- type: branch_insn
- branch_type: b
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x80132670
- target_func: 'PlayerGetHeight'
-
-# - name: EnItem_BindAnimation_Fix
-# type: branch_insn
-# branch_type: b
-# src_addr_ntsc: 0xdeadbeef
-# src_addr_pal: 0x80A291E0
-# target_func: 'EnItem_BindAnimation_Fix'
-
- - name: DealWithBlahTable
- type: branch_insn
- branch_type: b
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x80141F70
- target_func: 'DealWithBlahTable'
-
- - name: GetAsdfTable
- type: branch_insn
- branch_type: b
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x801466C0
- target_func: 'GetAsdfTable'
-
- - name: GetBlahTableOffset
- type: branch_insn
- branch_type: bl
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x801421AC
- target_func: 'GetBlahTableOffset'
-
- - name: GetWeirdScaleTable
- type: branch_insn
- branch_type: bl
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x8014676C
- target_func: 'GetWeirdScaleTable'
-
- - name: WtfEver
- type: branch_insn
- branch_type: bl
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x80133E48
- target_func: 'WtfEver'
-
- - name: YetAnother
- type: branch_insn
- branch_type: bl
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x80138840
- target_func: 'YetAnother'
-
- - name: ExtendHammerStruct
- type: patch
- addr_ntsc: 0xdeadbeef
- addr_pal: 0x807FCBA8
- data: '3860 045C'
-
- - name: ThrowHammer
- type: branch_insn
- branch_type: b
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x8013BEE4
- target_func: 'ThrowHammer'
-
- - name: MoreProjectileStuff_Fix
- type: branch_insn
- branch_type: b
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x8013C3A0
- target_func: 'MoreProjectileStuff_Fix'
-
- - name: ProjectileShootCheck_Fix1
- type: patch
- addr_ntsc: 0xdeadbeef
- addr_pal: 0x8013BB7C
- data: '4181003C'
-
- - name: ProjectileShootCheck_Fix2
- type: branch_insn
- branch_type: b
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x8013BBB8
- target_func: 'ProjectileShootCheck_Fix'
-
- - name: QBlockItemChange
- type: patch
- addr_ntsc: 0xdeadbeef
- addr_pal: 0x802ee628
- data: '00000006'
-
- - name: QBlockItemFix
- type: patch
- addr_ntsc: 0xdeadbeef
- addr_pal: 0x8002288c
- data: '60000000'
-
- - name: FixMushroomIfSmallBlock
- type: patch
- addr_ntsc: 0xdeadbeef
- addr_pal: 0x800221ac
- data: '2800 0003'
-
- - name: SomeEnItemFix
- type: patch
- addr_ntsc: 0xdeadbeef
- addr_pal: 0x80A2BE98
- data: '2800 0003'
-
- - name: MushroomEnItemFix
- type: patch
- addr_ntsc: 0xdeadbeef
- addr_pal: 0x80A28598
- data: '2800 0003'
-
- - name: DisablePowerupValidityCheck
- type: patch
- addr_ntsc: 0xdeadbeef
- addr_pal: 0x800611C4
- data: '60000000'
-
- - name: TinyTableFix
- type: patch
- addr_ntsc: 0xdeadbeef
- addr_pal: 0x802F5AEC
- data: '00000001'
-
- #It's not actually a function but who cares?
- - name: AlwaysLoadBrosArc
- type: add_func_pointer
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x8098C488
- target_func: 'BrosArcFileName'
-
- - name: AlwaysLoadBrosArc
- type: add_func_pointer
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x8098C490
- target_func: 'I_hammerArcFilename'
-
- - name: ChangeHammerBrres
- type: add_func_pointer
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x80AF0FA8
- target_func: 'I_hammerResFile'
-
- - name: ChangeHammerArc
- type: add_func_pointer
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x80AF0ECC
- target_func: 'I_hammerArcFilename'
-
- - name: ChangeHammerModel
- type: add_func_pointer
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x80AF1000
- target_func: 'I_hammerModelName'
-
- - name: LetPlayerGetHammerItem
- type: branch_insn
- branch_type: bl
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x80A285FC
- target_func: 'TryToGiveMarioHammerSuit'
-
- - name: WeirdAnimLoadHack
- type: branch_insn
- branch_type: bl
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x80A27CE4
- target_func: 'WeirdAnimLoadHack'
-
- - name: SetHammerToEnItemDCA
- type: add_func_pointer
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x80AF117C
- target_func: 'SetHammerToEnItemDCA'
-
- - name: PlumberSetPowerupFix
- type: branch_insn
- branch_type: b
- src_addr_pal: 0x800D47D4
- target_func: 'PlumberSetPowerupFix'
-
- - name: PlumberSetPowerupFix2
- type: branch_insn
- branch_type: b
- src_addr_pal: 0x80141510
- target_func: 'PlumberSetPowerupFix2'
-
- - name: PlumberSetPowerupTextureFix
- type: branch_insn
- branch_type: b
- src_addr_pal: 0x800CA6F8
- target_func: 'PlumberSetPowerupTextureFix'
-
-# - name: PlumberSetPowerupTextureDebug
-# type: branch_insn
-# branch_type: b
-# src_addr_pal: 0x800CA6B0
-# target_func: 'PlumberSetPowerupTextureDebug'
-
- - name: FixPowerupScale_First
- type: branch_insn
- branch_type: bl
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x800d6fdc
- target_func: 'GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r4_dest'
-
- - name: FixPowerupScale_Second
- type: branch_insn
- branch_type: bl
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x8004cc80
- target_func: 'GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r3_dest'
-
- - name: FixPowerupScale_Third
- type: branch_insn
- branch_type: bl
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x800d7064
- target_func: 'GetPowerupScaleFloatAddr_r8_trash_r0_valshl2_r7_dest'
-
- - name: FixPowerupScale_Fourth
- type: branch_insn
- branch_type: bl
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x801293D0
- target_func: 'GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r3_dest'
-
- - name: FixPowerupScale_Fifth
- type: branch_insn
- branch_type: bl
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x80137CDC
- target_func: 'GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r3_dest'
-
- - name: FixPowerupScale_Sixth
- type: branch_insn
- branch_type: b
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x80141FF4
- target_func: 'GetPowerupScaleFloatAddr_fixForSixth'
-
- - name: FixPowerupScale_Seventh
- type: branch_insn
- branch_type: bl
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x8014378C
- target_func: 'GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r3_dest'
-
- - name: FixPowerupScale_Eighth
- type: branch_insn
- branch_type: bl
- src_addr_ntsc: 0xdeadbeef
- src_addr_pal: 0x80143884
- target_func: 'GetPowerupScaleFloatAddr_r8_trash_r0_valshl2_r7_dest'
+--- +source_files: [../src/poweruphax.S] +hooks: + - name: GetInfoFromDumbTable + type: branch_insn + branch_type: b + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x80142650 + target_func: 'GetInfoFromDumbTable' + + - name: FukidashiFix + type: branch_insn + branch_type: b + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x800B1A50 + target_func: 'FukidashiFix' + + - name: PlayerGetHeightFix + type: branch_insn + branch_type: b + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x80132670 + target_func: 'PlayerGetHeight' + +# - name: EnItem_BindAnimation_Fix +# type: branch_insn +# branch_type: b +# src_addr_ntsc: 0xdeadbeef +# src_addr_pal: 0x80A291E0 +# target_func: 'EnItem_BindAnimation_Fix' + + - name: DealWithBlahTable + type: branch_insn + branch_type: b + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x80141F70 + target_func: 'DealWithBlahTable' + + - name: GetAsdfTable + type: branch_insn + branch_type: b + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x801466C0 + target_func: 'GetAsdfTable' + + - name: GetBlahTableOffset + type: branch_insn + branch_type: bl + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x801421AC + target_func: 'GetBlahTableOffset' + + - name: GetWeirdScaleTable + type: branch_insn + branch_type: bl + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x8014676C + target_func: 'GetWeirdScaleTable' + + - name: WtfEver + type: branch_insn + branch_type: bl + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x80133E48 + target_func: 'WtfEver' + + - name: YetAnother + type: branch_insn + branch_type: bl + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x80138840 + target_func: 'YetAnother' + + - name: ExtendHammerStruct + type: patch + addr_ntsc: 0xdeadbeef + addr_pal: 0x807FCBA8 + data: '3860 045C' + + - name: ThrowHammer + type: branch_insn + branch_type: b + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x8013BEE4 + target_func: 'ThrowHammer' + + - name: MoreProjectileStuff_Fix + type: branch_insn + branch_type: b + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x8013C3A0 + target_func: 'MoreProjectileStuff_Fix' + + - name: ProjectileShootCheck_Fix1 + type: patch + addr_ntsc: 0xdeadbeef + addr_pal: 0x8013BB7C + data: '4181003C' + + - name: ProjectileShootCheck_Fix2 + type: branch_insn + branch_type: b + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x8013BBB8 + target_func: 'ProjectileShootCheck_Fix' + + - name: QBlockItemChange + type: patch + addr_ntsc: 0xdeadbeef + addr_pal: 0x802ee628 + data: '00000006' + + - name: QBlockItemFix + type: patch + addr_ntsc: 0xdeadbeef + addr_pal: 0x8002288c + data: '60000000' + + - name: FixMushroomIfSmallBlock + type: patch + addr_ntsc: 0xdeadbeef + addr_pal: 0x800221ac + data: '2800 0003' + + - name: SomeEnItemFix + type: patch + addr_ntsc: 0xdeadbeef + addr_pal: 0x80A2BE98 + data: '2800 0003' + + - name: MushroomEnItemFix + type: patch + addr_ntsc: 0xdeadbeef + addr_pal: 0x80A28598 + data: '2800 0003' + + - name: DisablePowerupValidityCheck + type: patch + addr_ntsc: 0xdeadbeef + addr_pal: 0x800611C4 + data: '60000000' + + - name: TinyTableFix + type: patch + addr_ntsc: 0xdeadbeef + addr_pal: 0x802F5AEC + data: '00000001' + + #It's not actually a function but who cares? + - name: AlwaysLoadBrosArc + type: add_func_pointer + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x8098C488 + target_func: 'BrosArcFileName' + + - name: AlwaysLoadBrosArc + type: add_func_pointer + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x8098C490 + target_func: 'I_hammerArcFilename' + + - name: ChangeHammerBrres + type: add_func_pointer + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x80AF0FA8 + target_func: 'I_hammerResFile' + + - name: ChangeHammerArc + type: add_func_pointer + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x80AF0ECC + target_func: 'I_hammerArcFilename' + + - name: ChangeHammerModel + type: add_func_pointer + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x80AF1000 + target_func: 'I_hammerModelName' + + - name: LetPlayerGetHammerItem + type: branch_insn + branch_type: bl + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x80A285FC + target_func: 'TryToGiveMarioHammerSuit' + + - name: WeirdAnimLoadHack + type: branch_insn + branch_type: bl + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x80A27CE4 + target_func: 'WeirdAnimLoadHack' + + - name: SetHammerToEnItemDCA + type: add_func_pointer + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x80AF117C + target_func: 'SetHammerToEnItemDCA' + + - name: PlumberSetPowerupFix + type: branch_insn + branch_type: b + src_addr_pal: 0x800D47D4 + target_func: 'PlumberSetPowerupFix' + + - name: PlumberSetPowerupFix2 + type: branch_insn + branch_type: b + src_addr_pal: 0x80141510 + target_func: 'PlumberSetPowerupFix2' + + - name: PlumberSetPowerupTextureFix + type: branch_insn + branch_type: b + src_addr_pal: 0x800CA6F8 + target_func: 'PlumberSetPowerupTextureFix' + +# - name: PlumberSetPowerupTextureDebug +# type: branch_insn +# branch_type: b +# src_addr_pal: 0x800CA6B0 +# target_func: 'PlumberSetPowerupTextureDebug' + + - name: FixPowerupScale_First + type: branch_insn + branch_type: bl + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x800d6fdc + target_func: 'GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r4_dest' + + - name: FixPowerupScale_Second + type: branch_insn + branch_type: bl + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x8004cc80 + target_func: 'GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r3_dest' + + - name: FixPowerupScale_Third + type: branch_insn + branch_type: bl + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x800d7064 + target_func: 'GetPowerupScaleFloatAddr_r8_trash_r0_valshl2_r7_dest' + + - name: FixPowerupScale_Fourth + type: branch_insn + branch_type: bl + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x801293D0 + target_func: 'GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r3_dest' + + - name: FixPowerupScale_Fifth + type: branch_insn + branch_type: bl + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x80137CDC + target_func: 'GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r3_dest' + + - name: FixPowerupScale_Sixth + type: branch_insn + branch_type: b + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x80141FF4 + target_func: 'GetPowerupScaleFloatAddr_fixForSixth' + + - name: FixPowerupScale_Seventh + type: branch_insn + branch_type: bl + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x8014378C + target_func: 'GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r3_dest' + + - name: FixPowerupScale_Eighth + type: branch_insn + branch_type: bl + src_addr_ntsc: 0xdeadbeef + src_addr_pal: 0x80143884 + target_func: 'GetPowerupScaleFloatAddr_r8_trash_r0_valshl2_r7_dest' # Below Here are added all the Hammer Collision hacks - - name: HammerPodooboo
- type: patch
- addr_pal: 0x80ACE8E4
- data: '0008820C'
- - - name: HammerThwomp
- type: patch
- addr_pal: 0x80ACF9D0
- data: '0008820e'
- - - name: HammerBigThwomp
- type: patch
- addr_pal: 0x80ACF9F4
- data: '0008820e'
- - - name: HammerBigBoo
- type: patch
- addr_pal: 0x80AD4AA0
- data: '0008a80e'
- - - name: HammerBigBooTwo
- type: patch
- addr_pal: 0x80AD4AA4
- data: '20020000'
- - - name: HammerAmp
- type: patch
- addr_pal: 0x80ACE17C
- data: '00080a04'
- - - name: HammerSpikeBall
- type: patch
- addr_pal: 0x80AD4D88
- data: '00080006'
- - - name: HammerBigSpikeBall
- type: patch
- addr_pal: 0x80ACDD50
- data: '00080006'
- - - name: HammerUrchin
- type: patch
- addr_pal: 0x80AD4F48
- data: '00088a1e'
- - - name: HammerChainChomp
- type: patch
- addr_pal: 0x80AD5214
- data: '00088206'
- - - name: HammerFireSnake
- type: patch
- addr_pal: 0x80ACFBC4
- data: '00088206'
- - - name: HammerFishbones
- type: patch
- addr_pal: 0x80AD2748
- data: '0008881e'
- - - name: HammerBeanGoomba
- type: patch
- addr_pal: 0x80acd988
- data: '0008A2BE'
- - - name: HammerPukucoinOne
- type: patch
- addr_pal: 0x80AD3C60
- data: '00088a0e'
+ - name: HammerPodooboo + type: patch + addr_pal: 0x80ACE8E4 + data: '0008820C' + + - name: HammerThwomp + type: patch + addr_pal: 0x80ACF9D0 + data: '0008820e' + + - name: HammerBigThwomp + type: patch + addr_pal: 0x80ACF9F4 + data: '0008820e' + + - name: HammerBigBoo + type: patch + addr_pal: 0x80AD4AA0 + data: '0008a80e' + + - name: HammerBigBooTwo + type: patch + addr_pal: 0x80AD4AA4 + data: '20020000' + + - name: HammerAmp + type: patch + addr_pal: 0x80ACE17C + data: '00080a04' + + - name: HammerSpikeBall + type: patch + addr_pal: 0x80AD4D88 + data: '00080006' + + - name: HammerBigSpikeBall + type: patch + addr_pal: 0x80ACDD50 + data: '00080006' + + - name: HammerUrchin + type: patch + addr_pal: 0x80AD4F48 + data: '00088a1e' + + - name: HammerChainChomp + type: patch + addr_pal: 0x80AD5214 + data: '00088206' + + - name: HammerFireSnake + type: patch + addr_pal: 0x80ACFBC4 + data: '00088206' + + - name: HammerFishbones + type: patch + addr_pal: 0x80AD2748 + data: '0008881e' + + - name: HammerBeanGoomba + type: patch + addr_pal: 0x80acd988 + data: '0008A2BE' + + - name: HammerPukucoinOne + type: patch + addr_pal: 0x80AD3C60 + data: '00088a0e' - name: HammerPukucoinTwo - type: patch
- addr_pal: 0x80AD3C3C
- data: '00088a0e'
- - - name: HammerBulber
- type: patch
- addr_pal: 0x80ACEC60
- data: '00088a0e'
- - - name: HammerFuzzyOne
- type: patch
- addr_pal: 0x80ACECF8
- data: '0008828e'
- - - name: HammerFuzzyTwo
- type: patch
- addr_pal: 0x80ACED1C
- data: '0008828e'
- - - name: HammerGhostCircle
- type: patch
- addr_pal: 0x80AD4158
- data: '0008a80e'
- - - name: HammerPiranhaLily
- type: patch
- addr_pal: 0x80AD5538
- data: '003AFFFE'
- - -# - name: HammerClam
-# type: patch
-# addr_pal: 0x80acd4BC
-# data: '00000047'
+ type: patch + addr_pal: 0x80AD3C3C + data: '00088a0e' + + - name: HammerBulber + type: patch + addr_pal: 0x80ACEC60 + data: '00088a0e' + + - name: HammerFuzzyOne + type: patch + addr_pal: 0x80ACECF8 + data: '0008828e' + + - name: HammerFuzzyTwo + type: patch + addr_pal: 0x80ACED1C + data: '0008828e' + + - name: HammerGhostCircle + type: patch + addr_pal: 0x80AD4158 + data: '0008a80e' + + - name: HammerPiranhaLily + type: patch + addr_pal: 0x80AD5538 + data: '003AFFFE' + + +# - name: HammerClam +# type: patch +# addr_pal: 0x80acd4BC +# data: '00000047' # -# - name: HammerClamTwo
-# type: patch
-# addr_pal: 0x80acd4e0
-# data: '00000047'
+# - name: HammerClamTwo +# type: patch +# addr_pal: 0x80acd4e0 +# data: '00000047' # -# - name: HammerClamNull
-# type: patch
-# addr_pal: 0x80AD5BF0
-# data: '80095C10'
+# - name: HammerClamNull +# type: patch +# addr_pal: 0x80AD5BF0 +# data: '80095C10' - - name: HammerGiantWigglerNull
- type: patch
- addr_pal: 0x80AD7FC8
- data: '80095C10'
+ - name: HammerGiantWigglerNull + type: patch + addr_pal: 0x80AD7FC8 + data: '80095C10' - - name: HammerParabeetleNull
- type: patch
- addr_pal: 0x80B028D8
- data: '80095C10'
+ - name: HammerParabeetleNull + type: patch + addr_pal: 0x80B028D8 + data: '80095C10' - - name: HammerGiantBuzzyNull
- type: patch
- addr_pal: 0x80AD8A10
- data: '80095C10'
+ - name: HammerGiantBuzzyNull + type: patch + addr_pal: 0x80AD8A10 + data: '80095C10' - - name: HammerGiantBuzzy
- type: patch
- addr_pal: 0x80ACDC8C
- data: '0000004F'
+ - name: HammerGiantBuzzy + type: patch + addr_pal: 0x80ACDC8C + data: '0000004F' - - name: HammerGiantBuzzy
- type: patch
- addr_pal: 0x80ACDC90
- data: 'FFBAFFBC'
+ - name: HammerGiantBuzzy + type: patch + addr_pal: 0x80ACDC90 + data: 'FFBAFFBC' - - name: HammerKingBill
- type: patch
- addr_pal: 0x80AD2618
- data: '0000004F'
+ - name: HammerKingBill + type: patch + addr_pal: 0x80AD2618 + data: '0000004F' - - name: HammerKingBillTwo
- type: patch
- addr_pal: 0x80AD261C
- data: '00088806'
+ - name: HammerKingBillTwo + type: patch + addr_pal: 0x80AD261C + data: '00088806' - - name: HammerKingBillNull
- type: patch
- addr_pal: 0x80AF72A8
- data: '80095C10'
+ - name: HammerKingBillNull + type: patch + addr_pal: 0x80AF72A8 + data: '80095C10' - - name: HammerBulletBill
- type: patch
- addr_pal: 0x80AD22B8
- data: '03000000'
+ - name: HammerBulletBill + type: patch + addr_pal: 0x80AD22B8 + data: '03000000' - - name: HammerBanzaiBill
- type: patch
- addr_pal: 0x80ad22Dc
- data: '03000000'
+ - name: HammerBanzaiBill + type: patch + addr_pal: 0x80ad22Dc + data: '03000000' - - name: HammerPolterOne
- type: patch
- addr_pal: 0x80AD3ADC
- data: '00000047'
+ - name: HammerPolterOne + type: patch + addr_pal: 0x80AD3ADC + data: '00000047' - - name: HammerPolterTwo
- type: patch
- addr_pal: 0x80AD3B00
- data: '00000047'
+ - name: HammerPolterTwo + type: patch + addr_pal: 0x80AD3B00 + data: '00000047' - - name: Icicle
- type: patch
- data: "0000004F"
- addr_pal: 0x80AD0EB4
+ - name: Icicle + type: patch + data: "0000004F" + addr_pal: 0x80AD0EB4 - - name: IcicleOne
- type: patch
- data: "0000004F"
- addr_pal: 0x80AD0ED8
+ - name: IcicleOne + type: patch + data: "0000004F" + addr_pal: 0x80AD0ED8 + - name: IcicleTwo + type: patch + data: "0000004F" + addr_pal: 0x80ACFD08 - - name: IcicleTwo
- type: patch
- data: "0000004F"
- addr_pal: 0x80ACFD08
+ - name: IcicleThree + type: patch + data: "0000004F" + addr_pal: 0x80ACFD2C - - name: IcicleThree
- type: patch
- data: "0000004F"
- addr_pal: 0x80ACFD2C
+ - name: IcicleNormalNoIceball + type: patch + data: "80095C10" + addr_pal: 0x80AEFFFC - - name: IcicleFour
- type: patch
- data: "0000004F"
- addr_pal: 0x80acdb58
+ - name: IcicleFixationNoIceball + type: patch + data: "80095C10" + addr_pal: 0x80AE9DC0 + - name: FuckinCastleLarryNull + type: patch + data: "80095C10" + addr_pal: 0x80B76C90 - - name: FuckinCastleLarryNull
- type: patch
- data: "80095C10"
- addr_pal: 0x80B76C90
+ - name: FuckinLarryNull + type: patch + data: "80095C10" + addr_pal: 0x80B81F44 - - name: FuckinLarryNull
- type: patch
- data: "80095C10"
- addr_pal: 0x80B81F44
+ - name: FuckinCastleLemmyNull + type: patch + data: "80095C10" + addr_pal: 0x80B777A8 - - name: FuckinCastleLemmyNull
- type: patch
- data: "80095C10"
- addr_pal: 0x80B777A8
+ - name: FuckinLemmyNull + type: patch + data: "80095C10" + addr_pal: 0x80B82DF0 - - name: FuckinLemmyNull
- type: patch
- data: "80095C10"
- addr_pal: 0x80B82DF0
+ - name: FuckinCastleWendyNull + type: patch + data: "80095C10" + addr_pal: 0x80B7AD70 - - name: FuckinCastleWendyNull
- type: patch
- data: "80095C10"
- addr_pal: 0x80B7AD70
+ - name: FuckinWendyNull + type: patch + data: "80095C10" + addr_pal: 0x80B87644 - - name: FuckinWendyNull
- type: patch
- data: "80095C10"
- addr_pal: 0x80B87644
+ - name: FuckinCastleLudwigNull + type: patch + data: "80095C10" + addr_pal: 0x80B78380 - - name: FuckinCastleLudwigNull
- type: patch
- data: "80095C10"
- addr_pal: 0x80B78380
+ - name: FuckinLudwigNull + type: patch + data: "80095C10" + addr_pal: 0x80B840D8 - - name: FuckinLudwigNull
- type: patch
- data: "80095C10"
- addr_pal: 0x80B840D8
+ - name: FuckinCastleIggyNull + type: patch + data: "80095C10" + addr_pal: 0x80B75F80 - - name: FuckinCastleIggyNull
- type: patch
- data: "80095C10"
- addr_pal: 0x80B75F80
+ - name: FuckinIggyNull + type: patch + data: "80095C10" + addr_pal: 0x80B7BC28 - - name: FuckinIggyNull
- type: patch
- data: "80095C10"
- addr_pal: 0x80B7BC28
+ - name: FuckinCastleMortonNull + type: patch + data: "80095C10" + addr_pal: 0x80B79060 - - name: FuckinCastleMortonNull
- type: patch
- data: "80095C10"
- addr_pal: 0x80B79060
+ - name: FuckinMortonNull + type: patch + data: "80095C10" + addr_pal: 0x80B853A8 - - name: FuckinMortonNull
- type: patch
- data: "80095C10"
- addr_pal: 0x80B853A8
+ - name: FuckinCastleRoyNull + type: patch + data: "80095C10" + addr_pal: 0x80B79DC8 - - name: FuckinCastleRoyNull
- type: patch
- data: "80095C10"
- addr_pal: 0x80B79DC8
+ - name: FuckinRoyNull + type: patch + data: "80095C10" + addr_pal: 0x80B86410 - - name: FuckinRoyNull
- type: patch
- data: "80095C10"
- addr_pal: 0x80B86410
+ - name: FuckinKamekNull + type: patch + data: "80095C10" + addr_pal: 0x80B7CBDC - - name: FuckinKamekNull
- type: patch
- data: "80095C10"
- addr_pal: 0x80B7CBDC
+ - name: FuckinBowserNull + type: patch + data: "80095C10" + addr_pal: 0x80B7E800 - - name: FuckinBowserNull
- type: patch
- data: "80095C10"
- addr_pal: 0x80B7E800
+ - name: FuckinJrANull + type: patch + data: "80095C10" + addr_pal: 0x80B804B4 - - name: FuckinJrANull
- type: patch
- data: "80095C10"
- addr_pal: 0x80B804B4
+ - name: FuckinJrBNull + type: patch + data: "80095C10" + addr_pal: 0x80B80BBC - - name: FuckinJrBNull
- type: patch
- data: "80095C10"
- addr_pal: 0x80B80BBC
- - - name: FuckinJrCNull
- type: patch
- data: "80095C10"
- addr_pal: 0x80B81468
+ - name: FuckinJrCNull + type: patch + data: "80095C10" + addr_pal: 0x80B81468 diff --git a/spritespawner.yaml b/spritespawner.yaml index e75bf09..8c2e7ca 100644 --- a/spritespawner.yaml +++ b/spritespawner.yaml @@ -1,15 +1,15 @@ ----
-# Replaces Ac_Lift_ObjBg_HMove_Big
-
-source_files: [../src/spritespawner.cpp]
-hooks:
- - name: SpriteSpawner_Create
- type: add_func_pointer
- src_addr_pal: 0x80ADEA18
- target_func: 'SpriteSpawner_Create(SpriteSpawner *)'
-
- - name: SpriteSpawner_Execute
- type: add_func_pointer
- src_addr_pal: 0x80ADEA30
- target_func: 'SpriteSpawner_Execute(SpriteSpawner *)'
+--- +# Replaces Ac_Lift_ObjBg_HMove_Big + +source_files: [../src/spritespawner.cpp] +hooks: + - name: SpriteSpawner_Create + type: add_func_pointer + src_addr_pal: 0x80ADEA18 + target_func: 'SpriteSpawner_Create(SpriteSpawner *)' + + - name: SpriteSpawner_Execute + type: add_func_pointer + src_addr_pal: 0x80ADEA30 + target_func: 'SpriteSpawner_Execute(SpriteSpawner *)'
\ No newline at end of file diff --git a/spriteswapper.yaml b/spriteswapper.yaml new file mode 100644 index 0000000..38e0160 --- /dev/null +++ b/spriteswapper.yaml @@ -0,0 +1,15 @@ +--- +# Replaces EN_Remocon_ToriMochi + +source_files: [../src/spriteSwapper.cpp] +hooks: + - name: SpriteSwapper_Create + type: add_func_pointer + src_addr_pal: 0x80B05E28 + target_func: 'SpriteSwapper_Create(SpriteSwapper *)' + + - name: SpriteSwapper_Execute + type: add_func_pointer + src_addr_pal: 0x80B05E40 + target_func: 'SpriteSwapper_Execute(SpriteSwapper *)' +
\ No newline at end of file diff --git a/spritetex.yaml b/spritetex.yaml index 9eda5c0..453ab24 100644 --- a/spritetex.yaml +++ b/spritetex.yaml @@ -1,565 +1,565 @@ ----
-source_files: [../src/spritetex.s]
-hooks:
-# - name: TEX_WoodBox
-# type: branch_insn
-# branch_type: bl
-# NOTES: 'fix ntsc addr later'
-# src_addr_ntsc: 0x80ACBFB0
-# src_addr_pal: 0x80ACBFB0
-# target_func: 'TEX_WoodBox'
-
- - name: TEX_Bush
- type: branch_insn
- branch_type: bl
- src_addr_ntsc: 0x80875BB4
- src_addr_pal: 0x80875BB4
- target_func: 'TEX_Bush'
-
-
-
+--- +source_files: [../src/spritetex.s] +hooks: +# - name: TEX_WoodBox +# type: branch_insn +# branch_type: bl +# NOTES: 'fix ntsc addr later' +# src_addr_ntsc: 0x80ACBFB0 +# src_addr_pal: 0x80ACBFB0 +# target_func: 'TEX_WoodBox' + + - name: TEX_Bush + type: branch_insn + branch_type: bl + src_addr_ntsc: 0x80875BB4 + src_addr_pal: 0x80875BB4 + target_func: 'TEX_Bush' + + + # The below was added by Tempus - - name: TEX_Goomba
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80031384
- target_func: 'TEX_Goomba'
+ - name: TEX_Goomba + type: branch_insn + branch_type: bl + src_addr_pal: 0x80031384 + target_func: 'TEX_Goomba' - - name: TEX_BigGoomba
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80033350
- target_func: 'TEX_BigGoomba'
+ - name: TEX_BigGoomba + type: branch_insn + branch_type: bl + src_addr_pal: 0x80033350 + target_func: 'TEX_BigGoomba' - - name: TEX_Barrel
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x809AB3B4
- target_func: 'TEX_Barrel'
+ - name: TEX_Barrel + type: branch_insn + branch_type: bl + src_addr_pal: 0x809AB3B4 + target_func: 'TEX_Barrel' -# - name: TEX_Blooper
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80A0451C
-# target_func: 'TEX_Blooper'
+# - name: TEX_Blooper +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80A0451C +# target_func: 'TEX_Blooper' -# - name: TEX_BigBlock
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x809B8DB8
-# target_func: 'TEX_BigBlock'
+# - name: TEX_BigBlock +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x809B8DB8 +# target_func: 'TEX_BigBlock' - - name: TEX_Thwomp
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x809F63F4
- target_func: 'TEX_Thwomp'
+ - name: TEX_Thwomp + type: branch_insn + branch_type: bl + src_addr_pal: 0x809F63F4 + target_func: 'TEX_Thwomp' - - name: TEX_GiantBuzzy
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x809B6B44
- target_func: 'TEX_GiantBuzzy'
+ - name: TEX_GiantBuzzy + type: branch_insn + branch_type: bl + src_addr_pal: 0x809B6B44 + target_func: 'TEX_GiantBuzzy' - - name: TEX_Buzzy
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A67834
- target_func: 'TEX_Buzzy'
+ - name: TEX_Buzzy + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A67834 + target_func: 'TEX_Buzzy' - - name: TEX_BuzzyShell
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A67540
- target_func: 'TEX_BuzzyShell'
+ - name: TEX_BuzzyShell + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A67540 + target_func: 'TEX_BuzzyShell' - - name: TEX_SpikeTop
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80AB2C34
- target_func: 'TEX_SpikeTop'
+ - name: TEX_SpikeTop + type: branch_insn + branch_type: bl + src_addr_pal: 0x80AB2C34 + target_func: 'TEX_SpikeTop' - - name: TEX_SpinyShell
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x8003DBF8
- target_func: 'TEX_SpinyShell'
+ - name: TEX_SpinyShell + type: branch_insn + branch_type: bl + src_addr_pal: 0x8003DBF8 + target_func: 'TEX_SpinyShell' - - name: TEX_Spiny
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x8003DD0C
+ - name: TEX_Spiny + type: branch_insn + branch_type: bl + src_addr_pal: 0x8003DD0C target_func: 'TEX_Spiny' - - name: TEX_SpringBlock
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80AC8640
- target_func: 'TEX_SpringBlock'
+ - name: TEX_SpringBlock + type: branch_insn + branch_type: bl + src_addr_pal: 0x80AC8640 + target_func: 'TEX_SpringBlock' - - name: TEX_Coaster
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80859714
- target_func: 'TEX_Coaster'
+ - name: TEX_Coaster + type: branch_insn + branch_type: bl + src_addr_pal: 0x80859714 + target_func: 'TEX_Coaster' - - name: TEX_Koopa
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A72904
- target_func: 'TEX_Koopa'
+ - name: TEX_Koopa + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A72904 + target_func: 'TEX_Koopa' - - name: TEX_KoopaShell
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A72644
- target_func: 'TEX_Koopa'
+ - name: TEX_KoopaShell + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A72644 + target_func: 'TEX_Koopa' - - name: TEX_Gabon
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A00290
- target_func: 'TEX_Gabon'
+ - name: TEX_Gabon + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A00290 + target_func: 'TEX_Gabon' - - name: TEX_Gabon_Spike
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A00984
- target_func: 'TEX_Gabon_Spike'
+ - name: TEX_Gabon_Spike + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A00984 + target_func: 'TEX_Gabon_Spike' - - name: TEX_GabonRock
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x807F8CD4
- target_func: 'TEX_GabonRock'
+ - name: TEX_GabonRock + type: branch_insn + branch_type: bl + src_addr_pal: 0x807F8CD4 + target_func: 'TEX_GabonRock' - - name: TEX_Podoboo
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x809D0CC0
- target_func: 'TEX_Podoboo'
+ - name: TEX_Podoboo + type: branch_insn + branch_type: bl + src_addr_pal: 0x809D0CC0 + target_func: 'TEX_Podoboo' - - name: TEX_Switch
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A19ED4
- target_func: 'TEX_Switch'
+ - name: TEX_Switch + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A19ED4 + target_func: 'TEX_Switch' -# - name: TEX_WiggleShroom
-# type: branch_insn
-# branch_type: bl
+# - name: TEX_WiggleShroom +# type: branch_insn +# branch_type: bl # src_addr_pal: 0x800BC9D8 -# target_func: 'TEX_WiggleShroom'
+# target_func: 'TEX_WiggleShroom' - - name: TEX_Bramball
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A1C844
- target_func: 'TEX_Bramball'
+ - name: TEX_Bramball + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A1C844 + target_func: 'TEX_Bramball' - - name: TEX_Monty
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x809D8DB4
- target_func: 'TEX_Monty'
+ - name: TEX_Monty + type: branch_insn + branch_type: bl + src_addr_pal: 0x809D8DB4 + target_func: 'TEX_Monty' -# - name: TEX_ChainChomp
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80ABF934
-# target_func: 'TEX_ChainChomp'
+# - name: TEX_ChainChomp +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80ABF934 +# target_func: 'TEX_ChainChomp' - - name: TEX_Manta
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x8085DAA8
- target_func: 'TEX_Manta'
+ - name: TEX_Manta + type: branch_insn + branch_type: bl + src_addr_pal: 0x8085DAA8 + target_func: 'TEX_Manta' - - name: TEX_Parabeetle
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A83260
- target_func: 'TEX_Parabeetle'
+ - name: TEX_Parabeetle + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A83260 + target_func: 'TEX_Parabeetle' - - name: TEX_Bomb
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x809C90A4
- target_func: 'TEX_Bomb'
+ - name: TEX_Bomb + type: branch_insn + branch_type: bl + src_addr_pal: 0x809C90A4 + target_func: 'TEX_Bomb' - - name: TEX_ParaBomb
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A7EEF8
- target_func: 'TEX_ParaBomb'
+ - name: TEX_ParaBomb + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A7EEF8 + target_func: 'TEX_ParaBomb' -# - name: TEX_CheepA
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80A3B8F8
-# target_func: 'TEX_CheepA'
+# - name: TEX_CheepA +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80A3B8F8 +# target_func: 'TEX_CheepA' -# - name: TEX_CheepB
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80AB2288
-# target_func: 'TEX_CheepB'
+# - name: TEX_CheepB +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80AB2288 +# target_func: 'TEX_CheepB' -# - name: TEX_CheepC
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80A8A008
-# target_func: 'TEX_CheepC'
+# - name: TEX_CheepC +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80A8A008 +# target_func: 'TEX_CheepC' -# - name: TEX_CheepChomp
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x809A67F4
-# target_func: 'TEX_CheepChomp'
+# - name: TEX_CheepChomp +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x809A67F4 +# target_func: 'TEX_CheepChomp' # - name: TEX_BigBoo -# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80AAF5E0
-# target_func: 'TEX_BigBoo'
+# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80AAF5E0 +# target_func: 'TEX_BigBoo' # # # - name: TEX_Boo -# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x808F0628
-# target_func: 'TEX_Boo'
+# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x808F0628 +# target_func: 'TEX_Boo' - - name: TEX_Midway
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x807E22C4
- target_func: 'TEX_Midway'
+ - name: TEX_Midway + type: branch_insn + branch_type: bl + src_addr_pal: 0x807E22C4 + target_func: 'TEX_Midway' - - name: TEX_Goal
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A0A0E8
- target_func: 'TEX_Goal'
+ - name: TEX_Goal + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A0A0E8 + target_func: 'TEX_Goal' -# - name: TEX_StretchMush
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x8084AD10
-# target_func: 'TEX_StretchMush'
+# - name: TEX_StretchMush +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x8084AD10 +# target_func: 'TEX_StretchMush' - - name: TEX_BlockSlide
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x807E54AC
- target_func: 'TEX_BlockSlide'
+ - name: TEX_BlockSlide + type: branch_insn + branch_type: bl + src_addr_pal: 0x807E54AC + target_func: 'TEX_BlockSlide' -# - name: TEX_Spinner
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x8084F9E0
-# target_func: 'TEX_Spinner'
+# - name: TEX_Spinner +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x8084F9E0 +# target_func: 'TEX_Spinner' -# - name: TEX_Platforms
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x800C03A0
-# target_func: 'TEX_Platforms'
+# - name: TEX_Platforms +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x800C03A0 +# target_func: 'TEX_Platforms' -# - name: TEX_Platform_ShifterH
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80841CBC
-# target_func: 'TEX_Platform_ShifterH'
+# - name: TEX_Platform_ShifterH +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80841CBC +# target_func: 'TEX_Platform_ShifterH' -# - name: TEX_Platform_ShifterF
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x808374FC
-# target_func: 'TEX_Platform_ShifterF'
+# - name: TEX_Platform_ShifterF +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x808374FC +# target_func: 'TEX_Platform_ShifterF' # -# - name: TEX_Platform_ShifterL
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80839810
-# target_func: 'TEX_Platform_ShifterL'
+# - name: TEX_Platform_ShifterL +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80839810 +# target_func: 'TEX_Platform_ShifterL' # -# - name: TEX_Platform_ShifterV
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80844D68
-# target_func: 'TEX_Platform_ShifterF'
+# - name: TEX_Platform_ShifterV +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80844D68 +# target_func: 'TEX_Platform_ShifterF' # -# - name: TEX_Platform_ShifterR
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80845B08
-# target_func: 'TEX_Platform_ShifterR'
+# - name: TEX_Platform_ShifterR +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80845B08 +# target_func: 'TEX_Platform_ShifterR' # -# - name: TEX_Platform_ShifterS
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80848A64
-# target_func: 'TEX_Platform_ShifterS'
+# - name: TEX_Platform_ShifterS +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80848A64 +# target_func: 'TEX_Platform_ShifterS' # -# - name: TEX_Platform_ShifterK
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x8084A778
-# target_func: 'TEX_Platform_ShifterK'
+# - name: TEX_Platform_ShifterK +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x8084A778 +# target_func: 'TEX_Platform_ShifterK' # -# - name: TEX_Platform_ShifterW
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x8084F344
-# target_func: 'TEX_Platform_ShifterW'
+# - name: TEX_Platform_ShifterW +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x8084F344 +# target_func: 'TEX_Platform_ShifterW' # -# - name: TEX_Platform_ShifterSL
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80858870
-# target_func: 'TEX_Platform_ShifterSL'
+# - name: TEX_Platform_ShifterSL +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80858870 +# target_func: 'TEX_Platform_ShifterSL' # -# - name: TEX_Platform_ShifterWL
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x808BF040
-# target_func: 'TEX_Platform_ShifterW'
+# - name: TEX_Platform_ShifterWL +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x808BF040 +# target_func: 'TEX_Platform_ShifterW' # - - name: TEX_PokeyA
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80AA1DB0
- target_func: 'TEX_PokeyA'
+ - name: TEX_PokeyA + type: branch_insn + branch_type: bl + src_addr_pal: 0x80AA1DB0 + target_func: 'TEX_PokeyA' - - name: TEX_PokeyB
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A9F834
- target_func: 'TEX_PokeyB'
+ - name: TEX_PokeyB + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A9F834 + target_func: 'TEX_PokeyB' - - name: TEX_PokeyC
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A9D028
- target_func: 'TEX_PokeyC'
+ - name: TEX_PokeyC + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A9D028 + target_func: 'TEX_PokeyC' - - name: TEX_PokeyNoSand
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A9E7A8
- target_func: 'TEX_PokeyNoSand'
+ - name: TEX_PokeyNoSand + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A9E7A8 + target_func: 'TEX_PokeyNoSand' -# - name: TEX_PokeySnowmanPos
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80A9F7C0
-# target_func: 'TEX_PokeySnowmanPos'
+# - name: TEX_PokeySnowmanPos +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80A9F7C0 +# target_func: 'TEX_PokeySnowmanPos' # -# - name: TEX_PokeySnowmanPosA
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80A9FEF8
-# target_func: 'TEX_PokeySnowmanPosA'
+# - name: TEX_PokeySnowmanPosA +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80A9FEF8 +# target_func: 'TEX_PokeySnowmanPosA' # -# - name: TEX_PokeySnowmanPosB
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80AA002C
-# target_func: 'TEX_PokeySnowmanPosB'
+# - name: TEX_PokeySnowmanPosB +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80AA002C +# target_func: 'TEX_PokeySnowmanPosB' # # -# - name: TEX_PokeySnowmanPosC
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80AA04D0
-# target_func: 'TEX_PokeySnowmanPosC'
+# - name: TEX_PokeySnowmanPosC +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80AA04D0 +# target_func: 'TEX_PokeySnowmanPosC' # # -# - name: TEX_PokeySnowmanPosD
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80AA0644
-# target_func: 'TEX_PokeySnowmanPosD'
+# - name: TEX_PokeySnowmanPosD +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80AA0644 +# target_func: 'TEX_PokeySnowmanPosD' # -# - name: TEX_PokeySnowmanPosE
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80AA0848
-# target_func: 'TEX_PokeySnowmanPosE'
+# - name: TEX_PokeySnowmanPosE +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80AA0848 +# target_func: 'TEX_PokeySnowmanPosE' # -# - name: TEX_PokeySnowmanPosF
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80AA0A5C
-# target_func: 'TEX_PokeySnowmanPosF'
+# - name: TEX_PokeySnowmanPosF +# type: branch_insn +# branch_type: bl +# src_addr_pal: 0x80AA0A5C +# target_func: 'TEX_PokeySnowmanPosF' # # # -# - name: TEX_PokeySnowmanPosZ
-# type: patch
-# data: '60000000'
-# addr_pal: 0x80A9D054
+# - name: TEX_PokeySnowmanPosZ +# type: patch +# data: '60000000' +# addr_pal: 0x80A9D054 - - name: TEX_PokeySnowman
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A9F714
- target_func: 'TEX_PokeySnowman'
+ - name: TEX_PokeySnowman + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A9F714 + target_func: 'TEX_PokeySnowman' - - name: TEX_CloudBounce
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A5C900
- target_func: 'TEX_CloudBounce'
+ - name: TEX_CloudBounce + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A5C900 + target_func: 'TEX_CloudBounce' - - name: TEX_SpikeBall
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x809B7620
- target_func: 'TEX_SpikeBall'
+ - name: TEX_SpikeBall + type: branch_insn + branch_type: bl + src_addr_pal: 0x809B7620 + target_func: 'TEX_SpikeBall' - - name: TEX_SpikeBallSmall
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80AB6054
- target_func: 'TEX_SpikeBall'
+ - name: TEX_SpikeBallSmall + type: branch_insn + branch_type: bl + src_addr_pal: 0x80AB6054 + target_func: 'TEX_SpikeBall' - - name: TEX_Huckit
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A3F004
- target_func: 'TEX_Huckit'
+ - name: TEX_Huckit + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A3F004 + target_func: 'TEX_Huckit' - - name: TEX_HuckitBalls
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A40B70
- target_func: 'TEX_HuckitBalls'
+ - name: TEX_HuckitBalls + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A40B70 + target_func: 'TEX_HuckitBalls' - - name: HammerTime
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A5BCB0
- target_func: 'HammerTime'
+ - name: HammerTime + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A5BCB0 + target_func: 'HammerTime' - - name: HammerLaunch
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A5BA68
+ - name: HammerLaunch + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A5BA68 target_func: 'HammerLaunch' - - name: HammerSpin
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80A5BA90
- target_func: 'HammerSpin'
+ - name: HammerSpin + type: branch_insn + branch_type: bl + src_addr_pal: 0x80A5BA90 + target_func: 'HammerSpin' - - name: TEX_YoshiEggSetColour
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80911050
- target_func: 'TEX_YoshiEggSetColour'
+ - name: TEX_YoshiEggSetColour + type: branch_insn + branch_type: bl + src_addr_pal: 0x80911050 + target_func: 'TEX_YoshiEggSetColour' - - name: TEX_YoshiEggSetBrres
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x809113D0
- target_func: 'TEX_YoshiEggSetBrres'
+ - name: TEX_YoshiEggSetBrres + type: branch_insn + branch_type: bl + src_addr_pal: 0x809113D0 + target_func: 'TEX_YoshiEggSetBrres' - - name: TEX_YoshiEggSetFrame
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x809114B4
+ - name: TEX_YoshiEggSetFrame + type: branch_insn + branch_type: bl + src_addr_pal: 0x809114B4 target_func: 'TEX_YoshiEggSetFrame' - - name: TEX_YoshiEggEffect
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x80911658
- target_func: 'TEX_YoshiEggEffect'
- - - name: TEX_YoshiSetColour
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x8005E9C8
- target_func: 'TEX_YoshiSetColour'
- - - name: TEX_YoshiHack
- type: branch_insn
- branch_type: bl
- src_addr_pal: 0x800FE58C
- target_func: 'TEX_YoshiHack'
- - - name: TEX_YoshiColourOrderA
- type: patch
- data: '3F8000004000000040400000'
- addr_pal: 0x8093DAB4
- - - name: TEX_YoshiColourOrderB
- type: patch
- data: '00000003000000010000000200000000'
- addr_pal: 0x8093DAD8
+ - name: TEX_YoshiEggEffect + type: branch_insn + branch_type: bl + src_addr_pal: 0x80911658 + target_func: 'TEX_YoshiEggEffect' + + - name: TEX_YoshiSetColour + type: branch_insn + branch_type: bl + src_addr_pal: 0x8005E9C8 + target_func: 'TEX_YoshiSetColour' + + - name: TEX_YoshiHack + type: branch_insn + branch_type: bl + src_addr_pal: 0x800FE58C + target_func: 'TEX_YoshiHack' + + - name: TEX_YoshiColourOrderA + type: patch + data: '3F8000004000000040400000' + addr_pal: 0x8093DAB4 + + - name: TEX_YoshiColourOrderB + type: patch + data: '00000003000000010000000200000000' + addr_pal: 0x8093DAD8 diff --git a/src/animtiles.cpp b/src/animtiles.cpp index 26cdbf8..2efba16 100644 --- a/src/animtiles.cpp +++ b/src/animtiles.cpp @@ -1,61 +1,61 @@ -#include <common.h>
-#include <game.h>
-#include "fileload.h"
-
-struct AnimDef_Header {
- u32 magic;
- u32 entryCount;
-};
-
-struct AnimDef_Entry {
- u16 texNameOffset;
- u16 frameDelayOffset;
- u16 tileNum;
- u8 tilesetNum;
- u8 reverse;
-};
-
-FileHandle fh;
-
-void DoTiles(void* self) {
- //OSReport("fucker\n");
- AnimDef_Header *header;
-
- header = (AnimDef_Header*)LoadFile(&fh, "/NewerRes/AnimTiles.bin");
-
- if (!header) {
- OSReport("anim load fail\n");
- return;
- }
-
- if (header->magic != 'NWRa') {
- OSReport("anim info incorrect\n");
- FreeFile(&fh);
- return;
- }
-
- AnimDef_Entry *entries = (AnimDef_Entry*)(header+1);
-
- OSReport("Loading animated tiles\n");
-
- for (int i = 0; i < header->entryCount; i++) {
- AnimDef_Entry *entry = &entries[i];
- char *name = (char*)fh.filePtr+entry->texNameOffset;
- char *frameDelays = (char*)fh.filePtr+entry->frameDelayOffset;
-
- char realName[0x40];
- snprintf(realName, 0x40, "BG_tex/%s", name);
-
- void *blah = BgTexMng__LoadAnimTile(self, entry->tilesetNum, entry->tileNum, realName, frameDelays, entry->reverse);
-
- OSReport("[%d] %s %08x\n", i, name, blah);
- //OSReport("Returned: %08x\n", blah);
- }
-
- OSReport("Animated tiles complete\n");
-}
-
-
-void DestroyTiles(void *self) {
- FreeFile(&fh);
-}
+#include <common.h> +#include <game.h> +#include "fileload.h" + +struct AnimDef_Header { + u32 magic; + u32 entryCount; +}; + +struct AnimDef_Entry { + u16 texNameOffset; + u16 frameDelayOffset; + u16 tileNum; + u8 tilesetNum; + u8 reverse; +}; + +FileHandle fh; + +void DoTiles(void* self) { + //OSReport("fucker\n"); + AnimDef_Header *header; + + header = (AnimDef_Header*)LoadFile(&fh, "/NewerRes/AnimTiles.bin"); + + if (!header) { + OSReport("anim load fail\n"); + return; + } + + if (header->magic != 'NWRa') { + OSReport("anim info incorrect\n"); + FreeFile(&fh); + return; + } + + AnimDef_Entry *entries = (AnimDef_Entry*)(header+1); + + OSReport("Loading animated tiles\n"); + + for (int i = 0; i < header->entryCount; i++) { + AnimDef_Entry *entry = &entries[i]; + char *name = (char*)fh.filePtr+entry->texNameOffset; + char *frameDelays = (char*)fh.filePtr+entry->frameDelayOffset; + + char realName[0x40]; + snprintf(realName, 0x40, "BG_tex/%s", name); + + void *blah = BgTexMng__LoadAnimTile(self, entry->tilesetNum, entry->tileNum, realName, frameDelays, entry->reverse); + + OSReport("[%d] %s %08x\n", i, name, blah); + //OSReport("Returned: %08x\n", blah); + } + + OSReport("Animated tiles complete\n"); +} + + +void DestroyTiles(void *self) { + FreeFile(&fh); +} diff --git a/src/crowdclapper.s b/src/crowdclapper.s new file mode 100644 index 0000000..786013f --- /dev/null +++ b/src/crowdclapper.s @@ -0,0 +1,39 @@ +.extern OneofManySoundPlayers +.extern EventTable + +#ifndef __MWERKS__ +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24 +.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29 +.set r30,30; .set r31,31; .set f0,0; .set f2,2; .set f3,3 +#endif + +.text +.align 4 + +.global CrowdClapperEventActivate +CrowdClapperEventActivate: + + mflr r0 + bl OneofManySoundPlayers + mtlr r0 + + lis r8, EventTable@h + ori r8, r8, EventTable@l + + lwz r11, 4(r8) + + lwz r9, 4(r31) + srwi r9, r9, 24 + + subi r9, r9, 1 + + li r10, 1 + slw r10, r10, r9 + + or r11, r11, r10 + stw r11, 0(r8) + blr
\ No newline at end of file diff --git a/src/eventlooper.cpp b/src/eventlooper.cpp index 755742d..6bc0526 100644 --- a/src/eventlooper.cpp +++ b/src/eventlooper.cpp @@ -1,37 +1,37 @@ -#include <common.h>
-#include <game.h>
-
-struct EventLooper {
- u32 id; // 0x00
- u32 settings; // 0x04
- u16 name; // 0x08
- u8 _0A[6]; // 0x0A
- u8 _10[0x9C]; // 0x10
- float x; // 0xAC
- float y; // 0xB0
- float z; // 0xB4
- u8 _B8[0x318]; // 0xB8
- // Any variables you add to the class go here; starting at offset 0x3D0
- u64 eventFlag; // 0x3D0
- u64 eventActive; // 0x3D0
- u8 delay; // 0x3D4
- u8 delayCount; // 0x3D7
-};
-
-struct EventTable_t {
- u64 events;
- // ...
-};
-
-extern EventTable_t *EventTable;
+#include <common.h> +#include <game.h> -void EventLooper_Update(EventLooper *self);
+struct EventLooper { + u32 id; // 0x00 + u32 settings; // 0x04 + u16 name; // 0x08 + u8 _0A[6]; // 0x0A + u8 _10[0x9C]; // 0x10 + float x; // 0xAC + float y; // 0xB0 + float z; // 0xB4 + u8 _B8[0x318]; // 0xB8 + // Any variables you add to the class go here; starting at offset 0x3D0 + u64 eventFlag; // 0x3D0 + u64 eventActive; // 0x3D0 + u8 delay; // 0x3D4 + u8 delayCount; // 0x3D7 +}; +struct EventTable_t { + u64 events; + // ... +}; -
-bool EventLooper_Create(EventLooper *self) {
- char eventStart = (self->settings >> 24) & 0xFF;
- char eventEnd = (self->settings >> 16) & 0xFF;
+extern EventTable_t *EventTable; + +void EventLooper_Update(EventLooper *self); + + + +bool EventLooper_Create(EventLooper *self) { + char eventStart = (self->settings >> 24) & 0xFF; + char eventEnd = (self->settings >> 16) & 0xFF; // Putting all the events into the flag int i; @@ -41,41 +41,41 @@ bool EventLooper_Create(EventLooper *self) { q = q | ((u64)1 << (i - 1)); } - self->eventFlag = q;
+ self->eventFlag = q; - self->delay = (((self->settings) & 0xFF) + 1) * 10;
- self->delayCount = 0;
+ self->delay = (((self->settings) & 0xFF) + 1) * 10; + self->delayCount = 0; - char tmpEvent= (self->settings >> 8) & 0xFF;
+ char tmpEvent= (self->settings >> 8) & 0xFF; if (tmpEvent == 0) { self->eventActive = (u64)0xFFFFFFFFFFFFFFFF; } else { - self->eventActive = (u64)1 << (tmpEvent - 1);
+ self->eventActive = (u64)1 << (tmpEvent - 1); } if (EventTable->events & self->eventActive) - {
+ { u64 evState = (u64)1 << (eventStart - 1); EventTable->events = EventTable->events | evState; } - EventLooper_Update(self);
-
- return true;
-}
-
-bool EventLooper_Execute(EventLooper *self) {
- EventLooper_Update(self);
- return true;
-}
-
+ EventLooper_Update(self); + + return true; +} + +bool EventLooper_Execute(EventLooper *self) { + EventLooper_Update(self); + return true; +} + -void EventLooper_Update(EventLooper *self) {
+void EventLooper_Update(EventLooper *self) { if ((EventTable->events & self->eventActive) == 0) return; @@ -83,7 +83,7 @@ void EventLooper_Update(EventLooper *self) { // Waiting for the right moment if (self->delayCount < self->delay) { -// OSReport("Delaying: %d / %d\n", self->delayCount, self->delay);
+// OSReport("Delaying: %d / %d\n", self->delayCount, self->delay); self->delayCount = self->delayCount + 1; return; @@ -93,7 +93,7 @@ void EventLooper_Update(EventLooper *self) { self->delayCount = 0; // Find which event(s) is/are on - u64 evState = EventTable->events & self->eventFlag;
+ u64 evState = EventTable->events & self->eventFlag; // Turn off the old events EventTable->events = EventTable->events & (~self->eventFlag); @@ -107,7 +107,7 @@ void EventLooper_Update(EventLooper *self) { else { - char eventStart = (self->settings >> 24) & 0xFF;
+ char eventStart = (self->settings >> 24) & 0xFF; evState = (u64)1 << (eventStart - 1); EventTable->events = EventTable->events | evState; } diff --git a/src/fileload.cpp b/src/fileload.cpp index 5f60e8c..fac7576 100644 --- a/src/fileload.cpp +++ b/src/fileload.cpp @@ -1,134 +1,134 @@ -#include "fileload.h"
-
-extern "C" void UncompressBackward(void *bottom);
-
-
-void *LoadFile(FileHandle *handle, const char *name) {
- OSReport("[LoadFile %s]\n", name);
-
- int entryNum = DVDConvertPathToEntrynum(name);
-
- DVDHandle dvdhandle;
- if (!DVDFastOpen(entryNum, &dvdhandle)) {
- OSReport("Cannot open file %s [%d]\n", name, entryNum);
- return 0;
- }
-
- handle->length = dvdhandle.length;
- handle->filePtr = EGG__Heap__alloc((handle->length+0x1F) & ~0x1F, 0x20, GetArchiveHeap());
-
- int ret = DVDReadPrio(&dvdhandle, handle->filePtr, (handle->length+0x1F) & ~0x1F, 0, 2);
-
- DVDClose(&dvdhandle);
-
- OSReport("[Success %p]\n", handle->filePtr);
-
- return handle->filePtr;
-}
-
-void *LoadCompressedFile(FileHandle *handle, const char *name) {
- OSReport("[LoadCompressedFile %s]\n", name);
-
- int entryNum = DVDConvertPathToEntrynum(name);
-
- DVDHandle dvdhandle;
- if (!DVDFastOpen(entryNum, &dvdhandle)) {
- OSReport("Cannot open file %s [%d]\n", name, entryNum);
- return 0;
- }
-
- u32 infoBlock[0x20 / sizeof(u32)] __attribute__ ((aligned(32)));
- DVDReadPrio(&dvdhandle, infoBlock, 0x20, dvdhandle.length - 8, 2);
-
- // Reverse it!
- infoBlock[1] = (infoBlock[1] >> 24) | ((infoBlock[1] >> 8) & 0xFF00) | ((infoBlock[1] & 0xFF00) << 8) | ((infoBlock[1] & 0xFF) << 24);
-
- u32 uncompSize = dvdhandle.length + infoBlock[1];
- OSReport("[Comp:%d UnComp:%d]\n", dvdhandle.length, uncompSize);
- handle->length = uncompSize;
- handle->filePtr = EGG__Heap__alloc((uncompSize+0x1F) & ~0x1F, 0x20, GetArchiveHeap());
-
- int ret = DVDReadPrio(&dvdhandle, handle->filePtr, (dvdhandle.length+0x1F) & ~0x1F, 0, 2);
-
- DVDClose(&dvdhandle);
-
- UncompressBackward((void*)((u32)handle->filePtr + dvdhandle.length));
-
- OSReport("[Success %p]\n", handle->filePtr);
-
- return handle->filePtr;
-}
-
-bool FreeFile(FileHandle *handle) {
- if (!handle) return false;
-
- if (handle->filePtr) {
- OSReport("[FreeFile %p]\n", handle->filePtr);
- EGG__Heap__free(handle->filePtr, GetArchiveHeap());
- }
-
- handle->filePtr = 0;
- handle->length = 0;
-
- return true;
-}
-
-
-
-
-File::File() {
- m_loaded = false;
-}
-
-File::~File() {
- close();
-}
-
-bool File::open(const char *filename) {
- if (m_loaded)
- close();
-
- void *ret = LoadFile(&m_handle, filename);
- if (ret != 0)
- m_loaded = true;
-
- return (ret != 0);
-}
-
-bool File::openCompressed(const char *filename) {
- if (m_loaded)
- close();
-
- void *ret = LoadCompressedFile(&m_handle, filename);
- if (ret != 0)
- m_loaded = true;
-
- return (ret != 0);
-}
-
-void File::close() {
- if (!m_loaded)
- return;
-
- m_loaded = false;
- FreeFile(&m_handle);
-}
-
-bool File::isOpen() {
- return m_loaded;
-}
-
-void *File::ptr() {
- if (m_loaded)
- return m_handle.filePtr;
- else
- return 0;
-}
-
-u32 File::length() {
- if (m_loaded)
- return m_handle.length;
- else
- return 0xFFFFFFFF;
-}
-
+#include "fileload.h" + +extern "C" void UncompressBackward(void *bottom); + + +void *LoadFile(FileHandle *handle, const char *name) { + OSReport("[LoadFile %s]\n", name); + + int entryNum = DVDConvertPathToEntrynum(name); + + DVDHandle dvdhandle; + if (!DVDFastOpen(entryNum, &dvdhandle)) { + OSReport("Cannot open file %s [%d]\n", name, entryNum); + return 0; + } + + handle->length = dvdhandle.length; + handle->filePtr = EGG__Heap__alloc((handle->length+0x1F) & ~0x1F, 0x20, GetArchiveHeap()); + + int ret = DVDReadPrio(&dvdhandle, handle->filePtr, (handle->length+0x1F) & ~0x1F, 0, 2); + + DVDClose(&dvdhandle); + + OSReport("[Success %p]\n", handle->filePtr); + + return handle->filePtr; +} + +void *LoadCompressedFile(FileHandle *handle, const char *name) { + OSReport("[LoadCompressedFile %s]\n", name); + + int entryNum = DVDConvertPathToEntrynum(name); + + DVDHandle dvdhandle; + if (!DVDFastOpen(entryNum, &dvdhandle)) { + OSReport("Cannot open file %s [%d]\n", name, entryNum); + return 0; + } + + u32 infoBlock[0x20 / sizeof(u32)] __attribute__ ((aligned(32))); + DVDReadPrio(&dvdhandle, infoBlock, 0x20, dvdhandle.length - 8, 2); + + // Reverse it! + infoBlock[1] = (infoBlock[1] >> 24) | ((infoBlock[1] >> 8) & 0xFF00) | ((infoBlock[1] & 0xFF00) << 8) | ((infoBlock[1] & 0xFF) << 24); + + u32 uncompSize = dvdhandle.length + infoBlock[1]; + OSReport("[Comp:%d UnComp:%d]\n", dvdhandle.length, uncompSize); + handle->length = uncompSize; + handle->filePtr = EGG__Heap__alloc((uncompSize+0x1F) & ~0x1F, 0x20, GetArchiveHeap()); + + int ret = DVDReadPrio(&dvdhandle, handle->filePtr, (dvdhandle.length+0x1F) & ~0x1F, 0, 2); + + DVDClose(&dvdhandle); + + UncompressBackward((void*)((u32)handle->filePtr + dvdhandle.length)); + + OSReport("[Success %p]\n", handle->filePtr); + + return handle->filePtr; +} + +bool FreeFile(FileHandle *handle) { + if (!handle) return false; + + if (handle->filePtr) { + OSReport("[FreeFile %p]\n", handle->filePtr); + EGG__Heap__free(handle->filePtr, GetArchiveHeap()); + } + + handle->filePtr = 0; + handle->length = 0; + + return true; +} + + + + +File::File() { + m_loaded = false; +} + +File::~File() { + close(); +} + +bool File::open(const char *filename) { + if (m_loaded) + close(); + + void *ret = LoadFile(&m_handle, filename); + if (ret != 0) + m_loaded = true; + + return (ret != 0); +} + +bool File::openCompressed(const char *filename) { + if (m_loaded) + close(); + + void *ret = LoadCompressedFile(&m_handle, filename); + if (ret != 0) + m_loaded = true; + + return (ret != 0); +} + +void File::close() { + if (!m_loaded) + return; + + m_loaded = false; + FreeFile(&m_handle); +} + +bool File::isOpen() { + return m_loaded; +} + +void *File::ptr() { + if (m_loaded) + return m_handle.filePtr; + else + return 0; +} + +u32 File::length() { + if (m_loaded) + return m_handle.length; + else + return 0xFFFFFFFF; +} + diff --git a/src/fileload.h b/src/fileload.h index 5dcdb2b..e5667ff 100644 --- a/src/fileload.h +++ b/src/fileload.h @@ -1,74 +1,74 @@ -#ifndef __NEWER_FILELOAD_H
-#define __NEWER_FILELOAD_H
-
-#include <common.h>
-
-struct FileHandle {
- void *filePtr;
- int length;
-};
-
-struct DVDHandle {
- int unk1; // 00
- int unk2; // 04
- int unk3; // 08
- int unk4; // 0C
- int unk5; // 10
- int unk6; // 14
- int unk7; // 18
- int unk8; // 1C
- int unk9; // 20
- int unk10; // 24
- int unk11; // 28
- int unk12; // 2C
- int address; // 30
- int length; // 34
- int unk13; // 38
-};
-
-
-int DVDConvertPathToEntrynum(const char *path);
-bool DVDFastOpen(int entrynum, DVDHandle *handle);
-int DVDReadPrio(DVDHandle *handle, void *buffer, int length, int offset, int unk);
-bool DVDClose(DVDHandle *handle);
-
-// EGG::Heap
-void *EGG__Heap__alloc(unsigned long size, int unk, void *heap);
-void EGG__Heap__free(void *ptr, void *heap);
-
-void *LoadFile(FileHandle *handle, const char *name);
-void *LoadCompressedFile(FileHandle *handle, const char *name);
-bool FreeFile(FileHandle *handle);
-
-void inline *GetArchiveHeap() {
- return ArchiveHeap;
-
-}
-
-
-// C++ interface
-class File {
-public:
- File();
- ~File();
-
- bool open(const char *filename);
- void close();
-
- bool openCompressed(const char *filename);
-
- bool isOpen();
-
- void *ptr();
- u32 length();
-
-private:
- FileHandle m_handle;
- bool m_loaded;
-};
-
-
-// Todo: input stream maybe?
-
-#endif
-
+#ifndef __NEWER_FILELOAD_H +#define __NEWER_FILELOAD_H + +#include <common.h> + +struct FileHandle { + void *filePtr; + int length; +}; + +struct DVDHandle { + int unk1; // 00 + int unk2; // 04 + int unk3; // 08 + int unk4; // 0C + int unk5; // 10 + int unk6; // 14 + int unk7; // 18 + int unk8; // 1C + int unk9; // 20 + int unk10; // 24 + int unk11; // 28 + int unk12; // 2C + int address; // 30 + int length; // 34 + int unk13; // 38 +}; + + +int DVDConvertPathToEntrynum(const char *path); +bool DVDFastOpen(int entrynum, DVDHandle *handle); +int DVDReadPrio(DVDHandle *handle, void *buffer, int length, int offset, int unk); +bool DVDClose(DVDHandle *handle); + +// EGG::Heap +void *EGG__Heap__alloc(unsigned long size, int unk, void *heap); +void EGG__Heap__free(void *ptr, void *heap); + +void *LoadFile(FileHandle *handle, const char *name); +void *LoadCompressedFile(FileHandle *handle, const char *name); +bool FreeFile(FileHandle *handle); + +void inline *GetArchiveHeap() { + return ArchiveHeap; + +} + + +// C++ interface +class File { +public: + File(); + ~File(); + + bool open(const char *filename); + void close(); + + bool openCompressed(const char *filename); + + bool isOpen(); + + void *ptr(); + u32 length(); + +private: + FileHandle m_handle; + bool m_loaded; +}; + + +// Todo: input stream maybe? + +#endif + diff --git a/src/gakenoko.S b/src/gakenoko.S index 9443ce4..3f12501 100644 --- a/src/gakenoko.S +++ b/src/gakenoko.S @@ -1,220 +1,220 @@ -# GAKE CLASS LAYOUT
-#
-# 524: SomeMHeapAllocatorSubclass
-# 540: 0 [[ResFile maybe?]]
-# 544: mdl_c
-# 584: SomeModelAnimationClass
-# 5BC: ResAnmTexPat (maybe?)
-# 5C0: Some type of animation: 80329890
-# 5C4: Set to 0 in ctor
-# 5C8: Set to 0 in ctor
-# 5CC: mAllocator_c
-# 5F4: EGG::Effect subclass 80329CA0
-#
-#
-# NET CLASS LAYOUT
-#
-# 524: 0
-# 528: SomeMHeapAllocatorSubclass
-# 544: ResFile
-# 548: mdl_c
-# 588: SomeModelAnimationClass
-# 5C0: ResAnmTexPat
-# 5C4: Some type of animation: 80329890
-# 5C8: Set to 0 in ctor
-# 5CC: Set to 0 in ctor
-# 5D0: mAllocator_c
-
-.extern mHeapAllocatorSubclass_Link
-.extern mHeapAllocatorSubclass_UnLink
-.extern RetrieveFileFromArc
-.extern GetResMdl
-.extern m3d__mdl_c__DoStuff
-.extern sub_80064BD0
-.extern GetResAnmChr
-.extern SomeModelAnimationClass_Setup
-.extern GetResAnmTexPat
-.extern sub_80166970
-.extern sub_80166D10
-.extern daEnGakeNoko_c__StateID_FoolMove
-
-#ifndef __MWERKS__
-.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4
-.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
-.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
-.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
-.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
-.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
-.set r30,30; .set r31,31; .set f0,0; .set f2,2; .set f3,3
-#endif
-
-.set sp,1
-.set rtoc,2
-.set this,31
-
-.text
-
-.align 4
-.global gakenoko_create
-
-.set AnmTexPat,0x24
-.set ResMdlForTexPat,0x20
-.set AnmChr,0x1C
-.set ResMdlForChr,0x18
-.set ResMdlForScnMdl,0x14
-.set AnmTexPatAgain,0x10
-
-# Stack layout:
-# 0x34 : LR
-# 0x30 : SP
-# 0x2C : save this
-# 0x28 : save r30
-# 0x24 : AnmTexPat
-# 0x20 : ResMdlForTexPat
-# 0x1C : AnmChr
-# 0x18 : ResMdlForChr
-# 0x14 : ResMdlForScnMdl
-# 0x10 : AnmTexPatAgain
-
-# Local register vars:
-# r31 = this
-# r30 = resmdl
-
-gakenoko_create:
- stwu r1, -0x30(sp)
- mflr r0
- stw r0, 0x34(sp)
- stw this, 0x2C(sp)
- stw r30, 0x28(sp)
-
- mr this, r3
-
- # Create a heap
- addi r3, r3, 0x524 # SomeMHeapAllocatorSubclass
- li r4, -1
- lis r5, 0x8037
- lwz r5, 0x7F48(r5)
- bl mHeapAllocatorSubclass_Link
-
- # Get ResFile
- lwz r3, -0x5668(r13)
- addi r3, r3, 4
- lis r4, arcName@h
- ori r4, r4, arcName@l
- lis r5, fileName@h
- ori r5, r5, fileName@l
- bl RetrieveFileFromArc
-
- stw r3, 0x540(this)
-
- # Get model
- addi r3, this, 0x540 # ResFile
- lis r4, arcName@h
- ori r4, r4, arcName@l
- bl GetResMdl
-
- mr r30, r3
- stw r3, ResMdlForScnMdl(sp) # store resmdl
-
- # Do scnmdl stuff
- addi r3, this, 0x544 # mdl_c
- addi r4, sp, ResMdlForScnMdl
- addi r5, this, 0x524 # SomeMHeapAllocatorSubclass
- li r6, 0x7fff
- li r7, 1
- li r8, 0
- bl m3d__mdl_c__DoStuff
-
- addi r3, this, 0x544 # mdl_c
- bl sub_80064BD0
-
- # Handle anim
- addi r3, this, 0x540 # ResFile
- lis r4, animName@h
- ori r4, r4, animName@l
- bl GetResAnmChr
-
- stw r3, AnmChr(sp)
-
- # Set it up
- stw r30, ResMdlForChr(sp)
-
- addi r3, this, 0x584 # SomeModelAnimationClass
- addi r4, sp, ResMdlForChr
- addi r5, sp, AnmChr
- addi r6, this, 0x524 # SomeMHeapAllocatorSubclass
- li r7, 0
- bl SomeModelAnimationClass_Setup
-
- # Now handle the texpat anim
- addi r3, this, 0x540 # ResFile
- lis r4, arcName@h
- ori r4, r4, arcName@l
- bl GetResAnmTexPat
-
- stw r3, 0x5BC(this) # ResAnmTexPat
- stw r3, AnmTexPat(sp)
-
- # Set it up
- stw r30, ResMdlForTexPat(sp)
-
- addi r3, this, 0x5C0 # Weird Animation
- addi r4, sp, ResMdlForTexPat
- addi r5, sp, AnmTexPat
- addi r6, this, 0x524 # SomeMHeapAllocatorSubclass
- li r7, 0
- li r8, 1
- bl sub_80166970
-
-
- lwz r0, 0x5BC(this)
- stw r0, AnmTexPatAgain(sp)
-
- addi r3, this, 0x5C0 # Weird Animation
- addi r4, this, 0x544 # mdl_c
- addi r5, sp, AnmTexPatAgain
- li r6, 0
- li r7, 1
- bl sub_80166D10
-
- # Unbind the MHeapAllocatorSubclass
- addi r3, this, 0x524 # SomeMHeapAllocatorSubclass
- bl mHeapAllocatorSubclass_UnLink
-
-
- # Model's done
- # Set a state
- mr r3, this
- lis r4, daEnGakeNoko_c__StateID_FoolMove@h
- ori r4, r4, daEnGakeNoko_c__StateID_FoolMove@l
-
- lwz r12, 0x60(this)
- lwz r12, 0xD4(r12)
- mtctr r12
-
-
- li r3, 1
-
- # Clean up stack
- lwz r0, 0x34(sp)
- lwz this, 0x2C(sp)
- lwz r30, 0x28(sp)
- mtlr r0
- addi sp, sp, 0x30
-
- blr
-
-
-.data
-
-fileName:
- .string "g3d/nokonokoB.brres"
-
-arcName:
- .string "nokonokoB"
-
-animName:
- .string "net_walk2"
-
-debugString:
- .string "X> %08x\n"
+# GAKE CLASS LAYOUT +# +# 524: SomeMHeapAllocatorSubclass +# 540: 0 [[ResFile maybe?]] +# 544: mdl_c +# 584: SomeModelAnimationClass +# 5BC: ResAnmTexPat (maybe?) +# 5C0: Some type of animation: 80329890 +# 5C4: Set to 0 in ctor +# 5C8: Set to 0 in ctor +# 5CC: mAllocator_c +# 5F4: EGG::Effect subclass 80329CA0 +# +# +# NET CLASS LAYOUT +# +# 524: 0 +# 528: SomeMHeapAllocatorSubclass +# 544: ResFile +# 548: mdl_c +# 588: SomeModelAnimationClass +# 5C0: ResAnmTexPat +# 5C4: Some type of animation: 80329890 +# 5C8: Set to 0 in ctor +# 5CC: Set to 0 in ctor +# 5D0: mAllocator_c + +.extern mHeapAllocatorSubclass_Link +.extern mHeapAllocatorSubclass_UnLink +.extern RetrieveFileFromArc +.extern GetResMdl +.extern m3d__mdl_c__DoStuff +.extern sub_80064BD0 +.extern GetResAnmChr +.extern SomeModelAnimationClass_Setup +.extern GetResAnmTexPat +.extern sub_80166970 +.extern sub_80166D10 +.extern daEnGakeNoko_c__StateID_FoolMove + +#ifndef __MWERKS__ +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24 +.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29 +.set r30,30; .set r31,31; .set f0,0; .set f2,2; .set f3,3 +#endif + +.set sp,1 +.set rtoc,2 +.set this,31 + +.text + +.align 4 +.global gakenoko_create + +.set AnmTexPat,0x24 +.set ResMdlForTexPat,0x20 +.set AnmChr,0x1C +.set ResMdlForChr,0x18 +.set ResMdlForScnMdl,0x14 +.set AnmTexPatAgain,0x10 + +# Stack layout: +# 0x34 : LR +# 0x30 : SP +# 0x2C : save this +# 0x28 : save r30 +# 0x24 : AnmTexPat +# 0x20 : ResMdlForTexPat +# 0x1C : AnmChr +# 0x18 : ResMdlForChr +# 0x14 : ResMdlForScnMdl +# 0x10 : AnmTexPatAgain + +# Local register vars: +# r31 = this +# r30 = resmdl + +gakenoko_create: + stwu r1, -0x30(sp) + mflr r0 + stw r0, 0x34(sp) + stw this, 0x2C(sp) + stw r30, 0x28(sp) + + mr this, r3 + + # Create a heap + addi r3, r3, 0x524 # SomeMHeapAllocatorSubclass + li r4, -1 + lis r5, 0x8037 + lwz r5, 0x7F48(r5) + bl mHeapAllocatorSubclass_Link + + # Get ResFile + lwz r3, -0x5668(r13) + addi r3, r3, 4 + lis r4, arcName@h + ori r4, r4, arcName@l + lis r5, fileName@h + ori r5, r5, fileName@l + bl RetrieveFileFromArc + + stw r3, 0x540(this) + + # Get model + addi r3, this, 0x540 # ResFile + lis r4, arcName@h + ori r4, r4, arcName@l + bl GetResMdl + + mr r30, r3 + stw r3, ResMdlForScnMdl(sp) # store resmdl + + # Do scnmdl stuff + addi r3, this, 0x544 # mdl_c + addi r4, sp, ResMdlForScnMdl + addi r5, this, 0x524 # SomeMHeapAllocatorSubclass + li r6, 0x7fff + li r7, 1 + li r8, 0 + bl m3d__mdl_c__DoStuff + + addi r3, this, 0x544 # mdl_c + bl sub_80064BD0 + + # Handle anim + addi r3, this, 0x540 # ResFile + lis r4, animName@h + ori r4, r4, animName@l + bl GetResAnmChr + + stw r3, AnmChr(sp) + + # Set it up + stw r30, ResMdlForChr(sp) + + addi r3, this, 0x584 # SomeModelAnimationClass + addi r4, sp, ResMdlForChr + addi r5, sp, AnmChr + addi r6, this, 0x524 # SomeMHeapAllocatorSubclass + li r7, 0 + bl SomeModelAnimationClass_Setup + + # Now handle the texpat anim + addi r3, this, 0x540 # ResFile + lis r4, arcName@h + ori r4, r4, arcName@l + bl GetResAnmTexPat + + stw r3, 0x5BC(this) # ResAnmTexPat + stw r3, AnmTexPat(sp) + + # Set it up + stw r30, ResMdlForTexPat(sp) + + addi r3, this, 0x5C0 # Weird Animation + addi r4, sp, ResMdlForTexPat + addi r5, sp, AnmTexPat + addi r6, this, 0x524 # SomeMHeapAllocatorSubclass + li r7, 0 + li r8, 1 + bl sub_80166970 + + + lwz r0, 0x5BC(this) + stw r0, AnmTexPatAgain(sp) + + addi r3, this, 0x5C0 # Weird Animation + addi r4, this, 0x544 # mdl_c + addi r5, sp, AnmTexPatAgain + li r6, 0 + li r7, 1 + bl sub_80166D10 + + # Unbind the MHeapAllocatorSubclass + addi r3, this, 0x524 # SomeMHeapAllocatorSubclass + bl mHeapAllocatorSubclass_UnLink + + + # Model's done + # Set a state + mr r3, this + lis r4, daEnGakeNoko_c__StateID_FoolMove@h + ori r4, r4, daEnGakeNoko_c__StateID_FoolMove@l + + lwz r12, 0x60(this) + lwz r12, 0xD4(r12) + mtctr r12 + + + li r3, 1 + + # Clean up stack + lwz r0, 0x34(sp) + lwz this, 0x2C(sp) + lwz r30, 0x28(sp) + mtlr r0 + addi sp, sp, 0x30 + + blr + + +.data + +fileName: + .string "g3d/nokonokoB.brres" + +arcName: + .string "nokonokoB" + +animName: + .string "net_walk2" + +debugString: + .string "X> %08x\n" diff --git a/src/growup.s b/src/growup.s index b8d8922..11fa5b4 100755 --- a/src/growup.s +++ b/src/growup.s @@ -1,14 +1,14 @@ -#ifndef __MWERKS__
-.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4
-.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
-.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
-.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
-.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
-.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
+#ifndef __MWERKS__ +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24 +.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29 .set r30,30; .set r31,31; .set f0,0; .set f1,1; .set f2,2 .set f3,3; .set f4,4; .set f5,5; .set f6,6; .set f8,8 -.set f31,31; .set f30,30
-#endif
+.set f31,31; .set f30,30 +#endif .text @@ -24,7 +24,7 @@ LoadFromSettingsS: # we can trash r12 for now, it's not supposed to be guaranteed anyway lwz r12, 4(r3) # get the sprite settings srwi r12, r12, 20 # get the highest nybble as r10 (maps to Nyb7 in Reggie) - andi. r12, r12, 0xF
+ andi. r12, r12, 0xF # first off, get the value from the lookup table lis r11, LookupTable@h @@ -38,7 +38,7 @@ LoadFromSettingsSF: # we can trash r12 for now, it's not supposed to be guaranteed anyway lwz r12, 4(r3) # get the sprite settings srwi r12, r12, 28 # get the highest nybble as r12 (maps to Nyb5 in Reggie) - andi. r12, r12, 0xF
+ andi. r12, r12, 0xF # first off, get the value from the lookup table lis r11, LookupTable@h @@ -52,7 +52,7 @@ LoadFromSettingsC: # we can trash r12 for now, it's not supposed to be guaranteed anyway lwz r12, 4(r4) # get the sprite settings srwi r12, r12, 20 # get the highest nybble as r12 (maps to Nyb7 in Reggie) - andi. r12, r12, 0xF
+ andi. r12, r12, 0xF # first off, get the value from the lookup table lis r11, LookupTable@h @@ -66,7 +66,7 @@ LoadFromSettingsCF: # we can trash r12 for now, it's not supposed to be guaranteed anyway lwz r12, 4(r4) # get the sprite settings srwi r12, r12, 28 # get the highest nybble as r12 (maps to Nyb5 in Reggie) - andi. r12, r12, 0xF
+ andi. r12, r12, 0xF # first off, get the value from the lookup table lis r11, LookupTable@h @@ -80,7 +80,7 @@ LoadFromSettingsH: # we can trash r12 for now, it's not supposed to be guaranteed anyway lwz r12, 4(r30) # get the sprite settings srwi r12, r12, 20 # get the highest nybble as r12 (maps to Nyb7 in Reggie) - andi. r12, r12, 0xF
+ andi. r12, r12, 0xF # first off, get the value from the lookup table lis r11, RiderLookupTable@h @@ -94,7 +94,7 @@ LoadFromSettingsHF: # we can trash r12 for now, it's not supposed to be guaranteed anyway lwz r12, 4(r30) # get the sprite settings srwi r12, r12, 28 # get the highest nybble as r12 (maps to Nyb5 in Reggie) - andi. r12, r12, 0xF
+ andi. r12, r12, 0xF # first off, get the value from the lookup table lis r11, RiderLookupTable@h @@ -108,7 +108,7 @@ LoadFromSettingsL: # we can trash r12 for now, it's not supposed to be guaranteed anyway lwz r12, 8(r30) # get the sprite settings srwi r12, r12, 20 # get the highest nybble as r12 (maps to Nyb7 in Reggie) - andi. r12, r12, 0xF
+ andi. r12, r12, 0xF # first off, get the value from the lookup table lis r11, LookupTable@h @@ -122,7 +122,7 @@ LoadFromSettingsLF: # we can trash r12 for now, it's not supposed to be guaranteed anyway lwz r12, 8(r30) # get the sprite settings srwi r12, r12, 28 # get the highest nybble as r12 (maps to Nyb5 in Reggie) - andi. r12, r12, 0xF
+ andi. r12, r12, 0xF # first off, get the value from the lookup table lis r11, LookupTable@h @@ -531,7 +531,7 @@ ModifyStandOnTopInitA: lwz r10, 4(r3) lwz r10, 4(r10) # get the sprite settings srwi r10, r10, 20 # get the highest nybble as r10 (maps to Nyb5 in Reggie) - andi. r10, r10, 0xF
+ andi. r10, r10, 0xF # first off, get the value from the lookup table lis r11, LookupTable@h @@ -562,7 +562,7 @@ ModifyStandOnTopInitB: lwz r10, 4(r3) lwz r10, 4(r10) # get the sprite settings srwi r10, r10, 20 # get the highest nybble as r10 (maps to Nyb5 in Reggie) - andi. r10, r10, 0xF
+ andi. r10, r10, 0xF # first off, get the value from the lookup table lis r11, LookupTable@h @@ -618,7 +618,7 @@ ModifyStandOnTopInitD: lwz r10, 4(r3) lwz r10, 4(r10) # get the sprite settings srwi r10, r10, 20 # get the highest nybble as r10 (maps to Nyb5 in Reggie) - andi. r10, r10, 0xF
+ andi. r10, r10, 0xF # first off, get the value from the lookup table lis r11, LookupTable@h diff --git a/src/heapbar.S b/src/heapbar.S index 35d45e5..4f86fbe 100644 --- a/src/heapbar.S +++ b/src/heapbar.S @@ -1,118 +1,118 @@ -# memory debugger - fun!
-# GX stuff is implemented in C++, this just gets the lowlevel info
-
-#ifndef __MWERKS__
-.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4
-.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
-.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
-.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
-.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
-.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
-.set r30,30; .set r31,31; .set f0,0; .set f2,2; .set f3,3
-#endif
-
-#define HEAP_EGGRootMEM1 1
-#define HEAP_EGGRootMEM2 2
-
-.extern cppGXStart
-.extern cppGXEnd
-.extern cppProcessHeap
-.extern MEMGetTotalFreeSizeForExpHeap
-.extern GameHeap1
-.extern GameHeap2
-
-.set sp,1
-.set rtoc,2
-.set this,31
-
-.text
-
-.align 4
-
-.global doHeapBar
-
-doHeapBar:
- blr
-
- stwu sp, -0x10(sp)
- mflr r0
- stw r0, 0x14(sp)
-
- stw this, 0xC(sp)
-
- #lis r3, EGGTSystem_Pointer@h
- #ori r3, r3, EGGTSystem_Pointer@l
- #lwz this, 0(r3)
-
- bl cppGXStart
-
- #lwz r3, 0x18(this)
- #lis r3, dSys_c__RootHeapMEM1@h
- #ori r3, r3, dSys_c__RootHeapMEM1@l
- lis r3, GameHeap1@h
- ori r3, r3, GameHeap1@l
- lwz r3, 0(r3)
- li r4, HEAP_EGGRootMEM1
- bl asmProcessHeap
-
- #lwz r3, 0x1C(this)
- #lis r3, dSys_c__RootHeapMEM2@h
- #ori r3, r3, dSys_c__RootHeapMEM2@l
- lis r3, GameHeap2@h
- ori r3, r3, GameHeap2@l
- lwz r3, 0(r3)
- li r4, HEAP_EGGRootMEM2
- bl asmProcessHeap
-
- bl cppGXEnd
-
- lwz this, 0xC(sp)
- lwz r0, 0x14(sp)
- mtlr r0
- addi sp, sp, 0x10
- blr
-
-
-
-asmProcessHeap:
-
- stwu sp, -0x10(sp)
- mflr r0
- stw r0, 0x14(sp)
-
- stw r31, 0xC(sp)
- stw r30, 0x8(sp)
-
- mr r31, r3
- mr r30, r4
-
- # get all the required data from the heap
- # cppProcessHeap(u32 freeSize, u32 heapSize, int heapID, char *name)
-
- # get free size first so the function doesn't destroy our volatile regs
- # because I'm too lazy to save them >.>
- lwz r3, 0x10(r31)
- bl MEMGetTotalFreeSizeForExpHeap
-
- # get name
- lwz r6, 0x34(r31)
-
- # get heapID
- mr r5, r30
-
- # get heap size
- # this was a fucking pain to figure out -_-
- lwz r4, 0x10(r31) # get the MEMiHeapHead*
- lwz r7, 0x18(r4) # get heapStart
- lwz r8, 0x1C(r4) # get heapEnd
- sub r4, r8, r7 # heapSize = heapEnd - heapStart probably
-
- # now do it
- bl cppProcessHeap
-
- lwz r30, 0x8(sp)
- lwz r31, 0xC(sp)
- lwz r0, 0x14(sp)
- mtlr r0
- addi sp, sp, 0x10
- blr
+# memory debugger - fun! +# GX stuff is implemented in C++, this just gets the lowlevel info + +#ifndef __MWERKS__ +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24 +.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29 +.set r30,30; .set r31,31; .set f0,0; .set f2,2; .set f3,3 +#endif + +#define HEAP_EGGRootMEM1 1 +#define HEAP_EGGRootMEM2 2 + +.extern cppGXStart +.extern cppGXEnd +.extern cppProcessHeap +.extern MEMGetTotalFreeSizeForExpHeap +.extern GameHeap1 +.extern GameHeap2 + +.set sp,1 +.set rtoc,2 +.set this,31 + +.text + +.align 4 + +.global doHeapBar + +doHeapBar: + blr + + stwu sp, -0x10(sp) + mflr r0 + stw r0, 0x14(sp) + + stw this, 0xC(sp) + + #lis r3, EGGTSystem_Pointer@h + #ori r3, r3, EGGTSystem_Pointer@l + #lwz this, 0(r3) + + bl cppGXStart + + #lwz r3, 0x18(this) + #lis r3, dSys_c__RootHeapMEM1@h + #ori r3, r3, dSys_c__RootHeapMEM1@l + lis r3, GameHeap1@h + ori r3, r3, GameHeap1@l + lwz r3, 0(r3) + li r4, HEAP_EGGRootMEM1 + bl asmProcessHeap + + #lwz r3, 0x1C(this) + #lis r3, dSys_c__RootHeapMEM2@h + #ori r3, r3, dSys_c__RootHeapMEM2@l + lis r3, GameHeap2@h + ori r3, r3, GameHeap2@l + lwz r3, 0(r3) + li r4, HEAP_EGGRootMEM2 + bl asmProcessHeap + + bl cppGXEnd + + lwz this, 0xC(sp) + lwz r0, 0x14(sp) + mtlr r0 + addi sp, sp, 0x10 + blr + + + +asmProcessHeap: + + stwu sp, -0x10(sp) + mflr r0 + stw r0, 0x14(sp) + + stw r31, 0xC(sp) + stw r30, 0x8(sp) + + mr r31, r3 + mr r30, r4 + + # get all the required data from the heap + # cppProcessHeap(u32 freeSize, u32 heapSize, int heapID, char *name) + + # get free size first so the function doesn't destroy our volatile regs + # because I'm too lazy to save them >.> + lwz r3, 0x10(r31) + bl MEMGetTotalFreeSizeForExpHeap + + # get name + lwz r6, 0x34(r31) + + # get heapID + mr r5, r30 + + # get heap size + # this was a fucking pain to figure out -_- + lwz r4, 0x10(r31) # get the MEMiHeapHead* + lwz r7, 0x18(r4) # get heapStart + lwz r8, 0x1C(r4) # get heapEnd + sub r4, r8, r7 # heapSize = heapEnd - heapStart probably + + # now do it + bl cppProcessHeap + + lwz r30, 0x8(sp) + lwz r31, 0xC(sp) + lwz r0, 0x14(sp) + mtlr r0 + addi sp, sp, 0x10 + blr diff --git a/src/heapbar.cpp b/src/heapbar.cpp index 3759b22..386427d 100644 --- a/src/heapbar.cpp +++ b/src/heapbar.cpp @@ -1,147 +1,147 @@ -#define GEKKO
-
-#include <common.h>
-#include "rvl/mtx.h"
-#include "rvl/GXEnum.h"
-#include "rvl/GXStruct.h"
-#include "rvl/GXTransform.h"
-#include "rvl/GXGeometry.h"
-#include "rvl/GXDispList.h"
-#include "rvl/GXLighting.h"
-#include "rvl/GXTev.h"
-#include "rvl/GXTexture.h"
-#include "rvl/GXCull.h"
-#include "rvl/GXPixel.h"
-#include "rvl/GXBump.h"
-//#include "rvl/GXVert.h"
-#include "rvl/vifuncs.h"
-
-extern u32 Global5758;
-
-#define GXPosition3f32(x,y,z) \
- *((volatile float*)0xCC008000) = (x); \
- *((volatile float*)0xCC008000) = (y); \
- *((volatile float*)0xCC008000) = (z);
-
-#define GXColor1u32(x) \
- *((volatile u32*)0xCC008000) = (x);
-
-
-extern "C" {
-
-
-void cppGXStart() {
- Mtx44 ortho;
-
- MTXOrtho(ortho, 0, 456, 0, 686, 0.0F, 1.0F);
- GXSetProjection(ortho, GX_ORTHOGRAPHIC);
-
- Mtx identity;
- MTXIdentity(identity);
-
- GXLoadPosMtxImm(identity, GX_PNMTX0);
-
- GXSetNumTevStages(1);
- GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
- GXSetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
- GXSetTevDirect(GX_TEVSTAGE0);
-
- GXSetNumChans(1);
- GXSetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_VTX, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE);
-
- GXClearVtxDesc();
- GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
- GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
- GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
- GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBX8, 0);
-
- GXSetZMode(GX_TRUE, GX_ALWAYS, GX_TRUE);
-}
-
-void cppGXEnd() {
-}
-
-
-
-float y_positions[] = {
- -1,
- 0.0,
- 16.0
-};
-
-u32 colours[] = {
- -1,
- 0x0000ffff,
- 0xff0000ff
-};
-
-u32 col_5758[] = {
- 0x00ff00ff,
- 0xffff00ff,
- 0x00ffffff,
- 0xf0ff0fff
-};
-
-void cppProcessHeap(u32 freeSize, u32 heapSize, int heapID, char *name) {
- // get the info needed
- float y_pos = y_positions[heapID];
- u32 colour = colours[heapID];
-
- // width: 686
-
- //OSReport("%s => size %d, free %d\n", name, heapSize, freeSize);
-
- float left = 0;
- float right = ((heapSize - freeSize) * 686.0f) / heapSize;
- float top = y_pos;
- float bottom = y_pos+16;
-
- GXBegin(GX_QUADS, GX_VTXFMT0, 4);
-
- GXPosition3f32(left, top, 0.0);
- GXColor1u32(colour);
- GXPosition3f32(right, top, 0.0);
- GXColor1u32(colour);
- GXPosition3f32(right, bottom, 0.0);
- GXColor1u32(colour);
- GXPosition3f32(left, bottom, 0.0);
- GXColor1u32(colour);
-
- GXEnd();
-
-
- GXBegin(GX_QUADS, GX_VTXFMT0, 16);
-
- for (int i = 0; i < 4; i++) {
- GXPosition3f32(16*i, 32, 0.0);
- GXColor1u32(col_5758[i]);
- GXPosition3f32(16*i+16, 32, 0.0);
- GXColor1u32(col_5758[i]);
- GXPosition3f32(16*i+16, 48, 0.0);
- GXColor1u32(col_5758[i]);
- GXPosition3f32(16*i, 48, 0.0);
- GXColor1u32(col_5758[i]);
- }
-
- GXEnd();
-
- for (int i = 0; i < 4; i++) {
- if (Global5758 & (1 << i)) {
- GXBegin(GX_QUADS, GX_VTXFMT0, 4);
-
- GXPosition3f32(16*i, 48, 0.0);
- GXColor1u32(0xffffffff);
- GXPosition3f32(16*i+16, 48, 0.0);
- GXColor1u32(0xffffffff);
- GXPosition3f32(16*i+16, 56, 0.0);
- GXColor1u32(0xffffffff);
- GXPosition3f32(16*i, 56, 0.0);
- GXColor1u32(0xffffffff);
-
- GXEnd();
- }
- }
-}
-
-
-};
+#define GEKKO + +#include <common.h> +#include "rvl/mtx.h" +#include "rvl/GXEnum.h" +#include "rvl/GXStruct.h" +#include "rvl/GXTransform.h" +#include "rvl/GXGeometry.h" +#include "rvl/GXDispList.h" +#include "rvl/GXLighting.h" +#include "rvl/GXTev.h" +#include "rvl/GXTexture.h" +#include "rvl/GXCull.h" +#include "rvl/GXPixel.h" +#include "rvl/GXBump.h" +//#include "rvl/GXVert.h" +#include "rvl/vifuncs.h" + +extern u32 Global5758; + +#define GXPosition3f32(x,y,z) \ + *((volatile float*)0xCC008000) = (x); \ + *((volatile float*)0xCC008000) = (y); \ + *((volatile float*)0xCC008000) = (z); + +#define GXColor1u32(x) \ + *((volatile u32*)0xCC008000) = (x); + + +extern "C" { + + +void cppGXStart() { + Mtx44 ortho; + + MTXOrtho(ortho, 0, 456, 0, 686, 0.0F, 1.0F); + GXSetProjection(ortho, GX_ORTHOGRAPHIC); + + Mtx identity; + MTXIdentity(identity); + + GXLoadPosMtxImm(identity, GX_PNMTX0); + + GXSetNumTevStages(1); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0); + GXSetTevOp(GX_TEVSTAGE0, GX_PASSCLR); + GXSetTevDirect(GX_TEVSTAGE0); + + GXSetNumChans(1); + GXSetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_VTX, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE); + + GXClearVtxDesc(); + GXSetVtxDesc(GX_VA_POS, GX_DIRECT); + GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBX8, 0); + + GXSetZMode(GX_TRUE, GX_ALWAYS, GX_TRUE); +} + +void cppGXEnd() { +} + + + +float y_positions[] = { + -1, + 0.0, + 16.0 +}; + +u32 colours[] = { + -1, + 0x0000ffff, + 0xff0000ff +}; + +u32 col_5758[] = { + 0x00ff00ff, + 0xffff00ff, + 0x00ffffff, + 0xf0ff0fff +}; + +void cppProcessHeap(u32 freeSize, u32 heapSize, int heapID, char *name) { + // get the info needed + float y_pos = y_positions[heapID]; + u32 colour = colours[heapID]; + + // width: 686 + + //OSReport("%s => size %d, free %d\n", name, heapSize, freeSize); + + float left = 0; + float right = ((heapSize - freeSize) * 686.0f) / heapSize; + float top = y_pos; + float bottom = y_pos+16; + + GXBegin(GX_QUADS, GX_VTXFMT0, 4); + + GXPosition3f32(left, top, 0.0); + GXColor1u32(colour); + GXPosition3f32(right, top, 0.0); + GXColor1u32(colour); + GXPosition3f32(right, bottom, 0.0); + GXColor1u32(colour); + GXPosition3f32(left, bottom, 0.0); + GXColor1u32(colour); + + GXEnd(); + + + GXBegin(GX_QUADS, GX_VTXFMT0, 16); + + for (int i = 0; i < 4; i++) { + GXPosition3f32(16*i, 32, 0.0); + GXColor1u32(col_5758[i]); + GXPosition3f32(16*i+16, 32, 0.0); + GXColor1u32(col_5758[i]); + GXPosition3f32(16*i+16, 48, 0.0); + GXColor1u32(col_5758[i]); + GXPosition3f32(16*i, 48, 0.0); + GXColor1u32(col_5758[i]); + } + + GXEnd(); + + for (int i = 0; i < 4; i++) { + if (Global5758 & (1 << i)) { + GXBegin(GX_QUADS, GX_VTXFMT0, 4); + + GXPosition3f32(16*i, 48, 0.0); + GXColor1u32(0xffffffff); + GXPosition3f32(16*i+16, 48, 0.0); + GXColor1u32(0xffffffff); + GXPosition3f32(16*i+16, 56, 0.0); + GXColor1u32(0xffffffff); + GXPosition3f32(16*i, 56, 0.0); + GXColor1u32(0xffffffff); + + GXEnd(); + } + } +} + + +}; diff --git a/src/layoutlib.S b/src/layoutlib.S index 2fae70a..96c69cb 100644 --- a/src/layoutlib.S +++ b/src/layoutlib.S @@ -1,131 +1,131 @@ -.extern LayoutHelper_Link
-
-#ifndef __MWERKS__
-.extern _Z8LoadFileP10FileHandlePc
-.extern _Z8FreeFileP10FileHandle
-#define LoadFileFunc _Z8LoadFileP10FileHandlePc
-#define FreeFileFunc _Z8FreeFileP10FileHandle
-.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4
-.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
-.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
-.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
-.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
-.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
-.set r30,30; .set r31,31; .set f0,0; .set f2,2; .set f3,3
-#else
-.extern LoadFile__FP10FileHandlePCc
-.extern FreeFile__FP10FileHandle
-#define LoadFileFunc LoadFile__FP10FileHandlePCc
-#define FreeFileFunc FreeFile__FP10FileHandle
-#endif
-
-.text
-
-.set sp,1
-.set rtoc,2
-.set this,31
-
-
-
-
-.global EmbeddedLayout_LoadArc
-EmbeddedLayout_LoadArc:
- # stack setup
- stwu sp, -0x20(sp)
- mflr r0
- stw r0, 0x24(sp)
- stw r31, 0x1C(sp)
- stw r30, 0x18(sp)
-
- # r31 is a pointer to the LayoutHelper (must be converted)
- # r30 stores the filename
- addi r31, r3, 0xAC
- mr r30, r4
-
- # check to see if an arc has already been loaded
- lwz r0, 0xBC(r3)
- cmpwi r0, 0
- bne return_0
-
- # ok, no
- # create a FileHandle where a NSMBWFile would be
- # don't know if this will work but it's worth a try
- addi r3, r31, 0xC0
- mr r4, r30
- bl LoadFileFunc
-
- # check retval
- cmpwi r3, 0
- stw r3, 0xBC(r31)
- beq return_0
-
- # link it
- mr r4, r3
- mr r3, r31
- lis r5, arcString@h
- ori r5, r5, arcString@l
- bl LayoutHelper_Link
-
- # now add a pointer to the LayoutHelper into the Layout at offset 0x84
- # turn r3 into an EmbeddedLayout pointer
- subi r3, r31, 0xAC
- stw r31, 0x84(r3)
-
- b return_1
-
-return_0:
- li r3, 0
- b return
-
-return_1:
- li r3, 1
-
-return:
- lwz r30, 0x18(sp)
- lwz r31, 0x1C(sp)
- lwz r0, 0x24(sp)
- mtlr r0
- addi sp, sp, 0x20
- blr
-
-.align 4
-
-.global EmbeddedLayout_FreeArc
-EmbeddedLayout_FreeArc:
- # stack setup
- stwu sp, -0x10(sp)
- mflr r0
- stw r0, 0x14(sp)
- stw r31, 0xC(sp)
-
- # r31 is a pointer to the LayoutHelper (must be converted)
- addi r31, r3, 0xAC
-
- # - if an arc has been loaded, then free the NSMBWFile
- lwz r0, 0xBC(r3)
- cmpwi r0, 0
- beq xreturn_1
-
- # no, so free it
- addi r3, r31, 0xC0
- bl FreeFileFunc
-
- li r3, 0
- stw r3, 0xBC(r31)
-
-xreturn_1:
- li r3, 1
- lwz r31, 0xC(sp)
- lwz r0, 0x14(sp)
- mtlr r0
- addi sp, sp, 0x10
- blr
-
-
-
-.data
-arcString:
- .string "arc"
-
-.align 4
-
+.extern LayoutHelper_Link + +#ifndef __MWERKS__ +.extern _Z8LoadFileP10FileHandlePc +.extern _Z8FreeFileP10FileHandle +#define LoadFileFunc _Z8LoadFileP10FileHandlePc +#define FreeFileFunc _Z8FreeFileP10FileHandle +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24 +.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29 +.set r30,30; .set r31,31; .set f0,0; .set f2,2; .set f3,3 +#else +.extern LoadFile__FP10FileHandlePCc +.extern FreeFile__FP10FileHandle +#define LoadFileFunc LoadFile__FP10FileHandlePCc +#define FreeFileFunc FreeFile__FP10FileHandle +#endif + +.text + +.set sp,1 +.set rtoc,2 +.set this,31 + + + + +.global EmbeddedLayout_LoadArc +EmbeddedLayout_LoadArc: + # stack setup + stwu sp, -0x20(sp) + mflr r0 + stw r0, 0x24(sp) + stw r31, 0x1C(sp) + stw r30, 0x18(sp) + + # r31 is a pointer to the LayoutHelper (must be converted) + # r30 stores the filename + addi r31, r3, 0xAC + mr r30, r4 + + # check to see if an arc has already been loaded + lwz r0, 0xBC(r3) + cmpwi r0, 0 + bne return_0 + + # ok, no + # create a FileHandle where a NSMBWFile would be + # don't know if this will work but it's worth a try + addi r3, r31, 0xC0 + mr r4, r30 + bl LoadFileFunc + + # check retval + cmpwi r3, 0 + stw r3, 0xBC(r31) + beq return_0 + + # link it + mr r4, r3 + mr r3, r31 + lis r5, arcString@h + ori r5, r5, arcString@l + bl LayoutHelper_Link + + # now add a pointer to the LayoutHelper into the Layout at offset 0x84 + # turn r3 into an EmbeddedLayout pointer + subi r3, r31, 0xAC + stw r31, 0x84(r3) + + b return_1 + +return_0: + li r3, 0 + b return + +return_1: + li r3, 1 + +return: + lwz r30, 0x18(sp) + lwz r31, 0x1C(sp) + lwz r0, 0x24(sp) + mtlr r0 + addi sp, sp, 0x20 + blr + +.align 4 + +.global EmbeddedLayout_FreeArc +EmbeddedLayout_FreeArc: + # stack setup + stwu sp, -0x10(sp) + mflr r0 + stw r0, 0x14(sp) + stw r31, 0xC(sp) + + # r31 is a pointer to the LayoutHelper (must be converted) + addi r31, r3, 0xAC + + # - if an arc has been loaded, then free the NSMBWFile + lwz r0, 0xBC(r3) + cmpwi r0, 0 + beq xreturn_1 + + # no, so free it + addi r3, r31, 0xC0 + bl FreeFileFunc + + li r3, 0 + stw r3, 0xBC(r31) + +xreturn_1: + li r3, 1 + lwz r31, 0xC(sp) + lwz r0, 0x14(sp) + mtlr r0 + addi sp, sp, 0x10 + blr + + + +.data +arcString: + .string "arc" + +.align 4 + diff --git a/src/layoutlib.h b/src/layoutlib.h index 6b7d275..55a3027 100644 --- a/src/layoutlib.h +++ b/src/layoutlib.h @@ -1,149 +1,149 @@ -#ifndef __NEWER_LAYOUTLIB_H
-#define __NEWER_LAYOUTLIB_H
-
-/* Treeki's LayoutLib for New Super Mario Bros Wii */
-#include <common.h>
-
-typedef float MTX[3][4];
-
-struct nw4r__lyt__Layout {
- void *vtable;
- void *field_04;
- void *field_08;
- void *field_0C;
- void *rootPane;
- void *field_14;
- void *field_18;
- void *field_1C;
-};
-
-struct nw4r__lyt__DrawInfo {
- // 0x00
- void *vtable;
- MTX matrix;
-
- // 0x34
- float left;
- float top;
- float right;
-
- // 0x40
- float bottom;
- float scale_x;
- float scale_y;
- float opacity;
-
- // 0x50
- unsigned char widescreenFlag;
-};
-
-struct FrameCtrl_c {
-
-};
-
-struct Anm_c {
- FrameCtrl_c *fc_ptr;
- void *brlanHandler;
- void *field_08;
- char field_0C;
- char pad[3];
- FrameCtrl_c fc;
-};
-
-struct Layout {
- void *field_00;
- void *field_04;
- void *vtable;
- unsigned char drawOrder; // 0x0C
- char pad1[3];
-
- // offset 0x10
- nw4r__lyt__Layout layout; // Actually m2d::Layout_c, but the struct is the same
-
- // offset 0x30
- nw4r__lyt__DrawInfo drawInfo;
-
- // offset 0x84
- //LayoutHelper *field_84;
- void *field_84;
- float posX; // 0x88
- float posY; // 0x8C
- float clipX; // 0x90
- float clipY; // 0x94
- float clipWidth; // 0x98
- float clipHeight; // 0x9C
- unsigned char clipEnabled; // 0xA0
- char pad2[3];
- unsigned int animEnabled; // 0xA4
- void *field_A8;
-
- // offset 0xAC
- //LayoutHelper lh; // actually a m2d::ResAccLoader_c
- char lh[0xD4]; // don't feel like figuring this one out -_-
-
- // offset 0x180
- //BrlanHandler *brlanHandlers; // 0x180, points to brlan handlers
- void *brlanHandlers;
- //GrpHandler *grpHandlers; // 0x184
- void *grpHandlers;
- char *field_188; // char array, probably "anim enabled"
- int brlanCount; // 0x18C
- int grpCount; // 0x190
- int field_194; // no idea
-};
-
-
-void EmbeddedLayout_ctor(Layout *self); // 0x800C89A0
-void EmbeddedLayout_dtor(Layout *self, bool del); // 0x800C89F0
-void EmbeddedLayout_Free(Layout *self); // 0x800C9A20
-bool EmbeddedLayout_LoadArcOld(Layout *self, const char *path, bool isLangSpecific); // 0x800C8D00
-
-extern "C" {
-bool EmbeddedLayout_LoadArc(Layout *self, const char *path); // custom
-bool EmbeddedLayout_FreeArc(Layout *self); // custom
-};
-
-void EmbeddedLayout_LoadBrlans(Layout *self, const char **names, int count); // 0x800C90A0
-void EmbeddedLayout_LoadGroups(Layout *self, const char **names, int *brlanLinkIDs, int count); // 0x800C91E0
-
-void EmbeddedLayout_AddToDrawList(Layout *self); // 0x80163990
-
-void *EmbeddedLayout_FindPaneByName(Layout *self, const char *name);
-void *EmbeddedLayout_FindTextBoxByName(Layout *self, const char *name);
-void *EmbeddedLayout_FindPictureByName(Layout *self, const char *name);
-void *EmbeddedLayout_FindWindowByName(Layout *self, const char *name);
-
-void EmbeddedLayout_EnableNonLoopAnim(Layout *self, int animNum, bool pointlessShit); // 0x800C93E0
-void EmbeddedLayout_EnableLoopAnim(Layout *self, int animNum); // 0x800C9470
-void EmbeddedLayout_ResetAnimToInitialState(Layout *self, int animNum, bool isLoop_maybe); // 0x800C94C0
-void EmbeddedLayout_DisableAnim(Layout *self, int animNum); // 0x800C9580
-void EmbeddedLayout_DisableAllAnims(Layout *self); // 0x800C95F0
-void EmbeddedLayout_Process(Layout *self); // 0x800C9650
-bool EmbeddedLayout_CheckIfAnimationIsOn(Layout *self, int animNum); // 0x800C9700
-bool EmbeddedLayout_CheckIfAnyAnimationsAreOn(Layout *self); // 0x800C9730
-
-
-typedef bool (*__EmbeddedLayout_Build_type)(Layout*, const char*, void*);
-inline bool EmbeddedLayout_Build(Layout *self, const char *brlytName, void *lh) {
- VF_BEGIN(__EmbeddedLayout_Build_type, self, 5, 8)
- return VF_CALL(self, brlytName, lh);
- VF_END;
-}
-
-typedef void (*__EmbeddedLayout_UpdateMatrix_type)(Layout*);
-inline void EmbeddedLayout_UpdateMatrix(Layout *self) {
- VF_BEGIN(__EmbeddedLayout_UpdateMatrix_type, self, 4, 8)
- VF_CALL(self);
- VF_END;
-}
-
-typedef void (*__TextBox_SetString_type)(void*, unsigned short const *, unsigned short);
-inline void TextBox_SetString(void *self, unsigned short const *str, unsigned short unk) {
- VF_BEGIN(__TextBox_SetString_type, self, 31, 0)
- VF_CALL(self, str, unk);
- VF_END;
-}
-
-#define PANE_FLAGS(pane) (*((u8*)(((u32)(pane))+0xBB)))
-
-#endif
+#ifndef __NEWER_LAYOUTLIB_H +#define __NEWER_LAYOUTLIB_H + +/* Treeki's LayoutLib for New Super Mario Bros Wii */ +#include <common.h> + +typedef float MTX[3][4]; + +struct nw4r__lyt__Layout { + void *vtable; + void *field_04; + void *field_08; + void *field_0C; + void *rootPane; + void *field_14; + void *field_18; + void *field_1C; +}; + +struct nw4r__lyt__DrawInfo { + // 0x00 + void *vtable; + MTX matrix; + + // 0x34 + float left; + float top; + float right; + + // 0x40 + float bottom; + float scale_x; + float scale_y; + float opacity; + + // 0x50 + unsigned char widescreenFlag; +}; + +struct FrameCtrl_c { + +}; + +struct Anm_c { + FrameCtrl_c *fc_ptr; + void *brlanHandler; + void *field_08; + char field_0C; + char pad[3]; + FrameCtrl_c fc; +}; + +struct Layout { + void *field_00; + void *field_04; + void *vtable; + unsigned char drawOrder; // 0x0C + char pad1[3]; + + // offset 0x10 + nw4r__lyt__Layout layout; // Actually m2d::Layout_c, but the struct is the same + + // offset 0x30 + nw4r__lyt__DrawInfo drawInfo; + + // offset 0x84 + //LayoutHelper *field_84; + void *field_84; + float posX; // 0x88 + float posY; // 0x8C + float clipX; // 0x90 + float clipY; // 0x94 + float clipWidth; // 0x98 + float clipHeight; // 0x9C + unsigned char clipEnabled; // 0xA0 + char pad2[3]; + unsigned int animEnabled; // 0xA4 + void *field_A8; + + // offset 0xAC + //LayoutHelper lh; // actually a m2d::ResAccLoader_c + char lh[0xD4]; // don't feel like figuring this one out -_- + + // offset 0x180 + //BrlanHandler *brlanHandlers; // 0x180, points to brlan handlers + void *brlanHandlers; + //GrpHandler *grpHandlers; // 0x184 + void *grpHandlers; + char *field_188; // char array, probably "anim enabled" + int brlanCount; // 0x18C + int grpCount; // 0x190 + int field_194; // no idea +}; + + +void EmbeddedLayout_ctor(Layout *self); // 0x800C89A0 +void EmbeddedLayout_dtor(Layout *self, bool del); // 0x800C89F0 +void EmbeddedLayout_Free(Layout *self); // 0x800C9A20 +bool EmbeddedLayout_LoadArcOld(Layout *self, const char *path, bool isLangSpecific); // 0x800C8D00 + +extern "C" { +bool EmbeddedLayout_LoadArc(Layout *self, const char *path); // custom +bool EmbeddedLayout_FreeArc(Layout *self); // custom +}; + +void EmbeddedLayout_LoadBrlans(Layout *self, const char **names, int count); // 0x800C90A0 +void EmbeddedLayout_LoadGroups(Layout *self, const char **names, int *brlanLinkIDs, int count); // 0x800C91E0 + +void EmbeddedLayout_AddToDrawList(Layout *self); // 0x80163990 + +void *EmbeddedLayout_FindPaneByName(Layout *self, const char *name); +void *EmbeddedLayout_FindTextBoxByName(Layout *self, const char *name); +void *EmbeddedLayout_FindPictureByName(Layout *self, const char *name); +void *EmbeddedLayout_FindWindowByName(Layout *self, const char *name); + +void EmbeddedLayout_EnableNonLoopAnim(Layout *self, int animNum, bool pointlessShit); // 0x800C93E0 +void EmbeddedLayout_EnableLoopAnim(Layout *self, int animNum); // 0x800C9470 +void EmbeddedLayout_ResetAnimToInitialState(Layout *self, int animNum, bool isLoop_maybe); // 0x800C94C0 +void EmbeddedLayout_DisableAnim(Layout *self, int animNum); // 0x800C9580 +void EmbeddedLayout_DisableAllAnims(Layout *self); // 0x800C95F0 +void EmbeddedLayout_Process(Layout *self); // 0x800C9650 +bool EmbeddedLayout_CheckIfAnimationIsOn(Layout *self, int animNum); // 0x800C9700 +bool EmbeddedLayout_CheckIfAnyAnimationsAreOn(Layout *self); // 0x800C9730 + + +typedef bool (*__EmbeddedLayout_Build_type)(Layout*, const char*, void*); +inline bool EmbeddedLayout_Build(Layout *self, const char *brlytName, void *lh) { + VF_BEGIN(__EmbeddedLayout_Build_type, self, 5, 8) + return VF_CALL(self, brlytName, lh); + VF_END; +} + +typedef void (*__EmbeddedLayout_UpdateMatrix_type)(Layout*); +inline void EmbeddedLayout_UpdateMatrix(Layout *self) { + VF_BEGIN(__EmbeddedLayout_UpdateMatrix_type, self, 4, 8) + VF_CALL(self); + VF_END; +} + +typedef void (*__TextBox_SetString_type)(void*, unsigned short const *, unsigned short); +inline void TextBox_SetString(void *self, unsigned short const *str, unsigned short unk) { + VF_BEGIN(__TextBox_SetString_type, self, 31, 0) + VF_CALL(self, str, unk); + VF_END; +} + +#define PANE_FLAGS(pane) (*((u8*)(((u32)(pane))+0xBB))) + +#endif diff --git a/src/levelinfo.cpp b/src/levelinfo.cpp index 9807fc4..ec65350 100644 --- a/src/levelinfo.cpp +++ b/src/levelinfo.cpp @@ -1,36 +1,36 @@ -#include "levelinfo.h"
-
-void LevelInfo_Prepare(FileHandle *fh) {
- void *file = fh->filePtr;
-
- // decrypt all the level names
- for (int sect = 0; sect < LevelInfo_GetSectionCount(file); sect++) {
- // parse this section
- LevelInfo_Section *thisSect = LevelInfo_GetSection(file, sect);
- LevelInfo_Entry *levels = LevelInfo_GetLevels(file, thisSect);
-
- for (int lev = 0; lev < thisSect->levelCount; lev++) {
- LevelInfo_Entry *level = &levels[lev];
-
- char *name = LevelInfo_GetName(file, level);
-
- for (int i = 0; i < level->nameLength+1; i++) {
- name[i] -= 0xD0;
- }
- }
- }
-}
-
-LevelInfo_Entry *LevelInfo_Search(void *file, int world, int level) {
- for (int i = 0; i < LevelInfo_GetSectionCount(file); i++) {
- LevelInfo_Section *sect = LevelInfo_GetSection(file, i);
-
- for (int j = 0; j < sect->levelCount; j++) {
- LevelInfo_Entry *entry = &LevelInfo_GetLevels(file, sect)[j];
- if (entry->world == world && entry->level == level)
- return entry;
- }
- }
-
- return 0;
-}
+#include "levelinfo.h" + +void LevelInfo_Prepare(FileHandle *fh) { + void *file = fh->filePtr; + + // decrypt all the level names + for (int sect = 0; sect < LevelInfo_GetSectionCount(file); sect++) { + // parse this section + LevelInfo_Section *thisSect = LevelInfo_GetSection(file, sect); + LevelInfo_Entry *levels = LevelInfo_GetLevels(file, thisSect); + + for (int lev = 0; lev < thisSect->levelCount; lev++) { + LevelInfo_Entry *level = &levels[lev]; + + char *name = LevelInfo_GetName(file, level); + + for (int i = 0; i < level->nameLength+1; i++) { + name[i] -= 0xD0; + } + } + } +} + +LevelInfo_Entry *LevelInfo_Search(void *file, int world, int level) { + for (int i = 0; i < LevelInfo_GetSectionCount(file); i++) { + LevelInfo_Section *sect = LevelInfo_GetSection(file, i); + + for (int j = 0; j < sect->levelCount; j++) { + LevelInfo_Entry *entry = &LevelInfo_GetLevels(file, sect)[j]; + if (entry->world == world && entry->level == level) + return entry; + } + } + + return 0; +} diff --git a/src/levelinfo.h b/src/levelinfo.h index 1b75275..8e1e916 100644 --- a/src/levelinfo.h +++ b/src/levelinfo.h @@ -1,56 +1,56 @@ -#ifndef __NEWER_LEVELINFO_H
-#define __NEWER_LEVELINFO_H
-
-#include <common.h>
-#include "fileload.h"
-
-struct LevelInfo_Header {
- u32 magic;
- u32 sectionCount;
-};
-
-struct LevelInfo_Section {
- u32 levelCount;
-};
-
-struct LevelInfo_Entry {
- u8 world;
- u8 level;
- u8 reserved1;
- u8 reserved2;
- u8 nameLength;
- u8 reserved3;
- u16 flags;
- u32 nameOffset;
-};
-
-inline u32 LevelInfo_GetSectionCount(void *file) {
- return ((LevelInfo_Header*)file)->sectionCount;
-}
-
-inline u32 *LevelInfo_GetOffsets(void *file) {
- return (u32*)(((LevelInfo_Header*)file)+1);
-}
-
-inline LevelInfo_Section *LevelInfo_GetSection(void *file, int id) {
- u32 offs = LevelInfo_GetOffsets(file)[id];
- return (LevelInfo_Section*)(((char*)file)+offs);
-};
-
-inline LevelInfo_Entry *LevelInfo_GetLevels(void *file, LevelInfo_Section *section) {
- return (LevelInfo_Entry*)(section+1);
-}
-
-inline LevelInfo_Entry *LevelInfo_GetLevels(void *file, int sectionID) {
- return (LevelInfo_Entry*)(LevelInfo_GetSection(file, sectionID)+1);
-}
-
-inline char *LevelInfo_GetName(void *file, LevelInfo_Entry *entry) {
- return ((char*)file)+entry->nameOffset;
-}
-
-void LevelInfo_Prepare(FileHandle *fh);
-LevelInfo_Entry *LevelInfo_Search(void *file, int world, int level);
-
-
-#endif
+#ifndef __NEWER_LEVELINFO_H +#define __NEWER_LEVELINFO_H + +#include <common.h> +#include "fileload.h" + +struct LevelInfo_Header { + u32 magic; + u32 sectionCount; +}; + +struct LevelInfo_Section { + u32 levelCount; +}; + +struct LevelInfo_Entry { + u8 world; + u8 level; + u8 reserved1; + u8 reserved2; + u8 nameLength; + u8 reserved3; + u16 flags; + u32 nameOffset; +}; + +inline u32 LevelInfo_GetSectionCount(void *file) { + return ((LevelInfo_Header*)file)->sectionCount; +} + +inline u32 *LevelInfo_GetOffsets(void *file) { + return (u32*)(((LevelInfo_Header*)file)+1); +} + +inline LevelInfo_Section *LevelInfo_GetSection(void *file, int id) { + u32 offs = LevelInfo_GetOffsets(file)[id]; + return (LevelInfo_Section*)(((char*)file)+offs); +}; + +inline LevelInfo_Entry *LevelInfo_GetLevels(void *file, LevelInfo_Section *section) { + return (LevelInfo_Entry*)(section+1); +} + +inline LevelInfo_Entry *LevelInfo_GetLevels(void *file, int sectionID) { + return (LevelInfo_Entry*)(LevelInfo_GetSection(file, sectionID)+1); +} + +inline char *LevelInfo_GetName(void *file, LevelInfo_Entry *entry) { + return ((char*)file)+entry->nameOffset; +} + +void LevelInfo_Prepare(FileHandle *fh); +LevelInfo_Entry *LevelInfo_Search(void *file, int world, int level); + + +#endif diff --git a/src/levelnames.cpp b/src/levelnames.cpp index b6f440e..95d7e5d 100644 --- a/src/levelnames.cpp +++ b/src/levelnames.cpp @@ -1,83 +1,83 @@ -#include <common.h>
-#include <actors.h>
-#include <stage.h>
-#include "levelinfo.h"
-#include "fileload.h"
-#include "layoutlib.h"
-
-//#define DEBUG_NAMES
-
-#ifndef DEBUG_NAMES
-#define OSReport(...)
-#endif
-
-extern char CurrentLevel;
-extern char CurrentWorld;
-
-int DoNames(int state) {
- OSReport("DoNames called - State param is %d\n", state);
- int wnum = (int)CurrentWorld;
- int lnum = (int)CurrentLevel;
- OSReport("Current Level: %d-%d\n", wnum+1, lnum+1);
-
- // Skip the title screen
- // and only process the code if the State is set to 1
- // (the screen has been initialised)
- if (state == 1 && lnum != STAGE_TITLE) {
- OSReport("Processing\n");
- // grab the CRSIN object
- Actor *ptr = FindActorByType(CRSIN, 0);
- //OSReport("CRSIN actor found at : %08X\n", ptr);
-
- // FIX !!!!!
-
- if (ptr != 0) {
- void *worldObj = EmbeddedLayout_FindTextBoxByName((Layout*)((u32)ptr+0xB0), "TXT_WorldName");
- void *levelObj = EmbeddedLayout_FindTextBoxByName((Layout*)((u32)ptr+0xB0), "TXT_LevelName");
- //OSReport("WorldObj TextBox : %08X; LevelObj TextBox : %08X\n", worldObj, levelObj);
- if (worldObj == 0 || levelObj == 0) return state;
-
- /*char *file = RetrieveFileFromArc(ARC_TABLE, "Mario", "newer/names.bin");
- //OSReport("RetrieveFileFromArc returned : %08X\n", file);
- char *worldname = file + (wnum * 0x40);
- char *levelname = file + 0x280 + (wnum * 0xA80) + (lnum * 0x40);*/
- OSReport("Loading file...\n");
- FileHandle fh;
- void *info = LoadFile(&fh, "/NewerRes/LevelInfo.bin");
-
- LevelInfo_Prepare(&fh);
- LevelInfo_Entry *entry = LevelInfo_Search(info, wnum, lnum);
- char *worldname = LevelInfo_GetName(info, entry);
- char *levelname = "";
- OSReport("Got name : %s\n", worldname);
-
- void *vtable = *((void**)levelObj);
- void *funcaddr = *((void**)((u32)vtable+0x7C));
- int (*SetString)(void*, unsigned short*, unsigned short);
- SetString = (int(*)(void*, unsigned short*, unsigned short))funcaddr;
-
- unsigned short wbuffer[0x40], lbuffer[0x40];
- for (int i = 0; i < 0x40; i++) {
- wbuffer[i] = (unsigned short)worldname[i];
- lbuffer[i] = (unsigned short)levelname[i];
- }
-
- SetString(worldObj, wbuffer, 0);
- SetString(levelObj, lbuffer, 0);
-
- OSReport("Freeing file\n");
- FreeFile(&fh);
- OSReport("Inserted strings\n");
- }
- } else {
- OSReport("Skipped\n");
- }
-
- OSReport("Reached the end of DoNames\n");
- return state;
-}
-
-int DoNamesTest2(int state, u32 ptr) {
- OSReport("TEST 1:%08X 2:%08X\n", state, ptr);
- return DoNames(state);
-}
+#include <common.h> +#include <actors.h> +#include <stage.h> +#include "levelinfo.h" +#include "fileload.h" +#include "layoutlib.h" + +//#define DEBUG_NAMES + +#ifndef DEBUG_NAMES +#define OSReport(...) +#endif + +extern char CurrentLevel; +extern char CurrentWorld; + +int DoNames(int state) { + OSReport("DoNames called - State param is %d\n", state); + int wnum = (int)CurrentWorld; + int lnum = (int)CurrentLevel; + OSReport("Current Level: %d-%d\n", wnum+1, lnum+1); + + // Skip the title screen + // and only process the code if the State is set to 1 + // (the screen has been initialised) + if (state == 1 && lnum != STAGE_TITLE) { + OSReport("Processing\n"); + // grab the CRSIN object + Actor *ptr = FindActorByType(CRSIN, 0); + //OSReport("CRSIN actor found at : %08X\n", ptr); + + // FIX !!!!! + + if (ptr != 0) { + void *worldObj = EmbeddedLayout_FindTextBoxByName((Layout*)((u32)ptr+0xB0), "TXT_WorldName"); + void *levelObj = EmbeddedLayout_FindTextBoxByName((Layout*)((u32)ptr+0xB0), "TXT_LevelName"); + //OSReport("WorldObj TextBox : %08X; LevelObj TextBox : %08X\n", worldObj, levelObj); + if (worldObj == 0 || levelObj == 0) return state; + + /*char *file = RetrieveFileFromArc(ARC_TABLE, "Mario", "newer/names.bin"); + //OSReport("RetrieveFileFromArc returned : %08X\n", file); + char *worldname = file + (wnum * 0x40); + char *levelname = file + 0x280 + (wnum * 0xA80) + (lnum * 0x40);*/ + OSReport("Loading file...\n"); + FileHandle fh; + void *info = LoadFile(&fh, "/NewerRes/LevelInfo.bin"); + + LevelInfo_Prepare(&fh); + LevelInfo_Entry *entry = LevelInfo_Search(info, wnum, lnum); + char *worldname = LevelInfo_GetName(info, entry); + char *levelname = ""; + OSReport("Got name : %s\n", worldname); + + void *vtable = *((void**)levelObj); + void *funcaddr = *((void**)((u32)vtable+0x7C)); + int (*SetString)(void*, unsigned short*, unsigned short); + SetString = (int(*)(void*, unsigned short*, unsigned short))funcaddr; + + unsigned short wbuffer[0x40], lbuffer[0x40]; + for (int i = 0; i < 0x40; i++) { + wbuffer[i] = (unsigned short)worldname[i]; + lbuffer[i] = (unsigned short)levelname[i]; + } + + SetString(worldObj, wbuffer, 0); + SetString(levelObj, lbuffer, 0); + + OSReport("Freeing file\n"); + FreeFile(&fh); + OSReport("Inserted strings\n"); + } + } else { + OSReport("Skipped\n"); + } + + OSReport("Reached the end of DoNames\n"); + return state; +} + +int DoNamesTest2(int state, u32 ptr) { + OSReport("TEST 1:%08X 2:%08X\n", state, ptr); + return DoNames(state); +} diff --git a/src/levelspecial.cpp b/src/levelspecial.cpp index 7ad69ff..e075773 100644 --- a/src/levelspecial.cpp +++ b/src/levelspecial.cpp @@ -1,30 +1,30 @@ -#include <common.h>
-#include <game.h>
-
-struct LevelSpecial {
- u32 id; // 0x00
- u32 settings; // 0x04
- u16 name; // 0x08
- u8 _0A[6]; // 0x0A
- u8 _10[0x9C]; // 0x10
- float x; // 0xAC
- float y; // 0xB0
- float z; // 0xB4
- u8 _B8[0x318]; // 0xB8
- // Any variables you add to the class go here; starting at offset 0x3D0
- u64 eventFlag; // 0x3D0
- u8 type; // 0x3D4
- u8 effect; // 0x3D5
- u8 lastEvState; // 0x3D6
- u8 func; // 0x3D7
-};
-
-struct EventTable_t {
- u64 events;
- // ...
-};
- -extern EventTable_t *EventTable;
+#include <common.h> +#include <game.h> + +struct LevelSpecial { + u32 id; // 0x00 + u32 settings; // 0x04 + u16 name; // 0x08 + u8 _0A[6]; // 0x0A + u8 _10[0x9C]; // 0x10 + float x; // 0xAC + float y; // 0xB0 + float z; // 0xB4 + u8 _B8[0x318]; // 0xB8 + // Any variables you add to the class go here; starting at offset 0x3D0 + u64 eventFlag; // 0x3D0 + u8 type; // 0x3D4 + u8 effect; // 0x3D5 + u8 lastEvState; // 0x3D6 + u8 func; // 0x3D7 +}; + +struct EventTable_t { + u64 events; + // ... +}; + +extern EventTable_t *EventTable; extern u16 TimeStopFlag; extern u32 TimerBranch; @@ -50,17 +50,17 @@ float GlobalRiderFloatModifications [] = {1, 0.6, 0.7, 0.9, 1, 1, 1, 1.1, 1.25, extern "C" dAc_Py_c *GetSpecificPlayerActor(int number); -void LevelSpecial_Update(LevelSpecial *self);
+void LevelSpecial_Update(LevelSpecial *self); bool ResetAfterLevel(); -#define ACTIVATE 1
-#define DEACTIVATE 0
-
-fBase_c *FindActorByID(u32 id);
+#define ACTIVATE 1 +#define DEACTIVATE 0 +fBase_c *FindActorByID(u32 id); -bool ResetAfterLevel(void) {
+ +bool ResetAfterLevel(void) { TimeStopFlag = 0; TimerBranch = 0x3403FFA4; MarioDescentRate = -4; @@ -75,50 +75,50 @@ bool ResetAfterLevel(void) { AlwaysDrawFlag = 0x9421FFF0; AlwaysDrawBranch = 0x7C0802A6; ZOrderOn = 0; - return true;
-}
-
-bool LevelSpecial_Create(LevelSpecial *self) {
- char eventNum = (self->settings >> 24) & 0xFF;
- self->eventFlag = (u64)1 << (eventNum - 1);
-
- OSReport("Special Event created @%p event %d\n", self, eventNum);
-
- OSReport("Eventnum: %d. Event flag: %08x %08x\n", eventNum, self->eventFlag >> 32, self->eventFlag & 0xFFFFFFFF);
-
- self->type = (self->settings) & 15;
- self->effect = (self->settings >> 4) & 15;
-
- self->lastEvState = 0xFF;
-
- LevelSpecial_Update(self);
-
- return true;
-}
-
-bool LevelSpecial_Execute(LevelSpecial *self) {
- LevelSpecial_Update(self);
- return true;
-}
-
- -void LevelSpecial_Update(LevelSpecial *self) {
- //OSReport("%08x%08x", EventTable->events >> 32, EventTable->events & 0xFFFFFFFF);
-
- u8 newEvState = 0;
- if (EventTable->events & self->eventFlag)
- newEvState = 1;
-
- if (newEvState == self->lastEvState)
- return;
-
- OSReport("Event state changed from %d to %d\n", self->lastEvState, newEvState);
-
- u8 offState;
+ return true; +} + +bool LevelSpecial_Create(LevelSpecial *self) { + char eventNum = (self->settings >> 24) & 0xFF; + self->eventFlag = (u64)1 << (eventNum - 1); + + OSReport("Special Event created @%p event %d\n", self, eventNum); + + OSReport("Eventnum: %d. Event flag: %08x %08x\n", eventNum, self->eventFlag >> 32, self->eventFlag & 0xFFFFFFFF); + + self->type = (self->settings) & 15; + self->effect = (self->settings >> 4) & 15; + + self->lastEvState = 0xFF; + + LevelSpecial_Update(self); + + return true; +} + +bool LevelSpecial_Execute(LevelSpecial *self) { + LevelSpecial_Update(self); + return true; +} + + +void LevelSpecial_Update(LevelSpecial *self) { + //OSReport("%08x%08x", EventTable->events >> 32, EventTable->events & 0xFFFFFFFF); + + u8 newEvState = 0; + if (EventTable->events & self->eventFlag) + newEvState = 1; + + if (newEvState == self->lastEvState) + return; + + OSReport("Event state changed from %d to %d\n", self->lastEvState, newEvState); + + u8 offState; if (newEvState == ACTIVATE) - {
- offState = (newEvState == 1) ? 1 : 0;
- OSReport("Activate Special Event!", offState);
+ { + offState = (newEvState == 1) ? 1 : 0; + OSReport("Activate Special Event!", offState); switch (self->type) { case 1: // Time Freeze @@ -251,12 +251,12 @@ void LevelSpecial_Update(LevelSpecial *self) { default: break; } - }
-
+ } + else - {
- offState = (newEvState == 1) ? 0 : 1;
- OSReport("Deactivate Special Event", offState);
+ { + offState = (newEvState == 1) ? 0 : 1; + OSReport("Deactivate Special Event", offState); switch (self->type) { case 1: // Time Freeze @@ -371,14 +371,14 @@ void LevelSpecial_Update(LevelSpecial *self) { default: break; } - }
- OSReport("Special Event is %d\n", offState);
+ } + OSReport("Special Event is %d\n", offState); - OSReport("Success!\n");
-
-
- self->lastEvState = newEvState;
+ OSReport("Success!\n"); + + + self->lastEvState = newEvState; } diff --git a/src/linegod.S b/src/linegod.S index ed636dd..811fa84 100644 --- a/src/linegod.S +++ b/src/linegod.S @@ -1,53 +1,53 @@ -.text
-
-#ifndef __MWERKS__
-.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4
-.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
-.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
-.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
-.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
-.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
-.set r30,30; .set r31,31; .set f0,0; .set f2,2; .set f3,3
-#endif
-
-.align 4
-.extern ContinueBgActorSpawn
-.global BgActorSpawnFix
-BgActorSpawnFix:
- mr 30, 3
-
- #lis 3, TestStr@h
- #ori 3, 3, TestStr@l
- #mr 4, 30
- #crclr 4*cr1+eq
- #bl OSReport
-
- lbz 0, 7(30)
- cmpwi 0, 1
- beq JustRet
- b ContinueBgActorSpawn
-JustRet:
-
- lwz 31, 0x3C(1)
- lwz 30, 0x38(1)
- lwz 0, 0x44(1)
- mtlr 0
- addi 1, 1, 0x40
- blr
-
-
-.global BgActorSetInfoFix
-BgActorSetInfoFix:
- sth 4, 0(3)
- sth 5, 2(3)
- sth 6, 4(3)
- stb 7, 6(3)
- li 4, 0
- stb 4, 7(3)
- blr
-
-
-#.data
-#TestStr:
-# .string "Spawning actor %p\n"
-# .align 4
+.text + +#ifndef __MWERKS__ +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24 +.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29 +.set r30,30; .set r31,31; .set f0,0; .set f2,2; .set f3,3 +#endif + +.align 4 +.extern ContinueBgActorSpawn +.global BgActorSpawnFix +BgActorSpawnFix: + mr 30, 3 + + #lis 3, TestStr@h + #ori 3, 3, TestStr@l + #mr 4, 30 + #crclr 4*cr1+eq + #bl OSReport + + lbz 0, 7(30) + cmpwi 0, 1 + beq JustRet + b ContinueBgActorSpawn +JustRet: + + lwz 31, 0x3C(1) + lwz 30, 0x38(1) + lwz 0, 0x44(1) + mtlr 0 + addi 1, 1, 0x40 + blr + + +.global BgActorSetInfoFix +BgActorSetInfoFix: + sth 4, 0(3) + sth 5, 2(3) + sth 6, 4(3) + stb 7, 6(3) + li 4, 0 + stb 4, 7(3) + blr + + +#.data +#TestStr: +# .string "Spawning actor %p\n" +# .align 4 diff --git a/src/linegod.cpp b/src/linegod.cpp index de08fa0..dcadf59 100644 --- a/src/linegod.cpp +++ b/src/linegod.cpp @@ -1,213 +1,213 @@ -#include <common.h>
-#include <game.h>
-
-// TODO: make "No Deactivation"
-
-struct BgActor {
- u16 def_id; // 0x00
- u16 x; // 0x02
- u16 y; // 0x04
- u8 layer; // 0x06
- u8 EXTRA_off; // 0x07
- u32 actor_id; // 0x08
-};
-
-struct BgActorDef {
- u32 tilenum;
- u16 actor;
- u8 _06[2];
- float x;
- float y;
- float z;
- float another_x;
- float another_y;
- u32 extra_var;
-};
-
-struct dBgActorManager_c {
- u32 vtable; // 0x00
- u8 _04[0x34]; // 0x04
- BgActor *array; // 0x38
- u32 count; // 0x3C
- u32 type; // 0x40
-};
-
-extern dBgActorManager_c *dBgActorManager;
-
-extern BgActorDef *BgActorDefs;
-
-struct BG_GM_hax {
- u8 _00[0x8FE64];
- float _0x8FE64;
- float _0x8FE68;
- float _0x8FE6C;
- float _0x8FE70;
-};
-
-extern BG_GM_hax *BG_GM_ptr;
-
-// Regular class is 0x3D0.
-// Let's add stuff to the end just to be safe.
-// Size is now 0x400
-// 80898798 38600400
-
-#define LINEGOD_FUNC_ACTIVATE 0
-#define LINEGOD_FUNC_DEACTIVATE 1
-
-struct LineGod {
- u32 id; // 0x00
- u32 settings; // 0x04
- u16 name; // 0x08
- u8 _0A[6]; // 0x0A
- u8 _10[0x9C]; // 0x10
- float x; // 0xAC
- float y; // 0xB0
- float z; // 0xB4
- u8 _B8[0x318]; // 0xB8
- u64 eventFlag; // 0x3D0
- u8 func; // 0x3D4
- u8 width; // 0x3D5
- u8 height; // 0x3D6
- u8 lastEvState; // 0x3D7
- BgActor *ac[8]; // 0x3D8
-};
-
-struct EventTable_t {
- u64 events;
- // ...
-};
-
-extern EventTable_t *EventTable;
-
-fBase_c *FindActorByID(u32 id);
-
-u16 *GetPointerToTile(BG_GM_hax *self, u16 x, u16 y, u16 layer, short *blockID_p, bool unused);
-
-
-
-void LineGod_BuildList(LineGod *self);
-bool LineGod_AppendToList(LineGod *self, BgActor *ac);
-void LineGod_Update(LineGod *self);
-
-
-bool LineGod_Create(LineGod *self) {
- char eventNum = (self->settings >> 24) & 0xFF;
- self->eventFlag = (u64)1 << (eventNum - 1);
-
- OSReport("LineGod created @%p event %d\n", self, eventNum);
-
- //OSReport("Eventnum: %d. Event flag: %08x %08x\n", eventNum, self->eventFlag >> 32, self->eventFlag & 0xFFFFFFFF);
-
- self->func = (self->settings) & 1;
- self->width = (self->settings >> 4) & 15;
- self->height = (self->settings >> 8) & 15;
-
- self->lastEvState = 0xFF;
-
- LineGod_BuildList(self);
- LineGod_Update(self);
-
- return true;
-}
-
-bool LineGod_Execute(LineGod *self) {
- LineGod_Update(self);
- return true;
-}
-
-void LineGod_BuildList(LineGod *self) {
- for (int clearIdx = 0; clearIdx < 8; clearIdx++) {
- self->ac[clearIdx] = 0;
- }
-
-
- u16 x1 = self->x / 16;
- u16 x2 = x1 + self->width - 1;
- u16 y1 = (-self->y) / 16;
- u16 y2 = y1 + self->height - 1;
- OSReport("Searching ... %d,%d - %d,%d\n", x1, y1, x2, y2);
-
- x1 -= (BG_GM_ptr->_0x8FE64 / 16);
- x2 -= (BG_GM_ptr->_0x8FE64 / 16);
- y1 += (BG_GM_ptr->_0x8FE6C / 16);
- y2 += (BG_GM_ptr->_0x8FE6C / 16);
- OSReport("Manipulated offsets ... %d,%d - %d,%d\n", x1, y1, x2, y2);
-
- OSReport("My array: %p\n", &self->ac[0]);
-
- for (int i = 0; i < dBgActorManager->count; i++) {
- BgActor *ac = &dBgActorManager->array[i];
- //OSReport("Actor %p: %d,%d", ac, ac->x, ac->y);
-
- if (ac->x >= x1 && ac->x <= x2 && ac->y >= y1 && ac->y <= y2)
- LineGod_AppendToList(self, ac);
- }
-}
-
-bool LineGod_AppendToList(LineGod *self, BgActor *ac) {
- OSReport("Adding %p to the list (pos: %d,%d)\n", ac, ac->x, ac->y);
-
- for (int search = 0; search < 8; search++) {
- if (self->ac[search] == 0) {
- self->ac[search] = ac;
- return true;
- }
- }
-
- return false;
-}
-
-void LineGod_Update(LineGod *self) {
- //OSReport("%08x%08x", EventTable->events >> 32, EventTable->events & 0xFFFFFFFF);
-
- u8 newEvState = 0;
- if (EventTable->events & self->eventFlag)
- newEvState = 1;
-
- if (newEvState == self->lastEvState)
- return;
-
- u16 x_bias = (BG_GM_ptr->_0x8FE64 / 16);
- u16 y_bias = -(BG_GM_ptr->_0x8FE6C / 16);
-
- OSReport("Event state changed from %d to %d\n", self->lastEvState, newEvState);
-
- u8 offState;
- if (self->func == LINEGOD_FUNC_ACTIVATE)
- offState = (newEvState == 1) ? 1 : 0;
- else
- offState = (newEvState == 1) ? 0 : 1;
-
- //OSReport("offState is %d\n", offState);
-
- for (int i = 0; i < 8; i++) {
- if (self->ac[i] != 0) {
- BgActor *ac = self->ac[i];
-
- //OSReport("Assigning %d to %p->EXTRA_off (actor ID is %d)\n", offState, ac, ac->actor_id);
-
- ac->EXTRA_off = offState;
- if (offState == 1 && ac->actor_id != 0) {
- fBase_c *assoc_ac = FindActorByID(ac->actor_id);
- //OSReport("Got actor: %p\n", assoc_ac);
- if (assoc_ac != 0)
- assoc_ac->Delete();
- ac->actor_id = 0;
- }
-
- u16 *tile = GetPointerToTile(BG_GM_ptr, (ac->x + x_bias) * 16, (ac->y + y_bias) * 16, 0, 0, 0);
- if (offState == 1)
- *tile = 0;
- else
- *tile = BgActorDefs[ac->def_id].tilenum;
-
- //OSReport("def_id: %d; def_ptr: %p\n", ac->def_id, &(BgActorDefs[ac->def_id]));
- //OSReport("Placed tile %d at %p [%d,%d]\n", *tile, tile, ac->x+x_bias, ac->y+y_bias);
- }
- }
-
- //OSReport("Success!\n");
-
-
- self->lastEvState = newEvState;
-}
+#include <common.h> +#include <game.h> + +// TODO: make "No Deactivation" + +struct BgActor { + u16 def_id; // 0x00 + u16 x; // 0x02 + u16 y; // 0x04 + u8 layer; // 0x06 + u8 EXTRA_off; // 0x07 + u32 actor_id; // 0x08 +}; + +struct BgActorDef { + u32 tilenum; + u16 actor; + u8 _06[2]; + float x; + float y; + float z; + float another_x; + float another_y; + u32 extra_var; +}; + +struct dBgActorManager_c { + u32 vtable; // 0x00 + u8 _04[0x34]; // 0x04 + BgActor *array; // 0x38 + u32 count; // 0x3C + u32 type; // 0x40 +}; + +extern dBgActorManager_c *dBgActorManager; + +extern BgActorDef *BgActorDefs; + +struct BG_GM_hax { + u8 _00[0x8FE64]; + float _0x8FE64; + float _0x8FE68; + float _0x8FE6C; + float _0x8FE70; +}; + +extern BG_GM_hax *BG_GM_ptr; + +// Regular class is 0x3D0. +// Let's add stuff to the end just to be safe. +// Size is now 0x400 +// 80898798 38600400 + +#define LINEGOD_FUNC_ACTIVATE 0 +#define LINEGOD_FUNC_DEACTIVATE 1 + +struct LineGod { + u32 id; // 0x00 + u32 settings; // 0x04 + u16 name; // 0x08 + u8 _0A[6]; // 0x0A + u8 _10[0x9C]; // 0x10 + float x; // 0xAC + float y; // 0xB0 + float z; // 0xB4 + u8 _B8[0x318]; // 0xB8 + u64 eventFlag; // 0x3D0 + u8 func; // 0x3D4 + u8 width; // 0x3D5 + u8 height; // 0x3D6 + u8 lastEvState; // 0x3D7 + BgActor *ac[8]; // 0x3D8 +}; + +struct EventTable_t { + u64 events; + // ... +}; + +extern EventTable_t *EventTable; + +fBase_c *FindActorByID(u32 id); + +u16 *GetPointerToTile(BG_GM_hax *self, u16 x, u16 y, u16 layer, short *blockID_p, bool unused); + + + +void LineGod_BuildList(LineGod *self); +bool LineGod_AppendToList(LineGod *self, BgActor *ac); +void LineGod_Update(LineGod *self); + + +bool LineGod_Create(LineGod *self) { + char eventNum = (self->settings >> 24) & 0xFF; + self->eventFlag = (u64)1 << (eventNum - 1); + + OSReport("LineGod created @%p event %d\n", self, eventNum); + + //OSReport("Eventnum: %d. Event flag: %08x %08x\n", eventNum, self->eventFlag >> 32, self->eventFlag & 0xFFFFFFFF); + + self->func = (self->settings) & 1; + self->width = (self->settings >> 4) & 15; + self->height = (self->settings >> 8) & 15; + + self->lastEvState = 0xFF; + + LineGod_BuildList(self); + LineGod_Update(self); + + return true; +} + +bool LineGod_Execute(LineGod *self) { + LineGod_Update(self); + return true; +} + +void LineGod_BuildList(LineGod *self) { + for (int clearIdx = 0; clearIdx < 8; clearIdx++) { + self->ac[clearIdx] = 0; + } + + + u16 x1 = self->x / 16; + u16 x2 = x1 + self->width - 1; + u16 y1 = (-self->y) / 16; + u16 y2 = y1 + self->height - 1; + OSReport("Searching ... %d,%d - %d,%d\n", x1, y1, x2, y2); + + x1 -= (BG_GM_ptr->_0x8FE64 / 16); + x2 -= (BG_GM_ptr->_0x8FE64 / 16); + y1 += (BG_GM_ptr->_0x8FE6C / 16); + y2 += (BG_GM_ptr->_0x8FE6C / 16); + OSReport("Manipulated offsets ... %d,%d - %d,%d\n", x1, y1, x2, y2); + + OSReport("My array: %p\n", &self->ac[0]); + + for (int i = 0; i < dBgActorManager->count; i++) { + BgActor *ac = &dBgActorManager->array[i]; + //OSReport("Actor %p: %d,%d", ac, ac->x, ac->y); + + if (ac->x >= x1 && ac->x <= x2 && ac->y >= y1 && ac->y <= y2) + LineGod_AppendToList(self, ac); + } +} + +bool LineGod_AppendToList(LineGod *self, BgActor *ac) { + OSReport("Adding %p to the list (pos: %d,%d)\n", ac, ac->x, ac->y); + + for (int search = 0; search < 8; search++) { + if (self->ac[search] == 0) { + self->ac[search] = ac; + return true; + } + } + + return false; +} + +void LineGod_Update(LineGod *self) { + //OSReport("%08x%08x", EventTable->events >> 32, EventTable->events & 0xFFFFFFFF); + + u8 newEvState = 0; + if (EventTable->events & self->eventFlag) + newEvState = 1; + + if (newEvState == self->lastEvState) + return; + + u16 x_bias = (BG_GM_ptr->_0x8FE64 / 16); + u16 y_bias = -(BG_GM_ptr->_0x8FE6C / 16); + + OSReport("Event state changed from %d to %d\n", self->lastEvState, newEvState); + + u8 offState; + if (self->func == LINEGOD_FUNC_ACTIVATE) + offState = (newEvState == 1) ? 1 : 0; + else + offState = (newEvState == 1) ? 0 : 1; + + //OSReport("offState is %d\n", offState); + + for (int i = 0; i < 8; i++) { + if (self->ac[i] != 0) { + BgActor *ac = self->ac[i]; + + //OSReport("Assigning %d to %p->EXTRA_off (actor ID is %d)\n", offState, ac, ac->actor_id); + + ac->EXTRA_off = offState; + if (offState == 1 && ac->actor_id != 0) { + fBase_c *assoc_ac = FindActorByID(ac->actor_id); + //OSReport("Got actor: %p\n", assoc_ac); + if (assoc_ac != 0) + assoc_ac->Delete(); + ac->actor_id = 0; + } + + u16 *tile = GetPointerToTile(BG_GM_ptr, (ac->x + x_bias) * 16, (ac->y + y_bias) * 16, 0, 0, 0); + if (offState == 1) + *tile = 0; + else + *tile = BgActorDefs[ac->def_id].tilenum; + + //OSReport("def_id: %d; def_ptr: %p\n", ac->def_id, &(BgActorDefs[ac->def_id])); + //OSReport("Placed tile %d at %p [%d,%d]\n", *tile, tile, ac->x+x_bias, ac->y+y_bias); + } + } + + //OSReport("Success!\n"); + + + self->lastEvState = newEvState; +} diff --git a/src/msgbox.S b/src/msgbox.S index db0021c..ac49676 100644 --- a/src/msgbox.S +++ b/src/msgbox.S @@ -1,37 +1,37 @@ -.text
-
-#ifndef __MWERKS__
-.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4
-.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
-.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
-.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
-.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
-.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
-.set r30,30; .set r31,31; .set f0,0; .set f2,2; .set f3,3
-#endif
-
-.extern Global5758
-
-# -if param & 1 /and/ messagebox is on,
-# otherwise, return Global5758 & param
-
-.global Query5758Replacement
-Query5758Replacement:
- mr 5, 3 # save param
- lis 4, Global5758@h
- ori 4, 4, Global5758@l
- lwz 0, 0(4) # get 5758
- and 3, 0, 3 # AND with param
- andi. 5, 5, 1 # if param & 1 == 0..
- beqlr # then return
-
- lis 4, MessageBoxIsShowing@h
- ori 4, 4, MessageBoxIsShowing@l
- lwz 4, 0(4)
- or 3, 3, 4 # otherwise, OR with MessageBoxIsShowing
- blr # then return
-
-
-.data
-MessageBoxIsShowing:
- .long 0
+.text + +#ifndef __MWERKS__ +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24 +.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29 +.set r30,30; .set r31,31; .set f0,0; .set f2,2; .set f3,3 +#endif + +.extern Global5758 + +# -if param & 1 /and/ messagebox is on, +# otherwise, return Global5758 & param + +.global Query5758Replacement +Query5758Replacement: + mr 5, 3 # save param + lis 4, Global5758@h + ori 4, 4, Global5758@l + lwz 0, 0(4) # get 5758 + and 3, 0, 3 # AND with param + andi. 5, 5, 1 # if param & 1 == 0.. + beqlr # then return + + lis 4, MessageBoxIsShowing@h + ori 4, 4, MessageBoxIsShowing@l + lwz 4, 0(4) + or 3, 3, 4 # otherwise, OR with MessageBoxIsShowing + blr # then return + + +.data +MessageBoxIsShowing: + .long 0 diff --git a/src/msgbox.cpp b/src/msgbox.cpp index 63eb994..f99f73f 100644 --- a/src/msgbox.cpp +++ b/src/msgbox.cpp @@ -1,227 +1,227 @@ -#include <common.h>
-#include <game.h>
-#include "layoutlib.h"
-#include "fileload.h"
-
-
-struct MsgData_Header {
- u32 magic;
- u32 msgCount;
-};
-
-struct MsgData_Entry {
- u32 number;
- u32 titleOffset;
- u32 msgOffset;
-};
-
-
-
-struct dMsgBoxManager_c {
- // 0x00
- int ID;
- unsigned int Settings;
- short Type;
- char Unk_0A;
- char Unk_0B;
- char Unk_0C;
- char Unk_0D;
- char Unk_0E;
- char Unk_0F;
-
- // 0x10
- void *CONNECT_parent;
- void *CONNECT_child;
- void *CONNECT_prev;
- void *CONNECT_next;
-
- // 0x20
- void *CONNECT_thisObj;
- void *EXECUTE_prev;
- void *EXECUTE_next;
- void *EXECUTE_thisObj;
-
- // 0x30
- short Unk_30;
- short Unk_32;
- void *DRAW_prev;
- void *DRAW_next;
- void *DRAW_thisObj;
-
- // 0x40
- short Unk_40;
- short Unk_42;
- void *IDLookup_prev;
- void *IDLookup_next;
- void *IDLookup_thisObj;
-
- // 0x50
- void *Unk_50;
- int Unk_54;
- int Unk_58;
- void *Unk_5C;
-
- // 0x60
- void *vtable;
- int Unk_64; // dBase_c starts here
- char *weirdTypeString;
- char *actorName;
-
- // dMsgBoxManager_c starts here (offset 0x70)
- Layout *layout;
- int state;
- FileHandle msgDataFH;
-
- // 0x80
- void *msgData;
-
- // current allocated class size: 0xD0
-};
-
-
-#define STATE_NULL 0
-#define STATE_BOX_APPEAR_WAIT 1
-#define STATE_BUTTON_APPEAR_WAIT 2
-#define STATE_SHOWN 3
-#define STATE_BUTTON_DISAPPEAR_WAIT 4
-#define STATE_BOX_DISAPPEAR_WAIT 5
-
-#define animBoxAppear 0
-#define animBoxDisappear 1
-#define animButtonAppear 2
-#define animButtonDisappear 3
-
-extern int MessageBoxIsShowing;
-dMsgBoxManager_c *CurrentMsgBoxManager;
-
-const char *brlan_BoxAppear = "BoxAppear.brlan";
-const char *brlan_BoxDisappear = "BoxDisappear.brlan";
-const char *brlan_ButtonAppear = "ButtonAppear.brlan";
-const char *brlan_ButtonDisappear = "ButtonDisappear.brlan";
-
-const char *group_Box = "G_Box";
-const char *group_Button = "G_Button";
-
-bool dMsgBoxManager_c__Create(dMsgBoxManager_c *self) {
- self->layout = (Layout*)AllocFromGameHeap1(sizeof(Layout));
-
- if (!self->layout) {
- OSReport("memalloc fail\n");
- InfiniteLoop;
- }
-
- EmbeddedLayout_ctor(self->layout);
- EmbeddedLayout_LoadArc(self->layout, "NewerRes/msgbox.arc");
-
- if (!EmbeddedLayout_Build(self->layout, "MessageBox.brlyt", 0)) {
- OSReport("build fail\n");
- InfiniteLoop;
- }
-
-
- const char *anims[4] = {brlan_BoxAppear, brlan_BoxDisappear, brlan_ButtonAppear, brlan_ButtonDisappear};
- EmbeddedLayout_LoadBrlans(self->layout, anims, 4);
-
- const char *groups[4] = {group_Box, group_Box, group_Button, group_Button};
-
- int mappings[4] = {0, 1, 2, 3};
- EmbeddedLayout_LoadGroups(self->layout, groups, mappings, 4);
-
- EmbeddedLayout_DisableAllAnims(self->layout);
-
- for (int i = 0; i < 4; i++) {
- EmbeddedLayout_ResetAnimToInitialState(self->layout, i, false);
- }
-
- self->msgData = LoadFile(&self->msgDataFH, "/NewerRes/MsgData.bin");
-
- self->state = STATE_NULL;
- self->layout->drawOrder = 0xA0;
-
- CurrentMsgBoxManager = self;
-
- return true;
-}
-
-bool dMsgBoxManager_c__Execute(dMsgBoxManager_c *self) {
- if (self->state == STATE_NULL)
- return true;
-
-
- switch (self->state) {
- /**************************************************************************/
- case STATE_BOX_APPEAR_WAIT:
- if (!EmbeddedLayout_CheckIfAnimationIsOn(self->layout, animBoxAppear)) {
- EmbeddedLayout_EnableNonLoopAnim(self->layout, animButtonAppear, false);
- self->state = STATE_BUTTON_APPEAR_WAIT;
- }
-
- break;
-
- /**************************************************************************/
- case STATE_BUTTON_APPEAR_WAIT:
- if (!EmbeddedLayout_CheckIfAnimationIsOn(self->layout, animButtonAppear)) {
- self->state = STATE_SHOWN;
- }
-
- break;
-
- /**************************************************************************/
- case STATE_SHOWN:
- if (false) {
- EmbeddedLayout_EnableNonLoopAnim(self->layout, animButtonDisappear, false);
- self->state = STATE_BUTTON_DISAPPEAR_WAIT;
- }
-
- break;
-
- /**************************************************************************/
- case STATE_BUTTON_DISAPPEAR_WAIT:
- if (!EmbeddedLayout_CheckIfAnimationIsOn(self->layout, animButtonDisappear)) {
- EmbeddedLayout_EnableNonLoopAnim(self->layout, animBoxDisappear, false);
- self->state = STATE_BOX_DISAPPEAR_WAIT;
- }
-
- break;
-
- /**************************************************************************/
- case STATE_BOX_DISAPPEAR_WAIT:
- if (!EmbeddedLayout_CheckIfAnimationIsOn(self->layout, animBoxDisappear)) {
- self->state = STATE_NULL;
-
- EmbeddedLayout_DisableAllAnims(self->layout);
-
- for (int i = 0; i < 4; i++) {
- EmbeddedLayout_ResetAnimToInitialState(self->layout, i, false);
- }
- }
- break;
- }
-
-
- EmbeddedLayout_Process(self->layout);
- EmbeddedLayout_UpdateMatrix(self->layout);
-
- return true;
-}
-
-bool dMsgBoxManager_c__Draw(dMsgBoxManager_c *self) {
- if (self->state != STATE_NULL) {
- EmbeddedLayout_AddToDrawList(self->layout);
- }
-
- return true;
-}
-
-bool dMsgBoxManager_c__Delete(dMsgBoxManager_c *self) {
- EmbeddedLayout_FreeArc(self->layout);
- EmbeddedLayout_Free(self->layout);
- EmbeddedLayout_dtor(self->layout, false);
- FreeFromGameHeap1(self->layout);
-
- CurrentMsgBoxManager = 0;
-
- return true;
-}
-
-
+#include <common.h> +#include <game.h> +#include "layoutlib.h" +#include "fileload.h" + + +struct MsgData_Header { + u32 magic; + u32 msgCount; +}; + +struct MsgData_Entry { + u32 number; + u32 titleOffset; + u32 msgOffset; +}; + + + +struct dMsgBoxManager_c { + // 0x00 + int ID; + unsigned int Settings; + short Type; + char Unk_0A; + char Unk_0B; + char Unk_0C; + char Unk_0D; + char Unk_0E; + char Unk_0F; + + // 0x10 + void *CONNECT_parent; + void *CONNECT_child; + void *CONNECT_prev; + void *CONNECT_next; + + // 0x20 + void *CONNECT_thisObj; + void *EXECUTE_prev; + void *EXECUTE_next; + void *EXECUTE_thisObj; + + // 0x30 + short Unk_30; + short Unk_32; + void *DRAW_prev; + void *DRAW_next; + void *DRAW_thisObj; + + // 0x40 + short Unk_40; + short Unk_42; + void *IDLookup_prev; + void *IDLookup_next; + void *IDLookup_thisObj; + + // 0x50 + void *Unk_50; + int Unk_54; + int Unk_58; + void *Unk_5C; + + // 0x60 + void *vtable; + int Unk_64; // dBase_c starts here + char *weirdTypeString; + char *actorName; + + // dMsgBoxManager_c starts here (offset 0x70) + Layout *layout; + int state; + FileHandle msgDataFH; + + // 0x80 + void *msgData; + + // current allocated class size: 0xD0 +}; + + +#define STATE_NULL 0 +#define STATE_BOX_APPEAR_WAIT 1 +#define STATE_BUTTON_APPEAR_WAIT 2 +#define STATE_SHOWN 3 +#define STATE_BUTTON_DISAPPEAR_WAIT 4 +#define STATE_BOX_DISAPPEAR_WAIT 5 + +#define animBoxAppear 0 +#define animBoxDisappear 1 +#define animButtonAppear 2 +#define animButtonDisappear 3 + +extern int MessageBoxIsShowing; +dMsgBoxManager_c *CurrentMsgBoxManager; + +const char *brlan_BoxAppear = "BoxAppear.brlan"; +const char *brlan_BoxDisappear = "BoxDisappear.brlan"; +const char *brlan_ButtonAppear = "ButtonAppear.brlan"; +const char *brlan_ButtonDisappear = "ButtonDisappear.brlan"; + +const char *group_Box = "G_Box"; +const char *group_Button = "G_Button"; + +bool dMsgBoxManager_c__Create(dMsgBoxManager_c *self) { + self->layout = (Layout*)AllocFromGameHeap1(sizeof(Layout)); + + if (!self->layout) { + OSReport("memalloc fail\n"); + InfiniteLoop; + } + + EmbeddedLayout_ctor(self->layout); + EmbeddedLayout_LoadArc(self->layout, "NewerRes/msgbox.arc"); + + if (!EmbeddedLayout_Build(self->layout, "MessageBox.brlyt", 0)) { + OSReport("build fail\n"); + InfiniteLoop; + } + + + const char *anims[4] = {brlan_BoxAppear, brlan_BoxDisappear, brlan_ButtonAppear, brlan_ButtonDisappear}; + EmbeddedLayout_LoadBrlans(self->layout, anims, 4); + + const char *groups[4] = {group_Box, group_Box, group_Button, group_Button}; + + int mappings[4] = {0, 1, 2, 3}; + EmbeddedLayout_LoadGroups(self->layout, groups, mappings, 4); + + EmbeddedLayout_DisableAllAnims(self->layout); + + for (int i = 0; i < 4; i++) { + EmbeddedLayout_ResetAnimToInitialState(self->layout, i, false); + } + + self->msgData = LoadFile(&self->msgDataFH, "/NewerRes/MsgData.bin"); + + self->state = STATE_NULL; + self->layout->drawOrder = 0xA0; + + CurrentMsgBoxManager = self; + + return true; +} + +bool dMsgBoxManager_c__Execute(dMsgBoxManager_c *self) { + if (self->state == STATE_NULL) + return true; + + + switch (self->state) { + /**************************************************************************/ + case STATE_BOX_APPEAR_WAIT: + if (!EmbeddedLayout_CheckIfAnimationIsOn(self->layout, animBoxAppear)) { + EmbeddedLayout_EnableNonLoopAnim(self->layout, animButtonAppear, false); + self->state = STATE_BUTTON_APPEAR_WAIT; + } + + break; + + /**************************************************************************/ + case STATE_BUTTON_APPEAR_WAIT: + if (!EmbeddedLayout_CheckIfAnimationIsOn(self->layout, animButtonAppear)) { + self->state = STATE_SHOWN; + } + + break; + + /**************************************************************************/ + case STATE_SHOWN: + if (false) { + EmbeddedLayout_EnableNonLoopAnim(self->layout, animButtonDisappear, false); + self->state = STATE_BUTTON_DISAPPEAR_WAIT; + } + + break; + + /**************************************************************************/ + case STATE_BUTTON_DISAPPEAR_WAIT: + if (!EmbeddedLayout_CheckIfAnimationIsOn(self->layout, animButtonDisappear)) { + EmbeddedLayout_EnableNonLoopAnim(self->layout, animBoxDisappear, false); + self->state = STATE_BOX_DISAPPEAR_WAIT; + } + + break; + + /**************************************************************************/ + case STATE_BOX_DISAPPEAR_WAIT: + if (!EmbeddedLayout_CheckIfAnimationIsOn(self->layout, animBoxDisappear)) { + self->state = STATE_NULL; + + EmbeddedLayout_DisableAllAnims(self->layout); + + for (int i = 0; i < 4; i++) { + EmbeddedLayout_ResetAnimToInitialState(self->layout, i, false); + } + } + break; + } + + + EmbeddedLayout_Process(self->layout); + EmbeddedLayout_UpdateMatrix(self->layout); + + return true; +} + +bool dMsgBoxManager_c__Draw(dMsgBoxManager_c *self) { + if (self->state != STATE_NULL) { + EmbeddedLayout_AddToDrawList(self->layout); + } + + return true; +} + +bool dMsgBoxManager_c__Delete(dMsgBoxManager_c *self) { + EmbeddedLayout_FreeArc(self->layout); + EmbeddedLayout_Free(self->layout); + EmbeddedLayout_dtor(self->layout, false); + FreeFromGameHeap1(self->layout); + + CurrentMsgBoxManager = 0; + + return true; +} + + diff --git a/src/poweruphax.S b/src/poweruphax.S index bfd8c83..3db06c7 100644 --- a/src/poweruphax.S +++ b/src/poweruphax.S @@ -1,689 +1,689 @@ -.text
-.align 4
-.set sp, 1
-
-.extern returnFromGPSFASixth
-.extern daEnItem_c__GetWhetherPlayerCanGetPowerupOrNot
-.extern dAcPy_c__ChangePowerupWithAnimation
-.extern PlayPlayerSound
-.extern CreateActor
-.extern PlayerProjectileShooting
-.extern Actor_SearchByName
-.extern SomeTable_802F5440
-.extern SomeTable_802F5580
-.extern SomeTable_802F56C0
-.extern BlahTable
-.extern continuePlumberSetPowerupTexture
-.extern doneSettingThePowerupTexture
-.extern doneSettingThePowerupTexture2
-
-#ifndef __MWERKS__
-.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4
-.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
-.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
-.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
-.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
-.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
-.set r30,30; .set r31,31; .set f0,0; .set f2,2; .set f3,3
-.set f1,1; .set f30,30; .set f31,31
-#endif
-
-.global GetInfoFromDumbTable
-GetInfoFromDumbTable:
- lis r3, SomeTable@h
- ori r3, r3, SomeTable@l
-
- slwi r4, r4, 2
- slwi r0, r5, 6
-
- lwzx r3, r3, r4
- add r3, r3, r0
- blr
-
-
-
-
-.global FukidashiFix
-FukidashiFix:
- lis r7, ZeroFloat@h
- ori r7, r7, ZeroFloat@l
-
- lis r8, FukidashiTable2@h
- ori r8, r8, FukidashiTable2@l
-
- mulli r6, r4, 0x20
- slwi r0, r5, 2
- add r0, r0, r6
-
- lfs f0, 0(r7)
- lfsx f1, r8, r0
-
- stfs f0, 0x1DC(r3)
- stfs f1, 0x1E0(r3)
- stfs f0, 0x1E4(r3)
-
- blr
-
-
-
-
-.global PlayerGetHeight
-PlayerGetHeight:
- lwz r0, 0x14D4(r3)
-
- lwz r4, 0x1090(r3)
- slwi r4, r4, 3
-
- cmpwi r0, 0
- beq useNormal
- cmpwi r0, 1
- bne useDucking
-
-useNormal:
- lis r3, PlayerHeightsNormal@h
- ori r3, r3, PlayerHeightsNormal@l
- b gotOffset
-
-useDucking:
- lis r3, PlayerHeightsDucking@h
- ori r3, r3, PlayerHeightsDucking@l
-
-gotOffset:
- lfsx f1, r3, r4
- blr
-
-
-
-.global WtfEver
-WtfEver:
- lis r3, WtfEverTable@h
- ori r3, r3, WtfEverTable@l
- lfsx f0, r3, r0
- blr
-
-
-
-.global YetAnother
-YetAnother:
- lis r3, YetAnotherTable@h
- ori r3, r3, YetAnotherTable@l
- lfsx f0, r3, r0
- blr
-
-
-
-
-.global GetWeirdScaleTable
-GetWeirdScaleTable:
- lis r5, WeirdScaleTable@h
- ori r5, r5, WeirdScaleTable@l
- lfsx f1, r5, r0
- blr
-
-
-
-
-
-.global GetAsdfTable
-GetAsdfTable:
- extsb r0, r4
- cmpwi r0, -1
- bne dontGetThisOne
-
- lwz r0, 0x1090(r3)
- extsb r4, r0
-
-dontGetThisOne:
- extsb r0, r4
-
- lis r3, AsdfTable@h
- ori r3, r3, AsdfTable@l
- lbzx r3, r3, r0
-
- blr
-
-
-
-
-
-.global GetBlahTableOffset
-GetBlahTableOffset:
- lis r5, BlahTableOffsets@h
- ori r5, r5, BlahTableOffsets@l
- lwzx r30, r5, r4
- blr
-
-
-.global DealWithBlahTable
-DealWithBlahTable:
- lis r5, BlahTableOffsets@h
- ori r5, r5, BlahTableOffsets@l
-
- # points to BlahTable
- lis r4, BlahTable@h
- ori r4, r4, BlahTable@l
-
- # get blahtableoffset entry based on powerup
- lwz r0, 0x1090(r3)
- slwi r0, r0, 2
- lwzx r0, r5, r0
-
- # now get the entry from the blahtable
- slwi r0, r0, 2
- lwzx r4, r4, r0
-
- # do shit here
-
- lfs f3, 0(r4)
- stfs f3, 0x14E4(r3)
- stfs f3, 0x164(r3)
-
- lfs f1, 0x2A70(r3)
- lfs f0, 0x2A74(r3)
-
- lfs f2, 4(r4)
- fadds f1, f2, f1
- fadds f0, f0, f1
- stfs f0, 0x14E8(r3)
- stfs f0, 0x168(r3)
-
- lfs f0, 0x8(r4)
- lfs f1, 0xC(r4)
- stfs f0, 0x16C(r3)
- stfs f1, 0x170(r3)
-
- # hope I did this right
- blr
-
-
-
-
-
-.global GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r4_dest
-GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r4_dest:
- lis r6, PowerupScaleFloats@h
- ori r6, r6, PowerupScaleFloats@l
- add r4, r6, r0
- blr
-
-.global GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r3_dest
-GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r3_dest:
- lis r6, PowerupScaleFloats@h
- ori r6, r6, PowerupScaleFloats@l
- add r3, r6, r0
- blr
-
-.global GetPowerupScaleFloatAddr_r8_trash_r0_valshl2_r7_dest
-GetPowerupScaleFloatAddr_r8_trash_r0_valshl2_r7_dest:
- lis r8, PowerupScaleFloats@h
- ori r8, r8, PowerupScaleFloats@l
- add r7, r8, r0
- blr
-
-.global GetPowerupScaleFloatAddr_fixForSixth
-GetPowerupScaleFloatAddr_fixForSixth:
- lis r5, PowerupScaleFloats@h
- ori r5, r5, PowerupScaleFloats@l
- add r4, r5, r4
- b returnFromGPSFASixth
-
-
-
-.global PlumberSetPowerupFix
-PlumberSetPowerupFix:
- lbz r0, 0x152(r31) # get powerup id
-
- cmpwi r0, 2
- beq doFireTex
-
- cmpwi r0, 6
- beq doIceTex
-
- cmpwi r0, 7
- beq doHammerTex
-
- li r4, 0
- b gotTexID
-
-doFireTex:
- li r4, 1
- b gotTexID
-
-doIceTex:
- li r4, 2
- b gotTexID
-
-doHammerTex:
- li r4, 3
-
-gotTexID:
- lwz r12, 0(r31)
- mr r3, r31
- lwz r12, 0x34(r12)
- mtctr r12
- bctrl
-
- b doneSettingThePowerupTexture
-
-
-
-.global PlumberSetPowerupFix2
-PlumberSetPowerupFix2:
- cmpwi r31, 2
- beq doFireTex2
-
- cmpwi r31, 6
- beq doIceTex2
-
- cmpwi r31, 7
- beq doHammerTex2
-
- li r4, 0
- b gotTexID2
-
-doFireTex2:
- li r4, 1
- b gotTexID2
-
-doIceTex2:
- li r4, 2
- b gotTexID2
-
-doHammerTex2:
- li r4, 3
-
-gotTexID2:
- lwz r3, 0x2A64(r30)
- lwz r12, 0(r3)
- lwz r12, 0x34(r12)
- mtctr r12
- bctrl
-
- b doneSettingThePowerupTexture2
-
-
-
-
-.global PlumberSetPowerupTextureDebug
-.extern OSReport
-.extern continuePlumberSetPowerupTextureDebug
-PlumberSetPowerupTextureDebug:
- stwu sp, -0x30(sp)
- mflr r0
- stw r0, 0x34(sp)
- stw r3, 0x20(sp)
- stw r4, 0x24(sp)
-
- mr r6, r0
- mr r5, r4
- mr r4, r3
- lis r3, PowerupTexDebugStr@h
- ori r3, r3, PowerupTexDebugStr@l
- crclr 4*cr1+eq
- bl OSReport
-
- lwz r3, 0x20(sp)
- lwz r4, 0x24(sp)
- lwz r0, 0x34(sp)
- mtlr r0
- addi sp, sp, 0x30
-
- stwu sp, -0x30(sp)
-
- b continuePlumberSetPowerupTextureDebug
-
-
-
-
-
-.global PlumberSetPowerupTextureFix
-PlumberSetPowerupTextureFix:
- stb r4, 0x153(r3)
-
- lis r5, PowerupTextures@h
- ori r5, r5, PowerupTextures@l
-
- slwi r4, r4, 2
- lfsx f31, r5, r4
-
- b continuePlumberSetPowerupTexture
-
-
-
-.global SetHammerToEnItemDCA
-SetHammerToEnItemDCA:
- bl daEnItem_c__GetWhetherPlayerCanGetPowerupOrNot
- cmpwi r3, 1
- bne DontSetHammer
-
- li r0, 5
- sth r0, 0xDCA(r31)
-
-DontSetHammer:
- lwz r0, 0x14(sp)
- lwz r31, 0xC(sp)
- mtlr r0
- addi sp, sp, 0x10
- blr
-
-
-#.global EnItem_BindAnimation_Fix
-#EnItem_BindAnimation_Fix:
-# lhz r0, 0xDCA(r3)
-# cmpwi r0, 5
-# beqlr
-# stwu sp, -0x20(sp)
-# b EnItem_BindAnimation_Continued
-
-
-.global WeirdAnimLoadHack
-WeirdAnimLoadHack:
- cmplwi r4, 5 #hammersuit
- beqlr
- cmplwi r4, 6 #1up
- beqlr
- # neither of those succeeded
- crclr 4*cr0+eq
- blr
-
-
-
-.global TryToGiveMarioHammerSuit
-TryToGiveMarioHammerSuit:
- stwu sp, -0x10(sp)
- mflr r0
- stw r0, 0x14(sp)
-
- # check the obtained item number
- cmplwi r3, 5
- bne IsntGettingHammerSuit
-
- # check the current player powerup
- cmplwi r4, 7
- bne DontHaveHammerSuit
-
- li r28, 0
- li r29, 2
- b ReturnFromTTGMHS
-
-DontHaveHammerSuit:
- mr r3, r30
- li r4, 7
- bl dAcPy_c__ChangePowerupWithAnimation
-
- cmpwi r3, 0
- beq ReturnFromTTGMHS
-
- li r29, 1
-
-IsntGettingHammerSuit:
-ReturnFromTTGMHS:
- # end of function
- lwz r0, 0x14(sp)
- mtlr r0
- addi sp, sp, 0x10
-
- # leftover instruction from what we replaced to add the bl
- cmpwi r29, 0
- blr
-
-
-
-.global ThrowHammer
-ThrowHammer:
- # continues on from PlayerProjectileShooting
-
- # get powerup
- lwz r3, 0x1090(r30)
- cmplwi r3, 7
- bne ReturnFromThrowHammer
-
- mr r3, r30
- li r4, 498
- li r5, 0
- bl PlayPlayerSound
-
- li r3, 0x73 # Hammer
- li r4, 0 # Settings
- addi r5, sp, 0x2C # Position
- li r6, 0 # Rotation
- lbz r7, 0x38F(r30) # Layer
- bl CreateActor
-
- # Store player ID
- lwz r4, 0(r30)
- stw r4, 0x450(r3)
-
- # store player number, but add 0x100 to differentiate it from 0
- lbz r4, 0x38D(r30)
- addi r4, r4, 0x100
- stw r4, 0x458(r3)
-
- # Fix scale
- lis r4, OneFloat@h
- ori r4, r4, OneFloat@l
- lfs f0, 0(r4)
- stfs f0, 0xDC(r3)
- stfs f0, 0xE0(r3)
- stfs f0, 0xE4(r3)
-
- mr r4, r30
- lwz r12, 0x60(r3)
- lwz r12, 0x8C(r12)
- mtctr r12
- bctrl
-
-ReturnFromThrowHammer:
- lwz r0, 0xC4(sp)
- psq_l f31, 0xB8(sp), 1, 0
- lfd f31, 0xB0(sp)
- psq_l f30, 0xA8(sp), 1, 0
- lfd f30, 0xA0(sp)
- lwz r31, 0x9C(sp)
- lwz r30, 0x98(sp)
- mtlr r0
- addi sp, sp, 0xC0
- blr
-
-
-
-.global MoreProjectileStuff_Fix
-MoreProjectileStuff_Fix:
- lwz r3, 0x1090(r31)
- cmplwi r3, 7
- bne ReturnFromMPSFix
-
- mr r3, r31
- li r4, 1
- bl PlayerProjectileShooting
-
-ReturnFromMPSFix:
- lwz r0, 0x14(sp)
- lwz r31, 0xC(sp)
- mtlr r0
- addi sp, sp, 0x10
- blr
-
-
-
-.global ProjectileShootCheck_Fix
-ProjectileShootCheck_Fix:
- lwz r3, 0x1090(r31)
- cmplwi r3, 7
- bne Return0fromPSCFix
-
- lbz r3, 0x38D(r31)
- li r4, 0
- extsb r3, r3
- bl CheckHammerLimit
-
- cmpwi r3, 0
- beq Return0fromPSCFix
-
- b Return1fromPSCFix
-
-Return0fromPSCFix:
- li r3, 0
- b ReturnFromPSCFix
-
-Return1fromPSCFix:
- li r3, 1
-
-ReturnFromPSCFix:
- lwz r0, 0x14(sp)
- lwz r31, 0xC(sp)
- mtlr r0
- addi sp, sp, 0x10
- blr
-
-
-.global CheckHammerLimit
-CheckHammerLimit:
- stwu sp, -0x10(sp)
- mflr r0
- stw r0, 0x14(sp)
- stw r31, 0xC(sp)
- stw r30, 0x8(sp)
-
- # r30 = player number
- mr r30, r3
- addi r30, r30, 0x100
-
- # r31 = hammer count so far
- li r31, 0
-
- # search for every Hammer
-
- li r3, 0
- b startOrContinueLoop
-loop:
-
- lwz r4, 0x458(r3)
- cmpw r4, r30
- bne startOrContinueLoop
-
- addi r31, r31, 1
-
-startOrContinueLoop:
- mr r4, r3
- li r3, 0x73
- bl Actor_SearchByName
-
- cmpwi r3, 0
- bne loop
-
- # now if the current count is >= 2, return 0
- # otherwise return 1
- cmpwi r31, 2
- bge tooManyHammers
-
- li r3, 1
- b gotHammerStatus
-
-tooManyHammers:
- li r3, 0
-
-gotHammerStatus:
- lwz r0, 0x14(sp)
- lwz r31, 0xC(sp)
- lwz r30, 0x8(sp)
- mtlr r0
- addi sp, sp, 0x10
- blr
-
-
-
-
-
-
-.data
-
-SomeTable:
- .long SomeTable_802F5580
- .long SomeTable_802F56C0
- .long SomeTable_802F56C0
- .long SomeTable_802F5440
- .long SomeTable_802F56C0
- .long SomeTable_802F56C0
- .long SomeTable_802F56C0
- .long SomeTable_802F56C0
-
-ZeroFloat:
- .float 0.0
-
-OneFloat:
- .float 1.0
-
-FukidashiTable2:
- .float 20.0, 32.0, 32.0, 12.0, 38.0, 33.0, 32.0, 32.0
- .float 20.0, 34.0, 34.0, 12.0, 39.0, 35.0, 34.0, 34.0
- .float 20.0, 29.0, 29.0, 11.0, 34.0, 29.0, 29.0, 29.0
- .float 20.0, 29.0, 29.0, 11.0, 34.0, 29.0, 29.0, 29.0
-
-PlayerHeightsNormal:
- .float 16.0, 27.0, 27.0, 12.0, 27.0, 27.0, 27.0, 27.0
-
-PlayerHeightsDucking:
- .float 13.0, 21.0, 21.0, 9.0, 21.0, 21.0, 21.0, 21.0
-
-WtfEverTable:
- .float 4.5, 10.0, 10.0, 1.0, 10.0, 9.0, 10.0, 10.0
-
-YetAnotherTable:
- .float 0.0, -4.0, -4.0, 4.0, -6.0, -2.0, -4.0, -4.0
-
-WeirdScaleTable:
- .float 16.0, 31.0, 31.0, 6.0, 34.0, 31.0, 31.0, 31.0
-
-AsdfTable:
- .byte 1, 2, 2, 0, 2, 2, 2, 2
-
-BlahTableOffsets:
- .long 1, 2, 2, 0, 3, 2, 2, 2
-
-PowerupScaleFloats:
- .long 0xDEADBEEF, 0xDEADBEEF # padding
- .float 1.0
- .float 1.0
- .float 1.0
- .float 0.6
- .float 1.0
- .float 1.0
- .float 1.0
- .float 1.0
-
-PowerupTextures:
- .float 0.0
- .float 1.0
- .float 2.0
- .float 3.0
-
-.global BrosArcFileName
-BrosArcFileName:
- .string "bros"
-
-.global I_hammerArcFilename
-I_hammerArcFilename:
- .string "I_hammer"
-
-.global I_hammerResFile
-I_hammerResFile:
-# .string "g3d/I_hammer.brres"
- .string "g3d/I_fireflower.brres"
-
-.global I_hammerModelName
-I_hammerModelName:
-# .string "I_hammer"
- .string "I_fireflower"
-
-
-PowerupTexDebugStr:
- .string "Plumber::SetPowerupTexture() called on class %p with texnum %d lr=%p\n"
-
-#.global BrosModelFilename
-#BrosModelFilename:
-# .string "g3d/bros.brres"
-
-#.global HammerModelName
-#HammerModelName:
-# .string "bros_hammer"
+.text +.align 4 +.set sp, 1 + +.extern returnFromGPSFASixth +.extern daEnItem_c__GetWhetherPlayerCanGetPowerupOrNot +.extern dAcPy_c__ChangePowerupWithAnimation +.extern PlayPlayerSound +.extern CreateActor +.extern PlayerProjectileShooting +.extern Actor_SearchByName +.extern SomeTable_802F5440 +.extern SomeTable_802F5580 +.extern SomeTable_802F56C0 +.extern BlahTable +.extern continuePlumberSetPowerupTexture +.extern doneSettingThePowerupTexture +.extern doneSettingThePowerupTexture2 + +#ifndef __MWERKS__ +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24 +.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29 +.set r30,30; .set r31,31; .set f0,0; .set f2,2; .set f3,3 +.set f1,1; .set f30,30; .set f31,31 +#endif + +.global GetInfoFromDumbTable +GetInfoFromDumbTable: + lis r3, SomeTable@h + ori r3, r3, SomeTable@l + + slwi r4, r4, 2 + slwi r0, r5, 6 + + lwzx r3, r3, r4 + add r3, r3, r0 + blr + + + + +.global FukidashiFix +FukidashiFix: + lis r7, ZeroFloat@h + ori r7, r7, ZeroFloat@l + + lis r8, FukidashiTable2@h + ori r8, r8, FukidashiTable2@l + + mulli r6, r4, 0x20 + slwi r0, r5, 2 + add r0, r0, r6 + + lfs f0, 0(r7) + lfsx f1, r8, r0 + + stfs f0, 0x1DC(r3) + stfs f1, 0x1E0(r3) + stfs f0, 0x1E4(r3) + + blr + + + + +.global PlayerGetHeight +PlayerGetHeight: + lwz r0, 0x14D4(r3) + + lwz r4, 0x1090(r3) + slwi r4, r4, 3 + + cmpwi r0, 0 + beq useNormal + cmpwi r0, 1 + bne useDucking + +useNormal: + lis r3, PlayerHeightsNormal@h + ori r3, r3, PlayerHeightsNormal@l + b gotOffset + +useDucking: + lis r3, PlayerHeightsDucking@h + ori r3, r3, PlayerHeightsDucking@l + +gotOffset: + lfsx f1, r3, r4 + blr + + + +.global WtfEver +WtfEver: + lis r3, WtfEverTable@h + ori r3, r3, WtfEverTable@l + lfsx f0, r3, r0 + blr + + + +.global YetAnother +YetAnother: + lis r3, YetAnotherTable@h + ori r3, r3, YetAnotherTable@l + lfsx f0, r3, r0 + blr + + + + +.global GetWeirdScaleTable +GetWeirdScaleTable: + lis r5, WeirdScaleTable@h + ori r5, r5, WeirdScaleTable@l + lfsx f1, r5, r0 + blr + + + + + +.global GetAsdfTable +GetAsdfTable: + extsb r0, r4 + cmpwi r0, -1 + bne dontGetThisOne + + lwz r0, 0x1090(r3) + extsb r4, r0 + +dontGetThisOne: + extsb r0, r4 + + lis r3, AsdfTable@h + ori r3, r3, AsdfTable@l + lbzx r3, r3, r0 + + blr + + + + + +.global GetBlahTableOffset +GetBlahTableOffset: + lis r5, BlahTableOffsets@h + ori r5, r5, BlahTableOffsets@l + lwzx r30, r5, r4 + blr + + +.global DealWithBlahTable +DealWithBlahTable: + lis r5, BlahTableOffsets@h + ori r5, r5, BlahTableOffsets@l + + # points to BlahTable + lis r4, BlahTable@h + ori r4, r4, BlahTable@l + + # get blahtableoffset entry based on powerup + lwz r0, 0x1090(r3) + slwi r0, r0, 2 + lwzx r0, r5, r0 + + # now get the entry from the blahtable + slwi r0, r0, 2 + lwzx r4, r4, r0 + + # do shit here + + lfs f3, 0(r4) + stfs f3, 0x14E4(r3) + stfs f3, 0x164(r3) + + lfs f1, 0x2A70(r3) + lfs f0, 0x2A74(r3) + + lfs f2, 4(r4) + fadds f1, f2, f1 + fadds f0, f0, f1 + stfs f0, 0x14E8(r3) + stfs f0, 0x168(r3) + + lfs f0, 0x8(r4) + lfs f1, 0xC(r4) + stfs f0, 0x16C(r3) + stfs f1, 0x170(r3) + + # hope I did this right + blr + + + + + +.global GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r4_dest +GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r4_dest: + lis r6, PowerupScaleFloats@h + ori r6, r6, PowerupScaleFloats@l + add r4, r6, r0 + blr + +.global GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r3_dest +GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r3_dest: + lis r6, PowerupScaleFloats@h + ori r6, r6, PowerupScaleFloats@l + add r3, r6, r0 + blr + +.global GetPowerupScaleFloatAddr_r8_trash_r0_valshl2_r7_dest +GetPowerupScaleFloatAddr_r8_trash_r0_valshl2_r7_dest: + lis r8, PowerupScaleFloats@h + ori r8, r8, PowerupScaleFloats@l + add r7, r8, r0 + blr + +.global GetPowerupScaleFloatAddr_fixForSixth +GetPowerupScaleFloatAddr_fixForSixth: + lis r5, PowerupScaleFloats@h + ori r5, r5, PowerupScaleFloats@l + add r4, r5, r4 + b returnFromGPSFASixth + + + +.global PlumberSetPowerupFix +PlumberSetPowerupFix: + lbz r0, 0x152(r31) # get powerup id + + cmpwi r0, 2 + beq doFireTex + + cmpwi r0, 6 + beq doIceTex + + cmpwi r0, 7 + beq doHammerTex + + li r4, 0 + b gotTexID + +doFireTex: + li r4, 1 + b gotTexID + +doIceTex: + li r4, 2 + b gotTexID + +doHammerTex: + li r4, 3 + +gotTexID: + lwz r12, 0(r31) + mr r3, r31 + lwz r12, 0x34(r12) + mtctr r12 + bctrl + + b doneSettingThePowerupTexture + + + +.global PlumberSetPowerupFix2 +PlumberSetPowerupFix2: + cmpwi r31, 2 + beq doFireTex2 + + cmpwi r31, 6 + beq doIceTex2 + + cmpwi r31, 7 + beq doHammerTex2 + + li r4, 0 + b gotTexID2 + +doFireTex2: + li r4, 1 + b gotTexID2 + +doIceTex2: + li r4, 2 + b gotTexID2 + +doHammerTex2: + li r4, 3 + +gotTexID2: + lwz r3, 0x2A64(r30) + lwz r12, 0(r3) + lwz r12, 0x34(r12) + mtctr r12 + bctrl + + b doneSettingThePowerupTexture2 + + + + +.global PlumberSetPowerupTextureDebug +.extern OSReport +.extern continuePlumberSetPowerupTextureDebug +PlumberSetPowerupTextureDebug: + stwu sp, -0x30(sp) + mflr r0 + stw r0, 0x34(sp) + stw r3, 0x20(sp) + stw r4, 0x24(sp) + + mr r6, r0 + mr r5, r4 + mr r4, r3 + lis r3, PowerupTexDebugStr@h + ori r3, r3, PowerupTexDebugStr@l + crclr 4*cr1+eq + bl OSReport + + lwz r3, 0x20(sp) + lwz r4, 0x24(sp) + lwz r0, 0x34(sp) + mtlr r0 + addi sp, sp, 0x30 + + stwu sp, -0x30(sp) + + b continuePlumberSetPowerupTextureDebug + + + + + +.global PlumberSetPowerupTextureFix +PlumberSetPowerupTextureFix: + stb r4, 0x153(r3) + + lis r5, PowerupTextures@h + ori r5, r5, PowerupTextures@l + + slwi r4, r4, 2 + lfsx f31, r5, r4 + + b continuePlumberSetPowerupTexture + + + +.global SetHammerToEnItemDCA +SetHammerToEnItemDCA: + bl daEnItem_c__GetWhetherPlayerCanGetPowerupOrNot + cmpwi r3, 1 + bne DontSetHammer + + li r0, 5 + sth r0, 0xDCA(r31) + +DontSetHammer: + lwz r0, 0x14(sp) + lwz r31, 0xC(sp) + mtlr r0 + addi sp, sp, 0x10 + blr + + +#.global EnItem_BindAnimation_Fix +#EnItem_BindAnimation_Fix: +# lhz r0, 0xDCA(r3) +# cmpwi r0, 5 +# beqlr +# stwu sp, -0x20(sp) +# b EnItem_BindAnimation_Continued + + +.global WeirdAnimLoadHack +WeirdAnimLoadHack: + cmplwi r4, 5 #hammersuit + beqlr + cmplwi r4, 6 #1up + beqlr + # neither of those succeeded + crclr 4*cr0+eq + blr + + + +.global TryToGiveMarioHammerSuit +TryToGiveMarioHammerSuit: + stwu sp, -0x10(sp) + mflr r0 + stw r0, 0x14(sp) + + # check the obtained item number + cmplwi r3, 5 + bne IsntGettingHammerSuit + + # check the current player powerup + cmplwi r4, 7 + bne DontHaveHammerSuit + + li r28, 0 + li r29, 2 + b ReturnFromTTGMHS + +DontHaveHammerSuit: + mr r3, r30 + li r4, 7 + bl dAcPy_c__ChangePowerupWithAnimation + + cmpwi r3, 0 + beq ReturnFromTTGMHS + + li r29, 1 + +IsntGettingHammerSuit: +ReturnFromTTGMHS: + # end of function + lwz r0, 0x14(sp) + mtlr r0 + addi sp, sp, 0x10 + + # leftover instruction from what we replaced to add the bl + cmpwi r29, 0 + blr + + + +.global ThrowHammer +ThrowHammer: + # continues on from PlayerProjectileShooting + + # get powerup + lwz r3, 0x1090(r30) + cmplwi r3, 7 + bne ReturnFromThrowHammer + + mr r3, r30 + li r4, 498 + li r5, 0 + bl PlayPlayerSound + + li r3, 0x73 # Hammer + li r4, 0 # Settings + addi r5, sp, 0x2C # Position + li r6, 0 # Rotation + lbz r7, 0x38F(r30) # Layer + bl CreateActor + + # Store player ID + lwz r4, 0(r30) + stw r4, 0x450(r3) + + # store player number, but add 0x100 to differentiate it from 0 + lbz r4, 0x38D(r30) + addi r4, r4, 0x100 + stw r4, 0x458(r3) + + # Fix scale + lis r4, OneFloat@h + ori r4, r4, OneFloat@l + lfs f0, 0(r4) + stfs f0, 0xDC(r3) + stfs f0, 0xE0(r3) + stfs f0, 0xE4(r3) + + mr r4, r30 + lwz r12, 0x60(r3) + lwz r12, 0x8C(r12) + mtctr r12 + bctrl + +ReturnFromThrowHammer: + lwz r0, 0xC4(sp) + psq_l f31, 0xB8(sp), 1, 0 + lfd f31, 0xB0(sp) + psq_l f30, 0xA8(sp), 1, 0 + lfd f30, 0xA0(sp) + lwz r31, 0x9C(sp) + lwz r30, 0x98(sp) + mtlr r0 + addi sp, sp, 0xC0 + blr + + + +.global MoreProjectileStuff_Fix +MoreProjectileStuff_Fix: + lwz r3, 0x1090(r31) + cmplwi r3, 7 + bne ReturnFromMPSFix + + mr r3, r31 + li r4, 1 + bl PlayerProjectileShooting + +ReturnFromMPSFix: + lwz r0, 0x14(sp) + lwz r31, 0xC(sp) + mtlr r0 + addi sp, sp, 0x10 + blr + + + +.global ProjectileShootCheck_Fix +ProjectileShootCheck_Fix: + lwz r3, 0x1090(r31) + cmplwi r3, 7 + bne Return0fromPSCFix + + lbz r3, 0x38D(r31) + li r4, 0 + extsb r3, r3 + bl CheckHammerLimit + + cmpwi r3, 0 + beq Return0fromPSCFix + + b Return1fromPSCFix + +Return0fromPSCFix: + li r3, 0 + b ReturnFromPSCFix + +Return1fromPSCFix: + li r3, 1 + +ReturnFromPSCFix: + lwz r0, 0x14(sp) + lwz r31, 0xC(sp) + mtlr r0 + addi sp, sp, 0x10 + blr + + +.global CheckHammerLimit +CheckHammerLimit: + stwu sp, -0x10(sp) + mflr r0 + stw r0, 0x14(sp) + stw r31, 0xC(sp) + stw r30, 0x8(sp) + + # r30 = player number + mr r30, r3 + addi r30, r30, 0x100 + + # r31 = hammer count so far + li r31, 0 + + # search for every Hammer + + li r3, 0 + b startOrContinueLoop +loop: + + lwz r4, 0x458(r3) + cmpw r4, r30 + bne startOrContinueLoop + + addi r31, r31, 1 + +startOrContinueLoop: + mr r4, r3 + li r3, 0x73 + bl Actor_SearchByName + + cmpwi r3, 0 + bne loop + + # now if the current count is >= 2, return 0 + # otherwise return 1 + cmpwi r31, 2 + bge tooManyHammers + + li r3, 1 + b gotHammerStatus + +tooManyHammers: + li r3, 0 + +gotHammerStatus: + lwz r0, 0x14(sp) + lwz r31, 0xC(sp) + lwz r30, 0x8(sp) + mtlr r0 + addi sp, sp, 0x10 + blr + + + + + + +.data + +SomeTable: + .long SomeTable_802F5580 + .long SomeTable_802F56C0 + .long SomeTable_802F56C0 + .long SomeTable_802F5440 + .long SomeTable_802F56C0 + .long SomeTable_802F56C0 + .long SomeTable_802F56C0 + .long SomeTable_802F56C0 + +ZeroFloat: + .float 0.0 + +OneFloat: + .float 1.0 + +FukidashiTable2: + .float 20.0, 32.0, 32.0, 12.0, 38.0, 33.0, 32.0, 32.0 + .float 20.0, 34.0, 34.0, 12.0, 39.0, 35.0, 34.0, 34.0 + .float 20.0, 29.0, 29.0, 11.0, 34.0, 29.0, 29.0, 29.0 + .float 20.0, 29.0, 29.0, 11.0, 34.0, 29.0, 29.0, 29.0 + +PlayerHeightsNormal: + .float 16.0, 27.0, 27.0, 12.0, 27.0, 27.0, 27.0, 27.0 + +PlayerHeightsDucking: + .float 13.0, 21.0, 21.0, 9.0, 21.0, 21.0, 21.0, 21.0 + +WtfEverTable: + .float 4.5, 10.0, 10.0, 1.0, 10.0, 9.0, 10.0, 10.0 + +YetAnotherTable: + .float 0.0, -4.0, -4.0, 4.0, -6.0, -2.0, -4.0, -4.0 + +WeirdScaleTable: + .float 16.0, 31.0, 31.0, 6.0, 34.0, 31.0, 31.0, 31.0 + +AsdfTable: + .byte 1, 2, 2, 0, 2, 2, 2, 2 + +BlahTableOffsets: + .long 1, 2, 2, 0, 3, 2, 2, 2 + +PowerupScaleFloats: + .long 0xDEADBEEF, 0xDEADBEEF # padding + .float 1.0 + .float 1.0 + .float 1.0 + .float 0.6 + .float 1.0 + .float 1.0 + .float 1.0 + .float 1.0 + +PowerupTextures: + .float 0.0 + .float 1.0 + .float 2.0 + .float 3.0 + +.global BrosArcFileName +BrosArcFileName: + .string "bros" + +.global I_hammerArcFilename +I_hammerArcFilename: + .string "I_hammer" + +.global I_hammerResFile +I_hammerResFile: +# .string "g3d/I_hammer.brres" + .string "g3d/I_fireflower.brres" + +.global I_hammerModelName +I_hammerModelName: +# .string "I_hammer" + .string "I_fireflower" + + +PowerupTexDebugStr: + .string "Plumber::SetPowerupTexture() called on class %p with texnum %d lr=%p\n" + +#.global BrosModelFilename +#BrosModelFilename: +# .string "g3d/bros.brres" + +#.global HammerModelName +#HammerModelName: +# .string "bros_hammer" diff --git a/src/randomcrap.S b/src/randomcrap.S index e7b6451..808009b 100644 --- a/src/randomcrap.S +++ b/src/randomcrap.S @@ -1,8 +1,8 @@ -.text
-.global HeapChangeAttempt
-HeapChangeAttempt:
- lis 4, 0x8037
- ori 4, 4, 0x7F50
- lwz 4, 0(4)
- blr
-
+.text +.global HeapChangeAttempt +HeapChangeAttempt: + lis 4, 0x8037 + ori 4, 4, 0x7F50 + lwz 4, 0(4) + blr + diff --git a/src/randtiles.cpp b/src/randtiles.cpp index c7388dd..0bc2ede 100644 --- a/src/randtiles.cpp +++ b/src/randtiles.cpp @@ -1,22 +1,22 @@ -#include "randtiles.h"
-
-u32 djb2(u8 *str) {
- u32 hash = 5381;
- int c;
-
- while (c = *str++)
- hash = ((hash << 5) + hash) + c;
-
- return hash;
-}
-
-RandTiles_Section *RandTiles_Search(void *file, u32 nameHash) {
- for (int i = 0; i < RandTiles_GetSectionCount(file); i++) {
- RandTiles_Section *sect = RandTiles_GetSection(file, i);
-
- if (sect->nameHash == nameHash)
- return sect;
- }
-
- return 0;
-}
+#include "randtiles.h" + +u32 djb2(u8 *str) { + u32 hash = 5381; + int c; + + while (c = *str++) + hash = ((hash << 5) + hash) + c; + + return hash; +} + +RandTiles_Section *RandTiles_Search(void *file, u32 nameHash) { + for (int i = 0; i < RandTiles_GetSectionCount(file); i++) { + RandTiles_Section *sect = RandTiles_GetSection(file, i); + + if (sect->nameHash == nameHash) + return sect; + } + + return 0; +} diff --git a/src/randtiles.h b/src/randtiles.h index ab2553d..14355da 100644 --- a/src/randtiles.h +++ b/src/randtiles.h @@ -1,63 +1,63 @@ -#ifndef __NEWER_RANDTILES_H
-#define __NEWER_RANDTILES_H
-
-#include <common.h>
-#include "fileload.h"
-
-#define RAND_CHECK_HORZ
-#define RAND_CHECK_VERT
-#define RAND_CHECK_BOTH
-
-struct RandTiles_Header {
- u32 magic;
- u32 sectionCount;
-};
-
-struct RandTiles_Section {
- u32 nameHash;
- u32 entryCount;
-};
-
-struct RandTiles_Entry {
- u16 startTile;
- u16 endTile;
- u8 count;
- u8 type;
- u16 reserved;
- u32 dataOffset;
-};
-
-inline u32 RandTiles_GetSectionCount(void *file) {
- return ((RandTiles_Header*)file)->sectionCount;
-}
-
-inline u32 *RandTiles_GetOffsets(void *file) {
- return (u32*)(((RandTiles_Header*)file)+1);
-}
-
-inline RandTiles_Section *RandTiles_GetSection(void *file, int id) {
- u32 offs = RandTiles_GetOffsets(file)[id];
- return (RandTiles_Section*)(((char*)file)+offs);
-};
-
-inline RandTiles_Entry *RandTiles_GetTiles(void *file, RandTiles_Section *section) {
- return (RandTiles_Entry*)(section+1);
-}
-
-inline RandTiles_Entry *RandTiles_GetTiles(void *file, int sectionID) {
- return (RandTiles_Entry*)(RandTiles_GetSection(file, sectionID)+1);
-}
-
-inline char *RandTiles_GetName(void *file, RandTiles_Section *section) {
- return ((char*)file)+section->nameOffset;
-}
-
-inline u16 *RandTiles_GetData(void *file, RandTiles_Entry *entry) {
- return (u16*)(((char*)file)+entry->dataOffset);
-}
-
-u32 djb2(u8 *str);
-RandTiles_Section *RandTiles_Search(void *file, u32 nameHash);
-
-
-#endif
+#ifndef __NEWER_RANDTILES_H +#define __NEWER_RANDTILES_H + +#include <common.h> +#include "fileload.h" + +#define RAND_CHECK_HORZ +#define RAND_CHECK_VERT +#define RAND_CHECK_BOTH + +struct RandTiles_Header { + u32 magic; + u32 sectionCount; +}; + +struct RandTiles_Section { + u32 nameHash; + u32 entryCount; +}; + +struct RandTiles_Entry { + u16 startTile; + u16 endTile; + u8 count; + u8 type; + u16 reserved; + u32 dataOffset; +}; + +inline u32 RandTiles_GetSectionCount(void *file) { + return ((RandTiles_Header*)file)->sectionCount; +} + +inline u32 *RandTiles_GetOffsets(void *file) { + return (u32*)(((RandTiles_Header*)file)+1); +} + +inline RandTiles_Section *RandTiles_GetSection(void *file, int id) { + u32 offs = RandTiles_GetOffsets(file)[id]; + return (RandTiles_Section*)(((char*)file)+offs); +}; + +inline RandTiles_Entry *RandTiles_GetTiles(void *file, RandTiles_Section *section) { + return (RandTiles_Entry*)(section+1); +} + +inline RandTiles_Entry *RandTiles_GetTiles(void *file, int sectionID) { + return (RandTiles_Entry*)(RandTiles_GetSection(file, sectionID)+1); +} + +inline char *RandTiles_GetName(void *file, RandTiles_Section *section) { + return ((char*)file)+section->nameOffset; +} + +inline u16 *RandTiles_GetData(void *file, RandTiles_Entry *entry) { + return (u16*)(((char*)file)+entry->dataOffset); +} + +u32 djb2(u8 *str); +RandTiles_Section *RandTiles_Search(void *file, u32 nameHash); + + +#endif diff --git a/src/spritespawner.cpp b/src/spritespawner.cpp index 1d6a071..5335dfe 100755 --- a/src/spritespawner.cpp +++ b/src/spritespawner.cpp @@ -1,74 +1,74 @@ -#include <common.h>
-#include <game.h>
-
-struct SpriteSpawner {
- u32 id; // 0x00
- u32 settings; // 0x04
- u16 name; // 0x08
- u8 _0A[6]; // 0x0A
- u8 _10[0x9C]; // 0x10
- float x; // 0xAC
- float y; // 0xB0
- float z; // 0xB4
- u8 _B8[0x318]; // 0xB8
- // Any variables you add to the class go here; starting at offset 0x3D0
- u64 eventFlag; // 0x3D0
- u16 type; // 0x3D4
- u32 inheritSet; // 0x3D6
+#include <common.h> +#include <game.h> + +struct SpriteSpawner { + u32 id; // 0x00 + u32 settings; // 0x04 + u16 name; // 0x08 + u8 _0A[6]; // 0x0A + u8 _10[0x9C]; // 0x10 + float x; // 0xAC + float y; // 0xB0 + float z; // 0xB4 + u8 _B8[0x318]; // 0xB8 + // Any variables you add to the class go here; starting at offset 0x3D0 + u64 eventFlag; // 0x3D0 + u16 type; // 0x3D4 + u32 inheritSet; // 0x3D6 u8 lastEvState; // 0x3DA - u32 createdActor;
-};
-
-struct EventTable_t {
- u64 events;
-};
- - -struct VEC {
- float x;
- float y;
- float z;
-};
- -
-extern EventTable_t *EventTable;
+ u32 createdActor; +}; + +struct EventTable_t { + u64 events; +}; + + +struct VEC { + float x; + float y; + float z; +}; + + +extern EventTable_t *EventTable; extern "C" dStageActor_c *CreateActor(u16 classID, int settings, VEC pos, char rot, char layer); extern "C" dStageActor_c *Actor_SearchByID(u32 actorID); -void SpriteSpawner_Update(SpriteSpawner *self);
- -#define ACTIVATE 1
-#define DEACTIVATE 0
-
- - -
-bool SpriteSpawner_Create(SpriteSpawner *self) {
- OSReport("I exist, dammit!");
- - char eventNum = (self->settings >> 28) & 0xF;
- OSReport("Event to activate: %d", eventNum);
- - self->eventFlag = (u64)1 << (eventNum - 1);
- self->createdActor = 0;
- self->type = (self->settings >> 16) & 0xFFF;
-
- short tempSet = self->settings & 0xFFFF;
- self->inheritSet = (tempSet & 3) | ((tempSet & 0xC) << 2) | ((tempSet & 0x30) << 4) | ((tempSet & 0xC0) << 6) | ((tempSet & 0x300) << 8) | ((tempSet & 0xC00) << 10) | ((tempSet & 0x3000) << 12) | ((tempSet & 0xC000) << 14);
-
- SpriteSpawner_Update(self);
-
- return true;
-}
-
-bool SpriteSpawner_Execute(SpriteSpawner *self) {
- SpriteSpawner_Update(self);
- return true;
-}
-
- -void SpriteSpawner_Update(SpriteSpawner *self) {
-
+void SpriteSpawner_Update(SpriteSpawner *self); + +#define ACTIVATE 1 +#define DEACTIVATE 0 + + + + +bool SpriteSpawner_Create(SpriteSpawner *self) { + OSReport("I exist, dammit!"); + + char eventNum = (self->settings >> 28) & 0xF; + OSReport("Event to activate: %d", eventNum); + + self->eventFlag = (u64)1 << (eventNum - 1); + self->createdActor = 0; + self->type = (self->settings >> 16) & 0xFFF; + + short tempSet = self->settings & 0xFFFF; + self->inheritSet = (tempSet & 3) | ((tempSet & 0xC) << 2) | ((tempSet & 0x30) << 4) | ((tempSet & 0xC0) << 6) | ((tempSet & 0x300) << 8) | ((tempSet & 0xC00) << 10) | ((tempSet & 0x3000) << 12) | ((tempSet & 0xC000) << 14); + + SpriteSpawner_Update(self); + + return true; +} + +bool SpriteSpawner_Execute(SpriteSpawner *self) { + SpriteSpawner_Update(self); + return true; +} + + +void SpriteSpawner_Update(SpriteSpawner *self) { + if (EventTable->events & self->eventFlag) { // Put an action for when the event turns on here @@ -80,7 +80,7 @@ void SpriteSpawner_Update(SpriteSpawner *self) { pos.y = self->y; pos.z = self->z; - OSReport("Spawning Sprite: %d at %f,%f,%f\n", self->type, pos.x, pos.y, pos.z);
+ OSReport("Spawning Sprite: %d at %f,%f,%f\n", self->type, pos.x, pos.y, pos.z); dStageActor_c *spawned = CreateActor(self->type, self->inheritSet, pos, 0, 0); self->createdActor = spawned->id; @@ -99,5 +99,5 @@ void SpriteSpawner_Update(SpriteSpawner *self) { } self->createdActor = 0; } - }
+ } } diff --git a/src/spriteswapper.cpp b/src/spriteswapper.cpp new file mode 100755 index 0000000..cbff99f --- /dev/null +++ b/src/spriteswapper.cpp @@ -0,0 +1,144 @@ +#include <common.h> +#include <game.h> + +struct SpriteSwapper { + u32 id; // 0x00 + u32 settings; // 0x04 + u16 name; // 0x08 + u8 _0A[6]; // 0x0A + u8 _10[0x9C]; // 0x10 + float x; // 0xAC + float y; // 0xB0 + float z; // 0xB4 + u8 _B8[0x318]; // 0xB8 + // Any variables you add to the class go here; starting at offset 0x3D0 + u64 eventFlag; // 0x3D0 + u16 firstType; // 0x3D4 + u16 secondType; // 0x3D4 + u8 lastEvState; // 0x3DA + u32 firstActor; + u32 secondActor; +}; + +struct EventTable_t { + u64 events; +}; + + +struct VEC { + float x; + float y; + float z; +}; + + +extern EventTable_t *EventTable; +extern "C" dStageActor_c *CreateActor(u16 classID, int settings, VEC pos, char rot, char layer); +extern "C" dStageActor_c *Actor_SearchByID(u32 actorID); + +void SpriteSwapper_Update(SpriteSwapper *self); + +#define ACTIVATE 1 +#define DEACTIVATE 0 + + + + +bool SpriteSwapper_Create(SpriteSwapper *self) { + OSReport("I exist, dammit!"); + + char eventNum = (self->settings >> 28) & 0xF; + OSReport("Event to activate: %d", eventNum); + + self->eventFlag = (u64)1 << (eventNum - 1); + self->firstActor = 0; + self->secondActor = 0; + self->firstType = (self->settings >> 16) & 0xFFF; + self->secondType = self->settings & 0xFFF; + + VEC pos; + pos.x = self->x; + pos.y = self->y; + pos.z = self->z; + + OSReport("Spawning first sprite."); + + dStageActor_c *spawned = CreateActor(self->firstType, 0, pos, 0, 0); + self->firstActor = spawned->id; + + OSReport("Spawned %d.", self->firstActor); + + SpriteSwapper_Update(self); + + return true; +} + +bool SpriteSwapper_Execute(SpriteSwapper *self) { + SpriteSwapper_Update(self); + return true; +} + + +void SpriteSwapper_Update(SpriteSwapper *self) { + + if (EventTable->events & self->eventFlag) + { + // Put an action for when the event turns on here + OSReport("Event turned on."); + + if (self->firstActor != 0) + { + OSReport("Found the first sprite."); + + dStageActor_c *spawned = Actor_SearchByID(self->firstActor); + if (spawned != 0) { + OSReport("It's still alive."); + self->x = spawned->pos.x; + self->y = spawned->pos.y; + self->z = spawned->pos.z; + spawned->Delete(); + } + self->firstActor = 0; + OSReport("Now it's deleted."); + + VEC pos; + pos.x = self->x; + pos.y = self->y; + pos.z = self->z; + + OSReport("Making second sprite."); + dStageActor_c *spawner = CreateActor(self->secondType, 0, pos, 0, 0); + self->secondActor = spawner->id; + OSReport("Spawned %d.", self->secondActor); + } +// EventTable->events = EventTable->events & ~self->eventFlag; + } + else + { + OSReport("Event turned off."); + if (self->secondActor != 0) + { + OSReport("Found the second sprite."); + dStageActor_c *spawned = Actor_SearchByID(self->secondActor); + if (spawned != 0) { + OSReport("It's still alive."); + self->x = spawned->pos.x; + self->y = spawned->pos.y; + self->z = spawned->pos.z; + spawned->Delete(); + } + self->secondActor = 0; + OSReport("Now it's deleted."); + + VEC pos; + pos.x = self->x; + pos.y = self->y; + pos.z = self->z; + + OSReport("Making first sprite again."); + dStageActor_c *spawner = CreateActor(self->firstType, 0, pos, 0, 0); + self->firstActor = spawner->id; + OSReport("Spawned %d.", self->firstActor); + } + } +} diff --git a/src/spritetex.S b/src/spritetex.S index c636943..75e0256 100755 --- a/src/spritetex.S +++ b/src/spritetex.S @@ -1,869 +1,869 @@ -.extern sprintf
-.extern GenerateRandomNumber
-
-#ifndef __MWERKS__
-.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4
-.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
-.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
-.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
-.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
-.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
-.set r30,30; .set r31,31; .set f0,0; .set f2,2; .set f3,3
-#endif
-
-.text
-.align 4
-.global GetTexFilenameForR5, TexFilenameBuffer, TexFormatString
-
-.set sp, 1
-
-GetTexFilenameForR5:
- # obj number should be put into r5
- # returned filename is in r5
- # this makes it easy to use with dRes_c::GetResource
-
- stwu sp, -0x20(sp)
- mflr r0
- stw r0, 0x24(sp)
- stw r3, 0x1C(sp)
- stw r4, 0x18(sp)
- stw r6, 0x14(sp)
- stw r7, 0x10(sp)
- stw r8, 0xC(sp)
- stw r9, 0x8(sp)
-
- lis r3, TexFilenameBuffer@h
- ori r3, r3, TexFilenameBuffer@l
-
- lis r4, TexFormatString@h
- ori r4, r4, TexFormatString@l
-
- crclr 4*cr1+eq
- bl sprintf
-
- lis r5, TexFilenameBuffer@h
- ori r5, r5, TexFilenameBuffer@l
-
- lwz r0, 0x24(sp)
- lwz r3, 0x1C(sp)
- lwz r4, 0x18(sp)
- lwz r6, 0x14(sp)
- lwz r7, 0x10(sp)
- lwz r8, 0xC(sp)
- lwz r9, 0x8(sp)
- mtlr r0
- addi sp, sp, 0x20
- blr
-
-
-.global TEX_YoshiEggSetColour
-TEX_YoshiEggSetColour:
-
- stwu sp, -0x30(sp)
- mflr r0
- stw r0, 0x24(sp)
- mr r9, r3
- stw r4, 0x18(sp)
- stw r5, 0x14(sp)
- stw r6, 0x10(sp)
- stw r7, 0x0C(sp)
-
- li r3, 10
- bl GenerateRandomNumber
- stw r3, 0x5F8(r9)
-
- lwz r0, 0x24(sp)
- mr r3, r9
- lwz r4, 0x18(sp)
- lwz r5, 0x14(sp)
- lwz r6, 0x10(sp)
- lwz r7, 0x0C(sp)
- mtlr r0
- addi sp, sp, 0x30
- blr
-
-
-.global TEX_YoshiEggSetBrres
-TEX_YoshiEggSetBrres:
-
- lwz r5, 0x5F8(r27)
- clrlwi r5, r5, 28
-
- cmpwi r5, 4
- blt YoshiEggOne
-
- cmpwi r5, 8
- blt YoshiEggTwo
-
- li r5, 2
- b GetTexFilenameForR5
-
-
-YoshiEggOne:
- li r5, 0
- b GetTexFilenameForR5
-
-YoshiEggTwo:
- li r5, 1
- b GetTexFilenameForR5
-
-
-
-.global TEX_YoshiEggSetFrame
-TEX_YoshiEggSetFrame:
-
- lwz r5, 0x5F8(r27)
- clrlwi r5, r5, 30
- blr
-
-
-.global TEX_YoshiEggEffect
-TEX_YoshiEggEffect:
-
- lwz r0, 0x5F8(r3)
- clrlwi r0, r0, 30
- blr
-
-
-.global TEX_YoshiSetColour
-TEX_YoshiSetColour:
-
- lwz r4, 0x5F8(r31)
- oris r4, r4, 1
- blr
-
-
-.global TEX_YoshiHack
-TEX_YoshiHack:
-
- stwu sp, -0x30(sp)
- mflr r0
- stw r0, 0x24(sp)
- stw r3, 0x1C(sp)
- stw r4, 0x18(sp)
- stw r5, 0x14(sp)
- stw r6, 0x10(sp)
- stw r7, 0x0C(sp)
- stw r8, 0x08(sp)
- stw r9, 0x04(sp)
-
- lwz r5, 0x24C(r31)
- clrlwi r5, r5, 28
-
- lis r3, TexFilenameBuffer@h
- ori r3, r3, TexFilenameBuffer@l
-
- lis r4, TexFormatString@h
- ori r4, r4, TexFormatString@l
-
- crclr 4*cr1+eq
- bl sprintf
-
- lis r5, TexFilenameBuffer@h
- ori r5, r5, TexFilenameBuffer@l
-
- lis r4, YoshiArc@h
- ori r4, r4, YoshiArc@l
-
- lwz r0, 0x24(sp)
- lwz r3, 0x1C(sp)
- lwz r6, 0x10(sp)
- lwz r7, 0x0C(sp)
- lwz r8, 0x08(sp)
- lwz r9, 0x04(sp)
- mtlr r0
- addi sp, sp, 0x30
- blr
-
-
-
-
-.global TEX_WoodBox
-TEX_WoodBox:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- b GetTexFilenameForR5
-
-
-.global TEX_Bush
-TEX_Bush:
- srwi r5, r27, 28
- b GetTexFilenameForR5
-
-
-# The below was added by Tempus
-
-
-.global TEX_Goomba
-TEX_Goomba:
- lwz r5, 4(r3)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_BigGoomba
-TEX_BigGoomba:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Barrel
-TEX_Barrel:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Blooper
-TEX_Blooper:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_BigBlock
-TEX_BigBlock:
- lwz r5, 4(r28)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Thwomp
-TEX_Thwomp:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_GiantBuzzy
-TEX_GiantBuzzy:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Buzzy
-TEX_Buzzy:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-.global TEX_BuzzyShell
-TEX_BuzzyShell:
- lwz r5, 4(r3)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_SpikeTop
-TEX_SpikeTop:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Spiny
-TEX_Spiny:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_SpinyShell
-TEX_SpinyShell:
- lwz r5, 4(r3)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_SpringBlock
-TEX_SpringBlock:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Coaster
-TEX_Coaster:
- lwz r5, 4(r3)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Koopa
-TEX_Koopa:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Gabon
-TEX_Gabon:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Gabon_Spike
-TEX_Gabon_Spike:
- andis. r4, r4, 0xFFF0
- blr
-
-.global TEX_GabonRock
-TEX_GabonRock:
- lwz r5, 4(r28)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Podoboo
-TEX_Podoboo:
- lwz r5, 4(r31)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Switch
-TEX_Switch:
- lwz r5, 4(r29)
- srwi r5, r5, 16
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_WiggleShroom
-TEX_WiggleShroom:
- lwz r5, -0x520(r3)
- # This sprite is pretty complex
- # The register with THIS is r29
- # before the loading function,
- # it passes it into r3, and then mr's
- # it into r30. r3 is then overwritten.
- # Then, it puts r31 into r5, r30 partly
- # into r3 and partly into r4. Why?
- # So, the possibilities for THIS are
- # r30, r3, and r4, no? In the next function,
- # r30 is stored over before our getFile, as
- # are r29/r28.
-
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Bramball
-TEX_Bramball:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Monty
-TEX_Monty:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_ChainChomp
-TEX_ChainChomp:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Manta
-TEX_Manta:
- lwz r5, 4(r28)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Parabeetle
-TEX_Parabeetle:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Bomb
-TEX_Bomb:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_ParaBomb
-TEX_ParaBomb:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_CheepA
-TEX_CheepA:
- lwz r5, 4(r27)
- srwi r5, r5, 20
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_CheepB
-TEX_CheepB:
- lwz r5, 4(r28)
- srwi r5, r5, 20
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_CheepC
-TEX_CheepC:
- lwz r5, 4(r28)
- srwi r5, r5, 20
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_CheepChomp
-TEX_CheepChomp:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_BigBoo
-TEX_BigBoo:
- lwz r5, 4(r27)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-.global TEX_Boo
-TEX_Boo:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-.global TEX_Midway
-TEX_Midway:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xFF
- b GetTexFilenameForR5
-
-
-.global TEX_Goal
-TEX_Goal:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_StretchMush
-TEX_StretchMush:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_BlockSlide
-TEX_BlockSlide:
- lwz r5, 4(r28)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Spinner
-TEX_Spinner:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Platforms
-TEX_Platforms:
-
- li r5, 1
- b GetTexFilenameForR5
-# cmpwi r0, 9
-# blt ReplacePlatforms
-#
-# lwzx r5, r5, r0
-# blr
-
-
-ReplacePlatforms:
-
- lwz r5, 4(r29)
- srwi r5, r5, 4
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Platform_ShifterH
-TEX_Platform_ShifterH:
-
- stw r5, 0x504(r30)
- lwz r5, 4(r30)
- stw r5, 0x3D8(r30)
- blr
-
-.global TEX_Platform_ShifterF
-TEX_Platform_ShifterF:
-
- stw r4, 0x504(r30)
- lwz r4, 4(r30)
- stw r4, 0x3D8(r30)
- blr
-
-.global TEX_Platform_ShifterL
-TEX_Platform_ShifterL:
-
- stw r5, 0x504(r28)
- lwz r5, 4(r28)
- stw r5, 0x3D8(r28)
- blr
-
-.global TEX_Platform_ShifterR
-TEX_Platform_ShifterR:
-
- stw r4, 0x504(r31)
- lwz r4, 4(r31)
- stw r4, 0x3D8(r31)
- blr
-
-.global TEX_Platform_ShifterS
-TEX_Platform_ShifterS:
-
- stw r30, 0x4C4(r27)
- lwz r30, 4(r27)
- stw r30, 0x398(r27)
- blr
-
-.global TEX_Platform_ShifterK
-TEX_Platform_ShifterK:
-
- stw r4, 0x5A4(r27)
- lwz r4, 4(r27)
- stw r4, 0x478(r27)
- blr
-
-.global TEX_Platform_ShifterW
-TEX_Platform_ShifterW:
-
- stw r0, 0x504(r29)
- lwz r0, 4(r29)
- stw r0, 0x3D8(r29)
- blr
-
-.global TEX_Platform_ShifterSL
-TEX_Platform_ShifterSL:
-
- stw r4, 0x504(r29)
- lwz r4, 4(r29)
- stw r4, 0x3D8(r29)
- blr
-
-
-
-
-.global TEX_PokeyA
-TEX_PokeyA:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_PokeyB
-TEX_PokeyB:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
-
- b GetTexFilenameForR5
-
-
-.global TEX_PokeySnowman
-TEX_PokeySnowman:
-
- lwz r10, 4(r30)
- srwi r10, r10, 24
- andi. r10, r10, 0xF
-
- cmpwi r10, 0x2
- bne SnowmanPokey
-
- lwz r10, 4(r30)
- # r10 is the current height
- andi. r10, r10, 0xF
-
- # Find it
- lis r11, SnowmanTable@h
- ori r11, r11, SnowmanTable@l
- slwi r10, r10, 2 # size *= 4 (size of float)
- lfsx f0, r11, r10 # get it from the array
-
- blr
-
-
-SnowmanPokey:
-
- lfs f0, 0x54(r31)
- blr
-
-
-
-
-.global TEX_PokeySnowmanPosF
-TEX_PokeySnowmanPosF:
-
- lwz r10, 4(r31)
- andi. r10, r10, 0xF
-
- lis r11, SnowmanTable@h
- ori r11, r11, SnowmanTable@l
- slwi r10, r10, 2 # size *= 4 (size of float)
- lfsx f2, r11, r10 # get it from the array
-
- fmuls f0, f0, f2
- stfs f0, 0xB0(r30)
- blr
-
-.global TEX_PokeySnowmanPosE
-TEX_PokeySnowmanPosE:
-
- lwz r10, 4(r31)
- andi. r10, r10, 0xF
-
- lis r11, SnowmanTable@h
- ori r11, r11, SnowmanTable@l
- slwi r10, r10, 2 # size *= 4 (size of float)
- lfsx f2, r11, r10 # get it from the array
-
- fmuls f31, f31, f2
- stfs f31, 0xB0(r29)
- blr
-
-.global TEX_PokeySnowmanPosD
-TEX_PokeySnowmanPosD:
-
- lwz r10, 4(r31)
- andi. r10, r10, 0xF
-
- lis r11, SnowmanTable@h
- ori r11, r11, SnowmanTable@l
- slwi r10, r10, 2 # size *= 4 (size of float)
- lfsx f2, r11, r10 # get it from the array
-
- fmuls f1, f1, f2
- stfs f1, 0xB0(r30)
- blr
-
-
-.global TEX_PokeySnowmanPosC
-TEX_PokeySnowmanPosC:
-
- lwz r10, 4(r31)
- andi. r10, r10, 0xF
-
- lis r11, SnowmanTable@h
- ori r11, r11, SnowmanTable@l
- slwi r10, r10, 2 # size *= 4 (size of float)
- lfsx f2, r11, r10 # get it from the array
-
- fmuls f0, f0, f2
- stfs f0, 0xB0(r31)
- blr
-
-
-.global TEX_PokeySnowmanPosB
-TEX_PokeySnowmanPosB:
-
- lwz r10, 4(r31)
- andi. r10, r10, 0xF
-
- lis r11, SnowmanTable@h
- ori r11, r11, SnowmanTable@l
- slwi r10, r10, 2 # size *= 4 (size of float)
- lfsx f0, r11, r10 # get it from the array
-
- fmuls f1, f1, f0
- stfs f1, 0x18(r1)
- blr
-
-
-
-.global TEX_PokeySnowmanPosA
-TEX_PokeySnowmanPosA:
-
- lwz r10, 4(r31)
- andi. r10, r10, 0xF
-
- lis r11, SnowmanTable@h
- ori r11, r11, SnowmanTable@l
- slwi r10, r10, 2 # size *= 4 (size of float)
- lfsx f0, r11, r10 # get it from the array
-
- fmuls f3, f3, f0
- stfs f3, 0x168(r31)
- blr
-
-
-.global TEX_PokeySnowmanPos
-TEX_PokeySnowmanPos:
-
- mr r3, r30
-
- lwz r10, 4(r30)
- andi. r10, r10, 0xF
-
- lis r11, SnowmanTable@h
- ori r11, r11, SnowmanTable@l
- slwi r10, r10, 2 # size *= 4 (size of float)
- lfsx f0, r11, r10 # get it from the array
-
- lis r5, AddAmount@h
- ori r5, r5, AddAmount@l
- slwi r6, r6, 2 # size *= 4 (size of float)
- lfsx f3, r5, r6 # get it from the array
-
- lfs f2, 0xB0(r30)
- fmuls f3, f3, f0
- fmuls f3, f3, f0
- fmuls f3, f3, f0
- fsubs f2, f2, f3
- stfs f2, 0xB0(r30)
-
- blr
-
-SnowmanPokeyPos:
-
- fsubs f0, f0, f31
- fsubs f0, f0, f31
- fsubs f1, f1, f31
- fsubs f1, f1, f31
-
-
- lfs f2, 8(r1)
- fadds f2, f2, f31
- stfs f2, 8(r1)
- blr
-
-
-.global TEX_PokeyC
-TEX_PokeyC:
-
- lwz r5, 4(r30)
- andis. r5, r5, 0xFFF0
- or r5, r5, r31
- or r5, r5, r0
-
- lwz r0, 0x524(r30)
- slwi r0, r0, 8
- or r5, r5, r0
-
- blr
-
-
-.global TEX_PokeyNoSand
-TEX_PokeyNoSand:
- cmpwi r3, 0x20
- blr
-
-
-
-.global TEX_CloudBounce
-TEX_CloudBounce:
- lwz r5, 4(r28)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_SpikeBall
-TEX_SpikeBall:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Huckit
-TEX_Huckit:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_HuckitBalls
-TEX_HuckitBalls:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-
-
-
-.global HammerTime
-HammerTime:
- lwz r8, 4(r31)
+.extern sprintf +.extern GenerateRandomNumber + +#ifndef __MWERKS__ +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24 +.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29 +.set r30,30; .set r31,31; .set f0,0; .set f2,2; .set f3,3 +#endif + +.text +.align 4 +.global GetTexFilenameForR5, TexFilenameBuffer, TexFormatString + +.set sp, 1 + +GetTexFilenameForR5: + # obj number should be put into r5 + # returned filename is in r5 + # this makes it easy to use with dRes_c::GetResource + + stwu sp, -0x20(sp) + mflr r0 + stw r0, 0x24(sp) + stw r3, 0x1C(sp) + stw r4, 0x18(sp) + stw r6, 0x14(sp) + stw r7, 0x10(sp) + stw r8, 0xC(sp) + stw r9, 0x8(sp) + + lis r3, TexFilenameBuffer@h + ori r3, r3, TexFilenameBuffer@l + + lis r4, TexFormatString@h + ori r4, r4, TexFormatString@l + + crclr 4*cr1+eq + bl sprintf + + lis r5, TexFilenameBuffer@h + ori r5, r5, TexFilenameBuffer@l + + lwz r0, 0x24(sp) + lwz r3, 0x1C(sp) + lwz r4, 0x18(sp) + lwz r6, 0x14(sp) + lwz r7, 0x10(sp) + lwz r8, 0xC(sp) + lwz r9, 0x8(sp) + mtlr r0 + addi sp, sp, 0x20 + blr + + +.global TEX_YoshiEggSetColour +TEX_YoshiEggSetColour: + + stwu sp, -0x30(sp) + mflr r0 + stw r0, 0x24(sp) + mr r9, r3 + stw r4, 0x18(sp) + stw r5, 0x14(sp) + stw r6, 0x10(sp) + stw r7, 0x0C(sp) + + li r3, 10 + bl GenerateRandomNumber + stw r3, 0x5F8(r9) + + lwz r0, 0x24(sp) + mr r3, r9 + lwz r4, 0x18(sp) + lwz r5, 0x14(sp) + lwz r6, 0x10(sp) + lwz r7, 0x0C(sp) + mtlr r0 + addi sp, sp, 0x30 + blr + + +.global TEX_YoshiEggSetBrres +TEX_YoshiEggSetBrres: + + lwz r5, 0x5F8(r27) + clrlwi r5, r5, 28 + + cmpwi r5, 4 + blt YoshiEggOne + + cmpwi r5, 8 + blt YoshiEggTwo + + li r5, 2 + b GetTexFilenameForR5 + + +YoshiEggOne: + li r5, 0 + b GetTexFilenameForR5 + +YoshiEggTwo: + li r5, 1 + b GetTexFilenameForR5 + + + +.global TEX_YoshiEggSetFrame +TEX_YoshiEggSetFrame: + + lwz r5, 0x5F8(r27) + clrlwi r5, r5, 30 + blr + + +.global TEX_YoshiEggEffect +TEX_YoshiEggEffect: + + lwz r0, 0x5F8(r3) + clrlwi r0, r0, 30 + blr + + +.global TEX_YoshiSetColour +TEX_YoshiSetColour: + + lwz r4, 0x5F8(r31) + oris r4, r4, 1 + blr + + +.global TEX_YoshiHack +TEX_YoshiHack: + + stwu sp, -0x30(sp) + mflr r0 + stw r0, 0x24(sp) + stw r3, 0x1C(sp) + stw r4, 0x18(sp) + stw r5, 0x14(sp) + stw r6, 0x10(sp) + stw r7, 0x0C(sp) + stw r8, 0x08(sp) + stw r9, 0x04(sp) + + lwz r5, 0x24C(r31) + clrlwi r5, r5, 28 + + lis r3, TexFilenameBuffer@h + ori r3, r3, TexFilenameBuffer@l + + lis r4, TexFormatString@h + ori r4, r4, TexFormatString@l + + crclr 4*cr1+eq + bl sprintf + + lis r5, TexFilenameBuffer@h + ori r5, r5, TexFilenameBuffer@l + + lis r4, YoshiArc@h + ori r4, r4, YoshiArc@l + + lwz r0, 0x24(sp) + lwz r3, 0x1C(sp) + lwz r6, 0x10(sp) + lwz r7, 0x0C(sp) + lwz r8, 0x08(sp) + lwz r9, 0x04(sp) + mtlr r0 + addi sp, sp, 0x30 + blr + + + + +.global TEX_WoodBox +TEX_WoodBox: + lwz r5, 4(r30) + srwi r5, r5, 24 + b GetTexFilenameForR5 + + +.global TEX_Bush +TEX_Bush: + srwi r5, r27, 28 + b GetTexFilenameForR5 + + +# The below was added by Tempus + + +.global TEX_Goomba +TEX_Goomba: + lwz r5, 4(r3) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_BigGoomba +TEX_BigGoomba: + lwz r5, 4(r30) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Barrel +TEX_Barrel: + lwz r5, 4(r30) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Blooper +TEX_Blooper: + lwz r5, 4(r30) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_BigBlock +TEX_BigBlock: + lwz r5, 4(r28) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Thwomp +TEX_Thwomp: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_GiantBuzzy +TEX_GiantBuzzy: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Buzzy +TEX_Buzzy: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + +.global TEX_BuzzyShell +TEX_BuzzyShell: + lwz r5, 4(r3) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_SpikeTop +TEX_SpikeTop: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Spiny +TEX_Spiny: + lwz r5, 4(r30) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_SpinyShell +TEX_SpinyShell: + lwz r5, 4(r3) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_SpringBlock +TEX_SpringBlock: + lwz r5, 4(r30) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Coaster +TEX_Coaster: + lwz r5, 4(r3) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Koopa +TEX_Koopa: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Gabon +TEX_Gabon: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Gabon_Spike +TEX_Gabon_Spike: + andis. r4, r4, 0xFFF0 + blr + +.global TEX_GabonRock +TEX_GabonRock: + lwz r5, 4(r28) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Podoboo +TEX_Podoboo: + lwz r5, 4(r31) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Switch +TEX_Switch: + lwz r5, 4(r29) + srwi r5, r5, 16 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_WiggleShroom +TEX_WiggleShroom: + lwz r5, -0x520(r3) + # This sprite is pretty complex + # The register with THIS is r29 + # before the loading function, + # it passes it into r3, and then mr's + # it into r30. r3 is then overwritten. + # Then, it puts r31 into r5, r30 partly + # into r3 and partly into r4. Why? + # So, the possibilities for THIS are + # r30, r3, and r4, no? In the next function, + # r30 is stored over before our getFile, as + # are r29/r28. + + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Bramball +TEX_Bramball: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Monty +TEX_Monty: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_ChainChomp +TEX_ChainChomp: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Manta +TEX_Manta: + lwz r5, 4(r28) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Parabeetle +TEX_Parabeetle: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Bomb +TEX_Bomb: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_ParaBomb +TEX_ParaBomb: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_CheepA +TEX_CheepA: + lwz r5, 4(r27) + srwi r5, r5, 20 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_CheepB +TEX_CheepB: + lwz r5, 4(r28) + srwi r5, r5, 20 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_CheepC +TEX_CheepC: + lwz r5, 4(r28) + srwi r5, r5, 20 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_CheepChomp +TEX_CheepChomp: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_BigBoo +TEX_BigBoo: + lwz r5, 4(r27) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + +.global TEX_Boo +TEX_Boo: + lwz r5, 4(r30) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + +.global TEX_Midway +TEX_Midway: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xFF + b GetTexFilenameForR5 + + +.global TEX_Goal +TEX_Goal: + lwz r5, 4(r30) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_StretchMush +TEX_StretchMush: + lwz r5, 4(r30) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_BlockSlide +TEX_BlockSlide: + lwz r5, 4(r28) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Spinner +TEX_Spinner: + lwz r5, 4(r30) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Platforms +TEX_Platforms: + + li r5, 1 + b GetTexFilenameForR5 +# cmpwi r0, 9 +# blt ReplacePlatforms +# +# lwzx r5, r5, r0 +# blr + + +ReplacePlatforms: + + lwz r5, 4(r29) + srwi r5, r5, 4 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Platform_ShifterH +TEX_Platform_ShifterH: + + stw r5, 0x504(r30) + lwz r5, 4(r30) + stw r5, 0x3D8(r30) + blr + +.global TEX_Platform_ShifterF +TEX_Platform_ShifterF: + + stw r4, 0x504(r30) + lwz r4, 4(r30) + stw r4, 0x3D8(r30) + blr + +.global TEX_Platform_ShifterL +TEX_Platform_ShifterL: + + stw r5, 0x504(r28) + lwz r5, 4(r28) + stw r5, 0x3D8(r28) + blr + +.global TEX_Platform_ShifterR +TEX_Platform_ShifterR: + + stw r4, 0x504(r31) + lwz r4, 4(r31) + stw r4, 0x3D8(r31) + blr + +.global TEX_Platform_ShifterS +TEX_Platform_ShifterS: + + stw r30, 0x4C4(r27) + lwz r30, 4(r27) + stw r30, 0x398(r27) + blr + +.global TEX_Platform_ShifterK +TEX_Platform_ShifterK: + + stw r4, 0x5A4(r27) + lwz r4, 4(r27) + stw r4, 0x478(r27) + blr + +.global TEX_Platform_ShifterW +TEX_Platform_ShifterW: + + stw r0, 0x504(r29) + lwz r0, 4(r29) + stw r0, 0x3D8(r29) + blr + +.global TEX_Platform_ShifterSL +TEX_Platform_ShifterSL: + + stw r4, 0x504(r29) + lwz r4, 4(r29) + stw r4, 0x3D8(r29) + blr + + + + +.global TEX_PokeyA +TEX_PokeyA: + lwz r5, 4(r30) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_PokeyB +TEX_PokeyB: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + + b GetTexFilenameForR5 + + +.global TEX_PokeySnowman +TEX_PokeySnowman: + + lwz r10, 4(r30) + srwi r10, r10, 24 + andi. r10, r10, 0xF + + cmpwi r10, 0x2 + bne SnowmanPokey + + lwz r10, 4(r30) + # r10 is the current height + andi. r10, r10, 0xF + + # Find it + lis r11, SnowmanTable@h + ori r11, r11, SnowmanTable@l + slwi r10, r10, 2 # size *= 4 (size of float) + lfsx f0, r11, r10 # get it from the array + + blr + + +SnowmanPokey: + + lfs f0, 0x54(r31) + blr + + + + +.global TEX_PokeySnowmanPosF +TEX_PokeySnowmanPosF: + + lwz r10, 4(r31) + andi. r10, r10, 0xF + + lis r11, SnowmanTable@h + ori r11, r11, SnowmanTable@l + slwi r10, r10, 2 # size *= 4 (size of float) + lfsx f2, r11, r10 # get it from the array + + fmuls f0, f0, f2 + stfs f0, 0xB0(r30) + blr + +.global TEX_PokeySnowmanPosE +TEX_PokeySnowmanPosE: + + lwz r10, 4(r31) + andi. r10, r10, 0xF + + lis r11, SnowmanTable@h + ori r11, r11, SnowmanTable@l + slwi r10, r10, 2 # size *= 4 (size of float) + lfsx f2, r11, r10 # get it from the array + + fmuls f31, f31, f2 + stfs f31, 0xB0(r29) + blr + +.global TEX_PokeySnowmanPosD +TEX_PokeySnowmanPosD: + + lwz r10, 4(r31) + andi. r10, r10, 0xF + + lis r11, SnowmanTable@h + ori r11, r11, SnowmanTable@l + slwi r10, r10, 2 # size *= 4 (size of float) + lfsx f2, r11, r10 # get it from the array + + fmuls f1, f1, f2 + stfs f1, 0xB0(r30) + blr + + +.global TEX_PokeySnowmanPosC +TEX_PokeySnowmanPosC: + + lwz r10, 4(r31) + andi. r10, r10, 0xF + + lis r11, SnowmanTable@h + ori r11, r11, SnowmanTable@l + slwi r10, r10, 2 # size *= 4 (size of float) + lfsx f2, r11, r10 # get it from the array + + fmuls f0, f0, f2 + stfs f0, 0xB0(r31) + blr + + +.global TEX_PokeySnowmanPosB +TEX_PokeySnowmanPosB: + + lwz r10, 4(r31) + andi. r10, r10, 0xF + + lis r11, SnowmanTable@h + ori r11, r11, SnowmanTable@l + slwi r10, r10, 2 # size *= 4 (size of float) + lfsx f0, r11, r10 # get it from the array + + fmuls f1, f1, f0 + stfs f1, 0x18(r1) + blr + + + +.global TEX_PokeySnowmanPosA +TEX_PokeySnowmanPosA: + + lwz r10, 4(r31) + andi. r10, r10, 0xF + + lis r11, SnowmanTable@h + ori r11, r11, SnowmanTable@l + slwi r10, r10, 2 # size *= 4 (size of float) + lfsx f0, r11, r10 # get it from the array + + fmuls f3, f3, f0 + stfs f3, 0x168(r31) + blr + + +.global TEX_PokeySnowmanPos +TEX_PokeySnowmanPos: + + mr r3, r30 + + lwz r10, 4(r30) + andi. r10, r10, 0xF + + lis r11, SnowmanTable@h + ori r11, r11, SnowmanTable@l + slwi r10, r10, 2 # size *= 4 (size of float) + lfsx f0, r11, r10 # get it from the array + + lis r5, AddAmount@h + ori r5, r5, AddAmount@l + slwi r6, r6, 2 # size *= 4 (size of float) + lfsx f3, r5, r6 # get it from the array + + lfs f2, 0xB0(r30) + fmuls f3, f3, f0 + fmuls f3, f3, f0 + fmuls f3, f3, f0 + fsubs f2, f2, f3 + stfs f2, 0xB0(r30) + + blr + +SnowmanPokeyPos: + + fsubs f0, f0, f31 + fsubs f0, f0, f31 + fsubs f1, f1, f31 + fsubs f1, f1, f31 + + + lfs f2, 8(r1) + fadds f2, f2, f31 + stfs f2, 8(r1) + blr + + +.global TEX_PokeyC +TEX_PokeyC: + + lwz r5, 4(r30) + andis. r5, r5, 0xFFF0 + or r5, r5, r31 + or r5, r5, r0 + + lwz r0, 0x524(r30) + slwi r0, r0, 8 + or r5, r5, r0 + + blr + + +.global TEX_PokeyNoSand +TEX_PokeyNoSand: + cmpwi r3, 0x20 + blr + + + +.global TEX_CloudBounce +TEX_CloudBounce: + lwz r5, 4(r28) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_SpikeBall +TEX_SpikeBall: + lwz r5, 4(r30) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Huckit +TEX_Huckit: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_HuckitBalls +TEX_HuckitBalls: + lwz r5, 4(r30) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + + + + +.global HammerTime +HammerTime: + lwz r8, 4(r31) srwi r8, r8, 8 andi. r8, r8, 0xF cmpwi r8, 1 - beq ThrowBobomb
+ beq ThrowBobomb cmpwi r8, 2 - beq ThrowGoomba
+ beq ThrowGoomba cmpwi r8, 3 - beq ThrowSpiny
+ beq ThrowSpiny cmpwi r8, 4 - beq ThrowCoin
+ beq ThrowCoin cmpwi r8, 5 - beq ThrowLemmyBall
-
- blr
-
+ beq ThrowLemmyBall + + blr + ThrowBobomb: li r3, 133 @@ -883,37 +883,37 @@ ThrowSpiny: ThrowCoin: li r3, 10 - mflr r8
+ mflr r8 mr r9, r5 - bl GenerateRandomNumber
+ bl GenerateRandomNumber mr r5, r9 - mtlr r8
- cmpwi r3, 1
- beq ThrowItem
-
+ mtlr r8 + cmpwi r3, 1 + beq ThrowItem + li r3, 0x193 li r4, 0 li r6, 0 li r7, 0 blr -
-ThrowItem:
+ +ThrowItem: li r3, 6 - mflr r8
+ mflr r8 mr r9, r5 - bl GenerateRandomNumber
+ bl GenerateRandomNumber mtlr r8 mr r5, r9 - li r4, 0
+ li r4, 0 - mr r4, r3
- li r3, 0x3C
+ mr r4, r3 + li r3, 0x3C li r6, 0 li r7, 0 - blr
-
+ blr + ThrowLemmyBall: li r3, 0x232 @@ -921,156 +921,156 @@ ThrowLemmyBall: blr -
-
-.global HammerLaunch
-HammerLaunch:
- mr r3, r30
- # r31 is the new actor currently
- # r30 is self, all others are volatile
-
- lwz r5, 4(r30)
- lwz r8, 0x348(r30)
-
- srwi r5, r5, 8
- andi. r5, r5, 0xF
-
- cmpwi r5, 0
- beqlr
-
- lis r7, LaunchAngle@h
- ori r7, r7, LaunchAngle@l
-
-# lfs f0, 0(r7)
-# stfs f0, 0xDC(r31)
-# stfs f0, 0xE0(r31)
-# stfs f0, 0xE4(r31)
-
- # Nybble 11 is for y right now
- li r6, 0
- slwi r6, r6, 2 # size *= 4 (size of float)
- lfsx f0, r7, r6 # get it from the array
-
- stfs f0, 0xEC(r31)
-
- cmpwi r5, 5
- beq LemmyLaunch
-
- li r6, 1
- slwi r6, r6, 2 # size *= 4 (size of float)
-
- cmpwi r8, 0
- bne FacingLeft
-
- # Nybble 12 is for x right now
- lfsx f0, r7, r6 # get it from the array
-
- stfs f0, 0xE8(r31)
-
- blr
-
-
-FacingLeft:
-
- lis r7, LaunchAngleLeft@h
- ori r7, r7, LaunchAngleLeft@l
-
- # Nybble 12 is for x right now
- lfsx f0, r7, r6 # get it from the array
-
- stfs f0, 0xE8(r31)
- li r7, 270
- sth r7, 0x102(r31)
-
- blr
-
-
-LemmyLaunch:
-
- li r6, 2
- slwi r6, r6, 2 # size *= 4 (size of float)
-
- cmpwi r8, 0
- bne FacingLeft
-
- # Nybble 12 is for x right now
- lfsx f0, r7, r6 # get it from the array
-
- stfs f0, 0xE8(r31)
- blr
-
-
-.global HammerSpin
-HammerSpin:
-# sth r3, 0x100(r31)
- blr
-
-
-
-
-.data
-TexFilenameBuffer:
- .long 0,0,0,0
-
-TexFormatString:
- .string "g3d/t%02d.brres"
-
-ConvertFloat:
- .word 0x43300000,0x0,0x43300000,0x80000000
-
-.align 4
-
-SnowmanTable:
- .float 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5
-
-AddAmount:
- .float 32.0
-
-LaunchAngle:
- .float 4.0, 2.5, 1.5
-
-LaunchAngleLeft:
- .float -4.0, -2.5, -1.5
-
-
-
-.align 4
-
-YoshiArc:
- .string "Y_TexGreen"
-.align 4
-
-Y_TexGreen:
- .string "Y_TexGreen"
-.align 4
-Y_TexRed:
- .string "Y_TexRed"
-.align 4
-Y_TexYellow:
- .string "Y_TexYellow"
-.align 4
-Y_TexBlue:
- .string "Y_TexBlue"
-.align 4
-Y_TexPurple:
- .string "Y_TexPurple"
-.align 4
-Y_TexOrange:
- .string "Y_TexOrange"
-.align 4
-Y_TexSkyBlue:
- .string "Y_TexSkyBlue"
-.align 4
-Y_TexBlack:
- .string "Y_TexBlack"
-.align 4
-Y_TexWhite:
- .string "Y_TexWhite"
-.align 4
-
-YoshiStrings:
- .long Y_TexGreen, Y_TexRed, Y_TexYellow, Y_TexBlue, Y_TexPurple, Y_TexOrange, Y_TexSkyBlue, Y_TexBlack, Y_TexWhite
-
-.align 4
-
-
+ + +.global HammerLaunch +HammerLaunch: + mr r3, r30 + # r31 is the new actor currently + # r30 is self, all others are volatile + + lwz r5, 4(r30) + lwz r8, 0x348(r30) + + srwi r5, r5, 8 + andi. r5, r5, 0xF + + cmpwi r5, 0 + beqlr + + lis r7, LaunchAngle@h + ori r7, r7, LaunchAngle@l + +# lfs f0, 0(r7) +# stfs f0, 0xDC(r31) +# stfs f0, 0xE0(r31) +# stfs f0, 0xE4(r31) + + # Nybble 11 is for y right now + li r6, 0 + slwi r6, r6, 2 # size *= 4 (size of float) + lfsx f0, r7, r6 # get it from the array + + stfs f0, 0xEC(r31) + + cmpwi r5, 5 + beq LemmyLaunch + + li r6, 1 + slwi r6, r6, 2 # size *= 4 (size of float) + + cmpwi r8, 0 + bne FacingLeft + + # Nybble 12 is for x right now + lfsx f0, r7, r6 # get it from the array + + stfs f0, 0xE8(r31) + + blr + + +FacingLeft: + + lis r7, LaunchAngleLeft@h + ori r7, r7, LaunchAngleLeft@l + + # Nybble 12 is for x right now + lfsx f0, r7, r6 # get it from the array + + stfs f0, 0xE8(r31) + li r7, 270 + sth r7, 0x102(r31) + + blr + + +LemmyLaunch: + + li r6, 2 + slwi r6, r6, 2 # size *= 4 (size of float) + + cmpwi r8, 0 + bne FacingLeft + + # Nybble 12 is for x right now + lfsx f0, r7, r6 # get it from the array + + stfs f0, 0xE8(r31) + blr + + +.global HammerSpin +HammerSpin: +# sth r3, 0x100(r31) + blr + + + + +.data +TexFilenameBuffer: + .long 0,0,0,0 + +TexFormatString: + .string "g3d/t%02d.brres" + +ConvertFloat: + .word 0x43300000,0x0,0x43300000,0x80000000 + +.align 4 + +SnowmanTable: + .float 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5 + +AddAmount: + .float 32.0 + +LaunchAngle: + .float 4.0, 2.5, 1.5 + +LaunchAngleLeft: + .float -4.0, -2.5, -1.5 + + + +.align 4 + +YoshiArc: + .string "Y_TexGreen" +.align 4 + +Y_TexGreen: + .string "Y_TexGreen" +.align 4 +Y_TexRed: + .string "Y_TexRed" +.align 4 +Y_TexYellow: + .string "Y_TexYellow" +.align 4 +Y_TexBlue: + .string "Y_TexBlue" +.align 4 +Y_TexPurple: + .string "Y_TexPurple" +.align 4 +Y_TexOrange: + .string "Y_TexOrange" +.align 4 +Y_TexSkyBlue: + .string "Y_TexSkyBlue" +.align 4 +Y_TexBlack: + .string "Y_TexBlack" +.align 4 +Y_TexWhite: + .string "Y_TexWhite" +.align 4 + +YoshiStrings: + .long Y_TexGreen, Y_TexRed, Y_TexYellow, Y_TexBlue, Y_TexPurple, Y_TexOrange, Y_TexSkyBlue, Y_TexBlack, Y_TexWhite + +.align 4 + + diff --git a/src/tilegod.S b/src/tilegod.S index 248b3dc..474b16c 100644 --- a/src/tilegod.S +++ b/src/tilegod.S @@ -1,65 +1,65 @@ -.text
-
-#ifndef __MWERKS__
-.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4
-.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
-.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
-.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
-.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
-.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
-.set r30,30; .set r31,31; .set f0,0; .set f2,2; .set f3,3
-#endif
-
-.align 4
-.extern ExitFromTileGodHack
-.extern TileTable
-
-.global NEW_GetTileFromTileTable
-NEW_GetTileFromTileTable:
- andi. r0, r3, 0x8000
- beq UseRegular
-
- li r4, 0x7FFF
- and r3, r3, r4
- blr
-
-UseRegular:
- lis r4, TileTable@h
- ori r4, r4, TileTable@l
-
- clrlslwi r0, r3, 16, 1
- lhzx r3, r4, r0
- blr
-
-
-.global TileGodHack
-TileGodHack:
- lwz r4, 4(r3) # Load settings
- extrwi. r0, r4, 1, 16 # Get and check the "use regular tile" flag
- extrwi r4, r4, 3, 17 # Get the tile number OR tileset number
- bne Special
-
- lis r3, TileGodTiles@h
- ori r3, r3, TileGodTiles@l
- slwi r4, r4, 1
- lhzx r25, r3, r4
-
- b ExitFromTileGodHack
-
-Special:
- lwz r3, 4(r3) # Load settings
- srwi r3, r3, 20 # Get tile number
- andi. r3, r3, 0xFF # Cut off top nybble
- slwi r4, r4, 8 # Shift tileset number
- or r3, r3, r4 # Add tileset number
- ori r25, r3, 0x8000 # Add "get regular tile" flag
-
- b ExitFromTileGodHack
-
-
-
-.data
-TileGodTiles:
- .short 0x7C, 0x02, 0x0C, 0x7B, 0x0F, 0x00
-
-
+.text + +#ifndef __MWERKS__ +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24 +.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29 +.set r30,30; .set r31,31; .set f0,0; .set f2,2; .set f3,3 +#endif + +.align 4 +.extern ExitFromTileGodHack +.extern TileTable + +.global NEW_GetTileFromTileTable +NEW_GetTileFromTileTable: + andi. r0, r3, 0x8000 + beq UseRegular + + li r4, 0x7FFF + and r3, r3, r4 + blr + +UseRegular: + lis r4, TileTable@h + ori r4, r4, TileTable@l + + clrlslwi r0, r3, 16, 1 + lhzx r3, r4, r0 + blr + + +.global TileGodHack +TileGodHack: + lwz r4, 4(r3) # Load settings + extrwi. r0, r4, 1, 16 # Get and check the "use regular tile" flag + extrwi r4, r4, 3, 17 # Get the tile number OR tileset number + bne Special + + lis r3, TileGodTiles@h + ori r3, r3, TileGodTiles@l + slwi r4, r4, 1 + lhzx r25, r3, r4 + + b ExitFromTileGodHack + +Special: + lwz r3, 4(r3) # Load settings + srwi r3, r3, 20 # Get tile number + andi. r3, r3, 0xFF # Cut off top nybble + slwi r4, r4, 8 # Shift tileset number + or r3, r3, r4 # Add tileset number + ori r25, r3, 0x8000 # Add "get regular tile" flag + + b ExitFromTileGodHack + + + +.data +TileGodTiles: + .short 0x7C, 0x02, 0x0C, 0x7B, 0x0F, 0x00 + + diff --git a/src/worldmap.cpp b/src/worldmap.cpp index d7f73d0..d650fce 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -1,1064 +1,1064 @@ -#include "worldmap.h"
-
-extern "C" void LoadMapScene();
-
-dScNewerWorldMap_c *dScNewerWorldMap_c::instance = 0;
-
-
-dScNewerWorldMap_c *dScNewerWorldMap_c::build() {
- // return new dScNewerWorldMap_c;
- OSReport("Creating WorldMap\n");
-
- void *buffer = AllocFromGameHeap1(sizeof(dScNewerWorldMap_c));
- dScNewerWorldMap_c *c = new(buffer) dScNewerWorldMap_c;
-
- OSReport("Created WorldMap @ %p\n", c);
-
- instance = c;
- return c;
-}
-
-
-#define SELC_SETUP_DONE(sc) (*((bool*)(((u32)(sc))+0xD38)))
-
-#define EASYP_SETUP_DONE(ep) (*((bool*)(((u32)(ep))+0x278)))
-#define EASYP_ACTIVE(ep) (*((bool*)(((u32)(ep))+0x279)))
-
-#define CSMENU_SETUP_DONE(csm) (*((bool*)(((u32)(csm))+0x270)))
-#define CSMENU_ACTIVE(csm) (*((bool*)(((u32)(csm))+0x271)))
-#define CSMENU_CHOICE_OK(csm) (*((bool*)(((u32)(csm))+0x272)))
-#define CSMENU_UNK(csm) (*((bool*)(((u32)(csm))+0x273)))
-#define CSMENU_CURRENT(csm) (*((int*)(((u32)(csm))+0x268)))
-
-#define YESNO_SETUP_DONE(ynw) (*((bool*)(((u32)(ynw))+0x294)))
-#define YESNO_VISIBLE(ynw) (*((bool*)(((u32)(ynw))+0x295)))
-#define YESNO_CLOSE(ynw) (*((bool*)(((u32)(ynw))+0x296)))
-#define YESNO_OPENING(ynw) (*((bool*)(((u32)(ynw))+0x297)))
-#define YESNO_REFUSED(ynw) (*((bool*)(((u32)(ynw))+0x298)))
-#define YESNO_CANCELLED(ynw) (*((bool*)(((u32)(ynw))+0x299)))
-#define YESNO_CANCELLED2(ynw) (*((bool*)(((u32)(ynw))+0x29A)))
-#define YESNO_CURRENT(ynw) (*((int*)(((u32)(ynw))+0x284)))
-#define YESNO_TYPE(ynw) (*((int*)(((u32)(ynw))+0x28C)))
-
-#define NPCHG_SETUP_DONE(npc) (*((bool*)(((u32)(npc))+0x67C)))
-#define NPCHG_ACTIVE(npc) (*((bool*)(((u32)(npc))+0x67E)))
-#define NPCHG_HIDE_FOR_EASYP(npc) (*((bool*)(((u32)(npc))+0x67F)))
-#define NPCHG_READY(npc) (*((bool*)(((u32)(npc))+0x680)))
-#define NPCHG_CCSB(npc,idx) (((void**)(((u32)(npc))+0x74))[(idx)])
-#define NPCHG_CCSC(npc,idx) (((void**)(((u32)(npc))+0x84))[(idx)])
-#define NPCHG_CCSA(npc,idx) (((void**)(((u32)(npc))+0x94))[(idx)])
-#define NPCHG_CCI(npc,idx) (((void**)(((u32)(npc))+0xA4))[(idx)])
-#define NPCHG_2DPLAYER(npc,idx) (((void**)(((u32)(npc))+0x64C))[(idx)])
-
-#define STKI_SETUP_DONE(si) (*((bool*)(((u32)(si))+0x310)))
-#define STKI_SHADOW(si) (*((void**)(((u32)(si))+0x310)))
-#define STKI_2DPLAYER(si,idx) (((void**)(((u32)(si))+0x2E4))[(idx)])
-#define STKI_ITEM(si,idx) (((void**)(((u32)(si))+0x2F4))[(idx)])
-#define STKI_SHOW(si) (*((bool*)(((u32)(si))+0x8DD)))
-
-#define SIS_SETUP_DONE(sis) (*((bool*)(((u32)(sis))+0x260)))
-
-#define CCSB_ACTIVE(ccsb) (*((bool*)(((u32)(ccsb))+0x29C)))
-
-#define CCSC_ACTIVE(ccsc) (*((bool*)(((u32)(ccsc))+0x2A1)))
-
-#define PLAYER2D_SHOW_EASY_PAIRING(p2d) (*((bool*)(((u32)(p2d))+0x264)))
-
-#define CONT_LIVES(cont,idx) (((int*)(((u32)(cont))+0x2B8))[(idx)])
-#define CONT_SETUP_DONE(cont) (*((bool*)(((u32)(cont))+0x2D4)))
-#define CONT_UNK1(cont) (*((bool*)(((u32)(cont))+0x2D5)))
-#define CONT_UNK2(cont) (*((bool*)(((u32)(cont))+0x2D6)))
-#define CONT_DONE(cont) (*((bool*)(((u32)(cont))+0x2D7)))
-#define CONT_UNK3(cont) (*((bool*)(((u32)(cont))+0x2E0)))
-
-inline u8 GetSwitchStatus() {
- return *((u8*)(((u32)GameMgr)+0x380));
-}
-
-inline void SetSwitchStatus(u8 stat) {
- *((u8*)(((u32)GameMgr)+0x380)) = stat;
-}
-
-#define STATE_START_DVD 0
-#define STATE_LOAD_RES 1
-#define STATE_END_DVD 2
-#define STATE_SETUP_WAIT 3
-#define STATE_LIMBO 4
-#define STATE_CONTINUE_WAIT 5
-#define STATE_NORMAL 6
-#define STATE_OPT_CHANGE_WAIT 7
-#define STATE_CSMENU 8
-#define STATE_TITLE_CONFIRM_OPEN_WAIT 9
-#define STATE_TITLE_CONFIRM_SELECT 10
-#define STATE_TITLE_CONFIRM_HIT_WAIT 11
-#define STATE_PLAYER_CHANGE_WAIT 12
-#define STATE_EASY_PAIRING_WAIT 13
-#define STATE_POWERUPS_WAIT 14
-#define STATE_SAVE_OPEN 15
-#define STATE_SAVE_SELECT 16
-#define STATE_SAVE_WINDOW_CLOSE 17
-#define STATE_SAVE_DO 18
-#define STATE_SAVE_END_WINDOW 19
-#define STATE_SAVE_END_CLOSE_WAIT 20
-#define STATE_QUICKSAVE_OPEN 21
-#define STATE_QUICKSAVE_SELECT 22
-#define STATE_QUICKSAVE_WINDOW_CLOSE 23
-#define STATE_QUICKSAVE_DO 24
-#define STATE_QUICKSAVE_END_WINDOW 25
-#define STATE_QUICKSAVE_END_CLOSE_WAIT 26
-#define STATE_SAVE_ERROR 27
-
-#define MENU_HEIGHT 15
-
-const char *anim1 = "optionActivated.brlan";
-const char *anim2 = "optionDeactivated.brlan";
-
-const char *group1 = "G_opt00";
-const char *group2 = "G_opt01";
-const char *group3 = "G_opt02";
-const char *group4 = "G_opt03";
-const char *group5 = "G_opt04";
-const char *group6 = "G_opt05";
-const char *group7 = "G_opt06";
-const char *group8 = "G_opt07";
-const char *group9 = "G_opt08";
-const char *group10 = "G_opt09";
-const char *group11 = "G_opt10";
-const char *group12 = "G_opt11";
-const char *group13 = "G_opt12";
-const char *group14 = "G_opt13";
-const char *group15 = "G_opt14";
-
-
-void dScNewerWorldMap_c::StartLevel() {
- LevelInfo_Entry *level = LevelInfo_GetLevels(this->levelInfo, this->currentPage);
- level += this->selections[this->currentPage];
- StartLevel(level);
-}
-
-void dScNewerWorldMap_c::StartLevel(LevelInfo_Entry *entry) {
- for (int i = 0; i < 4; i++) {
- bool isThere = QueryPlayerAvailability(i);
- int id = Player_ID[i];
- Player_Active[i] = isThere ? 1 : 0;
- if (!isThere) Player_Flags[i] = 0;
- }
-
- StartLevelInfo sl;
- sl.unk1 = 0;
- sl.unk2 = 0xFF;
- sl.unk3 = 0;
- sl.unk4 = 0;
- sl.purpose = 0;
-
- sl.world1 = entry->world;
- sl.world2 = entry->world;
- sl.level1 = entry->level;
- sl.level2 = entry->level;
-
- // hopefully this will fix the Star Coin issues
- SetSomeConditionShit(entry->world, entry->level, 2);
-
- ActivateWipe(WIPE_MARIO);
-
- DoStartLevel(GetGameMgr(), &sl);
-}
-
-void dScNewerWorldMap_c::SetTitle(const char *text) {
- unsigned short conv_buf[0x200];
- int length = strlen(text);
- if (length > 0x1FF)
- length = 0x1FF;
-
- for (int i = 0; i < length; i++) {
- conv_buf[i] = text[i];
- }
- conv_buf[length] = 0;
-
- void *textBox = EmbeddedLayout_FindTextBoxByName(this->layout, "ScreenTitle");
- TextBox_SetString(textBox, conv_buf, 0);
-}
-
-void dScNewerWorldMap_c::GenSBTitle() {
- char buf[0x100];
- sprintf(buf, "Switches: R:%s; G:%s; Y:%s; B:%s",
- ((GetSwitchStatus() & 1) != 0) ? "On" : "Off",
- ((GetSwitchStatus() & 2) != 0) ? "On" : "Off",
- ((GetSwitchStatus() & 4) != 0) ? "On" : "Off",
- ((GetSwitchStatus() & 8) != 0) ? "On" : "Off");
- this->SetTitle(buf);
-}
-
-void dScNewerWorldMap_c::GenText() {
- char buf[0x1FF];
- char paneNameBuf[0x20];
- char textBoxNameBuf[0x20];
- unsigned short wchars[0x1FF];
-
- SaveBlock *save = GetSaveFile()->GetBlock(-1);
-
- LevelInfo_Section *section = LevelInfo_GetSection(this->levelInfo, this->currentPage);
- LevelInfo_Entry *levels = LevelInfo_GetLevels(this->levelInfo, section);
-
- int count = section->levelCount;
-
- for (int i = 0; i < MENU_HEIGHT; i++) {
- sprintf(paneNameBuf, "Opt%02d", i);
- sprintf(textBoxNameBuf, "OptText%02d", i);
- void *pane = EmbeddedLayout_FindPaneByName(this->layout, paneNameBuf);
- void *textBox = EmbeddedLayout_FindTextBoxByName(this->layout, textBoxNameBuf);
-
- if (i < count) {
- // valid level
- PANE_FLAGS(pane) |= 1;
-
- u32 conds = save->GetLevelCondition(levels[i].world, levels[i].level);
-
- char cond1, cond2, cond3, cond4, cond5;
- cond1 = (conds & COND_NORMAL ? 'x' : '.');
- cond2 = (conds & COND_SECRET ? 'x' : '.');
- cond3 = (conds & COND_COIN1 ? 'x' : '.');
- cond4 = (conds & COND_COIN2 ? 'x' : '.');
- cond5 = (conds & COND_COIN3 ? 'x' : '.');
-
- sprintf(buf, "%s %c%c %c%c%c", LevelInfo_GetName(this->levelInfo, &levels[i]), cond1, cond2, cond3, cond4, cond5);
-
- for (int i = 0; i < 0x1FF; i++) {
- wchars[i] = buf[i];
- if (buf[i] == 0) break;
- }
-
- TextBox_SetString(textBox, wchars, 0);
- } else {
- // invalid, hide the pane
- PANE_FLAGS(pane) &= ~1;
- }
- }
-}
-
-int dScNewerWorldMap_c::onCreate() {
- OSReport("1:Loading scene\n");
-
- LoadMapScene();
- OSReport("2:Loading scene\n");
- GameSetup__LoadScene(0); // lol, stolen from GAME_SETUP
-
- OSReport("3:Layout alloc\n");
- this->layout = (Layout*)AllocFromGameHeap1(sizeof(Layout));
- if (!this->layout) {
- OSReport("memalloc fail\n");
- InfiniteLoop;
- }
-
- OSReport("4:Layout ctor\n");
- EmbeddedLayout_ctor(this->layout);
- OSReport("5:Layout load arc\n");
- EmbeddedLayout_LoadArc(this->layout, "NewerRes/wmap.arc");
-
- OSReport("6:Layout build\n");
- if (!EmbeddedLayout_Build(this->layout, "levelSelect.brlyt", 0)) {
- OSReport("build fail\n");
- InfiniteLoop;
- }
-
-
- OSReport("7:Layout load brlan\n");
- const char *anims[2] = {anim1, anim2};
- EmbeddedLayout_LoadBrlans(this->layout, anims, 2);
-
- const char *groups[30] = {
- group1, group2, group3, group4, group5,
- group6, group7, group8, group9, group10,
- group11, group12, group13, group14, group15,
- group1, group2, group3, group4, group5,
- group6, group7, group8, group9, group10,
- group11, group12, group13, group14, group15,
- };
-
- int mappings[30] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
- OSReport("8:Layout load group\n");
- EmbeddedLayout_LoadGroups(this->layout, groups, mappings, 30);
-
- OSReport("9:Layout reset anims\n");
- EmbeddedLayout_DisableAllAnims(this->layout);
-
- for (int i = 0; i < 15; i++) {
- EmbeddedLayout_ResetAnimToInitialState(this->layout, i, false);
- }
-
-
- OSReport("10:Item 1\n");
- this->selectCursor = CreateParentedObject(SELECT_CURSOR, this, 0, 0);
- OSReport("11:Item 2\n");
- this->csMenu = CreateParentedObject(COURSE_SELECT_MENU, this, 0, 0);
- OSReport("12:Item 3\n");
- this->yesNoWindow = CreateParentedObject(YES_NO_WINDOW, this, 0, 0);
- OSReport("13:Item 4\n");
- this->numPeopleChange = CreateParentedObject(NUMBER_OF_PEOPLE_CHANGE, this, 0, 0);
-
- for (int i = 0; i < 4; i++) {
- OSReport("14:Character change select %d\n", i);
- void *ccsb = CreateParentedObject(CHARACTER_CHANGE_SELECT_BASE, this, i, 0);
- void *ccsc = CreateParentedObject(CHARACTER_CHANGE_SELECT_CONTENTS, this, i, 0);
- void *ccsa = CreateParentedObject(CHARACTER_CHANGE_SELECT_ARROW, this, i, 0);
- void *cci = CreateParentedObject(CHARACTER_CHANGE_INDICATOR, this, i, 0);
-
- NPCHG_CCSB(this->numPeopleChange, i) = ccsb;
- NPCHG_CCSC(this->numPeopleChange, i) = ccsc;
- NPCHG_CCSA(this->numPeopleChange, i) = ccsa;
- NPCHG_CCI(this->numPeopleChange, i) = cci;
- }
-
- OSReport("15:Item 5\n");
- this->continueObj = CreateParentedObject(CONTINUE, this, 0, 0);
-
- OSReport("16:Item 6\n");
- this->stockItem = CreateParentedObject(STOCK_ITEM, this, 0, 0);
- OSReport("17:Item 7\n");
- this->stockItemShadow = CreateParentedObject(STOCK_ITEM_SHADOW, this, 0, 0);
- STKI_SHADOW(this->stockItem) = this->stockItemShadow;
-
- OSReport("18:Item 8\n");
- this->easyPairing = CreateParentedObject(EASY_PAIRING, this, 0, 0);
-
- this->state = STATE_START_DVD;
-
- this->layout->drawOrder = 0;
-
- *CurrentDrawFunc = NewerMapDrawFunc;
-
- // level info
- OSReport("19:Load level info\n");
- this->levelInfo = LoadFile(&this->levelInfoFH, "/NewerRes/LevelInfo.bin");
- OSReport("20:Prepare level info\n");
- LevelInfo_Prepare(&this->levelInfoFH);
-
- // load the menu info
- OSReport("21:Load save info\n");
- SaveBlock *save = GetSaveFile()->GetBlock(-1);
-
- this->currentPage = save->current_world;
-
- // bounds check
- if (save->current_path_node >= 15)
- save->current_path_node = 0;
-
- int sCount = LevelInfo_GetSectionCount(this->levelInfo);
- this->selections = (int*)AllocFromGameHeap1(sizeof(int) * sCount);
-
- for (int i = 0; i < sCount; i++) {
- this->selections[i] = 0;
- }
-
- this->selections[this->currentPage] = save->current_path_node;
-
- // show button anim
- OSReport("22:Enable anim\n");
- EmbeddedLayout_EnableNonLoopAnim(this->layout, save->current_path_node, false);
-
- OSReport("23:Make text\n");
- this->GenText();
- this->GenSBTitle();
-
- OSReport("24:onCreate complete\n");
- return true;
-}
-
-int dScNewerWorldMap_c::onDelete() {
- EmbeddedLayout_FreeArc(this->layout);
- EmbeddedLayout_Free(this->layout);
- EmbeddedLayout_dtor(this->layout, false);
- FreeFromGameHeap1(this->layout);
-
- FreeFromGameHeap1(this->selections);
-
- FreeFile(&this->levelInfoFH);
-
- FreeScene(0);
- FreeScene(1);
-
- DVD_FreeFile(GetDVDClass2(), "SI_kinoko");
- DVD_FreeFile(GetDVDClass2(), "SI_fireflower");
- DVD_FreeFile(GetDVDClass2(), "SI_iceflower");
- DVD_FreeFile(GetDVDClass2(), "SI_penguin");
- DVD_FreeFile(GetDVDClass2(), "SI_propeller");
- DVD_FreeFile(GetDVDClass2(), "SI_star");
-
- return true;
-}
-
-int dScNewerWorldMap_c::onExecute() {
-
- if (QueryGlobal5758(0xFFFFFFFF)) return true;
- if (CheckIfWeCantDoStuff()) return true;
-
- /**************************************************************************/
- // Read Wiimote Buttons
-
- int heldButtons = Remocon_GetButtons(GetActiveRemocon());
- int nowPressed = Remocon_GetPressed(GetActiveRemocon());
-
- /**************************************************************************/
- // State Specific
-
- switch (this->state) {
- /**********************************************************************/
- // STATE_START_DVD : Set up DVD
- case STATE_START_DVD:
-
- DVD_Start();
- this->state = STATE_LOAD_RES;
-
- break;
-
- /**********************************************************************/
- // STATE_LOAD_RES : Load extra stuff we need
- case STATE_LOAD_RES:
-
- DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_kinoko", 0);
- DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_fireflower", 0);
- DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_iceflower", 0);
- DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_penguin", 0);
- DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_propeller", 0);
- DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_star", 0);
- //DVD_LoadFile(GetDVDClass(), "Object", "fruits_kusa_gake", 0);
-
- this->state = STATE_END_DVD;
-
- break;
-
- /**********************************************************************/
- // STATE_END_DVD : Wait for files to load, end DVD
- case STATE_END_DVD:
-
- if (!DVD_StillLoading(GetDVDClass2())) {
- if (DVD_End()) {
- this->state = STATE_SETUP_WAIT;
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_SETUP_WAIT : Waiting for the world map managers to be set up
- case STATE_SETUP_WAIT: {
-
- bool success = true;
-
- success &= CSMENU_SETUP_DONE(this->csMenu);
- success &= SELC_SETUP_DONE(this->selectCursor);
- success &= NPCHG_SETUP_DONE(this->numPeopleChange);
- success &= YESNO_SETUP_DONE(this->yesNoWindow);
- success &= CONT_SETUP_DONE(this->continueObj);
- success &= STKI_SETUP_DONE(this->stockItem);
- success &= SIS_SETUP_DONE(this->stockItemShadow);
- success &= EASYP_SETUP_DONE(this->easyPairing);
-
- if (success) {
- // ok, now we can set up other required shit
-
- // first up: player models for Stocked Items
- for (int i = 0; i < 4; i++) {
- void *obj = CreateChildObject(WM_2D_PLAYER, this, i, 0, 0);
- STKI_2DPLAYER(this->stockItem,i) = obj;
- NPCHG_2DPLAYER(this->numPeopleChange,i) = obj;
- }
-
- // next: items for the Powerup screen
- for (int i = 0; i < 7; i++) {
- void *obj = CreateChildObject(WM_ITEM, this, i, 0, 0);
- STKI_ITEM(this->stockItem,i) = obj;
- }
-
- // now, check if we need to handle Continue
- if (CheckIfContinueShouldBeActivated()) {
- this->state = STATE_CONTINUE_WAIT;
- CONT_UNK1(this->continueObj) = true;
- CONT_UNK2(this->continueObj) = true;
- CONT_UNK3(this->continueObj) = false;
- } else {
- this->state = STATE_OPT_CHANGE_WAIT;
- }
- }
-
- } break;
-
- /**********************************************************************/
- // STATE_CONTINUE_WAIT : Waiting for the Continue anim to finish
- case STATE_CONTINUE_WAIT:
-
- if (CONT_DONE(this->continueObj)) {
- CONT_UNK1(this->continueObj) = 0;
- CONT_UNK2(this->continueObj) = 0;
- CONT_UNK3(this->continueObj) = 0;
-
- for (int i = 0; i < 4; i++) {
- int idx = SearchForIndexOfPlayerID(i);
- Player_Lives[Player_ID[idx]] = CONT_LIVES(this->continueObj, i);
- }
-
- this->state = STATE_OPT_CHANGE_WAIT;
- }
-
- break;
-
- /**********************************************************************/
- // STATE_NORMAL : Nothing related to the menu is going on
- case STATE_NORMAL: {
-
- int currentPage = this->currentPage;
- int currentSelection = this->selections[currentPage];
- int newPage = currentPage;
- int newSelection = currentSelection;
-
- // Activate the menu
- if (nowPressed & WPAD_PLUS) {
- CSMENU_ACTIVE(this->csMenu) = true;
- this->state = STATE_CSMENU;
- }
-
- if (nowPressed & WPAD_B) {
- SetSwitchStatus((GetSwitchStatus() + 1) & 15);
- this->GenSBTitle();
- }
-
- // Change the current level
- if ((nowPressed & WPAD_UP) && currentSelection > 0) {
- newSelection = currentSelection - 1;
- }
-
- if ((nowPressed & WPAD_DOWN) && currentSelection < (LevelInfo_GetSection(this->levelInfo, currentPage)->levelCount - 1)) {
- newSelection = currentSelection + 1;
- }
-
- // Change the current world
- if ((nowPressed & WPAD_LEFT) && currentPage > 0) {
- newPage = currentPage - 1;
- }
-
- if ((nowPressed & WPAD_RIGHT) && currentPage < (LevelInfo_GetSectionCount(this->levelInfo) - 1)) {
- newPage = currentPage + 1;
- }
-
-
- if (newPage != currentPage) {
- this->currentPage = newPage;
- this->GenText();
-
- // do this to let the rest of the code handle animations
- newSelection = this->selections[newPage];
- }
-
- if (newSelection != currentSelection) {
- EmbeddedLayout_DisableAllAnims(this->layout);
-
- // enable On animation
- EmbeddedLayout_EnableNonLoopAnim(this->layout, newSelection, false);
-
- // enable Off animation
- EmbeddedLayout_EnableNonLoopAnim(this->layout, currentSelection+15, false);
-
- this->selections[newPage] = newSelection;
- this->state = STATE_OPT_CHANGE_WAIT;
- }
-
-
- // save the info to the file
- if (currentSelection != newSelection || currentPage != newPage) {
- SaveBlock *save = GetSaveFile()->GetBlock(-1);
- save->current_world = newPage;
- save->current_path_node = newSelection;
- }
-
-
- // Enter the current level
- if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) {
- this->StartLevel();
- this->state = STATE_LIMBO; // just in case
- }
-
- if (nowPressed & WPAD_ONE) {
- STKI_SHOW(this->stockItem) = true;
- this->state = STATE_POWERUPS_WAIT;
- }
- } break;
-
- /**********************************************************************/
- // STATE_OPT_CHANGE_WAIT : Waiting for the option change animation to
- // finish playing
- case STATE_OPT_CHANGE_WAIT:
-
- if (!EmbeddedLayout_CheckIfAnimationIsOn(this->layout, -1)) {
- this->state = STATE_NORMAL;
- }
-
- break;
- /**********************************************************************/
- // STATE_CSMENU : The course select menu is currently being shown
- case STATE_CSMENU:
-
- // First off, check to see if it's been hidden
- if (!CSMENU_ACTIVE(this->csMenu)) {
- // That means something happened
- if (CSMENU_CHOICE_OK(this->csMenu)) {
- // Player pressed a button
-
- switch (CSMENU_CURRENT(this->csMenu)) {
- case 0:
- // Star Coins
- //OSReport("Star Coins was pressed\n");
- this->state = STATE_NORMAL;
- break;
-
- case 1:
- // Add/Drop Players
- //OSReport("Add/Drop Players was pressed\n");
- this->state = STATE_PLAYER_CHANGE_WAIT;
- NPCHG_ACTIVE(this->numPeopleChange) = true;
- WpadShit(10);
-
- break;
-
- case 2:
- // Save or Quick Save
- //OSReport("Save or Quick Save was pressed\n");
- if (GetSaveFile()->GetBlock(-1)->bitfield & 2) {
- this->state = STATE_SAVE_OPEN;
- YESNO_TYPE(this->yesNoWindow) = 1;
- YESNO_VISIBLE(this->yesNoWindow) = 1;
-
- } else {
- this->state = STATE_QUICKSAVE_OPEN;
- YESNO_TYPE(this->yesNoWindow) = 15;
- YESNO_VISIBLE(this->yesNoWindow) = 1;
-
- }
-
- break;
-
- case 3:
- // Title Screen
- //OSReport("Title Screen was pressed\n");
- this->state = STATE_TITLE_CONFIRM_OPEN_WAIT;
- YESNO_VISIBLE(this->yesNoWindow) = true;
- YESNO_TYPE(this->yesNoWindow) = 10;
- break;
- }
-
- } else {
- // Ok, change back to STATE_NORMAL
- this->state = STATE_NORMAL;
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_TITLE_CONFIRM_OPEN_WAIT : Waiting for the "Go to Title Screen"
- // YesNoWindow to finish opening
- case STATE_TITLE_CONFIRM_OPEN_WAIT:
-
- if (!YESNO_OPENING(this->yesNoWindow)) {
- this->state = STATE_TITLE_CONFIRM_SELECT;
- }
-
- break;
-
- /**********************************************************************/
- // STATE_TITLE_CONFIRM_SELECT : Let the user choose an option on the
- // "Go to Title Screen" YesNoWindow.
- case STATE_TITLE_CONFIRM_SELECT:
-
- if (nowPressed & WPAD_LEFT) {
- // Select "OK!"
- YESNO_CURRENT(this->yesNoWindow) = 1;
-
- } else if (nowPressed & WPAD_RIGHT) {
- // Select "Cancel"
- YESNO_CURRENT(this->yesNoWindow) = 0;
-
- } else if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) {
- // Pick the current option
- YESNO_CLOSE(this->yesNoWindow) = true;
- if (YESNO_CURRENT(this->yesNoWindow) != 1)
- YESNO_REFUSED(this->yesNoWindow) = true;
- this->state = STATE_TITLE_CONFIRM_HIT_WAIT;
-
- } else {
- // Cancel using B or 1
- if (CheckIfMenuShouldBeCancelledForSpecifiedWiimote(0)) {
- YESNO_CANCELLED(this->yesNoWindow) = true;
- YESNO_CURRENT(this->yesNoWindow) = true;
- this->state = STATE_TITLE_CONFIRM_HIT_WAIT;
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_TITLE_CONFIRM_HIT_WAIT : Process the user's chosen option on
- // the "Go to Title Screen" YesNoWindow. Also, wait for the
- // animation to be complete.
- case STATE_TITLE_CONFIRM_HIT_WAIT:
-
- if (!YESNO_OPENING(this->yesNoWindow)) {
- if (YESNO_CURRENT(this->yesNoWindow) == 1) {
- this->state = STATE_NORMAL;
- } else {
- this->state = STATE_LIMBO;
- StartTitleScreenStage(false, 0);
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_PLAYER_CHANGE_WAIT : Wait for the user to do something on the
- // Add/Drop Players screen.
- case STATE_PLAYER_CHANGE_WAIT:
-
- if (NPCHG_READY(this->numPeopleChange)) {
- if (nowPressed & WPAD_PLUS) {
- // activate easy pairing. FUN !!
- NPCHG_HIDE_FOR_EASYP(this->numPeopleChange) = 1;
-
- for (int i = 0; i < 4; i++) {
- void *obj = NPCHG_2DPLAYER(this->numPeopleChange, i);
- void *ccsb = NPCHG_CCSB(this->numPeopleChange, i);
- void *ccsc = NPCHG_CCSC(this->numPeopleChange, i);
-
- PLAYER2D_SHOW_EASY_PAIRING(obj) = 1;
- CCSB_ACTIVE(ccsb) = 1;
- CCSC_ACTIVE(ccsc) = 1;
- }
-
- EASYP_ACTIVE(this->easyPairing) = 1;
- this->state = STATE_EASY_PAIRING_WAIT;
- }
- } else {
- if (!NPCHG_ACTIVE(this->numPeopleChange)) {
- this->state = STATE_NORMAL;
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_EASY_PAIRING_WAIT : Wait for the user to exit Easy Pairing.
- case STATE_EASY_PAIRING_WAIT:
-
- if (!EASYP_ACTIVE(this->easyPairing)) {
- NPCHG_HIDE_FOR_EASYP(this->numPeopleChange) = 0;
-
- for (int i = 0; i < 4; i++) {
- void *obj = NPCHG_2DPLAYER(this->numPeopleChange, i);
- void *ccsb = NPCHG_CCSB(this->numPeopleChange, i);
- void *ccsc = NPCHG_CCSC(this->numPeopleChange, i);
-
- PLAYER2D_SHOW_EASY_PAIRING(obj) = 0;
- CCSB_ACTIVE(ccsb) = 0;
- CCSC_ACTIVE(ccsc) = 0;
- }
-
- this->state = STATE_PLAYER_CHANGE_WAIT;
- WpadShit(10);
- }
-
- break;
-
- /**********************************************************************/
- // STATE_POWERUPS_WAIT : Wait for the user to exit the Powerups screen.
- case STATE_POWERUPS_WAIT:
-
- if (!STKI_SHOW(this->stockItem)) {
- this->state = STATE_NORMAL;
- }
-
- break;
-
- /**********************************************************************/
- // STATE_SAVE_OPEN : Waiting for the "Save?" YesNoWindow to open
- case STATE_SAVE_OPEN:
-
- if (!YESNO_OPENING(this->yesNoWindow)) {
- this->state = STATE_SAVE_SELECT;
- }
-
- break;
-
- /**********************************************************************/
- // STATE_SAVE_SELECT : Let the user choose an option on the
- // "Save?" YesNoWindow.
- case STATE_SAVE_SELECT:
-
- if (nowPressed & WPAD_LEFT) {
- // Select "OK!"
- YESNO_CURRENT(this->yesNoWindow) = 1;
-
- } else if (nowPressed & WPAD_RIGHT) {
- // Select "Cancel"
- YESNO_CURRENT(this->yesNoWindow) = 0;
-
- } else if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) {
- // Pick the current option
- YESNO_CLOSE(this->yesNoWindow) = true;
-
- if (YESNO_CURRENT(this->yesNoWindow) != 1)
- YESNO_CANCELLED2(this->yesNoWindow) = true;
- this->state = STATE_SAVE_WINDOW_CLOSE;
-
- } else {
- // Cancel using B or 1
- if (CheckIfMenuShouldBeCancelledForSpecifiedWiimote(0)) {
- YESNO_CANCELLED(this->yesNoWindow) = true;
- YESNO_CURRENT(this->yesNoWindow) = 1;
- this->state = STATE_SAVE_WINDOW_CLOSE;
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_SAVE_WINDOW_CLOSE : Process the user's chosen option on the
- // "Save?" YesNoWindow. Also, wait for the animation to be complete.
- case STATE_SAVE_WINDOW_CLOSE:
-
- if (!YESNO_VISIBLE(this->yesNoWindow)) {
- if (YESNO_CURRENT(this->yesNoWindow) == 1) {
- this->state = STATE_NORMAL;
- } else {
- this->state = STATE_SAVE_DO;
- SaveGame(0, false);
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_SAVE_DO : Save the game.
- case STATE_SAVE_DO:
-
- if (!GetSaveFile()->CheckIfWriting()) {
- if (GetSaveHandler()->CurrentError == 0) {
- YESNO_TYPE(this->yesNoWindow) = 2;
- YESNO_VISIBLE(this->yesNoWindow) = true;
- this->state = STATE_SAVE_END_WINDOW;
- } else {
- this->state = STATE_SAVE_ERROR;
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_SAVE_END_WINDOW : Handle the Save End window.
- case STATE_SAVE_END_WINDOW:
-
- if (!YESNO_OPENING(this->yesNoWindow)) {
- if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) {
- YESNO_CLOSE(this->yesNoWindow) = true;
- this->state = STATE_SAVE_END_CLOSE_WAIT;
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_SAVE_END_CLOSE_WAIT : Wait for the Save End window to close.
- case STATE_SAVE_END_CLOSE_WAIT:
-
- if (!YESNO_OPENING(this->yesNoWindow)) {
- this->state = STATE_NORMAL;
- }
-
- break;
-
- /**********************************************************************/
- // STATE_QUICKSAVE_OPEN : Waiting for the "Save?" YesNoWindow to open
- case STATE_QUICKSAVE_OPEN:
-
- if (!YESNO_OPENING(this->yesNoWindow)) {
- this->state = STATE_QUICKSAVE_SELECT;
- }
-
- break;
-
- /**********************************************************************/
- // STATE_QUICKSAVE_SELECT : Let the user choose an option on the
- // "Save?" YesNoWindow.
- case STATE_QUICKSAVE_SELECT:
-
- if (nowPressed & WPAD_LEFT) {
- // Select "OK!"
- YESNO_CURRENT(this->yesNoWindow) = 1;
-
- } else if (nowPressed & WPAD_RIGHT) {
- // Select "Cancel"
- YESNO_CURRENT(this->yesNoWindow) = 0;
-
- } else if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) {
- // Pick the current option
- YESNO_CLOSE(this->yesNoWindow) = true;
-
- if (YESNO_CURRENT(this->yesNoWindow) != 1)
- YESNO_CANCELLED2(this->yesNoWindow) = true;
- this->state = STATE_QUICKSAVE_WINDOW_CLOSE;
-
- } else {
- // Cancel using B or 1
- if (CheckIfMenuShouldBeCancelledForSpecifiedWiimote(0)) {
- YESNO_CANCELLED(this->yesNoWindow) = true;
- YESNO_CURRENT(this->yesNoWindow) = 1;
- this->state = STATE_QUICKSAVE_WINDOW_CLOSE;
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_QUICKSAVE_WINDOW_CLOSE : Process the user's chosen option on
- // the "Save?" YesNoWindow. Also, wait for the animation to be complete
- case STATE_QUICKSAVE_WINDOW_CLOSE:
-
- if (!YESNO_VISIBLE(this->yesNoWindow)) {
- if (YESNO_CURRENT(this->yesNoWindow) == 1) {
- this->state = STATE_NORMAL;
- } else {
- this->state = STATE_QUICKSAVE_DO;
- SaveGame(0, true);
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_QUICKSAVE_DO : Save the game.
- case STATE_QUICKSAVE_DO:
-
- if (!GetSaveFile()->CheckIfWriting()) {
- if (GetSaveHandler()->CurrentError == 0) {
- YESNO_TYPE(this->yesNoWindow) = 16;
- YESNO_VISIBLE(this->yesNoWindow) = true;
- this->state = STATE_QUICKSAVE_END_WINDOW;
- } else {
- this->state = STATE_SAVE_ERROR;
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_QUICKSAVE_END_WINDOW : Handle the Save End window.
- case STATE_QUICKSAVE_END_WINDOW:
-
- if (!YESNO_OPENING(this->yesNoWindow)) {
- if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) {
- YESNO_CLOSE(this->yesNoWindow) = true;
- YESNO_REFUSED(this->yesNoWindow) = true;
- this->state = STATE_QUICKSAVE_END_CLOSE_WAIT;
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_QUICKSAVE_END_CLOSE_WAIT : Wait for Save End window to close
- case STATE_QUICKSAVE_END_CLOSE_WAIT:
-
- if (!YESNO_OPENING(this->yesNoWindow)) {
- if (YESNO_CURRENT(this->yesNoWindow) == 1) {
- this->state = STATE_NORMAL;
- } else {
- this->state = STATE_LIMBO;
- StartTitleScreenStage(false, 0);
- }
- }
-
- break;
-
- }
-
- if (this->state >= STATE_NORMAL) {
- EmbeddedLayout_Process(this->layout);
- EmbeddedLayout_UpdateMatrix(this->layout);
- }
-
- return true;
-}
-
-int dScNewerWorldMap_c::onDraw() {
- EmbeddedLayout_AddToDrawList(this->layout);
-
- return true;
-}
-
-
-
-void NewerMapDrawFunc() {
- int keepCamera = GetCurrentCameraID();
-
- // All drawing uses scene 1, since that's the only one loaded by GAME_SETUP.
- // Todo: Newer-specific scenes?
-
- // Stage 1
- SetupLYTDrawing();
- DrawAllLayoutsBeforeX(129);
- GXDrawDone(); // is all GXDrawDone really needed..?
-
- // Stage 2
- Reset3DState();
- SetCurrentCameraID(0);
- LinkScene(0);
- SceneCalcWorld(0);
- SceneCameraStuff(0);
- ChangeAlphaUpdate(false);
- CalcMaterial();
- DrawOpa();
- DrawXlu();
- UnlinkScene(0);
- GXDrawDone();
-
- //Reset3DState();
- //T3D::DrawQueue();
-
- // Stage 3
- Reset3DState();
- SetupLYTDrawing();
- DrawAllLayoutsAfterXandBeforeY(128, 146);
- GXDrawDone();
-
- // Stage 4
- RemoveAllFromScnRoot();
- Reset3DState();
- SetCurrentCameraID(1);
-
- DoSpecialDrawing1();
- LinkScene(1);
- SceneCalcWorld(1);
- SceneCameraStuff(1);
- CalcMaterial();
- DrawOpa();
- DrawXlu();
-
- // Stage 5
- if (GAMEMGR_GET_AFC(GameMgr)) {
- for (int i = 0; i < 4; i++) {
- RenderEffects(0, 11+i);
- }
-
- for (int i = 0; i < 4; i++) {
- RenderEffects(0, 7+i);
- }
- }
-
- RenderEffects(0, 2); // need to investigate how this thing works
-
- DrawAllLayoutsAfterX(145);
- ClearLayoutDrawList(); // this is REALLY IMPORTANT!
-
- UnlinkScene(1);
-
- // End
- SetCurrentCameraID(0);
-}
-
+#include "worldmap.h" + +extern "C" void LoadMapScene(); + +dScNewerWorldMap_c *dScNewerWorldMap_c::instance = 0; + + +dScNewerWorldMap_c *dScNewerWorldMap_c::build() { + // return new dScNewerWorldMap_c; + OSReport("Creating WorldMap\n"); + + void *buffer = AllocFromGameHeap1(sizeof(dScNewerWorldMap_c)); + dScNewerWorldMap_c *c = new(buffer) dScNewerWorldMap_c; + + OSReport("Created WorldMap @ %p\n", c); + + instance = c; + return c; +} + + +#define SELC_SETUP_DONE(sc) (*((bool*)(((u32)(sc))+0xD38))) + +#define EASYP_SETUP_DONE(ep) (*((bool*)(((u32)(ep))+0x278))) +#define EASYP_ACTIVE(ep) (*((bool*)(((u32)(ep))+0x279))) + +#define CSMENU_SETUP_DONE(csm) (*((bool*)(((u32)(csm))+0x270))) +#define CSMENU_ACTIVE(csm) (*((bool*)(((u32)(csm))+0x271))) +#define CSMENU_CHOICE_OK(csm) (*((bool*)(((u32)(csm))+0x272))) +#define CSMENU_UNK(csm) (*((bool*)(((u32)(csm))+0x273))) +#define CSMENU_CURRENT(csm) (*((int*)(((u32)(csm))+0x268))) + +#define YESNO_SETUP_DONE(ynw) (*((bool*)(((u32)(ynw))+0x294))) +#define YESNO_VISIBLE(ynw) (*((bool*)(((u32)(ynw))+0x295))) +#define YESNO_CLOSE(ynw) (*((bool*)(((u32)(ynw))+0x296))) +#define YESNO_OPENING(ynw) (*((bool*)(((u32)(ynw))+0x297))) +#define YESNO_REFUSED(ynw) (*((bool*)(((u32)(ynw))+0x298))) +#define YESNO_CANCELLED(ynw) (*((bool*)(((u32)(ynw))+0x299))) +#define YESNO_CANCELLED2(ynw) (*((bool*)(((u32)(ynw))+0x29A))) +#define YESNO_CURRENT(ynw) (*((int*)(((u32)(ynw))+0x284))) +#define YESNO_TYPE(ynw) (*((int*)(((u32)(ynw))+0x28C))) + +#define NPCHG_SETUP_DONE(npc) (*((bool*)(((u32)(npc))+0x67C))) +#define NPCHG_ACTIVE(npc) (*((bool*)(((u32)(npc))+0x67E))) +#define NPCHG_HIDE_FOR_EASYP(npc) (*((bool*)(((u32)(npc))+0x67F))) +#define NPCHG_READY(npc) (*((bool*)(((u32)(npc))+0x680))) +#define NPCHG_CCSB(npc,idx) (((void**)(((u32)(npc))+0x74))[(idx)]) +#define NPCHG_CCSC(npc,idx) (((void**)(((u32)(npc))+0x84))[(idx)]) +#define NPCHG_CCSA(npc,idx) (((void**)(((u32)(npc))+0x94))[(idx)]) +#define NPCHG_CCI(npc,idx) (((void**)(((u32)(npc))+0xA4))[(idx)]) +#define NPCHG_2DPLAYER(npc,idx) (((void**)(((u32)(npc))+0x64C))[(idx)]) + +#define STKI_SETUP_DONE(si) (*((bool*)(((u32)(si))+0x310))) +#define STKI_SHADOW(si) (*((void**)(((u32)(si))+0x310))) +#define STKI_2DPLAYER(si,idx) (((void**)(((u32)(si))+0x2E4))[(idx)]) +#define STKI_ITEM(si,idx) (((void**)(((u32)(si))+0x2F4))[(idx)]) +#define STKI_SHOW(si) (*((bool*)(((u32)(si))+0x8DD))) + +#define SIS_SETUP_DONE(sis) (*((bool*)(((u32)(sis))+0x260))) + +#define CCSB_ACTIVE(ccsb) (*((bool*)(((u32)(ccsb))+0x29C))) + +#define CCSC_ACTIVE(ccsc) (*((bool*)(((u32)(ccsc))+0x2A1))) + +#define PLAYER2D_SHOW_EASY_PAIRING(p2d) (*((bool*)(((u32)(p2d))+0x264))) + +#define CONT_LIVES(cont,idx) (((int*)(((u32)(cont))+0x2B8))[(idx)]) +#define CONT_SETUP_DONE(cont) (*((bool*)(((u32)(cont))+0x2D4))) +#define CONT_UNK1(cont) (*((bool*)(((u32)(cont))+0x2D5))) +#define CONT_UNK2(cont) (*((bool*)(((u32)(cont))+0x2D6))) +#define CONT_DONE(cont) (*((bool*)(((u32)(cont))+0x2D7))) +#define CONT_UNK3(cont) (*((bool*)(((u32)(cont))+0x2E0))) + +inline u8 GetSwitchStatus() { + return *((u8*)(((u32)GameMgr)+0x380)); +} + +inline void SetSwitchStatus(u8 stat) { + *((u8*)(((u32)GameMgr)+0x380)) = stat; +} + +#define STATE_START_DVD 0 +#define STATE_LOAD_RES 1 +#define STATE_END_DVD 2 +#define STATE_SETUP_WAIT 3 +#define STATE_LIMBO 4 +#define STATE_CONTINUE_WAIT 5 +#define STATE_NORMAL 6 +#define STATE_OPT_CHANGE_WAIT 7 +#define STATE_CSMENU 8 +#define STATE_TITLE_CONFIRM_OPEN_WAIT 9 +#define STATE_TITLE_CONFIRM_SELECT 10 +#define STATE_TITLE_CONFIRM_HIT_WAIT 11 +#define STATE_PLAYER_CHANGE_WAIT 12 +#define STATE_EASY_PAIRING_WAIT 13 +#define STATE_POWERUPS_WAIT 14 +#define STATE_SAVE_OPEN 15 +#define STATE_SAVE_SELECT 16 +#define STATE_SAVE_WINDOW_CLOSE 17 +#define STATE_SAVE_DO 18 +#define STATE_SAVE_END_WINDOW 19 +#define STATE_SAVE_END_CLOSE_WAIT 20 +#define STATE_QUICKSAVE_OPEN 21 +#define STATE_QUICKSAVE_SELECT 22 +#define STATE_QUICKSAVE_WINDOW_CLOSE 23 +#define STATE_QUICKSAVE_DO 24 +#define STATE_QUICKSAVE_END_WINDOW 25 +#define STATE_QUICKSAVE_END_CLOSE_WAIT 26 +#define STATE_SAVE_ERROR 27 + +#define MENU_HEIGHT 15 + +const char *anim1 = "optionActivated.brlan"; +const char *anim2 = "optionDeactivated.brlan"; + +const char *group1 = "G_opt00"; +const char *group2 = "G_opt01"; +const char *group3 = "G_opt02"; +const char *group4 = "G_opt03"; +const char *group5 = "G_opt04"; +const char *group6 = "G_opt05"; +const char *group7 = "G_opt06"; +const char *group8 = "G_opt07"; +const char *group9 = "G_opt08"; +const char *group10 = "G_opt09"; +const char *group11 = "G_opt10"; +const char *group12 = "G_opt11"; +const char *group13 = "G_opt12"; +const char *group14 = "G_opt13"; +const char *group15 = "G_opt14"; + + +void dScNewerWorldMap_c::StartLevel() { + LevelInfo_Entry *level = LevelInfo_GetLevels(this->levelInfo, this->currentPage); + level += this->selections[this->currentPage]; + StartLevel(level); +} + +void dScNewerWorldMap_c::StartLevel(LevelInfo_Entry *entry) { + for (int i = 0; i < 4; i++) { + bool isThere = QueryPlayerAvailability(i); + int id = Player_ID[i]; + Player_Active[i] = isThere ? 1 : 0; + if (!isThere) Player_Flags[i] = 0; + } + + StartLevelInfo sl; + sl.unk1 = 0; + sl.unk2 = 0xFF; + sl.unk3 = 0; + sl.unk4 = 0; + sl.purpose = 0; + + sl.world1 = entry->world; + sl.world2 = entry->world; + sl.level1 = entry->level; + sl.level2 = entry->level; + + // hopefully this will fix the Star Coin issues + SetSomeConditionShit(entry->world, entry->level, 2); + + ActivateWipe(WIPE_MARIO); + + DoStartLevel(GetGameMgr(), &sl); +} + +void dScNewerWorldMap_c::SetTitle(const char *text) { + unsigned short conv_buf[0x200]; + int length = strlen(text); + if (length > 0x1FF) + length = 0x1FF; + + for (int i = 0; i < length; i++) { + conv_buf[i] = text[i]; + } + conv_buf[length] = 0; + + void *textBox = EmbeddedLayout_FindTextBoxByName(this->layout, "ScreenTitle"); + TextBox_SetString(textBox, conv_buf, 0); +} + +void dScNewerWorldMap_c::GenSBTitle() { + char buf[0x100]; + sprintf(buf, "Switches: R:%s; G:%s; Y:%s; B:%s", + ((GetSwitchStatus() & 1) != 0) ? "On" : "Off", + ((GetSwitchStatus() & 2) != 0) ? "On" : "Off", + ((GetSwitchStatus() & 4) != 0) ? "On" : "Off", + ((GetSwitchStatus() & 8) != 0) ? "On" : "Off"); + this->SetTitle(buf); +} + +void dScNewerWorldMap_c::GenText() { + char buf[0x1FF]; + char paneNameBuf[0x20]; + char textBoxNameBuf[0x20]; + unsigned short wchars[0x1FF]; + + SaveBlock *save = GetSaveFile()->GetBlock(-1); + + LevelInfo_Section *section = LevelInfo_GetSection(this->levelInfo, this->currentPage); + LevelInfo_Entry *levels = LevelInfo_GetLevels(this->levelInfo, section); + + int count = section->levelCount; + + for (int i = 0; i < MENU_HEIGHT; i++) { + sprintf(paneNameBuf, "Opt%02d", i); + sprintf(textBoxNameBuf, "OptText%02d", i); + void *pane = EmbeddedLayout_FindPaneByName(this->layout, paneNameBuf); + void *textBox = EmbeddedLayout_FindTextBoxByName(this->layout, textBoxNameBuf); + + if (i < count) { + // valid level + PANE_FLAGS(pane) |= 1; + + u32 conds = save->GetLevelCondition(levels[i].world, levels[i].level); + + char cond1, cond2, cond3, cond4, cond5; + cond1 = (conds & COND_NORMAL ? 'x' : '.'); + cond2 = (conds & COND_SECRET ? 'x' : '.'); + cond3 = (conds & COND_COIN1 ? 'x' : '.'); + cond4 = (conds & COND_COIN2 ? 'x' : '.'); + cond5 = (conds & COND_COIN3 ? 'x' : '.'); + + sprintf(buf, "%s %c%c %c%c%c", LevelInfo_GetName(this->levelInfo, &levels[i]), cond1, cond2, cond3, cond4, cond5); + + for (int i = 0; i < 0x1FF; i++) { + wchars[i] = buf[i]; + if (buf[i] == 0) break; + } + + TextBox_SetString(textBox, wchars, 0); + } else { + // invalid, hide the pane + PANE_FLAGS(pane) &= ~1; + } + } +} + +int dScNewerWorldMap_c::onCreate() { + OSReport("1:Loading scene\n"); + + LoadMapScene(); + OSReport("2:Loading scene\n"); + GameSetup__LoadScene(0); // lol, stolen from GAME_SETUP + + OSReport("3:Layout alloc\n"); + this->layout = (Layout*)AllocFromGameHeap1(sizeof(Layout)); + if (!this->layout) { + OSReport("memalloc fail\n"); + InfiniteLoop; + } + + OSReport("4:Layout ctor\n"); + EmbeddedLayout_ctor(this->layout); + OSReport("5:Layout load arc\n"); + EmbeddedLayout_LoadArc(this->layout, "NewerRes/wmap.arc"); + + OSReport("6:Layout build\n"); + if (!EmbeddedLayout_Build(this->layout, "levelSelect.brlyt", 0)) { + OSReport("build fail\n"); + InfiniteLoop; + } + + + OSReport("7:Layout load brlan\n"); + const char *anims[2] = {anim1, anim2}; + EmbeddedLayout_LoadBrlans(this->layout, anims, 2); + + const char *groups[30] = { + group1, group2, group3, group4, group5, + group6, group7, group8, group9, group10, + group11, group12, group13, group14, group15, + group1, group2, group3, group4, group5, + group6, group7, group8, group9, group10, + group11, group12, group13, group14, group15, + }; + + int mappings[30] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; + OSReport("8:Layout load group\n"); + EmbeddedLayout_LoadGroups(this->layout, groups, mappings, 30); + + OSReport("9:Layout reset anims\n"); + EmbeddedLayout_DisableAllAnims(this->layout); + + for (int i = 0; i < 15; i++) { + EmbeddedLayout_ResetAnimToInitialState(this->layout, i, false); + } + + + OSReport("10:Item 1\n"); + this->selectCursor = CreateParentedObject(SELECT_CURSOR, this, 0, 0); + OSReport("11:Item 2\n"); + this->csMenu = CreateParentedObject(COURSE_SELECT_MENU, this, 0, 0); + OSReport("12:Item 3\n"); + this->yesNoWindow = CreateParentedObject(YES_NO_WINDOW, this, 0, 0); + OSReport("13:Item 4\n"); + this->numPeopleChange = CreateParentedObject(NUMBER_OF_PEOPLE_CHANGE, this, 0, 0); + + for (int i = 0; i < 4; i++) { + OSReport("14:Character change select %d\n", i); + void *ccsb = CreateParentedObject(CHARACTER_CHANGE_SELECT_BASE, this, i, 0); + void *ccsc = CreateParentedObject(CHARACTER_CHANGE_SELECT_CONTENTS, this, i, 0); + void *ccsa = CreateParentedObject(CHARACTER_CHANGE_SELECT_ARROW, this, i, 0); + void *cci = CreateParentedObject(CHARACTER_CHANGE_INDICATOR, this, i, 0); + + NPCHG_CCSB(this->numPeopleChange, i) = ccsb; + NPCHG_CCSC(this->numPeopleChange, i) = ccsc; + NPCHG_CCSA(this->numPeopleChange, i) = ccsa; + NPCHG_CCI(this->numPeopleChange, i) = cci; + } + + OSReport("15:Item 5\n"); + this->continueObj = CreateParentedObject(CONTINUE, this, 0, 0); + + OSReport("16:Item 6\n"); + this->stockItem = CreateParentedObject(STOCK_ITEM, this, 0, 0); + OSReport("17:Item 7\n"); + this->stockItemShadow = CreateParentedObject(STOCK_ITEM_SHADOW, this, 0, 0); + STKI_SHADOW(this->stockItem) = this->stockItemShadow; + + OSReport("18:Item 8\n"); + this->easyPairing = CreateParentedObject(EASY_PAIRING, this, 0, 0); + + this->state = STATE_START_DVD; + + this->layout->drawOrder = 0; + + *CurrentDrawFunc = NewerMapDrawFunc; + + // level info + OSReport("19:Load level info\n"); + this->levelInfo = LoadFile(&this->levelInfoFH, "/NewerRes/LevelInfo.bin"); + OSReport("20:Prepare level info\n"); + LevelInfo_Prepare(&this->levelInfoFH); + + // load the menu info + OSReport("21:Load save info\n"); + SaveBlock *save = GetSaveFile()->GetBlock(-1); + + this->currentPage = save->current_world; + + // bounds check + if (save->current_path_node >= 15) + save->current_path_node = 0; + + int sCount = LevelInfo_GetSectionCount(this->levelInfo); + this->selections = (int*)AllocFromGameHeap1(sizeof(int) * sCount); + + for (int i = 0; i < sCount; i++) { + this->selections[i] = 0; + } + + this->selections[this->currentPage] = save->current_path_node; + + // show button anim + OSReport("22:Enable anim\n"); + EmbeddedLayout_EnableNonLoopAnim(this->layout, save->current_path_node, false); + + OSReport("23:Make text\n"); + this->GenText(); + this->GenSBTitle(); + + OSReport("24:onCreate complete\n"); + return true; +} + +int dScNewerWorldMap_c::onDelete() { + EmbeddedLayout_FreeArc(this->layout); + EmbeddedLayout_Free(this->layout); + EmbeddedLayout_dtor(this->layout, false); + FreeFromGameHeap1(this->layout); + + FreeFromGameHeap1(this->selections); + + FreeFile(&this->levelInfoFH); + + FreeScene(0); + FreeScene(1); + + DVD_FreeFile(GetDVDClass2(), "SI_kinoko"); + DVD_FreeFile(GetDVDClass2(), "SI_fireflower"); + DVD_FreeFile(GetDVDClass2(), "SI_iceflower"); + DVD_FreeFile(GetDVDClass2(), "SI_penguin"); + DVD_FreeFile(GetDVDClass2(), "SI_propeller"); + DVD_FreeFile(GetDVDClass2(), "SI_star"); + + return true; +} + +int dScNewerWorldMap_c::onExecute() { + + if (QueryGlobal5758(0xFFFFFFFF)) return true; + if (CheckIfWeCantDoStuff()) return true; + + /**************************************************************************/ + // Read Wiimote Buttons + + int heldButtons = Remocon_GetButtons(GetActiveRemocon()); + int nowPressed = Remocon_GetPressed(GetActiveRemocon()); + + /**************************************************************************/ + // State Specific + + switch (this->state) { + /**********************************************************************/ + // STATE_START_DVD : Set up DVD + case STATE_START_DVD: + + DVD_Start(); + this->state = STATE_LOAD_RES; + + break; + + /**********************************************************************/ + // STATE_LOAD_RES : Load extra stuff we need + case STATE_LOAD_RES: + + DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_kinoko", 0); + DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_fireflower", 0); + DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_iceflower", 0); + DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_penguin", 0); + DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_propeller", 0); + DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_star", 0); + //DVD_LoadFile(GetDVDClass(), "Object", "fruits_kusa_gake", 0); + + this->state = STATE_END_DVD; + + break; + + /**********************************************************************/ + // STATE_END_DVD : Wait for files to load, end DVD + case STATE_END_DVD: + + if (!DVD_StillLoading(GetDVDClass2())) { + if (DVD_End()) { + this->state = STATE_SETUP_WAIT; + } + } + + break; + + /**********************************************************************/ + // STATE_SETUP_WAIT : Waiting for the world map managers to be set up + case STATE_SETUP_WAIT: { + + bool success = true; + + success &= CSMENU_SETUP_DONE(this->csMenu); + success &= SELC_SETUP_DONE(this->selectCursor); + success &= NPCHG_SETUP_DONE(this->numPeopleChange); + success &= YESNO_SETUP_DONE(this->yesNoWindow); + success &= CONT_SETUP_DONE(this->continueObj); + success &= STKI_SETUP_DONE(this->stockItem); + success &= SIS_SETUP_DONE(this->stockItemShadow); + success &= EASYP_SETUP_DONE(this->easyPairing); + + if (success) { + // ok, now we can set up other required shit + + // first up: player models for Stocked Items + for (int i = 0; i < 4; i++) { + void *obj = CreateChildObject(WM_2D_PLAYER, this, i, 0, 0); + STKI_2DPLAYER(this->stockItem,i) = obj; + NPCHG_2DPLAYER(this->numPeopleChange,i) = obj; + } + + // next: items for the Powerup screen + for (int i = 0; i < 7; i++) { + void *obj = CreateChildObject(WM_ITEM, this, i, 0, 0); + STKI_ITEM(this->stockItem,i) = obj; + } + + // now, check if we need to handle Continue + if (CheckIfContinueShouldBeActivated()) { + this->state = STATE_CONTINUE_WAIT; + CONT_UNK1(this->continueObj) = true; + CONT_UNK2(this->continueObj) = true; + CONT_UNK3(this->continueObj) = false; + } else { + this->state = STATE_OPT_CHANGE_WAIT; + } + } + + } break; + + /**********************************************************************/ + // STATE_CONTINUE_WAIT : Waiting for the Continue anim to finish + case STATE_CONTINUE_WAIT: + + if (CONT_DONE(this->continueObj)) { + CONT_UNK1(this->continueObj) = 0; + CONT_UNK2(this->continueObj) = 0; + CONT_UNK3(this->continueObj) = 0; + + for (int i = 0; i < 4; i++) { + int idx = SearchForIndexOfPlayerID(i); + Player_Lives[Player_ID[idx]] = CONT_LIVES(this->continueObj, i); + } + + this->state = STATE_OPT_CHANGE_WAIT; + } + + break; + + /**********************************************************************/ + // STATE_NORMAL : Nothing related to the menu is going on + case STATE_NORMAL: { + + int currentPage = this->currentPage; + int currentSelection = this->selections[currentPage]; + int newPage = currentPage; + int newSelection = currentSelection; + + // Activate the menu + if (nowPressed & WPAD_PLUS) { + CSMENU_ACTIVE(this->csMenu) = true; + this->state = STATE_CSMENU; + } + + if (nowPressed & WPAD_B) { + SetSwitchStatus((GetSwitchStatus() + 1) & 15); + this->GenSBTitle(); + } + + // Change the current level + if ((nowPressed & WPAD_UP) && currentSelection > 0) { + newSelection = currentSelection - 1; + } + + if ((nowPressed & WPAD_DOWN) && currentSelection < (LevelInfo_GetSection(this->levelInfo, currentPage)->levelCount - 1)) { + newSelection = currentSelection + 1; + } + + // Change the current world + if ((nowPressed & WPAD_LEFT) && currentPage > 0) { + newPage = currentPage - 1; + } + + if ((nowPressed & WPAD_RIGHT) && currentPage < (LevelInfo_GetSectionCount(this->levelInfo) - 1)) { + newPage = currentPage + 1; + } + + + if (newPage != currentPage) { + this->currentPage = newPage; + this->GenText(); + + // do this to let the rest of the code handle animations + newSelection = this->selections[newPage]; + } + + if (newSelection != currentSelection) { + EmbeddedLayout_DisableAllAnims(this->layout); + + // enable On animation + EmbeddedLayout_EnableNonLoopAnim(this->layout, newSelection, false); + + // enable Off animation + EmbeddedLayout_EnableNonLoopAnim(this->layout, currentSelection+15, false); + + this->selections[newPage] = newSelection; + this->state = STATE_OPT_CHANGE_WAIT; + } + + + // save the info to the file + if (currentSelection != newSelection || currentPage != newPage) { + SaveBlock *save = GetSaveFile()->GetBlock(-1); + save->current_world = newPage; + save->current_path_node = newSelection; + } + + + // Enter the current level + if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) { + this->StartLevel(); + this->state = STATE_LIMBO; // just in case + } + + if (nowPressed & WPAD_ONE) { + STKI_SHOW(this->stockItem) = true; + this->state = STATE_POWERUPS_WAIT; + } + } break; + + /**********************************************************************/ + // STATE_OPT_CHANGE_WAIT : Waiting for the option change animation to + // finish playing + case STATE_OPT_CHANGE_WAIT: + + if (!EmbeddedLayout_CheckIfAnimationIsOn(this->layout, -1)) { + this->state = STATE_NORMAL; + } + + break; + /**********************************************************************/ + // STATE_CSMENU : The course select menu is currently being shown + case STATE_CSMENU: + + // First off, check to see if it's been hidden + if (!CSMENU_ACTIVE(this->csMenu)) { + // That means something happened + if (CSMENU_CHOICE_OK(this->csMenu)) { + // Player pressed a button + + switch (CSMENU_CURRENT(this->csMenu)) { + case 0: + // Star Coins + //OSReport("Star Coins was pressed\n"); + this->state = STATE_NORMAL; + break; + + case 1: + // Add/Drop Players + //OSReport("Add/Drop Players was pressed\n"); + this->state = STATE_PLAYER_CHANGE_WAIT; + NPCHG_ACTIVE(this->numPeopleChange) = true; + WpadShit(10); + + break; + + case 2: + // Save or Quick Save + //OSReport("Save or Quick Save was pressed\n"); + if (GetSaveFile()->GetBlock(-1)->bitfield & 2) { + this->state = STATE_SAVE_OPEN; + YESNO_TYPE(this->yesNoWindow) = 1; + YESNO_VISIBLE(this->yesNoWindow) = 1; + + } else { + this->state = STATE_QUICKSAVE_OPEN; + YESNO_TYPE(this->yesNoWindow) = 15; + YESNO_VISIBLE(this->yesNoWindow) = 1; + + } + + break; + + case 3: + // Title Screen + //OSReport("Title Screen was pressed\n"); + this->state = STATE_TITLE_CONFIRM_OPEN_WAIT; + YESNO_VISIBLE(this->yesNoWindow) = true; + YESNO_TYPE(this->yesNoWindow) = 10; + break; + } + + } else { + // Ok, change back to STATE_NORMAL + this->state = STATE_NORMAL; + } + } + + break; + + /**********************************************************************/ + // STATE_TITLE_CONFIRM_OPEN_WAIT : Waiting for the "Go to Title Screen" + // YesNoWindow to finish opening + case STATE_TITLE_CONFIRM_OPEN_WAIT: + + if (!YESNO_OPENING(this->yesNoWindow)) { + this->state = STATE_TITLE_CONFIRM_SELECT; + } + + break; + + /**********************************************************************/ + // STATE_TITLE_CONFIRM_SELECT : Let the user choose an option on the + // "Go to Title Screen" YesNoWindow. + case STATE_TITLE_CONFIRM_SELECT: + + if (nowPressed & WPAD_LEFT) { + // Select "OK!" + YESNO_CURRENT(this->yesNoWindow) = 1; + + } else if (nowPressed & WPAD_RIGHT) { + // Select "Cancel" + YESNO_CURRENT(this->yesNoWindow) = 0; + + } else if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) { + // Pick the current option + YESNO_CLOSE(this->yesNoWindow) = true; + if (YESNO_CURRENT(this->yesNoWindow) != 1) + YESNO_REFUSED(this->yesNoWindow) = true; + this->state = STATE_TITLE_CONFIRM_HIT_WAIT; + + } else { + // Cancel using B or 1 + if (CheckIfMenuShouldBeCancelledForSpecifiedWiimote(0)) { + YESNO_CANCELLED(this->yesNoWindow) = true; + YESNO_CURRENT(this->yesNoWindow) = true; + this->state = STATE_TITLE_CONFIRM_HIT_WAIT; + } + } + + break; + + /**********************************************************************/ + // STATE_TITLE_CONFIRM_HIT_WAIT : Process the user's chosen option on + // the "Go to Title Screen" YesNoWindow. Also, wait for the + // animation to be complete. + case STATE_TITLE_CONFIRM_HIT_WAIT: + + if (!YESNO_OPENING(this->yesNoWindow)) { + if (YESNO_CURRENT(this->yesNoWindow) == 1) { + this->state = STATE_NORMAL; + } else { + this->state = STATE_LIMBO; + StartTitleScreenStage(false, 0); + } + } + + break; + + /**********************************************************************/ + // STATE_PLAYER_CHANGE_WAIT : Wait for the user to do something on the + // Add/Drop Players screen. + case STATE_PLAYER_CHANGE_WAIT: + + if (NPCHG_READY(this->numPeopleChange)) { + if (nowPressed & WPAD_PLUS) { + // activate easy pairing. FUN !! + NPCHG_HIDE_FOR_EASYP(this->numPeopleChange) = 1; + + for (int i = 0; i < 4; i++) { + void *obj = NPCHG_2DPLAYER(this->numPeopleChange, i); + void *ccsb = NPCHG_CCSB(this->numPeopleChange, i); + void *ccsc = NPCHG_CCSC(this->numPeopleChange, i); + + PLAYER2D_SHOW_EASY_PAIRING(obj) = 1; + CCSB_ACTIVE(ccsb) = 1; + CCSC_ACTIVE(ccsc) = 1; + } + + EASYP_ACTIVE(this->easyPairing) = 1; + this->state = STATE_EASY_PAIRING_WAIT; + } + } else { + if (!NPCHG_ACTIVE(this->numPeopleChange)) { + this->state = STATE_NORMAL; + } + } + + break; + + /**********************************************************************/ + // STATE_EASY_PAIRING_WAIT : Wait for the user to exit Easy Pairing. + case STATE_EASY_PAIRING_WAIT: + + if (!EASYP_ACTIVE(this->easyPairing)) { + NPCHG_HIDE_FOR_EASYP(this->numPeopleChange) = 0; + + for (int i = 0; i < 4; i++) { + void *obj = NPCHG_2DPLAYER(this->numPeopleChange, i); + void *ccsb = NPCHG_CCSB(this->numPeopleChange, i); + void *ccsc = NPCHG_CCSC(this->numPeopleChange, i); + + PLAYER2D_SHOW_EASY_PAIRING(obj) = 0; + CCSB_ACTIVE(ccsb) = 0; + CCSC_ACTIVE(ccsc) = 0; + } + + this->state = STATE_PLAYER_CHANGE_WAIT; + WpadShit(10); + } + + break; + + /**********************************************************************/ + // STATE_POWERUPS_WAIT : Wait for the user to exit the Powerups screen. + case STATE_POWERUPS_WAIT: + + if (!STKI_SHOW(this->stockItem)) { + this->state = STATE_NORMAL; + } + + break; + + /**********************************************************************/ + // STATE_SAVE_OPEN : Waiting for the "Save?" YesNoWindow to open + case STATE_SAVE_OPEN: + + if (!YESNO_OPENING(this->yesNoWindow)) { + this->state = STATE_SAVE_SELECT; + } + + break; + + /**********************************************************************/ + // STATE_SAVE_SELECT : Let the user choose an option on the + // "Save?" YesNoWindow. + case STATE_SAVE_SELECT: + + if (nowPressed & WPAD_LEFT) { + // Select "OK!" + YESNO_CURRENT(this->yesNoWindow) = 1; + + } else if (nowPressed & WPAD_RIGHT) { + // Select "Cancel" + YESNO_CURRENT(this->yesNoWindow) = 0; + + } else if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) { + // Pick the current option + YESNO_CLOSE(this->yesNoWindow) = true; + + if (YESNO_CURRENT(this->yesNoWindow) != 1) + YESNO_CANCELLED2(this->yesNoWindow) = true; + this->state = STATE_SAVE_WINDOW_CLOSE; + + } else { + // Cancel using B or 1 + if (CheckIfMenuShouldBeCancelledForSpecifiedWiimote(0)) { + YESNO_CANCELLED(this->yesNoWindow) = true; + YESNO_CURRENT(this->yesNoWindow) = 1; + this->state = STATE_SAVE_WINDOW_CLOSE; + } + } + + break; + + /**********************************************************************/ + // STATE_SAVE_WINDOW_CLOSE : Process the user's chosen option on the + // "Save?" YesNoWindow. Also, wait for the animation to be complete. + case STATE_SAVE_WINDOW_CLOSE: + + if (!YESNO_VISIBLE(this->yesNoWindow)) { + if (YESNO_CURRENT(this->yesNoWindow) == 1) { + this->state = STATE_NORMAL; + } else { + this->state = STATE_SAVE_DO; + SaveGame(0, false); + } + } + + break; + + /**********************************************************************/ + // STATE_SAVE_DO : Save the game. + case STATE_SAVE_DO: + + if (!GetSaveFile()->CheckIfWriting()) { + if (GetSaveHandler()->CurrentError == 0) { + YESNO_TYPE(this->yesNoWindow) = 2; + YESNO_VISIBLE(this->yesNoWindow) = true; + this->state = STATE_SAVE_END_WINDOW; + } else { + this->state = STATE_SAVE_ERROR; + } + } + + break; + + /**********************************************************************/ + // STATE_SAVE_END_WINDOW : Handle the Save End window. + case STATE_SAVE_END_WINDOW: + + if (!YESNO_OPENING(this->yesNoWindow)) { + if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) { + YESNO_CLOSE(this->yesNoWindow) = true; + this->state = STATE_SAVE_END_CLOSE_WAIT; + } + } + + break; + + /**********************************************************************/ + // STATE_SAVE_END_CLOSE_WAIT : Wait for the Save End window to close. + case STATE_SAVE_END_CLOSE_WAIT: + + if (!YESNO_OPENING(this->yesNoWindow)) { + this->state = STATE_NORMAL; + } + + break; + + /**********************************************************************/ + // STATE_QUICKSAVE_OPEN : Waiting for the "Save?" YesNoWindow to open + case STATE_QUICKSAVE_OPEN: + + if (!YESNO_OPENING(this->yesNoWindow)) { + this->state = STATE_QUICKSAVE_SELECT; + } + + break; + + /**********************************************************************/ + // STATE_QUICKSAVE_SELECT : Let the user choose an option on the + // "Save?" YesNoWindow. + case STATE_QUICKSAVE_SELECT: + + if (nowPressed & WPAD_LEFT) { + // Select "OK!" + YESNO_CURRENT(this->yesNoWindow) = 1; + + } else if (nowPressed & WPAD_RIGHT) { + // Select "Cancel" + YESNO_CURRENT(this->yesNoWindow) = 0; + + } else if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) { + // Pick the current option + YESNO_CLOSE(this->yesNoWindow) = true; + + if (YESNO_CURRENT(this->yesNoWindow) != 1) + YESNO_CANCELLED2(this->yesNoWindow) = true; + this->state = STATE_QUICKSAVE_WINDOW_CLOSE; + + } else { + // Cancel using B or 1 + if (CheckIfMenuShouldBeCancelledForSpecifiedWiimote(0)) { + YESNO_CANCELLED(this->yesNoWindow) = true; + YESNO_CURRENT(this->yesNoWindow) = 1; + this->state = STATE_QUICKSAVE_WINDOW_CLOSE; + } + } + + break; + + /**********************************************************************/ + // STATE_QUICKSAVE_WINDOW_CLOSE : Process the user's chosen option on + // the "Save?" YesNoWindow. Also, wait for the animation to be complete + case STATE_QUICKSAVE_WINDOW_CLOSE: + + if (!YESNO_VISIBLE(this->yesNoWindow)) { + if (YESNO_CURRENT(this->yesNoWindow) == 1) { + this->state = STATE_NORMAL; + } else { + this->state = STATE_QUICKSAVE_DO; + SaveGame(0, true); + } + } + + break; + + /**********************************************************************/ + // STATE_QUICKSAVE_DO : Save the game. + case STATE_QUICKSAVE_DO: + + if (!GetSaveFile()->CheckIfWriting()) { + if (GetSaveHandler()->CurrentError == 0) { + YESNO_TYPE(this->yesNoWindow) = 16; + YESNO_VISIBLE(this->yesNoWindow) = true; + this->state = STATE_QUICKSAVE_END_WINDOW; + } else { + this->state = STATE_SAVE_ERROR; + } + } + + break; + + /**********************************************************************/ + // STATE_QUICKSAVE_END_WINDOW : Handle the Save End window. + case STATE_QUICKSAVE_END_WINDOW: + + if (!YESNO_OPENING(this->yesNoWindow)) { + if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) { + YESNO_CLOSE(this->yesNoWindow) = true; + YESNO_REFUSED(this->yesNoWindow) = true; + this->state = STATE_QUICKSAVE_END_CLOSE_WAIT; + } + } + + break; + + /**********************************************************************/ + // STATE_QUICKSAVE_END_CLOSE_WAIT : Wait for Save End window to close + case STATE_QUICKSAVE_END_CLOSE_WAIT: + + if (!YESNO_OPENING(this->yesNoWindow)) { + if (YESNO_CURRENT(this->yesNoWindow) == 1) { + this->state = STATE_NORMAL; + } else { + this->state = STATE_LIMBO; + StartTitleScreenStage(false, 0); + } + } + + break; + + } + + if (this->state >= STATE_NORMAL) { + EmbeddedLayout_Process(this->layout); + EmbeddedLayout_UpdateMatrix(this->layout); + } + + return true; +} + +int dScNewerWorldMap_c::onDraw() { + EmbeddedLayout_AddToDrawList(this->layout); + + return true; +} + + + +void NewerMapDrawFunc() { + int keepCamera = GetCurrentCameraID(); + + // All drawing uses scene 1, since that's the only one loaded by GAME_SETUP. + // Todo: Newer-specific scenes? + + // Stage 1 + SetupLYTDrawing(); + DrawAllLayoutsBeforeX(129); + GXDrawDone(); // is all GXDrawDone really needed..? + + // Stage 2 + Reset3DState(); + SetCurrentCameraID(0); + LinkScene(0); + SceneCalcWorld(0); + SceneCameraStuff(0); + ChangeAlphaUpdate(false); + CalcMaterial(); + DrawOpa(); + DrawXlu(); + UnlinkScene(0); + GXDrawDone(); + + //Reset3DState(); + //T3D::DrawQueue(); + + // Stage 3 + Reset3DState(); + SetupLYTDrawing(); + DrawAllLayoutsAfterXandBeforeY(128, 146); + GXDrawDone(); + + // Stage 4 + RemoveAllFromScnRoot(); + Reset3DState(); + SetCurrentCameraID(1); + + DoSpecialDrawing1(); + LinkScene(1); + SceneCalcWorld(1); + SceneCameraStuff(1); + CalcMaterial(); + DrawOpa(); + DrawXlu(); + + // Stage 5 + if (GAMEMGR_GET_AFC(GameMgr)) { + for (int i = 0; i < 4; i++) { + RenderEffects(0, 11+i); + } + + for (int i = 0; i < 4; i++) { + RenderEffects(0, 7+i); + } + } + + RenderEffects(0, 2); // need to investigate how this thing works + + DrawAllLayoutsAfterX(145); + ClearLayoutDrawList(); // this is REALLY IMPORTANT! + + UnlinkScene(1); + + // End + SetCurrentCameraID(0); +} + diff --git a/src/worldmap.h b/src/worldmap.h index 0cf567e..82032e6 100644 --- a/src/worldmap.h +++ b/src/worldmap.h @@ -1,63 +1,63 @@ -/*
- * Newer Super Mario Bros. Wii
- * World Maps
- *
- * Wish me luck. That's all I'm saying. --Treeki
- * Started: 03/06/2010; 11:52pm
- */
-
-// TODO: add Save Error state
-
-//#define WM_DEBUGGING
-
-#include <common.h>
-#include <game.h>
-
-#include "layoutlib.h"
-#include "fileload.h"
-#include "levelinfo.h"
-
-#ifdef WM_DEBUGGING
-#define MapReport OSReport
-#else
-inline void MapReport(const char *str, ...) { }
-#endif
-
-void NewerMapDrawFunc();
-
-
-// WORLD MAP CLASS LAYOUT
-class dScNewerWorldMap_c : public dScene_c {
-public:
- Layout *layout;
- int currentPage;
- int *selections;
- int state;
- void *csMenu;
- void *selectCursor;
- void *numPeopleChange;
- void *yesNoWindow;
- void *continueObj;
- void *stockItem;
- void *stockItemShadow;
- void *easyPairing;
-
- void *levelInfo;
- FileHandle levelInfoFH;
-
- void StartLevel(LevelInfo_Entry *entry);
-
- void StartLevel();
- void GenText();
- void GenSBTitle();
- void SetTitle(const char *text);
-
- int onCreate();
- int onDelete();
- int onExecute();
- int onDraw();
-
- static dScNewerWorldMap_c *build();
- static dScNewerWorldMap_c *instance;
-};
-
+/* + * Newer Super Mario Bros. Wii + * World Maps + * + * Wish me luck. That's all I'm saying. --Treeki + * Started: 03/06/2010; 11:52pm + */ + +// TODO: add Save Error state + +//#define WM_DEBUGGING + +#include <common.h> +#include <game.h> + +#include "layoutlib.h" +#include "fileload.h" +#include "levelinfo.h" + +#ifdef WM_DEBUGGING +#define MapReport OSReport +#else +inline void MapReport(const char *str, ...) { } +#endif + +void NewerMapDrawFunc(); + + +// WORLD MAP CLASS LAYOUT +class dScNewerWorldMap_c : public dScene_c { +public: + Layout *layout; + int currentPage; + int *selections; + int state; + void *csMenu; + void *selectCursor; + void *numPeopleChange; + void *yesNoWindow; + void *continueObj; + void *stockItem; + void *stockItemShadow; + void *easyPairing; + + void *levelInfo; + FileHandle levelInfoFH; + + void StartLevel(LevelInfo_Entry *entry); + + void StartLevel(); + void GenText(); + void GenSBTitle(); + void SetTitle(const char *text); + + int onCreate(); + int onDelete(); + int onExecute(); + int onDraw(); + + static dScNewerWorldMap_c *build(); + static dScNewerWorldMap_c *instance; +}; + |