~nytpu/ankano unlisted

ref: d2e19612bcef6363dbe24e99a7496981c4b08460 ankano/include/defines.asm -rw-r--r-- 2.0 KiB
d2e19612nytpu update game map and remove superfluous allocation from header 4 months ago
                                                                                
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
; defines.asm
; definitions that are used in the rest of the program
;
; Copyright (C) 2020 nytpu
; SPDX-License-Identifier: GPL-3.0-or-later
; For more license details, see LICENSE or <https://www.gnu.org/licenses/>.
;
; This file incorporates code from:
; Copyright (C) 2018-2020 Eldred Habert
; See LICENSE_MIT or <https://opensource.org/licenses/MIT>

; include the libraries
INCLUDE "hardware.inc/hardware.inc"
	rev_Check_hardware_inc 3.0

; structs is broken on newest rgbds version
;INCLUDE "rgbds-structs/structs.asm"


/* broken
; struct definitions
	struct PlayerStruct
	bytes 1, YPos
	bytes 1, XPos
	bytes 1, YBox
	bytes 1, XBox
	bytes 1, Attr
	bytes 3, Tiles
	end_struct
*/

; a couple more hardware defines
NB_SPRITES equ 40


; I generally discourage the use of pseudo-instructions for a variety of reasons,
; but this one includes a label, and manually giving them different names is tedious.
wait_vram: MACRO
.waitVRAM\@
	ldh a, [rSTAT]
	and STATF_BUSY
	jr nz, .waitVRAM\@
ENDM

; `ld b, X` followed by `ld c, Y` is wasteful (same with other reg pairs).
; This writes to both halves of the pair at once, without sacrificing readability
; Example usage: `lb bc, X, Y`
lb: MACRO
	assert -128 <= (\2) && (\2) <= 255, "Second argument to `lb` must be 8-bit!"
	assert -128 <= (\3) && (\3) <= 255, "Third argument to `lb` must be 8-bit!"
	ld \1, ((\2) << 8) | (\3)
ENDM

; 64 bytes, should be sufficient for most purposes. If you're really starved on
; memory check your stack usage and consider setting this to 32 instead.
; 16 is probably not enough.
STACK_SIZE equ $40


; Use this to cause a crash.
; I don't recommend using this unless you want a condition:
; `call cc, Crash` is 3 bytes (`cc` being a condition); `error cc` is only 2 bytes
; This should help minimize the impact of error checking
error: MACRO
	IF _NARG == 0
		rst Crash
	ELSE
		assert Crash == $0038
		; This assembles to XX FF (with XX being the `jr` instruction)
		; If the condition is fulfilled, this jumps to the operand: $FF
		; $FF encodes the instruction `rst $38`!
		jr \1, @-1
	ENDC
ENDM