Merge pull request #43 from robojumper/nw4r_db

Nw4r db
This commit is contained in:
Elijah Thomas
2024-05-31 19:31:21 -04:00
committed by GitHub
18 changed files with 1479 additions and 78 deletions
+4 -7
View File
@@ -3,17 +3,19 @@
#include <common.h>
#include <m/m_dvd.h>
#include <nw4r/db/db_mapFile.h>
#include <rvl/OS.h>
class DbMapFile {
public:
DbMapFile(): unk_0(0) {}
DbMapFile(): mMapFileHandle(nullptr) {}
~DbMapFile();
void RegisterOnDvd(const char *, const OSModuleInfo *);
void Unregister();
private:
UNKWORD unk_0;
nw4r::db::MapFileHandle mMapFileHandle;
nw4r::db::MapFile mMapFile;
};
// https://github.com/zeldaret/tp/blob/main/include/DynamicLink.h
@@ -75,11 +77,6 @@ struct DynamicModuleControl : DynamicModuleControlBase {
/* 0x2C */ mDvd_callback_c *mDvdCallbackRequest;
/* 0x30 */ EGG::ExpHeap *mHeap;
/* 0x34 */ DbMapFile mpRelMapFile;
// Some of these might be members of DbMapFile
UNKWORD unk1;
UNKWORD unk2;
UNKWORD unk3;
UNKWORD unk4;
static u32 sAllocBytes;
static mDvd_toMainRam_base_c *sDvdFile;
+2 -2
View File
@@ -10,8 +10,8 @@ extern "C" {
int fprintf(FILE* stream, const char* format, ...);
int printf(const char* format, ...);
int sprintf(const char* str, const char* format, ...);
int snprintf(const char* str, size_t n, const char* format, ...);
int sprintf(char* str, const char* format, ...);
int snprintf(char* str, size_t n, const char* format, ...);
int vsnprintf(char* str, size_t n, const char* format, va_list arg);
int vprintf(const char* format, va_list arg);
+16
View File
@@ -0,0 +1,16 @@
#ifndef NW4R_DB_ASSERT_H
#define NW4R_DB_ASSERT_H
#include <nw4r/db/db_console.h>
namespace nw4r {
namespace db {
typedef detail::ConsoleHead *ConsoleHandle;
ConsoleHandle Assertion_SetConsole(ConsoleHandle handle);
} // namespace db
} // namespace nw4r
#endif
+52
View File
@@ -0,0 +1,52 @@
#ifndef NW4R_DB_CONSOLE_H
#define NW4R_DB_CONSOLE_H
#include <common.h>
#include <nw4r/ut/ut_TextWriterBase.h>
namespace nw4r {
namespace db {
namespace detail {
typedef struct ConsoleHead {
u8 *textBuf;
u16 width;
u16 height;
u16 priority;
u16 attr;
u16 printTop;
u16 printXPos;
u16 ringTop;
u32 ringTopLineCnt;
s32 viewTopLine;
s16 viewPosX;
s16 viewPosY;
u16 viewLines;
bool isVisible;
nw4r::ut::TextWriterBase<char> *writer;
ConsoleHead *next;
} ConsoleHead;
} // namespace detail
typedef detail::ConsoleHead *ConsoleHandle;
enum ConsoleOutputType {
CONSOLE_OUTPUT_NONE = 0,
CONSOLE_OUTPUT_DISPLAY = 1,
CONSOLE_OUTPUT_TERMINAL = 2,
CONSOLE_OUTPUT_ALL = CONSOLE_OUTPUT_DISPLAY | CONSOLE_OUTPUT_TERMINAL,
};
ConsoleHandle Console_Create(void *arg, u16, u16, u16, u16, u16);
ConsoleHandle Console_Destroy(ConsoleHandle console);
void Console_DrawDirect(ConsoleHandle console);
void Console_VFPrintf(ConsoleOutputType type, ConsoleHandle console, const char* format, va_list vlist);
void Console_Printf(ConsoleHandle console, const char* format, ...);
s32 Console_GetTotalLines(ConsoleHandle console);
} // namespace db
} // namespace nw4r
#endif
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef DB_DIRECT_PRINT_H
#define DB_DIRECT_PRINT_H
#ifndef NW4R_DB_DIRECT_PRINT_H
#define NW4R_DB_DIRECT_PRINT_H
#include <Runtime.PPCEABI.H/__va_arg.h>
#include <common.h>
+26
View File
@@ -0,0 +1,26 @@
#ifndef NW4R_DB_EXCEPTION_H
#define NW4R_DB_EXCEPTION_H
#include <nw4r/db/db_console.h>
#include <rvl/OS.h>
namespace nw4r {
namespace db {
typedef struct {
u16 error;
OSContext *ctx;
u32 dsisr;
u32 dar;
} ExceptionCallbackParam;
void Exception_Init();
ConsoleHandle Exception_SetConsole(ConsoleHandle, const _GXRenderModeObj *);
ConsoleHandle Exception_GetConsole();
void Exception_SetUserCallback(bool (*)(ConsoleHandle, void *), void *);
} // namespace db
} // namespace nw4r
#endif
+26
View File
@@ -0,0 +1,26 @@
#ifndef NW4R_DB_MAPFILE_H
#define NW4R_DB_MAPFILE_H
#include <rvl/OS.h>
namespace nw4r {
namespace db {
typedef struct MapFile {
u8 *mapBuf;
const OSModuleInfo *moduleInfo;
s32 fileEntry;
MapFile *next;
} MapFile;
typedef MapFile *MapFileHandle;
MapFileHandle MapFile_RegistOnDvd(void *, const char *, const OSModuleInfo *);
void MapFile_Unregist(MapFileHandle);
void MapFile_UnregistAll();
bool MapFile_QuerySymbol(u32 address, u8 *strBuf, u32 strBufSize);
} // namespace db
} // namespace nw4r
#endif
+1 -1
View File
@@ -36,7 +36,7 @@ typedef enum {
OS_ERR_MAX
} OSErrorType;
typedef void (*OSErrorHandler)(u8 error, OSContext *ctx, u32 dsisr, u32 dar, ...);
typedef void (*OSErrorHandler)(u16 error, OSContext *ctx, u32 dsisr, u32 dar);
extern OSErrorHandler __OSErrorTable[OS_ERR_MAX];
extern u32 __OSFpscrEnableBits;
+1
View File
@@ -105,6 +105,7 @@ BOOL OSLinkFixed(OSModuleInfo* newModule, void* bss);
BOOL OSUnlink(OSModuleInfo* module);
void OSSetStringTable(void* string_table);
void __OSModuleInit(void);
OSModuleInfo* OSSearchModule(void* ptr, u32* section, u32* offset);
#ifdef __cplusplus
};