Match and link CBasicsDolphin.cpp

This commit is contained in:
Phillip Stephens 2022-12-05 20:11:13 -08:00
parent e4a864880b
commit 6880c19ae9
7 changed files with 76 additions and 7 deletions

View File

@ -3,8 +3,7 @@
.section .sbss, "wa"
.balign 8
.global lbl_805A9240
lbl_805A9240:
gInitialized:
.skip 0x8
.section .text, "ax"
@ -14,7 +13,7 @@ Init__7CBasicsFv:
/* 802D6354 002D32B4 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 802D6358 002D32B8 7C 08 02 A6 */ mflr r0
/* 802D635C 002D32BC 90 01 00 14 */ stw r0, 0x14(r1)
/* 802D6360 002D32C0 88 0D A6 80 */ lbz r0, lbl_805A9240@sda21(r13)
/* 802D6360 002D32C0 88 0D A6 80 */ lbz r0, gInitialized@sda21(r13)
/* 802D6364 002D32C4 28 00 00 00 */ cmplwi r0, 0
/* 802D6368 002D32C8 40 82 00 48 */ bne lbl_802D63B0
/* 802D636C 002D32CC 48 0A 75 3D */ bl OSInit
@ -33,10 +32,10 @@ Init__7CBasicsFv:
/* 802D63A0 002D3300 48 09 B8 05 */ bl DVDInit
/* 802D63A4 002D3304 4B FF FF 15 */ bl InitGlobalTimer__10CStopwatchFv
/* 802D63A8 002D3308 38 00 00 01 */ li r0, 1
/* 802D63AC 002D330C 98 0D A6 80 */ stb r0, lbl_805A9240@sda21(r13)
/* 802D63AC 002D330C 98 0D A6 80 */ stb r0, gInitialized@sda21(r13)
lbl_802D63B0:
/* 802D63B0 002D3310 80 01 00 14 */ lwz r0, 0x14(r1)
/* 802D63B4 002D3314 88 6D A6 80 */ lbz r3, lbl_805A9240@sda21(r13)
/* 802D63B4 002D3314 88 6D A6 80 */ lbz r3, gInitialized@sda21(r13)
/* 802D63B8 002D3318 7C 08 03 A6 */ mtlr r0
/* 802D63BC 002D331C 38 21 00 10 */ addi r1, r1, 0x10
/* 802D63C0 002D3320 4E 80 00 20 */ blr

View File

@ -468,7 +468,7 @@ LIBS = [
"objects": [
"Kyoto/Basics/CBasics",
["Kyoto/Basics/CStopwatch", True],
"Kyoto/Basics/CBasicsDolphin",
["Kyoto/Basics/CBasicsDolphin", True],
["Kyoto/Alloc/CCallStackDolphin", True],
["Kyoto/Basics/COsContextDolphin", True],
["Kyoto/Basics/CSWDataDolphin", True],

View File

@ -4,7 +4,7 @@
#include "types.h"
namespace CBasics {
void Init();
bool Init();
char* Stringize(const char* fmt, ...);
inline uint SwapBytes(uint x) {
#if 0

View File

@ -46,6 +46,8 @@ struct DVDFileInfo {
DVDCallback callback;
};
void DVDInit();
void DVDSetAutoFatalMessaging(BOOL);
void DVDReset();

View File

@ -154,6 +154,7 @@ void OSFatal(GXColor fg, GXColor bg, const char* msg);
#include <dolphin/os/OSContext.h>
#include <dolphin/os/OSError.h>
#include <dolphin/os/OSException.h>
#include <dolphin/os/OSFastCast.h>
#include <dolphin/os/OSFont.h>
#include <dolphin/os/OSInterrupt.h>
#include <dolphin/os/OSMutex.h>

View File

@ -5,9 +5,57 @@
extern "C" {
#endif
#define OS_GQR_F32 0x0000
#define OS_GQR_U8 0x0004
#define OS_GQR_U16 0x0005
#define OS_GQR_S8 0x0006
#define OS_GQR_S16 0x0007
#define OS_FASTCAST_U8 2
#define OS_FASTCAST_U16 3
#define OS_FASTCAST_S16 5
// clang-format off
static inline void OSInitFastCast(void) {
#ifdef __MWERKS__
asm
{
li r3, OS_GQR_U8
oris r3, r3, OS_GQR_U8
mtspr GQR2, r3
li r3, OS_GQR_U16
oris r3, r3, OS_GQR_U16
mtspr GQR3, r3
li r3, OS_GQR_S8
oris r3, r3, OS_GQR_S8
mtspr GQR4, r3
li r3, OS_GQR_S16
oris r3, r3, OS_GQR_S16
mtspr GQR5, r3
}
#else
asm volatile ("
li 3, 0x0004
oris 3, 3, 0x0004
mtspr GQR2, 3
li 3, 0x0005
oris 3, 3, 0x0005
mtspr GQR3, 3
li 3, 0x0006
oris 3, 3, 0x0006
mtspr GQR4, 3
li 3, 0x0007
oris 3, 3, 0x0007
mtspr GQR5, 3
" : : : "r3" );
#endif
}
// clang-format off
#ifdef __cplusplus
}

View File

@ -0,0 +1,19 @@
#include "Kyoto/Basics/CBasics.hpp"
#include "Kyoto/Basics/CStopwatch.hpp"
#include "dolphin/os.h"
#include "dolphin/dvd.h"
static bool gInitialized = false;
bool CBasics::Init() {
if (!gInitialized) {
OSInit();
OSInitFastCast();
DVDInit();
CStopwatch::InitGlobalTimer();
gInitialized = true;
}
return gInitialized;
}