fork/training-mode-ce

git clone https://git.julia.blue/fork/training-mode-ce

AitchAdd rect/text drawing code -> add action log drawing code -> add float cancel event (#301)8e0b417

techchase-camera
6.1 KiB121 linesraw
1#ifndef MEX_H_TEXT
2#define MEX_H_TEXT
3
4#include "structs.h"
5#include "datatypes.h"
6#include "obj.h"
7#include "gx.h"
8
9/*** Structs ***/
10
11struct SISData
12{
13    u8 *image_data_arr;   // array of I4 image data for characters, stride is (32*32) / 2
14    u8 *kerning_data_arr; // array of kerning data for characters, stride is 0x2, kerning is at 0x0
15};
16
17struct TextCanvas
18{
19    TextCanvas *next; // 0x0
20    GOBJ *cam_gobj;   // 0x4,
21    u16 size;         // 0x8 data remaining after this alloc?
22    u16 sis_idx;      // 0xa sis group this canvas belongs to
23    // data after this....
24    u8 p_link;  // 0xC
25    u8 xd;      // 0xD
26    u8 gx_link; // 0xE
27    u8 gx_pri;  // 0xF
28};
29
30struct Text
31{
32    Vec3 trans;                               // 0x0-0xC, affects entire viewport
33    Vec2 aspect;                              // 0xC-0x14 CHANGE THIS TO BOUND, affects entire viewport
34    float scissor_top;                        // 0x14, is_scissor must be enabled
35    float scissor_bot;                        // 0x18, is_scissor must be enabled
36    float scissor_left;                       // 0x1c, is_scissor must be enabled
37    float scissor_right;                      // 0x20, is_scissor must be enabled
38    Vec2 viewport_scale;                      // 0x24-0x2C, scales entire viewport including text (was orignally scale)
39    GXColor viewport_color;                   // 0x2c, if the alpha value is != 0, uses an additional GXSetTevAlphaIn call @ 803a87f8 if enabled. background is the size of the aspect
40    GXColor color;                            // 0x30
41    Vec2 scale;                               // 0x34-0x3C scales just the text. (was originally stretch)
42    float x3c;                                // 0x3c
43    float x40;                                // 0x40
44    u16 x44;                                  // 0x44
45    u16 x46;                                  // 0x46
46    u8 use_aspect;                            // 0x48, will fit the text to the bounds defined in aspect
47    u8 kerning;                               // 0x49
48    u8 align;                                 // 0x4a
49    u8 x4b;                                   //
50    u8 is_depth_compare;                      // 0x4C, if set to 1, updates the depth buffer when rendering, uses GX_LEQUAL (803a85a0)
51    u8 hidden;                                // 0x4D
52    u8 is_scissor;                            // 0x4E, crops the text within the bounding box 803a88e8
53    u8 sis_id;                                // 0x4F, id of the premade text file to use
54    void *x50;                                // some buffer alloc'd @ 803a5ba0
55    GOBJ *gobj;                               // 0x54
56    void (*render_callback)(GOBJ *text_gobj); // 0x58, read at 803a878c
57    u8 *text_start;                           // 0x5C, start parsing text data at this ptr
58    u8 *text_end;                             // 0x60, stops parsing text data at this ptr
59    TextCanvas *allocInfo;                    // 0x64
60    void *x68;                                // 0x68, some alloc used for dialogue?
61    u16 x6c;                                  // 0x6c, flags of some kind
62    u16 x6e;                                  // 0x6e
63    float x70;                                // 0x70
64    float x74;                                // 0x74
65    float x78;                                // 0x78
66    float x7c;                                // 0x7c
67    float x80;                                // 0x80
68    float x84;                                // 0x84
69    float x88;                                // 0x88
70    GXColor x8c;                              // 0x8c, temp color storage when processing text opcodes. 803a8d7c
71    u16 x90;                                  // 0x90
72    u16 x92;                                  // 0x92
73    int x94;                                  // 0x94
74    int char_display_num;                     // 0x98, how many characters to display
75    u8 is_fit;                                // 0x9c
76    u8 x9d;                                   // 0x9d
77    u8 x9e;                                   // 0x9e, checked per character, 1 and 2 are valid inputs. updates the float @ x70
78    u8 x9f;                                   // 0x9f
79    int xa0;                                  // 0xa0
80};
81
82/*** Functions ***/
83
84int Text_CreateCanvas(int sis_id, GOBJ *cam_gobj, int gobj_entityclass, int gobj_plink, int gobj_ppriority, int gxlink, int gxpri, int cobj_gxpri); // the optional gobj and cobj_gxlink are used to create a cobj as well. set gobj
85Text *Text_CreateText(int sis_id, int canvasID);
86Text *Text_CreateText2(int sis_id, int canvasID, float pos_x, float pos_y, float pos_z, float limit_x, float limit_y);
87void Text_Destroy(Text *text);
88int Text_AddSubtext(Text *text, float xPos, float yPos, char *string, ...);
89void Text_SetScale(Text *text, int subtext, float x, float y);
90void Text_SetColor(Text *text, int subtext, GXColor *color);
91void Text_SetPosition(Text *text, int subtext, float x, float y);
92void Text_SetText(Text *text, int subtext, const char *string, ...);
93u8 *Text_Alloc(int size);
94void Text_DestroyAlloc(u8 *alloc);
95void Text_DestroyAllAlloc(Text *text);
96int Text_ConvertToMenuText(char *out, char *in);
97void Text_GX(GOBJ *gobj, int pass);
98void Text_LoadSdFile(int index, char *filename, char *symbol);
99void Text_SetSisText(Text *text, int text_index);
100void Text_DestroyAllSisCanvas(int sis_id);
101void Text_DestroyCanvas(TextCanvas *);
102void Text_InitSisHeap();
103
104/*** Variables ***/
105// Text data
106static int *stc_textheap_size = (int *)(R13_OFFSET(-0x3d38));
107static TextCanvas **stc_textheap_start = (TextCanvas **)(R13_OFFSET(-0x3d34));
108static TextCanvas **stc_textheap_next = (TextCanvas **)(R13_OFFSET(-0x3d30));
109static TextCanvas **stc_textheap_first = (TextCanvas **)(R13_OFFSET(-0x3d2c));
110
111// Text object
112static Text **stc_text_first = (Text **)(R13_OFFSET(-0x3d28));
113
114// Text canvas
115static TextCanvas **stc_textcanvas_first = (TextCanvas **)(R13_OFFSET(-0x3d24));
116
117// Sis Library
118static HSD_Archive **stc_sis_archives = (HSD_Archive **)0x804d1110; // array of sis file archive pointers
119static SISData **stc_sis_data = (void *)0x804d1124;                 // array of currently loaded sis data, indexed by sis_id
120
121#endif