#ifndef MESSAGE_DATA_FMT_NES_H
#define MESSAGE_DATA_FMT_NES_H

#include "sfx.h" // For sfx ids
/*
 * Text control characters
 */

#define MESSAGE_COLOR_DEFAULT 0x00
#define MESSAGE_COLOR_RED 0x01
#define MESSAGE_COLOR_GREEN 0x02
#define MESSAGE_COLOR_BLUE 0x03
#define MESSAGE_COLOR_YELLOW 0x04
#define MESSAGE_COLOR_LIGHTBLUE 0x05
#define MESSAGE_COLOR_PINK 0x06
#define MESSAGE_COLOR_SILVER 0x07
#define MESSAGE_COLOR_ORANGE 0x08
#define MESSAGE_TEXT_SPEED 0x0A // Note this should take an arg 0 to 6, but always just sets next decode char as 0
#define MESSAGE_HS_BOAT_ARCHERY 0x0B
#define MESSAGE_STRAY_FAIRIES 0x0C
#define MESSAGE_TOKENS 0x0D
#define MESSAGE_POINTS_TENS 0x0E
#define MESSAGE_POINTS_THOUSANDS 0x0F
#define MESSAGE_BOX_BREAK 0x10
#define MESSAGE_NEWLINE 0x11
#define MESSAGE_BOX_BREAK2 0x12
#define MESSAGE_CARRIAGE_RETURN 0x13
#define MESSAGE_SHIFT 0x14
#define MESSAGE_CONTINUE 0x15
#define MESSAGE_NAME 0x16
#define MESSAGE_QUICKTEXT_ENABLE 0x17
#define MESSAGE_QUICKTEXT_DISABLE 0x18
#define MESSAGE_EVENT 0x19
#define MESSAGE_PERSISTENT 0x1A
#define MESSAGE_BOX_BREAK_DELAYED 0x1B
#define MESSAGE_FADE 0x1C
#define MESSAGE_FADE_SKIPPABLE 0x1D
#define MESSAGE_SFX 0x1E
#define MESSAGE_DELAY 0x1F
#define MESSAGE_BTN_A 0xB0
#define MESSAGE_BTN_B 0xB1
#define MESSAGE_BTN_C 0xB2
#define MESSAGE_BTN_L 0xB3
#define MESSAGE_BTN_R 0xB4
#define MESSAGE_BTN_Z 0xB5
#define MESSAGE_BTN_CUP 0xB6
#define MESSAGE_BTN_CDOWN 0xB7
#define MESSAGE_BTN_CLEFT 0xB8
#define MESSAGE_BTN_CRIGHT 0xB9
#define MESSAGE_Z_TARGET 0xBA
#define MESSAGE_CONTROL_PAD 0xBB
#define MESSAGE_END 0xBF
#define MESSAGE_BACKGROUND 0xC1
#define MESSAGE_TWO_CHOICE 0xC2
#define MESSAGE_THREE_CHOICE 0xC3
#define MESSAGE_TIMER_POSTMAN 0xC4
#define MESSAGE_TIMER_MINIGAME_1 0xC5
#define MESSAGE_TIMER_2 0xC6
#define MESSAGE_TIMER_MOON_CRASH 0xC7
#define MESSAGE_TIMER_MINIGAME_2 0xC8
#define MESSAGE_TIMER_ENV_HAZARD 0xC9
#define MESSAGE_TIME 0xCA
#define MESSAGE_CHEST_FLAGS 0xCB
#define MESSAGE_INPUT_BANK 0xCC
#define MESSAGE_RUPEES_SELECTED 0xCD
#define MESSAGE_RUPEES_TOTAL 0xCE
#define MESSAGE_TIME_UNTIL_MOON_CRASH 0xCF
#define MESSAGE_INPUT_DOGGY_RACETRACK_BET 0xD0
#define MESSAGE_INPUT_BOMBER_CODE 0xD1
#define MESSAGE_PAUSE_MENU 0xD2
#define MESSAGE_TIME_SPEED 0xD3
#define MESSAGE_OWL_WARP 0xD4
#define MESSAGE_INPUT_LOTTERY_CODE 0xD5
#define MESSAGE_SPIDER_HOUSE_MASK_CODE 0xD6
#define MESSAGE_STRAY_FAIRIES_LEFT_WOODFALL 0xD7
#define MESSAGE_STRAY_FAIRIES_LEFT_SNOWHEAD 0xD8
#define MESSAGE_STRAY_FAIRIES_LEFT_GREAT_BAY 0xD9
#define MESSAGE_STRAY_FAIRIES_LEFT_STONE_TOWER 0xDA
#define MESSAGE_POINTS_BOAT_ARCHERY 0xDB // Seems to be the exact same as CTRL_POINTS_THOUSANDS
#define MESSAGE_LOTTERY_CODE 0xDC
#define MESSAGE_LOTTERY_CODE_GUESS 0xDD
#define MESSAGE_HELD_ITEM_PRICE 0xDE
#define MESSAGE_BOMBER_CODE 0xDF
#define MESSAGE_EVENT2 0xE0 // Seems to be the exact same as CTRL_EVENT
#define MESSAGE_SPIDER_HOUSE_MASK_CODE_1 0xE1
#define MESSAGE_SPIDER_HOUSE_MASK_CODE_2 0xE2
#define MESSAGE_SPIDER_HOUSE_MASK_CODE_3 0xE3
#define MESSAGE_SPIDER_HOUSE_MASK_CODE_4 0xE4
#define MESSAGE_SPIDER_HOUSE_MASK_CODE_5 0xE5
#define MESSAGE_SPIDER_HOUSE_MASK_CODE_6 0xE6
#define MESSAGE_HOURS_UNTIL_MOON_CRASH 0xE7
#define MESSAGE_TIME_UNTIL_NEW_DAY 0xE8
#define MESSAGE_HS_POINTS_BANK_RUPEES 0xF0
#define MESSAGE_HS_POINTS_UNK_1 0xF1
#define MESSAGE_HS_POINTS_FISHING 0xF2
#define MESSAGE_HS_TIME_BOAT_ARCHERY 0xF3 // Note this interprets the highscore value as a time (not the actual timer for the minigame)
#define MESSAGE_HS_TIME_HORSE_BACK_BALLOON 0xF4 // Note this interprets the highscore value as a time (not the actual timer for the minigame)
#define MESSAGE_HS_TIME_LOTTERY_GUESS 0xF5
#define MESSAGE_HS_TOWN_SHOOTING_GALLERY 0xF6
#define MESSAGE_HS_UNK_1 0xF7
#define MESSAGE_HS_UNK_3_LOWER 0xF8
#define MESSAGE_HS_HORSE_BACK_BALLOON 0xF9
#define MESSAGE_HS_DEKU_PLAYGROUND_DAY_1 0xFA
#define MESSAGE_HS_DEKU_PLAYGROUND_DAY_2 0xFB
#define MESSAGE_HS_DEKU_PLAYGROUND_DAY_3 0xFC
#define MESSAGE_DEKU_PLAYGROUND_NAME_DAY_1 0xFD
#define MESSAGE_DEKU_PLAYGROUND_NAME_DAY_2 0xFE
#define MESSAGE_DEKU_PLAYGROUND_NAME_DAY_3 0xFF

#ifdef MESSAGE_DATA_STATIC
// For use in message_data_static files

#define ARG1(x) (x),
#define ARG2(x) (((x) >> 8) & 0xFF), (((x) >> 0) & 0xFF),
#define CTRL_BASE(name) ARG1(MESSAGE_##name)

// For use in message_data_static files

// 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 }

// Not a control command, used to define the data that begins every message
#define HEADER(textBoxProperties, itemId, nextTextId, firstChoicePrice, secondChoicePrice, unk12074) \
    ARG2(textBoxProperties) ARG1(itemId) ARG2(nextTextId) ARG2(firstChoicePrice) ARG2(secondChoicePrice) ARG2(unk12074)

#define COLOR_DEFAULT CTRL_BASE(COLOR_DEFAULT)
#define COLOR_RED CTRL_BASE(COLOR_RED)
#define COLOR_GREEN CTRL_BASE(COLOR_GREEN)
#define COLOR_BLUE CTRL_BASE(COLOR_BLUE)
#define COLOR_YELLOW CTRL_BASE(COLOR_YELLOW)
#define COLOR_LIGHTBLUE CTRL_BASE(COLOR_LIGHTBLUE)
#define COLOR_PINK CTRL_BASE(COLOR_PINK)
#define COLOR_SILVER CTRL_BASE(COLOR_SILVER)
#define COLOR_ORANGE CTRL_BASE(COLOR_ORANGE)
#define TEXT_SPEED CTRL_BASE(TEXT_SPEED)
#define HS_BOAT_ARCHERY CTRL_BASE(HS_BOAT_ARCHERY)
#define STRAY_FAIRIES CTRL_BASE(STRAY_FAIRIES)
#define TOKENS CTRL_BASE(TOKENS)
#define POINTS_TENS CTRL_BASE(POINTS_TENS)
#define POINTS_THOUSANDS CTRL_BASE(POINTS_THOUSANDS)
#define BOX_BREAK CTRL_BASE(BOX_BREAK)
// 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 CTRL_BASE(NEWLINE)
#define BOX_BREAK2 CTRL_BASE(BOX_BREAK2)
#define CARRIAGE_RETURN CTRL_BASE(CARRIAGE_RETURN)
#define SHIFT(amount) CTRL_BASE(SHIFT) ARG1(amount)
#define CONTINUE CTRL_BASE(CONTINUE)
#define NAME CTRL_BASE(NAME)
#define QUICKTEXT_ENABLE CTRL_BASE(QUICKTEXT_ENABLE)
#define QUICKTEXT_DISABLE CTRL_BASE(QUICKTEXT_DISABLE)
#define EVENT CTRL_BASE(EVENT)
#define PERSISTENT CTRL_BASE(PERSISTENT)
#define BOX_BREAK_DELAYED(delay) CTRL_BASE(BOX_BREAK_DELAYED) ARG2(delay)
#define FADE(delay) CTRL_BASE(FADE) ARG2(delay)
#define FADE_SKIPPABLE(delay) CTRL_BASE(FADE_SKIPPABLE) ARG2(delay)
#define SFX(sfxId) CTRL_BASE(SFX) ARG2(sfxId)
#define DELAY(delay) CTRL_BASE(DELAY) ARG2(delay)
#define END CTRL_BASE(END)
#define BACKGROUND CTRL_BASE(BACKGROUND)
#define TWO_CHOICE CTRL_BASE(TWO_CHOICE)
#define THREE_CHOICE CTRL_BASE(THREE_CHOICE)
#define TIMER_POSTMAN CTRL_BASE(TIMER_POSTMAN)
#define TIMER_MINIGAME_1 CTRL_BASE(TIMER_MINIGAME_1)
#define TIMER_2 CTRL_BASE(TIMER_2)
#define TIMER_MOON_CRASH CTRL_BASE(TIMER_MOON_CRASH)
#define TIMER_MINIGAME_2 CTRL_BASE(TIMER_MINIGAME_2)
#define TIMER_ENV_HAZARD CTRL_BASE(TIMER_ENV_HAZARD)
#define TIME CTRL_BASE(TIME)
#define CHEST_FLAGS CTRL_BASE(CHEST_FLAGS)
#define INPUT_BANK CTRL_BASE(INPUT_BANK)
#define RUPEES_SELECTED CTRL_BASE(RUPEES_SELECTED)
#define RUPEES_TOTAL CTRL_BASE(RUPEES_TOTAL)
#define TIME_UNTIL_MOON_CRASH CTRL_BASE(TIME_UNTIL_MOON_CRASH)
#define INPUT_DOGGY_RACETRACK_BET CTRL_BASE(INPUT_DOGGY_RACETRACK_BET)
#define INPUT_BOMBER_CODE CTRL_BASE(INPUT_BOMBER_CODE)
#define PAUSE_MENU CTRL_BASE(PAUSE_MENU)
#define TIME_SPEED CTRL_BASE(TIME_SPEED)
#define OWL_WARP CTRL_BASE(OWL_WARP)
#define INPUT_LOTTERY_CODE CTRL_BASE(INPUT_LOTTERY_CODE)
#define SPIDER_HOUSE_MASK_CODE CTRL_BASE(SPIDER_HOUSE_MASK_CODE)
#define STRAY_FAIRIES_LEFT_WOODFALL CTRL_BASE(STRAY_FAIRIES_LEFT_WOODFALL)
#define STRAY_FAIRIES_LEFT_SNOWHEAD CTRL_BASE(STRAY_FAIRIES_LEFT_SNOWHEAD)
#define STRAY_FAIRIES_LEFT_GREAT_BAY CTRL_BASE(STRAY_FAIRIES_LEFT_GREAT_BAY)
#define STRAY_FAIRIES_LEFT_STONE_TOWER CTRL_BASE(STRAY_FAIRIES_LEFT_STONE_TOWER)
#define POINTS_BOAT_ARCHERY CTRL_BASE(POINTS_BOAT_ARCHERY)
#define LOTTERY_CODE CTRL_BASE(LOTTERY_CODE)
#define LOTTERY_CODE_GUESS CTRL_BASE(LOTTERY_CODE_GUESS)
#define HELD_ITEM_PRICE CTRL_BASE(HELD_ITEM_PRICE)
#define BOMBER_CODE CTRL_BASE(BOMBER_CODE)
#define EVENT2 CTRL_BASE(EVENT2)
#define SPIDER_HOUSE_MASK_CODE_1 CTRL_BASE(SPIDER_HOUSE_MASK_CODE_1)
#define SPIDER_HOUSE_MASK_CODE_2 CTRL_BASE(SPIDER_HOUSE_MASK_CODE_2)
#define SPIDER_HOUSE_MASK_CODE_3 CTRL_BASE(SPIDER_HOUSE_MASK_CODE_3)
#define SPIDER_HOUSE_MASK_CODE_4 CTRL_BASE(SPIDER_HOUSE_MASK_CODE_4)
#define SPIDER_HOUSE_MASK_CODE_5 CTRL_BASE(SPIDER_HOUSE_MASK_CODE_5)
#define SPIDER_HOUSE_MASK_CODE_6 CTRL_BASE(SPIDER_HOUSE_MASK_CODE_6)
#define HOURS_UNTIL_MOON_CRASH CTRL_BASE(HOURS_UNTIL_MOON_CRASH)
#define TIME_UNTIL_NEW_DAY CTRL_BASE(TIME_UNTIL_NEW_DAY)
#define HS_POINTS_BANK_RUPEES CTRL_BASE(HS_POINTS_BANK_RUPEES)
#define HS_POINTS_UNK_1 CTRL_BASE(HS_POINTS_UNK_1)
#define HS_POINTS_FISHING CTRL_BASE(HS_POINTS_FISHING)
#define HS_TIME_BOAT_ARCHERY CTRL_BASE(HS_TIME_BOAT_ARCHERY)
#define HS_TIME_HORSE_BACK_BALLOON CTRL_BASE(HS_TIME_HORSE_BACK_BALLOON)
#define HS_TIME_LOTTERY_GUESS CTRL_BASE(HS_TIME_LOTTERY_GUESS)
#define HS_TOWN_SHOOTING_GALLERY CTRL_BASE(HS_TOWN_SHOOTING_GALLERY)
#define HS_UNK_1 CTRL_BASE(HS_UNK_1)
#define HS_UNK_3_LOWER CTRL_BASE(HS_UNK_3_LOWER)
#define HS_HORSE_BACK_BALLOON CTRL_BASE(HS_HORSE_BACK_BALLOON)
#define HS_DEKU_PLAYGROUND_DAY_1 CTRL_BASE(HS_DEKU_PLAYGROUND_DAY_1)
#define HS_DEKU_PLAYGROUND_DAY_2 CTRL_BASE(HS_DEKU_PLAYGROUND_DAY_2)
#define HS_DEKU_PLAYGROUND_DAY_3 CTRL_BASE(HS_DEKU_PLAYGROUND_DAY_3)
#define DEKU_PLAYGROUND_NAME_DAY_1 CTRL_BASE(DEKU_PLAYGROUND_NAME_DAY_1)
#define DEKU_PLAYGROUND_NAME_DAY_2 CTRL_BASE(DEKU_PLAYGROUND_NAME_DAY_2)
#define DEKU_PLAYGROUND_NAME_DAY_3 CTRL_BASE(DEKU_PLAYGROUND_NAME_DAY_3)

#endif

#endif
