summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPyredrid <Pyredrid@users.noreply.github.com>2020-09-03 23:01:25 -0400
committerPyredrid <Pyredrid@users.noreply.github.com>2020-09-03 23:01:25 -0400
commitc4b5c0609cfe9f85c4c9039df8992920ff206dfb (patch)
treee31c9e6e6197ba4b29a81d98cede608ba3c289da
parentd89a36ab34d884bc1269465c21f0f4a82d653681 (diff)
Updated printf in mGBA (markdown)
-rw-r--r--printf-in-mGBA.md59
1 files changed, 58 insertions, 1 deletions
diff --git a/printf-in-mGBA.md b/printf-in-mGBA.md
index 9d02e17..e51fa91 100644
--- a/printf-in-mGBA.md
+++ b/printf-in-mGBA.md
@@ -50,6 +50,7 @@ In `gflib/string_util.h`, add `char *ConvertToAscii(const u8 *str);`.
Add `#include "malloc.h"` to `gflib/string_util.c`.
Then, add the following C function to `gflib/string_util.c`:
```c
+
char *ConvertToAscii(const u8 *str)
{
s32 i;
@@ -59,7 +60,7 @@ char *ConvertToAscii(const u8 *str)
char modifiedCode = '?';
if(*str >= CHAR_a && *str <= CHAR_z)
{
- modifiedCode = *str-(CHAR_A-'a'); // lower-case characters
+ modifiedCode = *str-(CHAR_a-'a'); // lower-case characters
}
else if(*str >= CHAR_A && *str <= CHAR_Z)
{
@@ -73,6 +74,62 @@ char *ConvertToAscii(const u8 *str)
{
modifiedCode = ' '; // space
}
+ else if (*str == CHAR_EXCL_MARK)
+ {
+ modifiedCode = '!'; // exclamation point
+ }
+ else if (*str == CHAR_QUESTION_MARK)
+ {
+ modifiedCode = '?'; // question mark
+ }
+ else if (*str == CHAR_PERIOD)
+ {
+ modifiedCode = '.'; // period
+ }
+ else if (*str == CHAR_DBL_QUOT_LEFT || *str == CHAR_DBL_QUOT_RIGHT)
+ {
+ modifiedCode = '"'; // double quote
+ }
+ else if (*str == CHAR_SGL_QUOT_LEFT || *str == CHAR_SGL_QUOT_RIGHT)
+ {
+ modifiedCode = '"'; // single quote
+ }
+ else if (*str == CHAR_CURRENCY)
+ {
+ modifiedCode = '$'; // currency mark (pokemonies in game, dollar sign in logs)
+ }
+ else if (*str == CHAR_COMMA)
+ {
+ modifiedCode = ','; // comma
+ }
+ else if (*str == CHAR_MULT_SIGN)
+ {
+ modifiedCode = '#'; // pound, hashtag, octothorpe, whatever
+ }
+ else if (*str == CHAR_SLASH)
+ {
+ modifiedCode = '/'; // slash
+ }
+ else if (*str == CHAR_LESS_THAN)
+ {
+ modifiedCode = '<'; // less than sign
+ }
+ else if (*str == CHAR_GREATER_THAN)
+ {
+ modifiedCode = '>'; // greater than sign
+ }
+ else if (*str == CHAR_PERCENT)
+ {
+ modifiedCode = '%'; // percentage
+ }
+ else if (*str == CHAR_LEFT_PAREN)
+ {
+ modifiedCode = '('; // opening parentheses
+ }
+ else if (*str == CHAR_RIGHT_PAREN)
+ {
+ modifiedCode = ')'; // closing parentheses
+ }
textBuffer[i] = modifiedCode;
}
textBuffer[i] = 0;