-
Notifications
You must be signed in to change notification settings - Fork 10
/
basic_sprite.inc
53 lines (39 loc) · 1.03 KB
/
basic_sprite.inc
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
IF !DEF(EASY_SPRITE_INC)
; don't re-include if sprite.inc already INCLUDE'd
EASY_SPRITE_INC = 1
OAMDATALOC = _RAM ; set first 160 bytes of RAM to hold OAM variables
OAMDATALOCBANK = OAMDATALOC / $100 ; used by DMA_ROUTINE to point to _RAM
; set first sprite's properties (at $C000)
; these macros are for demo-ing only. The normal method is to declare a sprite
; with spr_Declare <sprite name> and then use spr_SetX, spr_GetY, etc...
spr_Setup1stSprite: MACRO
push af
push hl
ld hl, OAMDATALOC
ld [hl], \1 ; set X coordinate
inc hl
ld [hl], \2 ; set Y coordinate
inc hl
ld [hl], \3 ; set Tile #
inc hl
ld [hl], \4 ; set flags (default of 0 works)
pop hl
pop af
ENDM
; set first sprite's X,y coordinates
spr_Set1stSpriteX: MACRO
ld a, \1 ; load X into A
ld [OAMDATALOC], a
ENDM
spr_Set1stSpriteY: MACRO
ld a, \1
ld [OAMDATALOC + 1], a
ENDM
; get first sprite's X, Y coordinates
spr_Get1stSpriteX: MACRO
ld a, [OAMDATALOC]
ENDM
spr_Get1stSpriteY: MACRO
ld a, [OAMDATALOC + 1]
ENDM
ENDC ; end sprite.inc inclusion