mirror of
https://github.com/HarbourMasters/SpaghettiKart
synced 2026-09-04 19:01:31 -04:00
7937896598
* support a more flexible background * remove useless function * rename of some font * experimental png * migrate to the new initdata * fix skybox and adjust minimap * format in audio * simplify player render * simplify shell render and support custom texture of shell * clean redshell texture * format and multiple fix * some update of name * allow change icon of character * more rename * continue rename * more documentation and simplification * change lus and continue rename * continue rename * few fix for asan * fix ghost * Update menu_items.c * fix mac error * some test of tweak for texture * some tweak * some button constant * finish fix ghost * Update menu_items.c * Update render_objects.c * Update menu_items.c * Update libultraship * Update libultraship * Delete valgrind.report * Update libultraship * callgrind benchmark * Update valgrind_callgrind.sh * fix animation * some rename * remove useless submodule * Update libultraship * fix assets * fix mistake * fix more mistake * Update menu_items.c * sync more rename with the decom + fix review * fix a mistake * fix more mistake * re add the limit of fps * fix some hd texture and minimap * fix a name * Update menu_items.c * fix a regression * fix some segment 5 texture (not all) * Update camera.c * improve performance of custom sprite * fix flatten bug and add documentation on player vertex * Update render_player.c * fix data menu * fix trophy for 50 and 150 * Update memory.c * Update code_80057C60.c * fix ghost * fix boo tlut * fix a mistake in yaml * fix yaml * Update common_data.yml * add comment for segment 3 * allow even more change in texture * Update common_data.yml * Update update.inc.c * Update camera.c * Update some_data.c * wip changes * Update other_textures.yml * More changes * Update update_objects.c * Fix compile * Update memory.c * Update memory.c --------- Co-authored-by: MegaMech <MegaMech@users.noreply.github.com>
145 lines
3.9 KiB
C
145 lines
3.9 KiB
C
#include <libultraship.h>
|
|
#include <libultraship/libultra.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <stubs.h>
|
|
#include "save.h"
|
|
|
|
struct state_pak {
|
|
OSPfsState state;
|
|
FILE* file;
|
|
};
|
|
|
|
struct state_pak openFile[16];
|
|
|
|
int fileIndex = 0;
|
|
|
|
u32 osTvType = OS_TV_NTSC;
|
|
u32 osResetType;
|
|
|
|
u8 osAppNmiBuffer[64];
|
|
|
|
void rmonPrintf(const char* fmt, ...) {
|
|
}
|
|
|
|
void func_80040030(u8* arg0, u8* arg1) {
|
|
}
|
|
|
|
void func_80040174(void* arg0, s32 arg1, s32 arg2) {
|
|
}
|
|
|
|
s32 osAiSetFrequency(u32 freq) {
|
|
return 1;
|
|
}
|
|
|
|
void mio0decode(u8* arg0, u8* arg1) {
|
|
arg1 = arg0;
|
|
}
|
|
|
|
s32 mio0encode(s32 input, s32 arg1, s32 arg2) {
|
|
return 1;
|
|
}
|
|
|
|
void osStartThread(OSThread* thread) {
|
|
}
|
|
|
|
void osCreateThread(OSThread* thread, OSId id, void (*entry)(void*), void* arg, void* sp, OSPri pri) {
|
|
}
|
|
|
|
void osInitialize(void) {
|
|
}
|
|
|
|
void osSetThreadPri(OSThread* thread, OSPri pri) {
|
|
}
|
|
|
|
void osSpTaskLoad(OSTask* task) {
|
|
}
|
|
|
|
void osSpTaskStartGo(OSTask* task) {
|
|
}
|
|
|
|
void osSpTaskYield(void) {
|
|
}
|
|
|
|
OSYieldResult osSpTaskYielded(OSTask* task) {
|
|
}
|
|
|
|
s32 osPfsDeleteFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name, u8* ext_name) {
|
|
char filename[1024];
|
|
sprintf(filename, "channel_%d_%hu_%hd_%s.sav", pfs->channel, company_code, game_code, game_name);
|
|
remove(filename);
|
|
return PFS_NO_ERROR;
|
|
}
|
|
|
|
s32 osPfsReadWriteFile(OSPfs* pfs, s32 file_no, u8 flag, int offset, int size_in_bytes, u8* data_buffer) {
|
|
if (flag == PFS_READ) {
|
|
fseek(openFile[file_no].file, offset, SEEK_SET);
|
|
fread(data_buffer, size_in_bytes, 1, openFile[file_no].file);
|
|
} else {
|
|
fseek(openFile[file_no].file, offset, SEEK_SET);
|
|
fwrite(data_buffer, size_in_bytes, 1, openFile[file_no].file);
|
|
}
|
|
return PFS_NO_ERROR;
|
|
}
|
|
|
|
s32 osPfsAllocateFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name, u8* ext_name, int file_size_in_bytes,
|
|
s32* file_no) {
|
|
char filename[1024];
|
|
sprintf(filename, "channel_%d_%hu_%hd_%s.sav", pfs->channel, company_code, game_code, game_name);
|
|
*file_no = fileIndex++;
|
|
openFile[*file_no].file = fopen(filename, "w+");
|
|
fwrite("\0", 1, file_size_in_bytes, openFile[*file_no].file);
|
|
openFile[*file_no].state.company_code = company_code;
|
|
openFile[*file_no].state.game_code = game_code;
|
|
strcpy(openFile[*file_no].state.game_name, game_name);
|
|
strcpy(openFile[*file_no].state.ext_name, ext_name);
|
|
return PFS_NO_ERROR;
|
|
}
|
|
|
|
s32 osPfsIsPlug(OSMesgQueue* queue, u8* pattern) {
|
|
}
|
|
|
|
s32 osPfsInit(OSMesgQueue* queue, OSPfs* pfs, int channel) {
|
|
pfs->queue = queue;
|
|
pfs->channel = channel;
|
|
pfs->status = 0;
|
|
pfs->status |= PFS_INITIALIZED;
|
|
return PFS_NO_ERROR;
|
|
}
|
|
|
|
s32 osPfsNumFiles(OSPfs* pfs, s32* max_files, s32* files_used) {
|
|
*max_files = 16;
|
|
*files_used = fileIndex;
|
|
return 0;
|
|
}
|
|
|
|
s32 osPfsFileState(OSPfs* pfs, s32 file_no, OSPfsState* state) {
|
|
}
|
|
|
|
s32 osPfsFreeBlocks(OSPfs* pfs, s32* bytes_not_used) {
|
|
*bytes_not_used = 0x1000;
|
|
return PFS_NO_ERROR;
|
|
}
|
|
|
|
s32 osPfsFindFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name, u8* ext_name, s32* file_no) {
|
|
char filename[1024];
|
|
sprintf(filename, "channel_%d_%hu_%hd_%s.sav", pfs->channel, company_code, game_code, game_name);
|
|
for (size_t i = 0; i < 16; i++) {
|
|
if (openFile[i].state.game_code == game_code && openFile[i].state.company_code == company_code &&
|
|
strcmp(openFile[i].state.game_name, game_name) == 0 && strcmp(openFile[i].state.ext_name, ext_name) == 0) {
|
|
*file_no = i;
|
|
return PFS_NO_ERROR;
|
|
}
|
|
}
|
|
*file_no = fileIndex++;
|
|
openFile[*file_no].file = fopen(filename, "r+");
|
|
if (openFile[*file_no].file == NULL) {
|
|
openFile[*file_no].file = fopen(filename, "w+");
|
|
}
|
|
openFile[*file_no].state.company_code = company_code;
|
|
openFile[*file_no].state.game_code = game_code;
|
|
strcpy(openFile[*file_no].state.game_name, game_name);
|
|
strcpy(openFile[*file_no].state.ext_name, ext_name);
|
|
return PFS_NO_ERROR;
|
|
}
|