	const_def
	const EVENT_PLAYER_GENDER                             ; $00
	const EVENT_MASONS_LAB_CHALLENGE_MACHINE_STATE        ; $01
	const EVENT_02                                        ; $02
	const EVENT_MASONS_LAB_CHALLENGE_MACHINE_STATE_DUMMY  ; $03
; Coin flags
	const EVENT_GOT_CHANSEY_COIN                          ; $04
	const EVENT_GOT_ODDISH_COIN                           ; $05
	const EVENT_GOT_CHARMANDER_COIN                       ; $06
	const EVENT_GOT_STARMIE_COIN                          ; $07
	const EVENT_GOT_PIKACHU_COIN                          ; $08
	const EVENT_GOT_ALAKAZAM_COIN                         ; $09
	const EVENT_GOT_KABUTO_COIN                           ; $0a
	const EVENT_GOT_GR_COIN                               ; $0b
	const EVENT_GOT_GR_COIN_PIECE_TOP_LEFT                ; $0c
	const EVENT_GOT_GR_COIN_PIECE_TOP_RIGHT               ; $0d
	const EVENT_GOT_GR_COIN_PIECE_BOTTOM_LEFT             ; $0e
	const EVENT_GOT_GR_COIN_PIECE_BOTTOM_RIGHT            ; $0f
	const EVENT_GOT_GOLBAT_COIN                           ; $10
	const EVENT_GOT_MAGNEMITE_COIN                        ; $11
	const EVENT_GOT_MAGMAR_COIN                           ; $12
	const EVENT_GOT_PSYDUCK_COIN                          ; $13
	const EVENT_GOT_MACHAMP_COIN                          ; $14
	const EVENT_GOT_MEW_COIN                              ; $15
	const EVENT_GOT_SNORLAX_COIN                          ; $16
	const EVENT_GOT_TOGEPI_COIN                           ; $17
	const EVENT_GOT_PONYTA_COIN                           ; $18
	const EVENT_GOT_HORSEA_COIN                           ; $19
	const EVENT_GOT_ARBOK_COIN                            ; $1a
	const EVENT_GOT_JIGGLYPUFF_COIN                       ; $1b
	const EVENT_GOT_DUGTRIO_COIN                          ; $1c
	const EVENT_GOT_GENGAR_COIN                           ; $1d
	const EVENT_GOT_RAICHU_COIN                           ; $1e
	const EVENT_GOT_LUGIA_COIN                            ; $1f
; Rock Club flags
	const EVENT_TALKED_TO_GENE                            ; $20
	const EVENT_TALKED_TO_MATTHEW                         ; $21
	const EVENT_TALKED_TO_RYAN                            ; $22
	const EVENT_TALKED_TO_ANDREW                          ; $23
; Fighting Club flags
	const EVENT_TALKED_TO_MITCH                           ; $24
	const EVENT_TALKED_TO_MICHAEL                         ; $25
	const EVENT_TALKED_TO_CHRIS                           ; $26
	const EVENT_TALKED_TO_JESSICA                         ; $27
; Grass Club flags
	const EVENT_TALKED_TO_NIKKI                           ; $28
	const EVENT_TALKED_TO_BRITTANY                        ; $29
	const EVENT_TALKED_TO_KRISTIN                         ; $2a
	const EVENT_TALKED_TO_HEATHER                         ; $2b
	const EVENT_BEAT_BRITTANY                             ; $2c
; Science Club flags
	const EVENT_TALKED_TO_RICK                            ; $2d
	const EVENT_TALKED_TO_DAVID                           ; $2e
	const EVENT_TALKED_TO_JOSEPH                          ; $2f
	const EVENT_TALKED_TO_ERIK                            ; $30
; Water Club flags
	const EVENT_TALKED_TO_AMY                             ; $31
	const EVENT_TALKED_TO_JOSHUA                          ; $32
	const EVENT_TALKED_TO_SARA                            ; $33
	const EVENT_TALKED_TO_AMANDA                          ; $34
	const EVENT_35                                        ; $35
	const EVENT_36                                        ; $36
; Lightning Club flags
	const EVENT_TALKED_TO_ISAAC                           ; $37
	const EVENT_TALKED_TO_JENNIFER                        ; $38
	const EVENT_TALKED_TO_NICHOLAS                        ; $39
	const EVENT_TALKED_TO_BRANDON                         ; $3a
	const EVENT_BEAT_NICHOLAS                             ; $3b
; Fire Club flags
	const EVENT_TALKED_TO_KEN                             ; $3c
	const EVENT_TALKED_TO_JOHN                            ; $3d
	const EVENT_TALKED_TO_ADAM                            ; $3e
	const EVENT_TALKED_TO_JONATHAN                        ; $3f
; Psychic Club flags
	const EVENT_TALKED_TO_MURRAY                          ; $40
	const EVENT_TALKED_TO_ROBERT                          ; $41
	const EVENT_TALKED_TO_DANIEL                          ; $42
	const EVENT_TALKED_TO_STEPHANIE                       ; $43
	const EVENT_BEAT_MURRAY                               ; $44
	const EVENT_WALKED_INTO_MURRAYS_CLUB_ROOM             ; $45
; GR Grass Fort flags
	const EVENT_TALKED_TO_MIDORI                          ; $46
	const EVENT_TALKED_TO_YUTA                            ; $47
	const EVENT_TALKED_TO_MIYUKI                          ; $48
	const EVENT_TALKED_TO_MORINO                          ; $49
	const EVENT_FREED_RICK                                ; $4a
	const EVENT_YUTAS_ROOM_DOOR_STATE                     ; $4b
	const EVENT_MIYUKIS_ROOM_DOOR_STATE                   ; $4c
	const EVENT_BEAT_MORINO                               ; $4d
; GR Lightning Fort flags
	const EVENT_TALKED_TO_RENNA                           ; $4e
	const EVENT_TALKED_TO_ICHIKAWA                        ; $4f
	const EVENT_TALKED_TO_CATHERINE                       ; $50
	const EVENT_TALKED_TO_TAP                             ; $51
	const EVENT_RENNAS_ROOM_DOOR_STATE                    ; $52
	const EVENT_ICHIKAWAS_ROOM_DOOR_STATE                 ; $53
	const EVENT_BEAT_CATHERINE                            ; $54
; GR Fire Fort flags
	const EVENT_TALKED_TO_JES                             ; $55
	const EVENT_TALKED_TO_YUKI                            ; $56
	const EVENT_TALKED_TO_SHOKO                           ; $57
	const EVENT_TALKED_TO_HIDERO                          ; $58
	const EVENT_JES_ROOM_DOOR_STATE                       ; $59
	const EVENT_YUKIS_ROOM_DOOR_STATE                     ; $5a
	const EVENT_SHOKOS_ROOM_DOOR_STATE                    ; $5b
	const EVENT_BEAT_HIDERO                               ; $5c
; GR Water Fort flags
	const EVENT_TALKED_TO_MIYAJIMA                        ; $5d
	const EVENT_TALKED_TO_SENTA                           ; $5e
	const EVENT_TALKED_TO_AIRA                            ; $5f
	const EVENT_TALKED_TO_KANOKO                          ; $60
	const EVENT_MIYAJIMAS_ROOM_DOOR_STATE                 ; $61
	const EVENT_SENTAS_ROOM_BRIDGE_STATE                  ; $62
	const EVENT_AIRAS_ROOM_BRIDGE_STATE                   ; $63
	const EVENT_BEAT_KANOKO                               ; $64
; GR Fighting Fort flags
	const EVENT_TALKED_TO_KAMIYA                          ; $65
	const EVENT_TALKED_TO_GODA                            ; $66
	const EVENT_TALKED_TO_GRACE                           ; $67
	const EVENT_BEAT_KAMIYA                               ; $68
	const EVENT_FREED_MITCH                               ; $69
	const EVENT_GRACES_ROOM_CHEST_STATE                   ; $6a
; GR Psychic Stronghold flags
	const EVENT_TALKED_TO_MIWA                            ; $6b
	const EVENT_TALKED_TO_KEVIN                           ; $6c
	const EVENT_TALKED_TO_YOSUKE                          ; $6d
	const EVENT_TALKED_TO_RYOKO                           ; $6e
	const EVENT_TALKED_TO_MAMI                            ; $6f
	const EVENT_BEAT_MIWA                                 ; $70
	const EVENT_BEAT_KEVIN                                ; $71
	const EVENT_BEAT_YOSUKE                               ; $72
	const EVENT_BEAT_RYOKO                                ; $73
	const EVENT_BEAT_MAMI                                 ; $74
; Colorless Altar flags
	const EVENT_TALKED_TO_NISHIJIMA                       ; $75
	const EVENT_TALKED_TO_ISHII                           ; $76
	const EVENT_TALKED_TO_SAMEJIMA                        ; $77
	const EVENT_BEAT_NISHIJIMA                            ; $78
	const EVENT_BEAT_ISHII                                ; $79
	const EVENT_BEAT_SAMEJIMA                             ; $7a
	const EVENT_BEAT_COLORLESS_ALTAR_MEMBERS              ; $7b
	const EVENT_TALKED_TO_NISHIJIMA_2                     ; $7c
	const EVENT_TALKED_TO_ISHII_2                         ; $7d
	const EVENT_TALKED_TO_SAMEJIMA_2                      ; $7e
; GR Castle flags
	const EVENT_TALKED_TO_KANZAKI                         ; $7f
	const EVENT_TALKED_TO_RUI                             ; $80
	const EVENT_BEAT_KANZAKI                              ; $81
	const EVENT_BEAT_RUI                                  ; $82
	const EVENT_MET_GR_GAL_ISHIHARAS_VILLA                ; $83
	const EVENT_TALKED_TO_BIRURITCHI                      ; $84
; Card Trade NPC flags
	const EVENT_TALKED_TO_TRADE_NPC_ROCK_CLUB             ; $85
	const EVENT_TALKED_TO_TRADE_NPC_FIGHTING_CLUB         ; $86
	const EVENT_TALKED_TO_TRADE_NPC_FIRE_CLUB             ; $87
	const EVENT_TALKED_TO_TRADE_NPC_LIGHTNING_CLUB        ; $88
	const EVENT_TALKED_TO_TRADE_NPC_PSYCHIC_CLUB          ; $89
	const EVENT_TALKED_TO_TRADE_NPC_TCG_CHALLENGE_HALL    ; $8a
	const EVENT_TALKED_TO_TRADE_NPC_GRASS_FORT            ; $8b
	const EVENT_TALKED_TO_TRADE_NPC_LIGHTNING_FORT        ; $8c
	const EVENT_TALKED_TO_TRADE_NPC_GR_CHALLENGE_HALL     ; $8d
	const EVENT_TALKED_TO_TRADE_NPC_FIRE_FORT             ; $8e
	const EVENT_TALKED_TO_TRADE_NPC_WATER_FORT            ; $8f
	const EVENT_TALKED_TO_TRADE_NPC_PSYCHIC_STRONGHOLD    ; $90
; Misc NPC flags
	const EVENT_91                                        ; $91
	const EVENT_92                                        ; $92
	const EVENT_TALKED_TO_SAM                             ; $93
	const EVENT_94                                        ; $94
; Ishihara flags
	const EVENT_TALKED_TO_ISHIHARA                        ; $95
	const EVENT_BATTLED_ISHIHARA                          ; $96
	const EVENT_TALKED_TO_ISHIHARA_POST_GAME              ; $97
; Cutscene trigger flags
	const EVENT_MET_GR1_ROCK_CLUB                         ; $98
	const EVENT_MET_GR4_LIGHTNING_CLUB                    ; $99
	const EVENT_MET_GR4_PSYCHIC_CLUB                      ; $9a
	const EVENT_MET_YUKI_FIRE_FORT                        ; $9b
	const EVENT_MET_FIGHTING_FORT_MEMBERS                 ; $9c
	const EVENT_MET_PSYCHIC_STRONGHOLD_MEMBERS            ; $9d
	const EVENT_MET_MAMI_AND_ROD                          ; $9e
	const EVENT_MET_COLORLESS_ALTAR_MEMBERS               ; $9f
	const EVENT_MET_BIRURITCHI_AND_ADMINS                 ; $a0
	const EVENT_GR_CASTLE_STAIRS_RUI_ROADBLOCK            ; $a1
	const EVENT_MET_RONALD_GAME_CENTER                    ; $a2
; GR member flags
	const EVENT_TALKED_TO_GR1_FIGHTING_CLUB               ; $a3
	const EVENT_TALKED_TO_GR2_SCIENCE_GRASS_CLUB          ; $a4
	const EVENT_TALKED_TO_GR3_WATER_CLUB                  ; $a5
	const EVENT_TALKED_TO_GR4_PSYCHIC_CLUB                ; $a6
	const EVENT_A7                                        ; $a7
	const EVENT_OBTAINED_TWO_GR_COIN_PIECES               ; $a8
	const EVENT_TALKED_TO_GR5_POKEMON_DOME                ; $a9
	const EVENT_TALKED_TO_GR5_TCG_AIRPORT                 ; $aa
; Card Trade flags
	const EVENT_TRADED_CARDS_ROCK_CLUB                    ; $ab
	const EVENT_TRADED_CARDS_FIGHTING_CLUB                ; $ac
	const EVENT_TRADED_CARDS_FIRE_CLUB                    ; $ad
	const EVENT_TRADED_CARDS_LIGHTNING_CLUB               ; $ae
	const EVENT_TRADED_CARDS_PSYCHIC_CLUB                 ; $af
	const EVENT_TRADED_CARDS_TCG_CHALLENGE_HALL           ; $b0
	const EVENT_B1                                        ; $b1
	const EVENT_B2                                        ; $b2
	const EVENT_TRADED_CARDS_GRASS_FORT                   ; $b3
	const EVENT_TRADED_CARDS_LIGHTNING_FORT               ; $b4
	const EVENT_TRADED_CARDS_GR_CHALLENGE_HALL            ; $b5
	const EVENT_TRADED_CARDS_FIRE_FORT                    ; $b6
	const EVENT_TRADED_CARDS_WATER_FORT                   ; $b7
	const EVENT_TRADED_CARDS_PSYCHIC_STRONGHOLD           ; $b8
; Cage flags
	const EVENT_GODAS_ROOM_CAGE_STATE                     ; $b9
	const EVENT_MIDORIS_ROOM_CAGE_STATE                   ; $ba
; Grand Master flags
	const EVENT_TALKED_TO_COURTNEY_POKEMON_DOME           ; $bb
	const EVENT_TALKED_TO_STEVE_POKEMON_DOME              ; $bc
	const EVENT_TALKED_TO_JACK_POKEMON_DOME               ; $bd
	const EVENT_ENTERED_GRAND_MASTER_CUP                  ; $be
	const EVENT_FREED_COURTNEY                            ; $bf
	const EVENT_FREED_STEVE                               ; $c0
	const EVENT_FREED_JACK                                ; $c1
	const EVENT_FREED_ROD                                 ; $c2
; Game Center flags
	const EVENT_MET_GAME_CENTER_CHIP_GIRL                 ; $c3
	const EVENT_TALKED_TO_SLOT_MACHINE_WOMAN              ; $c4
	const EVENT_TALKED_TO_COIN_TOSS_BOY                   ; $c5
; GR hall flag
	const EVENT_TALKED_TO_GR_CHALLENGE_MACHINE_STAFF      ; $c6
; Door flags
	const EVENT_LIGHTNING_FORT_ENTRANCE_DOOR_STATE        ; $c7
	const EVENT_FIRE_FORT_ENTRANCE_DOOR_STATE             ; $c8
	const EVENT_WATER_FORT_ENTRANCE_DOOR_STATE            ; $c9
	const EVENT_FIGHTING_FORT_ENTRANCE_DOOR_STATE         ; $ca
	const EVENT_INSERTED_LEFT_COIN_IN_FIGHTING_FORT_DOOR  ; $cb
	const EVENT_INSERTED_RIGHT_COIN_IN_FIGHTING_FORT_DOOR ; $cc
	const EVENT_CAN_TRAVEL_PAST_FIGHTING_FORT             ; $cd
	const EVENT_GR_CASTLE_ENTRANCE_DOOR_STATE             ; $ce
	const EVENT_INSERTED_LEFT_COIN_IN_GR_CASTLE_DOOR      ; $cf
	const EVENT_INSERTED_RIGHT_COIN_IN_GR_CASTLE_DOOR     ; $d0
	const EVENT_SEALED_FORT_DOOR_STATE                    ; $d1
; Chest flags
	const EVENT_OPENED_CHEST_GRACES_ROOM                  ; $d2
	const EVENT_OPENED_CHEST_FIGHTING_FORT_1              ; $d3
	const EVENT_OPENED_CHEST_FIGHTING_FORT_2              ; $d4
	const EVENT_OPENED_CHEST_FIGHTING_FORT_3              ; $d5
	const EVENT_OPENED_CHEST_FIGHTING_FORT_4              ; $d6
	const EVENT_OPENED_CHEST_FIGHTING_FORT_5              ; $d7
	const EVENT_OPENED_CHEST_FIGHTING_FORT_BASEMENT       ; $d8
; Flyover flag
	const EVENT_SHORT_GR_ISLAND_FLYOVER_SEQUENCE          ; $d9
; Pokemon Dome Cups flags
	const EVENT_WON_FINAL_CUP                             ; $da
	const EVENT_WON_GRAND_MASTER_CUP                      ; $db
; Ghost Master flags
	const EVENT_GHOST_MASTER_STATUES_STATE                ; $dc
	const EVENT_BATTLED_TOBICHAN                          ; $dd
	const EVENT_BATTLED_EIJI                              ; $de
	const EVENT_BATTLED_MAGICIAN                          ; $df
	const EVENT_BATTLED_TOSHIRON                          ; $e0
	const EVENT_BATTLED_PIERROT                           ; $e1
	const EVENT_BATTLED_ANNA                              ; $e2
	const EVENT_BATTLED_DEE                               ; $e3
	const EVENT_BATTLED_MASQUERADE                        ; $e4
	const EVENT_BATTLED_YUI                               ; $e5
; Card Dungeon flags
	const EVENT_TALKED_TO_PAWN                            ; $e6
	const EVENT_TALKED_TO_KNIGHT                          ; $e7
	const EVENT_TALKED_TO_BISHOP                          ; $e8
	const EVENT_TALKED_TO_ROOK                            ; $e9
	const EVENT_TALKED_TO_QUEEN                           ; $ea
; Misc flags
	const EVENT_EB                                        ; $eb
	const EVENT_TALKED_TO_ROD_POKEMON_DOME                ; $ec
	const EVENT_SET_UNTIL_MAP_RELOAD_1                    ; $ed
	const EVENT_EE                                        ; $ee
	const EVENT_EF                                        ; $ef
	const EVENT_F0                                        ; $f0
	const EVENT_SET_UNTIL_MAP_RELOAD_2                    ; $f1
	const EVENT_F2                                        ; $f2
	const EVENT_F3                                        ; $f3
	const EVENT_ISHIHARA_CARD_TRADE_STATE                 ; $f4
	const EVENT_ISHIHARA_LOCATION_STATE                   ; $f5
DEF NUM_EVENT_FLAGS EQU const_value

	const_def 1
	const GC_PIECES_1 ; 1
	const GC_PIECES_2 ; 2
	const GC_PIECES_3 ; 3
	const GC_PIECES_4 ; 4

; Ronald events
; - card pops after you leave Mason's Lab for the first time
; - challenges you at Fig/Grass/Sci/Fire/Psy Club after 2 GR Coin pieces, giving you Super Energy Retrieval only if you win
; - gives you 1 LEGENDARY_POWER at Water Club after you win GR3 there for the first time
; - gives you 2 ISLAND_OF_FOSSIL at Fig/Grass/Sci/Fire Club after 4 pieces, boasting he's got back stolen cards
; DEF RONALD_FIRST_CARD_POP  EQU $0
DEF RONALD_DUEL_GC_PIECES_2  EQU $1
DEF RONALD_GIFT_WON_GR3_ONCE EQU $1
DEF RONALD_GIFT_GC_PIECES_4  EQU $2

; Imakuni? event win-count thresholds, both Black and Red
DEF IMAKUNI_THRESHOLD_1 EQU $3
DEF IMAKUNI_THRESHOLD_2 EQU $6
DEF IMAKUNI_THRESHOLD_3 EQU $9

DEF EVENT_VAR_BYTES   EQU $34
DEF GENERAL_VAR_BYTES EQU $34

DEF PLAYER_MALE   EQU $0
DEF PLAYER_FEMALE EQU $1

DEF NORTH    EQU $00
DEF EAST     EQU $01
DEF SOUTH    EQU $02
DEF WEST     EQU $03

DEF MOVE_BACKWARDS  EQU %10000000 ; for when an NPC walks backwards
DEF MOVE_SPEED_WALK EQU 1
DEF MOVE_SPEED_RUN  EQU 2

; the true max is probably much lower. this is just the biggest 6-bit number.
DEF MAX_MOVEMENT EQU $3f

; generate MOVE_x constants for use in NPCMovement data.
; see also: script_extractor.py
; The raw data value = (number of steps to move << 2) + speed
; e.g. MOVE_2 = 0x09; RUN_2 = 0x0a
FOR N, MAX_MOVEMENT
	DEF MOVE_{d:N} EQU (N << 2) + MOVE_SPEED_WALK
	DEF RUN_{d:N} EQU (N << 2) + MOVE_SPEED_RUN
ENDR

; TODO: Identify WRAM to give them proper names
DEF wD606_STRUCT_SIZE  EQU $8
DEF SCRIPT_BUFFER_SIZE EQU $20
DEF SCRIPT_STACK_SIZE  EQU $10

DEF NUM_UNIQUE_MAILS_IN_GAME    EQU 29
DEF MAIL_MAX_NUM                EQU 8
DEF MAIL_MAX_ON_SCREEN          EQU 4
DEF MAIL_BUFFER_SIZE            EQU MAIL_MAX_NUM + 1
DEF MAIL_QUEUE_BUFFER_SIZE      EQU 25
DEF NEW_MAIL EQU $ff

DEF B_MAIL_READ EQU 7
DEF B_MAIL_PRIORITY_DELIVERY EQU 7

; mail attachments
	const_def 4
	const B_MAIL_BILLS_PC     ; 4
	const B_MAIL_BLACK_BOX    ; 5
	const B_MAIL_GENERIC_CARD ; 6
	const B_MAIL_BOOSTER_PACK ; 7

DEF MAIL_COMMAND_GIVE_BILLS_PC     EQU 1 << B_MAIL_BILLS_PC
DEF MAIL_COMMAND_GIVE_BLACK_BOX    EQU 1 << B_MAIL_BLACK_BOX
DEF MAIL_COMMAND_GIVE_GENERIC_CARD EQU 1 << B_MAIL_GENERIC_CARD
DEF MAIL_COMMAND_GIVE_BOOSTER      EQU 1 << B_MAIL_BOOSTER_PACK
DEF MAIL_TERMINATOR EQU $ffff

; TODO: Figure out why 2 is added in IngameCardPop
	const_def
	const SCRIPTED_CARD_POP_RONALD       ; $0
	const SCRIPTED_CARD_POP_IMAKUNI      ; $1
	const SCRIPTED_RARE_CARD_POP_IMAKUNI ; $2

; duel requirement IDs
; for DuelRequirementFunctionMap and duel_requirement_check script calls
	const_def
	const DUEL_REQUIREMENT_MIYUKI           ; $00
	const DUEL_REQUIREMENT_RENNA            ; $01
	const DUEL_REQUIREMENT_ICHIKAWA         ; $02
	const DUEL_REQUIREMENT_YUKI             ; $03
	const DUEL_REQUIREMENT_SHOKO            ; $04
	const DUEL_REQUIREMENT_MIYAJIMA         ; $05
	const DUEL_REQUIREMENT_SENTA            ; $06
	const DUEL_REQUIREMENT_GODA             ; $07
	const DUEL_REQUIREMENT_GRACE            ; $08
	const DUEL_REQUIREMENT_MIWA             ; $09
	const DUEL_REQUIREMENT_YOSUKE           ; $0a
	const DUEL_REQUIREMENT_RYOKO            ; $0b
	const DUEL_REQUIREMENT_NISHIJIMA_REROLL ; $0c
	const DUEL_REQUIREMENT_NISHIJIMA_USE    ; $0d
	const DUEL_REQUIREMENT_ISHII_REROLL     ; $0e
	const DUEL_REQUIREMENT_ISHII_USE        ; $0f
	const DUEL_REQUIREMENT_SAMEJIMA_REROLL  ; $10
	const DUEL_REQUIREMENT_SAMEJIMA_USE     ; $11
	const DUEL_REQUIREMENT_KANZAKI          ; $12

; booster pack list types, used by give_booster_packs
	const_def
	const BOOSTERS_GIVE_ALL    ; 0
	const BOOSTERS_GIVE_N      ; 1
	const BOOSTERS_GIVE_RANDOM ; 2
