mirror of
https://github.com/izzy2lost/Diddy-Kong-Racing.git
synced 2026-06-19 01:16:26 -07:00
Rename xprintf and printf files. I accidentally used the xprintf name in the wrong place, and don't want to cause confusion with libreultra and others
This commit is contained in:
@@ -260,7 +260,7 @@ $(BUILD_DIR)/lib/src/al/%.o: OPT_FLAGS := -O3
|
||||
$(BUILD_DIR)/lib/src/os/%.o: OPT_FLAGS := -O1
|
||||
$(BUILD_DIR)/lib/src/os/osViMgr.o: OPT_FLAGS := -O2
|
||||
$(BUILD_DIR)/lib/src/os/osCreatePiManager.o: OPT_FLAGS := -O2
|
||||
$(BUILD_DIR)/lib/src/printf.o : OPT_FLAGS := -O3
|
||||
$(BUILD_DIR)/lib/src/libc/xprintf.o : OPT_FLAGS := -O3
|
||||
$(BUILD_DIR)/lib/src/al/unknown_0C9C90.o: OPT_FLAGS := -O2 -Wo,-loopunroll,0
|
||||
#$(BUILD_DIR)/lib/src/libc/llcvt.o: OPT_FLAGS :=
|
||||
#$(BUILD_DIR)/lib/src/libc/llcvt.o: MIPSISET := -mips3 32
|
||||
|
||||
@@ -40,24 +40,24 @@ glabel func_80069F64
|
||||
/* 06ABB8 80069FB8 02E08025 */ move $s0, $s7
|
||||
.L80069FBC:
|
||||
/* 06ABBC 80069FBC 86050000 */ lh $a1, ($s0)
|
||||
/* 06ABC0 80069FC0 0C032755 */ jal xprintf
|
||||
/* 06ABC0 80069FC0 0C032755 */ jal simple_sprintf
|
||||
/* 06ABC4 80069FC4 02602025 */ move $a0, $s3
|
||||
/* 06ABC8 80069FC8 86050020 */ lh $a1, 0x20($s0)
|
||||
/* 06ABCC 80069FCC 02802025 */ move $a0, $s4
|
||||
/* 06ABD0 80069FD0 30AEFFFF */ andi $t6, $a1, 0xffff
|
||||
/* 06ABD4 80069FD4 0C032755 */ jal xprintf
|
||||
/* 06ABD4 80069FD4 0C032755 */ jal simple_sprintf
|
||||
/* 06ABD8 80069FD8 01C02825 */ move $a1, $t6
|
||||
/* 06ABDC 80069FDC 26310002 */ addiu $s1, $s1, 2
|
||||
/* 06ABE0 80069FE0 1635FFF6 */ bne $s1, $s5, .L80069FBC
|
||||
/* 06ABE4 80069FE4 26100002 */ addiu $s0, $s0, 2
|
||||
/* 06ABE8 80069FE8 0C032755 */ jal xprintf
|
||||
/* 06ABE8 80069FE8 0C032755 */ jal simple_sprintf
|
||||
/* 06ABEC 80069FEC 03C02025 */ move $a0, $fp
|
||||
/* 06ABF0 80069FF0 26D60004 */ addiu $s6, $s6, 4
|
||||
/* 06ABF4 80069FF4 24010010 */ li $at, 16
|
||||
/* 06ABF8 80069FF8 16C1FFEE */ bne $s6, $at, .L80069FB4
|
||||
/* 06ABFC 80069FFC 26F70008 */ addiu $s7, $s7, 8
|
||||
/* 06AC00 8006A000 3C04800E */ lui $a0, %hi(D_800E7088) # $a0, 0x800e
|
||||
/* 06AC04 8006A004 0C032755 */ jal xprintf
|
||||
/* 06AC04 8006A004 0C032755 */ jal simple_sprintf
|
||||
/* 06AC08 8006A008 24847088 */ addiu $a0, %lo(D_800E7088) # addiu $a0, $a0, 0x7088
|
||||
/* 06AC0C 8006A00C 8FBF003C */ lw $ra, 0x3c($sp)
|
||||
/* 06AC10 8006A010 8FB00018 */ lw $s0, 0x18($sp)
|
||||
|
||||
@@ -21,7 +21,7 @@ glabel func_80065E30
|
||||
/* 066A7C 80065E7C 132B0003 */ beq $t9, $t3, .L80065E8C
|
||||
.L80065E80:
|
||||
/* 066A80 80065E80 3C04800E */ lui $a0, %hi(D_800E6ED0) # $a0, 0x800e
|
||||
/* 066A84 80065E84 0C032755 */ jal xprintf
|
||||
/* 066A84 80065E84 0C032755 */ jal simple_sprintf
|
||||
/* 066A88 80065E88 24846ED0 */ addiu $a0, %lo(D_800E6ED0) # addiu $a0, $a0, 0x6ed0
|
||||
.L80065E8C:
|
||||
/* 066A8C 80065E8C 8FBF0014 */ lw $ra, 0x14($sp)
|
||||
|
||||
@@ -288,7 +288,7 @@ glabel func_8002C0C4
|
||||
/* 02D0FC 8002C4FC 14200004 */ bnez $at, .L8002C510
|
||||
/* 02D100 8002C500 3C04800E */ lui $a0, %hi(D_800E5E38) # $a0, 0x800e
|
||||
/* 02D104 8002C504 24845E38 */ addiu $a0, %lo(D_800E5E38) # addiu $a0, $a0, 0x5e38
|
||||
/* 02D108 8002C508 0C032755 */ jal xprintf
|
||||
/* 02D108 8002C508 0C032755 */ jal simple_sprintf
|
||||
/* 02D10C 8002C50C 02602825 */ move $a1, $s3
|
||||
.L8002C510:
|
||||
/* 02D110 8002C510 0C01C42C */ jal set_free_queue_state
|
||||
|
||||
@@ -30,7 +30,7 @@ glabel func_8003B368
|
||||
/* 03BFBC 8003B3BC 15C10006 */ bne $t6, $at, .L8003B3D8
|
||||
/* 03BFC0 8003B3C0 3C04800E */ lui $a0, %hi(D_800E5FA0) # $a0, 0x800e
|
||||
/* 03BFC4 8003B3C4 24845FA0 */ addiu $a0, %lo(D_800E5FA0) # addiu $a0, $a0, 0x5fa0
|
||||
/* 03BFC8 8003B3C8 0C032755 */ jal xprintf
|
||||
/* 03BFC8 8003B3C8 0C032755 */ jal simple_sprintf
|
||||
/* 03BFCC 8003B3CC AFA60024 */ sw $a2, 0x24($sp)
|
||||
/* 03BFD0 8003B3D0 8FA60024 */ lw $a2, 0x24($sp)
|
||||
/* 03BFD4 8003B3D4 00000000 */ nop
|
||||
|
||||
@@ -46,7 +46,7 @@ glabel func_8003B7CC
|
||||
/* 03C460 8003B860 15210007 */ bne $t1, $at, .L8003B880
|
||||
/* 03C464 8003B864 A0680012 */ sb $t0, 0x12($v1)
|
||||
/* 03C468 8003B868 AFA30024 */ sw $v1, 0x24($sp)
|
||||
/* 03C46C 8003B86C 0C032755 */ jal xprintf
|
||||
/* 03C46C 8003B86C 0C032755 */ jal simple_sprintf
|
||||
/* 03C470 8003B870 AFA6002C */ sw $a2, 0x2c($sp)
|
||||
/* 03C474 8003B874 8FA30024 */ lw $v1, 0x24($sp)
|
||||
/* 03C478 8003B878 8FA6002C */ lw $a2, 0x2c($sp)
|
||||
|
||||
@@ -26,7 +26,7 @@ glabel func_8003C644
|
||||
/* 03D288 8003C688 2401FFFF */ li $at, -1
|
||||
/* 03D28C 8003C68C 15C10003 */ bne $t6, $at, .L8003C69C
|
||||
/* 03D290 8003C690 3C04800E */ lui $a0, %hi(D_800E5FC8) # $a0, 0x800e
|
||||
/* 03D294 8003C694 0C032755 */ jal xprintf
|
||||
/* 03D294 8003C694 0C032755 */ jal simple_sprintf
|
||||
/* 03D298 8003C698 24845FC8 */ addiu $a0, %lo(D_800E5FC8) # addiu $a0, $a0, 0x5fc8
|
||||
.L8003C69C:
|
||||
/* 03D29C 8003C69C 92380008 */ lbu $t8, 8($s1)
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/* The comment below is needed for this file to be picked up by generate_ld */
|
||||
/* RAM_POS: 0x800C9D40 */
|
||||
|
||||
#include "simplesprintf.h"
|
||||
#include "types.h"
|
||||
#include "macros.h"
|
||||
#include "stdarg.h"
|
||||
#include "xprintf.h"
|
||||
|
||||
/**
|
||||
* This gets called inside of _PrintF, but it is just hardcoded to return true.
|
||||
*/
|
||||
char *prout_simple_sprintf(char *dst, const char *src, size_t count) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Like sprintf, but simpler. It just hardcodes 0 for the dst,
|
||||
* and calls a function that just hardcodes a return of TRUE.
|
||||
*/
|
||||
s32 simple_sprintf(const char *format, ...) {
|
||||
s32 written;
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
written = _Printf(prout_simple_sprintf, 0, format, args);
|
||||
va_end(args);
|
||||
|
||||
return written;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef _SIMPLESPRINTF_H_
|
||||
#define _SIMPLESPRINTF_H_
|
||||
#include "types.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
char *prout_simple_sprintf(char *dst, const char *src, size_t count);
|
||||
s32 simple_sprintf(const char *format, ...);
|
||||
|
||||
#endif
|
||||
+203
-20
@@ -1,29 +1,212 @@
|
||||
/* The comment below is needed for this file to be picked up by generate_ld */
|
||||
/* RAM_POS: 0x800C9D40 */
|
||||
/* RAM_POS: 0x800D38A0 */
|
||||
|
||||
#include "xprintf.h"
|
||||
#include "types.h"
|
||||
#include "macros.h"
|
||||
#include "stdarg.h"
|
||||
#include "printf.h"
|
||||
#include "libultra_internal.h"
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include "xprintf.h"
|
||||
|
||||
/**
|
||||
* This gets called insdie of _PrintF, but it is just hardcoded to return true.
|
||||
*/
|
||||
char *prout_xprintf(char *dst, const char *src, size_t count) {
|
||||
return TRUE;
|
||||
const char length_str[] = "hlL";
|
||||
const char flags_str[] = " +-#0";
|
||||
const u32 flags_arr[] = { FLAGS_SPACE, FLAGS_PLUS, FLAGS_MINUS, FLAGS_HASH, FLAGS_ZERO, 0 };
|
||||
char _spaces[] = " ";
|
||||
char _zeroes[] = "00000000000000000000000000000000";
|
||||
|
||||
static void _Putfld(printf_struct *a0, va_list *args, u8 type, u8 *buff);
|
||||
s32 _Printf(outfun prout, char *dst, const char *fmt, va_list args) {
|
||||
printf_struct x;
|
||||
const u8 *fmt_ptr;
|
||||
u8 c;
|
||||
const char *flag_index;
|
||||
u8 ac[0x20]; // probably a buffer?
|
||||
x.size = 0;
|
||||
while (TRUE) {
|
||||
fmt_ptr = (u8 *) fmt;
|
||||
while ((c = *fmt_ptr++) > 0) {
|
||||
if (c == '%') {
|
||||
fmt_ptr--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
_PROUT(fmt, fmt_ptr - (u8 *) fmt);
|
||||
if (c == 0) {
|
||||
return x.size;
|
||||
}
|
||||
fmt = (char *) ++fmt_ptr;
|
||||
x.flags = 0;
|
||||
for (; (flag_index = strchr(flags_str, *fmt_ptr)) != NULL; fmt_ptr++) {
|
||||
x.flags |= flags_arr[flag_index - flags_str];
|
||||
}
|
||||
if (*fmt_ptr == '*') {
|
||||
x.width = va_arg(args, s32);
|
||||
if (x.width < 0) {
|
||||
x.width = -x.width;
|
||||
x.flags |= FLAGS_MINUS;
|
||||
}
|
||||
fmt_ptr++;
|
||||
} else {
|
||||
ATOI(x.width, fmt_ptr);
|
||||
}
|
||||
if (*fmt_ptr != '.') {
|
||||
x.precision = -1;
|
||||
} else {
|
||||
fmt_ptr++;
|
||||
if (*fmt_ptr == '*') {
|
||||
x.precision = va_arg(args, s32);
|
||||
fmt_ptr++;
|
||||
} else {
|
||||
ATOI(x.precision, fmt_ptr);
|
||||
}
|
||||
}
|
||||
if (strchr(length_str, *fmt_ptr) != NULL) {
|
||||
x.length = *fmt_ptr++;
|
||||
} else {
|
||||
x.length = 0;
|
||||
}
|
||||
|
||||
if (x.length == 'l' && *fmt_ptr == 'l') {
|
||||
x.length = 'L';
|
||||
fmt_ptr++;
|
||||
}
|
||||
_Putfld(&x, &args, *fmt_ptr, ac);
|
||||
x.width -= x.n0 + x.num_leading_zeros + x.part2_len + x.num_mid_zeros
|
||||
+ x.part3_len + x.num_trailing_zeros;
|
||||
if (!(x.flags & FLAGS_MINUS))
|
||||
_PAD(_spaces, x.width);
|
||||
_PROUT((char *) ac, x.n0);
|
||||
_PAD(_zeroes, x.num_leading_zeros);
|
||||
_PROUT(x.buff, x.part2_len);
|
||||
_PAD(_zeroes, x.num_mid_zeros);
|
||||
_PROUT((char *) (&x.buff[x.part2_len]), x.part3_len)
|
||||
_PAD(_zeroes, x.num_trailing_zeros);
|
||||
if (x.flags & FLAGS_MINUS)
|
||||
_PAD(_spaces, x.width);
|
||||
fmt = (char *) fmt_ptr + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Like sprintf, but simpler. It just hardcodes 0 for the dst,
|
||||
* and calls a function that just haardcodes a return of TRUE.
|
||||
*/
|
||||
s32 xprintf(const char *format, ...) {
|
||||
s32 written;
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
written = _Printf(prout_xprintf, 0, format, args);
|
||||
va_end(args);
|
||||
static void _Putfld(printf_struct *a0, va_list *args, u8 type, u8 *buff) {
|
||||
a0->n0 = a0->num_leading_zeros = a0->part2_len = a0->num_mid_zeros = a0->part3_len =
|
||||
a0->num_trailing_zeros = 0;
|
||||
|
||||
return written;
|
||||
switch (type) {
|
||||
|
||||
case 'c':
|
||||
buff[a0->n0++] = va_arg(*args, u32);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
case 'i':
|
||||
if (a0->length == 'l') {
|
||||
a0->value.s64 = va_arg(*args, s32);
|
||||
} else if (a0->length == 'L') {
|
||||
a0->value.s64 = va_arg(*args, s64);
|
||||
} else {
|
||||
a0->value.s64 = va_arg(*args, s32);
|
||||
}
|
||||
|
||||
if (a0->length == 'h') {
|
||||
a0->value.s64 = (s16) a0->value.s64;
|
||||
}
|
||||
|
||||
if (a0->value.s64 < 0) {
|
||||
buff[a0->n0++] = '-';
|
||||
} else if (a0->flags & FLAGS_PLUS) {
|
||||
buff[a0->n0++] = '+';
|
||||
} else if (a0->flags & FLAGS_SPACE) {
|
||||
buff[a0->n0++] = ' ';
|
||||
}
|
||||
|
||||
a0->buff = (char *) &buff[a0->n0];
|
||||
|
||||
_Litob(a0, type);
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
case 'X':
|
||||
case 'u':
|
||||
case 'o':
|
||||
if (a0->length == 'l') {
|
||||
a0->value.s64 = va_arg(*args, s32);
|
||||
} else if (a0->length == 'L') {
|
||||
a0->value.s64 = va_arg(*args, s64);
|
||||
} else {
|
||||
a0->value.s64 = va_arg(*args, s32);
|
||||
}
|
||||
|
||||
if (a0->length == 'h') {
|
||||
a0->value.s64 = (u16) a0->value.s64;
|
||||
} else if (a0->length == 0) {
|
||||
a0->value.s64 = (u32) a0->value.s64;
|
||||
}
|
||||
|
||||
if (a0->flags & FLAGS_HASH) {
|
||||
buff[a0->n0++] = '0';
|
||||
if (type == 'x' || type == 'X') {
|
||||
|
||||
buff[a0->n0++] = type;
|
||||
}
|
||||
}
|
||||
a0->buff = (char *) &buff[a0->n0];
|
||||
_Litob(a0, type);
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
case 'f':
|
||||
case 'g':
|
||||
case 'E':
|
||||
case 'G':
|
||||
//... okay?
|
||||
a0->value.f64 = a0->length == 'L' ? va_arg(*args, f64) : va_arg(*args, f64);
|
||||
|
||||
if (LDSIGN(a0->value.f64)) {
|
||||
buff[a0->n0++] = '-';
|
||||
} else {
|
||||
if (a0->flags & FLAGS_PLUS) {
|
||||
buff[a0->n0++] = '+';
|
||||
} else if (a0->flags & FLAGS_SPACE) {
|
||||
buff[a0->n0++] = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
a0->buff = (char *) &buff[a0->n0];
|
||||
_Ldtob(a0, type);
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
if (a0->length == 'h') {
|
||||
*(va_arg(*args, u16 *)) = a0->size;
|
||||
} else if (a0->length == 'l') {
|
||||
*va_arg(*args, u32 *) = a0->size;
|
||||
} else if (a0->length == 'L') {
|
||||
*va_arg(*args, u64 *) = a0->size;
|
||||
} else {
|
||||
*va_arg(*args, u32 *) = a0->size;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
a0->value.s64 = (long) va_arg(*args, void *);
|
||||
a0->buff = (char *) &buff[a0->n0];
|
||||
_Litob(a0, 'x');
|
||||
break;
|
||||
|
||||
case 's':
|
||||
a0->buff = va_arg(*args, char *);
|
||||
a0->part2_len = strlen(a0->buff);
|
||||
if (a0->precision >= 0 && a0->part2_len > a0->precision) {
|
||||
a0->part2_len = a0->precision;
|
||||
}
|
||||
break;
|
||||
|
||||
case '%':
|
||||
buff[a0->n0++] = '%';
|
||||
break;
|
||||
|
||||
default:
|
||||
buff[a0->n0++] = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+57
-4
@@ -1,9 +1,62 @@
|
||||
#ifndef _XPRINTF_H_
|
||||
#define _XPRINTF_H_
|
||||
#ifndef _PRINTF_H_
|
||||
#define _PRINTF_H_
|
||||
#include "types.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
char *prout_xprintf(char *dst, const char *src, size_t count);
|
||||
s32 xprintf(const char *format, ...);
|
||||
/**
|
||||
* This is a definition for a function that gets passed to and
|
||||
* will get called inside _PrintF
|
||||
*/
|
||||
typedef char *outfun(char *dst, const char *src, size_t count);
|
||||
typedef struct {
|
||||
union {
|
||||
/* 00 */ long long s64;
|
||||
double f64;
|
||||
} value;
|
||||
/* 08 */ char *buff;
|
||||
/* 0c */ int n0;
|
||||
/* 10 */ int num_leading_zeros;
|
||||
/* 14 */ int part2_len;
|
||||
/* 18 */ int num_mid_zeros;
|
||||
/* 1c */ int part3_len;
|
||||
/* 20 */ int num_trailing_zeros;
|
||||
/* 24 */ int precision;
|
||||
/* 28 */ int width;
|
||||
/* 2c */ unsigned int size;
|
||||
/* 30 */ unsigned int flags;
|
||||
/* 34 */ unsigned char length;
|
||||
} printf_struct;
|
||||
|
||||
#define isdigit(x) ((x >= '0' && x <= '9'))
|
||||
#define LDSIGN(x) (((unsigned short *)&(x))[0] & 0x8000)
|
||||
#define ATOI(dst, src) \
|
||||
for (dst = 0; isdigit(*src); ++src) { \
|
||||
if (dst < 999) \
|
||||
dst = dst * 10 + *src - '0'; \
|
||||
}
|
||||
#define _PROUT(fmt, _size) \
|
||||
if (_size > 0) { \
|
||||
dst = (*prout)(dst, fmt, _size); \
|
||||
if (dst != 0) \
|
||||
x.size += _size; \
|
||||
else \
|
||||
return x.size; \
|
||||
}
|
||||
#define MAX_PAD ((sizeof(_spaces) - 1))
|
||||
#define _PAD(s, n) \
|
||||
if (0 < (n)) { \
|
||||
int i, j = (n); \
|
||||
for (; 0 < j; j -= i) { \
|
||||
i = MAX_PAD < (unsigned int)j ? (int)MAX_PAD : j; \
|
||||
_PROUT(s, i); \
|
||||
} \
|
||||
}
|
||||
#define FLAGS_SPACE 1
|
||||
#define FLAGS_PLUS 2
|
||||
#define FLAGS_MINUS 4
|
||||
#define FLAGS_HASH 8
|
||||
#define FLAGS_ZERO 16
|
||||
s32 _Printf(outfun prout, char *dst, const char *fmt, va_list args);
|
||||
void _Litob(printf_struct *args, u8 type);
|
||||
void _Ldtob(printf_struct *args, u8 type);
|
||||
#endif
|
||||
|
||||
@@ -1,212 +0,0 @@
|
||||
/* The comment below is needed for this file to be picked up by generate_ld */
|
||||
/* RAM_POS: 0x800D38A0 */
|
||||
|
||||
#include "types.h"
|
||||
#include "macros.h"
|
||||
#include "libultra_internal.h"
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include "printf.h"
|
||||
|
||||
const char length_str[] = "hlL";
|
||||
const char flags_str[] = " +-#0";
|
||||
const u32 flags_arr[] = { FLAGS_SPACE, FLAGS_PLUS, FLAGS_MINUS, FLAGS_HASH, FLAGS_ZERO, 0 };
|
||||
char _spaces[] = " ";
|
||||
char _zeroes[] = "00000000000000000000000000000000";
|
||||
|
||||
static void _Putfld(printf_struct *a0, va_list *args, u8 type, u8 *buff);
|
||||
s32 _Printf(outfun prout, char *dst, const char *fmt, va_list args) {
|
||||
printf_struct x;
|
||||
const u8 *fmt_ptr;
|
||||
u8 c;
|
||||
const char *flag_index;
|
||||
u8 ac[0x20]; // probably a buffer?
|
||||
x.size = 0;
|
||||
while (TRUE) {
|
||||
fmt_ptr = (u8 *) fmt;
|
||||
while ((c = *fmt_ptr++) > 0) {
|
||||
if (c == '%') {
|
||||
fmt_ptr--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
_PROUT(fmt, fmt_ptr - (u8 *) fmt);
|
||||
if (c == 0) {
|
||||
return x.size;
|
||||
}
|
||||
fmt = (char *) ++fmt_ptr;
|
||||
x.flags = 0;
|
||||
for (; (flag_index = strchr(flags_str, *fmt_ptr)) != NULL; fmt_ptr++) {
|
||||
x.flags |= flags_arr[flag_index - flags_str];
|
||||
}
|
||||
if (*fmt_ptr == '*') {
|
||||
x.width = va_arg(args, s32);
|
||||
if (x.width < 0) {
|
||||
x.width = -x.width;
|
||||
x.flags |= FLAGS_MINUS;
|
||||
}
|
||||
fmt_ptr++;
|
||||
} else {
|
||||
ATOI(x.width, fmt_ptr);
|
||||
}
|
||||
if (*fmt_ptr != '.') {
|
||||
x.precision = -1;
|
||||
} else {
|
||||
fmt_ptr++;
|
||||
if (*fmt_ptr == '*') {
|
||||
x.precision = va_arg(args, s32);
|
||||
fmt_ptr++;
|
||||
} else {
|
||||
ATOI(x.precision, fmt_ptr);
|
||||
}
|
||||
}
|
||||
if (strchr(length_str, *fmt_ptr) != NULL) {
|
||||
x.length = *fmt_ptr++;
|
||||
} else {
|
||||
x.length = 0;
|
||||
}
|
||||
|
||||
if (x.length == 'l' && *fmt_ptr == 'l') {
|
||||
x.length = 'L';
|
||||
fmt_ptr++;
|
||||
}
|
||||
_Putfld(&x, &args, *fmt_ptr, ac);
|
||||
x.width -= x.n0 + x.num_leading_zeros + x.part2_len + x.num_mid_zeros
|
||||
+ x.part3_len + x.num_trailing_zeros;
|
||||
if (!(x.flags & FLAGS_MINUS))
|
||||
_PAD(_spaces, x.width);
|
||||
_PROUT((char *) ac, x.n0);
|
||||
_PAD(_zeroes, x.num_leading_zeros);
|
||||
_PROUT(x.buff, x.part2_len);
|
||||
_PAD(_zeroes, x.num_mid_zeros);
|
||||
_PROUT((char *) (&x.buff[x.part2_len]), x.part3_len)
|
||||
_PAD(_zeroes, x.num_trailing_zeros);
|
||||
if (x.flags & FLAGS_MINUS)
|
||||
_PAD(_spaces, x.width);
|
||||
fmt = (char *) fmt_ptr + 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void _Putfld(printf_struct *a0, va_list *args, u8 type, u8 *buff) {
|
||||
a0->n0 = a0->num_leading_zeros = a0->part2_len = a0->num_mid_zeros = a0->part3_len =
|
||||
a0->num_trailing_zeros = 0;
|
||||
|
||||
switch (type) {
|
||||
|
||||
case 'c':
|
||||
buff[a0->n0++] = va_arg(*args, u32);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
case 'i':
|
||||
if (a0->length == 'l') {
|
||||
a0->value.s64 = va_arg(*args, s32);
|
||||
} else if (a0->length == 'L') {
|
||||
a0->value.s64 = va_arg(*args, s64);
|
||||
} else {
|
||||
a0->value.s64 = va_arg(*args, s32);
|
||||
}
|
||||
|
||||
if (a0->length == 'h') {
|
||||
a0->value.s64 = (s16) a0->value.s64;
|
||||
}
|
||||
|
||||
if (a0->value.s64 < 0) {
|
||||
buff[a0->n0++] = '-';
|
||||
} else if (a0->flags & FLAGS_PLUS) {
|
||||
buff[a0->n0++] = '+';
|
||||
} else if (a0->flags & FLAGS_SPACE) {
|
||||
buff[a0->n0++] = ' ';
|
||||
}
|
||||
|
||||
a0->buff = (char *) &buff[a0->n0];
|
||||
|
||||
_Litob(a0, type);
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
case 'X':
|
||||
case 'u':
|
||||
case 'o':
|
||||
if (a0->length == 'l') {
|
||||
a0->value.s64 = va_arg(*args, s32);
|
||||
} else if (a0->length == 'L') {
|
||||
a0->value.s64 = va_arg(*args, s64);
|
||||
} else {
|
||||
a0->value.s64 = va_arg(*args, s32);
|
||||
}
|
||||
|
||||
if (a0->length == 'h') {
|
||||
a0->value.s64 = (u16) a0->value.s64;
|
||||
} else if (a0->length == 0) {
|
||||
a0->value.s64 = (u32) a0->value.s64;
|
||||
}
|
||||
|
||||
if (a0->flags & FLAGS_HASH) {
|
||||
buff[a0->n0++] = '0';
|
||||
if (type == 'x' || type == 'X') {
|
||||
|
||||
buff[a0->n0++] = type;
|
||||
}
|
||||
}
|
||||
a0->buff = (char *) &buff[a0->n0];
|
||||
_Litob(a0, type);
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
case 'f':
|
||||
case 'g':
|
||||
case 'E':
|
||||
case 'G':
|
||||
//... okay?
|
||||
a0->value.f64 = a0->length == 'L' ? va_arg(*args, f64) : va_arg(*args, f64);
|
||||
|
||||
if (LDSIGN(a0->value.f64)) {
|
||||
buff[a0->n0++] = '-';
|
||||
} else {
|
||||
if (a0->flags & FLAGS_PLUS) {
|
||||
buff[a0->n0++] = '+';
|
||||
} else if (a0->flags & FLAGS_SPACE) {
|
||||
buff[a0->n0++] = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
a0->buff = (char *) &buff[a0->n0];
|
||||
_Ldtob(a0, type);
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
if (a0->length == 'h') {
|
||||
*(va_arg(*args, u16 *)) = a0->size;
|
||||
} else if (a0->length == 'l') {
|
||||
*va_arg(*args, u32 *) = a0->size;
|
||||
} else if (a0->length == 'L') {
|
||||
*va_arg(*args, u64 *) = a0->size;
|
||||
} else {
|
||||
*va_arg(*args, u32 *) = a0->size;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
a0->value.s64 = (long) va_arg(*args, void *);
|
||||
a0->buff = (char *) &buff[a0->n0];
|
||||
_Litob(a0, 'x');
|
||||
break;
|
||||
|
||||
case 's':
|
||||
a0->buff = va_arg(*args, char *);
|
||||
a0->part2_len = strlen(a0->buff);
|
||||
if (a0->precision >= 0 && a0->part2_len > a0->precision) {
|
||||
a0->part2_len = a0->precision;
|
||||
}
|
||||
break;
|
||||
|
||||
case '%':
|
||||
buff[a0->n0++] = '%';
|
||||
break;
|
||||
|
||||
default:
|
||||
buff[a0->n0++] = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
#ifndef _PRINTF_H_
|
||||
#define _PRINTF_H_
|
||||
#include "types.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
/**
|
||||
* This is a definition for a function that gets passed to and
|
||||
* will get called inside _PrintF
|
||||
*/
|
||||
typedef char *outfun(char *dst, const char *src, size_t count);
|
||||
typedef struct {
|
||||
union {
|
||||
/* 00 */ long long s64;
|
||||
double f64;
|
||||
} value;
|
||||
/* 08 */ char *buff;
|
||||
/* 0c */ int n0;
|
||||
/* 10 */ int num_leading_zeros;
|
||||
/* 14 */ int part2_len;
|
||||
/* 18 */ int num_mid_zeros;
|
||||
/* 1c */ int part3_len;
|
||||
/* 20 */ int num_trailing_zeros;
|
||||
/* 24 */ int precision;
|
||||
/* 28 */ int width;
|
||||
/* 2c */ unsigned int size;
|
||||
/* 30 */ unsigned int flags;
|
||||
/* 34 */ unsigned char length;
|
||||
} printf_struct;
|
||||
|
||||
#define isdigit(x) ((x >= '0' && x <= '9'))
|
||||
#define LDSIGN(x) (((unsigned short *)&(x))[0] & 0x8000)
|
||||
#define ATOI(dst, src) \
|
||||
for (dst = 0; isdigit(*src); ++src) { \
|
||||
if (dst < 999) \
|
||||
dst = dst * 10 + *src - '0'; \
|
||||
}
|
||||
#define _PROUT(fmt, _size) \
|
||||
if (_size > 0) { \
|
||||
dst = (*prout)(dst, fmt, _size); \
|
||||
if (dst != 0) \
|
||||
x.size += _size; \
|
||||
else \
|
||||
return x.size; \
|
||||
}
|
||||
#define MAX_PAD ((sizeof(_spaces) - 1))
|
||||
#define _PAD(s, n) \
|
||||
if (0 < (n)) { \
|
||||
int i, j = (n); \
|
||||
for (; 0 < j; j -= i) { \
|
||||
i = MAX_PAD < (unsigned int)j ? (int)MAX_PAD : j; \
|
||||
_PROUT(s, i); \
|
||||
} \
|
||||
}
|
||||
#define FLAGS_SPACE 1
|
||||
#define FLAGS_PLUS 2
|
||||
#define FLAGS_MINUS 4
|
||||
#define FLAGS_HASH 8
|
||||
#define FLAGS_ZERO 16
|
||||
s32 _Printf(outfun prout, char *dst, const char *fmt, va_list args);
|
||||
void _Litob(printf_struct *args, u8 type);
|
||||
void _Ldtob(printf_struct *args, u8 type);
|
||||
#endif
|
||||
+8
-8
@@ -7,7 +7,7 @@
|
||||
#include "unknown_06B2B0.h"
|
||||
#include "unknown_0255E0.h"
|
||||
#include "video.h"
|
||||
#include "lib/src/libc/xprintf.h"
|
||||
#include "lib/src/libc/simplesprintf.h"
|
||||
|
||||
extern u32 osTvType;
|
||||
|
||||
@@ -879,13 +879,13 @@ void func_80069F64(s16 *mtx) {
|
||||
for(i = 0; i < 4; i++) {
|
||||
for(j = 0; j < 4; j++) {
|
||||
val = mtx[i * 4 + j];
|
||||
xprintf("%x.", val);
|
||||
simple_sprintf("%x.", val);
|
||||
val = mtx[((i + 4) * 4 + j)]; // Issue here.
|
||||
xprintf("%x ", (u16)val);
|
||||
simple_sprintf("%x ", (u16)val);
|
||||
}
|
||||
xprintf("\n");
|
||||
simple_sprintf("\n");
|
||||
}
|
||||
xprintf("\n");
|
||||
simple_sprintf("\n");
|
||||
}
|
||||
#else
|
||||
GLOBAL_ASM("asm/non_matchings/camera/func_80069F64.s")
|
||||
@@ -897,11 +897,11 @@ void func_8006A03C(f32 *mtx) {
|
||||
|
||||
for(i = 0; i < 4; i++) {
|
||||
for(j = 0; j < 4; j++) {
|
||||
xprintf("%f ", mtx[i * 4 + j]);
|
||||
simple_sprintf("%f ", mtx[i * 4 + j]);
|
||||
}
|
||||
xprintf("\n");
|
||||
simple_sprintf("\n");
|
||||
}
|
||||
xprintf("\n");
|
||||
simple_sprintf("\n");
|
||||
}
|
||||
|
||||
OSMesgQueue *func_8006A100(void) {
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
#include "main.h"
|
||||
#include "thread0_epc.h"
|
||||
#include "unknown_06B2B0.h"
|
||||
#include "lib/src/libc/xprintf.h"
|
||||
#include "lib/src/libc/simplesprintf.h"
|
||||
|
||||
/************ .rodata ************/
|
||||
|
||||
@@ -65,7 +65,7 @@ void func_80065E30(void) {
|
||||
D_8011D758[1] = temp3;
|
||||
D_8011D758[0] = temp4;
|
||||
if ((temp2 != temp4) || (temp != temp3)) {
|
||||
xprintf("WARNING: Stack overflow/underflow!!!\n");
|
||||
simple_sprintf("WARNING: Stack overflow/underflow!!!\n");
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
/* RAM_POS: 0x8007F640 */
|
||||
|
||||
#include "screen_asset.h"
|
||||
#include "lib/src/libc/xprintf.h"
|
||||
#include "lib/src/libc/simplesprintf.h"
|
||||
|
||||
// Render settings for the screens
|
||||
Gfx gRdpSetModeScreenAsset[] = {
|
||||
@@ -36,7 +36,7 @@ u8 *load_screen(s32 screenIndex) {
|
||||
return 0x80100000;
|
||||
} else {
|
||||
if (screenIndex < 0 || screenIndex >= screenTableCount) {
|
||||
xprintf("SCREEN: No out of range!!\n");
|
||||
simple_sprintf("SCREEN: No out of range!!\n");
|
||||
screenIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ BUILD_DIR = 'build/' + VERSION
|
||||
|
||||
LATE_DATA_FILES = [
|
||||
BUILD_DIR + '/lib/src/al/alCopy.o',
|
||||
BUILD_DIR + '/lib/src/printf.o',
|
||||
BUILD_DIR + '/lib/src/libc/xprintf.o',
|
||||
BUILD_DIR + '/lib/src/os/osTimer.o',
|
||||
BUILD_DIR + '/lib/src/unknown_0D3020.o'
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user