diff options
author | yenatch <yenatch@gmail.com> | 2018-02-25 22:39:51 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-25 22:39:51 -0500 |
commit | 725148443f0ed0f70af747259ef49643359e92a2 (patch) | |
tree | 5f8ccf80489e0820934d40a732a5ce8d7f65e1e3 /macros/data.asm | |
parent | f44f306cfd4b438d0ba2f56b61be4b118ef3274b (diff) | |
parent | 7453bd1aa8e55a1a9fcce7c69f62106f5e5f6e9c (diff) |
Merge pull request #476 from Rangi42/master
Resolve some issues; rename some maps; move more tables into data/; warp_def → warp_event (ready to merge)
Diffstat (limited to 'macros/data.asm')
-rw-r--r-- | macros/data.asm | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/macros/data.asm b/macros/data.asm index 8345a2523..ad2d9b8ef 100644 --- a/macros/data.asm +++ b/macros/data.asm @@ -1,3 +1,8 @@ +; Value macros + +percent EQUS "* $ff / 100" + + ; Constant data (db, dw, dl) macros dwb: MACRO @@ -26,29 +31,29 @@ dbwww: MACRO ENDM dn: MACRO ; nybbles - rept _NARG / 2 +rept _NARG / 2 db ((\1) << 4) | (\2) shift shift - endr +endr ENDM dc: MACRO ; "crumbs" - rept _NARG / 4 +rept _NARG / 4 db ((\1) << 6) | ((\2) << 4) | ((\3) << 2) | (\4) shift shift shift shift - endr +endr ENDM dx: MACRO x = 8 * ((\1) - 1) - rept \1 +rept \1 db ((\2) >> x) & $ff x = x + -8 - endr +endr ENDM dt: MACRO ; three-byte (big-endian) @@ -64,17 +69,17 @@ bigdw: MACRO ; big-endian word ENDM dba: MACRO ; dbw bank, address - rept _NARG +rept _NARG dbw BANK(\1), \1 shift - endr +endr ENDM dab: MACRO ; dwb address, bank - rept _NARG +rept _NARG dwb \1, BANK(\1) shift - endr +endr ENDM dba_pic: MACRO ; dbw bank, address @@ -106,20 +111,19 @@ menu_coords: MACRO ENDM -sine_wave: MACRO -; \1: amplitude -x = 0 - rept $20 - ; Round up. - dw (sin(x) + (sin(x) & $ff)) >> 8 -x = x + (\1) * $40000 - endr -ENDM - - bcd: MACRO - rept _NARG +rept _NARG dn ((\1) % 100) / 10, (\1) % 10 shift - endr +endr +ENDM + + +sine_table: MACRO +; \1 samples of sin(x) from x=0 to x<32768 (pi radians) +x = 0 +rept \1 + dw (sin(x) + (sin(x) & $ff)) >> 8 ; round up +x = x + DIV(32768, \1) ; a circle has 65536 "degrees" +endr ENDM |