Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1806 | yogev_ezra | 1 | ; level format |
2 | ; [fx|fy]..[field cells x2]..[worm_count]..[worm_len][start cell #][body dirs x2] |
||
3 | |||
4 | ; internal format |
||
5 | ; [stepptr]= worms # |
||
6 | ; area: [worm_len][start_cell #][end_cell #]..[dirs].. |
||
7 | ; [cur_step]: dragged worm pointer |
||
8 | ; [finish]: 0 - if head dragged, 1- if tail |
||
9 | WG_levelp: |
||
10 | mcall 40,100111b |
||
11 | inc [drag_flag] |
||
12 | call get_xy_sf |
||
13 | sub esi,2 |
||
14 | call LP_levelp.bit2 |
||
15 | cmp edx,4 |
||
16 | jne .ok |
||
17 | dec esi |
||
18 | .ok: |
||
19 | movzx ecx,byte[esi] |
||
20 | mov [stepptr],ecx |
||
21 | inc esi |
||
22 | xor eax,eax |
||
23 | mov edi,area |
||
24 | .lp1: |
||
25 | push ecx |
||
26 | movzx ecx,byte[esi] |
||
27 | inc esi |
||
28 | mov [edi],cl |
||
29 | inc edi |
||
30 | lodsb |
||
31 | dec ecx |
||
32 | movzx ebx,al |
||
33 | stosb |
||
34 | push edi |
||
35 | inc edi |
||
36 | mov edx,8/2 |
||
37 | lodsb |
||
38 | .lp: |
||
39 | rol al,2 |
||
40 | push ecx |
||
41 | mov cl,al |
||
42 | and ecx,11b |
||
43 | add ebx,[dirs+ecx*4] |
||
44 | mov [edi],cl |
||
45 | pop ecx |
||
46 | inc edi |
||
47 | dec edx |
||
48 | test edx,edx |
||
49 | jnz .nxt |
||
50 | mov edx,8/2 |
||
51 | lodsb |
||
52 | .nxt: |
||
53 | loop .lp |
||
54 | cmp edx,4 |
||
55 | jne .ok2 |
||
56 | dec esi |
||
57 | .ok2: |
||
58 | pop ecx |
||
59 | mov [ecx],bl |
||
60 | pop ecx |
||
61 | loop .lp1 |
||
62 | mov esi,[stepptr] |
||
63 | ret |
||
64 | |||
65 | WG_key: |
||
66 | cmp eax,0 |
||
67 | jl WG_mouse |
||
68 | ret |
||
69 | |||
70 | WG_drawm: |
||
71 | mov [win_flag],1 |
||
72 | mov ecx,[cell_count] |
||
73 | ; mov [sq_size],3 |
||
74 | .lp: |
||
75 | push ecx |
||
76 | movzx ebx,byte[field+ecx-1] |
||
77 | and byte[field+ecx-1],11000000b |
||
78 | shr ebx,6 |
||
79 | test ebx,ebx |
||
80 | jz .no |
||
81 | dec ebx |
||
82 | lea eax,[ecx-1] |
||
83 | call get_xy |
||
84 | add [lx],5-2 shl 16 |
||
85 | add [ly],5-2 shl 16 |
||
86 | mov edx,[f_colors+ebx*4] |
||
87 | mcall 13,[lx],[ly] |
||
88 | .no: |
||
89 | pop ecx |
||
90 | loop .lp |
||
91 | |||
92 | add [sq_size],3 |
||
93 | |||
94 | mov ecx,[stepptr] |
||
95 | xor eax,eax |
||
96 | mov esi,area |
||
97 | push ebp |
||
98 | mov edi,w_colors |
||
99 | mov dword[player],1 |
||
100 | .lp2: |
||
101 | push ecx |
||
102 | movzx ecx,byte[esi] |
||
103 | inc esi |
||
104 | xor eax,eax |
||
105 | lodsb |
||
106 | mov ebp,esi |
||
107 | .lp1: |
||
108 | inc esi |
||
109 | push ecx eax |
||
110 | call get_xy |
||
111 | mcall 13,[lx],[ly],[edi] |
||
112 | pop eax |
||
113 | mov ecx,[player] |
||
114 | mov bl,[field+eax] |
||
115 | shr bl,6 |
||
116 | add [field+eax],cl |
||
117 | cmp bl,cl |
||
118 | je .match |
||
119 | and [win_flag],0 |
||
120 | .match: |
||
121 | pop ecx |
||
122 | push esi edi |
||
123 | movzx ebx,byte[esi] |
||
124 | mov esi,eax |
||
125 | mov [ebp],al |
||
126 | add eax,[dirs+ebx*4] |
||
127 | |||
128 | cmp ecx,1 |
||
129 | je .skip |
||
130 | mov edi,eax |
||
131 | call getline |
||
132 | call bold_line |
||
133 | .skip: |
||
134 | pop edi esi |
||
135 | loop .lp1 |
||
136 | pop ecx |
||
137 | add edi,4 |
||
138 | inc dword[player] |
||
139 | loop .lp2 |
||
140 | pop ebp |
||
141 | sub [sq_size],3 |
||
142 | |||
143 | ret |
||
144 | |||
145 | WG_mouse: |
||
146 | cmp [win_flag],1 |
||
147 | je .ex |
||
148 | mov [jump],still |
||
149 | mov edx,eax |
||
150 | call get_last_mclick |
||
151 | cmp edx,-2 |
||
152 | jne .no1st |
||
153 | test eax,eax |
||
154 | jz .ex |
||
155 | .noempty: |
||
156 | |||
157 | ; First Click at ebx cell |
||
158 | ; dpd ebx |
||
159 | mov [cur_step],0 |
||
160 | mov dword[finish],0 |
||
161 | mov esi,area |
||
162 | mov ecx,[stepptr] |
||
163 | .fndlp: |
||
164 | movzx edx,byte[esi] |
||
165 | cmp bl,[esi+1] |
||
166 | je .fnd |
||
167 | cmp bl,[esi+2] |
||
168 | jne .nxt |
||
169 | inc dword[finish] |
||
170 | .fnd: |
||
171 | mov [cur_step],esi |
||
172 | mov [jump],drw;red |
||
173 | jmp .ex |
||
174 | .nxt: |
||
175 | lea esi,[esi+edx+2] |
||
176 | loop .fndlp |
||
177 | jmp .ex |
||
178 | |||
179 | .no1st: |
||
180 | test eax,eax |
||
181 | jz .ex |
||
182 | ; While dragging |
||
183 | mov esi,[cur_step] |
||
184 | test esi,esi |
||
185 | jz .ex |
||
186 | lea edi,[esi+1] |
||
187 | add edi,[finish] |
||
188 | movzx eax,byte[edi] |
||
189 | cmp eax,ebx |
||
190 | je .ex |
||
191 | push ebx |
||
192 | cmp dword[finish],0 |
||
193 | jne .noswap |
||
194 | xchg eax,ebx |
||
195 | .noswap: |
||
196 | call get_offset |
||
197 | cmp ebx,1 |
||
198 | pop ebx |
||
199 | jne .ex |
||
200 | cmp eax,-1 |
||
201 | je .ex |
||
202 | test byte[field+ebx],11b |
||
203 | jnz .ex |
||
204 | movzx ecx,byte[esi] |
||
205 | cmp dword[finish],0 |
||
206 | jne .tail |
||
207 | mov [esi+1],bl |
||
208 | mov [esi+2],al |
||
209 | add esi,ecx |
||
210 | std |
||
211 | lea edi,[esi+1] |
||
212 | rep movsb |
||
213 | jmp .redex |
||
214 | |||
215 | .tail: |
||
216 | mov [esi+2],bl |
||
217 | movzx ebx,byte[esi+3] |
||
218 | movzx edx,byte[esi+1] |
||
219 | add edx,[dirs+ebx*4] |
||
220 | mov [esi+1],dl |
||
221 | add esi,3 |
||
222 | lea edi,[esi-1] |
||
223 | rep movsb |
||
224 | mov [edi-1],al |
||
225 | ; ud2 |
||
226 | .redex: |
||
227 | cld |
||
228 | mov [jump],drw;red |
||
229 | mov esi,area |
||
230 | .ex: |
||
231 | ret |
||
232 | |||
233 | WG_level: |
||
234 | file 'wriggle.bin' |
||
235 | |||
236 | if lang eq ru |
||
237 | WG_help mstr \ |
||
238 | 'Ваша задача - тянуть червяков за голову или',\ |
||
239 | 'хвост, пока каждый из них не покроет клетки',\ |
||
240 | 'своего цвета, оставив незакрытыми белые квадраты.',\ |
||
241 | 'Червяки не могут перекрывать и пересекать друг',\ |
||
242 | 'друга.','',\ |
||
243 | 'http://www.clickmazes.com' |
||
244 | else |
||
245 | WG_help mstr \ |
||
246 | 'Your aim is to drag the wriggley worms by head or',\ |
||
247 | 'tail until each worm covers the squares of its',\ |
||
248 | 'own colour leaving only white squares exposed.',\ |
||
249 | 'Worms cannot cross or overlap.','',\ |
||
250 | 'http://www.clickmazes.com' |
||
251 | end if |