This repository was archived by the owner on Sep 21, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMacros.asm
More file actions
58 lines (51 loc) · 1.77 KB
/
Macros.asm
File metadata and controls
58 lines (51 loc) · 1.77 KB
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
; ================================================================
; Macros
; ================================================================
; ================================================================
; Global macros
; ================================================================
; Wait for VRAM accessibility.
macro WaitForVRAM
ldh a,[rSTAT]
and STATF_BUSY
jr nz,@-4
endm
; Copy a tileset to a specified VRAM address.
; USAGE: CopyTileset [tileset],[VRAM address],[number of tiles to copy]
; "tiles" refers to any tileset.
macro CopyTileset
ld bc,$10*\3 ; number of tiles to copy
ld hl,\1 ; address of tiles to copy
ld de,$8000+\2 ; address to copy to
.loop
ld a,[hl+]
ld [de],a
inc de
dec bc
ld a,b
or c
jr nz,.loop
endm
; Copy a 1BPP tileset to a specified VRAM address.
; USAGE: CopyTileset1BPP [tileset],[VRAM address],[number of tiles to copy]
; "tiles" refers to any tileset.
macro CopyTileset1BPP
ld bc,$10*\3 ; number of tiles to copy
ld hl,\1 ; address of tiles to copy
ld de,$8000+\2 ; address to copy to
.loop
ld a,[hl+] ; get tile
ld [de],a ; write tile
inc de ; increment destination address
ld [de],a ; write tile again
inc de ; increment destination address again
dec bc
dec bc ; since we're copying two tiles, we need to dec bc twice
ld a,b
or c
jr nz,.loop
endm
; ================================================================
; Project-specific macros
; ================================================================
; Insert project-specific macros here.