Skip to content

Commit

Permalink
Match Gecko_ExceptionPPC
Browse files Browse the repository at this point in the history
  • Loading branch information
DeathHound6 committed Nov 4, 2024
1 parent 4beca33 commit 9d9cabf
Show file tree
Hide file tree
Showing 8 changed files with 518 additions and 53 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This will also generate `.s` (assembly) files inside the `build/[GAME ID]/asm` f
- Write C++ code that creates matching assembly code
- Use the following string as the build flags
- Compiler `4.3 build 188 (Wii MW 1.5)`
- `-O2,p -lang=c++ -RTTI off -enum int -fp hard -enc SJIS -fp_contract on -str reuse -inline auto -use_lmw_stmw on`
- `-O4,s -lang=c++ -RTTI off -enum int -fp hard -enc SJIS -fp_contract on -str reuse -inline auto -use_lmw_stmw on`
- When placing the function or variable into this repository, mark in a comment the address of the symbol
- For example `// symbol 0x80395304`

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ Select an object from the left sidebar to begin diffing. Changes to the project
## References
- [Decomp Toolkit](https://github.com/encounter/dtk-template) (repo template)
- [Dolphin 2001 SDK](https://github.com/doldecomp/dolsdk2001)
- [MSL Runtime](https://github.com/projectPiki/pikmin2/blob/main/src/Dolphin/Runtime) (From Pikmin 2 Decomp)
- Alice uses Revolution SDK of a currently unknown version or release, however, dolsdk can be used as a basis
71 changes: 37 additions & 34 deletions config/SALP4Q/splits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,51 +13,54 @@ Sections:
.sdata2 type:rodata align:16
.sbss2 type:bss align:32

PowerPC_EABI_Support/Runtime/global_destructor_chain.c:
.text start:0x80368C58 end:0x80394124
Revolution/OS/__start.c:
.init start:0x80004000 end:0x80006618

PowerPC_EABI_Support/Runtime/__init_cpp_exceptions.cpp:
.text start:0x80395304 end:0x80395374
.ctors start:0x804D3540 end:0x804D3544 rename:.ctors$10
.dtors start:0x804D41E0 end:0x804D41E4 rename:.dtors$10
.dtors start:0x804D41E4 end:0x804D41E8 rename:.dtors$15
.sdata start:0x805F3828 end:0x805F3830
Alice/Objects/Groups/CKGrpAliceHero.cpp:
.text start:0x8000DBF0 end:0x8000E264

PowerPC_EABI_Support/Runtime/Gecko_ExceptionPPC.cpp:
.text start:0x80395374 end:0x80395480
Alice/Objects/Hooks/CKHkAliceHero.cpp:
.text start:0x8001D894 end:0x8001E9E8

Alice/Objects/0Managers/CKSoundManager.cpp:
.text start:0x802BA0DC end:0x802BAEA0
Alice/Objects/Components/CKAliceHeroConfig.cpp:
.text start:0x800539D4 end:0x80055528

Alice/Objects/1Services/CKSrvTrigger.cpp:
.text start:0x8022CE90 end:0x8022D744
Alice/Objects/Logic/CKAliceGameSpawnPoint.cpp:
.text start:0x800EEFBC end:0x800EF814

Alice/Objects/2Hooks/CKHkAliceHero.cpp:
.text start:0x8001D894 end:0x8001E9E8
Alice/Objects/Geometries/CSkinGeometry.cpp:
.text start:0x801DB1A8 end:0x801DB6D8

Alice/Objects/4Groups/CKGrpAliceHero.cpp:
.text start:0x8000DBF0 end:0x8000E264
Alice/Objects/Graphics/CLightManager.cpp:
.text start:0x801E3D88 end:0x801E76B4

Alice/Objects/6Components/CKAliceHeroConfig.cpp:
.text start:0x800539D4 end:0x80055528
Alice/Objects/Nodes/CSpawnNode.cpp:
.text start:0x80211C1C end:0x80212060

Alice/Objects/7Camera/CKCameraFixTrack.cpp:
.text start:0x80238574 end:0x802388B4
Alice/Objects/Services/CKSrvTrigger.cpp:
.text start:0x8022CE90 end:0x8022D744

Alice/Objects/8Cinematics/CKStartDoor.cpp:
.text start:0x80266000 end:0x802662AC
Alice/Objects/Camera/CKCameraFixTrack.cpp:
.text start:0x80238574 end:0x802388B4

Alice/Objects/9Dictionaries/CKSoundDictionary.cpp:
.text start:0x802B9360 end:0x802B9A70
Alice/Objects/Cinematics/CKStartDoor.cpp:
.text start:0x80266000 end:0x802662AC

Alice/Objects/10Geometries/CSkinGeometry.cpp:
.text start:0x801DB1A8 end:0x801DB6D8
Alice/Objects/Dictionaries/CKSoundDictionary.cpp:
.text start:0x802B9360 end:0x802B9A70

Alice/Objects/11Nodes/CSpawnNode.cpp:
.text start:0x80211C1C end:0x80212060
Alice/Objects/Managers/CKSoundManager.cpp:
.text start:0x802BA0DC end:0x802BAEA0

Alice/Objects/12Logic/CKAliceGameSpawnPoint.cpp:
.text start:0x800EEFBC end:0x800EF814
PowerPC_EABI_Support/Runtime/global_destructor_chain.c:
.text start:0x80368C58 end:0x80394124

PowerPC_EABI_Support/Runtime/__init_cpp_exceptions.cpp:
.text start:0x80395304 end:0x80395374
.ctors start:0x804D3540 end:0x804D3544 rename:.ctors$10
.dtors start:0x804D41E0 end:0x804D41E4 rename:.dtors$10
.dtors start:0x804D41E4 end:0x804D41E8 rename:.dtors$15
.sdata start:0x805F3828 end:0x805F3830

Alice/Objects/13Graphics/CLightManager.cpp:
.text start:0x801E3D88 end:0x801E76B4
PowerPC_EABI_Support/Runtime/Gecko_ExceptionPPC.cpp:
.text start:0x80395374 end:0x80395480
37 changes: 33 additions & 4 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
"-fp hardware",
"-Cpp_exceptions off",
# "-W all",
"-O4,p",
"-O4,s",
"-inline auto",
'-pragma "cats off"',
'-pragma "warn_notinlined off"',
Expand Down Expand Up @@ -244,7 +244,7 @@ def MatchingFor(*versions):
config.warn_missing_source = False
config.libs = [
{
"lib": "PowerPC_EABI_Support",
"lib": "PowerPC_EABI_Support/Runtime",
"mw_version": config.linker_version,
"cflags": cflags_runtime,
"host": False,
Expand All @@ -255,6 +255,22 @@ def MatchingFor(*versions):
Object(MatchingFor(), "PowerPC_EABI_Support/Runtime/global_destructor_chain.c")
],
},
{
"lib": "PowerPC_EABI_Support/MSL",
"mw_version": config.linker_version,
"cflags": cflags_runtime,
"host": False,
"progress_category": "sdk", # str | List[str]
"objects": [],
},
{
"lib": "PowerPC_EABI_Support/MetroTRK",
"mw_version": config.linker_version,
"cflags": cflags_runtime,
"host": False,
"progress_category": "sdk", # str | List[str]
"objects": [],
},
{
"lib": "Revolution",
"mw_version": config.linker_version,
Expand All @@ -268,10 +284,23 @@ def MatchingFor(*versions):
{
"lib": "Alice",
"mw_version": config.linker_version,
"cflags": cflags_runtime,
"cflags": cflags_base,
"host": False,
"progress_category": "game", # str | List[str]
"objects": [],
"objects": [
Object(MatchingFor(), "Alice/Objects/Managers/CKSoundManager.cpp"),
Object(MatchingFor(), "Alice/Objects/Services/CKSrvTrigger.cpp"),
Object(MatchingFor(), "Alice/Objects/Hooks/CKHkAliceHero.cpp"),
Object(MatchingFor(), "Alice/Objects/Groups/CKGrpAliceHero.cpp"),
Object(MatchingFor(), "Alice/Objects/Components/CKAliceHeroConfig.cpp"),
Object(MatchingFor(), "Alice/Objects/Camera/CKCameraFixTrack.cpp"),
Object(MatchingFor(), "Alice/Objects/Cinematics/CKStartDoor.cpp"),
Object(MatchingFor(), "Alice/Objects/Dictionaries/CKSoundDictionary.cpp"),
Object(MatchingFor(), "Alice/Objects/Geometries/CSkinGeometry.cpp"),
Object(MatchingFor(), "Alice/Objects/Nodes/CSpawnNode.cpp"),
Object(MatchingFor(), "Alice/Objects/Logic/CKAliceGameSpawnPoint.cpp"),
Object(MatchingFor(), "Alice/Objects/Graphics/CLightManager.cpp")
],
}
]

Expand Down
8 changes: 4 additions & 4 deletions include/PowerPC_EABI_Support/Runtime/Gecko_ExceptionPPC.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "types.h"
#include "PowerPC_EABI_Support/Runtime/__ppc_eabi_linker.h"
#define MAXFRAGMENTS 1
#define MAXFRAGMENTS 0x1F

typedef struct ExceptionTableIndex {
u32 functionoffset;
Expand All @@ -25,11 +25,11 @@
typedef struct ProcessInfo {
__eti_init_info* exception_info;
char* TOC;
s32 active;
u32 active;
} ProcessInfo;

s32 __register_fragment(struct __eti_init_info*, char*);
void __unregister_fragment(s32);
u32 __register_fragment(struct __eti_init_info*, char*);
void __unregister_fragment(u32);
s32 ExPPC_FindExceptionFragment(char*, FragmentInfo*);

#endif
89 changes: 89 additions & 0 deletions include/Revolution/OS/__ppc_eabi_init.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#ifndef RVL_SDK_OS_PPC_EABI_INIT_H
#define RVL_SDK_OS_PPC_EABI_INIT_H
#include "global.h"
#ifdef __cplusplus
extern "C" {
#endif

#pragma section ".init"
DECL_SECTION(".init") void __init_hardware(void);
// DECL_SECTION(".init") void __flush_cache(void*, size_t);

s32 main(s32 argc, char** argv);
void __init_user(void);
void __init_cpp(void);
void __fini_cpp(void);
DECL_WEAK void exit(void);
void _ExitProcess(void);

// Declare linker symbols for a section in the ROM
#define DECL_ROM_SECTION(x) \
extern u8 _f##x[]; \
extern u8 _f##x##_rom[]; \
extern u8 _e##x[];

// Declare linker symbols for a BSS section
#define DECL_BSS_SECTION(x) \
extern u8 _f##x[]; \
extern u8 _e##x[];

// Debugger stack
extern u8 _db_stack_addr[];
extern u8 _db_stack_end[];

// Program arena
extern u8 __ArenaLo[];
extern u8 __ArenaHi[];

// Program stack
extern u8 _stack_addr[];
extern u8 _stack_end[];

// Small data bases
extern u8 _SDA_BASE_[];
extern u8 _SDA2_BASE_[];

// ROM sections
DECL_ROM_SECTION(_init);
DECL_ROM_SECTION(extab);
DECL_ROM_SECTION(extabindex);
DECL_ROM_SECTION(_text);
DECL_ROM_SECTION(_ctors);
DECL_ROM_SECTION(_dtors);
DECL_ROM_SECTION(_rodata);
DECL_ROM_SECTION(_data);
DECL_ROM_SECTION(_sdata);
DECL_ROM_SECTION(_sdata2);
DECL_ROM_SECTION(_stack);

// BSS sections
DECL_BSS_SECTION(_bss);
DECL_BSS_SECTION(_sbss);
DECL_BSS_SECTION(_sbss2);

// typedef struct RomSection {
// void* phys; // at 0x4
// void* virt; // at 0x0
// size_t size; // at 0x8
// } RomSection;

// typedef struct BssSection {
// void* virt; // at 0x0
// size_t size; // at 0x8
// } BssSection;

typedef struct ExtabIndexInfo {
void* section; // at 0x0
struct ExtabIndexInfo* extab; // at 0x4
void* codeStart; // at 0x8
u32 codeSize; // at 0xC
} ExtabIndexInfo;

// DECL_SECTION(".init") extern const RomSection _rom_copy_info[];
// DECL_SECTION(".init") extern const BssSection _bss_init_info[];
DECL_SECTION(".init") extern const ExtabIndexInfo _eti_init_info[];

#ifdef __cplusplus
}
#endif
#endif
16 changes: 7 additions & 9 deletions src/PowerPC_EABI_Support/Runtime/Gecko_ExceptionPPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,26 @@

extern ProcessInfo fragment_info[MAXFRAGMENTS];

s32 __register_fragment(struct __eti_init_info* info, char* TOC)
#pragma schedule once
u32 __register_fragment(struct __eti_init_info* info, char* TOC)
{
ProcessInfo* f = fragment_info;
s32 i;

for (i = 0; i < MAXFRAGMENTS; i++, f++) {
for (u32 i = 0; i < MAXFRAGMENTS+1; i++, f++) {
if (f->active == 0) {
f->exception_info = info;
f->TOC = TOC;
f->active = 1;
return i;
}
}

return -1;
}
#pragma schedule twice

void __unregister_fragment(s32 fragmentID)
void __unregister_fragment(u32 fragmentID)
{
ProcessInfo* f;
if (fragmentID >= 0 && fragmentID < MAXFRAGMENTS) {
if (fragmentID >= 0 && fragmentID <= MAXFRAGMENTS) {
f = &fragment_info[fragmentID];
f->exception_info = 0;
f->TOC = 0;
Expand All @@ -37,7 +36,7 @@ s32 ExPPC_FindExceptionFragment(char* returnaddr, FragmentInfo* frag)
s32 i;
__eti_init_info* eti_info;

for (i = 0, f = fragment_info; i < MAXFRAGMENTS; ++i, ++f) {
for (i = 0, f = fragment_info; i < MAXFRAGMENTS+1; ++i, ++f) {
if (f->active) {
eti_info = f->exception_info;
while (1) {
Expand All @@ -58,6 +57,5 @@ s32 ExPPC_FindExceptionFragment(char* returnaddr, FragmentInfo* frag)
}
}
}

return 0;
}
Loading

0 comments on commit 9d9cabf

Please sign in to comment.