diff --git a/common.py b/common.py index f3fcda14..0384adaa 100644 --- a/common.py +++ b/common.py @@ -297,6 +297,7 @@ REL_SDATA2_SIZE = 0 CFLAGS = [ "-O4", "-char unsigned", + "-fp hard" ] CPLFLAGS =[ "-lang=c++", @@ -357,7 +358,6 @@ EXTERNAL_DOL_CFLAGS = ' '.join(BASE_DOL_CFLAGS) EXTERNAL_REL_CFLAGS = ' '.join(BASE_REL_CFLAGS) LDFLAGS = ' '.join([ - "-fp hard", "-maxerrors 1", "-mapunused" ]) diff --git a/config/analysis_overrides.yml b/config/analysis_overrides.yml index 31f073e0..bd513ddd 100644 --- a/config/analysis_overrides.yml +++ b/config/analysis_overrides.yml @@ -2,8 +2,8 @@ blocked_pointers: - 0x800A8440 - 0x800A8514 forced_types: - 0x80003534: ENTRY - 0x80005468: ENTRY + 0x80003534: FUNCTION + 0x80005468: FUNCTION 0x8003ab3c: ENTRY 0x8003ab70: ENTRY 0x8003ab70: ENTRY diff --git a/config/dol_slices.yml b/config/dol_slices.yml index bb34bdbd..5b2300fa 100644 --- a/config/dol_slices.yml +++ b/config/dol_slices.yml @@ -7,6 +7,8 @@ runtime/__mem.c: .init: [0x800033a8, 0x800034e0] #TRK/mem_TRK.c: # .init: [0x800034e0, 0x80003510] +#TRK/__exception.c: +# .init: [0x80003534, 0x8000556C] jaudio_NES/dummyprobe.c: .text: [0x800083f8, 0x80008400] #jaudio_NES/verysimple.c: @@ -14,9 +16,20 @@ jaudio_NES/dummyprobe.c: # .sdata: [0x80217b80, 0x80217b88] libforest/ReconfigBATs.c: .text: [0x8005adac, 0x8005aed4] +#libu64/debug.c: //not match +# .text: [0x8005aed4, 0x8005af30] +# .data: [0x800dc7c8, 0x800dc7f0] #libu64/gfxprint.c: specify ranges later libc64/aprintf.c: .text: [0x8005cbdc, 0x8005cc14] +#libc64/math64.c: //not match +# .text: [0x8005cc14, 0x8005cccc] +# .sdata2: [0x80219118, 0x80219130] +libc64/qrand.c: + .text: [0x8005cccc, 0x8005cd64] + .sdata: [0x80217de8, 0x80217df0] + .sbss: [0x80218640, 0x80218648] + .sdata2: [0x80219130, 0x80219138] #libultra/ultra.c: won't link # .text: [0x8005d01c, 0x8005d15c] # .bss: [0x80206f60, 0x80206fa0] diff --git a/config/rel_slices.yml b/config/rel_slices.yml index c155b6cc..76b0acd4 100644 --- a/config/rel_slices.yml +++ b/config/rel_slices.yml @@ -4,7 +4,7 @@ m_room_type/mRmTp_FtrItemNo2FtrIdx.c: .text: [0x803E7878, 0x803E78BC] #m_skin_matrix.c: # .text: [0x803f1528, 0x803f1bb4] -# .rodata: [0x80643310, 0x80643318] +# .rodata: [0x80643310, 0x80643318] #zurumode/zerucheck_init.c: # .text: [0x8040eb38, 0x8040EB50] #zurumode/zerucheck_key_check.c: diff --git a/include/rand.h b/include/MSL_C/rand.h similarity index 100% rename from include/rand.h rename to include/MSL_C/rand.h diff --git a/include/MSL_C/w_math.h b/include/MSL_C/w_math.h new file mode 100644 index 00000000..5f8cb11e --- /dev/null +++ b/include/MSL_C/w_math.h @@ -0,0 +1,25 @@ +#ifndef W_MATH_H +#define W_MATH_H +#include "types.h" + +inline float sqrtf(float x) +{ + static const double _half=.5; + static const double _three=3.0; + volatile float y; + if(x > 0.0f) + { + double guess = __frsqrte((double)x); // returns an approximation to + guess = _half*guess*(_three - guess*guess*x); // now have 12 sig bits + guess = _half*guess*(_three - guess*guess*x); // now have 24 sig bits + guess = _half*guess*(_three - guess*guess*x); // now have 32 sig bits + y=(float)(x*guess); + return y; + } + return x; +} + +f64 atan2(f64, f64); +f64 acos(f32); + +#endif \ No newline at end of file diff --git a/include/libc/math.h b/include/libc/math.h index 6d52fa8d..6f3bce9e 100644 --- a/include/libc/math.h +++ b/include/libc/math.h @@ -4,4 +4,9 @@ #include "types.h" s16 sins(u16); +f32 fatan2(f32, f32); + +f64 fsqrt(f32); + +f32 facos(f32); #endif \ No newline at end of file diff --git a/include/libc64/qrand.h b/include/libc64/qrand.h new file mode 100644 index 00000000..03d5403a --- /dev/null +++ b/include/libc64/qrand.h @@ -0,0 +1,11 @@ +#ifndef LQRAND_H +#define LQRAND_H + +#include "types.h" + +u32 qrand(void); +void sqrand(u32); +f32 fqrand(void); +f64 fqrand2(void); + +#endif \ No newline at end of file diff --git a/include/libu64/debug.h b/include/libu64/debug.h new file mode 100644 index 00000000..5719222b --- /dev/null +++ b/include/libu64/debug.h @@ -0,0 +1,8 @@ +#ifndef LDEBUG_H +#define LDEBUG_H + +#include "types.h" + +void _dbg_hungup(const char*, s32); + +#endif \ No newline at end of file diff --git a/include/libultra/osThread.h b/include/libultra/osThread.h new file mode 100644 index 00000000..afa36f3c --- /dev/null +++ b/include/libultra/osThread.h @@ -0,0 +1,13 @@ +#ifndef LOS_THREAD_H +#define LOS_THREAD_H + +#include "types.h" +#include "dolphin/OSThread.h" +typedef s32 OSPri; +typedef s32 OSId; + + + +OSId osGetThreadId(OSThread*); + +#endif \ No newline at end of file diff --git a/rel/m_skin_matrix.c b/rel/m_skin_matrix.c index f14f7310..48e08e4c 100644 --- a/rel/m_skin_matrix.c +++ b/rel/m_skin_matrix.c @@ -1,5 +1,8 @@ #include "m_skin_matrix.h" #include "m_lib.h" + +#include "orderfloats/80643310_80643318.inc" + 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)); @@ -210,4 +213,23 @@ void Skin_Matrix_SetRotateXyz_s(MtxF* mf, s16 x, s16 y, s16 z) { } else { mf->zy = 0; } +} + +void Skin_Matrix_SetTranslate(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->xx = 1.0f; + mf->yy = 1.0f; + mf->zz = 1.0f; + mf->ww = 1.0f; + mf->xw = x; + mf->yw = y; + mf->zw = z; } \ No newline at end of file diff --git a/src/MSL_C/rand.c b/src/MSL_C/rand.c index 973fee80..ca254e79 100644 --- a/src/MSL_C/rand.c +++ b/src/MSL_C/rand.c @@ -1,4 +1,4 @@ -#include "rand.h" +#include "MSL_C/rand.h" static u32 next = 1; diff --git a/src/TRK/__exception.c b/src/TRK/__exception.c index fc5e419b..fc321c06 100644 --- a/src/TRK/__exception.c +++ b/src/TRK/__exception.c @@ -1,9 +1,18 @@ +/*I will bother with fill/skip later, and I forgor how to .ascii (it's not that)*/ #include "types.h" - -__declspec(section ".init")asm void gTRKInterruptVectorTable(void){ - nofralloc - - .ascii "Metrowerks Target Resident Kernel for PowerP" +__declspec(section ".init") asm void gTRKInterruptVectorTable(void){ +nofralloc +/* 80003534 4D657472 */ .4byte 0x4d657472 +/* 80003538 6F776572 */ xoris r23, r27, 0x6572 +/* 8000353C 6B732054 */ xori r19, r27, 0x2054 +/* 80003540 61726765 */ ori r18, r11, 0x6765 +/* 80003544 74205265 */ andis. r0, r1, 0x5265 +/* 80003548 73696465 */ andi. r9, r27, 0x6465 +/* 8000354C 6E74204B */ xoris r20, r19, 0x204b +/* 80003550 65726E65 */ oris r18, r11, 0x6e65 +/* 80003554 6C20666F */ xoris r0, r1, 0x666f +/* 80003558 7220506F */ andi. r0, r17, 0x506f +/* 8000355C 77657250 */ andis. r5, r27, 0x7250 /* 80003560 43000000 */ .4byte 0x43000000 /* 80003564 00000000 */ .4byte 0x00000000 /* 80003568 00000000 */ .4byte 0x00000000 @@ -1998,7 +2007,7 @@ lbl_80004764: __declspec(section ".init") asm void __TRK_reset(void){ nofralloc - /* 80005468 9421FFE0 */ stwu r1, -0x20(r1) +/* 80005468 9421FFE0 */ stwu r1, -0x20(r1) /* 8000546C 7C0802A6 */ mflr r0 /* 80005470 3C608021 */ lis r3, lc_base@ha /* 80005474 90010024 */ stw r0, 0x24(r1) diff --git a/src/libc64/math64.c b/src/libc64/math64.c new file mode 100644 index 00000000..77ace162 --- /dev/null +++ b/src/libc64/math64.c @@ -0,0 +1,12 @@ +#include "libc/math.h" +#include "MSL_C/w_math.h" +f32 fatan2(f32 x, f32 y){ + return atan2(x, y); +} +f64 fsqrt(f32 x){ + return sqrtf(x); +} + +f32 facos(f32 x){ + return acos(x); +} diff --git a/src/libc64/qrand.c b/src/libc64/qrand.c new file mode 100644 index 00000000..4a29e04b --- /dev/null +++ b/src/libc64/qrand.c @@ -0,0 +1,26 @@ +#include "libc64/qrand.h" + +static u32 __qrand_idum = 1; +static u32 __qrand_itemp; + +u32 qrand(void){ + __qrand_idum = __qrand_idum * 0x19660D + 0x3C6EF35F; + return __qrand_idum; +} + +void sqrand(u32 seed){ + __qrand_idum = seed; +} + +float fqrand(void){ + __qrand_idum = __qrand_idum * 0x19660D + 0x3C6EF35F; + __qrand_itemp = __qrand_idum >> 9 | 0x3F800000; + __qrand_itemp = __qrand_itemp; + return *(float*)&__qrand_itemp - 1.0f; +} + +double fqrand2(void){ + __qrand_idum = __qrand_idum * 0x19660D + 0x3C6EF35F; + __qrand_itemp = __qrand_idum >> 9 | 0x3F800000; + return *(float*)&__qrand_itemp - 1.5f; +} \ No newline at end of file diff --git a/src/libu64/debug.c b/src/libu64/debug.c new file mode 100644 index 00000000..200aff82 --- /dev/null +++ b/src/libu64/debug.c @@ -0,0 +1,8 @@ +#include "libu64/debug.h" +#include "libultra/osThread.h" + +void _dbg_hungup(const char* name, s32 line) { +char dbg_tbuf[0x100]; + +sprintf(dbg_tbuf, "*** HungUp in thread %d, [%s:%d] ***\n",osGetThreadId(0), name, line); +} diff --git a/tools/ppcdis b/tools/ppcdis index 83260829..eca3f301 160000 --- a/tools/ppcdis +++ b/tools/ppcdis @@ -1 +1 @@ -Subproject commit 83260829c50f37dd9fe54889cf8971c8fe14c54e +Subproject commit eca3f3015a86bf0c78d1e415aeff2dda1851194f