print stuff

This commit is contained in:
Derek Hensley 2024-01-20 21:48:32 -08:00
parent 7dfea48bec
commit 1d833e2f0d
9 changed files with 21 additions and 15 deletions

View File

@ -23,15 +23,15 @@ typedef struct {
/* 0x34 */ u8 qual; /* 0x34 */ u8 qual;
} _Pft; } _Pft;
typedef void* (*PrintCallback)(void*, const char*, size_t);
#define FLAGS_SPACE 1 #define FLAGS_SPACE 1
#define FLAGS_PLUS 2 #define FLAGS_PLUS 2
#define FLAGS_MINUS 4 #define FLAGS_MINUS 4
#define FLAGS_HASH 8 #define FLAGS_HASH 8
#define FLAGS_ZERO 16 #define FLAGS_ZERO 16
int _Printf(PrintCallback pfn, void* arg, const char* fmt, va_list ap); typedef char *outfun(char*,const char*,size_t);
int _Printf(outfun pfn, char* arg, const char* fmt, va_list ap);
void _Litob(_Pft* args, u8 type); void _Litob(_Pft* args, u8 type);
void _Ldtob(_Pft* args, u8 type); void _Ldtob(_Pft* args, u8 type);

View File

@ -9,7 +9,6 @@ typedef void (*FaultDrawerCallback)(void);
void FaultDrawer_SetOsSyncPrintfEnabled(u32 enabled); void FaultDrawer_SetOsSyncPrintfEnabled(u32 enabled);
void FaultDrawer_DrawRecImpl(s32 xStart, s32 yStart, s32 xEnd, s32 yEnd, u16 color); void FaultDrawer_DrawRecImpl(s32 xStart, s32 yStart, s32 xEnd, s32 yEnd, u16 color);
void FaultDrawer_FillScreen(void); void FaultDrawer_FillScreen(void);
void* FaultDrawer_FormatStringFunc(void* arg, const char* str, size_t count);
void FaultDrawer_SetDrawerFrameBuffer(void* frameBuffer, u16 w, u16 h); void FaultDrawer_SetDrawerFrameBuffer(void* frameBuffer, u16 w, u16 h);
void FaultDrawer_SetInputCallback(FaultDrawerCallback callback); void FaultDrawer_SetInputCallback(FaultDrawerCallback callback);
void FaultDrawer_Init(void); void FaultDrawer_Init(void);

View File

@ -1,10 +1,9 @@
#ifndef GFXPRINT_H #ifndef GFXPRINT_H
#define GFXPRINT_H #define GFXPRINT_H
#include "ultra64.h"
#include "color.h" #include "color.h"
#include "PR/gbi.h" #include "libc64/aprintf.h"
#include "PR/ultratypes.h"
#include "PR/xstdio.h"
#include "unk.h" #include "unk.h"
#define GFXP_UNUSED "\x8E" #define GFXP_UNUSED "\x8E"

View File

@ -3,6 +3,8 @@
#include "ultra64.h" #include "ultra64.h"
typedef void* (*PrintCallback)(void*, const char*, size_t);
int vaprintf(PrintCallback* pfn, const char* fmt, va_list args); int vaprintf(PrintCallback* pfn, const char* fmt, va_list args);
int aprintf(PrintCallback* pfn, const char* fmt, ...); int aprintf(PrintCallback* pfn, const char* fmt, ...);

View File

@ -1,5 +1,4 @@
#include "global.h" #include "gfxprint.h"
#include "libc64/aprintf.h"
#define GFXP_FLAG_HIRAGANA (1 << 0) #define GFXP_FLAG_HIRAGANA (1 << 0)
#define GFXP_FLAG_RAINBOW (1 << 1) #define GFXP_FLAG_RAINBOW (1 << 1)
@ -127,30 +126,37 @@ void GfxPrint_PrintChar(GfxPrint* this, u8 c) {
switch (c) { switch (c) {
case '\0': case '\0':
break; break;
case '\n': case '\n':
this->posY += 32; this->posY += 32;
case '\r': case '\r':
this->posX = this->baseX; this->posX = this->baseX;
break; break;
case '\t': case '\t':
do { do {
GfxPrint_PrintCharImpl(this, ' '); GfxPrint_PrintCharImpl(this, ' ');
} while ((this->posX - this->baseX) % 256); } while ((this->posX - this->baseX) % 256);
break; break;
case GFXP_HIRAGANA_CHAR: case GFXP_HIRAGANA_CHAR:
this->flags |= GFXP_FLAG_HIRAGANA; this->flags |= GFXP_FLAG_HIRAGANA;
break; break;
case GFXP_KATAKANA_CHAR: case GFXP_KATAKANA_CHAR:
this->flags &= ~GFXP_FLAG_HIRAGANA; this->flags &= ~GFXP_FLAG_HIRAGANA;
break; break;
case GFXP_RAINBOW_ON_CHAR: case GFXP_RAINBOW_ON_CHAR:
this->flags |= GFXP_FLAG_RAINBOW; this->flags |= GFXP_FLAG_RAINBOW;
this->flags |= GFXP_FLAG_UPDATE; this->flags |= GFXP_FLAG_UPDATE;
break; break;
case GFXP_RAINBOW_OFF_CHAR: case GFXP_RAINBOW_OFF_CHAR:
this->flags &= ~GFXP_FLAG_RAINBOW; this->flags &= ~GFXP_FLAG_RAINBOW;
this->flags |= GFXP_FLAG_UPDATE; this->flags |= GFXP_FLAG_UPDATE;
break; break;
case GFXP_UNUSED_CHAR: case GFXP_UNUSED_CHAR:
default: default:
break; break;

View File

@ -215,7 +215,7 @@ void FaultDrawer_FillScreen() {
FaultDrawer_SetCursor(sFaultDrawerInstance->xStart, sFaultDrawerInstance->yStart); FaultDrawer_SetCursor(sFaultDrawerInstance->xStart, sFaultDrawerInstance->yStart);
} }
void* FaultDrawer_FormatStringFunc(void* arg, const char* str, size_t count) { char* FaultDrawer_FormatStringFunc(char* arg, const char* str, size_t count) {
for (; count > 0; count--, str++) { for (; count > 0; count--, str++) {
if (sFaultDrawerInstance->escCode) { if (sFaultDrawerInstance->escCode) {
sFaultDrawerInstance->escCode = false; sFaultDrawerInstance->escCode = false;
@ -267,7 +267,7 @@ void* FaultDrawer_FormatStringFunc(void* arg, const char* str, size_t count) {
const char D_80099080[] = "(null)"; const char D_80099080[] = "(null)";
s32 FaultDrawer_VPrintf(const char* fmt, va_list ap) { s32 FaultDrawer_VPrintf(const char* fmt, va_list ap) {
return _Printf(FaultDrawer_FormatStringFunc, sFaultDrawerInstance, fmt, ap); return _Printf(FaultDrawer_FormatStringFunc, (void*)sFaultDrawerInstance, fmt, ap);
} }
s32 FaultDrawer_Printf(const char* fmt, ...) { s32 FaultDrawer_Printf(const char* fmt, ...) {

View File

@ -1,7 +1,7 @@
#include "libc64/aprintf.h" #include "libc64/aprintf.h"
int vaprintf(PrintCallback* pfn, const char* fmt, va_list args) { int vaprintf(PrintCallback* pfn, const char* fmt, va_list args) {
return _Printf(*pfn, pfn, fmt, args); return _Printf((outfun*)*pfn, (char*)pfn, fmt, args);
} }
int aprintf(PrintCallback* pfn, const char* fmt, ...) { int aprintf(PrintCallback* pfn, const char* fmt, ...) {

View File

@ -7,7 +7,7 @@ void* proutPrintf(void* dst, const char* fmt, size_t size) {
} }
int vsprintf(char* dst, const char* fmt, va_list args) { int vsprintf(char* dst, const char* fmt, va_list args) {
int ans = _Printf(proutPrintf, dst, fmt, args); int ans = _Printf((outfun*)proutPrintf, dst, fmt, args);
if (ans > -1) { if (ans > -1) {
dst[ans] = 0; dst[ans] = 0;
@ -20,7 +20,7 @@ int sprintf(char* dst, const char* fmt, ...) {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
ans = _Printf(&proutPrintf, dst, fmt, args); ans = _Printf((outfun*)proutPrintf, dst, fmt, args);
if (ans > -1) { if (ans > -1) {
dst[ans] = 0; dst[ans] = 0;
} }

View File

@ -31,7 +31,7 @@ char zeroes[] = "00000000000000000000000000000000";
void _Putfld(_Pft* px, va_list* pap, unsigned char code, unsigned char* ac); void _Putfld(_Pft* px, va_list* pap, unsigned char code, unsigned char* ac);
int _Printf(PrintCallback pfn, void* arg, const char* fmt, va_list ap) { int _Printf(outfun pfn, void* arg, const char* fmt, va_list ap) {
_Pft x; _Pft x;
x.nchar = 0; x.nchar = 0;
while (1) { while (1) {