mirror of https://github.com/zeldaret/mm.git
cartrominit OK (#412)
* cartrominit OK * spec * Rename a couple of variables
This commit is contained in:
parent
2854294009
commit
48a5116389
|
@ -54,8 +54,8 @@ typedef struct {
|
|||
} __OSTranxInfo; // size = 0x60
|
||||
|
||||
|
||||
typedef struct OSPiHandle_s {
|
||||
/* 0x00 */ struct OSPiHandle_s* next;
|
||||
typedef struct OSPiHandle {
|
||||
/* 0x00 */ struct OSPiHandle* next;
|
||||
/* 0x04 */ u8 type;
|
||||
/* 0x05 */ u8 latency;
|
||||
/* 0x06 */ u8 pageSize;
|
||||
|
|
|
@ -85,7 +85,7 @@ extern OSViMode osViModeMpalLan1;
|
|||
// extern __OSViContext D_80098060[2];
|
||||
extern __OSViContext* __osViCurr;
|
||||
extern __OSViContext* __osViNext;
|
||||
// extern UNK_TYPE4 D_800980D0;
|
||||
// extern UNK_TYPE4 sCartRomNeedsInit;
|
||||
extern OSViMode osViModeFpalLan1;
|
||||
// extern u8 ldigs[];
|
||||
// extern u8 udigs[];
|
||||
|
|
2
spec
2
spec
|
@ -195,8 +195,6 @@ beginseg
|
|||
include "build/src/libultra/io/pfsisplug.o"
|
||||
include "build/src/libultra/voice/voicegetstatus.o"
|
||||
include "build/src/libultra/io/cartrominit.o"
|
||||
include "build/data/boot/cartrominit.data.o"
|
||||
include "build/data/boot/cartrominit.bss.o"
|
||||
include "build/src/libultra/gu/guS2DInitBg.o"
|
||||
include "build/data/boot/guS2DInitBg.data.o"
|
||||
include "build/src/libultra/io/pfsselectbank.o"
|
||||
|
|
|
@ -1,3 +1,63 @@
|
|||
#include "global.h"
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/boot/cartrominit/osCartRomInit.s")
|
||||
OSPiHandle CartRomHandle;
|
||||
|
||||
OSPiHandle* osCartRomInit(void) {
|
||||
register u32 initialConfig;
|
||||
register s32 status;
|
||||
register u32 prevInt;
|
||||
register u32 lastLatency;
|
||||
register u32 lastPageSize;
|
||||
register u32 lastRelDuration;
|
||||
register u32 lastPulse;
|
||||
|
||||
static s32 sCartRomNeedsInit = true;
|
||||
|
||||
__osPiGetAccess();
|
||||
|
||||
if (!sCartRomNeedsInit) {
|
||||
__osPiRelAccess();
|
||||
return &CartRomHandle;
|
||||
}
|
||||
|
||||
sCartRomNeedsInit = false;
|
||||
CartRomHandle.type = DEVICE_TYPE_CART;
|
||||
CartRomHandle.baseAddress = 0xB0000000;
|
||||
CartRomHandle.domain = 0;
|
||||
CartRomHandle.speed = 0;
|
||||
bzero(&CartRomHandle.transferInfo, sizeof(__OSTranxInfo));
|
||||
|
||||
/* Uses `status & PI_STATUS_ERROR` in OoT */
|
||||
while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_BUSY | PI_STATUS_IOBUSY)) {
|
||||
;
|
||||
}
|
||||
|
||||
lastLatency = HW_REG(PI_BSD_DOM1_LAT_REG, u32);
|
||||
lastPageSize = HW_REG(PI_BSD_DOM1_PGS_REG, u32);
|
||||
lastRelDuration = HW_REG(PI_BSD_DOM1_RLS_REG, u32);
|
||||
lastPulse = HW_REG(PI_BSD_DOM1_PWD_REG, u32);
|
||||
|
||||
HW_REG(PI_BSD_DOM1_LAT_REG, u32) = 0xFF;
|
||||
HW_REG(PI_BSD_DOM1_PGS_REG, u32) = 0;
|
||||
HW_REG(PI_BSD_DOM1_RLS_REG, u32) = 3;
|
||||
HW_REG(PI_BSD_DOM1_PWD_REG, u32) = 0xFF;
|
||||
|
||||
initialConfig = HW_REG(CartRomHandle.baseAddress, u32);
|
||||
CartRomHandle.latency = initialConfig & 0xFF;
|
||||
CartRomHandle.pageSize = (initialConfig >> 0x10) & 0xF;
|
||||
CartRomHandle.relDuration = (initialConfig >> 0x14) & 0xF;
|
||||
CartRomHandle.pulse = (initialConfig >> 8) & 0xFF;
|
||||
|
||||
HW_REG(PI_BSD_DOM1_LAT_REG, u32) = lastLatency;
|
||||
HW_REG(PI_BSD_DOM1_PGS_REG, u32) = lastPageSize;
|
||||
HW_REG(PI_BSD_DOM1_RLS_REG, u32) = lastRelDuration;
|
||||
HW_REG(PI_BSD_DOM1_PWD_REG, u32) = lastPulse;
|
||||
|
||||
prevInt = __osDisableInt();
|
||||
CartRomHandle.next = __osPiTable;
|
||||
__osPiTable = &CartRomHandle;
|
||||
__osRestoreInt(prevInt);
|
||||
__osPiRelAccess();
|
||||
|
||||
return &CartRomHandle;
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
0x80098060:("D_80098060","__OSViContext","[2]",0x60),
|
||||
0x800980C0:("__osViCurr","__OSViContext*","",0x4),
|
||||
0x800980C4:("__osViNext","__OSViContext*","",0x4),
|
||||
0x800980D0:("D_800980D0","UNK_TYPE4","",0x4),
|
||||
0x800980D0:("sCartRomNeedsInit","UNK_TYPE4","",0x4),
|
||||
0x800980E0:("osViModeFpalLan1","OSViMode","",0x50),
|
||||
0x80098130:("ldigs","u8","[]",0x14),
|
||||
0x80098144:("udigs","u8","[]",0x14),
|
||||
|
|
Loading…
Reference in New Issue