diff options
author | yenatch <yenatch@gmail.com> | 2017-12-23 13:17:46 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-23 13:17:46 -0500 |
commit | 878092004956418bfd77bfdb9fc9dd7f640f80d2 (patch) | |
tree | 3a97e3eb15d5c545977038e67589f92158e5bf23 /macros/code.asm | |
parent | a6656a986bf9dde51561cab090648e0117b173ad (diff) | |
parent | 3c37bfc6fa2570a0a77c1230673910257ecf32df (diff) |
Merge pull request #419 from roukaour/master
More reorganization and documentation
Diffstat (limited to 'macros/code.asm')
-rw-r--r-- | macros/code.asm | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/macros/code.asm b/macros/code.asm new file mode 100644 index 000000000..5e247e9a3 --- /dev/null +++ b/macros/code.asm @@ -0,0 +1,55 @@ +; Syntactic sugar macros + +lb: MACRO ; r, hi, lo + ld \1, (\2 & $ff) << 8 + (\3 & $ff) + ENDM + +ln: MACRO ; r, hi, lo + ld \1, (\2 & $f) << 4 + (\3 & $f) + ENDM + +ldpixel: MACRO +if _NARG >= 5 + lb \1, \2 * 8 + \4, \3 * 8 + \5 +else + lb \1, \2 * 8, \3 * 8 +endc +endm + +depixel EQUS "ldpixel de," +bcpixel EQUS "ldpixel bc," + + +; Design patterns + +jumptable: MACRO + ld a, [\2] + ld e, a + ld d, 0 + ld hl, \1 + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp hl +endm + +; Many mobile functions were dummied out in localization. +mobile EQUS "ret" + +maskbits: macro +; example usage in rejection sampling: +; .loop +; call Random +; maskbits 30 +; cp 30 +; jr nc, .loop +x = 1 +rept 8 +IF \1 > x +x = (x + 1) * 2 +- 1 +ENDC +endr + and x +endm |