1
0
Fork 0

Fixed broken US functions and added PAL support

ThrowMario, GetMarioStatus and GetMarioHP were associated to wrong addresses in smsFuncs, that’s fixed. Also the C-Kit can now target the PAL version!
This commit is contained in:
QbeRoot 2017-09-22 15:11:32 +02:00 committed by GitHub
parent 646811b83c
commit 3bff6fc14b
9 changed files with 102905 additions and 84 deletions

158
README.md
View file

@ -1,79 +1,79 @@
# Super Mario Sunshine - C Kit
A WIP C library for everyone's favorite game: Super Mario Sunshine. The tools in this will allow you to compile C code which can be patched into Super Mario Sunshine.
#What can this do?
The library allows you to compile PPC code that replace functions and interact with objects in Super Mario Sunshine. The code can be either put into a gecko code with a max size of 229 lines or be patched into Super Mario Sunshine's Start.dol.
This is only for Super Mario Sunshine at the moment. (I'll probably make another kit for some other games in the future, though only me working on them; I don't want to involve Miluaces into the pain. ^ ^' )
#Neato!... Well, how do I set this up?
0. Clone or download the c kit.
0. Install devkitPro for PPC somewhere on your harddrive. The batch files are set up for it to be located at C:\devkitPro\devkitPPC, but you can edit the batch files to account for your install location.
0. If you want to patch Start.dol, extract it from your Super Mario Sunshine image and copy it into the c kit directory.
0. To compile C code, drag the source file onto build.bat for a gecko code or patchdol.bat to patch Start.dol.
0. The gecko code should be copied into your clipboard or a new .dol file with your source files name will be created.
#Alright. Do you have any examples to show?
Yes, actually. Here's an item spawning example from Miluaces:
```
include "sms.h"
int laststate; //Last state
int OnUpdate(MarDirector* director) {
int (*GameUpdate)(MarDirector* director) = GetObjectFunction(director, Director_GameUpdate);
MarioActor* mario = GetMarioHitActor();
ItemActor* item = 0;
if (!laststate){
if (ControllerOne->buttons & PRESS_DU) //Dpad up spawns a coin
item = MakeObjAppear(*gpItemManager, OBJ_COIN);
else if (ControllerOne->buttons & PRESS_DL) //Dpad left spawns a 1-up
item = MakeObjAppear(*gpItemManager, OBJ_ONEUP);
else if (ControllerOne->buttons & PRESS_DR) //Dpad right spawns a rocket nozzle
item = MakeObjAppear(*gpItemManager, OBJ_ROCKETNOZZLE);
else if (ControllerOne->buttons & PRESS_DD) //Dpad down spawns a turbo nozzle
item = MakeObjAppear(*gpItemManager, OBJ_TURBONOZZLE);
}
// If no dpad buttons are pressed, reset laststate
if (!(ControllerOne-> buttons & (PRESS_DU | PRESS_DL | PRESS_DR | PRESS_DD)))
laststate = 0;
//If item was assigned, set it up
if (item != 0){
//Set laststate to 1 to prevent more than one item spawning from one button press
laststate = 1;
//Set item position
item->position.x = mario->position.x;
item->position.y = mario->position.y + 200.0f;
item->position.z = mario->position.z;
//Set item velocity
item->velocity.y = 20.0f;
//Make item moveable
item->flags = item->flags & ~ITEMFLAG_STATIC;
}
return GameUpdate(director);
}
```
There are more examples in the repository.
#My code compiled! What do I do now?
Either build a new SMS image with your dol file or enter your gecko code to see your code run in game.
---
More examples and updates to the lib will surely come at the right moment. For support with this check out the Blastsoft Studios Discord ( https://discord.gg/mN9nf ).
Also visit SMS Realm ( http://smsrealm.net/board/ ) to discuss SMS hacking with other users.
# Super Mario Sunshine - C Kit
A WIP C library for everyone's favorite game: Super Mario Sunshine. The tools in this will allow you to compile C code which can be patched into Super Mario Sunshine.
#What can this do?
The library allows you to compile PPC code that replace functions and interact with objects in Super Mario Sunshine. The code can be either put into a gecko code with a max size of 229 lines or be patched into Super Mario Sunshine's Start.dol.
This is only for Super Mario Sunshine at the moment. (I'll probably make another kit for some other games in the future, though only me working on them; I don't want to involve Miluaces into the pain. ^ ^' )
#Neato!... Well, how do I set this up?
0. Clone or download the c kit.
0. Install devkitPro for PPC somewhere on your harddrive. The batch files are set up for it to be located at C:\devkitPro\devkitPPC, but you can edit the batch files to account for your install location.
0. If you want to patch Start.dol, extract it from your Super Mario Sunshine image and copy it into the c kit directory.
0. To compile C code, drag the source file onto build.bat for a gecko code or patchdol.bat to patch Start.dol.
0. The gecko code should be copied into your clipboard or a new .dol file with your source files name will be created.
#Alright. Do you have any examples to show?
Yes, actually. Here's an item spawning example from Miluaces:
```
include "sms.h"
int laststate; //Last state
int OnUpdate(MarDirector* director) {
int (*GameUpdate)(MarDirector* director) = GetObjectFunction(director, Director_GameUpdate);
MarioActor* mario = GetMarioHitActor();
ItemActor* item = 0;
if (!laststate){
if (ControllerOne->buttons & PRESS_DU) //Dpad up spawns a coin
item = MakeObjAppear(*gpItemManager, OBJ_COIN);
else if (ControllerOne->buttons & PRESS_DL) //Dpad left spawns a 1-up
item = MakeObjAppear(*gpItemManager, OBJ_ONEUP);
else if (ControllerOne->buttons & PRESS_DR) //Dpad right spawns a rocket nozzle
item = MakeObjAppear(*gpItemManager, OBJ_ROCKETNOZZLE);
else if (ControllerOne->buttons & PRESS_DD) //Dpad down spawns a turbo nozzle
item = MakeObjAppear(*gpItemManager, OBJ_TURBONOZZLE);
}
// If no dpad buttons are pressed, reset laststate
if (!(ControllerOne->buttons & (PRESS_DU | PRESS_DL | PRESS_DR | PRESS_DD)))
laststate = 0;
//If item was assigned, set it up
if (item != 0){
//Set laststate to 1 to prevent more than one item spawning from one button press
laststate = 1;
//Set item position
item->position.x = mario->position.x;
item->position.y = mario->position.y + 200.0f;
item->position.z = mario->position.z;
//Set item velocity
item->velocity.y = 20.0f;
//Make item moveable
item->flags = item->flags & ~ITEMFLAG_STATIC;
}
return GameUpdate(director);
}
```
There are more examples in the repository.
#My code compiled! What do I do now?
Either build a new SMS image with your dol file or enter your gecko code to see your code run in game.
---
More examples and updates to the lib will surely come at the right moment. For support with this check out the Blastsoft Studios Discord ( https://discord.gg/mN9nf ).
Also visit SMS Realm ( http://smsrealm.net/board/ ) to discuss SMS hacking with other users.

13
ports/pal/build.bat Normal file
View file

@ -0,0 +1,13 @@
C:\devkitPro\devkitPPC\bin\powerpc-eabi-gcc.exe %1 -S -o %~n1.s -O1 -std=c99
C:\devkitPro\devkitPPC\bin\powerpc-eabi-gcc.exe %1 -c -o %~n1.o -O1 -std=c99
if ERRORLEVEL 1 pause
if ERRORLEVEL 1 exit
C:\devkitPro\devkitPPC\bin\powerpc-eabi-ld.exe -Os -T linkerEU -T smsFuncsEU -o obj_%~n1.o %~n1.o -Map %~n1.map
if ERRORLEVEL 1 pause
if ERRORLEVEL 1 exit
C:\devkitPro\devkitPPC\bin\powerpc-eabi-objdump.exe obj_%~n1.o --full-content
if ERRORLEVEL 1 pause
if ERRORLEVEL 1 exit
C:\devkitPro\devkitPPC\bin\powerpc-eabi-objcopy.exe obj_%~n1.o %~n1.bin -O binary -R .eh_frame -R .comment -R .sdata -R .gnu.attributes -g -S
bin2gecko.exe %~n1.bin -m %~n1.map -c OnUpdate:0x8029e070:3 -c OnSetup:0x80291750:0 -c OnDraw2D:0x80138b50:0 -c OnWaterHitsGround:0x80277568:0 -c OnObjectTouchMario:0x801a81b4:3 -c OnAllNPCsUpdate:0x8003e140:0 -c OnSmallEnemyHitMario:0x80065e0c:3 -r OnEMarioControl:0x8003ff5c -r IsMario:0x80245898
pause

121
ports/pal/dollinker Normal file
View file

@ -0,0 +1,121 @@
__destroy_global_chain = 0x8032ff40;
__register_global_object = 0x8032ff88;
__destroy_new_array = 0x8032ffa0;
__destroy_arr = 0x8033001c;
__construct_array = 0x80330094;
__dt__26__partial_array_destructorFv = 0x80330194;
__construct_new_array = 0x8033024c;
__ptmf_test = 0x80330354;
__ptmf_scall = 0x80330384;
__unregister_fragment = 0x803303ac;
__register_fragment = 0x803303e0;
__cvt_fp2unsigned = 0x8033041c;
exit = 0x80330af8;
rand = 0x80333324;
srand = 0x8033331c;
long2str = 0x80332c20;
longlong2str = 0x80332940;
round_decimal = 0x8033280c;
float2str = 0x803321d4;
toupper = 0x803310bc;
tolower = 0x803310e4;
__num2dec = 0x80330c04;
__flush_buffer = 0x80330fb8;
__prep_buffer = 0x80331084;
__kill_critical_regions = 0x803310b8;
__div2u = 0x80330478;
__div2i = 0x80330564;
__mod2u = 0x8033069c;
__mod2i = 0x80330780;
__shl2i = 0x8033088c;
__shr2u = 0x803308b0;
__shr2i = 0x803308d4;
__cvt_sll_flt = 0x803308fc;
__cvt_dbl_usll = 0x803309b0;
GetR2__Fv = 0x80330a7c;
__fini_cpp_exceptions = 0x80330a84;
__init_cpp_exceptions = 0x80330ab8;
fwrite = 0x8033110c;
wcstombs = 0x803313e8;
memcmp = 0x80331424;
memchr = 0x80331468;
memmove = 0x80331494;
__copy_longs_rev_unaligned = 0x80331570;
__copy_longs_unaligned = 0x80331620;
__copy_longs_rev_aligned = 0x803316e4;
__copy_longs_aligned = 0x80331790;
__stdio_atexit = 0x8033184c;
sprintf = 0x80331850;
snprintf = 0x80331924;
vsnprintf = 0x803319f4;
vprintf = 0x80331a64;
__StringWrite = 0x80331ae0;
__FileWrite = 0x80331b4c;
__pformatter = 0x80331ba4;
parse_format = 0x80332e44;
__StringRead = 0x80333348;
strstr = 0x803333d8;
strrchr = 0x80333444;
strchr = 0x8033348c;
strcmp = 0x803334bc;
strcat = 0x803335e0;
strncpy = 0x8033360c;
strcpy = 0x80333650;
strlen = 0x80333704;
strtol = 0x80333724;
strtoul = 0x80333814;
__strtoul = 0x803338c0;
__close_console = 0x80333c08;
__write_console = 0x80333c10;
__read_console = 0x80333ca8;
fwide = 0x80333d88;
fabs__Fd = 0x80333e08;
__ieee754_atan2 = 0x80333e10;
atan = 0x803340a8;
frexp = 0x803342e8;
atan2 = 0x80334384;
fabsf__Ff = 0x803343a4;
atanf = 0x803343ac;
atan__Ff = 0x803345a0;
_inv_sqrtf = 0x803345c0;
acosf = 0x80334630;
atan2f = 0x80334674;
tanf = 0x8033474c;
cos__Ff = 0x80334790;
sin__Ff = 0x803347b0;
cosf = 0x803347d0;
sinf = 0x80334964;
__sinit_trigf_c = 0x80334b08;
powf = 0x80334b38;
expf = 0x80335278;
memset = 0x80003100;
__fill_mem = 0x80003130;
memcpy = 0x800031f4;
__nw__FUl = 0x802bbc38;
__nw__FUli = 0x802bbc80;
__nwa__FUl = 0x802bbd38;
__nwa__FUli = 0x802bbd80;
__dl__FPv = 0x802bbe38;
__dla__FPv = 0x802bbe9c;
SECTIONS
{
. = 0x80417800;
.text :
{
*(.text)
}
.rodata :
{
*(.rodata*)
}
.data :
{
*(.data)
}
. += 0x08;
.sdata :
{
*(.sdata)
}
}

121
ports/pal/linker Normal file
View file

@ -0,0 +1,121 @@
__destroy_global_chain = 0x8032ff40;
__register_global_object = 0x8032ff88;
__destroy_new_array = 0x8032ffa0;
__destroy_arr = 0x8033001c;
__construct_array = 0x80330094;
__dt__26__partial_array_destructorFv = 0x80330194;
__construct_new_array = 0x8033024c;
__ptmf_test = 0x80330354;
__ptmf_scall = 0x80330384;
__unregister_fragment = 0x803303ac;
__register_fragment = 0x803303e0;
__cvt_fp2unsigned = 0x8033041c;
exit = 0x80330af8;
rand = 0x80333324;
srand = 0x8033331c;
long2str = 0x80332c20;
longlong2str = 0x80332940;
round_decimal = 0x8033280c;
float2str = 0x803321d4;
toupper = 0x803310bc;
tolower = 0x803310e4;
__num2dec = 0x80330c04;
__flush_buffer = 0x80330fb8;
__prep_buffer = 0x80331084;
__kill_critical_regions = 0x803310b8;
__div2u = 0x80330478;
__div2i = 0x80330564;
__mod2u = 0x8033069c;
__mod2i = 0x80330780;
__shl2i = 0x8033088c;
__shr2u = 0x803308b0;
__shr2i = 0x803308d4;
__cvt_sll_flt = 0x803308fc;
__cvt_dbl_usll = 0x803309b0;
GetR2__Fv = 0x80330a7c;
__fini_cpp_exceptions = 0x80330a84;
__init_cpp_exceptions = 0x80330ab8;
fwrite = 0x8033110c;
wcstombs = 0x803313e8;
memcmp = 0x80331424;
memchr = 0x80331468;
memmove = 0x80331494;
__copy_longs_rev_unaligned = 0x80331570;
__copy_longs_unaligned = 0x80331620;
__copy_longs_rev_aligned = 0x803316e4;
__copy_longs_aligned = 0x80331790;
__stdio_atexit = 0x8033184c;
sprintf = 0x80331850;
snprintf = 0x80331924;
vsnprintf = 0x803319f4;
vprintf = 0x80331a64;
__StringWrite = 0x80331ae0;
__FileWrite = 0x80331b4c;
__pformatter = 0x80331ba4;
parse_format = 0x80332e44;
__StringRead = 0x80333348;
strstr = 0x803333d8;
strrchr = 0x80333444;
strchr = 0x8033348c;
strcmp = 0x803334bc;
strcat = 0x803335e0;
strncpy = 0x8033360c;
strcpy = 0x80333650;
strlen = 0x80333704;
strtol = 0x80333724;
strtoul = 0x80333814;
__strtoul = 0x803338c0;
__close_console = 0x80333c08;
__write_console = 0x80333c10;
__read_console = 0x80333ca8;
fwide = 0x80333d88;
fabs__Fd = 0x80333e08;
__ieee754_atan2 = 0x80333e10;
atan = 0x803340a8;
frexp = 0x803342e8;
atan2 = 0x80334384;
fabsf__Ff = 0x803343a4;
atanf = 0x803343ac;
atan__Ff = 0x803345a0;
_inv_sqrtf = 0x803345c0;
acosf = 0x80334630;
atan2f = 0x80334674;
tanf = 0x8033474c;
cos__Ff = 0x80334790;
sin__Ff = 0x803347b0;
cosf = 0x803347d0;
sinf = 0x80334964;
__sinit_trigf_c = 0x80334b08;
powf = 0x80334b38;
expf = 0x80335278;
memset = 0x80003100;
__fill_mem = 0x80003130;
memcpy = 0x800031f4;
__nw__FUl = 0x802bbc38;
__nw__FUli = 0x802bbc80;
__nwa__FUl = 0x802bbd38;
__nwa__FUli = 0x802bbd80;
__dl__FPv = 0x802bbe38;
__dla__FPv = 0x802bbe9c;
SECTIONS
{
. = 0x817fa000;
.text :
{
*(.text)
}
.rodata :
{
*(.rodata*)
}
.data :
{
*(.data)
}
. += 0x08;
.sdata :
{
*(.sdata)
}
}

101930
ports/pal/marioEU.map Normal file

File diff suppressed because it is too large Load diff

13
ports/pal/patchdol.bat Normal file
View file

@ -0,0 +1,13 @@
C:\devkitPro\devkitPPC\bin\powerpc-eabi-gcc.exe %1 -S -o %~n1.s -O1 -std=c99 -w
C:\devkitPro\devkitPPC\bin\powerpc-eabi-gcc.exe %1 -c -o %~n1.o -O1 -std=c99 -w
if ERRORLEVEL 1 pause
if ERRORLEVEL 1 exit
C:\devkitPro\devkitPPC\bin\powerpc-eabi-ld.exe -Os -T dollinkerEU -T smsFuncsEU -o obj_%~n1.o %~n1.o -Map %~n1.map
if ERRORLEVEL 1 pause
if ERRORLEVEL 1 exit
C:\devkitPro\devkitPPC\bin\powerpc-eabi-objdump.exe obj_%~n1.o --full-content
if ERRORLEVEL 1 pause
if ERRORLEVEL 1 exit
C:\devkitPro\devkitPPC\bin\powerpc-eabi-objcopy.exe obj_%~n1.o %~n1.bin -O binary -R .eh_frame -R .comment -R .gnu.attributes -g -S
DolInsert.exe %~n1.bin -m %~n1.map -dol ./Start.dol -o %~n1.dol -c OnUpdate:0x8029e070:3 -c OnSetup:0x80291750:0 -c OnDraw2D:0x80138b50:0 -c OnWaterHitsGround:0x80277568:0 -c OnObjectTouchMario:0x801a81b4:3 -c OnAllNPCsUpdate:0x8003e140:0 -c OnSmallEnemyHitMario:0x80065e0c:3 -r EMarioControl:0x8003ff5c -r IsMario:0x80245898 -r EMarioReceiveMessage:0x80039624 -r MarioSendMessage:0x8026b5fc -r EMarioPlayerControl:0x8003febc -c OnMarioIncHP:0x8027ac6c:0x8027ac90:0x8027ad10:0x8027b1a0:0x8027b21c:0x8027b260:0 -c OnMarioDecHP:0x8023a89c:0 -r EMarioDamageExec:0x8003feb8 -r IsMultiplayerMap:0x802a0bd8
pause

546
ports/pal/sms.h Normal file
View file

@ -0,0 +1,546 @@
#ifndef SMS_H
#define SMS_H
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
#define PRESS_START 0x1000
#define PRESS_B 0x0200
#define PRESS_A 0x0100
#define PRESS_Z 0x0010
#define PRESS_X 0x0400
#define PRESS_Y 0x0800
#define PRESS_DU 0x0008
#define PRESS_DD 0x0004
#define PRESS_DL 0x0001
#define PRESS_DR 0x0002
#define MARIOFLAG_ALIVE 0x00000001
#define MARIOFLAG_INVISIBLE 0x00000004
#define MARIOFLAG_ALLDEAD 0x00000F00
#define MARIOFLAG_GAMEOVER 0x00000400
#define MARIOFLAG_SLIP 0x00000080
#define MARIOFLAG_HASHELMET_FOLLOWCAMERA 0x00001000
#define MARIOFLAG_HASHELMET 0x00002000
#define MARIOFLAG_HASFLUDD 0x00008000
#define MARIOFLAG_SPLASH 0x00010000
#define MARIOFLAG_PUDDLE 0x00020000
#define MARIOFLAG_SHIRT 0x00100000
#define MARIOFLAG_GONE 0x00200000
#define STATE_NUMBER 0x0000000F
#define STATE_AIRBORN 0x00000800
#define STATE_CUTSCENE 0x00001000
#define STATE_STUNNED 0x00002000
#define STATE_RUNNING 0x04000440
#define STATE_IDLE 0x0C400200
#define STATE_SPIN 0x00000441
#define STATE_JUMPSPIN1 0x00000895
#define STATE_JUMPSPIN2 0x00000896
#define STATE_JUMP 0x02000880
#define STATE_JUMPSIDE 0x00000880
#define STATE_SIDESTEP 0x0C008220
#define STATE_SWIM 0x000024D7
#define STATE_DIVE 0x0080088A
#define STATE_DIVEJUMP 0x02000889
#define STATE_DIVESLIDE 0x00800456
#define STATE_CLIMB 0x18100340
#define STATE_CLIMBUP 0x10100343
#define STATE_WALLJUMP 0x02000886
#define STATE_WALLSLIDE 0x000008A7
#define STATE_HANG 0x3800034B
#define STATE_HANGCLIMB 0x3000054F
#define STATE_SLAMSTART 0x008008A9
#define STATE_SLAM 0x0080023C
#define STATE_SPRAY 0x0C008220
#define STATE_THROWN 0x000208B8
#define STATE_HOVER 0x0000088B
#define STATE_STUCK 0x0002033C
#define STATE_TALKING 0x10001308
typedef struct{
uint16_t buttons;
int8_t lanalogx;
int8_t lanalogy;
int8_t ranalogx;
int8_t ranalogy;
uint16_t u1;
uint8_t status;
uint8_t u2;
uint8_t u3;
uint8_t u4;
} __attribute__((packed)) Controller;
typedef struct{
void* type;
void* u1[55];
int u2;
int u3[7];
} MarioGamePad;
// MarDirector* mardirector = (MarDirector*)(r13 + 0x9FB8)
typedef struct{
int u1;
} MarDirector;
typedef struct{
float x;
float y;
float z;
} Vector;
typedef struct{
void* Type;
void* u2;
int u3;
int u4;
Vector position;
int u5;
void* u6;
Vector scale;
Vector direction;
void* u7;
void* u8;
void* u9;
int u10;
int collision;
float u12;
float u13;
float u14;
float u15;
float u16;
int u17;
int u18;
int u19;
void* u20;
} HitActor;
typedef struct{
void* Type; //0
void* u2;
int u3;
int u4;
Vector position; //10
int u5;
void* u6; //20
Vector scale;
Vector direction; //30
void* u7;
void* u8; //40
void* collist;
uint16_t colcount;
uint16_t u9;
int colsettings;
float u12; //50
float u13;
float u14;
float u15;
float u16; //60
int u17;
int u18;
int u19;
void* u20; //70
int u21;
int u22;
uint32_t status;
uint32_t laststatus;//80
int statustime;
void* u23[36]; //88
int flags; //118
void* u24[64];
char name[16]; //218
void* u25[180]; //228
MarioGamePad* gamepad; //4fc
} MarioActor;
struct EMario_t;
struct EnemyMario_t;
typedef struct EnemyMario_t{
void* Type; //0
void* u2;
int u3;
int u4;
Vector position; //10
int u5;
void* u6; //20
Vector scale;
Vector direction; //30
void* u7;
void* u8; //40
void* collist;
uint16_t colcount;
uint16_t u9;
int colsettings;
float u12; //50
float u13;
float u14;
float u15;
float u16; //60
int u17;
int u18;
int u19;
void* u20; //70
int u21;
int u22;
uint32_t status;
uint32_t laststatus;//80
int statustime;
void* u23[36]; //88
int flags; //118
void* u24[64];
char name[16]; //218
void* u25[180]; //228
MarioGamePad* gamepad; //4fc
void* u26[3940];
uint16_t emarioflags;
uint16_t emariodamage; //4294
uint16_t emariohealth; //4296
uint16_t u27; //4298
int u28;
int u29;
struct EMario_t* emario;
int u30;
int u31;
float u32;
float u33;
uint16_t u34;
uint16_t u35;
uint16_t u36;
uint16_t hpmetertimer;
} __attribute__((packed)) EnemyMario;
typedef struct EMario_t{
void* Type; //0
void* u2;
int u3;
int u4;
Vector position; //10
int u5;
void* u6; //20
Vector scale;
Vector direction; //30
void* u7;
void* u8; //40
void* collist;
uint16_t colcount;
uint16_t u9;
int colsettings;
float u12; //50
float u13;
float u14;
float u15;
float u16; //60
int u17;
int u18;
int u19;
void* u20; //70
void* u21[55];
EnemyMario* enemymario;
} __attribute__((packed)) EMario;
#define ITEMFLAG_STATIC 0x00000010
typedef struct{
void* Type;
void* u2;
int u3;
int u4;
Vector position;
int u5;
void* u6;
Vector scale;
Vector direction;
void* u7;
void* u8;
void* u9;
int u10;
int itemtype;
float u12;
float u13;
float u14;
float u15;
float u16;
int u17;
int u18;
int u19;
void* u20;
//0x74
int pad1[14];
Vector velocity;
int pad2[14];
int flags;
} ItemActor;
typedef struct {
int u1;
float u2;
} Sound;
typedef struct {
int x1;
int y1;
int x2;
int y2;
} JUTRect;
typedef struct {
void* type;
int content[64];
} J2DGrafContext;
typedef struct {
void* type;
int content[64];
} J2DOrthoGraph;
typedef struct {
void* type;
int content[9];
} J2DPrint;
typedef struct {
void* type;
} JUTResFont;
typedef struct {
} ResFONT;
typedef struct {
void* type;
int pad1[2];
int flags;
JUTRect bounds;
int content[100];
} J2DTextBox;
typedef struct {
void* type;
int content[64];
} J2DPane;
typedef struct {
void* type;
int content[64];
} J2DScreen;
typedef struct {
void* type;
} Talk2D;
typedef struct {
void* type;
} GCConsole;
typedef struct {
void* type;
} PollutionManager;
typedef struct {
void* type;
} ItemManager;
typedef struct {
void* type;
void* u1;
int flags1;
int flags2;
int timer;
} TrembleModelEffect;
typedef struct {
float a1[4];
float a2[4];
float a3[4];
} A3_A4_f;
//For C++ inheritence
#define GetObjectFunction( object, func ) (void*)*(void**)((int)*(int*)object + func)
#define Director_GameUpdate 0x64
#define HitActor_TouchPlayer 0x0148
#define HitActor_ReceiveMessage 0xA0
//Free is done automatically on stage transition
#define malloc(n) __nwa__FUl((n))
#define free(n) __dla__FUl((n))
void GXSetScissor(int x, int y, int x2, int y2);
void GXInvalidateTexAll();
void J2DOrthoGraph_Create(J2DOrthoGraph* targetaddr, JUTRect* view);
void J2DGrafContext_Setup2D(J2DGrafContext* graphics);
void J2DPrint_Create(J2DPrint* targetaddr, JUTResFont* font, int u);
float J2DPrint_GetWidth(J2DPrint* j2dprint, char* text);
void J2DPrint_Initiate(J2DPrint* j2dprint);
void J2DPrint_Print(J2DPrint* j2dprint, int x, int y, char* text, int u1, int u2, int u3);
void J2DPrint_Delete(J2DPrint* j2dprint, int mask);
#define GameFont (*(ResFONT**)((*(int*)(SceneReference - 0x6110)) + 0x48))
#define GameStrTable (RTOC - 0x4BC4)
void J2DTextBox_Create(J2DTextBox* targetaddr, int u1, JUTRect* bounds, ResFONT* font, void* table, int HBinding, int VBinding);
void J2DTextBox_Draw(J2DTextBox* textbox);
void J2DTextBox_Drawii(J2DTextBox* textbox, int a1, int a2);
void J2DTextBox_DrawSelf(J2DTextBox* textbox, int a1, int a2, A3_A4_f* matrix);
void J2DTextBox_SetString(J2DTextBox* textbox, char* string);
char* J2DTextBox_GetStringPtr(J2DTextBox* textbox);
void J2DTextBox_Delete(J2DTextBox* textbox);
void J2DPane_Draw(J2DPane* pane, int a1, int a2, J2DGrafContext* graphics, int a3);
void J2DPane_SetBasePosition(J2DPane* pane, int pos);
void J2DPane_MakeMatrix(J2DPane* pane, int a1, int a2);
void J2DScreen_Draw(J2DScreen* pane, int a1, int a2, J2DGrafContext* graphics, int a3);
void JUTRect_Set(JUTRect* rect, int x, int y, int w, int h);
void MarDirector_SetupObjects(MarDirector* director);
void Drama_PrepareUpdate(HitActor* this, int a1, void* drama, void* graphics, int obj);
/*
typedef ObjItemManager{
int a1;
int a2;
void (*__dt__)();
void (*GetType)();
void (*Load)();
void (*Save)();
void (*LoadAfter)();
void (*SearchF)();
void (*Perform)();
void (*CreateModelData)();
void (*CreateModelData)();
void (*CreateAnmData)();
void (*CreateModelDataArray)();
void (*ClipActors)();
void (*SetFlagOutOfCube)();
void (*CreateSpcBinary)();
bool (*HasMapCollision)();
}*/
register void* RTOC __asm ("r2");
register void* SceneReference __asm ("r13");
// GC
//static void (*GXSetBlendMode)(int a1, int a2, int a3, int a4) = (void*)0x80359ff0;
//static void (*GXBegin)(int a1, int a2, int a3) = (void*)0x803561a8;
static const Controller* Controllers = (Controller*)0x803fbbf4;
static const Controller* ControllerOne = (Controller*)0x803fbbf4;
static const Controller* ControllerTwo = (Controller*)0x803fbc00;
static const Controller* ControllerThree = (Controller*)0x803fbc0c;
static const Controller* ControllerFour = (Controller*)0x803fbc18;
static MarioGamePad* GamePads = (MarioGamePad*)0x8056f2ec;
static MarioGamePad* GamePadOne = (MarioGamePad*)0x8056f2ec;
static MarioGamePad* GamePadTwo = (MarioGamePad*)0x8056f3ec;
static MarioGamePad* GamePadThree = (MarioGamePad*)0x8056f4ec;
static MarioGamePad* GamePadFour = (MarioGamePad*)0x8056f5ec;
void MarioGamePad_Read();
void MarioGamePad_Update(MarioGamePad* pad);
void MarioGamePad_Reset(MarioGamePad* pad);
static void* gpSystemFont = (void*)0x80405850;
static void* gpRomFont = (void*)0x80405854;
// SMS
static void* gpApplication = (void*)0x803e10c0;
static Talk2D** TalkManager = (Talk2D**)0x80405458;
unsigned int CalcKeyCode(char* key);
void Vector_Add(Vector* v1, Vector* v2, Vector* vo);
void Vector_Subtract(Vector* v1, Vector* v2);
void Vector_Normalize(Vector* vi, Vector* vo);
void Vector_Scale(Vector* vi, float scale);
float Vector_Magnitude(Vector* v);
void Talk2D_OpenWindow(Talk2D* talkmanager, int a1, float f1);
void DrawWaterBackground(GCConsole* console);
void StampPollution(PollutionManager* pollution, int stamp, float x, float y, float z, float r);
void CleanPollution(PollutionManager* pollution, float x, float y, float z, float r);
// Stage
static MarDirector** gpMarDirector = (void*)0x80405840;
static void** gpItemManager = (void**)0x804055d8;
static void** gpMap = (void*)0x80405560;
static PollutionManager** gpPollution = (void*)0x80405598;
static void** gpStrategy = (void*)0x80405748;
static void** gpSunManager = (void*)0x80404820;
static HitActor** gpSunModel = (void*)0x80404828;
static uint8_t* ChangeScenario = (void*)0x003e9712;
static uint8_t* ChangeEpisode = (void*)0x003e9713;
void ChangeStage(MarDirector* director, uint32_t stageinfo);
HitActor* SearchF(void* namereflist, int keycode, char* ref);
#define SearchObjByRef(ref) SearchF((void*)*(((int*)*(int*)(SceneReference - 0x5e80)) + 1), CalcKeyCode((ref)), (ref))
int GetShineStage(uint8_t stageid);
int IsPolluted(void);
//Camera
static HitActor** gpCamera = (void*)0x80404808;
void Camera_AddMultiPlayer(void* camera, Vector* position);
void Camera_RemoveMultiPlayer(void* camera, Vector* position);
void Camera_CreateMultiPlayer(void* camera, unsigned char players);
// Mario
static HitActor** gpMarioOriginal = (void*)0x804057b0;
static HitActor** gpMarioAddress = (void*)0x804057d0;
#define GetFludd(mario) (HitActor*)((mario) + 0x03E4)
static Vector** gpMarioPos = (void*)0x804057d4;
static float** gpMarioAngleX = (void*)0x804057d8;
static float** gpMarioAngleY = (void*)0x804057dc;
static float** gpMarioAngleZ = (void*)0x804057e0;
static float** gpMarioSpeedX = (void*)0x804057e4;
static float** gpMarioSpeedY = (void*)0x804057e8;
static float** gpMarioSpeedZ = (void*)0x804057ec;
static const uint16_t** gpMarioLightID = (void*)0x804057f0;
static int** gpMarioFlag = (void*)0x804057f4;
static float** gpMarioThrowPower = (void*)0x804057f8;
static const void*** gpMarioGroundPlane = (void*)0x804057fc;
MarioActor* GetMarioHitActor();
HitActor* GetFLUDD();
HitActor* GetMarioYoshi();
int GetMarioHP();
int GetMarioStatus();
int GetMarioStatusFromHitActor(MarioActor* mario);
void IncGoldCoinFlag(uint32_t coinptr, int stage, int amount);
#define IncrementCoin(amount) incGoldCoinFlag(*(int*)(SceneReference - 0x6138), GetShineStage((*(int*)(gpApplication + 0x0E)) & 0xFF), (amount))
void GetMarioMapPosition();
void ThrowMario(void*, void*, float, float, float);
void SetMarioAnim(float a1, int a2, int a3);
int IsMarioJumping();
void SetMarioStatus(MarioActor* mario, int a2, int a3, int a4);
#define MarioDoJump(mario) SetMarioStatus((mario), 0x02000881, 0, 0)
#define MarioDoThrow(mario) SetMarioStatus((mario), 0x000208B8, 0, 0)
void EmitSweat(MarioActor* mario);
void Fludd_Emit(HitActor* fludd);
void Mario_StartVoice(MarioActor* mario, int id);
void Mario_SetGamePad(MarioActor* mario, MarioGamePad* gamepad);
void Mario_CheckController(HitActor* mario, void* drama, void* graphics);
void Mario_ReceiveMessage(MarioActor* mario, HitActor* other, unsigned long message);
void Mario_PlayerControl(MarioActor* mario, void* drama, void* graphics);
void Mario_CheckCollision(MarioActor* mario);
void Mario_DamageExec(MarioActor* mario, HitActor* other, int u1, int u2, int u3, float f1, int u4, float f2, short u5);
void Mario_IncHP(MarioActor* mario, int n);
void Mario_DecHP(MarioActor* mario, int n);
void EnemyMario_CheckController(HitActor* enemymario, void* drama, void* graphics);
void SetMarioVelocity(MarioActor* mario, float vel);
void StartTrembleEffect(TrembleModelEffect* effectmgr, float maxTremble, float minTremble, float damp, int timer);
void Mario_WearGlasses(MarioActor* mario);
#define GetMarioTrembleEffect(mario) ((TrembleModelEffect*)*((void**)(mario) + 0x014F))
#define MARIOMSG_THROW 0x07
#define MARIOMSG_HURTFIRE 0x0a
#define MARIOMSG_HURT 0x0e
void SendMsgToMario(MarioActor* mario, int msg);
// Objects
#define OBJ_WATER 0x20000002
#define OBJ_ONEUP 0x20000006
#define OBJ_COIN 0x2000000E
#define OBJ_BLUECOIN 0x20000010
#define OBJ_ROCKETNOZZLE 0x20000022
#define OBJ_HOVERNOZZLE 0x20000026
#define OBJ_TURBONOZZLE 0x2000002A
HitActor* MakeObjAppear(ItemManager* itemManager, int id);
// Effects
void GenerateEffectElectric(HitActor* pos);
// Music / SFX
void PlaySound(int rate, Sound* sfx, int nl1, int nl2, int nl3, int four);
void StartStageEntranceDemoSeq(int u1, int u2);
void StartBGM(int u1);
void StopBGM(int u1);
#endif

77
ports/pal/smsFuncs Normal file
View file

@ -0,0 +1,77 @@
MarDirector_SetupObjects = 0x802af6c4;
PlaySound = 0x80018a30;
StartStageEntranceDemoSeq = 0x802b3850;
GenerateEffectElectric = 0x8025aba4;
MakeObjAppear = 0x801aecf4;
SendMsgToMario = 0x8026b5fc;
EmitSweat = 0x8025c3e8;
Mario_StartVoice = 0x8027d108;
Fludd_Emit = 0x80260d24;
SetMarioStatus = 0x8024bdc0;
IsMarioJumping = 0x8026b740;
Mario_SetAnim = 0x8023f3fc;
ThrowMario = 0x8024bf8c;
GetMarioMapPosition = 0x8007070c;
IncGoldCoinFlag = 0x8028c428;
GetMarioStatusFromHitActor = 0x8026b3d4;
GetMarioStatus = 0x8026b400;
GetMarioHP = 0x8026b67c;
GetMarioYoshi = 0x8026b78c;
GetFLUDD = 0x8026b64c;
GetMarioHitActor = 0x8026b760;
GetShineStage = 0x802a0b70;
SearchF = 0x802f2954;
ChangeStage = 0x802921b4;
DrawWaterBackground = 0x8013df34;
Talk2D_OpenWindow = 0x801451a4;
Vector_Magnitude = 0x80222368;
Vector_Normalize = 0x80222390;
Vector_Subtract = 0x80010cfc;
Vector_Add = 0x803427c8;
Vector_Scale = 0x80342810;
CalcKeyCode = 0x802f2680;
JUTRect_Set = 0x802c2274;
J2DScreen_Draw = 0x802c7f50;
J2DPane_MakeMatrix = 0x802c3c90;
J2DPane_SetBasePosition = 0x802c3ee8;
J2DPane_Draw = 0x802c3768;
J2DTextBox_Delete = 0x802c8bbc;
J2DTextBox_GetStringPtr = 0x802c8e08;
J2DTextBox_SetString = 0x802c8e10;
J2DTextBox_DrawSelf = 0x802c8f80;
J2DTextBox_Drawii = 0x802c8cd0;
J2DTextBox_Draw = 0x802c8cd0;
J2DTextBox_Create = 0x802c89f0;
J2DPrint_Delete = 0x802c5e04;
J2DPrint_Print = 0x802c6180;
J2DPrint_Initiate = 0x802c5e50;
J2DPrint_GetWidth = 0x802c643c;
J2DPrint_Create = 0x802c5d10;
J2DGrafContext_Setup2D = 0x802e3864;
J2DOrthoGraph_Create = 0x802e5174;
GXInvalidateTexAll = 0x80358620;
GXSetScissor = 0x8035b358;
StampPollution = 0x8019670c;
CleanPollution = 0x8019663c;
Drama_PrepareUpdate = 0x802f4e24;
StartTrembleEffect = 0x8021ef1c;
SetMarioVelocity = 0x8024d4c0;
Mario_SetGamePad = 0x8026e378;
MarioGamePad_Read = 0x802a00fc;
MarioGamePad_Update = 0x802a0188;
MarioGamePad_Reset = 0x802a0a24;
EMario_Create = 0x80039c68;
Mario_CheckController = 0x80249220;
Mario_CheckCollision = 0x80278d74;
Mario_ReceiveMessage = 0x8027a880;
Mario_PlayerControl = 0x80245bc4;
Mario_DamageExec = 0x8023a598;
Mario_IncHP = 0x8023b6b4;
Mario_DecHP = 0x8023b5b4;
EnemyMario_CheckController = 0x8003ff5c;
Camera_AddMultiPlayer = 0x80030d78;
Camera_RemoveMultiPlayer = 0x80030ce0;
Camera_CreateMultiPlayer = 0x80030dd4;
Mario_DrawHP = 0x8003fc14;
IsPolluted = 0x80199b70;
Mario_WearGlasses = 0x8023fd30;

View file

@ -1,7 +1,7 @@
MarDirector_SetupObjects = 0x802b76f4;
PlaySound = 0x800189d4;
StartStageEntranceDemoSeq = 0x802bb880;
GenerateEffectElectric = 0x80262E18;
GenerateEffectElectric = 0x80262e18;
MakeObjAppear = 0x801b6e3c;
SendMsgToMario = 0x80273870;
EmitSweat = 0x8026465c;
@ -10,19 +10,19 @@ Fludd_Emit = 0x80268f98;
SetMarioStatus = 0x80254034;
IsMarioJumping = 0x802739b4;
Mario_SetAnim = 0x80247670;
ThrowMario = 0x8007706c;
ThrowMario = 0x80254200;
GetMarioMapPosition = 0x8007706c;
IncGoldCoinFlag = 0x80294610;
GetMarioStatusFromHitActor = 0x80273648;
GetMarioStatus = 0x802738f0;
GetMarioHP = 0x80273674;
GetMarioStatus = 0x80273674;
GetMarioHP = 0x802738f0;
GetMarioYoshi = 0x80273a00;
GetFLUDD = 0x802738c0;
GetMarioHitActor = 0x802739d4;
GetShineStage = 0x802a8ac8;
SearchF = 0x802fa7ac;
ChangeStage = 0x8029a31c;
DrawWaterBackground = 0x801492A4;
DrawWaterBackground = 0x801492a4;
Talk2D_OpenWindow = 0x80150514;
Vector_Magnitude = 0x8022a414;
Vector_Normalize = 0x8022a43c;