Match and link COsContext

This commit is contained in:
Phillip Stephens 2022-10-02 00:43:00 -07:00
parent 70a1e449bd
commit cc514ecf6e
13 changed files with 226 additions and 54 deletions

View File

@ -3,8 +3,8 @@
.section .data
.balign 8
.global lbl_803F08E0
lbl_803F08E0:
.global GXNtsc480IntDf
GXNtsc480IntDf:
# ROM: 0x3ED8E0
.4byte 0
.4byte 0x028001E0
@ -22,8 +22,8 @@ lbl_803F08E0:
.4byte 0x0A0C0A08
.4byte 0x08000000
.global lbl_803F091C
lbl_803F091C:
.global GXMpal480IntDf
GXMpal480IntDf:
# ROM: 0x3ED91C
.4byte 0x00000008
.4byte 0x028001E0
@ -41,8 +41,8 @@ lbl_803F091C:
.4byte 0x0A0C0A08
.4byte 0x08000000
.global lbl_803F0958
lbl_803F0958:
.global GXPal528IntDf
GXPal528IntDf:
# ROM: 0x3ED958
.4byte 0x00000004
.4byte 0x02800210
@ -60,8 +60,8 @@ lbl_803F0958:
.4byte 0x0A0C0A08
.4byte 0x08000000
.global lbl_803F0994
lbl_803F0994:
.global GXEurgb60Hz480IntDf
GXEurgb60Hz480IntDf:
# ROM: 0x3ED994
.4byte 0x00000014
.4byte 0x028001E0

View File

@ -795,28 +795,28 @@ lbl_80375A08:
/* 80375A0C 0037296C 41 82 00 28 */ beq lbl_80375A34
/* 80375A10 00372970 48 00 00 44 */ b lbl_80375A54
lbl_80375A14:
/* 80375A14 00372974 3C 60 80 3F */ lis r3, lbl_803F08E0@ha
/* 80375A18 00372978 38 03 08 E0 */ addi r0, r3, lbl_803F08E0@l
/* 80375A14 00372974 3C 60 80 3F */ lis r3, GXNtsc480IntDf@ha
/* 80375A18 00372978 38 03 08 E0 */ addi r0, r3, GXNtsc480IntDf@l
/* 80375A1C 0037297C 7C 1F 03 78 */ mr r31, r0
/* 80375A20 00372980 48 00 00 40 */ b lbl_80375A60
lbl_80375A24:
/* 80375A24 00372984 3C 60 80 3F */ lis r3, lbl_803F0958@ha
/* 80375A28 00372988 38 03 09 58 */ addi r0, r3, lbl_803F0958@l
/* 80375A24 00372984 3C 60 80 3F */ lis r3, GXPal528IntDf@ha
/* 80375A28 00372988 38 03 09 58 */ addi r0, r3, GXPal528IntDf@l
/* 80375A2C 0037298C 7C 1F 03 78 */ mr r31, r0
/* 80375A30 00372990 48 00 00 30 */ b lbl_80375A60
lbl_80375A34:
/* 80375A34 00372994 3C 60 80 3F */ lis r3, lbl_803F0994@ha
/* 80375A38 00372998 38 03 09 94 */ addi r0, r3, lbl_803F0994@l
/* 80375A34 00372994 3C 60 80 3F */ lis r3, GXEurgb60Hz480IntDf@ha
/* 80375A38 00372998 38 03 09 94 */ addi r0, r3, GXEurgb60Hz480IntDf@l
/* 80375A3C 0037299C 7C 1F 03 78 */ mr r31, r0
/* 80375A40 003729A0 48 00 00 20 */ b lbl_80375A60
lbl_80375A44:
/* 80375A44 003729A4 3C 60 80 3F */ lis r3, lbl_803F091C@ha
/* 80375A48 003729A8 38 03 09 1C */ addi r0, r3, lbl_803F091C@l
/* 80375A44 003729A4 3C 60 80 3F */ lis r3, GXMpal480IntDf@ha
/* 80375A48 003729A8 38 03 09 1C */ addi r0, r3, GXMpal480IntDf@l
/* 80375A4C 003729AC 7C 1F 03 78 */ mr r31, r0
/* 80375A50 003729B0 48 00 00 10 */ b lbl_80375A60
lbl_80375A54:
/* 80375A54 003729B4 3C 60 80 3F */ lis r3, lbl_803F08E0@ha
/* 80375A58 003729B8 38 03 08 E0 */ addi r0, r3, lbl_803F08E0@l
/* 80375A54 003729B4 3C 60 80 3F */ lis r3, GXNtsc480IntDf@ha
/* 80375A58 003729B8 38 03 08 E0 */ addi r0, r3, GXNtsc480IntDf@l
/* 80375A5C 003729BC 7C 1F 03 78 */ mr r31, r0
lbl_80375A60:
/* 80375A60 003729C0 80 01 00 28 */ lwz r0, 0x28(r1)

View File

@ -2,8 +2,8 @@
.section .text, "ax"
.global AllocFromArena__10COsContextFUi
AllocFromArena__10COsContextFUi:
.global AllocFromArena__10COsContextFUl
AllocFromArena__10COsContextFUl:
/* 802D63E0 002D3340 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 802D63E4 002D3344 7C 08 02 A6 */ mflr r0
/* 802D63E8 002D3348 90 01 00 14 */ stw r0, 0x14(r1)
@ -53,23 +53,23 @@ lbl_802D6484:
/* 802D6488 002D33E8 40 80 00 4C */ bge lbl_802D64D4
/* 802D648C 002D33EC 48 00 00 34 */ b lbl_802D64C0
lbl_802D6490:
/* 802D6490 002D33F0 3C 60 80 3F */ lis r3, lbl_803F08E0@ha
/* 802D6490 002D33F0 3C 60 80 3F */ lis r3, GXNtsc480IntDf@ha
/* 802D6494 002D33F4 38 00 00 01 */ li r0, 1
/* 802D6498 002D33F8 38 63 08 E0 */ addi r3, r3, lbl_803F08E0@l
/* 802D6498 002D33F8 38 63 08 E0 */ addi r3, r3, GXNtsc480IntDf@l
/* 802D649C 002D33FC 90 1F 00 10 */ stw r0, 0x10(r31)
/* 802D64A0 002D3400 7C 7E 1B 78 */ mr r30, r3
/* 802D64A4 002D3404 48 00 00 30 */ b lbl_802D64D4
lbl_802D64A8:
/* 802D64A8 002D3408 3C 60 80 3F */ lis r3, lbl_803F0958@ha
/* 802D64A8 002D3408 3C 60 80 3F */ lis r3, GXPal528IntDf@ha
/* 802D64AC 002D340C 38 00 00 02 */ li r0, 2
/* 802D64B0 002D3410 38 63 09 58 */ addi r3, r3, lbl_803F0958@l
/* 802D64B0 002D3410 38 63 09 58 */ addi r3, r3, GXPal528IntDf@l
/* 802D64B4 002D3414 90 1F 00 10 */ stw r0, 0x10(r31)
/* 802D64B8 002D3418 7C 7E 1B 78 */ mr r30, r3
/* 802D64BC 002D341C 48 00 00 18 */ b lbl_802D64D4
lbl_802D64C0:
/* 802D64C0 002D3420 3C 60 80 3F */ lis r3, lbl_803F091C@ha
/* 802D64C0 002D3420 3C 60 80 3F */ lis r3, GXMpal480IntDf@ha
/* 802D64C4 002D3424 38 00 00 03 */ li r0, 3
/* 802D64C8 002D3428 38 63 09 1C */ addi r3, r3, lbl_803F091C@l
/* 802D64C8 002D3428 38 63 09 1C */ addi r3, r3, GXMpal480IntDf@l
/* 802D64CC 002D342C 90 1F 00 10 */ stw r0, 0x10(r31)
/* 802D64D0 002D3430 7C 7E 1B 78 */ mr r30, r3
lbl_802D64D4:
@ -121,7 +121,7 @@ lbl_802D64EC:
/* 802D6580 002D34E0 A0 7F 00 3A */ lhz r3, 0x3a(r31)
/* 802D6584 002D34E4 38 03 FF F6 */ addi r0, r3, -10
/* 802D6588 002D34E8 B0 1F 00 3A */ sth r0, 0x3a(r31)
/* 802D658C 002D34EC 88 0D A0 98 */ lbz r0, lbl_805A8C58@sda21(r13)
/* 802D658C 002D34EC 88 0D A0 98 */ lbz r0, mProgressiveMode__10COsContext@sda21(r13)
/* 802D6590 002D34F0 28 00 00 00 */ cmplwi r0, 0
/* 802D6594 002D34F4 41 82 00 3C */ beq lbl_802D65D0
/* 802D6598 002D34F8 38 60 00 02 */ li r3, 2
@ -131,9 +131,9 @@ lbl_802D64EC:
/* 802D65A8 002D3508 38 81 00 08 */ addi r4, r1, 8
/* 802D65AC 002D350C 38 A0 00 07 */ li r5, 7
/* 802D65B0 002D3510 90 1F 00 44 */ stw r0, 0x44(r31)
/* 802D65B4 002D3514 80 E2 C5 68 */ lwz r7, lbl_805AE288@sda21(r2)
/* 802D65B8 002D3518 A0 C2 C5 6C */ lhz r6, lbl_805AE28C@sda21(r2)
/* 802D65BC 002D351C 88 02 C5 6E */ lbz r0, lbl_805AE28E@sda21(r2)
/* 802D65B4 002D3514 80 E2 C5 68 */ lwz r7, progressiveFilterPattern@sda21(r2)
/* 802D65B8 002D3518 A0 C2 C5 6C */ lhz r6, progressiveFilterPattern+4@sda21(r2)
/* 802D65BC 002D351C 88 02 C5 6E */ lbz r0, progressiveFilterPattern+6@sda21(r2)
/* 802D65C0 002D3520 90 E1 00 08 */ stw r7, 8(r1)
/* 802D65C4 002D3524 B0 C1 00 0C */ sth r6, 0xc(r1)
/* 802D65C8 002D3528 98 01 00 0E */ stb r0, 0xe(r1)
@ -244,17 +244,7 @@ lbl_802D6704:
.section .sdata2, "a"
.balign 8
.global lbl_805AE288
lbl_805AE288:
.global progressiveFilterPattern
progressiveFilterPattern:
# ROM: 0x3FAB28
.4byte 0x04041010
.global lbl_805AE28C
lbl_805AE28C:
# ROM: 0x3FAB2C
.2byte 0x00001004
.global lbl_805AE28E
lbl_805AE28E:
# ROM: 0x3FAB2E
.2byte 0x00000400
.byte 4, 4, 16, 16, 16, 4, 4,

View File

@ -608,11 +608,11 @@ lbl_80309660:
/* 803096B8 00306618 48 00 00 34 */ b lbl_803096EC
lbl_803096BC:
/* 803096BC 0030661C 3C 80 80 5A */ lis r4, mRenderModeObj__9CGraphics@ha
/* 803096C0 00306620 3C 60 80 3F */ lis r3, lbl_803F08E0@ha
/* 803096C0 00306620 3C 60 80 3F */ lis r3, GXNtsc480IntDf@ha
/* 803096C4 00306624 38 C4 65 00 */ addi r6, r4, mRenderModeObj__9CGraphics@l
/* 803096C8 00306628 38 A0 00 00 */ li r5, 0
/* 803096CC 0030662C 38 00 00 01 */ li r0, 1
/* 803096D0 00306630 38 83 08 E0 */ addi r4, r3, lbl_803F08E0@l
/* 803096D0 00306630 38 83 08 E0 */ addi r4, r3, GXNtsc480IntDf@l
/* 803096D4 00306634 90 A6 00 00 */ stw r5, 0(r6)
/* 803096D8 00306638 38 66 00 32 */ addi r3, r6, 0x32
/* 803096DC 0030663C 38 84 00 32 */ addi r4, r4, 0x32
@ -5778,4 +5778,3 @@ lbl_803D73C8:
.4byte 0x00000001
.4byte 0x000000FF
.4byte 0

View File

@ -860,8 +860,8 @@ lbl_805A8C50:
.global lbl_805A8C54
lbl_805A8C54:
.skip 0x4
.global lbl_805A8C58
lbl_805A8C58:
.global mProgressiveMode__10COsContext
mProgressiveMode__10COsContext:
.skip 0x4
.global sARAMMemArray
sARAMMemArray:
@ -7177,7 +7177,7 @@ sub_800083e4:
/* 80008428 00005388 38 61 00 08 */ addi r3, r1, 8
/* 8000842C 0000538C 54 05 0F FE */ srwi r5, r0, 0x1f
/* 80008430 00005390 38 04 E3 98 */ addi r0, r4, __vt__15CMemoryInStream@l
/* 80008434 00005394 98 AD A0 98 */ stb r5, lbl_805A8C58@sda21(r13)
/* 80008434 00005394 98 AD A0 98 */ stb r5, mProgressiveMode__10COsContext@sda21(r13)
/* 80008438 00005398 38 80 00 00 */ li r4, 0
/* 8000843C 0000539C 90 01 00 08 */ stw r0, 8(r1)
/* 80008440 000053A0 48 33 6C 6D */ bl __dt__12CInputStreamFv
@ -7292,7 +7292,7 @@ sub_80008584:
/* 800085B4 00005514 48 37 AA 59 */ bl OSSetSaveRegion
/* 800085B8 00005518 7F E3 FB 78 */ mr r3, r31
/* 800085BC 0000551C 38 80 00 80 */ li r4, 0x80
/* 800085C0 00005520 48 2C DE 21 */ bl AllocFromArena__10COsContextFUi
/* 800085C0 00005520 48 2C DE 21 */ bl AllocFromArena__10COsContextFUl
/* 800085C4 00005524 90 6D A0 90 */ stw r3, lbl_805A8C50@sda21(r13)
/* 800085C8 00005528 7F C3 F3 78 */ mr r3, r30
/* 800085CC 0000552C 80 01 00 24 */ lwz r0, 0x24(r1)

View File

@ -4,6 +4,7 @@
#include "types.h"
namespace CBasics {
void Init();
char* Stringize(const char* fmt, ...);
};

View File

@ -7,19 +7,46 @@
#include <dolphin/gx/GXStruct.h>
enum EConsoleType {
kCT_Emulator,
kCT_Development1,
kCT_Development2Or3,
kCT_Retail,
};
class COsKeyState {
public:
COsKeyState(int key, bool down, bool released, bool repeat, bool unk)
: x0_key(key), x4_down(down), x4_released(released), x4_repeat(repeat), x4_unk(unk) {}
private:
int x0_key;
short x4_down : 1;
short x4_released : 1;
short x4_repeat : 1;
short x4_unk : 1;
};
class COsContext {
static bool mProgressiveMode;
public:
COsContext(bool, bool);
~COsContext();
void OpenWindow(const char* title, int x, int y, int w, int h, bool fullscreen);
int OpenWindow(const char* title, int x, int y, int w, int h, bool fullscreen);
bool Update();
COsKeyState GetOsKeyState(int key) const;
void* AllocFromArena(size_t sz);
uint GetBaseFreeRam() const {
size_t hiAddr = reinterpret_cast< size_t >(x1c_arenaHi);
size_t loAddr = reinterpret_cast< size_t >(x20_arenaLo2);
return ((hiAddr & ~31) - ((loAddr + 31) & ~31));
}
static void SetProgressiveMode(bool progressive) { mProgressiveMode = progressive; }
static bool GetProgressiveMode() { return mProgressiveMode; }
private:
int x0_right;
int x4_bottom;

View File

@ -8,6 +8,39 @@
extern "C" {
#endif
//extern GXRenderModeObj GXNtsc240Ds;
//extern GXRenderModeObj GXNtsc240DsAa;
//extern GXRenderModeObj GXNtsc240Int;
//extern GXRenderModeObj GXNtsc240IntAa;
extern GXRenderModeObj GXNtsc480IntDf;
//extern GXRenderModeObj GXNtsc480Int;
//extern GXRenderModeObj GXNtsc480IntAa;
//extern GXRenderModeObj GXNtsc480Prog;
//extern GXRenderModeObj GXNtsc480ProgSoft;
//extern GXRenderModeObj GXNtsc480ProgAa;
//extern GXRenderModeObj GXMpal240Ds;
//extern GXRenderModeObj GXMpal240DsAa;
//extern GXRenderModeObj GXMpal240Int;
//extern GXRenderModeObj GXMpal240IntAa;
extern GXRenderModeObj GXMpal480IntDf;
//extern GXRenderModeObj GXMpal480Int;
//extern GXRenderModeObj GXMpal480IntAa;
//extern GXRenderModeObj GXPal264Ds;
//extern GXRenderModeObj GXPal264DsAa;
//extern GXRenderModeObj GXPal264Int;
//extern GXRenderModeObj GXPal264IntAa;
extern GXRenderModeObj GXPal528IntDf;
//extern GXRenderModeObj GXPal528Int;
//extern GXRenderModeObj GXPal524IntAa;
//extern GXRenderModeObj GXEurgb60Hz240Ds;
//extern GXRenderModeObj GXEurgb60Hz240DsAa;
//extern GXRenderModeObj GXEurgb60Hz240Int;
//extern GXRenderModeObj GXEurgb60Hz240IntAa;
extern GXRenderModeObj GXEurgb60Hz480IntDf;
//extern GXRenderModeObj GXEurgb60Hz480Int;
//extern GXRenderModeObj GXEurgb60Hz480IntAa;
#define GX_MAX_Z24 0x00FFFFFF
void GXSetCopyClear(GXColor clear_clr, u32 clear_z);

View File

@ -1,8 +1,8 @@
#ifndef _DOLPHIN_OS_H
#define _DOLPHIN_OS_H
#include <dolphin/types.h>
#include <dolphin/gx.h>
#include <dolphin/types.h>
#ifdef __cplusplus
extern "C" {
@ -63,6 +63,31 @@ void* OSAllocFromArenaHi(u32 size, u32 align);
OSTime OSGetTime();
OSTick OSGetTick();
#define OS_CONSOLE_MASK 0xf0000000
#define OS_CONSOLE_RETAIL 0x00000000
#define OS_CONSOLE_DEVELOPMENT 0x10000000
#define OS_CONSOLE_TDEV 0x20000000
#define OS_CONSOLE_RETAIL4 0x00000004
#define OS_CONSOLE_RETAIL3 0x00000003
#define OS_CONSOLE_RETAIL2 0x00000002
#define OS_CONSOLE_RETAIL1 0x00000001
#define OS_CONSOLE_TDEVHW4 0x20000007
#define OS_CONSOLE_TDEVHW3 0x20000006
#define OS_CONSOLE_TDEVHW2 0x20000005
#define OS_CONSOLE_TDEVHW1 0x20000004
#define OS_CONSOLE_DEVHW4 0x10000007
#define OS_CONSOLE_DEVHW3 0x10000006
#define OS_CONSOLE_DEVHW2 0x10000005
#define OS_CONSOLE_DEVHW1 0x10000004
#define OS_CONSOLE_MINNOW 0x10000003
#define OS_CONSOLE_ARTHUR 0x10000002
#define OS_CONSOLE_PC_EMULATOR 0x10000001
#define OS_CONSOLE_EMULATOR 0x10000000
u32 OSGetConsoleType();
void OSReport(const char* msg, ...);
void OSPanic(const char* file, int line, const char* msg, ...);
void OSFatal(GXColor fg, GXColor bg, const char* msg);

View File

@ -8,6 +8,7 @@
extern "C" {
#endif
void VIInit(void);
void VIConfigure(GXRenderModeObj* rm);
void VIFlush(void);

View File

@ -422,7 +422,7 @@ KYOTO_1 :=\
$(BUILD_DIR)/src/Kyoto/Basics/CStopwatch.o\
$(BUILD_DIR)/asm/Kyoto/Basics/CBasicsDolphin.o\
$(BUILD_DIR)/asm/Kyoto/Basics/CCallStackDolphin.o\
$(BUILD_DIR)/asm/Kyoto/Basics/COsContextDolphin.o\
$(BUILD_DIR)/src/Kyoto/Basics/COsContextDolphin.o\
$(BUILD_DIR)/src/Kyoto/Basics/CSWDataDolphin.o\
$(BUILD_DIR)/asm/Kyoto/Basics/RAssertDolphin.o\
$(BUILD_DIR)/asm/Kyoto/Animation/CAnimation.o\

View File

@ -0,0 +1,96 @@
#include "Kyoto/Basics/COsContext.hpp"
#include "Kyoto/Alloc/CMemory.hpp"
#include "Kyoto/Basics/CBasics.hpp"
#include "dolphin/os.h"
#include "dolphin/vi.h"
#include <string.h>
COsContext::COsContext(bool, bool) {
CBasics::Init();
switch (OSGetConsoleType()) {
case OS_CONSOLE_RETAIL1:
x14_consoleType = kCT_Retail;
break;
case OS_CONSOLE_DEVHW1:
x14_consoleType = kCT_Development1;
break;
case OS_CONSOLE_DEVHW2:
case OS_CONSOLE_DEVHW3:
x14_consoleType = kCT_Development2Or3;
break;
case OS_CONSOLE_EMULATOR:
x14_consoleType = kCT_Emulator;
break;
}
}
COsContext::~COsContext() {}
bool COsContext::Update() { return true; }
COsKeyState COsContext::GetOsKeyState(int key) const {
return COsKeyState(key, false, false, false, false);
}
int COsContext::OpenWindow(const char* title, int x, int y, int w, int h, bool fullscreen) {
VIInit();
GXRenderModeObj* rModeObj;
switch (VIGetTvFormat()) {
case VI_NTSC:
rModeObj = &GXNtsc480IntDf;
x10_format = 1;
break;
case VI_PAL:
rModeObj = &GXPal528IntDf;
x10_format = 2;
break;
case VI_MPAL:
rModeObj = &GXMpal480IntDf;
x10_format = 3;
break;
}
if (w > 0) {
x30_renderMode.viWidth = w;
}
if (h > 0) {
x30_renderMode.viHeight = h;
}
GXAdjustForOverscan(rModeObj, &x30_renderMode, 0, 16);
x8_left = x30_renderMode.viXOrigin;
xc_top = x30_renderMode.viYOrigin;
x0_right = x30_renderMode.viWidth;
x4_bottom = x30_renderMode.viHeight;
x2c_frameBufferSize = (u16)((x30_renderMode.fbWidth + 15) & ~15) * x30_renderMode.xfbHeight * 2;
x24_frameBuffer1 = OSAllocFromArenaLo(x2c_frameBufferSize, 32);
x28_frameBuffer2 = OSAllocFromArenaLo(x2c_frameBufferSize, 32);
x20_arenaLo2 = OSGetArenaLo();
x18_arenaLo1 = OSGetArenaLo();
x1c_arenaHi = OSGetArenaHi();
x30_renderMode.viWidth += 20;
x30_renderMode.viXOrigin -= 10;
if (mProgressiveMode) {
x30_renderMode.viTVmode = VI_TVMODE_NTSC_PROG;
x30_renderMode.xFBmode = VI_XFBMODE_SF;
u8 progressiveFilterPattern[7] = {4, 4, 16, 16, 16, 4, 4 };
memcpy(x30_renderMode.vfilter, progressiveFilterPattern, 7);
}
VIConfigure(&x30_renderMode);
VIFlush();
return -1;
}
void* COsContext::AllocFromArena(size_t sz) {
void* ret = OSAllocFromArenaLo(sz, 32);
x20_arenaLo2 = OSGetArenaLo();
x18_arenaLo1 = OSGetArenaLo();
x1c_arenaHi = OSGetArenaHi();
return ret;
}

View File

@ -74,7 +74,7 @@ CInGameTweakManager* gpTweakManager;
unkptr gpDefaultFont;
unkptr lbl_805A8C50;
unkptr lbl_805A8C54;
bool lbl_805A8C58;
bool mProgressiveMode__10COsContext;
u32 sARAMMemArray[2];
f32 sInfiniteLoopTime;