mirror of
https://github.com/zeldaret/oot.git
synced 2024-11-25 01:34:18 +00:00
[ntsc-1.0/1.1] Match "system" files (#2254)
This commit is contained in:
parent
d3bf8ae78b
commit
60f9607569
6 changed files with 108 additions and 6 deletions
|
@ -389,10 +389,12 @@ ALIGNED(4) typedef struct PreNmiBuff {
|
|||
} PreNmiBuff; // size = 0x18 (actually osAppNMIBuffer is 0x40 bytes large but the rest is unused)
|
||||
|
||||
typedef enum ViModeEditState {
|
||||
/* 0 */ VI_MODE_EDIT_STATE_INACTIVE,
|
||||
/* 1 */ VI_MODE_EDIT_STATE_ACTIVE,
|
||||
/* 2 */ VI_MODE_EDIT_STATE_2, // active, more adjustments
|
||||
/* 3 */ VI_MODE_EDIT_STATE_3 // active, more adjustments, print comparison with NTSC LAN1 mode
|
||||
/* -2 */ VI_MODE_EDIT_STATE_NEGATIVE_2 = -2,
|
||||
/* -1 */ VI_MODE_EDIT_STATE_NEGATIVE_1,
|
||||
/* 0 */ VI_MODE_EDIT_STATE_INACTIVE,
|
||||
/* 1 */ VI_MODE_EDIT_STATE_ACTIVE,
|
||||
/* 2 */ VI_MODE_EDIT_STATE_2, // active, more adjustments
|
||||
/* 3 */ VI_MODE_EDIT_STATE_3 // active, more adjustments, print comparison with NTSC LAN1 mode
|
||||
} ViModeEditState;
|
||||
|
||||
typedef struct ViMode {
|
||||
|
|
|
@ -39,7 +39,11 @@ void CIC6105_FaultClient(void) {
|
|||
Fault_Printf(" [Creator:%s]", gBuildCreator);
|
||||
Fault_SetCursor(56, 192);
|
||||
Fault_Printf("[Date:%s]", gBuildDate);
|
||||
#if OOT_VERSION < PAL_1_0
|
||||
Fault_SetCursor(128, 24);
|
||||
#else
|
||||
Fault_SetCursor(96, 32);
|
||||
#endif
|
||||
Fault_Printf("I LOVE YOU %08x", func_80001714());
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,11 @@ void rmonPrintf(const char* fmt, ...) {
|
|||
va_end(args);
|
||||
}
|
||||
|
||||
#if OOT_VERSION < PAL_1_0
|
||||
void func_800015F4(void) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OOT_DEBUG
|
||||
void* is_proutSyncPrintf(void* arg, const char* str, size_t count) {
|
||||
u32 data;
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
*/
|
||||
#include "global.h"
|
||||
#include "terminal.h"
|
||||
#include "versions.h"
|
||||
|
||||
vu32 gIrqMgrResetStatus = IRQ_RESET_STATUS_IDLE;
|
||||
volatile OSTime sIrqMgrResetTime = 0;
|
||||
|
@ -43,9 +44,13 @@ u32 sIrqMgrRetraceCount = 0;
|
|||
// Internal messages
|
||||
#define IRQ_RETRACE_MSG 666
|
||||
#define IRQ_PRENMI_MSG 669
|
||||
#if OOT_VERSION < PAL_1_0
|
||||
#define IRQ_PRENMI500_MSG 670
|
||||
#else
|
||||
#define IRQ_PRENMI450_MSG 671
|
||||
#define IRQ_PRENMI480_MSG 672
|
||||
#define IRQ_PRENMI500_MSG 673
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Registers a client and an associated message queue with the IRQ manager. When an
|
||||
|
@ -163,8 +168,13 @@ void IrqMgr_HandlePreNMI(IrqMgr* irqMgr) {
|
|||
irqMgr->resetStatus = IRQ_RESET_STATUS_PRENMI;
|
||||
sIrqMgrResetTime = irqMgr->resetTime = osGetTime();
|
||||
|
||||
#if OOT_VERSION < PAL_1_0
|
||||
// Schedule a PRENMI500 message to be handled in 500ms
|
||||
osSetTimer(&irqMgr->timer, OS_USEC_TO_CYCLES(500000), 0, &irqMgr->queue, (OSMesg)IRQ_PRENMI500_MSG);
|
||||
#else
|
||||
// Schedule a PRENMI450 message to be handled in 450ms
|
||||
osSetTimer(&irqMgr->timer, OS_USEC_TO_CYCLES(450000), 0, &irqMgr->queue, (OSMesg)IRQ_PRENMI450_MSG);
|
||||
#endif
|
||||
IrqMgr_JamMesgToClients(irqMgr, (OSMesg)&irqMgr->prenmiMsg);
|
||||
}
|
||||
|
||||
|
@ -183,6 +193,27 @@ void IrqMgr_CheckStacks(void) {
|
|||
}
|
||||
}
|
||||
|
||||
#if OOT_VERSION < PAL_1_0
|
||||
|
||||
void IrqMgr_HandlePreNMI500(IrqMgr* irqMgr) {
|
||||
u64 nmi = IRQ_RESET_STATUS_NMI; // required to match
|
||||
u32 result;
|
||||
|
||||
gIrqMgrResetStatus = nmi;
|
||||
irqMgr->resetStatus = IRQ_RESET_STATUS_NMI;
|
||||
|
||||
IrqMgr_SendMesgToClients(irqMgr, (OSMesg)&irqMgr->nmiMsg);
|
||||
|
||||
result = osAfterPreNMI();
|
||||
if (result != 0) {
|
||||
// Schedule another PRENMI500 message to be handled in 1ms
|
||||
osSetTimer(&irqMgr->timer, OS_USEC_TO_CYCLES(1000), 0, &irqMgr->queue, (OSMesg)IRQ_PRENMI500_MSG);
|
||||
}
|
||||
IrqMgr_CheckStacks();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void IrqMgr_HandlePreNMI450(IrqMgr* irqMgr) {
|
||||
u64 nmi = IRQ_RESET_STATUS_NMI; // required to match
|
||||
|
||||
|
@ -215,6 +246,8 @@ void IrqMgr_HandlePreNMI500(IrqMgr* irqMgr) {
|
|||
IrqMgr_CheckStacks();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Runs on each vertical retrace
|
||||
*
|
||||
|
@ -244,6 +277,11 @@ void IrqMgr_ThreadEntry(void* arg) {
|
|||
while (!exit) {
|
||||
osRecvMesg(&irqMgr->queue, (OSMesg*)&msg, OS_MESG_BLOCK);
|
||||
switch (msg) {
|
||||
#if OOT_VERSION < PAL_1_0
|
||||
default:
|
||||
break;
|
||||
#endif
|
||||
|
||||
case IRQ_RETRACE_MSG:
|
||||
IrqMgr_HandleRetrace(irqMgr);
|
||||
break;
|
||||
|
@ -254,6 +292,7 @@ void IrqMgr_ThreadEntry(void* arg) {
|
|||
IrqMgr_HandlePreNMI(irqMgr);
|
||||
break;
|
||||
|
||||
#if OOT_VERSION >= PAL_1_0
|
||||
case IRQ_PRENMI450_MSG:
|
||||
PRINTF("PRENMI450_MSG\n");
|
||||
PRINTF(T("スケジューラ:PRENMI450メッセージを受信\n", "Scheduler: Receives PRENMI450 message\n"));
|
||||
|
@ -265,6 +304,7 @@ void IrqMgr_ThreadEntry(void* arg) {
|
|||
PRINTF(T("スケジューラ:PRENMI480メッセージを受信\n", "Scheduler: Receives PRENMI480 message\n"));
|
||||
IrqMgr_HandlePreNMI480(irqMgr);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case IRQ_PRENMI500_MSG:
|
||||
PRINTF("PRENMI500_MSG\n");
|
||||
|
@ -273,11 +313,13 @@ void IrqMgr_ThreadEntry(void* arg) {
|
|||
exit = true;
|
||||
break;
|
||||
|
||||
#if OOT_VERSION >= PAL_1_0
|
||||
default:
|
||||
PRINTF(T("irqmgr.c:予期しないメッセージを受け取りました(%08x)\n",
|
||||
"irqmgr.c: Unexpected message received (%08x)\n"),
|
||||
msg);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "ultra64.h"
|
||||
#include "versions.h"
|
||||
|
||||
// Declared before including other headers for BSS ordering
|
||||
extern uintptr_t gSegments[NUM_SEGMENTS];
|
||||
|
@ -39,7 +40,11 @@ uintptr_t gSegments[NUM_SEGMENTS];
|
|||
|
||||
OSThread sGraphThread;
|
||||
STACK(sGraphStack, 0x1800);
|
||||
#if OOT_VERSION < PAL_1_0
|
||||
STACK(sSchedStack, 0x400);
|
||||
#else
|
||||
STACK(sSchedStack, 0x600);
|
||||
#endif
|
||||
STACK(sAudioStack, 0x800);
|
||||
STACK(sPadMgrStack, 0x500);
|
||||
STACK(sIrqMgrStack, 0x500);
|
||||
|
@ -78,7 +83,7 @@ void Main(void* arg) {
|
|||
#if PLATFORM_N64
|
||||
func_800AD410();
|
||||
if (D_80121211 != 0) {
|
||||
systemHeapStart = (uintptr_t)&_n64ddSegmentEnd;
|
||||
systemHeapStart = (uintptr_t)_n64ddSegmentEnd;
|
||||
SysCfb_Init(1);
|
||||
} else {
|
||||
func_800AD488();
|
||||
|
@ -150,7 +155,10 @@ void Main(void* arg) {
|
|||
StackCheck_Init(&sGraphStackInfo, sGraphStack, STACK_TOP(sGraphStack), 0, 0x100, "graph");
|
||||
osCreateThread(&sGraphThread, THREAD_ID_GRAPH, Graph_ThreadEntry, arg, STACK_TOP(sGraphStack), THREAD_PRI_GRAPH);
|
||||
osStartThread(&sGraphThread);
|
||||
|
||||
#if OOT_VERSION >= PAL_1_0
|
||||
osSetThreadPri(NULL, THREAD_PRI_MAIN);
|
||||
#endif
|
||||
|
||||
while (true) {
|
||||
s16* msg = NULL;
|
||||
|
@ -162,6 +170,9 @@ void Main(void* arg) {
|
|||
switch (*msg) {
|
||||
case OS_SC_PRE_NMI_MSG:
|
||||
PRINTF(T("main.c: リセットされたみたいだよ\n", "main.c: Looks like it's been reset\n"));
|
||||
#if OOT_VERSION < PAL_1_0
|
||||
StackCheck_Check(NULL);
|
||||
#endif
|
||||
PreNmiBuff_SetReset(gAppNmiBufferPtr);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "global.h"
|
||||
#include "ultra64/viint.h"
|
||||
#include "versions.h"
|
||||
|
||||
void ViMode_LogPrint(OSViMode* osViMode) {
|
||||
LOG_ADDRESS("osvimodep", osViMode, "../z_vimode.c", 87);
|
||||
|
@ -182,6 +183,7 @@ void ViMode_Save(ViMode* viMode) {
|
|||
R_VI_MODE_EDIT_ULX_ADJ = viMode->leftAdjust;
|
||||
R_VI_MODE_EDIT_LRX_ADJ = viMode->rightAdjust;
|
||||
|
||||
#if OOT_VERSION >= PAL_1_0
|
||||
if (SREG(58) == 1) {
|
||||
SREG(58) = 0;
|
||||
|
||||
|
@ -200,6 +202,7 @@ void ViMode_Save(ViMode* viMode) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ViMode_Load(ViMode* viMode) {
|
||||
|
@ -270,8 +273,18 @@ void ViMode_Update(ViMode* viMode, Input* input) {
|
|||
// Load state from REGs
|
||||
ViMode_Load(viMode);
|
||||
|
||||
#if OOT_VERSION < PAL_1_0
|
||||
if (viMode->editState == VI_MODE_EDIT_STATE_NEGATIVE_2) {
|
||||
// Log comparison between the NTSC LAN1 mode and the custom mode
|
||||
ViMode_LogPrint(&osViModeNtscLan1);
|
||||
ViMode_LogPrint(&viMode->customViMode);
|
||||
viMode->editState = VI_MODE_EDIT_STATE_NEGATIVE_1;
|
||||
} else if ((viMode->editState == VI_MODE_EDIT_STATE_2) || (viMode->editState == VI_MODE_EDIT_STATE_3))
|
||||
#else
|
||||
if ((viMode->editState == VI_MODE_EDIT_STATE_ACTIVE) || (viMode->editState == VI_MODE_EDIT_STATE_2) ||
|
||||
(viMode->editState == VI_MODE_EDIT_STATE_3)) {
|
||||
(viMode->editState == VI_MODE_EDIT_STATE_3))
|
||||
#endif
|
||||
{
|
||||
gScreenWidth = viMode->viWidth;
|
||||
gScreenHeight = viMode->viHeight;
|
||||
|
||||
|
@ -333,6 +346,21 @@ void ViMode_Update(ViMode* viMode, Input* input) {
|
|||
}
|
||||
|
||||
// Clamp adjustments
|
||||
#if OOT_VERSION < PAL_1_0
|
||||
// Do not allow parts of the framebuffer to end up offscreen
|
||||
if (viMode->leftAdjust < 0) {
|
||||
viMode->leftAdjust = 0;
|
||||
}
|
||||
if (viMode->upperAdjust < 0) {
|
||||
viMode->upperAdjust = 0;
|
||||
}
|
||||
if (viMode->rightAdjust > 0) {
|
||||
viMode->rightAdjust = 0;
|
||||
}
|
||||
if (viMode->lowerAdjust > 0) {
|
||||
viMode->lowerAdjust = 0;
|
||||
}
|
||||
#else
|
||||
if (viMode->editState >= VI_MODE_EDIT_STATE_2) {
|
||||
// Allow parts of the framebuffer to possibly be offscreen by a small margin
|
||||
if (viMode->leftAdjust < -16) {
|
||||
|
@ -362,11 +390,21 @@ void ViMode_Update(ViMode* viMode, Input* input) {
|
|||
viMode->lowerAdjust = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Configure the custom VI mode with the selected settings
|
||||
ViMode_Configure(viMode, OS_VI_MPAL_LPN1, osTvType, viMode->loRes, viMode->antialiasOff, viMode->modeN,
|
||||
viMode->fb16Bit, viMode->viWidth, viMode->viHeight, viMode->leftAdjust, viMode->rightAdjust,
|
||||
viMode->upperAdjust, viMode->lowerAdjust);
|
||||
|
||||
#if OOT_VERSION < PAL_1_0
|
||||
if (viMode->editState == VI_MODE_EDIT_STATE_3) {
|
||||
// Log comparison between the NTSC LAN1 mode and the custom mode
|
||||
ViMode_LogPrint(&osViModeNtscLan1);
|
||||
ViMode_LogPrint(&viMode->customViMode);
|
||||
}
|
||||
#endif
|
||||
|
||||
ViMode_ConfigureFeatures(viMode, viMode->viFeatures);
|
||||
|
||||
if (viMode->editState == VI_MODE_EDIT_STATE_3) {
|
||||
|
|
Loading…
Reference in a new issue