#!/usr/bin/env python3
#
#   Message Event Script Disassembler
#

import argparse, math, os, struct
from actor_symbols import resolve_symbol

cmd_info = [
    ('MSCRIPT_CMD_CHECK_WEEK_EVENT_REG', 0x05, '', '>Hh', (1,)),
    ('MSCRIPT_CMD_CHECK_GORON', 0x03, '', '>h', (0,)),
    ('MSCRIPT_CMD_CHECK_ZORA', 0x03, '', '>h', (0,)),
    ('MSCRIPT_CMD_CHECK_DEKU', 0x03, '', '>h', (0,)),
    ('MSCRIPT_CMD_CHECK_HUMAN', 0x03, '', '>h', (0,)),
    ('MSCRIPT_CMD_CHECK_TEXT_CHOICE', 0x07, '', '>hhh', (0,1,2)),
    ('MSCRIPT_CMD_OFFER_ITEM', 0x05, '', '>Hh', (1,)),
    ('MSCRIPT_CMD_AUTOTALK', 0x03, '', '>h', (0,)),
    ('MSCRIPT_CMD_CHECK_RUPEES', 0x05, '', '>Hh', (1,)),
    ('MSCRIPT_CMD_CHECK_CALLBACK', 0x03, '', '>h', (0,)),
    ('MSCRIPT_CMD_CHECK_DAY', 0x0d, '', '>hhhhhh', (0,1,2,3,4,5)),
    ('MSCRIPT_CMD_AWAIT_TEXT_JUMP', 0x03, '', '>h', (0,)),
    ('MSCRIPT_CMD_AWAIT_TEXT', 0x01, '', '', ()),
    ('MSCRIPT_CMD_AWAIT_TEXT_END', 0x01, '', '', ()),
    ('MSCRIPT_CMD_BEGIN_TEXT', 0x03, '', '>H', ()),
    ('MSCRIPT_CMD_CONTINUE_TEXT', 0x03, '', '>H', ()),
    ('MSCRIPT_CMD_DONE',  0x01, '', '', ()),
    ('MSCRIPT_CMD_SET_WEEK_EVENT_REG', 0x03, '', '>H', ()),
    ('MSCRIPT_CMD_CLOSE_TEXT', 0x01, '', '', ()),
    ('MSCRIPT_CMD_SET_COLLECTIBLE', 0x03, '', '>H', ()),
    ('MSCRIPT_CMD_CHANGE_RUPEES', 0x03, '', '>H', ()),
    ('MSCRIPT_CMD_PAUSE', 0x01, '', '', ()),
    ('MSCRIPT_CMD_UNSET_AUTOTALK', 0x01, '', '', ()),
    ('MSCRIPT_CMD_FOCUS_TO_CHILD', 0x01, '', '', ()),
    ('MSCRIPT_CMD_FOCUS_TO_SELF', 0x01, '', '', ()),
    ('MSCRIPT_CMD_JUMP', 0x03, '', '>h', (0,)),
    ('MSCRIPT_CMD_CHECK_QUEST_ITEM', 0x05, '', '>Hh', (1,)),
    ('MSCRIPT_CMD_CHECK_EVENT_INF', 0x05, '', '>Hh', (1,)),
    ('MSCRIPT_CMD_SET_EVENT_INF', 0x03, '', '>H', ()),
    ('MSCRIPT_CMD_UNSET_EVENT_INF', 0x03, '', '>H', ()),
    ('MSCRIPT_CMD_CHECK_ITEM_ACTION', 0x09, '', '>Hhhh', (1,2,3)),
    ('MSCRIPT_CMD_CHECK_HAS_SONG', 0x05, '', '>Hh', (1,)),
    ('MSCRIPT_CMD_CHECK_WORN_MASK', 0x05, '', '>Hh', (1,)),
    ('MSCRIPT_CMD_CHECK_AFTER_TIME', 0x05, '', '>BBh', (2,)),
    ('MSCRIPT_CMD_CHECK_BEFORE_TIME', 0x05, '', '>BBh', (2,)),
    ('MSCRIPT_CMD_CHECK_SWITCH_FLAG', 0x05, '', '>Hh', (1,)),
    ('MSCRIPT_CMD_SET_SWITCH_FLAG', 0x03, '', '>H', ()),
    ('MSCRIPT_CMD_CHECK_ITEM', 0x05, '', '>Hh', (1,)),
    ('MSCRIPT_CMD_BETWEEN_TIME', 0x07, '', '>BBBBh', (4,)),
    ('MSCRIPT_CMD_CHECK_IN_DAY', 0x05, '', '>Hh', (1,)),
    ('MSCRIPT_CMD_CHECK_CALLBACK_CONTINUE', 0x03, '', '>h', (0,)),
    ('MSCRIPT_CMD_CHECK_HAS_POWDER_KEG', 0x03, '', '>h', (0,)),
    ('MSCRIPT_CMD_DELETE_ITEM', 0x03, '', '>h', ()),
    ('MSCRIPT_CMD_CHECK_CALLBACK_MULTI', 0x07, '', '>hhh', (0,1,2)),
    ('MSCRIPT_CMD_PLAYER_TALK', 0x03, '', '>H', ()),
    ('MSCRIPT_CMD_NOTEBOOK_EVENT', 0x03, '', '>H', ()),
    ('MSCRIPT_CMD_AWAIT_TEXT_DONE', 0x01, '', '', ()),
    ('MSCRIPT_CMD_JUMP_3', 0x03, '', '>h', (0,)),
    ('MSCRIPT_CMD_PLAY_DECIDE', 0x01, '', '', ()),
    ('MSCRIPT_CMD_PLAY_CANCEL', 0x01, '', '', ()),
    ('MSCRIPT_CMD_PLAY_ERROR', 0x01, '', '', ()),
]

week_event_reg = {
    ( 0 << 8) | 0x01: "WEEKEVENTREG_00_01",
    ( 0 << 8) | 0x02: "WEEKEVENTREG_ENTERED_TERMINA_FIELD",
    ( 0 << 8) | 0x04: "WEEKEVENTREG_ENTERED_IKANA_GRAVEYARD",
    ( 0 << 8) | 0x08: "WEEKEVENTREG_ENTERED_ROMANI_RANCH",
    ( 0 << 8) | 0x10: "WEEKEVENTREG_ENTERED_GORMAN_TRACK",
    ( 0 << 8) | 0x20: "WEEKEVENTREG_ENTERED_MOUNTAIN_VILLAGE_WINTER",
    ( 0 << 8) | 0x40: "WEEKEVENTREG_ENTERED_GORON_SHRINE",
    ( 0 << 8) | 0x80: "WEEKEVENTREG_ENTERED_SNOWHEAD",
    ( 1 << 8) | 0x01: "WEEKEVENTREG_ENTERED_SOUTHERN_SWAMP_POISONED",
    ( 1 << 8) | 0x02: "WEEKEVENTREG_ENTERED_WOODFALL",
    ( 1 << 8) | 0x04: "WEEKEVENTREG_ENTERED_DEKU_PALACE",
    ( 1 << 8) | 0x08: "WEEKEVENTREG_ENTERED_GREAT_BAY_COAST",
    ( 1 << 8) | 0x10: "WEEKEVENTREG_ENTERED_PIRATES_FORTRESS",
    ( 1 << 8) | 0x20: "WEEKEVENTREG_ENTERED_ZORA_HALL",
    ( 1 << 8) | 0x40: "WEEKEVENTREG_ENTERED_WATERFALL_RAPIDS",
    ( 1 << 8) | 0x80: "WEEKEVENTREG_ENTERED_IKANA_CANYON",
    ( 2 << 8) | 0x01: "WEEKEVENTREG_ENTERED_IKANA_CASTLE",
    ( 2 << 8) | 0x02: "WEEKEVENTREG_ENTERED_STONE_TOWER",
    ( 2 << 8) | 0x04: "WEEKEVENTREG_ENTERED_STONE_TOWER_INVERTED",
    ( 2 << 8) | 0x08: "WEEKEVENTREG_ENTERED_EAST_CLOCK_TOWN",
    ( 2 << 8) | 0x10: "WEEKEVENTREG_ENTERED_WEST_CLOCK_TOWN",
    ( 2 << 8) | 0x20: "WEEKEVENTREG_ENTERED_NORTH_CLOCK_TOWN",
    ( 2 << 8) | 0x40: "WEEKEVENTREG_ENTERED_WOODFALL_TEMPLE",
    ( 2 << 8) | 0x80: "WEEKEVENTREG_ENTERED_SNOWHEAD_TEMPLE",
    ( 3 << 8) | 0x01: "WEEKEVENTREG_ENTERED_PIRATES_FORTRESS_EXTERIOR",
    ( 3 << 8) | 0x02: "WEEKEVENTREG_ENTERED_STONE_TOWER_TEMPLE",
    ( 3 << 8) | 0x04: "WEEKEVENTREG_ENTERED_STONE_TOWER_TEMPLE_INVERTED",
    ( 3 << 8) | 0x08: "WEEKEVENTREG_ENTERED_THE_MOON",
    ( 3 << 8) | 0x10: "WEEKEVENTREG_ENTERED_MOON_DEKU_TRIAL",
    ( 3 << 8) | 0x20: "WEEKEVENTREG_ENTERED_MOON_GORON_TRIAL",
    ( 3 << 8) | 0x40: "WEEKEVENTREG_ENTERED_MOON_ZORA_TRIAL",
    ( 3 << 8) | 0x80: "WEEKEVENTREG_03_80",
    ( 4 << 8) | 0x01: "WEEKEVENTREG_04_01",
    ( 4 << 8) | 0x02: "WEEKEVENTREG_04_02",
    ( 4 << 8) | 0x04: "WEEKEVENTREG_04_04",
    ( 4 << 8) | 0x08: "WEEKEVENTREG_04_08",
    ( 4 << 8) | 0x10: "WEEKEVENTREG_04_10",
    ( 4 << 8) | 0x20: "WEEKEVENTREG_04_20",
    ( 4 << 8) | 0x40: "WEEKEVENTREG_04_40",
    ( 4 << 8) | 0x80: "WEEKEVENTREG_04_80",
    ( 5 << 8) | 0x01: "WEEKEVENTREG_05_01",
    ( 5 << 8) | 0x02: "WEEKEVENTREG_05_02",
    ( 5 << 8) | 0x04: "WEEKEVENTREG_05_04",
    ( 5 << 8) | 0x08: "WEEKEVENTREG_05_08",
    ( 5 << 8) | 0x10: "WEEKEVENTREG_05_10",
    ( 5 << 8) | 0x20: "WEEKEVENTREG_05_20",
    ( 5 << 8) | 0x40: "WEEKEVENTREG_05_40",
    ( 5 << 8) | 0x80: "WEEKEVENTREG_05_80",
    ( 6 << 8) | 0x01: "WEEKEVENTREG_06_01",
    ( 6 << 8) | 0x02: "WEEKEVENTREG_06_02",
    ( 6 << 8) | 0x04: "WEEKEVENTREG_06_04",
    ( 6 << 8) | 0x08: "WEEKEVENTREG_06_08",
    ( 6 << 8) | 0x10: "WEEKEVENTREG_06_10",
    ( 6 << 8) | 0x20: "WEEKEVENTREG_06_20",
    ( 6 << 8) | 0x40: "WEEKEVENTREG_06_40",
    ( 6 << 8) | 0x80: "WEEKEVENTREG_06_80",
    ( 7 << 8) | 0x01: "WEEKEVENTREG_07_01",
    ( 7 << 8) | 0x02: "WEEKEVENTREG_07_02",
    ( 7 << 8) | 0x04: "WEEKEVENTREG_07_04",
    ( 7 << 8) | 0x08: "WEEKEVENTREG_07_08",
    ( 7 << 8) | 0x10: "WEEKEVENTREG_07_10",
    ( 7 << 8) | 0x20: "WEEKEVENTREG_07_20",
    ( 7 << 8) | 0x40: "WEEKEVENTREG_07_40",
    ( 7 << 8) | 0x80: "WEEKEVENTREG_ENTERED_WOODFALL_TEMPLE_PRISON",
    ( 8 << 8) | 0x01: "WEEKEVENTREG_08_01",
    ( 8 << 8) | 0x02: "WEEKEVENTREG_08_02",
    ( 8 << 8) | 0x04: "WEEKEVENTREG_08_04",
    ( 8 << 8) | 0x08: "WEEKEVENTREG_08_08",
    ( 8 << 8) | 0x10: "WEEKEVENTREG_08_10",
    ( 8 << 8) | 0x20: "WEEKEVENTREG_RECEIVED_DOGGY_RACETRACK_HEART_PIECE",
    ( 8 << 8) | 0x40: "WEEKEVENTREG_CLOCK_TOWER_OPENED",
    ( 8 << 8) | 0x80: "WEEKEVENTREG_08_80",
    ( 9 << 8) | 0x01: "WEEKEVENTREG_09_01",
    ( 9 << 8) | 0x02: "WEEKEVENTREG_09_02",
    ( 9 << 8) | 0x04: "WEEKEVENTREG_09_04",
    ( 9 << 8) | 0x08: "WEEKEVENTREG_09_08",
    ( 9 << 8) | 0x10: "WEEKEVENTREG_09_10",
    ( 9 << 8) | 0x20: "WEEKEVENTREG_09_20",
    ( 9 << 8) | 0x40: "WEEKEVENTREG_09_40",
    ( 9 << 8) | 0x80: "WEEKEVENTREG_09_80",
    (10 << 8) | 0x01: "WEEKEVENTREG_TALKED_TINGLE",
    (10 << 8) | 0x02: "WEEKEVENTREG_10_02",
    (10 << 8) | 0x04: "WEEKEVENTREG_10_04",
    (10 << 8) | 0x08: "WEEKEVENTREG_RECEIVED_BANK_WALLET_UPGRADE",
    (10 << 8) | 0x10: "WEEKEVENTREG_10_10",
    (10 << 8) | 0x20: "WEEKEVENTREG_10_20",
    (10 << 8) | 0x40: "WEEKEVENTREG_10_40",
    (10 << 8) | 0x80: "WEEKEVENTREG_10_80",
    (11 << 8) | 0x01: "WEEKEVENTREG_11_01",
    (11 << 8) | 0x02: "WEEKEVENTREG_11_02",
    (11 << 8) | 0x04: "WEEKEVENTREG_11_04",
    (11 << 8) | 0x08: "WEEKEVENTREG_11_08",
    (11 << 8) | 0x10: "WEEKEVENTREG_11_10",
    (11 << 8) | 0x20: "WEEKEVENTREG_11_20",
    (11 << 8) | 0x40: "WEEKEVENTREG_11_40",
    (11 << 8) | 0x80: "WEEKEVENTREG_11_80",
    (12 << 8) | 0x01: "WEEKEVENTREG_12_01",
    (12 << 8) | 0x02: "WEEKEVENTREG_12_02",
    (12 << 8) | 0x04: "WEEKEVENTREG_12_04",
    (12 << 8) | 0x08: "WEEKEVENTREG_SAVED_KOUME",
    (12 << 8) | 0x10: "WEEKEVENTREG_RECEIVED_KOTAKE_BOTTLE",
    (12 << 8) | 0x20: "WEEKEVENTREG_12_20",
    (12 << 8) | 0x40: "WEEKEVENTREG_12_40",
    (12 << 8) | 0x80: "WEEKEVENTREG_12_80",
    (13 << 8) | 0x01: "WEEKEVENTREG_13_01",
    (13 << 8) | 0x02: "WEEKEVENTREG_13_02",
    (13 << 8) | 0x04: "WEEKEVENTREG_13_04",
    (13 << 8) | 0x08: "WEEKEVENTREG_13_08",
    (13 << 8) | 0x10: "WEEKEVENTREG_13_10",
    (13 << 8) | 0x20: "WEEKEVENTREG_OCEANSIDE_SPIDER_HOUSE_BUYER_MOVED_IN",
    (13 << 8) | 0x40: "WEEKEVENTREG_RECEIVED_OCEANSIDE_WALLET_UPGRADE",
    (13 << 8) | 0x80: "WEEKEVENTREG_OCEANSIDE_SPIDER_HOUSE_COLLECTED_REWARD",
    (14 << 8) | 0x01: "WEEKEVENTREG_14_01",
    (14 << 8) | 0x02: "WEEKEVENTREG_SHARP_HOSTILE_CONVERSATION",
    (14 << 8) | 0x04: "WEEKEVENTREG_IKANA_SPRING_RESTORED",
    (14 << 8) | 0x08: "WEEKEVENTREG_DRANK_CHATEAU_ROMANI",
    (14 << 8) | 0x10: "WEEKEVENTREG_WON_DEKU_PLAYGROUND_DAY_1",
    (14 << 8) | 0x20: "WEEKEVENTREG_WON_DEKU_PLAYGROUND_DAY_2",
    (14 << 8) | 0x40: "WEEKEVENTREG_WON_DEKU_PLAYGROUND_DAY_3",
    (14 << 8) | 0x80: "WEEKEVENTREG_RECEIVED_DEKU_PLAYGROUND_HEART_PIECE",
    (15 << 8) | 0x01: "WEEKEVENTREG_15_01",
    (15 << 8) | 0x02: "WEEKEVENTREG_15_02",
    (15 << 8) | 0x04: "WEEKEVENTREG_15_04",
    (15 << 8) | 0x08: "WEEKEVENTREG_15_08",
    (15 << 8) | 0x10: "WEEKEVENTREG_15_10",
    (15 << 8) | 0x20: "WEEKEVENTREG_15_20",
    (15 << 8) | 0x40: "WEEKEVENTREG_15_40",
    (15 << 8) | 0x80: "WEEKEVENTREG_15_80",
    (16 << 8) | 0x01: "WEEKEVENTREG_16_01",
    (16 << 8) | 0x02: "WEEKEVENTREG_16_02",
    (16 << 8) | 0x04: "WEEKEVENTREG_16_04",
    (16 << 8) | 0x08: "WEEKEVENTREG_16_08",
    (16 << 8) | 0x10: "WEEKEVENTREG_TALKED_KOUME_INJURED",
    (16 << 8) | 0x20: "WEEKEVENTREG_16_20",
    (16 << 8) | 0x40: "WEEKEVENTREG_16_40",
    (16 << 8) | 0x80: "WEEKEVENTREG_16_80",
    (17 << 8) | 0x01: "WEEKEVENTREG_TALKED_KOUME_KIOSK_EMPTY",
    (17 << 8) | 0x02: "WEEKEVENTREG_17_02",
    (17 << 8) | 0x04: "WEEKEVENTREG_17_04",
    (17 << 8) | 0x08: "WEEKEVENTREG_17_08",
    (17 << 8) | 0x10: "WEEKEVENTREG_17_10",
    (17 << 8) | 0x20: "WEEKEVENTREG_17_20",
    (17 << 8) | 0x40: "WEEKEVENTREG_17_40",
    (17 << 8) | 0x80: "WEEKEVENTREG_RECEIVED_LAND_TITLE_DEED",
    (18 << 8) | 0x01: "WEEKEVENTREG_18_01",
    (18 << 8) | 0x02: "WEEKEVENTREG_18_02",
    (18 << 8) | 0x04: "WEEKEVENTREG_TALKED_CURIOSITY_SHOP_MAN_AS_GORON",
    (18 << 8) | 0x08: "WEEKEVENTREG_TALKED_CURIOSITY_SHOP_MAN_AS_ZORA",
    (18 << 8) | 0x10: "WEEKEVENTREG_TALKED_CURIOSITY_SHOP_MAN_AS_DEKU",
    (18 << 8) | 0x20: "WEEKEVENTREG_18_20",
    (18 << 8) | 0x40: "WEEKEVENTREG_18_40",
    (18 << 8) | 0x80: "WEEKEVENTREG_HAS_POWDERKEG_PRIVILEGES",
    (19 << 8) | 0x01: "WEEKEVENTREG_19_01",
    (19 << 8) | 0x02: "WEEKEVENTREG_19_02",
    (19 << 8) | 0x04: "WEEKEVENTREG_19_04",
    (19 << 8) | 0x08: "WEEKEVENTREG_19_08",
    (19 << 8) | 0x10: "WEEKEVENTREG_19_10",
    (19 << 8) | 0x20: "WEEKEVENTREG_19_20",
    (19 << 8) | 0x40: "WEEKEVENTREG_19_40",
    (19 << 8) | 0x80: "WEEKEVENTREG_19_80",
    (20 << 8) | 0x01: "WEEKEVENTREG_20_01",
    (20 << 8) | 0x02: "WEEKEVENTREG_CLEARED_WOODFALL_TEMPLE",
    (20 << 8) | 0x04: "WEEKEVENTREG_20_04",
    (20 << 8) | 0x08: "WEEKEVENTREG_20_08",
    (20 << 8) | 0x10: "WEEKEVENTREG_20_10",
    (20 << 8) | 0x20: "WEEKEVENTREG_20_20",
    (20 << 8) | 0x40: "WEEKEVENTREG_20_40",
    (20 << 8) | 0x80: "WEEKEVENTREG_20_80",
    (21 << 8) | 0x01: "WEEKEVENTREG_21_01",
    (21 << 8) | 0x02: "WEEKEVENTREG_21_02",
    (21 << 8) | 0x04: "WEEKEVENTREG_TALKED_GORON_GRAVEMAKER_AS_GORON",
    (21 << 8) | 0x08: "WEEKEVENTREG_TALKED_THAWED_GRAVEYARD_GORON",
    (21 << 8) | 0x10: "WEEKEVENTREG_21_10",
    (21 << 8) | 0x20: "WEEKEVENTREG_PROMISED_TO_HELP_WITH_ALIENS",
    (21 << 8) | 0x40: "WEEKEVENTREG_21_40",
    (21 << 8) | 0x80: "WEEKEVENTREG_21_80",
    (22 << 8) | 0x01: "WEEKEVENTREG_DEFENDED_AGAINST_ALIENS",
    (22 << 8) | 0x02: "WEEKEVENTREG_RECEIVED_ALIENS_BOTTLE",
    (22 << 8) | 0x04: "WEEKEVENTREG_CALMED_GORON_ELDERS_SON",
    (22 << 8) | 0x08: "WEEKEVENTREG_22_08",
    (22 << 8) | 0x10: "WEEKEVENTREG_22_10",
    (22 << 8) | 0x20: "WEEKEVENTREG_22_20",
    (22 << 8) | 0x40: "WEEKEVENTREG_22_40",
    (22 << 8) | 0x80: "WEEKEVENTREG_RECEIVED_HONEY_AND_DARLING_HEART_PIECE",
    (23 << 8) | 0x01: "WEEKEVENTREG_23_01",
    (23 << 8) | 0x02: "WEEKEVENTREG_RECEIVED_GREAT_SPIN_ATTACK",
    (23 << 8) | 0x04: "WEEKEVENTREG_23_04",
    (23 << 8) | 0x08: "WEEKEVENTREG_23_08",
    (23 << 8) | 0x10: "WEEKEVENTREG_23_10",
    (23 << 8) | 0x20: "WEEKEVENTREG_23_20",
    (23 << 8) | 0x40: "WEEKEVENTREG_23_40",
    (23 << 8) | 0x80: "WEEKEVENTREG_RECEIVED_BEAVER_RACE_BOTTLE",
    (24 << 8) | 0x01: "WEEKEVENTREG_24_01",
    (24 << 8) | 0x02: "WEEKEVENTREG_24_02",
    (24 << 8) | 0x04: "WEEKEVENTREG_24_04",
    (24 << 8) | 0x08: "WEEKEVENTREG_24_08",
    (24 << 8) | 0x10: "WEEKEVENTREG_24_10",
    (24 << 8) | 0x20: "WEEKEVENTREG_24_20",
    (24 << 8) | 0x40: "WEEKEVENTREG_24_40",
    (24 << 8) | 0x80: "WEEKEVENTREG_24_80",
    (25 << 8) | 0x01: "WEEKEVENTREG_RECEIVED_BEAVER_BROS_HEART_PIECE",
    (25 << 8) | 0x02: "WEEKEVENTREG_25_02",
    (25 << 8) | 0x04: "WEEKEVENTREG_25_04",
    (25 << 8) | 0x08: "WEEKEVENTREG_25_08",
    (25 << 8) | 0x10: "WEEKEVENTREG_25_10",
    (25 << 8) | 0x20: "WEEKEVENTREG_25_20",
    (25 << 8) | 0x40: "WEEKEVENTREG_25_40",
    (25 << 8) | 0x80: "WEEKEVENTREG_25_80",
    (26 << 8) | 0x01: "WEEKEVENTREG_26_01",
    (26 << 8) | 0x02: "WEEKEVENTREG_26_02",
    (26 << 8) | 0x04: "WEEKEVENTREG_26_04",
    (26 << 8) | 0x08: "WEEKEVENTREG_26_08",
    (26 << 8) | 0x10: "WEEKEVENTREG_26_10",
    (26 << 8) | 0x20: "WEEKEVENTREG_26_20",
    (26 << 8) | 0x40: "WEEKEVENTREG_26_40",
    (26 << 8) | 0x80: "WEEKEVENTREG_26_80",
    (27 << 8) | 0x01: "WEEKEVENTREG_27_01",
    (27 << 8) | 0x02: "WEEKEVENTREG_DEPOSITED_LETTER_TO_KAFEI_SOUTH_UPPER_CLOCKTOWN",
    (27 << 8) | 0x04: "WEEKEVENTREG_DEPOSITED_LETTER_TO_KAFEI_NORTH_CLOCKTOWN",
    (27 << 8) | 0x08: "WEEKEVENTREG_DEPOSITED_LETTER_TO_KAFEI_EAST_UPPER_CLOCKTOWN",
    (27 << 8) | 0x10: "WEEKEVENTREG_DEPOSITED_LETTER_TO_KAFEI_EAST_LOWER_CLOCKTOWN",
    (27 << 8) | 0x20: "WEEKEVENTREG_DEPOSITED_LETTER_TO_KAFEI_SOUTH_LOWER_CLOCKTOWN",
    (27 << 8) | 0x40: "WEEKEVENTREG_POSTMAN_CHECKED_SOUTH_UPPER_CLOCKTOWN",
    (27 << 8) | 0x80: "WEEKEVENTREG_POSTMAN_CHECKED_NORTH_CLOCKTOWN",
    (28 << 8) | 0x01: "WEEKEVENTREG_POSTMAN_CHECKED_EAST_UPPER_CLOCKTOWN",
    (28 << 8) | 0x02: "WEEKEVENTREG_POSTMAN_CHECKED_EAST_LOWER_CLOCKTOWN",
    (28 << 8) | 0x04: "WEEKEVENTREG_POSTMAN_CHECKED_SOUTH_LOWER_CLOCKTOWN",
    (28 << 8) | 0x08: "WEEKEVENTREG_LETTER_TO_KAFEI_SCHEDULED_DAY_2",
    (28 << 8) | 0x10: "WEEKEVENTREG_LETTER_TO_KAFEI_SCHEDULED_DAY_3",
    (28 << 8) | 0x20: "WEEKEVENTREG_28_20",
    (28 << 8) | 0x40: "WEEKEVENTREG_28_40",
    (28 << 8) | 0x80: "WEEKEVENTREG_28_80",
    (29 << 8) | 0x01: "WEEKEVENTREG_29_01",
    (29 << 8) | 0x02: "WEEKEVENTREG_29_02",
    (29 << 8) | 0x04: "WEEKEVENTREG_29_04",
    (29 << 8) | 0x08: "WEEKEVENTREG_29_08",
    (29 << 8) | 0x10: "WEEKEVENTREG_29_10",
    (29 << 8) | 0x20: "WEEKEVENTREG_29_20",
    (29 << 8) | 0x40: "WEEKEVENTREG_29_40",
    (29 << 8) | 0x80: "WEEKEVENTREG_29_80",
    (30 << 8) | 0x01: "WEEKEVENTREG_30_01",
    (30 << 8) | 0x02: "WEEKEVENTREG_30_02",
    (30 << 8) | 0x04: "WEEKEVENTREG_30_04",
    (30 << 8) | 0x08: "WEEKEVENTREG_30_08",
    (30 << 8) | 0x10: "WEEKEVENTREG_30_10",
    (30 << 8) | 0x20: "WEEKEVENTREG_30_20",
    (30 << 8) | 0x40: "WEEKEVENTREG_30_40",
    (30 << 8) | 0x80: "WEEKEVENTREG_30_80",
    (31 << 8) | 0x01: "WEEKEVENTREG_31_01",
    (31 << 8) | 0x02: "WEEKEVENTREG_31_02",
    (31 << 8) | 0x04: "WEEKEVENTREG_31_04",
    (31 << 8) | 0x08: "WEEKEVENTREG_31_08",
    (31 << 8) | 0x10: "WEEKEVENTREG_31_10",
    (31 << 8) | 0x20: "WEEKEVENTREG_31_20",
    (31 << 8) | 0x40: "WEEKEVENTREG_31_40",
    (31 << 8) | 0x80: "WEEKEVENTREG_31_80",
    (32 << 8) | 0x01: "WEEKEVENTREG_RECEIVED_SEAHORSE_HEART_PIECE",
    (32 << 8) | 0x02: "WEEKEVENTREG_RECEIVED_SWAMP_SHOOTING_GALLERY_HEART_PIECE",
    (32 << 8) | 0x04: "WEEKEVENTREG_RECEIVED_TOWN_SHOOTING_GALLERY_HEART_PIECE",
    (32 << 8) | 0x08: "WEEKEVENTREG_32_08",
    (32 << 8) | 0x10: "WEEKEVENTREG_32_10",
    (32 << 8) | 0x20: "WEEKEVENTREG_32_20",
    (32 << 8) | 0x40: "WEEKEVENTREG_32_40",
    (32 << 8) | 0x80: "WEEKEVENTREG_32_80",
    (33 << 8) | 0x01: "WEEKEVENTREG_33_01",
    (33 << 8) | 0x02: "WEEKEVENTREG_33_02",
    (33 << 8) | 0x04: "WEEKEVENTREG_BOUGHT_CURIOSITY_SHOP_SPECIAL_ITEM",
    (33 << 8) | 0x08: "WEEKEVENTREG_RECOVERED_STOLEN_BOMB_BAG",
    (33 << 8) | 0x10: "WEEKEVENTREG_33_10",
    (33 << 8) | 0x20: "WEEKEVENTREG_33_20",
    (33 << 8) | 0x40: "WEEKEVENTREG_33_40",
    (33 << 8) | 0x80: "WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE",
    (34 << 8) | 0x01: "WEEKEVENTREG_34_01",
    (34 << 8) | 0x02: "WEEKEVENTREG_34_02",
    (34 << 8) | 0x04: "WEEKEVENTREG_34_04",
    (34 << 8) | 0x08: "WEEKEVENTREG_TALKED_SWAMP_SPIDER_HOUSE_MAN",
    (34 << 8) | 0x10: "WEEKEVENTREG_34_10",
    (34 << 8) | 0x20: "WEEKEVENTREG_34_20",
    (34 << 8) | 0x40: "WEEKEVENTREG_RECEIVED_MASK_OF_TRUTH",
    (34 << 8) | 0x80: "WEEKEVENTREG_34_80",
    (35 << 8) | 0x01: "WEEKEVENTREG_TINGLE_MAP_BOUGHT_CLOCK_TOWN",
    (35 << 8) | 0x02: "WEEKEVENTREG_TINGLE_MAP_BOUGHT_WOODFALL",
    (35 << 8) | 0x04: "WEEKEVENTREG_TINGLE_MAP_BOUGHT_SNOWHEAD",
    (35 << 8) | 0x08: "WEEKEVENTREG_TINGLE_MAP_BOUGHT_ROMANI_RANCH",
    (35 << 8) | 0x10: "WEEKEVENTREG_TINGLE_MAP_BOUGHT_GREAT_BAY",
    (35 << 8) | 0x20: "WEEKEVENTREG_TINGLE_MAP_BOUGHT_STONE_TOWER",
    (35 << 8) | 0x40: "WEEKEVENTREG_35_40",
    (35 << 8) | 0x80: "WEEKEVENTREG_RECEIVED_FROG_CHOIR_HEART_PIECE",
    (36 << 8) | 0x01: "WEEKEVENTREG_36_01",
    (36 << 8) | 0x02: "WEEKEVENTREG_36_02",
    (36 << 8) | 0x04: "WEEKEVENTREG_36_04",
    (36 << 8) | 0x08: "WEEKEVENTREG_36_08",
    (36 << 8) | 0x10: "WEEKEVENTREG_36_10",
    (36 << 8) | 0x20: "WEEKEVENTREG_36_20",
    (36 << 8) | 0x40: "WEEKEVENTREG_36_40",
    (36 << 8) | 0x80: "WEEKEVENTREG_36_80",
    (37 << 8) | 0x01: "WEEKEVENTREG_37_01",
    (37 << 8) | 0x02: "WEEKEVENTREG_37_02",
    (37 << 8) | 0x04: "WEEKEVENTREG_37_04",
    (37 << 8) | 0x08: "WEEKEVENTREG_37_08",
    (37 << 8) | 0x10: "WEEKEVENTREG_37_10",
    (37 << 8) | 0x20: "WEEKEVENTREG_37_20",
    (37 << 8) | 0x40: "WEEKEVENTREG_37_40",
    (37 << 8) | 0x80: "WEEKEVENTREG_37_80",
    (38 << 8) | 0x01: "WEEKEVENTREG_38_01",
    (38 << 8) | 0x02: "WEEKEVENTREG_38_02",
    (38 << 8) | 0x04: "WEEKEVENTREG_38_04",
    (38 << 8) | 0x08: "WEEKEVENTREG_38_08",
    (38 << 8) | 0x10: "WEEKEVENTREG_38_10",
    (38 << 8) | 0x20: "WEEKEVENTREG_38_20",
    (38 << 8) | 0x40: "WEEKEVENTREG_38_40",
    (38 << 8) | 0x80: "WEEKEVENTREG_38_80",
    (39 << 8) | 0x01: "WEEKEVENTREG_39_01",
    (39 << 8) | 0x02: "WEEKEVENTREG_39_02",
    (39 << 8) | 0x04: "WEEKEVENTREG_39_04",
    (39 << 8) | 0x08: "WEEKEVENTREG_39_08",
    (39 << 8) | 0x10: "WEEKEVENTREG_39_10",
    (39 << 8) | 0x20: "WEEKEVENTREG_RECEIVED_EVAN_HEART_PIECE",
    (39 << 8) | 0x40: "WEEKEVENTREG_39_40",
    (39 << 8) | 0x80: "WEEKEVENTREG_39_80",
    (40 << 8) | 0x01: "WEEKEVENTREG_40_01",
    (40 << 8) | 0x02: "WEEKEVENTREG_40_02",
    (40 << 8) | 0x04: "WEEKEVENTREG_40_04",
    (40 << 8) | 0x08: "WEEKEVENTREG_40_08",
    (40 << 8) | 0x10: "WEEKEVENTREG_40_10",
    (40 << 8) | 0x20: "WEEKEVENTREG_40_20",
    (40 << 8) | 0x40: "WEEKEVENTREG_40_40",
    (40 << 8) | 0x80: "WEEKEVENTREG_40_80",
    (41 << 8) | 0x01: "WEEKEVENTREG_41_01",
    (41 << 8) | 0x02: "WEEKEVENTREG_41_02",
    (41 << 8) | 0x04: "WEEKEVENTREG_41_04",
    (41 << 8) | 0x08: "WEEKEVENTREG_RECEIVED_GORON_RACE_BOTTLE",
    (41 << 8) | 0x10: "WEEKEVENTREG_41_10",
    (41 << 8) | 0x20: "WEEKEVENTREG_41_20",
    (41 << 8) | 0x40: "WEEKEVENTREG_41_40",
    (41 << 8) | 0x80: "WEEKEVENTREG_41_80",
    (42 << 8) | 0x01: "WEEKEVENTREG_42_01",
    (42 << 8) | 0x02: "WEEKEVENTREG_42_02",
    (42 << 8) | 0x04: "WEEKEVENTREG_42_04",
    (42 << 8) | 0x08: "WEEKEVENTREG_42_08",
    (42 << 8) | 0x10: "WEEKEVENTREG_42_10",
    (42 << 8) | 0x20: "WEEKEVENTREG_42_20",
    (42 << 8) | 0x40: "WEEKEVENTREG_42_40",
    (42 << 8) | 0x80: "WEEKEVENTREG_42_80",
    (43 << 8) | 0x01: "WEEKEVENTREG_43_01",
    (43 << 8) | 0x02: "WEEKEVENTREG_43_02",
    (43 << 8) | 0x04: "WEEKEVENTREG_43_04",
    (43 << 8) | 0x08: "WEEKEVENTREG_43_08",
    (43 << 8) | 0x10: "WEEKEVENTREG_43_10",
    (43 << 8) | 0x20: "WEEKEVENTREG_43_20",
    (43 << 8) | 0x40: "WEEKEVENTREG_43_40",
    (43 << 8) | 0x80: "WEEKEVENTREG_43_80",
    (44 << 8) | 0x01: "WEEKEVENTREG_44_01",
    (44 << 8) | 0x02: "WEEKEVENTREG_44_02",
    (44 << 8) | 0x04: "WEEKEVENTREG_44_04",
    (44 << 8) | 0x08: "WEEKEVENTREG_44_08",
    (44 << 8) | 0x10: "WEEKEVENTREG_44_10",
    (44 << 8) | 0x20: "WEEKEVENTREG_44_20",
    (44 << 8) | 0x40: "WEEKEVENTREG_44_40",
    (44 << 8) | 0x80: "WEEKEVENTREG_44_80",
    (45 << 8) | 0x01: "WEEKEVENTREG_45_01",
    (45 << 8) | 0x02: "WEEKEVENTREG_45_02",
    (45 << 8) | 0x04: "WEEKEVENTREG_45_04",
    (45 << 8) | 0x08: "WEEKEVENTREG_45_08",
    (45 << 8) | 0x10: "WEEKEVENTREG_45_10",
    (45 << 8) | 0x20: "WEEKEVENTREG_45_20",
    (45 << 8) | 0x40: "WEEKEVENTREG_45_40",
    (45 << 8) | 0x80: "WEEKEVENTREG_45_80",
    (46 << 8) | 0x01: "WEEKEVENTREG_46_01",
    (46 << 8) | 0x02: "WEEKEVENTREG_46_02",
    (46 << 8) | 0x04: "WEEKEVENTREG_46_04",
    (46 << 8) | 0x08: "WEEKEVENTREG_46_08",
    (46 << 8) | 0x10: "WEEKEVENTREG_46_10",
    (46 << 8) | 0x20: "WEEKEVENTREG_46_20",
    (46 << 8) | 0x40: "WEEKEVENTREG_46_40",
    (46 << 8) | 0x80: "WEEKEVENTREG_46_80",
    (47 << 8) | 0x01: "WEEKEVENTREG_47_01",
    (47 << 8) | 0x02: "WEEKEVENTREG_47_02",
    (47 << 8) | 0x04: "WEEKEVENTREG_47_04",
    (47 << 8) | 0x08: "WEEKEVENTREG_47_08",
    (47 << 8) | 0x10: "WEEKEVENTREG_47_10",
    (47 << 8) | 0x20: "WEEKEVENTREG_47_20",
    (47 << 8) | 0x40: "WEEKEVENTREG_47_40",
    (47 << 8) | 0x80: "WEEKEVENTREG_47_80",
    (48 << 8) | 0x01: "WEEKEVENTREG_48_01",
    (48 << 8) | 0x02: "WEEKEVENTREG_48_02",
    (48 << 8) | 0x04: "WEEKEVENTREG_48_04",
    (48 << 8) | 0x08: "WEEKEVENTREG_48_08",
    (48 << 8) | 0x10: "WEEKEVENTREG_48_10",
    (48 << 8) | 0x20: "WEEKEVENTREG_48_20",
    (48 << 8) | 0x40: "WEEKEVENTREG_48_40",
    (48 << 8) | 0x80: "WEEKEVENTREG_48_80",
    (49 << 8) | 0x01: "WEEKEVENTREG_49_01",
    (49 << 8) | 0x02: "WEEKEVENTREG_49_02",
    (49 << 8) | 0x04: "WEEKEVENTREG_49_04",
    (49 << 8) | 0x08: "WEEKEVENTREG_49_08",
    (49 << 8) | 0x10: "WEEKEVENTREG_49_10",
    (49 << 8) | 0x20: "WEEKEVENTREG_49_20",
    (49 << 8) | 0x40: "WEEKEVENTREG_49_40",
    (49 << 8) | 0x80: "WEEKEVENTREG_49_80",
    (50 << 8) | 0x01: "WEEKEVENTREG_50_01",
    (50 << 8) | 0x02: "WEEKEVENTREG_50_02",
    (50 << 8) | 0x04: "WEEKEVENTREG_50_04",
    (50 << 8) | 0x08: "WEEKEVENTREG_PROMISED_MIDNIGHT_MEETING",
    (50 << 8) | 0x10: "WEEKEVENTREG_50_10",
    (50 << 8) | 0x20: "WEEKEVENTREG_HAD_MIDNIGHT_MEETING",
    (50 << 8) | 0x40: "WEEKEVENTREG_50_40",
    (50 << 8) | 0x80: "WEEKEVENTREG_RECEIVED_PENDANT_OF_MEMORIES",
    (51 << 8) | 0x01: "WEEKEVENTREG_DELIVERED_PENDANT_OF_MEMORIES",
    (51 << 8) | 0x02: "WEEKEVENTREG_LETTER_TO_KAFEI_SCHEDULED_TODAY",
    (51 << 8) | 0x04: "WEEKEVENTREG_HIT_LAUNDRY_POOL_BELL",
    (51 << 8) | 0x08: "WEEKEVENTREG_KAFEI_ENTRUSTED_LINK",
    (51 << 8) | 0x10: "WEEKEVENTREG_51_10",
    (51 << 8) | 0x20: "WEEKEVENTREG_ESCAPED_SAKONS_HIDEOUT",
    (51 << 8) | 0x40: "WEEKEVENTREG_COUPLES_MASK_CUTSCENE_FINISHED",
    (51 << 8) | 0x80: "WEEKEVENTREG_51_80",
    (52 << 8) | 0x01: "WEEKEVENTREG_ESCORTED_CREMIA",
    (52 << 8) | 0x02: "WEEKEVENTREG_52_02",
    (52 << 8) | 0x04: "WEEKEVENTREG_52_04",
    (52 << 8) | 0x08: "WEEKEVENTREG_52_08",
    (52 << 8) | 0x10: "WEEKEVENTREG_52_10",
    (52 << 8) | 0x20: "WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE",
    (52 << 8) | 0x40: "WEEKEVENTREG_52_40",
    (52 << 8) | 0x80: "WEEKEVENTREG_52_80",
    (53 << 8) | 0x01: "WEEKEVENTREG_53_01",
    (53 << 8) | 0x02: "WEEKEVENTREG_RECEIVED_BUSINESS_SCRUB_HEART_PIECE",
    (53 << 8) | 0x04: "WEEKEVENTREG_53_04",
    (53 << 8) | 0x08: "WEEKEVENTREG_GAVE_KOTAKE_MUSHROOM",
    (53 << 8) | 0x10: "WEEKEVENTREG_RECEIVED_FREE_BLUE_POTION",
    (53 << 8) | 0x20: "WEEKEVENTREG_53_20",
    (53 << 8) | 0x40: "WEEKEVENTREG_53_40",
    (53 << 8) | 0x80: "WEEKEVENTREG_53_80",
    (54 << 8) | 0x01: "WEEKEVENTREG_54_01",
    (54 << 8) | 0x02: "WEEKEVENTREG_54_02",
    (54 << 8) | 0x04: "WEEKEVENTREG_54_04",
    (54 << 8) | 0x08: "WEEKEVENTREG_54_08",
    (54 << 8) | 0x10: "WEEKEVENTREG_TALKED_ROMANI_ON_NIGHT_1",
    (54 << 8) | 0x20: "WEEKEVENTREG_54_20",
    (54 << 8) | 0x40: "WEEKEVENTREG_RECEIVED_SPIRIT_HOUSE_HEART_PIECE",
    (54 << 8) | 0x80: "WEEKEVENTREG_54_80",
    (55 << 8) | 0x01: "WEEKEVENTREG_55_01",
    (55 << 8) | 0x02: "WEEKEVENTREG_55_02",
    (55 << 8) | 0x04: "WEEKEVENTREG_TALKED_PART_TIMER_AS_GORON",
    (55 << 8) | 0x08: "WEEKEVENTREG_TALKED_PART_TIMER_AS_ZORA",
    (55 << 8) | 0x10: "WEEKEVENTREG_TALKED_PART_TIMER_AS_DEKU",
    (55 << 8) | 0x20: "WEEKEVENTREG_TALKED_ANJU_IN_LAUNDRY_POOL",
    (55 << 8) | 0x40: "WEEKEVENTREG_55_40",
    (55 << 8) | 0x80: "WEEKEVENTREG_CLEARED_GREAT_BAY_TEMPLE",
    (56 << 8) | 0x01: "WEEKEVENTREG_56_01",
    (56 << 8) | 0x02: "WEEKEVENTREG_RECEIVED_MARINE_RESEARCH_LAB_FISH_HEART_PIECE",
    (56 << 8) | 0x04: "WEEKEVENTREG_56_04",
    (56 << 8) | 0x08: "WEEKEVENTREG_56_08",
    (56 << 8) | 0x10: "WEEKEVENTREG_56_10",
    (56 << 8) | 0x20: "WEEKEVENTREG_56_20",
    (56 << 8) | 0x40: "WEEKEVENTREG_56_40",
    (56 << 8) | 0x80: "WEEKEVENTREG_56_80",
    (57 << 8) | 0x01: "WEEKEVENTREG_57_01",
    (57 << 8) | 0x02: "WEEKEVENTREG_57_02",
    (57 << 8) | 0x04: "WEEKEVENTREG_57_04",
    (57 << 8) | 0x08: "WEEKEVENTREG_57_08",
    (57 << 8) | 0x10: "WEEKEVENTREG_TALKED_ZORA_SHOPKEEPER_AS_HUMAN",
    (57 << 8) | 0x20: "WEEKEVENTREG_TALKED_ZORA_SHOPKEEPER_AS_DEKU",
    (57 << 8) | 0x40: "WEEKEVENTREG_TALKED_ZORA_SHOPKEEPER_AS_GORON",
    (57 << 8) | 0x80: "WEEKEVENTREG_TALKED_ZORA_SHOPKEEPER_AS_ZORA",
    (58 << 8) | 0x01: "WEEKEVENTREG_58_01",
    (58 << 8) | 0x02: "WEEKEVENTREG_58_02",
    (58 << 8) | 0x04: "WEEKEVENTREG_TALKED_GORON_SHOPKEEPER_AS_NON_GORON",
    (58 << 8) | 0x08: "WEEKEVENTREG_TALKED_GORON_SHOPKEEPER_AS_GORON",
    (58 << 8) | 0x10: "WEEKEVENTREG_TALKED_GORON_SHOPKEEPER_SPRING_AS_NON_GORON",
    (58 << 8) | 0x20: "WEEKEVENTREG_TALKED_GORON_SHOPKEEPER_SPRING_AS_GORON",
    (58 << 8) | 0x40: "WEEKEVENTREG_58_40",
    (58 << 8) | 0x80: "WEEKEVENTREG_58_80",
    (59 << 8) | 0x01: "WEEKEVENTREG_59_01",
    (59 << 8) | 0x02: "WEEKEVENTREG_59_02",
    (59 << 8) | 0x08: "WEEKEVENTREG_RECEIVED_BANK_HEART_PIECE",
    (59 << 8) | 0x04: "WEEKEVENTREG_59_04",
    (59 << 8) | 0x10: "WEEKEVENTREG_RECEIVED_SWAMP_SHOOTING_GALLERY_QUIVER_UPGRADE",
    (59 << 8) | 0x20: "WEEKEVENTREG_RECEIVED_TOWN_SHOOTING_GALLERY_QUIVER_UPGRADE",
    (59 << 8) | 0x40: "WEEKEVENTREG_59_40",
    (59 << 8) | 0x80: "WEEKEVENTREG_59_80",
    (60 << 8) | 0x01: "WEEKEVENTREG_60_01",
    (60 << 8) | 0x02: "WEEKEVENTREG_60_02",
    (60 << 8) | 0x04: "WEEKEVENTREG_60_04",
    (60 << 8) | 0x08: "WEEKEVENTREG_60_08",
    (60 << 8) | 0x10: "WEEKEVENTREG_60_10",
    (60 << 8) | 0x20: "WEEKEVENTREG_60_20",
    (60 << 8) | 0x40: "WEEKEVENTREG_60_40",
    (60 << 8) | 0x80: "WEEKEVENTREG_60_80",
    (61 << 8) | 0x01: "WEEKEVENTREG_61_01",
    (61 << 8) | 0x02: "WEEKEVENTREG_61_02",
    (61 << 8) | 0x04: "WEEKEVENTREG_61_04",
    (61 << 8) | 0x08: "WEEKEVENTREG_61_08",
    (61 << 8) | 0x10: "WEEKEVENTREG_61_10",
    (61 << 8) | 0x20: "WEEKEVENTREG_61_20",
    (61 << 8) | 0x40: "WEEKEVENTREG_61_40",
    (61 << 8) | 0x80: "WEEKEVENTREG_61_80",
    (62 << 8) | 0x01: "WEEKEVENTREG_62_01",
    (62 << 8) | 0x02: "WEEKEVENTREG_62_02",
    (62 << 8) | 0x04: "WEEKEVENTREG_62_04",
    (62 << 8) | 0x08: "WEEKEVENTREG_62_08",
    (62 << 8) | 0x10: "WEEKEVENTREG_62_10",
    (62 << 8) | 0x20: "WEEKEVENTREG_62_20",
    (62 << 8) | 0x40: "WEEKEVENTREG_62_40",
    (62 << 8) | 0x80: "WEEKEVENTREG_62_80",
    (63 << 8) | 0x01: "WEEKEVENTREG_KICKOUT_WAIT",
    (63 << 8) | 0x02: "WEEKEVENTREG_KICKOUT_TIME_PASSED",
    (63 << 8) | 0x04: "WEEKEVENTREG_63_04",
    (63 << 8) | 0x08: "WEEKEVENTREG_63_08",
    (63 << 8) | 0x10: "WEEKEVENTREG_63_10",
    (63 << 8) | 0x20: "WEEKEVENTREG_RECEIVED_SWORDSMANS_SCHOOL_HEART_PIECE",
    (63 << 8) | 0x40: "WEEKEVENTREG_63_40",
    (63 << 8) | 0x80: "WEEKEVENTREG_63_80",
    (64 << 8) | 0x01: "WEEKEVENTREG_64_01",
    (64 << 8) | 0x02: "WEEKEVENTREG_64_02",
    (64 << 8) | 0x04: "WEEKEVENTREG_64_04",
    (64 << 8) | 0x08: "WEEKEVENTREG_TINGLE_RECOGNIZED_PLAYER_FORM_LOW_BIT",
    (64 << 8) | 0x10: "WEEKEVENTREG_TINGLE_RECOGNIZED_PLAYER_FORM_HIGH_BIT",
    (64 << 8) | 0x20: "WEEKEVENTREG_CAN_USE_CURIOSITY_SHOP_PEEPHOLE",
    (64 << 8) | 0x40: "WEEKEVENTREG_64_40",
    (64 << 8) | 0x80: "WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_DAY_1",
    (65 << 8) | 0x01: "WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_NIGHT_1",
    (65 << 8) | 0x02: "WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_DAY_2",
    (65 << 8) | 0x04: "WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_NIGHT_2",
    (65 << 8) | 0x08: "WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_DAY_3",
    (65 << 8) | 0x10: "WEEKEVENTREG_TALKED_DOGGY_RACETRACK_OWNER_NIGHT_3",
    (65 << 8) | 0x20: "WEEKEVENTREG_65_20",
    (65 << 8) | 0x40: "WEEKEVENTREG_65_40",
    (65 << 8) | 0x80: "WEEKEVENTREG_65_80",
    (66 << 8) | 0x01: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_ANJU",
    (66 << 8) | 0x02: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_KAFEI",
    (66 << 8) | 0x04: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_CURIOSITY_SHOP_MAN",
    (66 << 8) | 0x08: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_BOMB_SHOP_LADY",
    (66 << 8) | 0x10: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_ROMANI",
    (66 << 8) | 0x20: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_CREMIA",
    (66 << 8) | 0x40: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_MAYOR_DOTOUR",
    (66 << 8) | 0x80: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_MADAOME_AROMA",
    (67 << 8) | 0x01: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_TOTO",
    (67 << 8) | 0x02: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_GORMAN",
    (67 << 8) | 0x04: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_POSTMAN",
    (67 << 8) | 0x08: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_ROSA_SISTERS",
    (67 << 8) | 0x10: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_TOILET_HAND",
    (67 << 8) | 0x20: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_ANJUS_GRANDMOTHER",
    (67 << 8) | 0x40: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_KAMARO",
    (67 << 8) | 0x80: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_GROG",
    (68 << 8) | 0x01: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_GORMAN_BROTHERS",
    (68 << 8) | 0x02: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_SHIRO",
    (68 << 8) | 0x04: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_GURU_GURU",
    (68 << 8) | 0x08: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_MET_BOMBERS",
    (68 << 8) | 0x10: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_ROOM_KEY",
    (68 << 8) | 0x20: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_PROMISED_MIDNIGHT_MEETING",
    (68 << 8) | 0x40: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_PROMISED_TO_MEET_KAFEI",
    (68 << 8) | 0x80: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_LETTER_TO_KAFEI",
    (69 << 8) | 0x01: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_DEPOSITED_LETTER_TO_KAFEI",
    (69 << 8) | 0x02: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_PENDANT_OF_MEMORIES",
    (69 << 8) | 0x04: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_DELIVERED_PENDANT_OF_MEMORIES",
    (69 << 8) | 0x08: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_ESCAPED_SAKONS_HIDEOUT",
    (69 << 8) | 0x10: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_PROMISED_TO_HELP_WITH_ALIENS",
    (69 << 8) | 0x20: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_DEFENDED_AGAINST_ALIENS",
    (69 << 8) | 0x40: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_ALIENS_BOTTLE",
    (69 << 8) | 0x80: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_ESCORTED_CREMIA",
    (70 << 8) | 0x01: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_ROMANIS_MASK",
    (70 << 8) | 0x02: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_KEATON_MASK",
    (70 << 8) | 0x04: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_PRIORITY_MAIL",
    (70 << 8) | 0x08: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_DELIVERED_PRIORITY_MAIL",
    (70 << 8) | 0x10: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_LEARNED_SECRET_CODE",
    (70 << 8) | 0x20: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_BOMBERS_NOTEBOOK",
    (70 << 8) | 0x40: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_MAYOR_HP",
    (70 << 8) | 0x80: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_ROSA_SISTERS_HP",
    (71 << 8) | 0x01: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_TOILET_HAND_HP",
    (71 << 8) | 0x02: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_GRANDMA_SHORT_STORY_HP",
    (71 << 8) | 0x04: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_GRANDMA_LONG_STORY_HP",
    (71 << 8) | 0x08: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_POSTMAN_HP",
    (71 << 8) | 0x10: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_KAFEIS_MASK",
    (71 << 8) | 0x20: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_ALL_NIGHT_MASK",
    (71 << 8) | 0x40: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_BUNNY_HOOD",
    (71 << 8) | 0x80: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_GAROS_MASK",
    (72 << 8) | 0x01: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_CIRCUS_LEADERS_MASK",
    (72 << 8) | 0x02: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_POSTMANS_HAT",
    (72 << 8) | 0x04: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_COUPLES_MASK",
    (72 << 8) | 0x08: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_BLAST_MASK",
    (72 << 8) | 0x10: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_KAMAROS_MASK",
    (72 << 8) | 0x20: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_STONE_MASK",
    (72 << 8) | 0x40: "WEEKEVENTREG_BOMBERS_NOTEBOOK_EVENT_RECEIVED_BREMEN_MASK",
    (72 << 8) | 0x80: "WEEKEVENTREG_72_80",
    (73 << 8) | 0x01: "WEEKEVENTREG_73_01",
    (73 << 8) | 0x02: "WEEKEVENTREG_73_02",
    (73 << 8) | 0x04: "WEEKEVENTREG_73_04",
    (73 << 8) | 0x08: "WEEKEVENTREG_73_08",
    (73 << 8) | 0x10: "WEEKEVENTREG_73_10",
    (73 << 8) | 0x20: "WEEKEVENTREG_73_20",
    (73 << 8) | 0x40: "WEEKEVENTREG_DEKU_LEARNED_WHERE_BOMBER_JIM_IS",
    (73 << 8) | 0x80: "WEEKEVENTREG_ENTERED_BOMBERS_CODE",
    (74 << 8) | 0x01: "WEEKEVENTREG_DEKU_TALKED_TO_BOMBER_2",
    (74 << 8) | 0x02: "WEEKEVENTREG_DEKU_TALKED_TO_BOMBER_3",
    (74 << 8) | 0x04: "WEEKEVENTREG_DEKU_TALKED_TO_BOMBER_4",
    (74 << 8) | 0x08: "WEEKEVENTREG_DEKU_TALKED_TO_BOMBER_5",
    (74 << 8) | 0x10: "WEEKEVENTREG_74_10",
    (74 << 8) | 0x20: "WEEKEVENTREG_74_20",
    (74 << 8) | 0x40: "WEEKEVENTREG_74_40",
    (74 << 8) | 0x80: "WEEKEVENTREG_74_80",
    (75 << 8) | 0x01: "WEEKEVENTREG_75_01",
    (75 << 8) | 0x02: "WEEKEVENTREG_75_02",
    (75 << 8) | 0x04: "WEEKEVENTREG_75_04",
    (75 << 8) | 0x08: "WEEKEVENTREG_75_08",
    (75 << 8) | 0x10: "WEEKEVENTREG_RECEIVED_ROOM_KEY",
    (75 << 8) | 0x20: "WEEKEVENTREG_75_20",
    (75 << 8) | 0x40: "WEEKEVENTREG_75_40",
    (75 << 8) | 0x80: "WEEKEVENTREG_RECEIVED_ROSA_SISTERS_HEART_PIECE",
    (76 << 8) | 0x01: "WEEKEVENTREG_76_01",
    (76 << 8) | 0x02: "WEEKEVENTREG_76_02",
    (76 << 8) | 0x04: "WEEKEVENTREG_76_04",
    (76 << 8) | 0x08: "WEEKEVENTREG_76_08",
    (76 << 8) | 0x10: "WEEKEVENTREG_76_10",
    (76 << 8) | 0x20: "WEEKEVENTREG_76_20",
    (76 << 8) | 0x40: "WEEKEVENTREG_76_40",
    (76 << 8) | 0x80: "WEEKEVENTREG_76_80",
    (77 << 8) | 0x01: "WEEKEVENTREG_RECEIVED_POSTMAN_COUNTING_GAME_HEART_PIECE",
    (77 << 8) | 0x02: "WEEKEVENTREG_77_02",
    (77 << 8) | 0x04: "WEEKEVENTREG_77_04",
    (77 << 8) | 0x08: "WEEKEVENTREG_77_08",
    (77 << 8) | 0x10: "WEEKEVENTREG_77_10",
    (77 << 8) | 0x20: "WEEKEVENTREG_77_20",
    (77 << 8) | 0x40: "WEEKEVENTREG_77_40",
    (77 << 8) | 0x80: "WEEKEVENTREG_77_80",
    (78 << 8) | 0x01: "WEEKEVENTREG_78_01",
    (78 << 8) | 0x02: "WEEKEVENTREG_78_02",
    (78 << 8) | 0x04: "WEEKEVENTREG_78_04",
    (78 << 8) | 0x08: "WEEKEVENTREG_78_08",
    (78 << 8) | 0x10: "WEEKEVENTREG_78_10",
    (78 << 8) | 0x20: "WEEKEVENTREG_78_20",
    (78 << 8) | 0x40: "WEEKEVENTREG_78_40",
    (78 << 8) | 0x80: "WEEKEVENTREG_78_80",
    (79 << 8) | 0x01: "WEEKEVENTREG_79_01",
    (79 << 8) | 0x02: "WEEKEVENTREG_79_02",
    (79 << 8) | 0x04: "WEEKEVENTREG_79_04",
    (79 << 8) | 0x08: "WEEKEVENTREG_79_08",
    (79 << 8) | 0x10: "WEEKEVENTREG_79_10",
    (79 << 8) | 0x20: "WEEKEVENTREG_79_20",
    (79 << 8) | 0x40: "WEEKEVENTREG_SAKON_DEAD",
    (79 << 8) | 0x80: "WEEKEVENTREG_RECEIVED_KEATON_HEART_PIECE",
    (80 << 8) | 0x01: "WEEKEVENTREG_80_01",
    (80 << 8) | 0x02: "WEEKEVENTREG_80_02",
    (80 << 8) | 0x04: "WEEKEVENTREG_80_04",
    (80 << 8) | 0x08: "WEEKEVENTREG_80_08",
    (80 << 8) | 0x10: "WEEKEVENTREG_RECEIVED_PRIORITY_MAIL",
    (80 << 8) | 0x20: "WEEKEVENTREG_TALKED_TO_CANYON_GUARD_WITH_NO_MASK",
    (80 << 8) | 0x40: "WEEKEVENTREG_TALKED_TO_CANYON_GUARD_WITH_CAPTAINS_HAT",
    (80 << 8) | 0x80: "WEEKEVENTREG_80_80",
    (81 << 8) | 0x01: "WEEKEVENTREG_81_01",
    (81 << 8) | 0x02: "WEEKEVENTREG_81_02",
    (81 << 8) | 0x04: "WEEKEVENTREG_81_04",
    (81 << 8) | 0x08: "WEEKEVENTREG_81_08",
    (81 << 8) | 0x10: "WEEKEVENTREG_81_10",
    (81 << 8) | 0x20: "WEEKEVENTREG_81_20",
    (81 << 8) | 0x40: "WEEKEVENTREG_81_40",
    (81 << 8) | 0x80: "WEEKEVENTREG_81_80",
    (82 << 8) | 0x01: "WEEKEVENTREG_82_01",
    (82 << 8) | 0x02: "WEEKEVENTREG_82_02",
    (82 << 8) | 0x04: "WEEKEVENTREG_82_04",
    (82 << 8) | 0x08: "WEEKEVENTREG_PLAYING_SWORDSMAN_MINIGAME ",
    (82 << 8) | 0x10: "WEEKEVENTREG_RECEIVED_FISHERMANS_JUMPING_GAME_HEART_PIECE",
    (82 << 8) | 0x20: "WEEKEVENTREG_82_20",
    (82 << 8) | 0x40: "WEEKEVENTREG_82_40",
    (82 << 8) | 0x80: "WEEKEVENTREG_82_80",
    (83 << 8) | 0x01: "WEEKEVENTREG_83_01",
    (83 << 8) | 0x02: "WEEKEVENTREG_83_02",
    (83 << 8) | 0x04: "WEEKEVENTREG_83_04",
    (83 << 8) | 0x08: "WEEKEVENTREG_83_08",
    (83 << 8) | 0x10: "WEEKEVENTREG_83_10",
    (83 << 8) | 0x20: "WEEKEVENTREG_83_20",
    (83 << 8) | 0x40: "WEEKEVENTREG_83_40",
    (83 << 8) | 0x80: "WEEKEVENTREG_83_80",
    (84 << 8) | 0x01: "WEEKEVENTREG_84_01",
    (84 << 8) | 0x02: "WEEKEVENTREG_84_02",
    (84 << 8) | 0x04: "WEEKEVENTREG_84_04",
    (84 << 8) | 0x08: "WEEKEVENTREG_84_08",
    (84 << 8) | 0x10: "WEEKEVENTREG_84_10",
    (84 << 8) | 0x20: "WEEKEVENTREG_84_20",
    (84 << 8) | 0x40: "WEEKEVENTREG_RECEIVED_RED_POTION_FOR_KOUME",
    (84 << 8) | 0x80: "WEEKEVENTREG_84_80",
    (85 << 8) | 0x01: "WEEKEVENTREG_85_01",
    (85 << 8) | 0x02: "WEEKEVENTREG_85_02",
    (85 << 8) | 0x04: "WEEKEVENTREG_85_04",
    (85 << 8) | 0x08: "WEEKEVENTREG_FAILED_RECEIVED_RED_POTION_FOR_KOUME_SHOP",
    (85 << 8) | 0x10: "WEEKEVENTREG_FAILED_RECEIVED_RED_POTION_FOR_KOUME_WOODS",
    (85 << 8) | 0x20: "WEEKEVENTREG_85_20",
    (85 << 8) | 0x40: "WEEKEVENTREG_85_40",
    (85 << 8) | 0x80: "WEEKEVENTREG_85_80",
    (86 << 8) | 0x01: "WEEKEVENTREG_86_01",
    (86 << 8) | 0x02: "WEEKEVENTREG_TALKED_TO_BOMBERS_GUARD",
    (86 << 8) | 0x04: "WEEKEVENTREG_86_04",
    (86 << 8) | 0x08: "WEEKEVENTREG_LISTENED_ANJU_POSTMAN_CONVERSATION",
    (86 << 8) | 0x10: "WEEKEVENTREG_86_10",
    (86 << 8) | 0x20: "WEEKEVENTREG_86_20",
    (86 << 8) | 0x40: "WEEKEVENTREG_86_40",
    (86 << 8) | 0x80: "WEEKEVENTREG_86_80",
    (87 << 8) | 0x01: "WEEKEVENTREG_TALKING_TO_COW_WITH_VOICE",
    (87 << 8) | 0x02: "WEEKEVENTREG_COUPLES_MASK_CUTSCENE_STARTED",
    (87 << 8) | 0x04: "WEEKEVENTREG_87_04",
    (87 << 8) | 0x08: "WEEKEVENTREG_87_08",
    (87 << 8) | 0x10: "WEEKEVENTREG_87_10",
    (87 << 8) | 0x20: "WEEKEVENTREG_87_20",
    (87 << 8) | 0x40: "WEEKEVENTREG_87_40",
    (87 << 8) | 0x80: "WEEKEVENTREG_87_80",
    (88 << 8) | 0x01: "WEEKEVENTREG_88_01",
    (88 << 8) | 0x02: "WEEKEVENTREG_88_02",
    (88 << 8) | 0x04: "WEEKEVENTREG_88_04",
    (88 << 8) | 0x08: "WEEKEVENTREG_88_08",
    (88 << 8) | 0x10: "WEEKEVENTREG_88_10",
    (88 << 8) | 0x20: "WEEKEVENTREG_88_20",
    (88 << 8) | 0x40: "WEEKEVENTREG_GATEKEEPER_OPENED_GORON_SHRINE",
    (88 << 8) | 0x80: "WEEKEVENTREG_GATEKEEPER_OPENED_GORON_SHRINE_FOR_HUMAN",
    (89 << 8) | 0x01: "WEEKEVENTREG_GATEKEEPER_OPENED_GORON_SHRINE_FOR_DEKU",
    (89 << 8) | 0x02: "WEEKEVENTREG_GATEKEEPER_OPENED_GORON_SHRINE_FOR_ZORA",
    (89 << 8) | 0x04: "WEEKEVENTREG_GATEKEEPER_OPENED_GORON_SHRINE_FOR_GORON",
    (89 << 8) | 0x08: "WEEKEVENTREG_89_08",
    (89 << 8) | 0x10: "WEEKEVENTREG_FAILED_TO_DEFEND_AGAINST_ALIENS",
    (89 << 8) | 0x20: "WEEKEVENTREG_89_20",
    (89 << 8) | 0x40: "WEEKEVENTREG_89_40",
    (89 << 8) | 0x80: "WEEKEVENTREG_89_80",
    (90 << 8) | 0x01: "WEEKEVENTREG_90_01",
    (90 << 8) | 0x02: "WEEKEVENTREG_90_02",
    (90 << 8) | 0x04: "WEEKEVENTREG_90_04",
    (90 << 8) | 0x08: "WEEKEVENTREG_POSTMAN_RECEIVED_LETTER_TO_KAFEI",
    (90 << 8) | 0x10: "WEEKEVENTREG_RECEIVED_GOSSIP_STONE_GROTTO_HEART_PIECE",
    (90 << 8) | 0x20: "WEEKEVENTREG_90_20",
    (90 << 8) | 0x40: "WEEKEVENTREG_90_40",
    (90 << 8) | 0x80: "WEEKEVENTREG_90_80",
    (91 << 8) | 0x01: "WEEKEVENTREG_91_01",
    (91 << 8) | 0x02: "WEEKEVENTREG_91_02",
    (91 << 8) | 0x04: "WEEKEVENTREG_LETTER_TO_KAFEI_SENT_IN_TIME",
    (91 << 8) | 0x08: "WEEKEVENTREG_LETTER_TO_KAFEI_SENT_LATE",
    (91 << 8) | 0x10: "WEEKEVENTREG_91_10",
    (91 << 8) | 0x20: "WEEKEVENTREG_91_20",
    (91 << 8) | 0x40: "WEEKEVENTREG_91_40",
    (91 << 8) | 0x80: "WEEKEVENTREG_91_80",
    (92 << 8) | 0x01: "WEEKEVENTREG_92_01",
    (92 << 8) | 0x02: "WEEKEVENTREG_92_02",
    (92 << 8) | 0x04: "WEEKEVENTREG_92_04",
    (92 << 8) | 0x08: "WEEKEVENTREG_92_08",
    (92 << 8) | 0x10: "WEEKEVENTREG_92_10",
    (92 << 8) | 0x20: "WEEKEVENTREG_92_20",
    (92 << 8) | 0x40: "WEEKEVENTREG_92_40",
    (92 << 8) | 0x80: "WEEKEVENTREG_92_80",
    (93 << 8) | 0x01: "WEEKEVENTREG_93_01",
    (93 << 8) | 0x02: "WEEKEVENTREG_93_02",
    (93 << 8) | 0x04: "WEEKEVENTREG_93_04",
    (93 << 8) | 0x08: "WEEKEVENTREG_93_08",
    (93 << 8) | 0x10: "WEEKEVENTREG_93_10",
    (93 << 8) | 0x20: "WEEKEVENTREG_93_20",
    (93 << 8) | 0x40: "WEEKEVENTREG_93_40",
    (93 << 8) | 0x80: "WEEKEVENTREG_93_80",
    (94 << 8) | 0x01: "WEEKEVENTREG_94_01",
    (94 << 8) | 0x02: "WEEKEVENTREG_94_02",
    (94 << 8) | 0x04: "WEEKEVENTREG_94_04",
    (94 << 8) | 0x08: "WEEKEVENTREG_94_08",
    (94 << 8) | 0x10: "WEEKEVENTREG_94_10",
    (94 << 8) | 0x20: "WEEKEVENTREG_94_20",
    (94 << 8) | 0x40: "WEEKEVENTREG_94_40",
    (94 << 8) | 0x80: "WEEKEVENTREG_94_80",
    (95 << 8) | 0x01: "WEEKEVENTREG_95_01",
    (95 << 8) | 0x02: "WEEKEVENTREG_95_02",
    (95 << 8) | 0x04: "WEEKEVENTREG_95_04",
    (95 << 8) | 0x08: "WEEKEVENTREG_95_08",
    (95 << 8) | 0x10: "WEEKEVENTREG_95_10",
    (95 << 8) | 0x20: "WEEKEVENTREG_95_20",
    (95 << 8) | 0x40: "WEEKEVENTREG_95_40",
    (95 << 8) | 0x80: "WEEKEVENTREG_95_80",
    (96 << 8) | 0x01: "WEEKEVENTREG_96_01",
    (96 << 8) | 0x02: "WEEKEVENTREG_96_02",
    (96 << 8) | 0x04: "WEEKEVENTREG_96_04",
    (96 << 8) | 0x08: "WEEKEVENTREG_96_08",
    (96 << 8) | 0x10: "WEEKEVENTREG_96_10",
    (96 << 8) | 0x20: "WEEKEVENTREG_96_20",
    (96 << 8) | 0x40: "WEEKEVENTREG_96_40",
    (96 << 8) | 0x80: "WEEKEVENTREG_96_80",
    (97 << 8) | 0x01: "WEEKEVENTREG_97_01",
    (97 << 8) | 0x02: "WEEKEVENTREG_97_02",
    (97 << 8) | 0x04: "WEEKEVENTREG_97_04",
    (97 << 8) | 0x08: "WEEKEVENTREG_97_08",
    (97 << 8) | 0x10: "WEEKEVENTREG_97_10",
    (97 << 8) | 0x20: "WEEKEVENTREG_97_20",
    (97 << 8) | 0x40: "WEEKEVENTREG_97_40",
    (97 << 8) | 0x80: "WEEKEVENTREG_97_80",
    (98 << 8) | 0x01: "WEEKEVENTREG_98_01",
    (98 << 8) | 0x02: "WEEKEVENTREG_98_02",
    (98 << 8) | 0x04: "WEEKEVENTREG_98_04",
    (98 << 8) | 0x08: "WEEKEVENTREG_98_08",
    (98 << 8) | 0x10: "WEEKEVENTREG_98_10",
    (98 << 8) | 0x20: "WEEKEVENTREG_98_20",
    (98 << 8) | 0x40: "WEEKEVENTREG_98_40",
    (98 << 8) | 0x80: "WEEKEVENTREG_98_80",
    (99 << 8) | 0x01: "WEEKEVENTREG_99_01",
    (99 << 8) | 0x02: "WEEKEVENTREG_99_02",
    (99 << 8) | 0x04: "WEEKEVENTREG_99_04",
    (99 << 8) | 0x08: "WEEKEVENTREG_99_08",
    (99 << 8) | 0x10: "WEEKEVENTREG_99_10",
    (99 << 8) | 0x20: "WEEKEVENTREG_99_20",
    (99 << 8) | 0x40: "WEEKEVENTREG_99_40",
    (99 << 8) | 0x80: "WEEKEVENTREG_99_80",
}

item_names = (
    "ITEM_OCARINA",
    "ITEM_BOW",
    "ITEM_ARROW_FIRE",
    "ITEM_ARROW_ICE",
    "ITEM_ARROW_LIGHT",
    "ITEM_OCARINA_FAIRY",
    "ITEM_BOMB",
    "ITEM_BOMBCHU",
    "ITEM_STICK",
    "ITEM_NUT",
    "ITEM_MAGIC_BEANS",
    "ITEM_SLINGSHOT",
    "ITEM_POWDER_KEG",
    "ITEM_PICTOGRAPH_BOX",
    "ITEM_LENS",
    "ITEM_HOOKSHOT",
    "ITEM_SWORD_GREAT_FAIRY",
    "ITEM_LONGSHOT",
    "ITEM_BOTTLE",
    "ITEM_POTION_RED",
    "ITEM_POTION_GREEN",
    "ITEM_POTION_BLUE",
    "ITEM_FAIRY",
    "ITEM_DEKU_PRINCESS",
    "ITEM_MILK_BOTTLE",
    "ITEM_MILK_HALF",
    "ITEM_FISH",
    "ITEM_BUG",
    "ITEM_BLUE_FIRE",
    "ITEM_POE",
    "ITEM_BIG_POE",
    "ITEM_SPRING_WATER",
    "ITEM_HOT_SPRING_WATER",
    "ITEM_ZORA_EGG",
    "ITEM_GOLD_DUST",
    "ITEM_MUSHROOM",
    "ITEM_SEA_HORSE",
    "ITEM_CHATEAU",
    "ITEM_HYLIAN_LOACH",
    "ITEM_OBABA_DRINK",
    "ITEM_MOON_TEAR",
    "ITEM_DEED_LAND",
    "ITEM_DEED_SWAMP",
    "ITEM_DEED_MOUNTAIN",
    "ITEM_DEED_OCEAN",
    "ITEM_ROOM_KEY",
    "ITEM_LETTER_MAMA",
    "ITEM_LETTER_TO_KAFEI",
    "ITEM_PENDANT_OF_MEMORIES",
    "ITEM_TINGLE_MAP",
    "ITEM_MASK_DEKU",
    "ITEM_MASK_GORON",
    "ITEM_MASK_ZORA",
    "ITEM_MASK_FIERCE_DEITY",
    "ITEM_MASK_TRUTH",
    "ITEM_MASK_KAFEIS_MASK",
    "ITEM_MASK_ALL_NIGHT",
    "ITEM_MASK_BUNNY",
    "ITEM_MASK_KEATON",
    "ITEM_MASK_GARO",
    "ITEM_MASK_ROMANI",
    "ITEM_MASK_CIRCUS_LEADER",
    "ITEM_MASK_POSTMAN",
    "ITEM_MASK_COUPLE",
    "ITEM_MASK_GREAT_FAIRY",
    "ITEM_MASK_GIBDO",
    "ITEM_MASK_DON_GERO",
    "ITEM_MASK_KAMARO",
    "ITEM_MASK_CAPTAIN",
    "ITEM_MASK_STONE",
    "ITEM_MASK_BREMEN",
    "ITEM_MASK_BLAST",
    "ITEM_MASK_SCENTS",
    "ITEM_MASK_GIANT",
    "ITEM_BOW_ARROW_FIRE",
    "ITEM_BOW_ARROW_ICE",
    "ITEM_BOW_ARROW_LIGHT",
    "ITEM_SWORD_KOKIRI",
    "ITEM_SWORD_RAZOR",
    "ITEM_SWORD_GILDED",
    "ITEM_SWORD_DEITY",
    "ITEM_SHIELD_HERO",
    "ITEM_SHIELD_MIRROR",
    "ITEM_QUIVER_30",
    "ITEM_QUIVER_40",
    "ITEM_QUIVER_50",
    "ITEM_BOMB_BAG_20",
    "ITEM_BOMB_BAG_30",
    "ITEM_BOMB_BAG_40",
    "ITEM_WALLET_DEFAULT",
    "ITEM_WALLET_ADULT",
    "ITEM_WALLET_GIANT",
    "ITEM_FISHING_POLE",
    "ITEM_REMAINS_ODOLWA",
    "ITEM_REMAINS_GOHT",
    "ITEM_REMAINS_GYORG",
    "ITEM_REMAINS_TWINMOLD",
    "ITEM_SONG_SONATA",
    "ITEM_SONG_LULLABY",
    "ITEM_SONG_NOVA",
    "ITEM_SONG_ELEGY",
    "ITEM_SONG_OATH",
    "ITEM_SONG_SARIA",
    "ITEM_SONG_TIME",
    "ITEM_SONG_HEALING",
    "ITEM_SONG_EPONA",
    "ITEM_SONG_SOARING",
    "ITEM_SONG_STORMS",
    "ITEM_SONG_SUN",
    "ITEM_BOMBERS_NOTEBOOK",
    "ITEM_SKULL_TOKEN",
    "ITEM_HEART_CONTAINER",
    "ITEM_HEART_PIECE",
    None,
    None,
    "ITEM_SONG_LULLABY_INTRO",
    "ITEM_KEY_BOSS",
    "ITEM_COMPASS",
    "ITEM_DUNGEON_MAP",
    "ITEM_STRAY_FAIRIES",
    "ITEM_KEY_SMALL",
    "ITEM_MAGIC_SMALL",
    "ITEM_MAGIC_LARGE",
    "ITEM_HEART_PIECE_2",
    "ITEM_INVALID_1",
    "ITEM_INVALID_2",
    "ITEM_INVALID_3",
    "ITEM_INVALID_4",
    "ITEM_INVALID_5",
    "ITEM_INVALID_6",
    "ITEM_INVALID_7",
    "ITEM_HEART",
    "ITEM_RUPEE_GREEN",
    "ITEM_RUPEE_BLUE",
    "ITEM_RUPEE_10",
    "ITEM_RUPEE_RED",
    "ITEM_RUPEE_PURPLE",
    "ITEM_RUPEE_SILVER",
    "ITEM_RUPEE_HUGE",
    "ITEM_STICKS_5",
    "ITEM_STICKS_10",
    "ITEM_NUTS_5",
    "ITEM_NUTS_10",
    "ITEM_BOMBS_5",
    "ITEM_BOMBS_10",
    "ITEM_BOMBS_20",
    "ITEM_BOMBS_30",
    "ITEM_ARROWS_10",
    "ITEM_ARROWS_30",
    "ITEM_ARROWS_40",
    "ITEM_ARROWS_50",
    "ITEM_BOMBCHUS_20",
    "ITEM_BOMBCHUS_10",
    "ITEM_BOMBCHUS_1",
    "ITEM_BOMBCHUS_5",
    "ITEM_STICK_UPGRADE_20",
    "ITEM_STICK_UPGRADE_30",
    "ITEM_NUT_UPGRADE_30",
    "ITEM_NUT_UPGRADE_40",
    "ITEM_CHATEAU_2",
    "ITEM_MILK",
    "ITEM_GOLD_DUST_2",
    "ITEM_HYLIAN_LOACH_2",
    "ITEM_SEA_HORSE_CAUGHT",
)

gi_names = (
    "GI_NONE",
    "GI_RUPEE_GREEN",
    "GI_RUPEE_BLUE",
    "GI_RUPEE_10",
    "GI_RUPEE_RED",
    "GI_RUPEE_PURPLE",
    "GI_RUPEE_SILVER",
    "GI_RUPEE_HUGE",
    "GI_WALLET_ADULT",
    "GI_WALLET_GIANT",
    "GI_RECOVERY_HEART",
    None,
    "GI_HEART_PIECE",
    "GI_HEART_CONTAINER",
    "GI_MAGIC_SMALL",
    "GI_MAGIC_LARGE",
    None,
    "GI_STRAY_FAIRY",
    None,
    None,
    "GI_BOMBS_1",
    "GI_BOMBS_5",
    "GI_BOMBS_10",
    "GI_BOMBS_20",
    "GI_BOMBS_30",
    "GI_STICKS_1",
    "GI_BOMBCHUS_10",
    "GI_BOMB_BAG_20",
    "GI_BOMB_BAG_30",
    "GI_BOMB_BAG_40",
    "GI_ARROWS_10",
    "GI_ARROWS_30",
    "GI_ARROWS_40",
    "GI_ARROWS_50",
    "GI_QUIVER_30",
    "GI_QUIVER_40",
    "GI_QUIVER_50",
    "GI_ARROW_FIRE",
    "GI_ARROW_ICE",
    "GI_ARROW_LIGHT",
    "GI_NUTS_1",
    "GI_NUTS_5",
    "GI_NUTS_10",
    None,
    None,
    None,
    "GI_BOMBCHUS_20",
    None,
    None,
    None,
    "GI_SHIELD_HERO",
    "GI_SHIELD_MIRROR",
    "GI_POWDER_KEG",
    "GI_MAGIC_BEANS",
    "GI_BOMBCHUS_1",
    "GI_SWORD_KOKIRI",
    "GI_SWORD_RAZOR",
    "GI_SWORD_GILDED",
    "GI_BOMBCHUS_5",
    "GI_SWORD_GREAT_FAIRY",
    "GI_KEY_SMALL",
    "GI_KEY_BOSS",
    "GI_MAP",
    "GI_COMPASS",
    "GI_40",
    "GI_HOOKSHOT",
    "GI_LENS",
    "GI_PICTOGRAPH_BOX",
    None,
    None,
    None,
    None,
    None,
    None,
    None,
    None,
    "GI_OCARINA",
    None,
    None,
    None,
    "GI_BOMBERS_NOTEBOOK",
    None,
    "GI_SKULL_TOKEN",
    None,
    None,
    "GI_REMAINS_ODOLWA",
    "GI_REMAINS_GOHT",
    "GI_REMAINS_GYORG",
    "GI_REMAINS_TWINMOLD",
    "GI_POTION_RED_BOTTLE",
    "GI_BOTTLE",
    "GI_POTION_RED",
    "GI_POTION_GREEN",
    "GI_POTION_BLUE",
    "GI_FAIRY",
    "GI_DEKU_PRINCESS",
    "GI_MILK_BOTTLE",
    "GI_MILK_HALF",
    "GI_FISH",
    "GI_BUG",
    "GI_BLUE_FIRE",
    "GI_POE",
    "GI_BIG_POE",
    "GI_SPRING_WATER",
    "GI_HOT_SPRING_WATER",
    "GI_ZORA_EGG",
    "GI_GOLD_DUST",
    "GI_MUSHROOM",
    "GI_6C",
    "GI_6D",
    "GI_SEAHORSE",
    "GI_CHATEAU_BOTTLE",
    "GI_HYLIAN_LOACH",
    None,
    None,
    None,
    None,
    "GI_75",
    "GI_ICE_TRAP",
    None,
    "GI_MASK_DEKU",
    "GI_MASK_GORON",
    "GI_MASK_ZORA",
    "GI_MASK_FIERCE_DEITY",
    "GI_MASK_CAPTAIN",
    "GI_MASK_GIANT",
    "GI_MASK_ALL_NIGHT",
    "GI_MASK_BUNNY",
    "GI_MASK_KEATON",
    "GI_MASK_GARO",
    "GI_MASK_ROMANI",
    "GI_MASK_CIRCUS_LEADER",
    "GI_MASK_POSTMAN",
    "GI_MASK_COUPLE",
    "GI_MASK_GREAT_FAIRY",
    "GI_MASK_GIBDO",
    "GI_MASK_DON_GERO",
    "GI_MASK_KAMARO",
    "GI_MASK_TRUTH",
    "GI_MASK_STONE",
    "GI_MASK_BREMEN",
    "GI_MASK_BLAST",
    "GI_MASK_SCENTS",
    "GI_MASK_KAFEIS_MASK",
    "GI_90",
    "GI_CHATEAU",
    "GI_MILK",
    "GI_GOLD_DUST_2",
    "GI_HYLIAN_LOACH_2",
    "GI_SEAHORSE_CAUGHT",
    "GI_MOON_TEAR",
    "GI_DEED_LAND",
    "GI_DEED_SWAMP",
    "GI_DEED_MOUNTAIN",
    "GI_DEED_OCEAN",
    "GI_SWORD_GREAT_FAIRY_STOLEN",
    "GI_SWORD_KOKIRI_STOLEN",
    "GI_SWORD_RAZOR_STOLEN",
    "GI_SWORD_GILDED_STOLEN",
    "GI_SHIELD_HERO_STOLEN",
    "GI_ROOM_KEY",
    "GI_LETTER_TO_MAMA",
    "GI_A2",
    "GI_A3",
    "GI_A4",
    "GI_A5",
    "GI_A6",
    "GI_A7",
    "GI_A8",
    "GI_BOTTLE_STOLEN",
    "GI_LETTER_TO_KAFEI",
    "GI_PENDANT_OF_MEMORIES",
    "GI_TINGLE_MAP_CLOCK_TOWN",
    "GI_TINGLE_MAP_WOODFALL",
    "GI_TINGLE_MAP_SNOWHEAD",
    "GI_TINGLE_MAP_ROMANI_RANCH",
    "GI_TINGLE_MAP_GREAT_BAY",
    "GI_TINGLE_MAP_STONE_TOWER",
    "GI_MAX",
)

notebook_event = (
    "BOMBERS_NOTEBOOK_EVENT_MET_BOMBERS",
    "BOMBERS_NOTEBOOK_EVENT_MET_ANJU",
    "BOMBERS_NOTEBOOK_EVENT_MET_KAFEI",
    "BOMBERS_NOTEBOOK_EVENT_MET_CURIOSITY_SHOP_MAN",
    "BOMBERS_NOTEBOOK_EVENT_MET_BOMB_SHOP_LADY",
    "BOMBERS_NOTEBOOK_EVENT_MET_ROMANI",
    "BOMBERS_NOTEBOOK_EVENT_MET_CREMIA",
    "BOMBERS_NOTEBOOK_EVENT_MET_MAYOR_DOTOUR",
    "BOMBERS_NOTEBOOK_EVENT_MET_MADAME_AROMA",
    "BOMBERS_NOTEBOOK_EVENT_MET_TOTO",
    "BOMBERS_NOTEBOOK_EVENT_MET_GORMAN",
    "BOMBERS_NOTEBOOK_EVENT_MET_POSTMAN",
    "BOMBERS_NOTEBOOK_EVENT_MET_ROSA_SISTERS",
    "BOMBERS_NOTEBOOK_EVENT_MET_TOLIET_HAND",
    "BOMBERS_NOTEBOOK_EVENT_MET_ANJUS_GRANDMOTHER",
    "BOMBERS_NOTEBOOK_EVENT_MET_KAMARO",
    "BOMBERS_NOTEBOOK_EVENT_MET_GROG",
    "BOMBERS_NOTEBOOK_EVENT_MET_GORMAN_BROTHERS",
    "BOMBERS_NOTEBOOK_EVENT_MET_SHIRO",
    "BOMBERS_NOTEBOOK_EVENT_MET_GURU_GURU",

    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_ROOM_KEY",
    "BOMBERS_NOTEBOOK_EVENT_PROMISED_MIDNIGHT_MEETING",
    "BOMBERS_NOTEBOOK_EVENT_PROMISED_TO_MEET_KAFEI",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_LETTER_TO_KAFEI",
    "BOMBERS_NOTEBOOK_EVENT_DEPOSITED_LETTER_TO_KAFEI",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_PENDANT_OF_MEMORIES",
    "BOMBERS_NOTEBOOK_EVENT_DELIVERED_PENDANT_OF_MEMORIES",
    "BOMBERS_NOTEBOOK_EVENT_ESCAPED_SAKONS_HIDEOUT",
    "BOMBERS_NOTEBOOK_EVENT_PROMISED_TO_HELP_WITH_THEM",
    "BOMBERS_NOTEBOOK_EVENT_DEFENDED_AGAINST_THEM",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_MILK_BOTTLE",
    "BOMBERS_NOTEBOOK_EVENT_ESCORTED_CREMIA",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_ROMANIS_MASK",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_KEATON_MASK",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_PRIORITY_MAIL",
    "BOMBERS_NOTEBOOK_EVENT_DELIVERED_PRIORITY_MAIL",
    "BOMBERS_NOTEBOOK_EVENT_LEARNED_SECRET_CODE",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_BOMBERS_NOTEBOOK",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_MAYOR_HP",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_ROSA_SISTERS_HP",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_TOILET_HAND_HP",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_GRANDMA_SHORT_STORY_HP",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_GRANDMA_LONG_STORY_HP",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_POSTMAN_HP",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_KAFEIS_MASK",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_ALL_NIGHT_MASK",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_BUNNY_HOOD",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_GAROS_MASK",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_CIRCUS_LEADERS_MASK",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_POSTMANS_HAT",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_COUPLES_MASK",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_BLAST_MASK",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_KAMAROS_MASK",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_STONE_MASK",
    "BOMBERS_NOTEBOOK_EVENT_RECEIVED_BREMEN_MASK",
)

mask_names = (
    "PLAYER_MASK_NONE",
    "PLAYER_MASK_TRUTH",
    "PLAYER_MASK_KAFEIS_MASK",
    "PLAYER_MASK_ALL_NIGHT",
    "PLAYER_MASK_BUNNY",
    "PLAYER_MASK_KEATON",
    "PLAYER_MASK_GARO",
    "PLAYER_MASK_ROMANI",
    "PLAYER_MASK_CIRCUS_LEADER",
    "PLAYER_MASK_POSTMAN",
    "PLAYER_MASK_COUPLE",
    "PLAYER_MASK_GREAT_FAIRY",
    "PLAYER_MASK_GIBDO",
    "PLAYER_MASK_DON_GERO",
    "PLAYER_MASK_KAMARO",
    "PLAYER_MASK_CAPTAIN",
    "PLAYER_MASK_STONE",
    "PLAYER_MASK_BREMEN",
    "PLAYER_MASK_BLAST",
    "PLAYER_MASK_SCENTS",
    "PLAYER_MASK_GIANT",
    "PLAYER_MASK_FIERCE_DEITY",
    "PLAYER_MASK_GORON",
    "PLAYER_MASK_ZORA",
    "PLAYER_MASK_DEKU",
    "PLAYER_MASK_MAX"
)

item_action_names = (
    "PLAYER_IA_NONE",
    "PLAYER_IA_LAST_USED",
    "PLAYER_IA_FISHING_ROD",
    "PLAYER_IA_SWORD_KOKIRI",
    "PLAYER_IA_SWORD_RAZOR",
    "PLAYER_IA_SWORD_GILDED",
    "PLAYER_IA_SWORD_TWO_HANDED",
    "PLAYER_IA_DEKU_STICK",
    "PLAYER_IA_ZORA_BOOMERANG",
    "PLAYER_IA_BOW",
    "PLAYER_IA_BOW_FIRE",
    "PLAYER_IA_BOW_ICE",
    "PLAYER_IA_BOW_LIGHT",
    "PLAYER_IA_HOOKSHOT",
    "PLAYER_IA_BOMB",
    "PLAYER_IA_POWDER_KEG",
    "PLAYER_IA_BOMBCHU",
    "PLAYER_IA_11",
    "PLAYER_IA_DEKU_NUT",
    "PLAYER_IA_PICTOGRAPH_BOX",
    "PLAYER_IA_OCARINA",
    "PLAYER_IA_BOTTLE_EMPTY",
    "PLAYER_IA_BOTTLE_FISH",
    "PLAYER_IA_BOTTLE_SPRING_WATER",
    "PLAYER_IA_BOTTLE_HOT_SPRING_WATER",
    "PLAYER_IA_BOTTLE_ZORA_EGG",
    "PLAYER_IA_BOTTLE_DEKU_PRINCESS",
    "PLAYER_IA_BOTTLE_GOLD_DUST",
    "PLAYER_IA_BOTTLE_1C",
    "PLAYER_IA_BOTTLE_SEAHORSE",
    "PLAYER_IA_BOTTLE_MUSHROOM",
    "PLAYER_IA_BOTTLE_HYLIAN_LOACH",
    "PLAYER_IA_BOTTLE_BUG",
    "PLAYER_IA_BOTTLE_POE",
    "PLAYER_IA_BOTTLE_BIG_POE",
    "PLAYER_IA_BOTTLE_POTION_RED",
    "PLAYER_IA_BOTTLE_POTION_BLUE",
    "PLAYER_IA_BOTTLE_POTION_GREEN",
    "PLAYER_IA_BOTTLE_MILK",
    "PLAYER_IA_BOTTLE_MILK_HALF",
    "PLAYER_IA_BOTTLE_CHATEAU",
    "PLAYER_IA_BOTTLE_FAIRY",
    "PLAYER_IA_MOONS_TEAR",
    "PLAYER_IA_DEED_LAND",
    "PLAYER_IA_ROOM_KEY",
    "PLAYER_IA_LETTER_TO_KAFEI",
    "PLAYER_IA_MAGIC_BEANS",
    "PLAYER_IA_DEED_SWAMP",
    "PLAYER_IA_DEED_MOUNTAIN",
    "PLAYER_IA_DEED_OCEAN",
    "PLAYER_IA_32",
    "PLAYER_IA_LETTER_MAMA",
    "PLAYER_IA_34",
    "PLAYER_IA_35",
    "PLAYER_IA_PENDANT_OF_MEMORIES",
    "PLAYER_IA_37",
    "PLAYER_IA_38",
    "PLAYER_IA_39",
    "PLAYER_IA_MASK_TRUTH",
    "PLAYER_IA_MASK_KAFEIS_MASK",
    "PLAYER_IA_MASK_ALL_NIGHT",
    "PLAYER_IA_MASK_BUNNY",
    "PLAYER_IA_MASK_KEATON",
    "PLAYER_IA_MASK_GARO",
    "PLAYER_IA_MASK_ROMANI",
    "PLAYER_IA_MASK_CIRCUS_LEADER",
    "PLAYER_IA_MASK_POSTMAN",
    "PLAYER_IA_MASK_COUPLE",
    "PLAYER_IA_MASK_GREAT_FAIRY",
    "PLAYER_IA_MASK_GIBDO",
    "PLAYER_IA_MASK_DON_GERO",
    "PLAYER_IA_MASK_KAMARO",
    "PLAYER_IA_MASK_CAPTAIN",
    "PLAYER_IA_MASK_STONE",
    "PLAYER_IA_MASK_BREMEN",
    "PLAYER_IA_MASK_BLAST",
    "PLAYER_IA_MASK_SCENTS",
    "PLAYER_IA_MASK_GIANT",
    "PLAYER_IA_MASK_FIERCE_DEITY",
    "PLAYER_IA_MASK_GORON",
    "PLAYER_IA_MASK_ZORA",
    "PLAYER_IA_MASK_DEKU",
    "PLAYER_IA_MASK_MAX",
    "PLAYER_IA_LENS_OF_TRUTH",
    "PLAYER_IA_MAX"
)

def getFlagMacro(flag) -> str:
    index = flag >> 8
    mask = flag & 0xFF
    return f"EVENTINF_{index}{int(math.log2(mask))}"

def read_bytes(data_file, offset, len):
    with open(data_file,"rb") as infile:
        infile.seek(offset)
        return bytearray(infile.read(len))

def disassemble_msg_script(data_file, script_start, offset, length):
    out = ""
    cmd = None
    branch_targets = []

    # Keep trying to disassemble until it hits the terminator and no commands branch past it
    while any([branch >= offset for branch in branch_targets]) or cmd != 0x10:
        # print(offset)
        cmd = read_bytes(data_file, script_start + offset, 1)[0]
        # print(cmd)

        cmd_name = cmd_info[cmd][0]
        cmd_len = cmd_info[cmd][1]
        cmd_args = cmd_info[cmd][3]

        is_branch = False

        args_formatted = []
        if len(cmd_args) > 1: # handle args
            raw_args = read_bytes(data_file, script_start + offset + 1, cmd_len - 1)
            arg_values = struct.unpack(cmd_args, raw_args)

            # print(len(raw_args) + 1, f"0x{cmd:02X}", [f"0x{b:02X}" for b in raw_args])

            for i,(arg_value,arg_type) in enumerate(zip(arg_values, cmd_args[1:]),0):
                arg_formatted = ""

                if cmd == 0 and i == 0:
                    arg_formatted = week_event_reg[arg_value]
                    assert arg_formatted is not None
                elif cmd == 6 and i == 0:
                    arg_formatted = gi_names[arg_value]
                    assert arg_formatted is not None
                elif cmd == 8 and i == 0:
                    arg_formatted = f'{arg_value}'
                    assert arg_formatted is not None
                elif cmd == 17 and i == 0:
                    arg_formatted = week_event_reg[arg_value]
                    assert arg_formatted is not None
                elif cmd == 20 and i == 0:
                    if arg_value & 0x8000: # Value is negative take twos compliment
                        arg_formatted = f'{arg_value - 0x10000}'
                    else:
                        arg_formatted = f'{arg_value}'
                    assert arg_formatted is not None
                elif cmd == 27 and i == 0:
                    arg_formatted = getFlagMacro(arg_value)
                    assert arg_formatted is not None
                elif cmd == 28 and i == 0:
                    arg_formatted = getFlagMacro(arg_value)
                    assert arg_formatted is not None
                elif cmd == 29 and i == 0:
                    arg_formatted = getFlagMacro(arg_value)
                    assert arg_formatted is not None
                elif cmd == 30 and i == 0:
                    arg_formatted = item_action_names[arg_value]
                    assert arg_formatted is not None
                elif cmd == 32 and i == 0:
                    arg_formatted = mask_names[arg_value]
                    assert arg_formatted is not None
                elif cmd == 34 and (i == 0 or i == 1):
                    arg_formatted = f'{arg_value}'
                    assert arg_formatted is not None
                elif cmd == 37 and i == 0:
                    arg_formatted = item_names[arg_value]
                    assert arg_formatted is not None
                elif cmd == 39 and i == 0:
                    arg_formatted = f'{arg_value}'
                    assert arg_formatted is not None
                elif cmd == 42 and i == 0:
                    arg_formatted = item_names[arg_value]
                    assert arg_formatted is not None
                elif cmd == 45 and i == 0:
                    arg_formatted = notebook_event[arg_value]
                    assert arg_formatted is not None
                else:
                    if arg_type == "h":
                        arg_formatted = f"{arg_value:#x}"
                    elif arg_type == "H":
                        arg_formatted = f"0x{arg_value:04X}"
                    elif arg_type == "B":
                        arg_formatted = f"0x{arg_value:02X}"

                    if i in cmd_info[cmd][4]: # skip argument indices
                        # add skip args to branch targets, and change the output to absolute differences rather than relative offsets
                        arg_value += cmd_len

                        is_branch = True
                        branch_pos = offset + cmd_len
                        branch_target = offset + arg_value

                        branch_targets.append(branch_target)

                        if arg_value == cmd_len:
                            arg_formatted == "0"
                        else:
                            arg_formatted = f"0x{branch_target:04X} - 0x{branch_pos:04X}"
                args_formatted.append(arg_formatted)
        # else:
        #     print(1, f"0x{cmd:02X}")

        args = ", ".join(args_formatted) if len(args_formatted) != 0 else ""

        line = f"    /* 0x{offset:04X} 0x{cmd_len:02X} */ {cmd_name}({args}),{f' // {cmd_info[cmd][2]}' if cmd_info[cmd][2] != '' else ''}\n"
        out += line

        if cmd == 0x10 or is_branch and branch_target < branch_pos: # maybe
            out += "\n"

        offset += cmd_len

        if is_branch and branch_target < branch_pos:
            # branch backwards, terminate if nothing branches past here
            # TODO if the branch is conditional we should not be terminating here
            if not any([branch >= offset for branch in branch_targets]):
                break

    length -= offset

    if length > 0:
        if length < 4 and all([b == 0 for b in read_bytes(data_file, script_start + offset, length)]):
            # padding
            pass
        else:
            # some data left over, try and disassemble it
            out += "                   // Unreachable\n"
            out += disassemble_msg_script(data_file, script_start, offset, length)

    return out

def main():
    parser = argparse.ArgumentParser(description="Disassembles MM behavior scripts")
    parser.add_argument('address', help="VRAM or ROM address to disassemble at", type=lambda s : int(s.replace("D_", "0x"), 16))
    parser.add_argument('length', help="Number of bytes to disassemble, by default it will disassemble all reachable commands", nargs='?', default=-1, type=int)
    parser.add_argument('--name', help="Array name", default="sMsgScript", type=str)
    args = parser.parse_args()

    file_result = resolve_symbol(args.address)

    if file_result[0] is None:
        print("Invalid address")
        return

    print(hex(file_result[1]), "in", file_result[0].split(os.sep)[-1])

    print(f"MsgScript {args.name}[] = {{")
    print(disassemble_msg_script(file_result[0], file_result[1], 0, args.length).rstrip())
    print("};")

if __name__ == "__main__":
    main()
