Skip to content

Commit

Permalink
db_console.cpp OK
Browse files Browse the repository at this point in the history
  • Loading branch information
CelestialAmber committed Sep 15, 2024
1 parent eb51b7f commit b1138d3
Show file tree
Hide file tree
Showing 10 changed files with 333 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"${workspaceFolder}/libs/NdevExi2A/include",
"${workspaceFolder}/libs/nw4r/include",
"${workspaceFolder}/libs/nw4r/include/nw4r/",
"${workspaceFolder}/libs/nw4r/include/nw4r/db",
"${workspaceFolder}/libs/nw4r/include/nw4r/g3d",
"${workspaceFolder}/libs/nw4r/include/nw4r/ut",
"${workspaceFolder}/libs/nw4r/include/nw4r/lyt",
Expand Down Expand Up @@ -38,6 +39,7 @@
"${workspaceFolder}/libs/NdevExi2A/include",
"${workspaceFolder}/libs/nw4r/include",
"${workspaceFolder}/libs/nw4r/include/nw4r/",
"${workspaceFolder}/libs/nw4r/include/nw4r/db",
"${workspaceFolder}/libs/nw4r/include/nw4r/g3d",
"${workspaceFolder}/libs/nw4r/include/nw4r/ut",
"${workspaceFolder}/libs/nw4r/include/nw4r/lyt",
Expand Down Expand Up @@ -66,6 +68,7 @@
"${workspaceFolder}/libs/NdevExi2A/include",
"${workspaceFolder}/libs/nw4r/include",
"${workspaceFolder}/libs/nw4r/include/nw4r/",
"${workspaceFolder}/libs/nw4r/include/nw4r/db",
"${workspaceFolder}/libs/nw4r/include/nw4r/g3d",
"${workspaceFolder}/libs/nw4r/include/nw4r/ut",
"${workspaceFolder}/libs/nw4r/include/nw4r/lyt",
Expand Down
5 changes: 4 additions & 1 deletion config/eu/splits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2093,7 +2093,10 @@ libs/CriWare/sofdec/sud/sud_lib.temp.c:
.text start:0x803D96F0 end:0x803D9884

libs/nw4r/db/db_console.temp.cpp:
.text start:0x803D9884 end:0x803D997C
.text start:0x803D9884 end:0x803D9958

libs/nw4r/db/db_DbgPrintBase.temp.cpp:
.text start:0x803D9958 end:0x803D997C

libs/nw4r/db/db_assert.temp.cpp:
.text start:0x803D997C end:0x803D9B74
Expand Down
5 changes: 4 additions & 1 deletion config/jp/splits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5104,7 +5104,10 @@ libs/CriWare/sofdec/sud/sud_lib.c:
.bss start:0x8061D708 end:0x8061D710

libs/nw4r/db/db_console.cpp:
.text start:0x803D7244 end:0x803D733C
.text start:0x803D7244 end:0x803D7318

libs/nw4r/db/db_DbgPrintBase.cpp:
.text start:0x803D7318 end:0x803D733C

libs/nw4r/db/db_assert.cpp:
.text start:0x803D733C end:0x803D7810
Expand Down
3 changes: 2 additions & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,8 @@ def nw4rLib(lib_name, objects, extra_cflags=[]):
nw4rLib(
"libnw4r_db",
[
Object(NonMatching, "db/db_console.cpp"),
Object(Matching, "db/db_console.cpp"),
Object(Matching, "db/db_DbgPrintBase.cpp"),
Object(NonMatching, "db/db_assert.cpp"),
],
),
Expand Down
14 changes: 14 additions & 0 deletions libs/nw4r/include/nw4r/db/db_DbgPrintBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef NW4R_DB_DBG_PRINT_BASE_H
#define NW4R_DB_DBG_PRINT_BASE_H

#include "types_nw4r.h"
#include "ut_CharWriter.h"

namespace nw4r
{
namespace db
{
}
}

#endif
4 changes: 2 additions & 2 deletions libs/nw4r/include/nw4r/db/db_assert.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _NW4R_DB_ASSERT_H
#define _NW4R_DB_ASSERT_H
#ifndef NW4R_DB_ASSERT_H
#define NW4R_DB_ASSERT_H

#include "types.h"

Expand Down
75 changes: 75 additions & 0 deletions libs/nw4r/include/nw4r/db/db_console.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#ifndef NW4R_DB_CONSOLE_H
#define NW4R_DB_CONSOLE_H

#include "types_nw4r.h"
#include "ut_TextWriterBase.h"
#include "ut_CharWriter.h"

namespace nw4r
{
namespace db
{
namespace detail
{
struct ConsoleHead
{
u8* textBuf; // at 0x0
u16 width; // at 0x4
u16 height; // at 0x6
u16 priority; // at 0x8
u16 attr; // at 0xA
u16 printTop; // at 0xC
u16 printXPos; // at 0xE
u16 ringTop; // at 0x10
long ringTopLineCnt; // at 0x14
long viewTopLine; // at 0x18
s16 viewPosX; // at 0x1C
s16 viewPosY; // at 0x1E
u16 viewLines; // at 0x20
u8 isVisible; // at 0x22
u8 padding_[1]; // at 0x23
ut::TextWriterBase<char>* writer; // at 0x24
ConsoleHead* next; // at 0x28
};
}

typedef enum ConsoleOutputType {
CONSOLE_OUTPUT_NONE,
CONSOLE_OUTPUT_DISPLAY,
CONSOLE_OUTPUT_TERMINAL,
CONSOLE_OUTPUT_ALL,
} ConsoleOutputType;

typedef void (*VisitStringCallback)(detail::ConsoleHead* console, u8* r4, long r5, u32 r6);

//unused
u8 Console_SetVisible(detail::ConsoleHead* console, bool isVisible) {
u8 before;
return 0;
}

//unused
long Console_SetViewBaseLine(detail::ConsoleHead* console, long line) {
long before;
return 0;
}

detail::ConsoleHead* Console_Create(void* buffer, u16 width, u16 height, u16 viewHeight, u16 priority, u16 attr);
void Console_Destroy(detail::ConsoleHead* console);
void Console_Clear(detail::ConsoleHead* console);
void Console_Draw(detail::ConsoleHead* console, ut::TextWriterBase<char>& writer);
void Console_DrawDirect(detail::ConsoleHead* console);
void Console_DrawAll();
void Console_DrawDirectAll();
void Console_VFPrintf(ConsoleOutputType type, detail::ConsoleHead* console, const char* format, va_list* vlist);
void Console_FPrintf(ConsoleOutputType type, detail::ConsoleHead* console, const char * format);
void Console_Printf(detail::ConsoleHead* console, const char* format, ...);
void Console_PrintfD(detail::ConsoleHead* console, const char* format, ...);
void Console_PrintfT(detail::ConsoleHead* console, const char* format, ...);
u16 Console_ChangePriority(detail::ConsoleHead* console, u16 r4);
void Console_VisitString(detail::ConsoleHead* console, VisitStringCallback visitor);
long Console_GetTotalLines(detail::ConsoleHead* console);
}
}

#endif
6 changes: 6 additions & 0 deletions libs/nw4r/include/nw4r/types_nw4r.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ template <typename T> struct TextWriterBase;

} // namespace ut

namespace db {
namespace detail {
struct ConsoleHead;
}
} // namespace db

namespace ef {
struct DrawOrder;
struct DrawInfo;
Expand Down
13 changes: 13 additions & 0 deletions libs/nw4r/src/db/db_DbgPrintBase.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "db_DbgPrintBase.h"

namespace nw4r
{
namespace db
{
//Dummy function to force SetTextColor to be generated here
void dummy(ut::CharWriter* pCharWriter){
ut::Color color;
pCharWriter->SetTextColor(color);
}
}
}
210 changes: 210 additions & 0 deletions libs/nw4r/src/db/db_console.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
#include "db_console.h"
#include <revolution/OS.h>

namespace nw4r
{
namespace db
{
//unused
static OSMutex sMutex;

//unused
static void TerminateLine_(detail::ConsoleHead* console)
{
}

//unused
static u8* GetTextPtr_(detail::ConsoleHead* console, u16 line, u16 xPos)
{
return 0;
}

//unused
static u8* NextLine_(detail::ConsoleHead* console)
{
return 0;
}

//unused
static u8* PutTab_(detail::ConsoleHead* console, u8* dstPtr)
{
return 0;
}

//unused
static u32 GetTabSize_(detail::ConsoleHead* console)
{
return 0;
}

//unused
static u32 PutChar_(detail::ConsoleHead* console, const u8* str, u8* dstPtr)
{
return 0;
}

//unused
static u32 CodeWidth_(const u8* p)
{
return 0;
}

//unused
static detail::ConsoleHead* SearchConsoleFromListByPriority_(u16 r3)
{
return nullptr;
}

//unused
static void AppendConsoleToList_(detail::ConsoleHead* console)
{
}

//unused
static void RemoveConsoleFromList_(detail::ConsoleHead* console)
{
}

//unused
detail::ConsoleHead* Console_Create(void* buffer, u16 width, u16 height, u16 viewHeight, u16 priority, u16 attr)
{
}

//unused
void Console_Destroy(detail::ConsoleHead* console)
{
}

//unused
void Console_Clear(detail::ConsoleHead* console)
{
}

//unused
static void UnlockMutex_(OSMutex* mutex)
{
}

//unused
static bool TryLockMutex_(OSMutex* mutex)
{
return false;
}

//unused
static void DoDrawString_(detail::ConsoleHead* console, u32 printLine, const u8* str, ut::TextWriterBase<char>* writer)
{
}

//unused
static void DoDrawConsole_(detail::ConsoleHead* console, ut::TextWriterBase<char>* writer)
{
}

static u16 GetRingUsedLines_(detail::ConsoleHead* console);

static u16 GetActiveLines_(detail::ConsoleHead* console)
{
u16 lines = GetRingUsedLines_(console);
if(console->printXPos != 0){
lines++;
}

return lines;
}

static u16 GetRingUsedLines_(detail::ConsoleHead* console)
{
long lines = console->printTop - console->ringTop;
if(lines < 0){
lines += console->height;
}
return (u16)lines;
}

//unused
void Console_Draw(detail::ConsoleHead* console, ut::TextWriterBase<char>& writer)
{
}

//unused
void Console_DrawDirect(detail::ConsoleHead* console)
{
}

//unused
void Console_DrawAll()
{
}

//unused
void Console_DrawDirectAll()
{
}

//unused
static void PrintToBuffer_(detail::ConsoleHead* console, const u8* str)
{
}

//unused
static u8* SearchEndOfLine_(const u8* str)
{
return 0;
}

//unused
static void Console_PrintString_(ConsoleOutputType type, detail::ConsoleHead* console, const u8* str)
{
}

//unused
void Console_VFPrintf(ConsoleOutputType type, detail::ConsoleHead* console, const char* format, va_list* vlist)
{
static u8 sStrBuf[1024];
}

//unused
void Console_FPrintf(ConsoleOutputType type, detail::ConsoleHead* console, const char * format)
{
}

void Console_Printf(detail::ConsoleHead* console, const char* format, ...)
{
va_list vlist;
va_start(vlist, format);
}

//unused
void Console_PrintfD(detail::ConsoleHead* console, const char* format, ...)
{
}

//unused
void Console_PrintfT(detail::ConsoleHead* console, const char* format, ...)
{
}

//unused
u16 Console_ChangePriority(detail::ConsoleHead* console, u16 r4)
{
return 0;
}

//unused
void Console_VisitString(detail::ConsoleHead* console, VisitStringCallback visitor)
{
}

long Console_GetTotalLines(detail::ConsoleHead* console)
{
BOOL enabled = OSDisableInterrupts();

long count = GetActiveLines_(console) + console->ringTopLineCnt;

OSRestoreInterrupts(enabled);

return count;
}
}
}

0 comments on commit b1138d3

Please sign in to comment.