-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLink.S
120 lines (103 loc) · 1.56 KB
/
Link.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
.SEGMENT "RODATA"
player_x: .byte $0F
player_y .byte $0F
player_lives: .byte $03
player_strength: .byte $0F
inventory_system: .byte $0F
.SEGMENT "CODE"
.org $8000
_decrementLives:
lda player_lives
cmp #0
beq .done
clc
sec ; Set carry flag
sbc a ; Subtract accumulator by 1
sta player_lives
.done:
rts
_incrementLives:
lda player_lives
cmp #10
beq .done
clc
sec
adc a ; Increment the accumulator by 1
sta player_lives
.done:
rts
_incrementStrength:
lda player_strength
cmp #20
beq .done
clc
sec
adc a
sta player_strength
.done:
rts
_decrementStrength:
lda player_strength
cmp #0
beq .done
clc
sec
sbc a
sta player_strength
.done:
rts
_incrementX:
lda player_x
cmp #1000
beq .done
clc
sec
adc a
sta player_x
.done:
rts
_decrementX:
lda player_x
cmp #0
beq .done
clc
sec
sbc a
sta player_x
.done:
rts
_incrementY:
; Check if the player's Y axis == screen X
lda player_y
cmp #1000
beq .done
; Increment player's Y axis
clc
sec
adc a
; Store the new value of Y into link_y
sta player_y
.done
rts
_decrementY:
; Check if the player's Y axis > 0
lda player_y
cmp #0
beq .done
; Decrement the player's Y axis
clc ; Clear carry flag
sec
sbc #1
sta player_y
.done:
rts
_inventorySystem:
; Check if the inventory is full
lda inventory_system
cmp #$0F
beq .done
; Get the object and store it into the byte
lda ($0004)
sta inventory_system
.done:
rts