-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfood.asm
168 lines (140 loc) · 2.81 KB
/
food.asm
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
.export FoodConstructor
.export FoodExecute
.export FoodDraw
.export food_kind
.include "include.branch-macros.asm"
.include "include.mov-macros.asm"
.include "include.sprites.asm"
.include "object_list.h.asm"
.include "sprite_space.h.asm"
.include "random.h.asm"
.include "points.h.asm"
.include "shared_object_values.asm"
.include "draw_picture.h.asm"
.include ".b/pictures.h.asm"
.include "sound.h.asm"
.importzp camera_h, camera_screen
.importzp player_health_delta
.importzp draw_screen
.importzp values
which_food = values + $08
.import object_data_extend
food_kind = object_data_extend + $00
FOOD_KIND_APPLE = 0
FOOD_KIND_STEAK = 1
FOOD_KIND_GRAPES = 2
FOOD_KIND_ICE_CREAM = 3
FOOD_KIND_BRKFAST = 4
LIFE_GAIN_APPLE = 2
LIFE_GAIN_STEAK = 5
LIFE_GAIN_GRAPES = 2
LIFE_GAIN_ICE_CREAM = 1
LIFE_GAIN_BRKFAST = 3
.segment "CODE"
.proc FoodConstructor
tya
sta food_kind,x
rts
.endproc
.proc FoodExecute
.scope MaybeDespawn
jsr ObjectOffscreenDespawn
bcc Okay
rts
Okay:
.endscope
.scope CollisionWithPlayer
jsr ObjectCollisionWithPlayer
bcc Next
DidCollide:
; Play sound of getting an item
lda #SFX_COLLECT_ITEM
jsr SoundPlay
; Rest
mov draw_v, {object_v,x}
mov draw_h, {object_h,x}
mov draw_screen, {object_screen,x}
lda food_kind,x
beq PointsApple
cmp #FOOD_KIND_STEAK
beq PointsSteak
cmp #FOOD_KIND_GRAPES
beq PointsGrapes
cmp #FOOD_KIND_ICE_CREAM
beq PointsIceCream
cmp #FOOD_KIND_BRKFAST
beq PointsBrkfast
jmp Next
PointsApple:
lda #LIFE_GAIN_APPLE
ldy #POINTS_APPLE
jmp Okay
PointsSteak:
lda #LIFE_GAIN_STEAK
ldy #POINTS_STEAK
jmp Okay
PointsGrapes:
lda #LIFE_GAIN_GRAPES
ldy #POINTS_GRAPES
jmp Okay
PointsIceCream:
lda #LIFE_GAIN_ICE_CREAM
ldy #POINTS_ICE_CREAM
jmp Okay
PointsBrkfast:
lda #LIFE_GAIN_BRKFAST
ldy #POINTS_BRKFAST
jmp Okay
Okay:
clc
adc player_health_delta
sta player_health_delta
jsr PointsGainAndCreate
jsr ObjectFree
jmp Return
Next:
.endscope
Draw:
; First part of food appears in the background of the later part.
jsr SpriteSpaceSetLowPriority
; Draw position.
lda object_h,x
sec
sbc camera_h
sta draw_h
lda object_screen,x
sbc camera_screen
sta draw_screen
ldy object_frame,x
lda food_animate_v_offset,y
clc
adc object_v,x
sta draw_v
; Animation.
ldy food_kind,x
lda food_picture,y
sta draw_picture_id
MovWord draw_picture_pointer, food_picture_data
MovWord draw_sprite_pointer, food_sprite_data
mov draw_palette, #0
; Draw the sprites.
jsr DrawPicture
Return:
rts
.endproc
FoodDraw = FoodExecute::Draw
food_picture:
.byte PICTURE_ID_FOOD_APPLE_OUTER
.byte PICTURE_ID_FOOD_STEAK_OUTER
.byte PICTURE_ID_FOOD_GRAPES_OUTER
.byte PICTURE_ID_FOOD_ICE_CREAM_OUTER
.byte PICTURE_ID_FOOD_BRKFAST_OUTER
food_animate_v_offset:
.byte 0
.byte 0
.byte 1
.byte 2
.byte 3
.byte 3
.byte 2
.byte 1