feat: add drawText
This commit is contained in:
parent
ce36acba05
commit
2984c79a76
10 changed files with 558 additions and 1 deletions
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2022-2024 sup39
|
||||
Copyright (c) 2021-2024 sup39
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
|
|
140
drawText/@code.xml
Normal file
140
drawText/@code.xml
Normal file
|
@ -0,0 +1,140 @@
|
|||
<code>
|
||||
<id>drawText</id>
|
||||
<category>lib</category>
|
||||
<title lang="en-US">drawText</title>
|
||||
<author>sup39(サポミク)</author>
|
||||
<version>0.3</version>
|
||||
<date>Jan 02, 2023</date>
|
||||
<description lang="en-US">
|
||||
```c
|
||||
typedef struct {
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
uint32_t fontSize;
|
||||
uint32_t colorTop;
|
||||
uint32_t colorBot;
|
||||
} DrawTextOpt;
|
||||
void drawText(DrawTextOpt *opt, const char *fmt, ...);
|
||||
```
|
||||
</description>
|
||||
<source version="GMSJ01">
|
||||
077F0238 000000D4
|
||||
9421FF08 7C0802A6
|
||||
BFC100F0 7C7F1B78
|
||||
900100FC 7C9E2378
|
||||
90A10088 90C1008C
|
||||
90E10090 91010094
|
||||
91210098 9141009C
|
||||
D82100A0 D84100A8
|
||||
D86100B0 D88100B8
|
||||
D8A100C0 D8C100C8
|
||||
D8E100D0 D90100D8
|
||||
39200200 80DF0004
|
||||
B1210070 39200000
|
||||
39210100 91210074
|
||||
39210080 91210078
|
||||
808D97F8 391F000C
|
||||
38FF0008 38A00000
|
||||
38610008 4A826AF9
|
||||
813F0004 38610008
|
||||
91210064 91210060
|
||||
A95F0000 388000FF
|
||||
91410024 7FC5F378
|
||||
E01F5000 38C10070
|
||||
F001002C 38000000
|
||||
90010034 4A826985
|
||||
BBC100F0 382100F8
|
||||
80010004 7C0803A6
|
||||
4E800020 00000000
|
||||
</source>
|
||||
<source version="GMSE01">
|
||||
077F0238 000000D4
|
||||
9421FF08 7C0802A6
|
||||
BFC100F0 7C7F1B78
|
||||
900100FC 7C9E2378
|
||||
90A10088 90C1008C
|
||||
90E10090 91010094
|
||||
91210098 9141009C
|
||||
D82100A0 D84100A8
|
||||
D86100B0 D88100B8
|
||||
D8A100C0 D8C100C8
|
||||
D8E100D0 D90100D8
|
||||
39200200 80DF0004
|
||||
B1210070 39200000
|
||||
39210100 91210074
|
||||
39210080 91210078
|
||||
808D9FC8 391F000C
|
||||
38FF0008 38A00000
|
||||
38610008 4AADDA3D
|
||||
813F0004 38610008
|
||||
91210064 91210060
|
||||
A95F0000 388000FF
|
||||
91410024 7FC5F378
|
||||
E01F5000 38C10070
|
||||
F001002C 38000000
|
||||
90010034 4AADD8C9
|
||||
BBC100F0 382100F8
|
||||
80010004 7C0803A6
|
||||
4E800020 00000000
|
||||
</source>
|
||||
<source version="GMSP01">
|
||||
077F0238 000000D4
|
||||
9421FF08 7C0802A6
|
||||
BFC100F0 7C7F1B78
|
||||
900100FC 7C9E2378
|
||||
90A10088 90C1008C
|
||||
90E10090 91010094
|
||||
91210098 9141009C
|
||||
D82100A0 D84100A8
|
||||
D86100B0 D88100B8
|
||||
D8A100C0 D8C100C8
|
||||
D8E100D0 D90100D8
|
||||
39200200 80DF0004
|
||||
B1210070 39200000
|
||||
39210100 91210074
|
||||
39210080 91210078
|
||||
808D9EF0 391F000C
|
||||
38FF0008 38A00000
|
||||
38610008 4AAD5AD1
|
||||
813F0004 38610008
|
||||
91210064 91210060
|
||||
A95F0000 388000FF
|
||||
91410024 7FC5F378
|
||||
E01F5000 38C10070
|
||||
F001002C 38000000
|
||||
90010034 4AAD595D
|
||||
BBC100F0 382100F8
|
||||
80010004 7C0803A6
|
||||
4E800020 00000000
|
||||
</source>
|
||||
<source version="GMSJ0A">
|
||||
077F0238 000000D4
|
||||
9421FF08 7C0802A6
|
||||
BFC100F0 7C7F1B78
|
||||
900100FC 7C9E2378
|
||||
90A10088 90C1008C
|
||||
90E10090 91010094
|
||||
91210098 9141009C
|
||||
D82100A0 D84100A8
|
||||
D86100B0 D88100B8
|
||||
D8A100C0 D8C100C8
|
||||
D8E100D0 D90100D8
|
||||
39200200 80DF0004
|
||||
B1210070 39200000
|
||||
39210100 91210074
|
||||
39210080 91210078
|
||||
808D9E88 391F000C
|
||||
38FF0008 38A00000
|
||||
38610008 4AABD24D
|
||||
813F0004 38610008
|
||||
91210064 91210060
|
||||
A95F0000 388000FF
|
||||
91410024 7FC5F378
|
||||
E01F5000 38C10070
|
||||
F001002C 38000000
|
||||
90010034 4AABD0D9
|
||||
BBC100F0 382100F8
|
||||
80010004 7C0803A6
|
||||
4E800020 00000000
|
||||
</source>
|
||||
</code>
|
20
drawText/info.xml
Normal file
20
drawText/info.xml
Normal file
|
@ -0,0 +1,20 @@
|
|||
<code>
|
||||
<id>drawText</id>
|
||||
<category>lib</category>
|
||||
<title lang="en-US">drawText</title>
|
||||
<author>sup39(サポミク)</author>
|
||||
<version>0.3</version>
|
||||
<date>Jan 02, 2023</date>
|
||||
<description lang="en-US">
|
||||
```c
|
||||
typedef struct {
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
uint32_t fontSize;
|
||||
uint32_t colorTop;
|
||||
uint32_t colorBot;
|
||||
} DrawTextOpt;
|
||||
void drawText(DrawTextOpt *opt, const char *fmt, ...);
|
||||
```
|
||||
</description>
|
||||
</code>
|
11
drawText/make.py
Normal file
11
drawText/make.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from supSMSGecko import make_xml, symbols, Button as B
|
||||
|
||||
'''
|
||||
Note: drawText.s is modified from compiled drawText.c file
|
||||
'''
|
||||
|
||||
def main(g, ver):
|
||||
S = symbols[ver]
|
||||
g.c_kit(addr_code=0x817f0238, input_path='src/drawText.s', entries=[])
|
||||
|
||||
make_xml(main)
|
58
drawText/src/drawText.c
Normal file
58
drawText/src/drawText.c
Normal file
|
@ -0,0 +1,58 @@
|
|||
#include "drawText.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
/* built-in functions */
|
||||
extern struct {} *gpSystemFont;
|
||||
typedef float Mtx[3][4];
|
||||
typedef struct {
|
||||
void* __vt__;
|
||||
char unk[0x1c-4];
|
||||
int xInt;
|
||||
int yInt;
|
||||
float xFloat;
|
||||
float yFloat;
|
||||
float zFloat;
|
||||
char unk1[12];
|
||||
uint32_t bgMask;
|
||||
uint32_t fgMask;
|
||||
uint32_t colorTop;
|
||||
uint32_t colorBot;
|
||||
int x4c;
|
||||
int lineHeight;
|
||||
int x54;
|
||||
int fontWidth;
|
||||
int fontHeight;
|
||||
char unk3[8];
|
||||
} J2DPrint;
|
||||
|
||||
void J2DPrint_print_1(void *this, void *font, int x4c, int lineHeight, uint32_t *colorTop, uint32_t *colorBot);
|
||||
// color.alpha = printer->color.alpha * alphaMask/0xff
|
||||
void J2DPrint_print_alpha_va(void *printer, uint8_t alphaMask, const char *fmt, va_list args);
|
||||
/**********************/
|
||||
|
||||
|
||||
void drawText(DrawTextOpt *opt, const char *fmt, ...) {
|
||||
Mtx mtx;
|
||||
J2DPrint printer;
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
||||
// new J2DPrinter
|
||||
J2DPrint_new_1(&printer, gpSystemFont, 0, opt->fontSize, &opt->colorTop, &opt->colorBot);
|
||||
printer.fontWidth = printer.fontHeight = opt->fontSize;
|
||||
|
||||
// set coordinate
|
||||
printer.xInt = opt->x;
|
||||
// printer.yInt = opt->y; // (actually unused)
|
||||
printer.xFloat = opt->x;
|
||||
printer.yFloat = opt->y;
|
||||
printer.zFloat = 0;
|
||||
|
||||
// print text
|
||||
J2DPrint_print_alpha_va(&printer, 0xff, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
// no need to delete if not allocating memory from heap
|
||||
// delete_J2DPrint(&printer, -1);
|
||||
}
|
14
drawText/src/drawText.h
Normal file
14
drawText/src/drawText.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#ifndef DRAW_H
|
||||
#define DRAW_H
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct {
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
uint32_t fontSize;
|
||||
uint32_t colorTop;
|
||||
uint32_t colorBot;
|
||||
} DrawTextOpt;
|
||||
void drawText(DrawTextOpt *opt, const char *fmt, ...);
|
||||
|
||||
#endif
|
71
drawText/src/drawText.s
Normal file
71
drawText/src/drawText.s
Normal file
|
@ -0,0 +1,71 @@
|
|||
.globl drawText
|
||||
.type drawText, @function
|
||||
drawText:
|
||||
.LFB0:
|
||||
stwu 1,-248(1)
|
||||
mflr 0
|
||||
stmw 30,240(1)
|
||||
mr 31,3 # r31 = opt
|
||||
stw 0,252(1)
|
||||
mr 30,4 # r30 = fmt
|
||||
stw 5,136(1)
|
||||
stw 6,140(1)
|
||||
stw 7,144(1)
|
||||
stw 8,148(1)
|
||||
stw 9,152(1)
|
||||
stw 10,156(1)
|
||||
#bne- 1,.L3
|
||||
stfd 1,160(1)
|
||||
stfd 2,168(1)
|
||||
stfd 3,176(1)
|
||||
stfd 4,184(1)
|
||||
stfd 5,192(1)
|
||||
stfd 6,200(1)
|
||||
stfd 7,208(1)
|
||||
stfd 8,216(1)
|
||||
.L3:
|
||||
li 9,0x200
|
||||
lwz 6,4(31) # opt->fontSize
|
||||
sth 9,112(1)
|
||||
li 9,0
|
||||
addi 9,1,256
|
||||
stw 9,116(1)
|
||||
addi 9,1,128
|
||||
stw 9,120(1)
|
||||
lwz 4,gpSystemFont$r13(13)
|
||||
addi 8,31,12 # opt->colorBot
|
||||
addi 7,31,8 # opt->colorTop
|
||||
li 5,0
|
||||
addi 3,1,8 # &printer
|
||||
bl J2DPrint_new_1
|
||||
################################
|
||||
lwz 9,4(31) # fontSize
|
||||
addi 3,1,8 # &printer
|
||||
stw 9,100(1) # printer.fontHeight =
|
||||
stw 9,96(1) # printer.fontWidth =
|
||||
|
||||
lha 10,0(31) # x
|
||||
li 4,255 # 0xff
|
||||
stw 10,36(1) # printer.xInt =
|
||||
|
||||
# lha 9,2(31) # y
|
||||
mr 5,30 # fmt
|
||||
# stw 9,40(1) # printer.yInt =
|
||||
|
||||
### xFloat, yFloat
|
||||
### GQR5 = 0x70007 (s16)
|
||||
psq_l f0, 0(r31), 0, gqr5
|
||||
addi 6,1,112 # ...
|
||||
psq_st f0, 44(r1), 0, gqr0
|
||||
|
||||
### zFloat
|
||||
li r0, 0
|
||||
stw r0, 52(r1)
|
||||
|
||||
bl J2DPrint_print_alpha_va
|
||||
################################
|
||||
lmw 30,240(1)
|
||||
addi 1,1,248
|
||||
lwz 0, 4(1)
|
||||
mtlr 0
|
||||
blr
|
154
drawText/test/@code.xml
Normal file
154
drawText/test/@code.xml
Normal file
|
@ -0,0 +1,154 @@
|
|||
<code>
|
||||
<source version="GMSJ01">
|
||||
C22069D0 00000023
|
||||
818D97E8 818C005C
|
||||
1D8C03E9 38000078
|
||||
7D8C0396 380003E8
|
||||
7D6C0396 1D4B03E8
|
||||
7CEA6050 3800003C
|
||||
7CAB0396 1D45003C
|
||||
7CCA5850 48000011
|
||||
00100147 0000001E
|
||||
F43464FF F6F6F6FF
|
||||
7C6802A6 48000015
|
||||
25643A25 3032642E
|
||||
25303364 00000000
|
||||
7C8802A6 3D80817F
|
||||
618C0238 7D8803A6
|
||||
4E800021 818D98B8
|
||||
C02C0010 C04C0014
|
||||
C06C0018 C08C00B0
|
||||
C0AC00A8 A0AC0096
|
||||
818DA8B0 A0CC00A6
|
||||
38C68000 818D97E8
|
||||
80EC0058 54E707BF
|
||||
48000011 001000BC
|
||||
0000000F FFFFFFFF
|
||||
FFFFFFFF 7C6802A6
|
||||
4800003D 5820252E
|
||||
30660A59 20252E30
|
||||
660A5A20 252E3066
|
||||
0A412025 68750A43
|
||||
20256875 0A482025
|
||||
2E32660A 5620252E
|
||||
32660A51 46202564
|
||||
00000000 7C8802A6
|
||||
3D80817F 618C0238
|
||||
7D8803A6 4E800021
|
||||
60000000 00000000
|
||||
</source>
|
||||
<source version="GMSE01">
|
||||
C21441B0 00000023
|
||||
818D9FB8 818C005C
|
||||
1D8C03E9 38000078
|
||||
7D8C0396 380003E8
|
||||
7D6C0396 1D4B03E8
|
||||
7CEA6050 3800003C
|
||||
7CAB0396 1D45003C
|
||||
7CCA5850 48000011
|
||||
00100147 0000001E
|
||||
F43464FF F6F6F6FF
|
||||
7C6802A6 48000015
|
||||
25643A25 3032642E
|
||||
25303364 00000000
|
||||
7C8802A6 3D80817F
|
||||
618C0238 7D8803A6
|
||||
4E800021 818D9F28
|
||||
C02C0010 C04C0014
|
||||
C06C0018 C08C00B0
|
||||
C0AC00A8 A0AC0096
|
||||
818D8EE8 A0CC00A6
|
||||
38C68000 818D9FB8
|
||||
80EC0058 54E707BF
|
||||
48000011 001000BC
|
||||
0000000F FFFFFFFF
|
||||
FFFFFFFF 7C6802A6
|
||||
4800003D 5820252E
|
||||
30660A59 20252E30
|
||||
660A5A20 252E3066
|
||||
0A412025 68750A43
|
||||
20256875 0A482025
|
||||
2E32660A 5620252E
|
||||
32660A51 46202564
|
||||
00000000 7C8802A6
|
||||
3D80817F 618C0238
|
||||
7D8803A6 4E800021
|
||||
60000000 00000000
|
||||
</source>
|
||||
<source version="GMSP01">
|
||||
C2138DEC 00000023
|
||||
818D9EE0 818C005C
|
||||
1D8C03E9 38000078
|
||||
7D8C0396 380003E8
|
||||
7D6C0396 1D4B03E8
|
||||
7CEA6050 3800003C
|
||||
7CAB0396 1D45003C
|
||||
7CCA5850 48000011
|
||||
00100147 0000001E
|
||||
F43464FF F6F6F6FF
|
||||
7C6802A6 48000015
|
||||
25643A25 3032642E
|
||||
25303364 00000000
|
||||
7C8802A6 3D80817F
|
||||
618C0238 7D8803A6
|
||||
4E800021 818D9E50
|
||||
C02C0010 C04C0014
|
||||
C06C0018 C08C00B0
|
||||
C0AC00A8 A0AC0096
|
||||
818D8EA8 A0CC00A6
|
||||
38C68000 818D9EE0
|
||||
80EC0058 54E707BF
|
||||
48000011 001000BC
|
||||
0000000F FFFFFFFF
|
||||
FFFFFFFF 7C6802A6
|
||||
4800003D 5820252E
|
||||
30660A59 20252E30
|
||||
660A5A20 252E3066
|
||||
0A412025 68750A43
|
||||
20256875 0A482025
|
||||
2E32660A 5620252E
|
||||
32660A51 46202564
|
||||
00000000 7C8802A6
|
||||
3D80817F 618C0238
|
||||
7D8803A6 4E800021
|
||||
60000000 00000000
|
||||
</source>
|
||||
<source version="GMSJ0A">
|
||||
C212553C 00000023
|
||||
818D9E78 818C005C
|
||||
1D8C03E9 38000078
|
||||
7D8C0396 380003E8
|
||||
7D6C0396 1D4B03E8
|
||||
7CEA6050 3800003C
|
||||
7CAB0396 1D45003C
|
||||
7CCA5850 48000011
|
||||
00100147 0000001E
|
||||
F43464FF F6F6F6FF
|
||||
7C6802A6 48000015
|
||||
25643A25 3032642E
|
||||
25303364 00000000
|
||||
7C8802A6 3D80817F
|
||||
618C0238 7D8803A6
|
||||
4E800021 818D9DE8
|
||||
C02C0010 C04C0014
|
||||
C06C0018 C08C00B0
|
||||
C0AC00A8 A0AC0096
|
||||
818DA898 A0CC00A6
|
||||
38C68000 818D9E78
|
||||
80EC0058 54E707BF
|
||||
48000011 001000BC
|
||||
0000000F FFFFFFFF
|
||||
FFFFFFFF 7C6802A6
|
||||
4800003D 5820252E
|
||||
30660A59 20252E30
|
||||
660A5A20 252E3066
|
||||
0A412025 68750A43
|
||||
20256875 0A482025
|
||||
2E32660A 5620252E
|
||||
32660A51 46202564
|
||||
00000000 7C8802A6
|
||||
3D80817F 618C0238
|
||||
7D8803A6 4E800021
|
||||
60000000 00000000
|
||||
</source>
|
||||
</code>
|
15
drawText/test/make.py
Normal file
15
drawText/test/make.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
from supSMSGecko import make_xml, symbols, Button as B
|
||||
|
||||
'''
|
||||
Note: drawText.s is modified from compiled drawText.c file
|
||||
'''
|
||||
|
||||
def main(g, ver):
|
||||
S = symbols[ver]
|
||||
g.C2(
|
||||
addr = S['drawWater'] - 0x30,
|
||||
input_path = 'test.s',
|
||||
extra_ld_input = ['drawText = 0x817f0238;'],
|
||||
)
|
||||
|
||||
make_xml(main)
|
74
drawText/test/test.s
Normal file
74
drawText/test/test.s
Normal file
|
@ -0,0 +1,74 @@
|
|||
/** drawText(option, fmt, ...)
|
||||
* r3 = option
|
||||
* r4 = fmt
|
||||
*/
|
||||
|
||||
.macro .opt x y size top bot
|
||||
bl 16
|
||||
.short \x
|
||||
.short \y
|
||||
.long \size
|
||||
.long \top
|
||||
.long \bot
|
||||
mflr 3
|
||||
.endm
|
||||
|
||||
.test:
|
||||
|
||||
.test.qft:
|
||||
lwz r12, gpMarDirector$r13(r13)
|
||||
lwz r12, 0x5C(r12)
|
||||
mulli r12, r12, 1001
|
||||
li r0, 120
|
||||
divwu r12, r12, r0
|
||||
### r7 = ms
|
||||
li r0, 1000
|
||||
divwu r11, r12, r0
|
||||
mulli r10, r11, 1000
|
||||
sub r7, r12, r10
|
||||
### r6 = s
|
||||
### r5 = m
|
||||
li r0, 60
|
||||
divwu r5, r11, r0
|
||||
mulli r10, r5, 60
|
||||
sub r6, r11, r10
|
||||
## option
|
||||
.opt 16 327 30 0xf43464ff 0xf6f6f6ff
|
||||
## fmt
|
||||
bl .qft.fmt.bl
|
||||
.asciz "%d:%02d.%03d"
|
||||
.align 2; .qft.fmt.bl: mflr r4
|
||||
## call
|
||||
lis r12, drawText@h
|
||||
ori r12, r12, drawText@l
|
||||
mtlr r12
|
||||
blrl
|
||||
|
||||
.test.display:
|
||||
lwz r12, gpMarioOriginal$r13(r13)
|
||||
lfs f1, 0x10(r12)
|
||||
lfs f2, 0x14(r12)
|
||||
lfs f3, 0x18(r12)
|
||||
lfs f4, 0xB0(r12)
|
||||
lfs f5, 0xA8(r12)
|
||||
### r5 = A
|
||||
lhz r5, 0x96(r12)
|
||||
### r6 = C
|
||||
lwz r12, gpCamera$r13(r13)
|
||||
lhz r6, 0xA6(r12)
|
||||
addi r6, r6, -0x8000
|
||||
### r7 = QF
|
||||
lwz r12, gpMarDirector$r13(r13)
|
||||
lwz r7, 0x58(r12)
|
||||
rlwinm. r7, r7, 0, 0x3
|
||||
## option
|
||||
.opt 16 188 15 0xffffffff 0xffffffff
|
||||
## fmt
|
||||
bl .display.bl
|
||||
.asciz "X %.0f\nY %.0f\nZ %.0f\nA %hu\nC %hu\nH %.2f\nV %.2f\nQF %d"
|
||||
.align 2; .display.bl: mflr r4
|
||||
## call
|
||||
lis r12, drawText@h
|
||||
ori r12, r12, drawText@l
|
||||
mtlr r12
|
||||
blrl
|
Loading…
Reference in a new issue