Rev 5253 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5253 | mario79 | 1 | ;--------------------------------------------------------------------- |
2 | key: |
||
3 | mcall 2 |
||
4 | cmp [extended_key],1 |
||
5 | je .extended_key |
||
6 | |||
7 | test al,al |
||
8 | jnz still |
||
9 | |||
10 | cmp ah,0xE0 |
||
11 | jne @f |
||
12 | |||
13 | mov [extended_key],1 |
||
14 | jmp still |
||
15 | ;-------------------------------------- |
||
16 | @@: |
||
17 | cmp ah,72 ; arrow up |
||
18 | je .arrow_up |
||
19 | |||
20 | cmp ah,80 ; arrow down |
||
21 | je .arrow_down |
||
22 | |||
23 | cmp ah,75 ; arrow left |
||
24 | je .arrow_left |
||
25 | |||
26 | cmp ah,77 ; arrow right |
||
27 | je .arrow_right |
||
28 | |||
29 | cmp ah,17 ; w - arrow up |
||
30 | je .arrow_up |
||
31 | |||
32 | cmp ah,31 ; s - arrow down |
||
33 | je .arrow_down |
||
34 | |||
35 | cmp ah,30 ; a - arrow left |
||
36 | je .arrow_left |
||
37 | |||
38 | cmp ah,32 ; d - arrow right |
||
39 | je .arrow_right |
||
40 | |||
41 | cmp ah,57 ; space - kick |
||
42 | je .kick |
||
43 | |||
44 | jmp still |
||
45 | ;--------------------------------------------------------------------- |
||
46 | .extended_key: |
||
47 | mov [extended_key],0 |
||
48 | cmp ah,72 ; arrow up |
||
49 | je .arrow_up |
||
50 | |||
51 | cmp ah,80 ; arrow down |
||
52 | je .arrow_down |
||
53 | |||
54 | cmp ah,75 ; arrow left |
||
55 | je .arrow_left |
||
56 | |||
57 | cmp ah,77 ; arrow right |
||
58 | je .arrow_right |
||
59 | |||
60 | jmp still |
||
61 | ;--------------------------------------------------------------------- |
||
62 | .arrow_up: |
||
63 | mov [protagonist_route],ROUTE_UP |
||
64 | mov cx,0x0100+ROUTE_UP |
||
65 | jmp .save_motion |
||
66 | ;--------------------------------------------------------------------- |
||
67 | .arrow_down: |
||
68 | mov [protagonist_route],ROUTE_DOWN |
||
69 | mov cx,0x0100+ROUTE_DOWN |
||
70 | jmp .save_motion |
||
71 | ;--------------------------------------------------------------------- |
||
72 | .arrow_left: |
||
73 | mov [protagonist_route],ROUTE_LEFT |
||
74 | mov cx,0x0100+ROUTE_LEFT |
||
75 | jmp .save_motion |
||
76 | ;--------------------------------------------------------------------- |
||
77 | .arrow_right: |
||
78 | mov [protagonist_route],ROUTE_RIGHT |
||
79 | mov cx,0x0100+ROUTE_RIGHT |
||
80 | ;--------------------------------------------------------------------- |
||
81 | .save_motion: |
||
82 | call calculate_offset |
||
83 | shl ebx,2 |
||
84 | add eax,ebx |
||
85 | add eax,plan_level |
||
86 | mov ebx,[eax] |
||
87 | ror ebx,16 |
||
88 | mov bx,cx |
||
89 | rol ebx,16 |
||
90 | mov [eax],ebx |
||
91 | ; jmp still |
||
92 | jmp calculate_action_for_all.2 |
||
93 | ;--------------------------------------------------------------------- |
||
94 | .kick: |
||
95 | mov eax,[protagonist_route] |
||
96 | cmp al,ROUTE_UP |
||
97 | jne @f |
||
98 | |||
99 | cmp [protagonist_position.y],0 |
||
100 | je calculate_action_for_all.1 ;still |
||
101 | |||
102 | call protagonist_kick_action |
||
103 | mov eax,[protagonist_position.y] |
||
104 | dec eax |
||
105 | call calculate_offset.1 |
||
106 | jmp .calculate_protagonist_kick_brick |
||
107 | ;-------------------------------------- |
||
108 | @@: |
||
109 | cmp al,ROUTE_DOWN |
||
110 | jne @f |
||
111 | |||
112 | cmp [protagonist_position.y],LEVEL_MAP_SIZE_Y-1 |
||
113 | je calculate_action_for_all.1 ;still |
||
114 | |||
115 | call protagonist_kick_action |
||
116 | mov eax,[protagonist_position.y] |
||
117 | inc eax |
||
118 | call calculate_offset.1 |
||
119 | jmp .calculate_protagonist_kick_brick |
||
120 | ;-------------------------------------- |
||
121 | @@: |
||
122 | cmp al,ROUTE_LEFT |
||
123 | jne @f |
||
124 | |||
125 | cmp [protagonist_position.x],0 |
||
126 | je calculate_action_for_all.1 ;still |
||
127 | |||
128 | call protagonist_kick_action |
||
129 | call calculate_offset |
||
130 | dec ebx |
||
131 | jmp .calculate_protagonist_kick_brick |
||
132 | ;-------------------------------------- |
||
133 | @@: |
||
134 | cmp al,ROUTE_RIGHT |
||
135 | jne still |
||
136 | |||
137 | cmp [protagonist_position.x],LEVEL_MAP_SIZE_X-1 |
||
138 | je calculate_action_for_all.1 ;still |
||
139 | |||
140 | call protagonist_kick_action |
||
141 | call calculate_offset |
||
142 | inc ebx |
||
143 | ;-------------------------------------- |
||
144 | .calculate_protagonist_kick_brick: |
||
145 | shl ebx,2 |
||
146 | add eax,ebx |
||
147 | add eax,plan_level |
||
148 | mov ebx,[eax] |
||
149 | |||
5319 | mario79 | 150 | ; cmp bh,OBJECT_FINAL_MONSTER ;OBJECT_PROTAGONIST |
151 | ; jbe .kill |
||
5253 | mario79 | 152 | |
153 | cmp bh,OBJECT_WHITE_BRICK |
||
154 | je .white_brick |
||
155 | |||
156 | cmp bh,OBJECT_RED_BRICK ; red brick? |
||
157 | jne still |
||
158 | |||
159 | and ebx,0x00ff00ff |
||
160 | add ebx,0x01000000 + RED_BRICK_CRASH_1 shl 8 ; reb brick crash 1 |
||
161 | mov [eax],ebx |
||
162 | push eax ebx |
||
163 | ; DEBUGF 1, "80 - reb brick crash 10\n" |
||
164 | call show_tiles_one_iteration |
||
165 | mcall 5,5 |
||
166 | pop ebx eax |
||
167 | |||
168 | and ebx,0x00ff00ff |
||
169 | add ebx,0x01000000 + RED_BRICK_CRASH_2 shl 8 ; reb brick crash 2 |
||
170 | mov [eax],ebx |
||
171 | push eax ebx |
||
172 | ; DEBUGF 1, "81 - reb brick crash 20\n" |
||
173 | call show_tiles_one_iteration |
||
174 | mcall 5,5 |
||
175 | pop ebx eax |
||
176 | |||
177 | and ebx,0x00ff00ff |
||
178 | add ebx,0x01000000 |
||
179 | mov [eax],ebx |
||
180 | ; DEBUGF 1, "81 - reb brick crash 30\n" |
||
181 | ; call show_tiles_one_iteration |
||
182 | jmp calculate_action_for_all.2 ;still |
||
183 | ;-------------------------------------- |
||
5319 | mario79 | 184 | ;.kill: |
185 | ; and ebx,0x000000ff |
||
186 | ; add ebx,0x01000000 |
||
187 | ; mov [eax],ebx |
||
188 | ;; call show_tiles_one_iteration |
||
189 | ; jmp calculate_action_for_all.2 |
||
5253 | mario79 | 190 | ;-------------------------------------- |
191 | .white_brick: |
||
192 | ror ebx,16 |
||
193 | xor bl,bl |
||
194 | mov bh,1 |
||
195 | add ebx,[protagonist_route] |
||
196 | rol ebx,16 |
||
197 | mov [eax],ebx |
||
198 | jmp calculate_action_for_all.2 |
||
199 | ;--------------------------------------------------------------------- |
||
200 | calculate_action_for_all: |
||
201 | call show_tiles_one_iteration |
||
202 | ;-------------------------------------- |
||
203 | .1: |
||
204 | call actions_for_all_cell |
||
205 | ;-------------------------------------- |
||
206 | .2: |
||
207 | call show_tiles_one_iteration |
||
208 | jmp still |
||
209 | ;--------------------------------------------------------------------- |
||
210 | calculate_offset: |
||
211 | mov eax,[protagonist_position.y] |
||
212 | ;-------------------------------------- |
||
213 | .1: |
||
214 | imul eax,LEVEL_MAP_SIZE_X*4 |
||
215 | mov ebx,[protagonist_position.x] |
||
216 | ret |
||
217 | ;--------------------------------------------------------------------- |
||
218 | protagonist_kick_action: |
||
219 | call snd_kick_action |
||
220 | add [protagonist_route],4 |
||
221 | call show_protagonist_1 |
||
222 | sub [protagonist_route],4 |
||
223 | call show_protagonist_1 |
||
224 | ret |
||
225 | ;--------------------------------------------------------------------- |
||
226 | calculate_protagonist_vs_brick: |
||
227 | shl ebx,2 |
||
228 | add eax,ebx |
||
229 | add eax,plan_level |
||
230 | mov ebx,[eax] |
||
231 | ; cmp bh,4 ; brick? |
||
232 | test bh,bh ; empty? |
||
233 | jnz @f |
||
234 | |||
235 | ret |
||
236 | ;-------------------------------------- |
||
237 | @@: |
||
238 | add esp,4 |
||
239 | jmp still |
||
240 | ;--------------------------------------------------------------------- |
||
241 | show_protagonist_1: |
||
242 | mov ecx,0x01000000 + OBJECT_PROTAGONIST shl 8 |
||
243 | call calculate_protagonist_position |
||
244 | ; call show_tiles_one_iteration |
||
245 | ; call actions_for_all_cell |
||
246 | call show_tiles_one_iteration ;show_tiles |
||
247 | mcall 5,10 |
||
248 | ret |
||
249 | ;--------------------------------------------------------------------- |
||
250 | calculate_protagonist_position: |
||
251 | call calculate_offset |
||
252 | shl ebx,2 |
||
253 | add eax,ebx |
||
254 | add eax,plan_level |
||
255 | mov ebx,[eax] |
||
256 | and ebx,0x00ff00ff |
||
257 | add ebx,ecx |
||
258 | mov [eax],ebx |
||
259 | ret |
||
260 | ;--------------------------------------------------------------------- |