mirror of
https://github.com/N64Recomp/N64ModernRuntime.git
synced 2025-10-30 08:02:29 +00:00
Pak.cpp: cleanup
This commit is contained in:
parent
ece48700a8
commit
1834cef9c9
1 changed files with 3 additions and 18 deletions
|
|
@ -158,17 +158,6 @@ extern "C" void osPfsInitPak_recomp(uint8_t* rdram, recomp_context* ctx) {
|
||||||
extern "C" void osPfsFreeBlocks_recomp(uint8_t* rdram, recomp_context* ctx) {
|
extern "C" void osPfsFreeBlocks_recomp(uint8_t* rdram, recomp_context* ctx) {
|
||||||
s32* bytes_not_used = _arg<1, s32*>(rdram, ctx);
|
s32* bytes_not_used = _arg<1, s32*>(rdram, ctx);
|
||||||
|
|
||||||
ControllerPak pak;
|
|
||||||
|
|
||||||
pak.header.open("controllerPak_header.sav", std::ios::binary | std::ios::in | std::ios::out);
|
|
||||||
|
|
||||||
if (!pak.header.good()) {
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
if (!pak.header.is_open()) {
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
s32 usedSpace = 0;
|
s32 usedSpace = 0;
|
||||||
for (size_t i = 0; i < MAX_FILES; i++) {
|
for (size_t i = 0; i < MAX_FILES; i++) {
|
||||||
u32 file_size = 0;
|
u32 file_size = 0;
|
||||||
|
|
@ -186,8 +175,6 @@ extern "C" void osPfsFreeBlocks_recomp(uint8_t* rdram, recomp_context* ctx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pak.header.close();
|
|
||||||
|
|
||||||
*bytes_not_used = (123 - usedSpace) << 8;
|
*bytes_not_used = (123 - usedSpace) << 8;
|
||||||
|
|
||||||
ctx->r2 = 0; // PFS_NO_ERROR
|
ctx->r2 = 0; // PFS_NO_ERROR
|
||||||
|
|
@ -206,8 +193,6 @@ extern "C" void osPfsAllocateFile_recomp(uint8_t* rdram, recomp_context* ctx) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ControllerPak pak;
|
|
||||||
|
|
||||||
/* Search for a free slot */
|
/* Search for a free slot */
|
||||||
u8 freeFileIndex = 0;
|
u8 freeFileIndex = 0;
|
||||||
for (size_t i = 0; i < MAX_FILES; i++) {
|
for (size_t i = 0; i < MAX_FILES; i++) {
|
||||||
|
|
@ -229,6 +214,8 @@ extern "C" void osPfsAllocateFile_recomp(uint8_t* rdram, recomp_context* ctx) {
|
||||||
|
|
||||||
/* Create empty file */
|
/* Create empty file */
|
||||||
|
|
||||||
|
ControllerPak pak;
|
||||||
|
|
||||||
char filename[100];
|
char filename[100];
|
||||||
sprintf(filename, "controllerPak_file_%d.sav", freeFileIndex);
|
sprintf(filename, "controllerPak_file_%d.sav", freeFileIndex);
|
||||||
pak.file.open(filename, std::ios::binary | std::ios::in | std::ios::out | std::ios::trunc);
|
pak.file.open(filename, std::ios::binary | std::ios::in | std::ios::out | std::ios::trunc);
|
||||||
|
|
@ -263,7 +250,7 @@ extern "C" void osPfsFileState_recomp(uint8_t* rdram, recomp_context* ctx) {
|
||||||
// should pass the state of the requested file_no to the incoming state pointer,
|
// should pass the state of the requested file_no to the incoming state pointer,
|
||||||
// games call this function 16 times, once per file
|
// games call this function 16 times, once per file
|
||||||
// fills the incoming state with the information inside the header of the pak.
|
// fills the incoming state with the information inside the header of the pak.
|
||||||
// If a header file doesn't exist, create it.
|
|
||||||
char filename[100];
|
char filename[100];
|
||||||
sprintf(filename, "controllerPak_file_%d.sav", file_no);
|
sprintf(filename, "controllerPak_file_%d.sav", file_no);
|
||||||
if (!std::filesystem::exists(filename)) {
|
if (!std::filesystem::exists(filename)) {
|
||||||
|
|
@ -295,8 +282,6 @@ extern "C" void osPfsFindFile_recomp(uint8_t* rdram, recomp_context* ctx) {
|
||||||
u8* ext_name = TO_PTR(u8, MEM_W(0x10, ctx->r29));
|
u8* ext_name = TO_PTR(u8, MEM_W(0x10, ctx->r29));
|
||||||
s32* file_no = TO_PTR(s32, MEM_W(0x14, ctx->r29));
|
s32* file_no = TO_PTR(s32, MEM_W(0x14, ctx->r29));
|
||||||
|
|
||||||
ControllerPak pak;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < MAX_FILES; i++) {
|
for (size_t i = 0; i < MAX_FILES; i++) {
|
||||||
u32 file_size_ = 0;
|
u32 file_size_ = 0;
|
||||||
u32 game_code_ = 0;
|
u32 game_code_ = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue