mirror of https://github.com/zeldaret/mm.git
sys_flashrom matched (#1251)
* done * WIP * Fix the rebase * fix build * re match * Last thing before the PR * PR fixes * PR Fixes (tharo) * fix * format * PR fixes (hensldm) * oops * MAGIC * Fix BSS and rename FLASH_MAGIC * PR Fixes (Engineer) * remove from functions.h
This commit is contained in:
parent
4143097c5a
commit
51cd9df591
|
@ -2222,21 +2222,13 @@ void func_8018450C(PlayState* play, SkeletonInfo* skeleton, Mtx* mtx, OverrideKe
|
|||
// void func_801853C8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6);
|
||||
// void func_80185460(void);
|
||||
|
||||
// void func_801857C0(void);
|
||||
// char* func_801857D0(void);
|
||||
// void func_80185864(void);
|
||||
u32 func_80185908(void);
|
||||
UNK_TYPE func_80185968(void* arg0, UNK_TYPE arg1, UNK_TYPE arg2);
|
||||
// void func_801859F0(void);
|
||||
// void func_80185A2C(void);
|
||||
// void func_80185B1C(void);
|
||||
// void func_80185BE4(void);
|
||||
// void func_80185C24(void);
|
||||
void SysFlashrom_ThreadEntry(s80185D40* param_1);
|
||||
void func_80185DDC(u8* arg0, u32 arg1, u32 arg2);
|
||||
s32 func_80185EC4(void);
|
||||
s32 func_80185F04(void);
|
||||
void func_80185F64(void* arg0, UNK_TYPE arg1, UNK_TYPE arg2);
|
||||
s32 SysFlashrom_InitFlash(void);
|
||||
s32 SysFlashrom_ReadData(void* addr, u32 pageNum, u32 pageCount);
|
||||
void SysFlashrom_WriteDataAsync(u8* addr, u32 pageNum, u32 pageCount);
|
||||
s32 SysFlashrom_IsBusy(void);
|
||||
s32 SysFlashrom_AwaitResult(void);
|
||||
void SysFlashrom_WriteDataSync(void* addr, u32 pageNum, u32 pageCount);
|
||||
|
||||
s32 func_80185F90(u32 param_1);
|
||||
u32 osFlashGetAddr(u32 pageNum);
|
||||
OSPiHandle* osFlashReInit(u8 latency, u8 pulse, u8 pageSize, u8 relDuration, u32 start);
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
#define Z_THREAD_ID_MAIN 3
|
||||
#define Z_THREAD_ID_GRAPH 4
|
||||
#define Z_THREAD_ID_SCHED 5
|
||||
#define Z_THREAD_ID_FLASHROM 13
|
||||
#define Z_THREAD_ID_DMAMGR 18
|
||||
#define Z_THREAD_ID_IRQMGR 19
|
||||
|
||||
|
@ -76,6 +77,7 @@
|
|||
#define Z_PRIORITY_AUDIOMGR 11
|
||||
#define Z_PRIORITY_IDLE 12
|
||||
#define Z_PRIORITY_MAIN 12
|
||||
#define Z_PRIORITY_FLASHROM 13
|
||||
#define Z_PRIORITY_PADMGR 15
|
||||
#define Z_PRIORITY_SCHED 16
|
||||
#define Z_PRIORITY_DMAMGR 17
|
||||
|
@ -118,13 +120,13 @@ typedef struct {
|
|||
} NmiBuff; // size >= 0x18
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ int unk0;
|
||||
/* 0x04 */ void* unk4;
|
||||
/* 0x08 */ int unk8;
|
||||
/* 0x0C */ int unkC;
|
||||
/* 0x10 */ int unk10;
|
||||
/* 0x14 */ OSMesgQueue unk14;
|
||||
} s80185D40; // size = 0x2C
|
||||
/* 0x00 */ s32 requestType;
|
||||
/* 0x04 */ OSMesg response;
|
||||
/* 0x08 */ void* addr;
|
||||
/* 0x0C */ s32 pageNum;
|
||||
/* 0x10 */ s32 pageCount;
|
||||
/* 0x14 */ OSMesgQueue messageQueue;
|
||||
} FlashromRequest; // size = 0x2C
|
||||
|
||||
// End of RDRAM without the Expansion Pak installed
|
||||
#define NORMAL_RDRAM_END 0x80400000
|
||||
|
@ -642,6 +644,19 @@ typedef struct {
|
|||
#define FRAM_STATUS_REGISTER FRAM_BASE_ADDRESS // FRAM Base Address in Cart Memory
|
||||
#define FRAM_COMMAND_REGISTER 0x10000 // Located at 0x08010000 on the Cart
|
||||
|
||||
#define FLASH_VERSION_MX_PROTO_A 0x00C20000
|
||||
#define FLASH_VERSION_MX_A 0x00C20001
|
||||
#define FLASH_VERSION_MX_C 0x00C2001E
|
||||
#define FLASH_VERSION_MX_B_AND_D 0x00C2001D
|
||||
#define FLASH_VERSION_MEI 0x003200F1
|
||||
|
||||
#define FLASH_TYPE_MAGIC 0x11118001
|
||||
|
||||
#define FLASH_PAGE_SIZE 128
|
||||
|
||||
#define FLASHROM_REQUEST_WRITE 1
|
||||
#define FLASHROM_REQUEST_READ 2
|
||||
|
||||
enum fram_command {
|
||||
/* Does nothing for FRAM_COMMAND_SET_MODE_READ_AND_STATUS, FRAM_MODE_NOP, FRAM_COMMAND_SET_MODE_STATUS_AND_STATUS
|
||||
Initializes fram to 0xFF in FRAM_MODE_ERASE
|
||||
|
|
1
spec
1
spec
|
@ -588,7 +588,6 @@ beginseg
|
|||
include "build/src/code/c_keyframe.o"
|
||||
include "build/src/code/sys_slowly.o"
|
||||
include "build/src/code/sys_flashrom.o"
|
||||
include "build/data/code/sys_flashrom.bss.o"
|
||||
include "build/asm/code/code_80185F90.text.o" // handwritten
|
||||
include "build/src/libultra/flash/osFlash.o"
|
||||
pad_text
|
||||
|
|
|
@ -1,44 +1,253 @@
|
|||
#include "prevent_bss_reordering.h"
|
||||
#include "global.h"
|
||||
#include "stack.h"
|
||||
#include "stackcheck.h"
|
||||
#include "system_malloc.h"
|
||||
|
||||
// extern UNK_TYPE1 D_801FBE10;
|
||||
// extern UNK_TYPE1 D_801FBE28;
|
||||
// extern UNK_TYPE1 D_801FBE2C;
|
||||
// extern UNK_TYPE4 D_801FBE30;
|
||||
extern STACK(sSysFlashromStack, 0x1000);
|
||||
extern StackEntry sSysFlashromStackInfo;
|
||||
extern OSThread sSysFlashromThread;
|
||||
extern s80185D40 D_801FD008;
|
||||
extern OSMesg D_801FD034[1];
|
||||
OSMesgQueue sFlashromMesgQueue;
|
||||
OSMesg sFlashromMesg[1];
|
||||
s32 sFlashromIsInit;
|
||||
s32 sFlashromVendor;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_flashrom/func_801857C0.s")
|
||||
STACK(sSysFlashromStack, 0x1000);
|
||||
StackEntry sSysFlashromStackInfo;
|
||||
OSThread sSysFlashromThread;
|
||||
FlashromRequest sFlashromRequest;
|
||||
OSMesg sSysFlashromMsgBuf[1];
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_flashrom/func_801857D0.s")
|
||||
s32 SysFlashrom_IsInit(void) {
|
||||
return sFlashromIsInit;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_flashrom/func_80185864.s")
|
||||
const char* SysFlashrom_GetVendorStr(void) {
|
||||
switch (sFlashromVendor) {
|
||||
case FLASH_VERSION_MX_PROTO_A:
|
||||
return "PROTO A";
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_flashrom/func_80185908.s")
|
||||
case FLASH_VERSION_MX_A:
|
||||
return "A";
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_flashrom/func_80185968.s")
|
||||
case FLASH_VERSION_MX_C:
|
||||
return "C";
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_flashrom/func_801859F0.s")
|
||||
case FLASH_VERSION_MEI:
|
||||
return "D(NEW)";
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_flashrom/func_80185A2C.s")
|
||||
case FLASH_VERSION_MX_B_AND_D:
|
||||
return "B or D";
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_flashrom/func_80185B1C.s")
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_flashrom/func_80185BE4.s")
|
||||
s32 SysFlashrom_CheckFlashType(void) {
|
||||
u32 flashType;
|
||||
u32 flashVendor;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_flashrom/func_80185C24.s")
|
||||
if (!SysFlashrom_IsInit()) {
|
||||
return -1;
|
||||
}
|
||||
osFlashReadId(&flashType, &flashVendor);
|
||||
sFlashromVendor = flashVendor;
|
||||
if (flashType == FLASH_TYPE_MAGIC) {
|
||||
if ((flashVendor == FLASH_VERSION_MX_PROTO_A) || (flashVendor == FLASH_VERSION_MX_A) ||
|
||||
(flashVendor == FLASH_VERSION_MX_C) || (flashVendor == FLASH_VERSION_MEI) ||
|
||||
(flashVendor == FLASH_VERSION_MX_B_AND_D)) {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_flashrom/SysFlashrom_ThreadEntry.s")
|
||||
s32 SysFlashrom_InitFlash(void) {
|
||||
osCreateMesgQueue(&sFlashromMesgQueue, sFlashromMesg, ARRAY_COUNT(sFlashromMesg));
|
||||
osFlashInit();
|
||||
sFlashromIsInit = true;
|
||||
if (SysFlashrom_CheckFlashType() != 0) {
|
||||
sFlashromIsInit = false;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_flashrom/func_80185DDC.s")
|
||||
s32 SysFlashrom_ReadData(void* addr, u32 pageNum, u32 pageCount) {
|
||||
OSIoMesg msg;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_flashrom/func_80185EC4.s")
|
||||
if (!SysFlashrom_IsInit()) {
|
||||
return -1;
|
||||
}
|
||||
osInvalDCache(addr, pageCount * FLASH_PAGE_SIZE);
|
||||
osFlashReadArray(&msg, OS_MESG_PRI_NORMAL, pageNum, addr, pageCount, &sFlashromMesgQueue);
|
||||
osRecvMesg(&sFlashromMesgQueue, NULL, OS_MESG_BLOCK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_flashrom/func_80185F04.s")
|
||||
s32 SysFlashrom_EraseSector(u32 page) {
|
||||
if (!SysFlashrom_IsInit()) {
|
||||
return -1;
|
||||
}
|
||||
return osFlashSectorErase(page);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_flashrom/func_80185F64.s")
|
||||
s32 SysFlashrom_ExecWrite(void* addr, u32 pageNum, u32 pageCount) {
|
||||
OSIoMesg msg;
|
||||
s32 result;
|
||||
u32 i;
|
||||
|
||||
if (!SysFlashrom_IsInit()) {
|
||||
return -1;
|
||||
}
|
||||
// Ensure the page is always aligned to a sector boundary.
|
||||
if ((pageNum % FLASH_PAGE_SIZE) != 0) {
|
||||
Fault_AddHungupAndCrash("../sys_flashrom.c", 275);
|
||||
}
|
||||
osWritebackDCache(addr, pageCount * FLASH_PAGE_SIZE);
|
||||
for (i = 0; i < pageCount; i++) {
|
||||
osFlashWriteBuffer(&msg, OS_MESG_PRI_NORMAL, (u8*)addr + i * FLASH_PAGE_SIZE, &sFlashromMesgQueue);
|
||||
osRecvMesg(&sFlashromMesgQueue, NULL, OS_MESG_BLOCK);
|
||||
result = osFlashWriteArray(i + pageNum);
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 SysFlashrom_AttemptWrite(void* addr, u32 pageNum, u32 pageCount) {
|
||||
s32 result;
|
||||
s32 i;
|
||||
|
||||
if (!SysFlashrom_IsInit()) {
|
||||
return -1;
|
||||
}
|
||||
osWritebackDCache(addr, pageCount * FLASH_PAGE_SIZE);
|
||||
i = 0;
|
||||
failRetry:
|
||||
result = SysFlashrom_EraseSector(pageNum);
|
||||
if (result != 0) {
|
||||
if (i < 3) {
|
||||
i++;
|
||||
goto failRetry;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
result = SysFlashrom_ExecWrite(addr, pageNum, pageCount);
|
||||
if (result != 0) {
|
||||
if (i < 3) {
|
||||
i++;
|
||||
goto failRetry;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Flash bits can only by flipped with a write from 1 -> 0. Going from 0 -> 1 requires an erasure.
|
||||
// This function will try to determine if any sectors need to be erased before writing saving erase cycles.
|
||||
s32 SysFlashrom_NeedsToErase(void* data, void* addr, u32 pageCount) {
|
||||
u32 size;
|
||||
u32 i;
|
||||
|
||||
for (i = 0; i < pageCount * FLASH_PAGE_SIZE; i += 4) {
|
||||
if ((*(s32*)data & *(s32*)addr) != *(s32*)addr) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
s32 SysFlashrom_WriteData(void* addr, u32 pageNum, u32 pageCount) {
|
||||
void* data;
|
||||
size_t size;
|
||||
s32 ret;
|
||||
|
||||
if (!SysFlashrom_IsInit()) {
|
||||
return -1;
|
||||
}
|
||||
size = pageCount * FLASH_PAGE_SIZE;
|
||||
data = SystemArena_Malloc(size);
|
||||
if (data == NULL) {
|
||||
ret = SysFlashrom_AttemptWrite(addr, pageNum, pageCount);
|
||||
} else {
|
||||
SysFlashrom_ReadData(data, pageNum, pageCount);
|
||||
if (bcmp(data, addr, size) == 0) {
|
||||
ret = 0;
|
||||
} else {
|
||||
// Will always erase the sector even if it wouldn't normally need to.
|
||||
if (SysFlashrom_NeedsToErase(data, addr, pageCount)) {
|
||||
ret = SysFlashrom_AttemptWrite(addr, pageNum, pageCount);
|
||||
} else {
|
||||
ret = SysFlashrom_AttemptWrite(addr, pageNum, pageCount);
|
||||
}
|
||||
if (ret == 0) {
|
||||
SysFlashrom_ReadData(data, pageNum, pageCount);
|
||||
if (bcmp(data, addr, size) == 0) {
|
||||
ret = 0;
|
||||
} else {
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
SystemArena_Free(data);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void SysFlashrom_ThreadEntry(void* arg) {
|
||||
FlashromRequest* req = (FlashromRequest*)arg;
|
||||
|
||||
switch (req->requestType) {
|
||||
case FLASHROM_REQUEST_WRITE:
|
||||
req->response = SysFlashrom_WriteData(req->addr, req->pageNum, req->pageCount);
|
||||
osSendMesg(&req->messageQueue, req->response, OS_MESG_BLOCK);
|
||||
break;
|
||||
|
||||
case FLASHROM_REQUEST_READ:
|
||||
req->response = SysFlashrom_ReadData(req->addr, req->pageNum, req->pageCount);
|
||||
osSendMesg(&req->messageQueue, req->response, OS_MESG_BLOCK);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SysFlashrom_WriteDataAsync(u8* addr, u32 pageNum, u32 pageCount) {
|
||||
FlashromRequest* req = &sFlashromRequest;
|
||||
if (SysFlashrom_IsInit()) {
|
||||
req->requestType = FLASHROM_REQUEST_WRITE;
|
||||
req->addr = addr;
|
||||
req->pageNum = pageNum;
|
||||
req->pageCount = pageCount;
|
||||
osCreateMesgQueue(&req->messageQueue, sSysFlashromMsgBuf, ARRAY_COUNT(sSysFlashromMsgBuf));
|
||||
StackCheck_Init(&sSysFlashromStackInfo, sSysFlashromStack, STACK_TOP(sSysFlashromStack), 0, 0x100,
|
||||
"sys_flashrom");
|
||||
osCreateThread(&sSysFlashromThread, Z_THREAD_ID_FLASHROM, SysFlashrom_ThreadEntry, req,
|
||||
STACK_TOP(sSysFlashromStack), Z_PRIORITY_FLASHROM);
|
||||
osStartThread(&sSysFlashromThread);
|
||||
}
|
||||
}
|
||||
|
||||
s32 SysFlashrom_IsBusy(void) {
|
||||
OSMesgQueue* queue = &sFlashromRequest.messageQueue;
|
||||
|
||||
if (!SysFlashrom_IsInit()) {
|
||||
return -1;
|
||||
}
|
||||
return MQ_IS_FULL(queue);
|
||||
}
|
||||
|
||||
s32 SysFlashrom_AwaitResult(void) {
|
||||
if (!SysFlashrom_IsInit()) {
|
||||
return -1;
|
||||
}
|
||||
osRecvMesg(&sFlashromRequest.messageQueue, NULL, OS_MESG_BLOCK);
|
||||
osDestroyThread(&sSysFlashromThread);
|
||||
StackCheck_Cleanup(&sSysFlashromStackInfo);
|
||||
return sFlashromRequest.response;
|
||||
}
|
||||
|
||||
void SysFlashrom_WriteDataSync(void* addr, u32 pageNum, u32 pageCount) {
|
||||
SysFlashrom_WriteDataAsync(addr, pageNum, pageCount);
|
||||
SysFlashrom_AwaitResult();
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ void Setup_SetRegs(void) {
|
|||
}
|
||||
|
||||
void Setup_InitImpl(SetupState* this) {
|
||||
func_80185908();
|
||||
SysFlashrom_InitFlash();
|
||||
SaveContext_Init();
|
||||
Setup_SetRegs();
|
||||
|
||||
|
|
|
@ -850,14 +850,14 @@ void Sram_ResetSaveFromMoonCrash(SramContext* sramCtx) {
|
|||
|
||||
bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE);
|
||||
|
||||
if (func_80185968(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2], D_801C67F0[gSaveContext.fileNum * 2]) !=
|
||||
0) {
|
||||
func_80185968(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2 + 1],
|
||||
if (SysFlashrom_ReadData(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2],
|
||||
D_801C67F0[gSaveContext.fileNum * 2]) != 0) {
|
||||
SysFlashrom_ReadData(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2 + 1],
|
||||
D_801C67F0[gSaveContext.fileNum * 2 + 1]);
|
||||
}
|
||||
Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save));
|
||||
if (CHECK_NEWF(gSaveContext.save.saveInfo.playerData.newf)) {
|
||||
func_80185968(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2 + 1],
|
||||
SysFlashrom_ReadData(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2 + 1],
|
||||
D_801C67F0[gSaveContext.fileNum * 2 + 1]);
|
||||
Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, sizeof(Save));
|
||||
}
|
||||
|
@ -910,27 +910,27 @@ void Sram_OpenSave(FileSelectState* fileSelect, SramContext* sramCtx) {
|
|||
bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE);
|
||||
|
||||
if (gSaveContext.fileNum == 0xFF) {
|
||||
func_80185968(sramCtx->saveBuf, D_801C67C8[0], D_801C67F0[0]);
|
||||
SysFlashrom_ReadData(sramCtx->saveBuf, D_801C67C8[0], D_801C67F0[0]);
|
||||
} else if (fileSelect->unk_2446A[gSaveContext.fileNum] != 0) {
|
||||
phi_t1 = gSaveContext.fileNum + 2;
|
||||
phi_t1 *= 2;
|
||||
|
||||
if (func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1], D_801C67F0[phi_t1]) != 0) {
|
||||
func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1 + 1], D_801C67F0[phi_t1 + 1]);
|
||||
if (SysFlashrom_ReadData(sramCtx->saveBuf, D_801C67C8[phi_t1], D_801C67F0[phi_t1]) != 0) {
|
||||
SysFlashrom_ReadData(sramCtx->saveBuf, D_801C67C8[phi_t1 + 1], D_801C67F0[phi_t1 + 1]);
|
||||
}
|
||||
} else {
|
||||
phi_t1 = gSaveContext.fileNum;
|
||||
phi_t1 *= 2;
|
||||
|
||||
if (func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1], D_801C67F0[phi_t1]) != 0) {
|
||||
func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1 + 1], D_801C67F0[phi_t1 + 1]);
|
||||
if (SysFlashrom_ReadData(sramCtx->saveBuf, D_801C67C8[phi_t1], D_801C67F0[phi_t1]) != 0) {
|
||||
SysFlashrom_ReadData(sramCtx->saveBuf, D_801C67C8[phi_t1 + 1], D_801C67F0[phi_t1 + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[phi_t1]);
|
||||
|
||||
if (CHECK_NEWF(gSaveContext.save.saveInfo.playerData.newf)) {
|
||||
func_80185968(sramCtx->saveBuf, D_801C67C8[phi_t1 + 1], D_801C67F0[phi_t1 + 1]);
|
||||
SysFlashrom_ReadData(sramCtx->saveBuf, D_801C67C8[phi_t1 + 1], D_801C67F0[phi_t1 + 1]);
|
||||
Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[phi_t1]);
|
||||
}
|
||||
}
|
||||
|
@ -1090,9 +1090,9 @@ void func_801457CC(FileSelectState* fileSelect2, SramContext* sramCtx) {
|
|||
|
||||
phi_s2 = false;
|
||||
sp6E = 0;
|
||||
if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64], D_801C67F0[sp64])) {
|
||||
if (SysFlashrom_ReadData(sramCtx->saveBuf, D_801C67C8[sp64], D_801C67F0[sp64])) {
|
||||
sp6E = 1;
|
||||
if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) {
|
||||
if (SysFlashrom_ReadData(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) {
|
||||
phi_s2 = true;
|
||||
}
|
||||
}
|
||||
|
@ -1115,7 +1115,7 @@ void func_801457CC(FileSelectState* fileSelect2, SramContext* sramCtx) {
|
|||
if (CHECK_NEWF2(gSaveContext.save.saveInfo.playerData.newf)) {}
|
||||
|
||||
phi_s2 = false;
|
||||
if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) {
|
||||
if (SysFlashrom_ReadData(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) {
|
||||
phi_s2 = true;
|
||||
}
|
||||
|
||||
|
@ -1171,7 +1171,7 @@ void func_801457CC(FileSelectState* fileSelect2, SramContext* sramCtx) {
|
|||
func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C6818[sp64]);
|
||||
} else if (sp6E == 0) { // TODO: == 0?
|
||||
temp_s2 = gSaveContext.save.saveInfo.checksum;
|
||||
if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) {
|
||||
if (SysFlashrom_ReadData(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) {
|
||||
phi_s2_3 = 1;
|
||||
} else {
|
||||
Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save));
|
||||
|
@ -1182,7 +1182,7 @@ void func_801457CC(FileSelectState* fileSelect2, SramContext* sramCtx) {
|
|||
|
||||
if (CHECK_NEWF(gSaveContext.save.saveInfo.playerData.newf) || (phi_s2_3 != sp7A) ||
|
||||
(phi_s2_3 != temp_s2)) {
|
||||
func_80185968(sramCtx->saveBuf, D_801C67C8[sp64], D_801C67F0[sp64]);
|
||||
SysFlashrom_ReadData(sramCtx->saveBuf, D_801C67C8[sp64], D_801C67F0[sp64]);
|
||||
Lib_MemCpy(&gSaveContext.save, sramCtx->saveBuf, sizeof(Save));
|
||||
Lib_MemCpy(&sramCtx->saveBuf[0x2000], &gSaveContext.save, sizeof(Save));
|
||||
func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C6818[sp64]);
|
||||
|
@ -1210,7 +1210,7 @@ void func_801457CC(FileSelectState* fileSelect2, SramContext* sramCtx) {
|
|||
phi_s2 = false;
|
||||
}
|
||||
|
||||
if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) {
|
||||
if (SysFlashrom_ReadData(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) {
|
||||
phi_s2 = true;
|
||||
}
|
||||
|
||||
|
@ -1267,7 +1267,7 @@ void func_801457CC(FileSelectState* fileSelect2, SramContext* sramCtx) {
|
|||
func_80146EBC(sramCtx, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1]);
|
||||
} else if (!sp6E) { // TODO: == 0?
|
||||
temp_s2 = gSaveContext.save.saveInfo.checksum;
|
||||
if (func_80185968(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) {
|
||||
if (SysFlashrom_ReadData(sramCtx->saveBuf, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1])) {
|
||||
phi_s2_3 = 1;
|
||||
} else {
|
||||
Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]);
|
||||
|
@ -1279,7 +1279,7 @@ void func_801457CC(FileSelectState* fileSelect2, SramContext* sramCtx) {
|
|||
|
||||
if (CHECK_NEWF(gSaveContext.save.saveInfo.playerData.newf) || (phi_s2_3 != sp7A) ||
|
||||
(phi_s2_3 != temp_s2)) {
|
||||
func_80185968(sramCtx->saveBuf, D_801C67C8[sp64], D_801C67F0[sp64]);
|
||||
SysFlashrom_ReadData(sramCtx->saveBuf, D_801C67C8[sp64], D_801C67F0[sp64]);
|
||||
Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, D_801C6870[sp64]);
|
||||
func_80146EBC(sramCtx, D_801C67C8[sp64], D_801C67F0[sp64]);
|
||||
func_80146EBC(sramCtx, D_801C67C8[sp64 + 1], D_801C67F0[sp64 + 1]);
|
||||
|
@ -1381,10 +1381,11 @@ void func_80146628(FileSelectState* fileSelect2, SramContext* sramCtx) {
|
|||
// clear buffer
|
||||
bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE);
|
||||
// read to buffer
|
||||
func_80185968(sramCtx->saveBuf, D_801C67C8[fileSelect->unk_2448E * 2], D_801C67F0[fileSelect->unk_2448E * 2]);
|
||||
SysFlashrom_ReadData(sramCtx->saveBuf, D_801C67C8[fileSelect->unk_2448E * 2],
|
||||
D_801C67F0[fileSelect->unk_2448E * 2]);
|
||||
|
||||
if (1) {}
|
||||
func_80185968(&sramCtx->saveBuf[0x2000], D_801C67C8[fileSelect->unk_2448E * 2 + 1],
|
||||
SysFlashrom_ReadData(&sramCtx->saveBuf[0x2000], D_801C67C8[fileSelect->unk_2448E * 2 + 1],
|
||||
D_801C67F0[fileSelect->unk_2448E * 2 + 1]);
|
||||
if (1) {}
|
||||
|
||||
|
@ -1518,7 +1519,7 @@ void Sram_Alloc(GameState* gameState, SramContext* sramCtx) {
|
|||
void func_80146EBC(SramContext* sramCtx, s32 curPage, s32 numPages) {
|
||||
sramCtx->curPage = curPage;
|
||||
sramCtx->numPages = numPages;
|
||||
func_80185F64(sramCtx->saveBuf, curPage, numPages);
|
||||
SysFlashrom_WriteDataSync(sramCtx->saveBuf, curPage, numPages);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1531,7 +1532,8 @@ void Sram_SaveSpecialEnterClockTown(PlayState* play) {
|
|||
gSaveContext.save.isFirstCycle = true;
|
||||
gSaveContext.save.isOwlSave = false;
|
||||
func_80145698(sramCtx);
|
||||
func_80185F64(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2], D_801C6818[gSaveContext.fileNum * 2]);
|
||||
SysFlashrom_WriteDataSync(sramCtx->saveBuf, D_801C67C8[gSaveContext.fileNum * 2],
|
||||
D_801C6818[gSaveContext.fileNum * 2]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1552,7 +1554,8 @@ void Sram_SaveSpecialNewDay(PlayState* play) {
|
|||
gSaveContext.save.day = day;
|
||||
gSaveContext.save.time = time;
|
||||
gSaveContext.save.cutsceneIndex = cutsceneIndex;
|
||||
func_80185F64(play->sramCtx.saveBuf, D_801C67C8[gSaveContext.fileNum * 2], D_801C67F0[gSaveContext.fileNum * 2]);
|
||||
SysFlashrom_WriteDataSync(play->sramCtx.saveBuf, D_801C67C8[gSaveContext.fileNum * 2],
|
||||
D_801C67F0[gSaveContext.fileNum * 2]);
|
||||
}
|
||||
|
||||
void func_80147008(SramContext* sramCtx, u32 curPage, u32 numPages) {
|
||||
|
@ -1563,7 +1566,7 @@ void func_80147008(SramContext* sramCtx, u32 curPage, u32 numPages) {
|
|||
|
||||
void func_80147020(SramContext* sramCtx) {
|
||||
// async flash write
|
||||
func_80185DDC(sramCtx->saveBuf, sramCtx->curPage, sramCtx->numPages);
|
||||
SysFlashrom_WriteDataAsync(sramCtx->saveBuf, sramCtx->curPage, sramCtx->numPages);
|
||||
|
||||
sramCtx->unk_18 = osGetTime();
|
||||
sramCtx->status = 2;
|
||||
|
@ -1571,8 +1574,8 @@ void func_80147020(SramContext* sramCtx) {
|
|||
|
||||
void func_80147068(SramContext* sramCtx) {
|
||||
if (sramCtx->status == 2) {
|
||||
if (func_80185EC4() != 0) { // if task running
|
||||
if (func_80185F04() == 0) { // wait for task done
|
||||
if (SysFlashrom_IsBusy() != 0) { // if task running
|
||||
if (SysFlashrom_AwaitResult() == 0) { // wait for task done
|
||||
// task success
|
||||
sramCtx->status = 4;
|
||||
} else {
|
||||
|
@ -1592,7 +1595,7 @@ void func_80147138(SramContext* sramCtx, s32 curPage, s32 numPages) {
|
|||
}
|
||||
|
||||
void func_80147150(SramContext* sramCtx) {
|
||||
func_80185DDC(sramCtx->saveBuf, sramCtx->curPage, sramCtx->numPages);
|
||||
SysFlashrom_WriteDataAsync(sramCtx->saveBuf, sramCtx->curPage, sramCtx->numPages);
|
||||
|
||||
sramCtx->unk_18 = osGetTime();
|
||||
sramCtx->status = 7;
|
||||
|
@ -1600,18 +1603,18 @@ void func_80147150(SramContext* sramCtx) {
|
|||
|
||||
void func_80147198(SramContext* sramCtx) {
|
||||
if (sramCtx->status == 7) {
|
||||
if (func_80185EC4() != 0) { // Is task running
|
||||
if (func_80185F04() == 0) { // Wait for task done
|
||||
func_80185DDC(sramCtx->saveBuf, sramCtx->curPage + 0x80, sramCtx->numPages);
|
||||
if (SysFlashrom_IsBusy() != 0) { // Is task running
|
||||
if (SysFlashrom_AwaitResult() == 0) { // Wait for task done
|
||||
SysFlashrom_WriteDataAsync(sramCtx->saveBuf, sramCtx->curPage + 0x80, sramCtx->numPages);
|
||||
sramCtx->status = 8;
|
||||
} else {
|
||||
func_80185DDC(sramCtx->saveBuf, sramCtx->curPage + 0x80, sramCtx->numPages);
|
||||
SysFlashrom_WriteDataAsync(sramCtx->saveBuf, sramCtx->curPage + 0x80, sramCtx->numPages);
|
||||
sramCtx->status = 8;
|
||||
}
|
||||
}
|
||||
} else if (sramCtx->status == 8) {
|
||||
if (func_80185EC4() != 0) { // Is task running
|
||||
if (func_80185F04() == 0) { // Wait for task done
|
||||
if (SysFlashrom_IsBusy() != 0) { // Is task running
|
||||
if (SysFlashrom_AwaitResult() == 0) { // Wait for task done
|
||||
sramCtx->status = 4;
|
||||
} else {
|
||||
sramCtx->status = 4;
|
||||
|
@ -1623,7 +1626,7 @@ void func_80147198(SramContext* sramCtx) {
|
|||
gSaveContext.save.isOwlSave = false;
|
||||
gSaveContext.save.saveInfo.checksum = 0;
|
||||
// flash read to buffer then copy to save context
|
||||
func_80185968(sramCtx->saveBuf, sramCtx->curPage, sramCtx->numPages);
|
||||
SysFlashrom_ReadData(sramCtx->saveBuf, sramCtx->curPage, sramCtx->numPages);
|
||||
Lib_MemCpy(&gSaveContext, sramCtx->saveBuf, offsetof(SaveContext, fileNum));
|
||||
}
|
||||
}
|
||||
|
@ -1664,9 +1667,9 @@ void func_80147414(SramContext* sramCtx, s32 fileNum, s32 arg2) {
|
|||
bzero(sramCtx->saveBuf, SAVE_BUFFER_SIZE);
|
||||
|
||||
// Read save file
|
||||
if (func_80185968(sramCtx->saveBuf, D_801C6840[fileNum * 2], D_801C6850[fileNum * 2]) != 0) {
|
||||
if (SysFlashrom_ReadData(sramCtx->saveBuf, D_801C6840[fileNum * 2], D_801C6850[fileNum * 2]) != 0) {
|
||||
// If failed, read backup save file
|
||||
func_80185968(sramCtx->saveBuf, D_801C6840[fileNum * 2 + 1], D_801C6850[fileNum * 2 + 1]);
|
||||
SysFlashrom_ReadData(sramCtx->saveBuf, D_801C6840[fileNum * 2 + 1], D_801C6850[fileNum * 2 + 1]);
|
||||
}
|
||||
|
||||
// Copy buffer to save context
|
||||
|
|
|
@ -3447,21 +3447,21 @@
|
|||
0x801856FC:("Slowly_ThreadEntry",),
|
||||
0x8018571C:("Slowly_Init",),
|
||||
0x801857A0:("Slowly_Destroy",),
|
||||
0x801857C0:("func_801857C0",),
|
||||
0x801857D0:("func_801857D0",),
|
||||
0x80185864:("func_80185864",),
|
||||
0x80185908:("func_80185908",),
|
||||
0x80185968:("func_80185968",),
|
||||
0x801859F0:("func_801859F0",),
|
||||
0x80185A2C:("func_80185A2C",),
|
||||
0x80185B1C:("func_80185B1C",),
|
||||
0x80185BE4:("func_80185BE4",),
|
||||
0x801857C0:("SysFlashrom_IsInit",),
|
||||
0x801857D0:("SysFlashrom_GetVendorStr",),
|
||||
0x80185864:("SysFlashrom_CheckFlashType",),
|
||||
0x80185908:("SysFlashrom_InitFlash",),
|
||||
0x80185968:("SysFlashrom_ReadData",),
|
||||
0x801859F0:("SysFlashrom_EraseSector",),
|
||||
0x80185A2C:("SysFlashrom_ExecWrite",),
|
||||
0x80185B1C:("SysFlashrom_AttemptWrite",),
|
||||
0x80185BE4:("SysFlashrom_NeedsToErase",),
|
||||
0x80185C24:("func_80185C24",),
|
||||
0x80185D40:("SysFlashrom_ThreadEntry",),
|
||||
0x80185DDC:("func_80185DDC",),
|
||||
0x80185EC4:("func_80185EC4",),
|
||||
0x80185F04:("func_80185F04",),
|
||||
0x80185F64:("func_80185F64",),
|
||||
0x80185DDC:("SysFlashrom_WriteDataAsync",),
|
||||
0x80185EC4:("SysFlashrom_IsBusy",),
|
||||
0x80185F04:("SysFlashrom_AwaitResult",),
|
||||
0x80185F64:("SysFlashrom_WriteDataSync",),
|
||||
0x80185F90:("func_80185F90",),
|
||||
0x80186A70:("osFlashGetAddr",),
|
||||
0x80186AB8:("osFlashReInit",),
|
||||
|
|
|
@ -4193,14 +4193,14 @@
|
|||
0x801FBDE8:("D_801FBDE8","Vec3f","",0xc),
|
||||
0x801FBE00:("sMatrixStack","MtxF*","",0x4),
|
||||
0x801FBE04:("sCurrentMatrix","MtxF*","",0x4),
|
||||
0x801FBE10:("D_801FBE10","UNK_TYPE1","",0x1),
|
||||
0x801FBE28:("D_801FBE28","UNK_TYPE1","",0x1),
|
||||
0x801FBE2C:("D_801FBE2C","UNK_TYPE1","",0x1),
|
||||
0x801FBE30:("D_801FBE30","UNK_TYPE4","",0x4),
|
||||
0x801FBE10:("sFlashromMesgQueue","UNK_TYPE1","",0x1),
|
||||
0x801FBE28:("sFlashromMesg","UNK_TYPE1","",0x1),
|
||||
0x801FBE2C:("sFlashromIsInit","UNK_TYPE1","",0x1),
|
||||
0x801FBE30:("sFlashromVendor","UNK_TYPE4","",0x4),
|
||||
0x801FBE38:("sSysFlashromStack","u8","[4096]",0x1000),
|
||||
0x801FCE38:("sSysFlashromStackInfo","StackEntry","",0x1c),
|
||||
0x801FCE58:("sSysFlashromThread","OSThread","",0x1b0),
|
||||
0x801FD008:("D_801FD008","s80185D40","",0x2c),
|
||||
0x801FD008:("sFlashromRequest","s80185D40","",0x2c),
|
||||
0x801FD034:("D_801FD034","OSMesg","",0x4),
|
||||
0x801FD040:("D_801FD040","s32","",0x10),
|
||||
0x801FD050:("D_801FD050","OSIoMesg","",0x18),
|
||||
|
|
|
@ -2962,20 +2962,21 @@ asm/non_matchings/code/sys_slowly/Slowly_ThreadEntry.s,Slowly_ThreadEntry,0x8018
|
|||
asm/non_matchings/code/sys_slowly/Slowly_Init.s,Slowly_Init,0x8018571C,0x21
|
||||
asm/non_matchings/code/sys_slowly/Slowly_Destroy.s,Slowly_Destroy,0x801857A0,0x8
|
||||
asm/non_matchings/code/sys_flashrom/func_801857C0.s,func_801857C0,0x801857C0,0x4
|
||||
asm/non_matchings/code/sys_flashrom/func_801857D0.s,func_801857D0,0x801857D0,0x25
|
||||
asm/non_matchings/code/sys_flashrom/func_80185864.s,func_80185864,0x80185864,0x29
|
||||
asm/non_matchings/code/sys_flashrom/func_80185908.s,func_80185908,0x80185908,0x18
|
||||
asm/non_matchings/code/sys_flashrom/func_80185968.s,func_80185968,0x80185968,0x22
|
||||
asm/non_matchings/code/sys_flashrom/func_801859F0.s,func_801859F0,0x801859F0,0xF
|
||||
asm/non_matchings/code/sys_flashrom/func_80185A2C.s,func_80185A2C,0x80185A2C,0x3C
|
||||
asm/non_matchings/code/sys_flashrom/func_80185B1C.s,func_80185B1C,0x80185B1C,0x32
|
||||
asm/non_matchings/code/sys_flashrom/func_80185BE4.s,func_80185BE4,0x80185BE4,0x10
|
||||
asm/non_matchings/code/sys_flashrom/SysFlashrom_IsInit.s,SysFlashrom_IsInit,0x801857C0,0x4
|
||||
asm/non_matchings/code/sys_flashrom/SysFlashrom_GetVendorStr.s,SysFlashrom_GetVendorStr,0x801857D0,0x25
|
||||
asm/non_matchings/code/sys_flashrom/SysFlashrom_CheckFlashType.s,SysFlashrom_CheckFlashType,0x80185864,0x29
|
||||
asm/non_matchings/code/sys_flashrom/SysFlashrom_InitFlash.s,SysFlashrom_InitFlash,0x80185908,0x18
|
||||
asm/non_matchings/code/sys_flashrom/SysFlashrom_ReadData.s,SysFlashrom_ReadData,0x80185968,0x22
|
||||
asm/non_matchings/code/sys_flashrom/SysFlashrom_EraseSector.s,SysFlashrom_EraseSector,0x801859F0,0xF
|
||||
asm/non_matchings/code/sys_flashrom/SysFlashrom_ExecWrite.s,SysFlashrom_ExecWrite,0x80185A2C,0x3C
|
||||
asm/non_matchings/code/sys_flashrom/SysFlashrom_AttemptWrite.s,SysFlashrom_AttemptWrite,0x80185B1C,0x32
|
||||
asm/non_matchings/code/sys_flashrom/SysFlashrom_NeedsToErase.s,SysFlashrom_NeedsToErase,0x80185BE4,0x10
|
||||
asm/non_matchings/code/sys_flashrom/func_80185C24.s,func_80185C24,0x80185C24,0x47
|
||||
asm/non_matchings/code/sys_flashrom/SysFlashrom_ThreadEntry.s,SysFlashrom_ThreadEntry,0x80185D40,0x27
|
||||
asm/non_matchings/code/sys_flashrom/func_80185DDC.s,func_80185DDC,0x80185DDC,0x3A
|
||||
asm/non_matchings/code/sys_flashrom/func_80185EC4.s,func_80185EC4,0x80185EC4,0x10
|
||||
asm/non_matchings/code/sys_flashrom/func_80185F04.s,func_80185F04,0x80185F04,0x18
|
||||
asm/non_matchings/code/sys_flashrom/func_80185F64.s,func_80185F64,0x80185F64,0xB
|
||||
asm/non_matchings/code/sys_flashrom/SysFlashrom_WriteDataAsync.s,SysFlashrom_WriteDataAsync,0x80185DDC,0x3A
|
||||
asm/non_matchings/code/sys_flashrom/SysFlashrom_IsBusy.s,SysFlashrom_IsBusy,0x80185EC4,0x10
|
||||
asm/non_matchings/code/sys_flashrom/SysFlashrom_AwaitResult.s,SysFlashrom_AwaitResult,0x80185F04,0x18
|
||||
asm/non_matchings/code/sys_flashrom/SysFlashrom_WriteDataSync.s,SysFlashrom_WriteDataSync,0x80185F64,0xB
|
||||
asm/non_matchings/code/code_80185F90/func_80185F90.s,func_80185F90,0x80185F90,0x26
|
||||
asm/non_matchings/code/osFlash/func_80186A70.s,func_80186A70,0x80186A70,0x12
|
||||
asm/non_matchings/code/osFlash/func_80186AB8.s,func_80186AB8,0x80186AB8,0x1C
|
||||
|
|
|
Loading…
Reference in New Issue