-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw_hero.s
60 lines (49 loc) · 1.28 KB
/
draw_hero.s
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
; vim: set syntax=asm_ca65:
.include "constants.inc"
DOWN_SPRITE_L_ATTR = %00000000
DOWN_SPRITE_R_ATTR = %01000000
; 76543210
; --------
; ||||||||
; ||||||++-- Palette (4 to 7) of sprite
; |||+++---- Unimplemented (read 0)
; ||+------- Priority (0: in front of background; 1: behind background)
; |+-------- Flip sprite horizontally
; +--------- Flip sprite vertically
.segment "RODATA"
hero:
.byte $70, $01, DOWN_SPRITE_L_ATTR, $80 ; sprite 0
.byte $70, $01, DOWN_SPRITE_R_ATTR, $88 ; sprite 1
.byte $78, $11, DOWN_SPRITE_L_ATTR, $80 ; sprite 2
.byte $78, $11, DOWN_SPRITE_R_ATTR, $88 ; sprite 3
; | | | |
; | | | +-- x-coord
; | | +---------------------- tile attributes
; | +--------------------------- tile index
; +-------------------------------- y-coord
.segment "CODE"
.proc draw_hero
PHP
PHA
TXA
PHA
TYA
PHA
LDY #$00
; A -> PPU OAM hero data
; Y -> Hero sprite address offsetdra
loop:
LDA hero,Y
STA HERO_SPRITE_ADDR,Y
INY
CPY #$10
BNE loop
PLA
TAY
PLA
TAX
PLA
PLP
RTS
.endproc
.export draw_hero