-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_hero_x.s
59 lines (43 loc) · 857 Bytes
/
update_hero_x.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
; vim: set syntax=asm_ca65:
.include "constants.inc"
.segment "ZEROPAGE"
.import hero_x_coord
.import controller_1_input
.segment "CODE"
.proc update_hero_x
PHP
PHA
TXA
PHA
TYA
PHA
LDA controller_1_input
AND #BTN_LEFT
BEQ check_right
DEC hero_x_coord
check_right:
LDA controller_1_input
AND #BTN_RIGHT
BEQ done_checking
INC hero_x_coord
done_checking:
LDA hero_x_coord
LDX #$03 ; offset
STA HERO_SPRITE_ADDR, X ; write sprite-0 x-coord
LDX #$0b ; offset
STA HERO_SPRITE_ADDR, X ; write sprite-2 x-coord
CLC
ADC #$08
LDX #$07 ; offset
STA HERO_SPRITE_ADDR, X ; write sprite-1 x-coord
LDX #$0f ; offset
STA HERO_SPRITE_ADDR, X ; write sprite-3 x-coord
PLA
TAY
PLA
TAX
PLA
PLP
RTS
.endproc
.export update_hero_x