diff options
-rw-r--r-- | include/code_macros.inc | 54 | ||||
-rw-r--r-- | include/const_macros.inc | 43 | ||||
-rw-r--r-- | include/gfx_macros.inc | 16 | ||||
-rw-r--r-- | include/macros.inc | 117 | ||||
-rw-r--r-- | source/bank_00.asm | 3 | ||||
-rw-r--r-- | source/bank_01.asm | 4 | ||||
-rw-r--r-- | source/bank_02.asm | 2 | ||||
-rw-r--r-- | source/bank_05.asm | 3 | ||||
-rw-r--r-- | source/bank_20.asm | 3 | ||||
-rw-r--r-- | source/bank_28.asm | 2 | ||||
-rw-r--r-- | source/bank_7c.asm | 2 |
11 files changed, 125 insertions, 124 deletions
diff --git a/include/code_macros.inc b/include/code_macros.inc new file mode 100644 index 0000000..531281d --- /dev/null +++ b/include/code_macros.inc @@ -0,0 +1,54 @@ +lb: macro + ld \1, ((\2) & $ff) << 8 | ((\3) & $ff) +endm + +ln: macro + ld \1, ((\2) & $f) << 4 | ((\3) & $f) +endm + +ld16: macro + ld a, LOW(\2) + ld [\1 + 0], a + ld a, HIGH(\2) + ld [\1 + 1], a +endm + + +farcall: macro + push af + ld a, LOW(\1) + ld [w_farcall_target + 0], a + ld a, HIGH(\1) + ld [w_farcall_target + 1], a + ld a, BANK(\1) + ld [w_bank_temp], a + pop af + call _farcall +endm + +farjp: macro + push af + ld a, LOW(\1) + ld [w_farcall_target + 0], a + ld a, HIGH(\1) + ld [w_farcall_target + 1], a + ld a, BANK(\1) + ld [w_bank_temp], a + pop af + jp _farjp +endm + + +push_bank_rom: macro + ld a, [w_bank_rom] + push af + ld a, \1 + ld [w_bank_rom], a + ld [rROMB0], a +endm + +pop_bank_rom: macro + pop af + ld [w_bank_rom], a + ld [rROMB0], a +endm diff --git a/include/const_macros.inc b/include/const_macros.inc new file mode 100644 index 0000000..5cbdd2a --- /dev/null +++ b/include/const_macros.inc @@ -0,0 +1,43 @@ +const_def: macro +if _NARG >= 1 +const_value = \1 +else +const_value = 0 +endc +if _NARG >= 2 +const_inc = \2 +else +const_inc = 1 +endc +endm + +const: macro +\1 EQU const_value +const_value = const_value + const_inc +endm + +shift_const: macro +\1 EQU (1 << const_value) +const_value = const_value + const_inc +endm + +const_skip: macro +if _NARG >= 1 +const_value = const_value + const_inc * (\1) +else +const_value = const_value + const_inc +endc +endm + +const_next: macro +if (const_value > 0 && \1 < const_value) || (const_value < 0 && \1 > const_value) +fail "const_next cannot go backwards from {const_value} to \1" +else +const_value = \1 +endc +endm + +const_dw: macro + const \1 + dw \2 +endm diff --git a/include/gfx_macros.inc b/include/gfx_macros.inc new file mode 100644 index 0000000..ad52e32 --- /dev/null +++ b/include/gfx_macros.inc @@ -0,0 +1,16 @@ +RGB: macro + rept _NARG / 3 + dw palred (\1) + palgreen (\2) + palblue (\3) + shift 3 + endr +endm + +palred EQUS "(1 << 0) *" +palgreen EQUS "(1 << 5) *" +palblue EQUS "(1 << 10) *" + +palettes EQUS "* PALETTE_SIZE" +palette EQUS "+ PALETTE_SIZE *" +color EQUS "+ PAL_COLOR_SIZE *" + +tiles EQUS "* $10" diff --git a/include/macros.inc b/include/macros.inc deleted file mode 100644 index 2f1d433..0000000 --- a/include/macros.inc +++ /dev/null @@ -1,117 +0,0 @@ -farcall: macro - push af - ld a, LOW(\1) - ld [w_farcall_target + 0], a - ld a, HIGH(\1) - ld [w_farcall_target + 1], a - ld a, BANK(\1) - ld [w_bank_temp], a - pop af - call _farcall -endm - -farjp: macro - push af - ld a, LOW(\1) - ld [w_farcall_target + 0], a - ld a, HIGH(\1) - ld [w_farcall_target + 1], a - ld a, BANK(\1) - ld [w_bank_temp], a - pop af - jp _farjp -endm - - -push_bank_rom: macro - ld a, [w_bank_rom] - push af - ld a, \1 - ld [w_bank_rom], a - ld [rROMB0], a -endm - -pop_bank_rom: macro - pop af - ld [w_bank_rom], a - ld [rROMB0], a -endm - - -RGB: macro - rept _NARG / 3 - dw palred (\1) + palgreen (\2) + palblue (\3) - shift 3 - endr -endm - -palred EQUS "(1 << 0) *" -palgreen EQUS "(1 << 5) *" -palblue EQUS "(1 << 10) *" - -palettes EQUS "* PALETTE_SIZE" -palette EQUS "+ PALETTE_SIZE *" -color EQUS "+ PAL_COLOR_SIZE *" - -tiles EQUS "* $10" - - -lb: macro - ld \1, ((\2) & $ff) << 8 | ((\3) & $ff) -endm - -ln: macro - ld \1, ((\2) & $f) << 4 | ((\3) & $f) -endm - -ld16: macro - ld a, LOW(\2) - ld [\1 + 0], a - ld a, HIGH(\2) - ld [\1 + 1], a -endm - - -const_def: macro -if _NARG >= 1 -const_value = \1 -else -const_value = 0 -endc -if _NARG >= 2 -const_inc = \2 -else -const_inc = 1 -endc -endm - -const: macro -\1 EQU const_value -const_value = const_value + const_inc -endm - -shift_const: macro -\1 EQU (1 << const_value) -const_value = const_value + const_inc -endm - -const_skip: macro -if _NARG >= 1 -const_value = const_value + const_inc * (\1) -else -const_value = const_value + const_inc -endc -endm - -const_next: macro -if (const_value > 0 && \1 < const_value) || (const_value < 0 && \1 > const_value) -fail "const_next cannot go backwards from {const_value} to \1" -else -const_value = \1 -endc -endm - -const_dw: macro - const \1 - dw \2 -endm diff --git a/source/bank_00.asm b/source/bank_00.asm index 81b99a9..b2587ee 100644 --- a/source/bank_00.asm +++ b/source/bank_00.asm @@ -1,6 +1,7 @@ INCLUDE "charmap.inc" INCLUDE "hardware.inc" -INCLUDE "macros.inc" +INCLUDE "code_macros.inc" +INCLUDE "const_macros.inc" SECTION "reset", ROM0[$0000] reset:: diff --git a/source/bank_01.asm b/source/bank_01.asm index 5cb8f34..a4b95bc 100644 --- a/source/bank_01.asm +++ b/source/bank_01.asm @@ -1,4 +1,6 @@ -INCLUDE "macros.inc" +INCLUDE "code_macros.inc" +INCLUDE "const_macros.inc" +INCLUDE "gfx_macros.inc" INCLUDE "level_constants.inc" INCLUDE "puzzle_constants.inc" diff --git a/source/bank_02.asm b/source/bank_02.asm index 7b25e93..a98d5dc 100644 --- a/source/bank_02.asm +++ b/source/bank_02.asm @@ -1,5 +1,5 @@ INCLUDE "charmap.inc" -INCLUDE "macros.inc" +INCLUDE "code_macros.inc" SECTION "text_char", ROMX[$4bf7], BANK[$02] far_textbox_print_char:: diff --git a/source/bank_05.asm b/source/bank_05.asm index a479f82..2b99243 100644 --- a/source/bank_05.asm +++ b/source/bank_05.asm @@ -1,5 +1,6 @@ INCLUDE "hardware.inc" -INCLUDE "macros.inc" +INCLUDE "code_macros.inc" +INCLUDE "const_macros.inc" SECTION "tutorial", ROMX[$4000], BANK[$05] diff --git a/source/bank_20.asm b/source/bank_20.asm index 79d67cc..435c010 100644 --- a/source/bank_20.asm +++ b/source/bank_20.asm @@ -1,4 +1,5 @@ -INCLUDE "macros.inc" +INCLUDE "code_macros.inc" +INCLUDE "const_macros.inc" INCLUDE "level_constants.inc" INCLUDE "puzzle_constants.inc" diff --git a/source/bank_28.asm b/source/bank_28.asm index e5d96fe..bd5f1ce 100644 --- a/source/bank_28.asm +++ b/source/bank_28.asm @@ -1,5 +1,5 @@ INCLUDE "hardware.inc" -INCLUDE "macros.inc" +INCLUDE "code_macros.inc" SECTION "function_28_426a", ROMX[$426a], BANK[$28] diff --git a/source/bank_7c.asm b/source/bank_7c.asm index 2c5f5da..82efa46 100644 --- a/source/bank_7c.asm +++ b/source/bank_7c.asm @@ -1,4 +1,4 @@ -INCLUDE "macros.inc" +INCLUDE "gfx_macros.inc" SECTION "gfx_alphabets", ROMX[$4000], BANK[$7c] gfx_alphabets:: |