summaryrefslogtreecommitdiff
path: root/macros/data.asm
diff options
context:
space:
mode:
Diffstat (limited to 'macros/data.asm')
-rwxr-xr-xmacros/data.asm75
1 files changed, 41 insertions, 34 deletions
diff --git a/macros/data.asm b/macros/data.asm
index 32903b0f..5b9614fe 100755
--- a/macros/data.asm
+++ b/macros/data.asm
@@ -1,7 +1,30 @@
; Value macros
+; Many arbitrary percentages are simple base-10 or base-16 values:
+; - 10 = 4 percent
+; - 15 = 6 percent
+; - $10 = 6 percent + 1 = 7 percent - 1
+; - 20 = 8 percent
+; - 25 = 10 percent
+; - 30 = 12 percent
+; - 40 = 16 percent
+; - 50 = 20 percent - 1
+; - 60 = 24 percent - 1
+; - 70 = 28 percent - 1
+; - 80 = 31 percent + 1 = 32 percent - 1
+; - 85 = 33 percent + 1 = 34 percent - 1
+; - 100 = 39 percent + 1 = 40 percent - 2
+; - 120 = 47 percent + 1
+; - 123 = 49 percent - 1
+; - 160 = 63 percent
+; - 180 = 71 percent - 1 = 70 percent + 2
+; - 200 = 79 percent - 1
+; - 230 = 90 percent + 1
percent EQUS "* $ff / 100"
+; e.g. 1 out_of 2 == 50 percent + 1 == $80
+out_of EQUS "* $100 /"
+
; Constant data (db, dw, dl) macros
dwb: MACRO
@@ -32,18 +55,14 @@ ENDM
dn: MACRO ; nybbles
rept _NARG / 2
db ((\1) << 4) | (\2)
- shift
- shift
+ shift 2
endr
ENDM
dc: MACRO ; "crumbs"
rept _NARG / 4
db ((\1) << 6) | ((\2) << 4) | ((\3) << 2) | (\4)
- shift
- shift
- shift
- shift
+ shift 4
endr
ENDM
@@ -51,7 +70,7 @@ dx: MACRO
x = 8 * ((\1) - 1)
rept \1
db ((\2) >> x) & $ff
-x = x + -8
+x = x - 8
endr
ENDM
@@ -81,32 +100,22 @@ rept _NARG
endr
ENDM
+; Reverses FixPicBank in engine/gfx/load_pics.asm
+;
+; Takes the actual bank of the pic in the ROM and returns the "defined" bank
+; $1f -> $13
+; $20 -> $14
+; $2e -> $1f
+;
+; Otherwise, the ROM bank will match the defined bank.
dba_pic: MACRO ; dbw bank, address
- db BANK(\1) - PICS_FIX
+ db (BANK(\1) == $1f) * ($13 - $1f) \
+ + (BANK(\1) == $20) * ($14 - $20) \
+ + (BANK(\1) == $2e) * ($1f - $2e) \
+ + (BANK(\1))
dw \1
ENDM
-dbpixel: MACRO
-if _NARG >= 4
-; x tile, x pxl, y tile, y pxl
- db \1 * 8 + \3, \2 * 8 + \4
-else
-; x, y
- db \1 * 8, \2 * 8
-endc
-ENDM
-
-dsprite: MACRO
-; y tile, y pxl, x tile, x pxl, vtile offset, attributes
- db (\1 * 8) % $100 + \2, (\3 * 8) % $100 + \4, \5, \6
-ENDM
-
-menu_coords: MACRO
-; x1, y1, x2, y2
- db \2, \1 ; start coords
- db \4, \3 ; end coords
-ENDM
-
bcd: MACRO
rept _NARG
dn ((\1) % 100) / 10, (\1) % 10
@@ -116,11 +125,9 @@ ENDM
sine_table: MACRO
; \1: amplitude
-
x = 0
- rept $20
- ; Round up.
- dw (sin(x) + (sin(x) & $ff)) >> 8
+rept 32
+ dw (sin(x) + (sin(x) & $ff)) >> 8 ; round up
x = x + (\1) * $40000
- endr
+endr
ENDM