summaryrefslogtreecommitdiff
path: root/src/macros/code.asm
diff options
context:
space:
mode:
Diffstat (limited to 'src/macros/code.asm')
-rw-r--r--src/macros/code.asm56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/macros/code.asm b/src/macros/code.asm
new file mode 100644
index 0000000..47b698f
--- /dev/null
+++ b/src/macros/code.asm
@@ -0,0 +1,56 @@
+INCROM: MACRO
+INCBIN "baserom.gbc", \1, \2 - \1
+ENDM
+
+const_def: MACRO
+if _NARG > 0
+const_value = \1
+else
+const_value = 0
+endc
+ENDM
+
+const: MACRO
+\1 EQU const_value
+const_value = const_value + 1
+ENDM
+
+lb: MACRO ; r, hi, lo
+ ld \1, (\2) << 8 + ((\3) & $ff)
+ENDM
+
+ldtx: MACRO
+ ld \1, \2_
+ENDM
+
+bank1call: MACRO
+ rst $18
+ dw \1
+ENDM
+
+farcall: MACRO
+ rst $28
+ db BANK(\1)
+ dw \1
+ENDM
+
+; used when the specified bank does not match the bank of the specified function
+; otherwise, farcall is preferred
+farcallx: MACRO
+ rst $28
+ db \1
+ dw \2
+ENDM
+
+emptybank: MACRO
+ rept $4000
+ db $ff
+ endr
+ENDM
+
+textpointer: MACRO
+ dw ((\1 + ($4000 * (BANK(\1) - 1))) - (TextOffsets + ($4000 * (BANK(TextOffsets) - 1)))) & $ffff
+ db ((\1 + ($4000 * (BANK(\1) - 1))) - (TextOffsets + ($4000 * (BANK(TextOffsets) - 1)))) >> 16
+ const \1_
+GLOBAL \1_
+ENDM