Spyro 1 Reverse Engineering
Decompilation of functions from Spyro 1 into human readable C
 
Loading...
Searching...
No Matches
draw_text.c
Go to the documentation of this file.
1#include <common.h>
2#include <moby.h>
3
22char* DrawTextCapitals(char *text,int *textInfo, int spacing, char color)
23{
24 unsigned int currentCharacter; //? Needs to be unsigned lmao?
25
26 currentCharacter = *text; // Puts first character of string in currentcCharacter
27
28 while (currentCharacter != 0) { // Not a NULL terminator
29 if (currentCharacter != 0x20) { // Not a space character
30 _ptr_hudMobys -= MOBY_SIZE; // Shifts the moby pointer to a new empty slot
31 memset(_ptr_hudMobys, 0, MOBY_SIZE); // Clears the new slot
32 Vec3Copy((int *)(_ptr_hudMobys + 0xc),textInfo); // Copy text x pos, y pos, and size(z pos) to the new moby
33 currentCharacter = *text; // Puts each character of the string in currentCharacter each iteration of the loop
34 if(currentCharacter - '0' < 10) { // If currentCharacter 0-9
35 *(unsigned short *)(_ptr_hudMobys + 0x36) = currentCharacter + 0xd4;
36 }
37 else if(currentCharacter - 'A' < 26) { // If currentCharacter is A-Z
38 *(unsigned short *)(_ptr_hudMobys + 0x36) = currentCharacter + 0x169;
39 }
40 else {
41 short mobyType; // Special Characters
42 if(currentCharacter == '/') {
43 mobyType = 0x115;
44 }
45 else if(currentCharacter == '?') {
46 mobyType = 0x116;
47 }
48 else if(currentCharacter == '%') {
49 mobyType = 0x110;
50 }
51 else if(currentCharacter == '^') {
52 mobyType = 0x141;
53 }
54 else if(currentCharacter == '+') {
55 mobyType = 0x13d;
56 }
57 else { // Default Character (_)
58 mobyType = 0x147;
59 }
60 *(short *)(_ptr_hudMobys + 0x36) = mobyType;
61 }
62 _ptr_hudMobys[0x47] = 0x7f;
63 _ptr_hudMobys[0x4f] = color;
64 _ptr_hudMobys[0x50] = 0xff;
65 }
66 text++; // Move to next char in String
67 textInfo[0] += spacing; // The x position in the textInfo struct is increased by the spacing amount
68 currentCharacter = *text; // currentCharacter is updated to the next character
69 }
70 //printf("my print: %X\n", _ptr_hudMobyData);
71 return _ptr_hudMobys;
72}
73
89int DrawTextAll(char *text,int *capitalTextInfo,int *lowercaseTextInfo,int spacing,char color)
90{
91 unsigned int currentCharacter;
92 bool isCapital;
93 int spaceSize;
94
95 isCapital = TRUE;
96 currentCharacter = *text;
97 while (currentCharacter != 0) { // While not a NULL terminator
98 if (currentCharacter == 0x20) { // If a space
99 spaceSize = *lowercaseTextInfo * 3;
100 isCapital = TRUE; // Character is uppercase
101 if (spaceSize < 0) { //? Weird Failsafe?
102 spaceSize = spaceSize + 3;
103 }
104 capitalTextInfo[0] += (spaceSize / 4); // Updates X position using spaceSize
105 }
106 else {
107 _ptr_hudMobys -= MOBY_SIZE; // Shifts the moby pointer to a new empty slot
109 Vec3Copy((int *)(_ptr_hudMobys + 0xc),capitalTextInfo);
110 if ((*text == '!') || (*text == '?')) { // If ! or ? then make capital
111 isCapital = TRUE;
112 }
113 if (!isCapital) {
114 *(int *)(_ptr_hudMobys + 0x10) += lowercaseTextInfo[1]; // Increases the Y position by the "y offset" for lowercase letters
115 *(int *)(_ptr_hudMobys + 0x14) = lowercaseTextInfo[2]; // sets the size to be the lowercase size
116 }
117 currentCharacter = *text;
118 if (currentCharacter - '0' < 10) { // If character is 0-9
119 *(short *)(_ptr_hudMobys + 0x36) = currentCharacter + 0xd4;
120 }
121 else if (currentCharacter - 'A' < 26) { // If character is A-Z
122 *(short *)(_ptr_hudMobys + 0x36) = currentCharacter + 0x169;
123 }
124 else if (currentCharacter == '!') {
125 *(short *)(_ptr_hudMobys + 0x36) = 0x4b; // Special Characters
126 }
127 else if (currentCharacter == ',') {
128 *(short *)(_ptr_hudMobys + 0x36) = 0x4c;
129 }
130 else if (currentCharacter == '?') {
131 *(short *)(_ptr_hudMobys + 0x36) = 0x116;
132 }
133 else if (currentCharacter == '.') {
134 *(short *)(_ptr_hudMobys + 0x36) = 0x147;
135 }
136 else { // Default Case (apostrophe but it's really a comma up in the air lol)
137 *(short *)(_ptr_hudMobys + 0x36) = 0x4c;
138 *(int *)(_ptr_hudMobys + 0x10) -= (*lowercaseTextInfo * 2) / 3; // Decreases y position (makes it go up) so the comma looks like an apostrophe
139 }
140 _ptr_hudMobys[0x47] = '\x7f';
141 _ptr_hudMobys[0x4f] = color;
142 _ptr_hudMobys[0x50] = 0xff;
143 if (isCapital) {
144 *capitalTextInfo += spacing; // If capital increase X position using default spacing
145 }
146 else {
147 *capitalTextInfo += *lowercaseTextInfo; // If not capital increase X position using lowercase spacing
148 }
149 isCapital = (unsigned int)(*text - 0x30) < 10; // Sets isCapitral to false when the character is not a number
150 }
151 text++;
152 currentCharacter = *text;
153 }
154 return _ptr_hudMobys;
155} // end of reveresed_functions
#define TRUE
Definition custom_types.h:5
char * _ptr_hudMobys
void memset(void *str, int c, int n)
int DrawTextAll(char *text, int *capitalTextInfo, int *lowercaseTextInfo, int spacing, char color)
Draws a text string to the screen (Capital & Lowercase allowed)
Definition draw_text.c:89
char * DrawTextCapitals(char *text, int *textInfo, int spacing, char color)
Draws a text string to the screen (Only capital characters allowed)
Definition draw_text.c:22
void Vec3Copy(int *dst, int *src)
Copies the 'src' Vector to the 'dst' Vector.
Definition vector.c:47
#define MOBY_SIZE
Definition moby.h:9