correct file system/math boundaries

This commit is contained in:
DizzyEggg 2025-06-30 11:37:09 +02:00
parent df851221fa
commit 2446490760
5 changed files with 93 additions and 108 deletions

View File

@ -11,4 +11,4 @@
#define _(x) x
#endif
ALIGNED(4) static const u8 sFill[] = _("pksdir0");
ALIGNED(4) static const u8 sPksDir0[] = _("pksdir0");

View File

@ -1,82 +0,0 @@
// ALIGNED(4) static const u8 sFill[] = _("pksdir0");
static const u32 gUnknown_80B96E4[300] = {
0, 0, 45426, 71998,
90852, 105476, 117424, 127527,
136278, 143997, 150902, 157148,
162850, 168096, 172953, 177474,
181704, 185677, 189423, 192966,
196328, 199525, 202574, 205487,
208276, 210952, 213522, 215995,
218379, 220679, 222900, 225049,
227130, 229147, 231103, 233003,
234849, 236645, 238392, 240095,
241754, 243372, 244951, 246494,
248000, 249473, 250913, 252323,
253703, 255054, 256378, 257676,
258948, 260197, 261422, 262624,
263805, 264965, 266105, 267225,
268326, 269410, 270475, 271524,
272556, 273572, 274573, 275558,
276529, 277486, 278429, 279358,
280275, 281179, 282071, 282950,
283818, 284675, 285521, 286356,
287180, 287994, 288798, 289593,
290378, 291153, 291920, 292677,
293426, 294167, 294899, 295623,
296339, 297048, 297749, 298442,
299129, 299808, 300480, 301145,
301804, 302456, 303102, 303741,
304374, 305001, 305623, 306238,
306848, 307452, 308050, 308643,
309231, 309814, 310391, 310963,
311531, 312093, 312651, 313204,
313753, 314296, 314836, 315371,
315901, 316428, 316950, 317468,
317982, 318492, 318998, 319500,
319999, 320493, 320984, 321472,
321955, 322435, 322912, 323385,
323855, 324321, 324785, 325244,
325701, 326155, 326605, 327052,
327497, 327938, 328376, 328812,
329245, 329674, 330101, 330525,
330947, 331366, 331782, 332195,
332606, 333014, 333420, 333824,
334224, 334623, 335019, 335412,
335804, 336193, 336579, 336964,
337346, 337726, 338103, 338479,
338852, 339224, 339593, 339960,
340325, 340688, 341049, 341408,
341766, 342121, 342474, 342825,
343175, 343523, 343868, 344212,
344555, 344895, 345234, 345571,
345906, 346240, 346571, 346902,
347230, 347557, 347882, 348206,
348528, 348848, 349167, 349485,
349800, 350115, 350428, 350739,
351049, 351357, 351664, 351970,
352274, 352576, 352878, 353178,
353476, 353773, 354069, 354364,
354657, 354949, 355240, 355529,
355817, 356104, 356389, 356674,
356957, 357239, 357519, 357799,
358077, 358354, 358630, 358905,
359179, 359451, 359723, 359993,
360262, 360530, 360797, 361063,
361328, 361591, 361854, 362116,
362376, 362636, 362894, 363152,
363408, 363664, 363918, 364172,
364424, 364676, 364927, 365176,
365425, 365673, 365920, 366165,
366410, 366655, 366898, 367140,
367381, 367622, 367861, 368100,
368338, 368575, 368811, 369047,
369281, 369515, 369748, 369980,
370211, 370441, 370671, 370899,
371127, 371354, 371581, 371806,
372031, 372255, 372479, 372701,
372923, 373144, 373364, 373584
};
ALIGNED(4) static const u8 gUnknown_80B9B94[] = _("pksdir0");
ALIGNED(4) static const u8 gUnknown_80B9B9C[] = _("not find file [%s]\n");

View File

@ -174,3 +174,81 @@ static const u32 sFastAtan2Lookup256[] = {
30, 30, 30, 30, 31, 31, 31, 31,
31, 31, 31, 31, 31, 31, 31, 31,
};
static const u32 gUnknown_80B96E4[300] = {
0, 0, 45426, 71998,
90852, 105476, 117424, 127527,
136278, 143997, 150902, 157148,
162850, 168096, 172953, 177474,
181704, 185677, 189423, 192966,
196328, 199525, 202574, 205487,
208276, 210952, 213522, 215995,
218379, 220679, 222900, 225049,
227130, 229147, 231103, 233003,
234849, 236645, 238392, 240095,
241754, 243372, 244951, 246494,
248000, 249473, 250913, 252323,
253703, 255054, 256378, 257676,
258948, 260197, 261422, 262624,
263805, 264965, 266105, 267225,
268326, 269410, 270475, 271524,
272556, 273572, 274573, 275558,
276529, 277486, 278429, 279358,
280275, 281179, 282071, 282950,
283818, 284675, 285521, 286356,
287180, 287994, 288798, 289593,
290378, 291153, 291920, 292677,
293426, 294167, 294899, 295623,
296339, 297048, 297749, 298442,
299129, 299808, 300480, 301145,
301804, 302456, 303102, 303741,
304374, 305001, 305623, 306238,
306848, 307452, 308050, 308643,
309231, 309814, 310391, 310963,
311531, 312093, 312651, 313204,
313753, 314296, 314836, 315371,
315901, 316428, 316950, 317468,
317982, 318492, 318998, 319500,
319999, 320493, 320984, 321472,
321955, 322435, 322912, 323385,
323855, 324321, 324785, 325244,
325701, 326155, 326605, 327052,
327497, 327938, 328376, 328812,
329245, 329674, 330101, 330525,
330947, 331366, 331782, 332195,
332606, 333014, 333420, 333824,
334224, 334623, 335019, 335412,
335804, 336193, 336579, 336964,
337346, 337726, 338103, 338479,
338852, 339224, 339593, 339960,
340325, 340688, 341049, 341408,
341766, 342121, 342474, 342825,
343175, 343523, 343868, 344212,
344555, 344895, 345234, 345571,
345906, 346240, 346571, 346902,
347230, 347557, 347882, 348206,
348528, 348848, 349167, 349485,
349800, 350115, 350428, 350739,
351049, 351357, 351664, 351970,
352274, 352576, 352878, 353178,
353476, 353773, 354069, 354364,
354657, 354949, 355240, 355529,
355817, 356104, 356389, 356674,
356957, 357239, 357519, 357799,
358077, 358354, 358630, 358905,
359179, 359451, 359723, 359993,
360262, 360530, 360797, 361063,
361328, 361591, 361854, 362116,
362376, 362636, 362894, 363152,
363408, 363664, 363918, 364172,
364424, 364676, 364927, 365176,
365425, 365673, 365920, 366165,
366410, 366655, 366898, 367140,
367381, 367622, 367861, 368100,
368338, 368575, 368811, 369047,
369281, 369515, 369748, 369980,
370211, 370441, 370671, 370899,
371127, 371354, 371581, 371806,
372031, 372255, 372479, 372701,
372923, 373144, 373364, 373584
};

View File

@ -1,35 +1,13 @@
#include "global.h"
#include "globaldata.h"
#include "decompress_sir.h"
#include "file_system.h"
// size: 0x8
typedef struct UnkFileStruct
{
/* 0x0 */ u32 unk0;
/* 0x4 */ u32 unk4;
} UnkFileStruct;
EWRAM_DATA u32 gUnknown_202D2A4 = {0};
EWRAM_DATA OpenedFile gFileCache[64] = {0};
static EWRAM_INIT u32 sFileCacheCursorPosition = {0};
#include "data/file_system.h"
UNUSED static void FP48_16_Log(UnkFileStruct *r0, s32 r1)
{
s32 temp;
temp = r1;
if (temp < 1)
temp = 1;
if (temp > 299)
temp = 299;
r0->unk4 = gUnknown_80B96E4[temp];
r0->unk0 = 0;
}
void InitFileSystem(void)
{
s32 i;
@ -61,7 +39,7 @@ OpenedFile *OpenFile(const u8 *filename, const FileArchive *arc)
const File *entries;
const File *file;
magic = strcmp(arc->magic, gUnknown_80B9B94) != 0;
magic = AreStringsDifferent(arc->magic, sPksDir0);
magicFound = 0;
@ -92,7 +70,7 @@ OpenedFile *OpenFile(const u8 *filename, const FileArchive *arc)
file = &entries[left];
if (strcmp(file->name, filename)) {
sprintf(buffer, gUnknown_80B9B9C, filename);
sprintf(buffer, _("not find file [%s]\n"), filename);
return NULL;
}

View File

@ -940,3 +940,14 @@ UNUSED void FP48_16_Hypot(s48_16 *dst, s48_16 *a, s48_16 *b)
*dst = sp0;
}
UNUSED static void FP48_16_Log(s48_16 *dst, s32 a)
{
if (a < 1)
a = 1;
if (a >= ARRAY_COUNT_INT(gUnknown_80B96E4))
a = ARRAY_COUNT_INT(gUnknown_80B96E4) - 1;
dst->lo = gUnknown_80B96E4[a];
dst->hi = 0;
}