fork/training-mode-ce
git clone https://git.julia.blue/fork/training-mode-ce
8e0b417
techchase-camera
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{ 13u8 * image_data_arr ;// array of I4 image data for characters, stride is (32*32) / 2 14u8 * kerning_data_arr ;// array of kerning data for characters, stride is 0x2, kerning is at 0x0 15}; 16 17struct TextCanvas 18{ 19TextCanvas * next ;// 0x0 20GOBJ * cam_gobj ;// 0x4, 21u16 size ;// 0x8 data remaining after this alloc? 22u16 sis_idx ;// 0xa sis group this canvas belongs to 23// data after this.... 24u8 p_link ;// 0xC 25u8 xd ;// 0xD 26u8 gx_link ;// 0xE 27u8 gx_pri ;// 0xF 28}; 29 30struct Text 31{ 32Vec3 trans ;// 0x0-0xC, affects entire viewport 33Vec2 aspect ;// 0xC-0x14 CHANGE THIS TO BOUND, affects entire viewport 34float scissor_top ;// 0x14, is_scissor must be enabled 35float scissor_bot ;// 0x18, is_scissor must be enabled 36float scissor_left ;// 0x1c, is_scissor must be enabled 37float scissor_right ;// 0x20, is_scissor must be enabled 38Vec2 viewport_scale ;// 0x24-0x2C, scales entire viewport including text (was orignally scale) 39GXColor viewport_color ;// 0x2c, if the alpha value is != 0, uses an additional GXSetTevAlphaIn call @ 803a87f8 if enabled. background is the size of the aspect 40GXColor color ;// 0x30 41Vec2 scale ;// 0x34-0x3C scales just the text. (was originally stretch) 42float x3c ;// 0x3c 43float x40 ;// 0x40 44u16 x44 ;// 0x44 45u16 x46 ;// 0x46 46u8 use_aspect ;// 0x48, will fit the text to the bounds defined in aspect 47u8 kerning ;// 0x49 48u8 align ;// 0x4a 49u8 x4b ;// 50u8 is_depth_compare ;// 0x4C, if set to 1, updates the depth buffer when rendering, uses GX_LEQUAL (803a85a0) 51u8 hidden ;// 0x4D 52u8 is_scissor ;// 0x4E, crops the text within the bounding box 803a88e8 53u8 sis_id ;// 0x4F, id of the premade text file to use 54void * x50 ;// some buffer alloc'd @ 803a5ba0 55GOBJ * gobj ;// 0x54 56void (* render_callback )(GOBJ * text_gobj );// 0x58, read at 803a878c 57u8 * text_start ;// 0x5C, start parsing text data at this ptr 58u8 * text_end ;// 0x60, stops parsing text data at this ptr 59TextCanvas * allocInfo ;// 0x64 60void * x68 ;// 0x68, some alloc used for dialogue? 61u16 x6c ;// 0x6c, flags of some kind 62u16 x6e ;// 0x6e 63float x70 ;// 0x70 64float x74 ;// 0x74 65float x78 ;// 0x78 66float x7c ;// 0x7c 67float x80 ;// 0x80 68float x84 ;// 0x84 69float x88 ;// 0x88 70GXColor x8c ;// 0x8c, temp color storage when processing text opcodes. 803a8d7c 71u16 x90 ;// 0x90 72u16 x92 ;// 0x92 73int x94 ;// 0x94 74int char_display_num ;// 0x98, how many characters to display 75u8 is_fit ;// 0x9c 76u8 x9d ;// 0x9d 77u8 x9e ;// 0x9e, checked per character, 1 and 2 are valid inputs. updates the float @ x70 78u8 x9f ;// 0x9f 79int 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