Overview
Macros in the Pokémon Red/Blue disassembly provide reusable code patterns that make assembly programming more readable and maintainable. All macro definitions are inmacros/*.asm files.
Macros expand at assembly time, replacing macro invocations with their defined code sequences. This allows complex operations to be expressed concisely.
Macro Categories
The disassembly organizes macros into several categories:- const.asm - Constant enumeration macros
- farcall.asm - Bank switching and far call macros
- coords.asm - Screen coordinate calculation macros
- data.asm - Data structure and value macros
- ram.asm - Memory structure definition macros
- gfx.asm - Graphics-related macros
- predef.asm - Predefined function call macros
Constant Macros
File:macros/const.asm
const_def - Initialize Enumeration
const_def - Initialize Enumeration
const - Define Constant
const - Define Constant
const_skip - Skip Values
const_skip - Skip Values
const_next - Jump to Value
const_next - Jump to Value
shift_const - Bit Flag Constants
shift_const - Bit Flag Constants
Far Call Macros
File:macros/farcall.asm
farcall - Call Function in Different Bank
farcall - Call Function in Different Bank
farcall
Calls a function in a different ROM bank using the bank switching mechanism.Definition:callfar - Alternative Call Order
callfar - Alternative Call Order
callfar
Identical tofarcall but loads registers in a different order.Definition:farcall and callfar is purely stylistic - they produce the same result.farjp - Jump to Different Bank
farjp - Jump to Different Bank
homecall - Call with Bank Restore
homecall - Call with Bank Restore
homecall
Calls a function in a different bank and automatically restores the previous bank.Definition:Coordinate Macros
File:macros/coords.asm
coord - Load Screen Coordinate
coord - Load Screen Coordinate
coord / hlcoord / bccoord / decoord
Calculates a screen coordinate address and loads it into a register pair.Definition:dwcoord - Coordinate Data Word
dwcoord - Coordinate Data Word
ldcoord_a / lda_coord - Direct Coordinate Access
ldcoord_a / lda_coord - Direct Coordinate Access
ldcoord_a / lda_coord
Directly reads or writes the accumulator to a screen coordinate.Definition:Data Macros
File:macros/data.asm
dbw / dwb - Mixed Data
dbw / dwb - Mixed Data
dn - Nybbles (4-bit pairs)
dn - Nybbles (4-bit pairs)
dba / dab - Bank + Address
dba / dab - Bank + Address
tmhm - TM/HM Learn Flags
tmhm - TM/HM Learn Flags
bcd2 / bcd3 - Binary Coded Decimal
bcd2 / bcd3 - Binary Coded Decimal
RAM Structure Macros
File:macros/ram.asm
box_struct - Box Pokémon Structure
box_struct - Box Pokémon Structure
party_struct - Party Pokémon Structure
party_struct - Party Pokémon Structure
battle_struct - Battle Pokémon Structure
battle_struct - Battle Pokémon Structure
spritestatedata1 / spritestatedata2 - Sprite Structures
spritestatedata1 / spritestatedata2 - Sprite Structures
spritestatedata1 / spritestatedata2
Define sprite state data structures for map sprites.Definition:Best Practices
Use Meaningful Names
Validate Inputs
Document Parameters
Keep Macros Simple
Related Pages
- Constants Reference - Constant definition system
- Data Structures - Memory layouts using macros
- Engine Modules - Macros in action