mirror of
https://github.com/ACreTeam/ac-decomp
synced 2026-08-14 19:59:47 -04:00
match m_skin_matrix, work on .init
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
#dolphin/os/__start.c:
|
||||
# .init: [0x80003100, 0x80003354] can't link because there's two mains
|
||||
#dolphin/os/__ppc_eabi_init.cpp:
|
||||
# .init: [0x80003354, 0x800033a8]
|
||||
# .text: [0x8007FDFC, 0x8007fe90]
|
||||
runtime/__mem.c:
|
||||
.init: [0x800033a8, 0x800034e0]
|
||||
#TRK/mem_TRK.c:
|
||||
# .init: [0x800034e0, 0x80003510]
|
||||
jaudio_NES/dummyprobe.c:
|
||||
.text: [0x800083f8, 0x80008400]
|
||||
#jaudio_NES/verysimple.c:
|
||||
|
||||
@@ -2,6 +2,9 @@ sys_vimgr.c:
|
||||
.text: [0x803703F8, 0x80370418]
|
||||
m_room_type/mRmTp_FtrItemNo2FtrIdx.c:
|
||||
.text: [0x803E7878, 0x803E78BC]
|
||||
#m_skin_matrix.c:
|
||||
# .text: [0x803f1528, 0x803f1bb4]
|
||||
# .rodata: [0x80643310, 0x80643318]
|
||||
#zurumode/zerucheck_init.c:
|
||||
# .text: [0x8040eb38, 0x8040EB50]
|
||||
#zurumode/zerucheck_key_check.c:
|
||||
|
||||
+4
-1
@@ -10,6 +10,7 @@ global:
|
||||
0x80003490: memcpy
|
||||
0x800034e0: TRK_memset
|
||||
0x80003510: TRK_memcpy
|
||||
0x80003534: gTRKInterruptVectorTable
|
||||
0x80005468: __TRK_reset
|
||||
0x800056c0: soundArenaAlloc
|
||||
0x800056c8: search_partial_address
|
||||
@@ -2624,6 +2625,7 @@ global:
|
||||
0x8009ae00: __save_fpr
|
||||
0x8009ae4c: __restore_fpr
|
||||
0x8009ae98: __save_gpr
|
||||
0x8009aeb4: _savegpr_21
|
||||
0x8009aeb8: _savegpr_22
|
||||
0x8009aebc: _savegpr_23
|
||||
0x8009aec0: _savegpr_24
|
||||
@@ -2632,7 +2634,8 @@ global:
|
||||
0x8009aecc: _savegpr_27
|
||||
0x8009aed0: _savegpr_28
|
||||
0x8009aed4: _savegpr_29
|
||||
0x8009aee4: __restore_gpr
|
||||
0x8009aee4: __restore_gpr
|
||||
0x8009af00: _restgpr_21
|
||||
0x8009af04: _restgpr_22
|
||||
0x8009af08: _restgpr_23
|
||||
0x8009af0c: _restgpr_24
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef DOLPHIN_TRK_H
|
||||
#define DOLPHIN_TRK_H
|
||||
#include "types.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
void InitMetroTRK(void);
|
||||
void exit(void);
|
||||
|
||||
void* TRK_memcpy(void* dst, const void* src, size_t size);
|
||||
void* TRK_memset(void* dst, int val, size_t size);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef DB_H
|
||||
#define DB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
void DBInit(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -12,6 +12,9 @@ void OSPanic(const char *file, int line, const char *message, ...);
|
||||
void OSReport(const char*, ...);
|
||||
void OSVReport(const char* format, va_list list);
|
||||
|
||||
extern void __OSPSInit();
|
||||
extern void __OSCacheInit();
|
||||
|
||||
#define OSErrorLine(line, ...) \
|
||||
OSPanic(__FILE__, line, __VA_ARGS__)
|
||||
|
||||
@@ -22,6 +25,8 @@ asm BOOL OSRestoreInterrupts(BOOL level);
|
||||
void __RAS_OSDisableInterrupts_begin(void);
|
||||
void __RAS_OSDisableInterrupts_end(void);
|
||||
|
||||
void OSResetSystem(u32, u32, u32); // goes in reset, but eh
|
||||
void OSInit(void);
|
||||
typedef void (*OSExceptionHandler)(u8, OSContext*);
|
||||
OSExceptionHandler __OSSetExceptionHandler(u8, OSExceptionHandler);
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#ifndef PPC_EABI_INIT_H
|
||||
#define PPC_EABI_INIT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
typedef void (*voidfunctionptr)(void); // pointer to function returning void
|
||||
__declspec(section ".ctors") extern voidfunctionptr _ctors[];
|
||||
__declspec(section ".dtors") extern voidfunctionptr _dtors[];
|
||||
|
||||
void __init_hardware(void);
|
||||
void __flush_cache(void*, size_t);
|
||||
void __init_user(void);
|
||||
void __fini_cpp(void);
|
||||
void _ExitProcess(void);
|
||||
|
||||
typedef struct RomSection {
|
||||
void* romOfs; // at 0x4
|
||||
void* virtualOfs; // at 0x0
|
||||
size_t size; // at 0x8
|
||||
} RomSection;
|
||||
|
||||
typedef struct BssSection {
|
||||
void* virtualOfs; // at 0x0
|
||||
size_t size; // at 0x8
|
||||
} BssSection;
|
||||
|
||||
typedef struct ExtabIndexInfo {
|
||||
void* etiStart; // at 0x0
|
||||
void* etiEnd; // at 0x4
|
||||
void* codeStart; // at 0x8
|
||||
u32 codeSize; // at 0x10
|
||||
} ExtabIndexInfo;
|
||||
|
||||
__declspec(section ".init") extern const RomSection _rom_copy_info[];
|
||||
__declspec(section ".init") extern const BssSection _bss_init_info[];
|
||||
__declspec(section ".init") extern const ExtabIndexInfo _eti_init_info[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -19,4 +19,21 @@ typedef struct {
|
||||
float m[4][4];
|
||||
} Mtx;
|
||||
|
||||
typedef float MtxF_t[4][4];
|
||||
typedef union {
|
||||
struct {
|
||||
|
||||
|
||||
float xx, yx, zx, wx,
|
||||
xy, yy, zy, wy,
|
||||
xz, yz, zz, wz,
|
||||
xw, yw, zw, ww;
|
||||
};
|
||||
MtxF_t mf;
|
||||
} MtxF;
|
||||
|
||||
typedef struct {
|
||||
f32 x, y, z;
|
||||
} Vec3f;
|
||||
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -56,11 +56,11 @@ void rgba_t_move(rgba_t*, rgba_t*);
|
||||
u32 none_proc1(void);
|
||||
void none_proc2(void);
|
||||
|
||||
void _Game_play_isPause(u32 //IDK);
|
||||
void _Game_play_isPause(u32); //IDK
|
||||
|
||||
//Unsure
|
||||
//?? check_percent_abs();
|
||||
//?? get_percent_forAccelBrake();
|
||||
void Game_play_Projection_Trans(game_play*, Vec3f*, Vec3f);
|
||||
//void Game_play_Projection_Trans(game_play*, Vec3f*, Vec3f);
|
||||
f32 get_percent(s32, s32, s32);
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef SKIN_MATRIX_H
|
||||
#define SKIN_MATRIX_H
|
||||
|
||||
#include "libultra/u64types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
void Skin_Matrix_PrjMulVector(MtxF*, Vec3f*, Vec3f*, f32*);
|
||||
void Skin_Matrix_MulMatrix(MtxF*, MtxF*, MtxF*);
|
||||
void Skin_Matrix_SetScale(MtxF* , f32 , f32, f32);
|
||||
void Skin_Matrix_SetTranslate(MtxF*, f32, f32, f32);
|
||||
void Skin_Matrix_SetRotateXyz_s(MtxF*, s16, s16, s16);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,213 @@
|
||||
#include "m_skin_matrix.h"
|
||||
#include "m_lib.h"
|
||||
void Skin_Matrix_PrjMulVector(MtxF* mf, Vec3f* src, Vec3f* xyzDest, f32* wDest) {
|
||||
xyzDest->x = mf->xw + ((src->x * mf->xx) + (src->y * mf->xy) + (src->z * mf->xz));
|
||||
xyzDest->y = mf->yw + ((src->x * mf->yx) + (src->y * mf->yy) + (src->z * mf->yz));
|
||||
xyzDest->z = mf->zw + ((src->x * mf->zx) + (src->y * mf->zy) + (src->z * mf->zz));
|
||||
*wDest = mf->ww + ((src->x * mf->wx) + (src->y * mf->wy) + (src->z * mf->wz));
|
||||
}
|
||||
|
||||
void Skin_Matrix_MulMatrix(MtxF* mfA, MtxF* mfB, MtxF* dest) {
|
||||
f32 cx;
|
||||
f32 cy;
|
||||
f32 cz;
|
||||
f32 cw;
|
||||
//---ROW1---
|
||||
f32 rx = mfA->xx;
|
||||
f32 ry = mfA->xy;
|
||||
f32 rz = mfA->xz;
|
||||
f32 rw = mfA->xw;
|
||||
//--------
|
||||
|
||||
cx = mfB->xx;
|
||||
cy = mfB->yx;
|
||||
cz = mfB->zx;
|
||||
cw = mfB->wx;
|
||||
dest->xx = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
cx = mfB->xy;
|
||||
cy = mfB->yy;
|
||||
cz = mfB->zy;
|
||||
cw = mfB->wy;
|
||||
dest->xy = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
cx = mfB->xz;
|
||||
cy = mfB->yz;
|
||||
cz = mfB->zz;
|
||||
cw = mfB->wz;
|
||||
dest->xz = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
cx = mfB->xw;
|
||||
cy = mfB->yw;
|
||||
cz = mfB->zw;
|
||||
cw = mfB->ww;
|
||||
dest->xw = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
//---ROW2---
|
||||
rx = mfA->yx;
|
||||
ry = mfA->yy;
|
||||
rz = mfA->yz;
|
||||
rw = mfA->yw;
|
||||
//--------
|
||||
cx = mfB->xx;
|
||||
cy = mfB->yx;
|
||||
cz = mfB->zx;
|
||||
cw = mfB->wx;
|
||||
dest->yx = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
cx = mfB->xy;
|
||||
cy = mfB->yy;
|
||||
cz = mfB->zy;
|
||||
cw = mfB->wy;
|
||||
dest->yy = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
cx = mfB->xz;
|
||||
cy = mfB->yz;
|
||||
cz = mfB->zz;
|
||||
cw = mfB->wz;
|
||||
dest->yz = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
cx = mfB->xw;
|
||||
cy = mfB->yw;
|
||||
cz = mfB->zw;
|
||||
cw = mfB->ww;
|
||||
dest->yw = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
//---ROW3---
|
||||
rx = mfA->zx;
|
||||
ry = mfA->zy;
|
||||
rz = mfA->zz;
|
||||
rw = mfA->zw;
|
||||
//--------
|
||||
cx = mfB->xx;
|
||||
cy = mfB->yx;
|
||||
cz = mfB->zx;
|
||||
cw = mfB->wx;
|
||||
dest->zx = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
cx = mfB->xy;
|
||||
cy = mfB->yy;
|
||||
cz = mfB->zy;
|
||||
cw = mfB->wy;
|
||||
dest->zy = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
cx = mfB->xz;
|
||||
cy = mfB->yz;
|
||||
cz = mfB->zz;
|
||||
cw = mfB->wz;
|
||||
dest->zz = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
cx = mfB->xw;
|
||||
cy = mfB->yw;
|
||||
cz = mfB->zw;
|
||||
cw = mfB->ww;
|
||||
dest->zw = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
//---ROW4---
|
||||
rx = mfA->wx;
|
||||
ry = mfA->wy;
|
||||
rz = mfA->wz;
|
||||
rw = mfA->ww;
|
||||
//--------
|
||||
cx = mfB->xx;
|
||||
cy = mfB->yx;
|
||||
cz = mfB->zx;
|
||||
cw = mfB->wx;
|
||||
dest->wx = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
cx = mfB->xy;
|
||||
cy = mfB->yy;
|
||||
cz = mfB->zy;
|
||||
cw = mfB->wy;
|
||||
dest->wy = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
cx = mfB->xz;
|
||||
cy = mfB->yz;
|
||||
cz = mfB->zz;
|
||||
cw = mfB->wz;
|
||||
dest->wz = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
|
||||
cx = mfB->xw;
|
||||
cy = mfB->yw;
|
||||
cz = mfB->zw;
|
||||
cw = mfB->ww;
|
||||
dest->ww = (rx * cx) + (ry * cy) + (rz * cz) + (rw * cw);
|
||||
}
|
||||
|
||||
|
||||
void Skin_Matrix_SetScale(MtxF* mf, f32 x, f32 y, f32 z) {
|
||||
mf->yx = 0.0f;
|
||||
mf->zx = 0.0f;
|
||||
mf->wx = 0.0f;
|
||||
mf->xy = 0.0f;
|
||||
mf->zy = 0.0f;
|
||||
mf->wy = 0.0f;
|
||||
mf->xz = 0.0f;
|
||||
mf->yz = 0.0f;
|
||||
mf->wz = 0.0f;
|
||||
mf->xw = 0.0f;
|
||||
mf->yw = 0.0f;
|
||||
mf->zw = 0.0f;
|
||||
mf->ww = 1.0f;
|
||||
mf->xx = x;
|
||||
mf->yy = y;
|
||||
mf->zz = z;
|
||||
}
|
||||
|
||||
void Skin_Matrix_SetRotateXyz_s(MtxF* mf, s16 x, s16 y, s16 z) {
|
||||
f32 cos;
|
||||
f32 sinZ = sin_s(z);
|
||||
f32 cosZ = cos_s(z);
|
||||
f32 xy;
|
||||
f32 sin;
|
||||
f32 xz;
|
||||
f32 yy;
|
||||
f32 yz;
|
||||
f32 zz;
|
||||
|
||||
mf->yy = cosZ;
|
||||
mf->xy = -sinZ;
|
||||
mf->wx = mf->wy = mf->wz = 0;
|
||||
mf->xw = mf->yw = mf->zw = 0;
|
||||
mf->ww = 1;
|
||||
|
||||
if (y != 0) {
|
||||
sin = sin_s(y);
|
||||
cos = cos_s(y);
|
||||
|
||||
mf->xx = cosZ * cos;
|
||||
mf->xz = cosZ * sin;
|
||||
|
||||
mf->yx = sinZ * cos;
|
||||
mf->yz = sinZ * sin;
|
||||
mf->zx = -sin;
|
||||
mf->zz = cos;
|
||||
|
||||
} else {
|
||||
mf->xx = cosZ;
|
||||
mf->yx = sinZ;
|
||||
mf->zx = mf->xz = mf->yz = 0;
|
||||
mf->zz = 1;
|
||||
}
|
||||
|
||||
if (x != 0) {
|
||||
sin = sin_s(x);
|
||||
cos = cos_s(x);
|
||||
|
||||
xy = mf->xy;
|
||||
xz = mf->xz;
|
||||
mf->xy = (xy * cos) + (xz * sin);
|
||||
mf->xz = - (xy * sin) + (xz * cos) ;
|
||||
|
||||
yy = mf->yy;
|
||||
yz = mf->yz;
|
||||
mf->yy = (yy * cos) + (yz * sin);
|
||||
mf->yz = - (yy * sin) + (yz * cos) ;
|
||||
|
||||
zz = mf->zz;
|
||||
mf->zy = zz * sin;
|
||||
mf->zz = zz * cos;
|
||||
} else {
|
||||
mf->zy = 0;
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
#include "main.h"
|
||||
#include "boot.h"
|
||||
|
||||
void mainproc(){
|
||||
//TODO
|
||||
}
|
||||
|
||||
u32 entry_foresta(void) { // Something something, needs pad manager? and idk what's debug_mode actually
|
||||
OSMesgQueue* osmsg;
|
||||
padmgr_Init(NULL,osmsg);
|
||||
new_Debug_mode();
|
||||
debug_mode[106] = 0;
|
||||
mainproc(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void main(void){
|
||||
OSReport("どうぶつの森 main2 開始");
|
||||
HotStartEntry = (u32)&entry;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,18 @@
|
||||
#include "TRK/dolphin_trk.h"
|
||||
|
||||
__declspec(section ".init") void* TRK_memset(void* dst, int val, size_t size){
|
||||
TRK_fill_mem(dst, val, size);
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
__declspec(section ".init") void* TRK_memcpy(void* dst, const void* src, size_t size){
|
||||
const u8* s = (const u8*)src -1;
|
||||
u8* d = (u8*)dst -1;
|
||||
|
||||
size++;
|
||||
while(--size != 0){
|
||||
*++d = *++s;
|
||||
return dst;
|
||||
}
|
||||
}
|
||||
+30
-2
@@ -95,8 +95,36 @@ void fault_callback_scroll(void){
|
||||
//TODO
|
||||
}
|
||||
|
||||
void adjustOSArena(){ //https://decomp.me/scratch/LdpbQ
|
||||
// To Finish
|
||||
void adjustOSArena(void) {
|
||||
|
||||
void* arenalo = OSGetArenaLo();
|
||||
void* arenahi = OSGetArenaHi();
|
||||
|
||||
OSReport("ARENA %08x-%08x\x1B\x5B\x6B\n", arenalo, arenahi);
|
||||
|
||||
if(arenahi > (void*)0x81800000) {
|
||||
if(!(osAppNMIBuffer[15] & 0x80)){
|
||||
OSReport("搭載メモリが 24MB を超えていますが、24MB に限定します。\x1B\x5B\x6D\n");
|
||||
arenahi = (void*)0x817ffa80;
|
||||
}
|
||||
|
||||
else if(arenahi > (void*)0x82000000){
|
||||
OSReport("搭載メモリが 32MB を超えています。\x1B\x5B\x6D\n");
|
||||
arenahi = (void*)0x81e00000;
|
||||
}
|
||||
|
||||
else {
|
||||
OSReport("搭載メモリが 32MB を超えていますが、32MB に限定します。\x1B\x5B\x6B\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
OSReport("搭載メモリが 24MB 以下なので動かない事がありえます。\x1B\x5B\x6D\n");
|
||||
}
|
||||
|
||||
OSSetArenaHi(arenahi);
|
||||
OSReport("ARENA %08x-%08x\x1B\x5B\x6B\n", arenalo, arenahi);
|
||||
|
||||
bzero(arenalo, ((u32)arenahi - (u32)arenalo));
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv){ //https://decomp.me/scratch/frpgE
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
#include "types.h"
|
||||
#include "dolphin/os.h"
|
||||
#include "dolphin/BASE/ppcarch.h"
|
||||
#include "init.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
static void __init_cpp(void);
|
||||
|
||||
__declspec(section ".init") asm void __init_hardware(void) {
|
||||
nofralloc
|
||||
mfmsr r0
|
||||
ori r0,r0,0x2000
|
||||
mtmsr r0
|
||||
mflr r31
|
||||
bl __OSPSInit
|
||||
bl __OSCacheInit
|
||||
mtlr r31
|
||||
blr
|
||||
}
|
||||
|
||||
__declspec(section ".init") asm void __flush_cache(void) {
|
||||
nofralloc
|
||||
lis r5, 0xFFFFFFF1@h
|
||||
ori r5, r5, 0xFFFFFFF1@l
|
||||
and r5, r5, r3
|
||||
subf r3, r5, r3
|
||||
add r4, r4, r3
|
||||
loop:
|
||||
dcbst 0, r5
|
||||
sync
|
||||
icbi 0, r5
|
||||
addic r5, r5, 8
|
||||
addic. r4, r4, -8
|
||||
bge loop
|
||||
isync
|
||||
blr
|
||||
}
|
||||
|
||||
|
||||
|
||||
void __init_user(void) { __init_cpp(); }
|
||||
|
||||
static void __init_cpp(void)
|
||||
{
|
||||
voidfunctionptr* constructor;
|
||||
/*
|
||||
* call static initializers
|
||||
*/
|
||||
for (constructor = _ctors; *constructor; constructor++) {
|
||||
(*constructor)();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void __fini_cpp(void)
|
||||
{
|
||||
// UNUSED FUNCTION
|
||||
}
|
||||
|
||||
void _ExitProcess(void) { PPCHalt(); }
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,160 @@
|
||||
#include "dolphin/os.h"
|
||||
#include "dolphin/db.h"
|
||||
#include "TRK/dolphin_trk.h"
|
||||
#include "dolphin/os/__ppc_eabi_init.h"
|
||||
|
||||
__declspec(section ".init")void __init_registers(void);
|
||||
__declspec(section ".init")void __init_data(void);
|
||||
|
||||
__declspec(section ".init") void __check_pad3(void){
|
||||
if((*(u16*)0x800030E4 & 0xEEF) == 0xEEF){
|
||||
OSResetSystem(0,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
__declspec(section ".init") asm void __start(void){
|
||||
nofralloc
|
||||
|
||||
bl __init_registers
|
||||
bl __init_hardware
|
||||
li r0, -1
|
||||
stwu r1, -8(r1)
|
||||
stw r0, 4(r1)
|
||||
stw r0, 0(r1)
|
||||
bl __init_data
|
||||
li r0, 0x0
|
||||
lis r6, 0x8000
|
||||
addi r6, r6, 0x44
|
||||
stw r0, 0(r6)
|
||||
lis r6, 0x8000
|
||||
addi r6, r6, 0xf4
|
||||
lwz r6, 0(r6)
|
||||
cmplwi r6, 0
|
||||
beq- ar
|
||||
lwz r7, 0xc(r6)
|
||||
b h
|
||||
|
||||
ar:
|
||||
lis r5, 0x8000
|
||||
addi r5, r5, 0x34
|
||||
lwz r5, 0(r5)
|
||||
cmplwi r5, 0
|
||||
beq- d
|
||||
lis r7, 0x8000
|
||||
addi r7, r7, 0x30E8
|
||||
lwz r7, 0(r7)
|
||||
h:
|
||||
li r5, 0x0
|
||||
cmplwi r7, 2
|
||||
beq+ met
|
||||
cmplwi r7, 3
|
||||
bne- d
|
||||
li r5, 0x1
|
||||
met:
|
||||
lis r6, InitMetroTRK@ha
|
||||
addi r6, r6, InitMetroTRK@l
|
||||
mtlr r6
|
||||
blrl
|
||||
d:
|
||||
lis r6, 0x8000
|
||||
addi r6, r6, 0xF4
|
||||
lwz r5, 0(r6)
|
||||
cmplwi r5, 0
|
||||
beq+ res
|
||||
lwz r6, 8(r5)
|
||||
cmplwi r6, 0
|
||||
beq+ res
|
||||
add r6, r5, r6
|
||||
lwz r14, 0(r6)
|
||||
cmplwi r14, 0
|
||||
beq- res
|
||||
addi r15, r6, 0x4
|
||||
mtctr r14
|
||||
|
||||
loop:
|
||||
addi r6, r6, 0x4
|
||||
lwz r7, 0(r6)
|
||||
add r7, r7, r5
|
||||
stw r7, 0(r6)
|
||||
bdnz loop
|
||||
lis r5, 0x8000
|
||||
addi r5, r5, 0x34
|
||||
rlwinm r7, r15, 0, 0, 0x1A
|
||||
stw r7, 0(r5)
|
||||
b indeb
|
||||
res:
|
||||
li r14, 0x0
|
||||
li r15, 0x0
|
||||
indeb:
|
||||
bl DBInit
|
||||
bl OSInit
|
||||
lis r4, 0x8000
|
||||
addi r4, r4, 0x30E6
|
||||
lhz r3, 0(r4)
|
||||
andi. r5, r3, 0x8000
|
||||
beq- check
|
||||
andi. r3, r3, 0x7FFF
|
||||
cmplwi r3, 1
|
||||
bne- user
|
||||
|
||||
check:
|
||||
bl __check_pad3
|
||||
user:
|
||||
bl __init_user
|
||||
mr r3, r14
|
||||
mr r4, r15
|
||||
bl main // can't find the dol main, because there's one main in dol and then one in rel
|
||||
b exit
|
||||
}
|
||||
|
||||
__declspec(section ".init") asm void __init_registers(void){
|
||||
nofralloc
|
||||
lis r1, 0x8021
|
||||
ori r1, r1, 0xA710
|
||||
lis r2, 0x8022
|
||||
ori r2, r2, 0xBE0
|
||||
lis r13, 0x8021
|
||||
ori r13, r13, 0xFB80
|
||||
blr
|
||||
}
|
||||
|
||||
__declspec(section ".init") static void __copy_rom_section(void* dst, const void* src, size_t size){
|
||||
if (size == 0 || dst == src){
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(dst, src, size);
|
||||
(dst, size);
|
||||
}
|
||||
|
||||
__declspec(section ".init") static void __init_bss_section(void* dst, size_t size){
|
||||
if(size == 0){
|
||||
return;
|
||||
}
|
||||
memset(dst, 0, size);
|
||||
}
|
||||
|
||||
__declspec(section ".init") static void __init_data(void){
|
||||
const RomSection* rs;
|
||||
const BssSection* bs;
|
||||
|
||||
rs = _rom_copy_info;
|
||||
while (1) {
|
||||
if (rs->size == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
__copy_rom_section(rs->virtualOfs, rs->romOfs, rs->size);
|
||||
rs++;
|
||||
}
|
||||
|
||||
bs = _bss_init_info;
|
||||
while (1) {
|
||||
if (bs->size == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
__init_bss_section(bs->virtualOfs, bs->size);
|
||||
bs++;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
#include "_mem.h"
|
||||
|
||||
__declspec(section ".init") void* memset(void* dst, int val, size_t size){
|
||||
__fill_mem(dst,val, size);
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
__declspec(section ".init") void __fill_mem(void* dst, int val, size_t n){
|
||||
u32 v = (u8) val;
|
||||
u32 i;
|
||||
|
||||
((u8 *) dst) = ((u8 *) dst) - 1;
|
||||
|
||||
if (n >= 32)
|
||||
{
|
||||
i = (~ (u32) dst) & 3;
|
||||
|
||||
if (i) {
|
||||
n -= i;
|
||||
|
||||
do {
|
||||
*++(((u8 *) dst)) = v;
|
||||
} while (--i);
|
||||
}
|
||||
|
||||
if (v)
|
||||
v |= v << 24 | v << 16 | v << 8;
|
||||
|
||||
((u32 *) dst) = ((u32 *) (((u8 *) dst) + 1)) - 1;
|
||||
|
||||
i = n >> 5;
|
||||
|
||||
if (i) {
|
||||
do {
|
||||
*++((u32 *) dst) = v;
|
||||
*++((u32 *) dst) = v;
|
||||
*++((u32 *) dst) = v;
|
||||
*++((u32 *) dst) = v;
|
||||
*++((u32 *) dst) = v;
|
||||
*++((u32 *) dst) = v;
|
||||
*++((u32 *) dst) = v;
|
||||
*++((u32 *) dst) = v;
|
||||
} while (--i);
|
||||
}
|
||||
|
||||
i = (n & 31) >> 2;
|
||||
|
||||
if (i) {
|
||||
do {
|
||||
*++((u32 *) dst) = v;
|
||||
} while (--i);
|
||||
}
|
||||
|
||||
((u8 *) dst) = ((u8 *) (((u32 *) dst) + 1)) - 1;
|
||||
|
||||
n &= 3;
|
||||
}
|
||||
|
||||
if (n)
|
||||
do {
|
||||
*++((u8 *) dst) = v;
|
||||
} while (--n);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
__declspec(section ".init") void* memcpy(void* dst, const void* src, size_t size){
|
||||
const u8* s;
|
||||
u8* d;
|
||||
|
||||
if((u32)src >= (u32)dst){
|
||||
s = (const u8*)src -1;
|
||||
d = (u8*)dst -1;
|
||||
size++;
|
||||
while (--size !=0){
|
||||
*++d = *++s;
|
||||
}
|
||||
}
|
||||
else{
|
||||
s = (const u8*)src + size;
|
||||
d = (u8*)dst + size;
|
||||
size++;
|
||||
while (--size != 0){
|
||||
*--d = *--s;
|
||||
}
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
Reference in New Issue
Block a user