summaryrefslogtreecommitdiff
path: root/src/macros/data.asm
blob: 17c4b8e4add93359a6b1a667a45bebfc0b028c09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
dn: MACRO
	db \1 << 4 | \2
ENDM

dbw: MACRO
	db \1
	dw \2
ENDM

dwb: MACRO
	dw \1
	db \2
ENDM

dx: MACRO
x = 8 * ((\1) - 1)
	rept \1
	db ((\2) >> x) & $ff
x = x - 8
	endr
	ENDM

dt: MACRO ; three-byte (big-endian)
	dx 3, \1
	ENDM

dd: MACRO ; four-byte (big-endian)
	dx 4, \1
	ENDM

bigdw: MACRO ; big-endian word
	dx 2, \1
	ENDM

sgb: MACRO
	db \1 << 3 + \2 ; sgb_command * 8 + length
ENDM

rgb: MACRO
	dw (\3 << 10 | \2 << 5 | \1)
ENDM

; poketcg specific macros below

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_
EXPORT \1_
ENDM

energy: MACRO
en = 0
if _NARG > 1
	rept _NARG / 2
x = 4 - 8 * (\1 % 2)
en = en + \2 << ((\1 * 4) + x)
	shift
	shift
	endr
	rept NUM_TYPES / 2
	db LOW(en)
en = en >> 8
	endr
else
	db 0, 0, 0, 0
endc
ENDM

gfx: MACRO
	dw ($4000 * (BANK(\1) - BANK(CardGraphics)) + (\1 - $4000)) / 8
ENDM

frame_table: MACRO
	db BANK(\1) - BANK(AnimData1) ; maybe use better reference for Bank20?
	dw \1
ENDM

frame_data: MACRO
	db \1 ; frame index
	db \2 ; anim count
	db \3 ; x translation
	db \4 ; y translation
ENDM

tx: MACRO
	dw \1_
ENDM

textitem: MACRO
	db \1, \2
	tx \3
ENDM

; cursor x / cursor y / attribute / idx-up / idx-down / idx-right / idx-left
; idx-[direction] means the index to get when the input is in the direction.
; its attribute is used for drawing a flipped cursor.
cursor_transition: MACRO
	db \1, \2, \3
	rept 4
		db \4
		shift
	endr
ENDM