mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-04 06:54:33 +00:00
Reworked text extraction + add JP text extraction (#1980)
* Reworked text extraction + add JP text extraction * Format * Suggested changes * Correct address for gc-us sJpnMessageEntryTable Co-authored-by: cadmic <cadmic24@gmail.com> --------- Co-authored-by: cadmic <cadmic24@gmail.com>
This commit is contained in:
parent
264581ff3f
commit
baf1e8c174
19 changed files with 1326 additions and 707 deletions
|
@ -1,180 +1,189 @@
|
|||
#ifndef MESSAGE_DATA_FMT_H
|
||||
#define MESSAGE_DATA_FMT_H
|
||||
|
||||
/*
|
||||
* Macros to create both a constant and a string literal from a magic value
|
||||
* The constants are used in code files when parsing text for various purposes
|
||||
* The strings are used in the message_data_static files themselves, as you can only concat strings with other strings
|
||||
*/
|
||||
#include "z64save.h" // For highscores
|
||||
#include "z64item.h" // For item ids
|
||||
#include "sfx.h" // For sfx ids
|
||||
|
||||
#ifndef GLUE
|
||||
#define GLUE(a, b) a##b
|
||||
#endif
|
||||
|
||||
#define STRINGIFY(s) #s
|
||||
#define EXPAND_AND_STRINGIFY(s) STRINGIFY(s)
|
||||
|
||||
#define HEX(N) GLUE(0x, N)
|
||||
#define STR(N) EXPAND_AND_STRINGIFY(GLUE(\x, N))
|
||||
#define TEXT_LANG_US_JP 0
|
||||
#define TEXT_LANG_EU 1
|
||||
|
||||
/*
|
||||
* Text control characters
|
||||
*/
|
||||
|
||||
// Control character magic values, in 2-digit hex without prefix
|
||||
// Non-Wide (nes/ger/fra)
|
||||
|
||||
#define CTRL_NEWLINE 01
|
||||
#define CTRL_END 02
|
||||
#define CTRL_BOX_BREAK 04
|
||||
#define CTRL_COLOR 05
|
||||
#define CTRL_SHIFT 06
|
||||
#define CTRL_TEXTID 07
|
||||
#define CTRL_QUICKTEXT_ENABLE 08
|
||||
#define CTRL_QUICKTEXT_DISABLE 09
|
||||
#define CTRL_PERSISTENT 0A
|
||||
#define CTRL_EVENT 0B
|
||||
#define CTRL_BOX_BREAK_DELAYED 0C
|
||||
#define CTRL_AWAIT_BUTTON_PRESS 0D
|
||||
#define CTRL_FADE 0E
|
||||
#define CTRL_NAME 0F
|
||||
#define CTRL_OCARINA 10
|
||||
#define CTRL_FADE2 11
|
||||
#define CTRL_SFX 12
|
||||
#define CTRL_ITEM_ICON 13
|
||||
#define CTRL_TEXT_SPEED 14
|
||||
#define CTRL_BACKGROUND 15
|
||||
#define CTRL_MARATHON_TIME 16
|
||||
#define CTRL_RACE_TIME 17
|
||||
#define CTRL_POINTS 18
|
||||
#define CTRL_TOKENS 19
|
||||
#define CTRL_UNSKIPPABLE 1A
|
||||
#define CTRL_TWO_CHOICE 1B
|
||||
#define CTRL_THREE_CHOICE 1C
|
||||
#define CTRL_FISH_INFO 1D
|
||||
#define CTRL_HIGHSCORE 1E
|
||||
#define CTRL_TIME 1F
|
||||
#define MESSAGE_NEWLINE 0x01
|
||||
#define MESSAGE_END 0x02
|
||||
#define MESSAGE_BOX_BREAK 0x04
|
||||
#define MESSAGE_COLOR 0x05
|
||||
#define MESSAGE_SHIFT 0x06
|
||||
#define MESSAGE_TEXTID 0x07
|
||||
#define MESSAGE_QUICKTEXT_ENABLE 0x08
|
||||
#define MESSAGE_QUICKTEXT_DISABLE 0x09
|
||||
#define MESSAGE_PERSISTENT 0x0A
|
||||
#define MESSAGE_EVENT 0x0B
|
||||
#define MESSAGE_BOX_BREAK_DELAYED 0x0C
|
||||
#define MESSAGE_AWAIT_BUTTON_PRESS 0x0D
|
||||
#define MESSAGE_FADE 0x0E
|
||||
#define MESSAGE_NAME 0x0F
|
||||
#define MESSAGE_OCARINA 0x10
|
||||
#define MESSAGE_FADE2 0x11
|
||||
#define MESSAGE_SFX 0x12
|
||||
#define MESSAGE_ITEM_ICON 0x13
|
||||
#define MESSAGE_TEXT_SPEED 0x14
|
||||
#define MESSAGE_BACKGROUND 0x15
|
||||
#define MESSAGE_MARATHON_TIME 0x16
|
||||
#define MESSAGE_RACE_TIME 0x17
|
||||
#define MESSAGE_POINTS 0x18
|
||||
#define MESSAGE_TOKENS 0x19
|
||||
#define MESSAGE_UNSKIPPABLE 0x1A
|
||||
#define MESSAGE_TWO_CHOICE 0x1B
|
||||
#define MESSAGE_THREE_CHOICE 0x1C
|
||||
#define MESSAGE_FISH_INFO 0x1D
|
||||
#define MESSAGE_HIGHSCORE 0x1E
|
||||
#define MESSAGE_TIME 0x1F
|
||||
|
||||
// Wide (jpn)
|
||||
|
||||
#define MESSAGE_WIDE_NEWLINE 0x000A
|
||||
#define MESSAGE_WIDE_END 0x8170
|
||||
#define MESSAGE_WIDE_BOX_BREAK 0x81A5
|
||||
#define MESSAGE_WIDE_COLOR 0x000B
|
||||
#define MESSAGE_WIDE_SHIFT 0x86C7
|
||||
#define MESSAGE_WIDE_TEXTID 0x81CB
|
||||
#define MESSAGE_WIDE_QUICKTEXT_ENABLE 0x8189
|
||||
#define MESSAGE_WIDE_QUICKTEXT_DISABLE 0x818A
|
||||
#define MESSAGE_WIDE_PERSISTENT 0x86C8
|
||||
#define MESSAGE_WIDE_EVENT 0x819F
|
||||
#define MESSAGE_WIDE_BOX_BREAK_DELAYED 0x81A3
|
||||
#define MESSAGE_WIDE_AWAIT_BUTTON_PRESS 0x81A4
|
||||
#define MESSAGE_WIDE_FADE 0x819E
|
||||
#define MESSAGE_WIDE_NAME 0x874F
|
||||
#define MESSAGE_WIDE_OCARINA 0x81F0
|
||||
#define MESSAGE_WIDE_FADE2 0x81F4
|
||||
#define MESSAGE_WIDE_SFX 0x81F3
|
||||
#define MESSAGE_WIDE_ITEM_ICON 0x819A
|
||||
#define MESSAGE_WIDE_TEXT_SPEED 0x86C9
|
||||
#define MESSAGE_WIDE_BACKGROUND 0x86B3
|
||||
#define MESSAGE_WIDE_MARATHON_TIME 0x8791
|
||||
#define MESSAGE_WIDE_RACE_TIME 0x8792
|
||||
#define MESSAGE_WIDE_POINTS 0x879B
|
||||
#define MESSAGE_WIDE_TOKENS 0x86A3
|
||||
#define MESSAGE_WIDE_UNSKIPPABLE 0x8199
|
||||
#define MESSAGE_WIDE_TWO_CHOICE 0x81BC
|
||||
#define MESSAGE_WIDE_THREE_CHOICE 0x81B8
|
||||
#define MESSAGE_WIDE_FISH_INFO 0x86A4
|
||||
#define MESSAGE_WIDE_HIGHSCORE 0x869F
|
||||
#define MESSAGE_WIDE_TIME 0x81A1
|
||||
|
||||
/*
|
||||
* Colors
|
||||
*/
|
||||
|
||||
#define COLOR_STR(N) EXPAND_AND_STRINGIFY(GLUE(\x4, N))
|
||||
typedef enum {
|
||||
TEXT_COLOR_DEFAULT,
|
||||
TEXT_COLOR_RED,
|
||||
TEXT_COLOR_ADJUSTABLE,
|
||||
TEXT_COLOR_BLUE,
|
||||
TEXT_COLOR_LIGHTBLUE,
|
||||
TEXT_COLOR_PURPLE,
|
||||
TEXT_COLOR_YELLOW,
|
||||
TEXT_COLOR_BLACK
|
||||
} TextColor;
|
||||
|
||||
// Color magic values, in single-digit hex without prefix
|
||||
/*
|
||||
* Background
|
||||
*/
|
||||
|
||||
#define CTRL_DEFAULT 0
|
||||
#define CTRL_RED 1
|
||||
#define CTRL_ADJUSTABLE 2
|
||||
#define CTRL_BLUE 3
|
||||
#define CTRL_LIGHTBLUE 4
|
||||
#define CTRL_PURPLE 5
|
||||
#define CTRL_YELLOW 6
|
||||
#define CTRL_BLACK 7
|
||||
typedef enum {
|
||||
TEXTBOX_BG_X_LEFT,
|
||||
TEXTBOX_BG_X_RIGHT
|
||||
} TextboxBackgroundIndex;
|
||||
|
||||
typedef enum {
|
||||
TEXTBOX_BG_FGCOL_WHITE,
|
||||
TEXTBOX_BG_FGCOL_DARK_RED,
|
||||
TEXTBOX_BG_FGCOL_ORANGE,
|
||||
TEXTBOX_BG_FGCOL_WHITE_3,
|
||||
TEXTBOX_BG_FGCOL_WHITE_4,
|
||||
TEXTBOX_BG_FGCOL_WHITE_5,
|
||||
TEXTBOX_BG_FGCOL_WHITE_6,
|
||||
TEXTBOX_BG_FGCOL_WHITE_7
|
||||
} TextboxBackgroundForegroundColor;
|
||||
|
||||
typedef enum {
|
||||
TEXTBOX_BG_BGCOL_BLACK,
|
||||
TEXTBOX_BG_BGCOL_GOLD,
|
||||
TEXTBOX_BG_BGCOL_BLACK_2,
|
||||
TEXTBOX_BG_BGCOL_BLACK_3
|
||||
} TextboxBackgroundBackgroundColor;
|
||||
|
||||
typedef enum {
|
||||
TEXTBOX_BG_Y_OFFSET_1,
|
||||
TEXTBOX_BG_Y_OFFSET_2
|
||||
} TextboxBackgroundYOffsetIndex;
|
||||
|
||||
#ifdef MESSAGE_DATA_STATIC
|
||||
// For use in message_data_static files
|
||||
|
||||
#define ARG(x) x
|
||||
// Encoded text consists of an array of bytes. Since it's in a macro it must be wrapped in a varargs macro so that each
|
||||
// byte is not treated as a separate macro argument to DEFINE_MESSAGE. IDO doesn't support varargs macros, however we
|
||||
// preprocess the message_data_static files with modern cpp instead. See the makefile rule for assets/text/
|
||||
# define MSG(...) { __VA_ARGS__ END }
|
||||
|
||||
// Encoding helpers
|
||||
# define ARG2(x) (((x) >> 8) & 0xFF), (((x) >> 0) & 0xFF),
|
||||
# ifdef MESSAGE_WCHAR
|
||||
# define ARG1(x) 0x00, (x),
|
||||
# define ARGC(x) 0x0C, (TEXT_COLOR_ ## x),
|
||||
# define CTRL_BASE(name) ARG2(MESSAGE_WIDE_ ## name)
|
||||
# else
|
||||
# define ARG1(x) (x),
|
||||
# define ARGC(x) (0x40 | (TEXT_COLOR_ ## x)),
|
||||
# define CTRL_BASE(name) ARG1(MESSAGE_ ## name)
|
||||
# endif
|
||||
# define ARGB1(x) ARG1(TEXTBOX_BG_ ## x)
|
||||
# define ARGB2(a,b,c,d) (((TEXTBOX_BG_FGCOL_ ## a) << 4) | ((TEXTBOX_BG_BGCOL_ ## b) << 0)), (((TEXTBOX_BG_Y_OFFSET_ ## c) << 4) | ((d) << 0)),
|
||||
|
||||
/*
|
||||
* Control characters
|
||||
*/
|
||||
|
||||
// while a control character, newlines are handled in the charmap conversion
|
||||
// stage to allow normal newline \n usage in message_data_static files
|
||||
#define NEWLINE STR(CTRL_NEWLINE)
|
||||
#define END STR(CTRL_END)
|
||||
#define BOX_BREAK STR(CTRL_BOX_BREAK)
|
||||
#define COLOR(x) STR(CTRL_COLOR) ARG(x) // 1
|
||||
#define SHIFT(x) STR(CTRL_SHIFT) ARG(x) // 1
|
||||
#define TEXTID(x) STR(CTRL_TEXTID) ARG(x) // 2
|
||||
#define QUICKTEXT_ENABLE STR(CTRL_QUICKTEXT_ENABLE)
|
||||
#define QUICKTEXT_DISABLE STR(CTRL_QUICKTEXT_DISABLE)
|
||||
#define PERSISTENT STR(CTRL_PERSISTENT)
|
||||
#define EVENT STR(CTRL_EVENT)
|
||||
#define BOX_BREAK_DELAYED(x) STR(CTRL_BOX_BREAK_DELAYED) ARG(x) // 1
|
||||
#define AWAIT_BUTTON_PRESS STR(CTRL_AWAIT_BUTTON_PRESS)
|
||||
#define FADE(x) STR(CTRL_FADE) ARG(x) // 1
|
||||
#define NAME STR(CTRL_NAME)
|
||||
#define OCARINA STR(CTRL_OCARINA)
|
||||
#define FADE2(x) STR(CTRL_FADE2) ARG(x) // 2
|
||||
#define SFX(x) STR(CTRL_SFX) ARG(x) // 2
|
||||
#define ITEM_ICON(x) STR(CTRL_ITEM_ICON) ARG(x) // 1
|
||||
#define TEXT_SPEED(x) STR(CTRL_TEXT_SPEED) ARG(x) // 1
|
||||
#define BACKGROUND(x,y,z) STR(CTRL_BACKGROUND) ARG(x) ARG(y) ARG(z)
|
||||
#define MARATHON_TIME STR(CTRL_MARATHON_TIME)
|
||||
#define RACE_TIME STR(CTRL_RACE_TIME)
|
||||
#define POINTS STR(CTRL_POINTS)
|
||||
#define TOKENS STR(CTRL_TOKENS)
|
||||
#define UNSKIPPABLE STR(CTRL_UNSKIPPABLE)
|
||||
#define TWO_CHOICE STR(CTRL_TWO_CHOICE)
|
||||
#define THREE_CHOICE STR(CTRL_THREE_CHOICE)
|
||||
#define FISH_INFO STR(CTRL_FISH_INFO)
|
||||
#define HIGHSCORE(x) STR(CTRL_HIGHSCORE) ARG(x) // 1
|
||||
#define TIME STR(CTRL_TIME)
|
||||
# define NEWLINE CTRL_BASE(NEWLINE)
|
||||
# define END CTRL_BASE(END)
|
||||
# define BOX_BREAK CTRL_BASE(BOX_BREAK)
|
||||
# define COLOR(color) CTRL_BASE(COLOR) ARGC(color)
|
||||
# define SHIFT(amount) CTRL_BASE(SHIFT) ARG1(amount)
|
||||
# define TEXTID(textId) CTRL_BASE(TEXTID) ARG2(textId)
|
||||
# define QUICKTEXT_ENABLE CTRL_BASE(QUICKTEXT_ENABLE)
|
||||
# define QUICKTEXT_DISABLE CTRL_BASE(QUICKTEXT_DISABLE)
|
||||
# define PERSISTENT CTRL_BASE(PERSISTENT)
|
||||
# define EVENT CTRL_BASE(EVENT)
|
||||
# define BOX_BREAK_DELAYED(delay) CTRL_BASE(BOX_BREAK_DELAYED) ARG1(delay)
|
||||
# define AWAIT_BUTTON_PRESS CTRL_BASE(AWAIT_BUTTON_PRESS)
|
||||
# define FADE(delay) CTRL_BASE(FADE) ARG1(delay)
|
||||
# define NAME CTRL_BASE(NAME)
|
||||
# define OCARINA CTRL_BASE(OCARINA)
|
||||
# define FADE2(delay) CTRL_BASE(FADE2) ARG2(delay)
|
||||
# define SFX(sfxId) CTRL_BASE(SFX) ARG2(sfxId)
|
||||
# define ITEM_ICON(itemId) CTRL_BASE(ITEM_ICON) ARG1(itemId)
|
||||
# define TEXT_SPEED(amount) CTRL_BASE(TEXT_SPEED) ARG1(amount)
|
||||
# define BACKGROUND(bgIdx, fgColor, bgColor, yOffset, unk) CTRL_BASE(BACKGROUND) ARGB1(bgIdx) ARGB2(fgColor, bgColor, yOffset, unk)
|
||||
# define MARATHON_TIME CTRL_BASE(MARATHON_TIME)
|
||||
# define RACE_TIME CTRL_BASE(RACE_TIME)
|
||||
# define POINTS CTRL_BASE(POINTS)
|
||||
# define TOKENS CTRL_BASE(TOKENS)
|
||||
# define UNSKIPPABLE CTRL_BASE(UNSKIPPABLE)
|
||||
# define TWO_CHOICE CTRL_BASE(TWO_CHOICE)
|
||||
# define THREE_CHOICE CTRL_BASE(THREE_CHOICE)
|
||||
# define FISH_INFO CTRL_BASE(FISH_INFO)
|
||||
# define HIGHSCORE(highscore) CTRL_BASE(HIGHSCORE) ARG1(highscore)
|
||||
# define TIME CTRL_BASE(TIME)
|
||||
|
||||
/*
|
||||
* Highscore values as strings, for code references the HighScores
|
||||
* enum should be used.
|
||||
*/
|
||||
|
||||
#define HS_HORSE_ARCHERY "\x00"
|
||||
#define HS_POE_POINTS "\x01"
|
||||
#define HS_LARGEST_FISH "\x02"
|
||||
#define HS_HORSE_RACE "\x03"
|
||||
#define HS_MARATHON "\x04"
|
||||
#define HS_DAMPE_RACE "\x06"
|
||||
|
||||
/*
|
||||
* Color values as strings
|
||||
*/
|
||||
|
||||
#define DEFAULT COLOR_STR(CTRL_DEFAULT)
|
||||
#define RED COLOR_STR(CTRL_RED)
|
||||
#define ADJUSTABLE COLOR_STR(CTRL_ADJUSTABLE)
|
||||
#define BLUE COLOR_STR(CTRL_BLUE)
|
||||
#define LIGHTBLUE COLOR_STR(CTRL_LIGHTBLUE)
|
||||
#define PURPLE COLOR_STR(CTRL_PURPLE)
|
||||
#define YELLOW COLOR_STR(CTRL_YELLOW)
|
||||
#define BLACK COLOR_STR(CTRL_BLACK)
|
||||
|
||||
#else
|
||||
// For use in code files
|
||||
#define MSGCOL_DEFAULT HEX(CTRL_DEFAULT)
|
||||
#define MSGCOL_RED HEX(CTRL_RED)
|
||||
#define MSGCOL_ADJUSTABLE HEX(CTRL_ADJUSTABLE)
|
||||
#define MSGCOL_BLUE HEX(CTRL_BLUE)
|
||||
#define MSGCOL_LIGHTBLUE HEX(CTRL_LIGHTBLUE)
|
||||
#define MSGCOL_PURPLE HEX(CTRL_PURPLE)
|
||||
#define MSGCOL_YELLOW HEX(CTRL_YELLOW)
|
||||
#define MSGCOL_BLACK HEX(CTRL_BLACK)
|
||||
|
||||
#define MESSAGE_NEWLINE HEX(CTRL_NEWLINE)
|
||||
#define MESSAGE_END HEX(CTRL_END)
|
||||
#define MESSAGE_BOX_BREAK HEX(CTRL_BOX_BREAK)
|
||||
#define MESSAGE_COLOR HEX(CTRL_COLOR)
|
||||
#define MESSAGE_SHIFT HEX(CTRL_SHIFT)
|
||||
#define MESSAGE_TEXTID HEX(CTRL_TEXTID)
|
||||
#define MESSAGE_QUICKTEXT_ENABLE HEX(CTRL_QUICKTEXT_ENABLE)
|
||||
#define MESSAGE_QUICKTEXT_DISABLE HEX(CTRL_QUICKTEXT_DISABLE)
|
||||
#define MESSAGE_PERSISTENT HEX(CTRL_PERSISTENT)
|
||||
#define MESSAGE_EVENT HEX(CTRL_EVENT)
|
||||
#define MESSAGE_BOX_BREAK_DELAYED HEX(CTRL_BOX_BREAK_DELAYED)
|
||||
#define MESSAGE_AWAIT_BUTTON_PRESS HEX(CTRL_AWAIT_BUTTON_PRESS)
|
||||
#define MESSAGE_FADE HEX(CTRL_FADE)
|
||||
#define MESSAGE_NAME HEX(CTRL_NAME)
|
||||
#define MESSAGE_OCARINA HEX(CTRL_OCARINA)
|
||||
#define MESSAGE_FADE2 HEX(CTRL_FADE2)
|
||||
#define MESSAGE_SFX HEX(CTRL_SFX)
|
||||
#define MESSAGE_ITEM_ICON HEX(CTRL_ITEM_ICON)
|
||||
#define MESSAGE_TEXT_SPEED HEX(CTRL_TEXT_SPEED)
|
||||
#define MESSAGE_BACKGROUND HEX(CTRL_BACKGROUND)
|
||||
#define MESSAGE_MARATHON_TIME HEX(CTRL_MARATHON_TIME)
|
||||
#define MESSAGE_RACE_TIME HEX(CTRL_RACE_TIME)
|
||||
#define MESSAGE_POINTS HEX(CTRL_POINTS)
|
||||
#define MESSAGE_TOKENS HEX(CTRL_TOKENS)
|
||||
#define MESSAGE_UNSKIPPABLE HEX(CTRL_UNSKIPPABLE)
|
||||
#define MESSAGE_TWO_CHOICE HEX(CTRL_TWO_CHOICE)
|
||||
#define MESSAGE_THREE_CHOICE HEX(CTRL_THREE_CHOICE)
|
||||
#define MESSAGE_FISH_INFO HEX(CTRL_FISH_INFO)
|
||||
#define MESSAGE_HIGHSCORE HEX(CTRL_HIGHSCORE)
|
||||
#define MESSAGE_TIME HEX(CTRL_TIME)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue