From 110ca9d43ede5d3c2fbbda8da0734e880fd7b0da Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Mon, 20 Sep 2021 21:43:37 -0400 Subject: [PATCH] Renamed unknown_0CA940 to xprintf. I was going to use sprintf, but it was taken, and this one seems to attempt to hardcode in certain values to be simpler. --- asm/non_matchings/camera/func_80069F64.s | 8 ++++---- asm/non_matchings/main/func_80065E30.s | 2 +- asm/non_matchings/unknown_0255E0/func_8002C0C4.s | 2 +- asm/non_matchings/unknown_032760/func_8003B368.s | 2 +- asm/non_matchings/unknown_032760/func_8003B7CC.s | 2 +- asm/non_matchings/unknown_032760/func_8003C644.s | 2 +- lib/src/{unknown_0CA940.c => xprintf.c} | 11 ++++++++--- lib/src/xprintf.h | 9 +++++++++ src/camera.c | 15 ++++++++------- src/main.c | 3 ++- src/screen_asset.c | 3 ++- 11 files changed, 38 insertions(+), 21 deletions(-) rename lib/src/{unknown_0CA940.c => xprintf.c} (51%) create mode 100644 lib/src/xprintf.h diff --git a/asm/non_matchings/camera/func_80069F64.s b/asm/non_matchings/camera/func_80069F64.s index c4b83ee9..7ba6e2c2 100644 --- a/asm/non_matchings/camera/func_80069F64.s +++ b/asm/non_matchings/camera/func_80069F64.s @@ -40,24 +40,24 @@ glabel func_80069F64 /* 06ABB8 80069FB8 02E08025 */ move $s0, $s7 .L80069FBC: /* 06ABBC 80069FBC 86050000 */ lh $a1, ($s0) -/* 06ABC0 80069FC0 0C032755 */ jal func_800C9D54 +/* 06ABC0 80069FC0 0C032755 */ jal xprintf /* 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 func_800C9D54 +/* 06ABD4 80069FD4 0C032755 */ jal xprintf /* 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 func_800C9D54 +/* 06ABE8 80069FE8 0C032755 */ jal xprintf /* 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 func_800C9D54 +/* 06AC04 8006A004 0C032755 */ jal xprintf /* 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) diff --git a/asm/non_matchings/main/func_80065E30.s b/asm/non_matchings/main/func_80065E30.s index b9202406..ed7bc349 100644 --- a/asm/non_matchings/main/func_80065E30.s +++ b/asm/non_matchings/main/func_80065E30.s @@ -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 func_800C9D54 +/* 066A84 80065E84 0C032755 */ jal xprintf /* 066A88 80065E88 24846ED0 */ addiu $a0, %lo(D_800E6ED0) # addiu $a0, $a0, 0x6ed0 .L80065E8C: /* 066A8C 80065E8C 8FBF0014 */ lw $ra, 0x14($sp) diff --git a/asm/non_matchings/unknown_0255E0/func_8002C0C4.s b/asm/non_matchings/unknown_0255E0/func_8002C0C4.s index ee713ce8..3b261eea 100644 --- a/asm/non_matchings/unknown_0255E0/func_8002C0C4.s +++ b/asm/non_matchings/unknown_0255E0/func_8002C0C4.s @@ -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 func_800C9D54 +/* 02D108 8002C508 0C032755 */ jal xprintf /* 02D10C 8002C50C 02602825 */ move $a1, $s3 .L8002C510: /* 02D110 8002C510 0C01C42C */ jal set_free_queue_state diff --git a/asm/non_matchings/unknown_032760/func_8003B368.s b/asm/non_matchings/unknown_032760/func_8003B368.s index 0c54edd2..3af8d7d6 100644 --- a/asm/non_matchings/unknown_032760/func_8003B368.s +++ b/asm/non_matchings/unknown_032760/func_8003B368.s @@ -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 func_800C9D54 +/* 03BFC8 8003B3C8 0C032755 */ jal xprintf /* 03BFCC 8003B3CC AFA60024 */ sw $a2, 0x24($sp) /* 03BFD0 8003B3D0 8FA60024 */ lw $a2, 0x24($sp) /* 03BFD4 8003B3D4 00000000 */ nop diff --git a/asm/non_matchings/unknown_032760/func_8003B7CC.s b/asm/non_matchings/unknown_032760/func_8003B7CC.s index d71d3ac2..d9ff707c 100644 --- a/asm/non_matchings/unknown_032760/func_8003B7CC.s +++ b/asm/non_matchings/unknown_032760/func_8003B7CC.s @@ -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 func_800C9D54 +/* 03C46C 8003B86C 0C032755 */ jal xprintf /* 03C470 8003B870 AFA6002C */ sw $a2, 0x2c($sp) /* 03C474 8003B874 8FA30024 */ lw $v1, 0x24($sp) /* 03C478 8003B878 8FA6002C */ lw $a2, 0x2c($sp) diff --git a/asm/non_matchings/unknown_032760/func_8003C644.s b/asm/non_matchings/unknown_032760/func_8003C644.s index ddda579e..b5af0eba 100644 --- a/asm/non_matchings/unknown_032760/func_8003C644.s +++ b/asm/non_matchings/unknown_032760/func_8003C644.s @@ -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 func_800C9D54 +/* 03D294 8003C694 0C032755 */ jal xprintf /* 03D298 8003C698 24845FC8 */ addiu $a0, %lo(D_800E5FC8) # addiu $a0, $a0, 0x5fc8 .L8003C69C: /* 03D29C 8003C69C 92380008 */ lbu $t8, 8($s1) diff --git a/lib/src/unknown_0CA940.c b/lib/src/xprintf.c similarity index 51% rename from lib/src/unknown_0CA940.c rename to lib/src/xprintf.c index 7c383074..fdae75a4 100644 --- a/lib/src/unknown_0CA940.c +++ b/lib/src/xprintf.c @@ -1,17 +1,22 @@ /* The comment below is needed for this file to be picked up by generate_ld */ /* RAM_POS: 0x800C9D40 */ +#include "xprintf.h" #include "types.h" #include "macros.h" #include "stdarg.h" +#include "printf.h" -s32 get_true(s32 arg0, s32 arg1, s32 arg2) { +char *prout_xprintf(char *dst, const char *src, size_t count) { return TRUE; } -void func_800C9D54(const char *format, ...) { +s32 xprintf(const char *format, ...) { + s32 written; va_list args; va_start(args, format); - _Printf(get_true, 0, format, args); + written = _Printf(prout_xprintf, 0, format, args); va_end(args); + + return written; } diff --git a/lib/src/xprintf.h b/lib/src/xprintf.h new file mode 100644 index 00000000..6532ce79 --- /dev/null +++ b/lib/src/xprintf.h @@ -0,0 +1,9 @@ +#ifndef _XPRINTF_H_ +#define _XPRINTF_H_ +#include "types.h" +#include + +char *prout_xprintf(char *dst, const char *src, size_t count); +s32 xprintf(const char *format, ...); + +#endif diff --git a/src/camera.c b/src/camera.c index 82c14507..b1645bbe 100644 --- a/src/camera.c +++ b/src/camera.c @@ -7,6 +7,7 @@ #include "unknown_06B2B0.h" #include "unknown_0255E0.h" #include "video.h" +#include "lib/src/xprintf.h" extern u32 osTvType; @@ -878,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]; - func_800C9D54("%x.", val); + xprintf("%x.", val); val = mtx[((i + 4) * 4 + j)]; // Issue here. - func_800C9D54("%x ", (u16)val); + xprintf("%x ", (u16)val); } - func_800C9D54("\n"); + xprintf("\n"); } - func_800C9D54("\n"); + xprintf("\n"); } #else GLOBAL_ASM("asm/non_matchings/camera/func_80069F64.s") @@ -896,11 +897,11 @@ void func_8006A03C(f32 *mtx) { for(i = 0; i < 4; i++) { for(j = 0; j < 4; j++) { - func_800C9D54("%f ", mtx[i * 4 + j]); + xprintf("%f ", mtx[i * 4 + j]); } - func_800C9D54("\n"); + xprintf("\n"); } - func_800C9D54("\n"); + xprintf("\n"); } OSMesgQueue *func_8006A100(void) { diff --git a/src/main.c b/src/main.c index 6d4ce606..4395a5ef 100644 --- a/src/main.c +++ b/src/main.c @@ -4,6 +4,7 @@ #include "main.h" #include "thread0_epc.h" #include "unknown_06B2B0.h" +#include "lib/src/xprintf.h" /************ .rodata ************/ @@ -64,7 +65,7 @@ void func_80065E30(void) { D_8011D758[1] = temp3; D_8011D758[0] = temp4; if ((temp2 != temp4) || (temp != temp3)) { - func_800C9D54("WARNING: Stack overflow/underflow!!!\n"); + xprintf("WARNING: Stack overflow/underflow!!!\n"); } } #else diff --git a/src/screen_asset.c b/src/screen_asset.c index aee03656..5e245ba4 100644 --- a/src/screen_asset.c +++ b/src/screen_asset.c @@ -2,6 +2,7 @@ /* RAM_POS: 0x8007F640 */ #include "screen_asset.h" +#include "lib/src/xprintf.h" // Render settings for the screens Gfx gRdpSetModeScreenAsset[] = { @@ -35,7 +36,7 @@ u8 *load_screen(s32 screenIndex) { return 0x80100000; } else { if (screenIndex < 0 || screenIndex >= screenTableCount) { - func_800C9D54("SCREEN: No out of range!!\n"); + xprintf("SCREEN: No out of range!!\n"); screenIndex = 0; }