diff options
-rw-r--r-- | arm9/lib/include/fx.h | 2 | ||||
-rw-r--r-- | arm9/lib/src/FX_vec.c | 54 | ||||
-rw-r--r-- | arm9/src/main.c | 1 | ||||
-rw-r--r-- | arm9/src/poke_overlay.c | 19 | ||||
-rw-r--r-- | arm9/src/string_util.c | 16 | ||||
-rw-r--r-- | include/main.h | 3 | ||||
-rw-r--r-- | include/poke_overlay.h | 15 | ||||
-rw-r--r-- | include/pokemon.h | 3 | ||||
-rw-r--r-- | include/string_util.h | 25 | ||||
-rw-r--r-- | include/structs.h | 2 |
10 files changed, 83 insertions, 57 deletions
diff --git a/arm9/lib/include/fx.h b/arm9/lib/include/fx.h index 3df89293..c09b24ae 100644 --- a/arm9/lib/include/fx.h +++ b/arm9/lib/include/fx.h @@ -142,7 +142,7 @@ void MTX_RotY44_(struct Mtx44 *mtx, fx32 sinphi, fx32 cosphi); void MTX_RotZ44_(struct Mtx44 *mtx, fx32 sinphi, fx32 cosphi); //Mtx43 -void MTX_ScaleApply33(struct Mtx33 *mtx, struct Mtx33 *dst, fx32 x, fx32 y, fx32 z); +void MTX_ScaleApply43(struct Mtx43 *mtx, struct Mtx43 *dst, fx32 x, fx32 y, fx32 z); fx32 MTX_Inverse43(struct Mtx43 *mtx, struct Mtx43 *inv); void MTX_Concat43(struct Mtx43 *a, struct Mtx43 *b, struct Mtx43 *c); void MTX_MultVec43(struct Vecx32 *vec, struct Mtx43 *mtx, struct Vecx32 *dst); diff --git a/arm9/lib/src/FX_vec.c b/arm9/lib/src/FX_vec.c index 95805f33..891b980a 100644 --- a/arm9/lib/src/FX_vec.c +++ b/arm9/lib/src/FX_vec.c @@ -15,13 +15,13 @@ ARM_FUNC void VEC_Subtract(struct Vecx32 *a, struct Vecx32 *b, struct Vecx32 *ds } ARM_FUNC void VEC_Fx16Add(struct Vecx16 *a, struct Vecx16 *b, struct Vecx16 *dst){ - dst->x = a->x + b->x; - dst->y = a->y + b->y; - dst->z = a->z + b->z; + dst->x = (s16)(a->x + b->x); + dst->y = (s16)(a->y + b->y); + dst->z = (s16)(a->z + b->z); } ARM_FUNC fx32 VEC_DotProduct(struct Vecx32 *a, struct Vecx32 *b){ - return ((fx64)a->x * b->x + (fx64)a->y * b->y + (fx64)a->z * b->z + (1 << (FX64_INT_SHIFT - 1))) >> FX64_INT_SHIFT; + return (fx32)(((fx64)a->x * b->x + (fx64)a->y * b->y + (fx64)a->z * b->z + (1 << (FX64_INT_SHIFT - 1))) >> FX64_INT_SHIFT); } ARM_FUNC fx32 VEC_Fx16DotProduct(struct Vecx16 *a, struct Vecx16 *b){ @@ -46,9 +46,9 @@ ARM_FUNC void VEC_Fx16CrossProduct(struct Vecx16 *a, struct Vecx16 *b, struct Ve x = ((a->y * b->z - a->z * b->y + (1 << (FX64_INT_SHIFT - 1))) >> FX64_INT_SHIFT); y = ((a->z * b->x - a->x * b->z + (1 << (FX64_INT_SHIFT - 1))) >> FX64_INT_SHIFT); z = ((a->x * b->y - a->y * b->x + (1 << (FX64_INT_SHIFT - 1))) >> FX64_INT_SHIFT); - dst->x = x; - dst->y = y; - dst->z = z; + dst->x = (fx16)x; + dst->y = (fx16)y; + dst->z = (fx16)z; } ARM_FUNC fx32 VEC_Mag(struct Vecx32 *a){ @@ -56,8 +56,8 @@ ARM_FUNC fx32 VEC_Mag(struct Vecx32 *a){ l2 += (fx64)a->y * a->y; l2 += (fx64)a->z * a->z; reg_CP_SQRTCNT = 0x1; - reg_CP_SQRT_PARAM = l2 * 4; - while (reg_CP_SQRTCNT & 0x8000); //wait for coprocessor to finish + reg_CP_SQRT_PARAM = (u64)(l2 * 4); + while (reg_CP_SQRTCNT & 0x8000) {} //wait for coprocessor to finish return ((fx32)reg_CP_SQRT_RESULT + 1) >> 1; } @@ -68,17 +68,17 @@ ARM_FUNC void VEC_Normalize(struct Vecx32 *a, struct Vecx32 *dst){ //1/sqrt(l) is computed by calculating sqrt(l)*(1/l) reg_CP_DIVCNT = 0x2; reg_CP_DIV_NUMER = 0x0100000000000000; - reg_CP_DIV_DENOM = l2; + reg_CP_DIV_DENOM = (u64)l2; reg_CP_SQRTCNT = 0x1; - reg_CP_SQRT_PARAM = l2 * 4; - while (reg_CP_SQRTCNT & 0x8000); //wait for sqrt to finish - fx32 sqrtresult = reg_CP_SQRT_RESULT; - while (reg_CP_DIVCNT & 0x8000); //wait for division to finish - l2 = reg_CP_DIV_RESULT; + reg_CP_SQRT_PARAM = (u64)(l2 * 4); + while (reg_CP_SQRTCNT & 0x8000) {} //wait for sqrt to finish + fx32 sqrtresult = (fx32)reg_CP_SQRT_RESULT; + while (reg_CP_DIVCNT & 0x8000) {} //wait for division to finish + l2 = (fx64)reg_CP_DIV_RESULT; l2 = sqrtresult * l2; - dst->x = (l2 * a->x + (1LL << (0x2D - 1))) >> 0x2D; - dst->y = (l2 * a->y + (1LL << (0x2D - 1))) >> 0x2D; - dst->z = (l2 * a->z + (1LL << (0x2D - 1))) >> 0x2D; + dst->x = (fx32)((l2 * a->x + (1LL << (0x2D - 1))) >> 0x2D); + dst->y = (fx32)((l2 * a->y + (1LL << (0x2D - 1))) >> 0x2D); + dst->z = (fx32)((l2 * a->z + (1LL << (0x2D - 1))) >> 0x2D); } ARM_FUNC void VEC_Fx16Normalize(struct Vecx16 *a, struct Vecx16 *dst){ @@ -88,17 +88,17 @@ ARM_FUNC void VEC_Fx16Normalize(struct Vecx16 *a, struct Vecx16 *dst){ //1/sqrt(l) is computed by calculating sqrt(l)*(1/l) reg_CP_DIVCNT = 0x2; reg_CP_DIV_NUMER = 0x0100000000000000; - reg_CP_DIV_DENOM = l2; + reg_CP_DIV_DENOM = (u64)l2; reg_CP_SQRTCNT = 0x1; - reg_CP_SQRT_PARAM = l2 * 4; - while (reg_CP_SQRTCNT & 0x8000); //wait for sqrt to finish - fx32 sqrtresult = reg_CP_SQRT_RESULT; - while (reg_CP_DIVCNT & 0x8000); //wait for division to finish - l2 = reg_CP_DIV_RESULT; + reg_CP_SQRT_PARAM = (u64)(l2 * 4); + while (reg_CP_SQRTCNT & 0x8000) {} //wait for sqrt to finish + fx32 sqrtresult = (fx32)reg_CP_SQRT_RESULT; + while (reg_CP_DIVCNT & 0x8000) {} //wait for division to finish + l2 = (fx64)reg_CP_DIV_RESULT; l2 = sqrtresult * l2; - dst->x = (l2 * a->x + (1LL << (0x2D - 1))) >> 0x2D; - dst->y = (l2 * a->y + (1LL << (0x2D - 1))) >> 0x2D; - dst->z = (l2 * a->z + (1LL << (0x2D - 1))) >> 0x2D; + dst->x = (fx16)((l2 * a->x + (1LL << (0x2D - 1))) >> 0x2D); + dst->y = (fx16)((l2 * a->y + (1LL << (0x2D - 1))) >> 0x2D); + dst->z = (fx16)((l2 * a->z + (1LL << (0x2D - 1))) >> 0x2D); } ARM_FUNC void VEC_MultAdd(fx32 factor, struct Vecx32 *a, struct Vecx32 *b, struct Vecx32 *dst){ diff --git a/arm9/src/main.c b/arm9/src/main.c index 9e6a6227..14abf075 100644 --- a/arm9/src/main.c +++ b/arm9/src/main.c @@ -10,7 +10,6 @@ FS_EXTERN_OVERLAY(MODULE_63); extern struct Unk21C48B8 gUnknown21C48B8; -extern void OS_WaitIrq(); extern void FUN_02016438(s32); extern void InitSystemForTheGame(void); extern void InitGraphicMemory(void); diff --git a/arm9/src/poke_overlay.c b/arm9/src/poke_overlay.c index 787cd65a..b557d412 100644 --- a/arm9/src/poke_overlay.c +++ b/arm9/src/poke_overlay.c @@ -3,21 +3,8 @@ #include "FS_file.h" #include "poke_overlay.h" -struct LoadedOverlay { - FSOverlayID id; - BOOL active; -}; - static struct LoadedOverlay gLoadedOverlays[3][8]; -struct LoadedOverlay* GetLoadedOverlaysInRegion(int); -BOOL GetOverlayRamBounds(FSOverlayID, void**, void**); -BOOL CanOverlayBeLoaded(FSOverlayID); -int GetOverlayLoadDestination(FSOverlayID); -BOOL LoadOverlayNormal(MIProcessor, FSOverlayID); -BOOL LoadOverlayNoInit(MIProcessor, FSOverlayID); -BOOL LoadOverlayNoInitAsync(MIProcessor, FSOverlayID); - THUMB_FUNC void FreeOverlayAllocation(struct LoadedOverlay * loaded) { if (loaded->active != TRUE) @@ -41,7 +28,7 @@ THUMB_FUNC void UnloadOverlayByID(FSOverlayID id) } } -THUMB_FUNC int GetOverlayLoadDestination(FSOverlayID id) +THUMB_FUNC s32 GetOverlayLoadDestination(FSOverlayID id) { FSOverlayInfo info; u8 *end; @@ -59,7 +46,7 @@ THUMB_FUNC int GetOverlayLoadDestination(FSOverlayID id) return OVERLAY_LOAD_WRAM; } -THUMB_FUNC BOOL HandleLoadOverlay(FSOverlayID id, int a1) +THUMB_FUNC BOOL HandleLoadOverlay(FSOverlayID id, s32 a1) { u32 sp0 = FS_DMA_NOT_USE; struct LoadedOverlay *r3; @@ -140,7 +127,7 @@ THUMB_FUNC BOOL CanOverlayBeLoaded(FSOverlayID id) return TRUE; } -THUMB_FUNC struct LoadedOverlay* GetLoadedOverlaysInRegion(int a0) +THUMB_FUNC struct LoadedOverlay* GetLoadedOverlaysInRegion(s32 a0) { switch (a0) { diff --git a/arm9/src/string_util.c b/arm9/src/string_util.c index e6ea85de..e36f1a30 100644 --- a/arm9/src/string_util.c +++ b/arm9/src/string_util.c @@ -1,4 +1,4 @@ -#include "global.h"
+#include "string_util.h"
#define EOS 0xFFFF
#define NON_DIGIT 0xE2
@@ -124,23 +124,17 @@ THUMB_FUNC u16 *StringFillEOS(u16 *dest, u32 num) return StringFill(dest, EOS, num);
}
-enum PrintingMode {
- NORMAL,
- PAD_SPACE,
- PAD_ZEROES
-};
-
THUMB_FUNC u16 *ConvertUIntToDecimalString(u16 *dest, u32 value, enum PrintingMode mode, u32 n)
{
- for (u32 x = gPowersOfTen[n - 1]; x != 0; x = x / 10) {
- u16 res = value / x;
+ for (u32 x = (u32)gPowersOfTen[n - 1]; x != 0; x = x / 10) {
+ u16 res = (u16)(value / x);
value = value - x * res;
if (mode == PAD_ZEROES) {
- *dest = res >= 10 ? NON_DIGIT : gDigitTable[res];
+ *dest = res >= 10 ? (u16)NON_DIGIT : gDigitTable[res];
dest++;
} else if (res != 0 || x == 1) {
mode = PAD_ZEROES;
- *dest = res >= 10 ? NON_DIGIT : gDigitTable[res];
+ *dest = res >= 10 ? (u16)NON_DIGIT : gDigitTable[res];
dest++;
} else if (mode == PAD_SPACE) {
*dest = 1;
diff --git a/include/main.h b/include/main.h index 6f75b2f7..fd2801de 100644 --- a/include/main.h +++ b/include/main.h @@ -68,6 +68,7 @@ struct UnkStruct_021C4918 { u8 unk6; u8 unk7; u8 unk8; + u8 padding[3]; }; extern struct UnkStruct_021C4918 gUnk021C4918; @@ -75,4 +76,6 @@ extern struct UnkStruct_021C4918 gUnk021C4918; extern struct Unk2106FA0 gBacklightTop; extern struct Unk2106FA0 gBacklightTop_2; // same as the first one, it's referenced twice in the constant pool... +void NitroMain(void); + #endif //GUARD_MAIN_H diff --git a/include/poke_overlay.h b/include/poke_overlay.h index 5ee9073a..400f600e 100644 --- a/include/poke_overlay.h +++ b/include/poke_overlay.h @@ -7,7 +7,20 @@ #define OVERLAY_LOAD_ITCM 1 #define OVERLAY_LOAD_DTCM 2 +struct LoadedOverlay { + FSOverlayID id; + BOOL active; +}; + +void FreeOverlayAllocation(struct LoadedOverlay * loaded); void UnloadOverlayByID(FSOverlayID id); -BOOL HandleLoadOverlay(FSOverlayID id, int a1); +s32 GetOverlayLoadDestination(FSOverlayID id); +BOOL HandleLoadOverlay(FSOverlayID id, s32 a1); +BOOL CanOverlayBeLoaded(FSOverlayID id); +struct LoadedOverlay* GetLoadedOverlaysInRegion(s32 a0); +BOOL GetOverlayRamBounds(FSOverlayID id, void ** start, void ** end); +BOOL LoadOverlayNormal(MIProcessor target, FSOverlayID id); +BOOL LoadOverlayNoInit(MIProcessor target, FSOverlayID id); +BOOL LoadOverlayNoInitAsync(MIProcessor target, FSOverlayID id); #endif //GUARD_POKE_OVERLAY_H diff --git a/include/pokemon.h b/include/pokemon.h index a350d1a1..8886c47c 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -112,6 +112,7 @@ typedef struct { u8 friendship; u8 ability; u8 circleMarking:1, triangleMarking:1, squareMarking:1, heartMarking:1, starMarking:1, diamondMarking:1; + u8 padding; OriginLanguage originLanguage; u8 hpEV; u8 atkEV; @@ -179,9 +180,11 @@ typedef struct { u8 pokerus; u8 pokeball; u8 flags; + u8 padding[3]; EncounterType encounterType; u8 HGSS_Pokeball; u8 HGSS_Performance; + u8 padding2[2]; } PokemonDataBlockD; typedef union { diff --git a/include/string_util.h b/include/string_util.h new file mode 100644 index 00000000..53d4e5f4 --- /dev/null +++ b/include/string_util.h @@ -0,0 +1,25 @@ +// +// Created by red031000 on 2020-05-24. +// + +#ifndef POKEDIAMOND_STRING_UTIL_H +#define POKEDIAMOND_STRING_UTIL_H + +#include "global.h" + +enum PrintingMode { + NORMAL, + PAD_SPACE, + PAD_ZEROES +}; + +void StringCopy(u16 *dest, const u16 *src); +u16 *StringCopyN(u16 *dest, const u16 *src, u32 num); +u32 StringLength(const u16 *s); +BOOL StringNotEqual(const u16 *s1, const u16 *s2); +BOOL StringNotEqualN(const u16 *s1, const u16 *s2, u32 num); +u16 *StringFill(u16 *dest, u16 value, u32 num); +u16 *StringFillEOS(u16 *dest, u32 num); +u16 *ConvertUIntToDecimalString(u16 *dest, u32 value, enum PrintingMode mode, u32 n); + +#endif //POKEDIAMOND_STRING_UTIL_H diff --git a/include/structs.h b/include/structs.h index 8c9657be..fbcf6e0c 100644 --- a/include/structs.h +++ b/include/structs.h @@ -17,11 +17,13 @@ struct UnkStruct_021C59C8_Sub20224 { struct UnkStruct_021C59C8_Sub_20464 { u8 unk_0; + u8 padding[3]; int unk_4; int unk_8; u8 unk_C; u8 unk_D; u8 unk_E; + u8 padding2; }; struct UnkStruct_021C59C8 { |