summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh <32826900+ShinyDragonHunter@users.noreply.github.com>2021-05-24 04:43:15 +0100
committerJosh <32826900+ShinyDragonHunter@users.noreply.github.com>2021-05-24 04:43:15 +0100
commita6d53b12e8a56993f5a9ee309862eff274367b82 (patch)
tree5889e30e5110e7a76e4c9f52de42006658e4cace
parentd83883f84c62c497d724d5d462fe65360085bc30 (diff)
Updated Implementing the “textcolor” script command from FRLG and give object events their own text colour (markdown)
-rw-r--r--Implementing-the-“textcolor”-script-command-from-FRLG-and-give-object-events-their-own-text-colour.md31
1 files changed, 13 insertions, 18 deletions
diff --git a/Implementing-the-“textcolor”-script-command-from-FRLG-and-give-object-events-their-own-text-colour.md b/Implementing-the-“textcolor”-script-command-from-FRLG-and-give-object-events-their-own-text-colour.md
index a89b379..e8660cd 100644
--- a/Implementing-the-“textcolor”-script-command-from-FRLG-and-give-object-events-their-own-text-colour.md
+++ b/Implementing-the-“textcolor”-script-command-from-FRLG-and-give-object-events-their-own-text-colour.md
@@ -5,7 +5,6 @@ This tutorial will walk you through how to implement this into Emerald whilst al
Open field_specials.c and add the following function:
```c
-
u8 ContextNpcGetTextColor(void)
{
u8 gfxId;
@@ -29,13 +28,11 @@ This function is what handles the context of the text. The `if (gSpecialVar_Text
Extern it somewhere in `include/field_specials.h` like so:
```c
-
u8 ContextNpcGetTextColor(void);
```
Next, we want to open menu.c and add the following function:
```c
-
void AddTextPrinterForMessageWithTextColor(bool8 allowSkippingDelayWithButtonPress)
{
u8 color;
@@ -46,7 +43,6 @@ void AddTextPrinterForMessageWithTextColor(bool8 allowSkippingDelayWithButtonPre
}
```
I put this above `AddTextPrinterForMessage` which is the function base Emerald uses.
-
In this function, we have the local variable `color`. This variable is what we’re using to call the `ContextNpcGetTextColor` function we added earlier. Because of `ContextNpcGetTextColor` we are able to use `gSpecialVar_TextColor` as the colour value in `AddTextPrinterParameterized2` and because of the logic from the aforementioned functions, the colour value in `AddTextPrinterParameterized2`, will be the value of `graphicsInfo->textColor`.
Don’t forget to extern the function somewhere in `menu.h` like this:
@@ -54,11 +50,15 @@ Don’t forget to extern the function somewhere in `menu.h` like this:
void AddTextPrinterForMessageWithTextColor(bool8 allowSkippingDelayWithButtonPress);
```
-We need to open `field_message_box.c` and find the function `StartDrawFieldMessage` and make the following change:
-
-
+At the top of menu.c, add the following:
+```diff
+#include "event_data.h"
++ #include "field_specials.h"
+```
+This is so we can use the aformentioned `ContextNpcGetTextColor` function.
-```c
+We need to open `field_message_box.c` and find the function `StartDrawFieldMessage` and make the following change:
+```diff
static void StartDrawFieldMessage(void)
{
@@ -67,7 +67,6 @@ static void StartDrawFieldMessage(void)
CreateTask_DrawFieldMessage();
}
```
-
`StartDrawFieldMessage` is the function that handles message boxes in the overworld.
Next, we want to open `field_control_avatar.c` go to the function `ProcessPlayerFieldInput` and make the following change:
@@ -116,7 +115,6 @@ We’re gonna implement the `textcolor` scripting command so you can make partic
Go to `scrcmd.c` and add the following function:
```c
-
bool8 ScrCmd_textcolor(struct ScriptContext * ctx)
{
gSpecialVar_PrevTextColor = gSpecialVar_TextColor;
@@ -129,20 +127,17 @@ This is the script command function for the textcolor script command. `ctx` is t
We want to go to `data/script_cmd_table.inc` and go to line 202 and change the following:
-```c
-.4byte ScrCmd_nop1 @ 0xc7
-```
-to
-```c
-.4byte ScrCmd_textcolor @ 0xc7
+```diff
+- .4byte ScrCmd_nop1 @ 0xc7
++ .4byte ScrCmd_textcolor @ 0xc7
```
This is so the scripting system knows to use `ScrCmd_textcolor` we added earlier.
We want to declare these new special vars we’re using! Go to `event_data.c` on line 15, make the follow change:
-```diff
+```diff
EWRAM_DATA u16 gSpecialVar_0x8000 = 0;
EWRAM_DATA u16 gSpecialVar_0x8001 = 0;
EWRAM_DATA u16 gSpecialVar_0x8002 = 0;
@@ -166,8 +161,8 @@ EWRAM_DATA u16 gSpecialVar_MonBoxPos = 0;
EWRAM_DATA static u8 gSpecialFlags[SPECIAL_FLAGS_SIZE] = {0};
```
And on line 30 in `include/event_data.h`, make the following change:
-```c
+```diff
extern u16 gSpecialVar_0x8000;
extern u16 gSpecialVar_0x8001;
extern u16 gSpecialVar_0x8002;