Rev 1020 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1020 | Rev 5093 | ||
---|---|---|---|
1 | use32 |
1 | use32 |
2 | org 0x0 |
2 | org 0x0 |
3 | db 'MENUET01' |
3 | db 'MENUET01' |
4 | dd 0x01 |
4 | dd 0x01 |
5 | dd _preSTART |
5 | dd _preSTART |
6 | dd I_END |
6 | dd I_END |
7 | dd 0x4000 |
7 | dd 0x4000 |
8 | dd 0x4000 |
8 | dd 0x4000 |
9 | dd 0x0,0x0 |
9 | dd 0x0,0x0 |
10 | 10 | ||
11 | include 'macros.inc' |
11 | include '../../macros.inc' |
12 | include 'lang.inc' |
12 | include 'lang.inc' |
13 | include 'draw_window.inc' |
13 | include 'draw_window.inc' |
14 | include 'ball_operations.inc' |
14 | include 'ball_operations.inc' |
15 | include 'basic_alg.inc' |
15 | include 'basic_alg.inc' |
16 | 16 | ||
17 | _preSTART: |
17 | _preSTART: |
18 | mcall 66, 1, 1 ;¯à¨¨¬ ¥¬ ᪠-ª®¤ë |
18 | mcall 66, 1, 1 ;¯à¨¨¬ ¥¬ ᪠-ª®¤ë |
19 | mcall 3 ;randomize |
19 | mcall 3 ;randomize |
20 | ror eax, 16 |
20 | ror eax, 16 |
21 | mov [TC_U_SYSTEM_RANDSEED], eax ;from PPro "system.inc" |
21 | mov [TC_U_SYSTEM_RANDSEED], eax ;from PPro "system.inc" |
22 | 22 | ||
23 | new_game: |
23 | new_game: |
24 | ;®¡ã«¥¨¥ ¬ âà¨æë |
24 | ;®¡ã«¥¨¥ ¬ âà¨æë |
25 | mov eax, 0 |
25 | mov eax, 0 |
26 | mov ecx, 81 / 4 |
26 | mov ecx, 81 / 4 |
27 | mov edi, lineBall |
27 | mov edi, lineBall |
28 | rep stosd |
28 | rep stosd |
29 | stosb |
29 | stosb |
30 | 30 | ||
31 | mov [score], 0 |
31 | mov [score], 0 |
32 | mov [countAllBall], 0 |
32 | mov [countAllBall], 0 |
33 | mov [current], 0 |
33 | mov [current], 0 |
34 | @@: |
34 | @@: |
35 | mov ebx, 7 |
35 | mov ebx, 7 |
36 | call random |
36 | call random |
37 | inc dl |
37 | inc dl |
38 | call add_new_ball |
38 | call add_new_ball |
39 | call test_new_ball |
39 | call test_new_ball |
40 | cmp [countAllBall], 5 |
40 | cmp [countAllBall], 5 |
41 | jb @b |
41 | jb @b |
42 | call generate_new___new_color |
42 | call generate_new___new_color |
43 | 43 | ||
44 | START: |
44 | START: |
45 | draw_window |
45 | draw_window |
46 | still: |
46 | still: |
47 | mcall 10 |
47 | mcall 10 |
48 | 48 | ||
49 | dec eax |
49 | dec eax |
50 | jz START ; ¯¥à¥à¨á®¢ âì ®ª® |
50 | jz START ; ¯¥à¥à¨á®¢ âì ®ª® |
51 | dec eax |
51 | dec eax |
52 | jnz button ;¥á«¨ ¥ ª« ¢¨è - § ç¨â ª®¯ª |
52 | jnz button ;¥á«¨ ¥ ª« ¢¨è - § ç¨â ª®¯ª |
53 | 53 | ||
54 | key: ; ¦ ⨥ ª« ¢¨è¨ |
54 | key: ; ¦ ⨥ ª« ¢¨è¨ |
55 | mcall 2 ; ¯®«ãç ¥¬ ª®¤ ª« ¢¨è¨ |
55 | mcall 2 ; ¯®«ãç ¥¬ ª®¤ ª« ¢¨è¨ |
56 | cmp ah, 60 |
56 | cmp ah, 60 |
57 | je new_game |
57 | je new_game |
58 | jmp still |
58 | jmp still |
59 | 59 | ||
60 | button: ; ¦ ⨥ ª®¯ª¨ |
60 | button: ; ¦ ⨥ ª®¯ª¨ |
61 | mcall 17 |
61 | mcall 17 |
62 | shr eax, 8 |
62 | shr eax, 8 |
63 | cmp ax, 1 ; ¥á«¨ ª®¯ª ¢ë室 ? |
63 | cmp ax, 1 ; ¥á«¨ ª®¯ª ¢ë室 ? |
64 | je .exit |
64 | je .exit |
65 | 65 | ||
66 | ;¯à®¢¥à¨¬, ¥ ¯ãáâ «¨ ª«¥âª |
66 | ;¯à®¢¥à¨¬, ¥ ¯ãáâ «¨ ª«¥âª |
67 | mov edx, [current] |
67 | mov edx, [current] |
68 | test byte [eax + lineBall - 2], 0x7 |
68 | test byte [eax + lineBall - 2], 0x7 |
69 | jz .blank |
69 | jz .blank |
70 | 70 | ||
71 | ;¯à®¢¥à¨¬ ¥ ¡ë« «¨ íâ ª«¥âª 㦥 ¢ë¡à |
71 | ;¯à®¢¥à¨¬ ¥ ¡ë« «¨ íâ ª«¥âª 㦥 ¢ë¡à |
72 | cmp eax, edx |
72 | cmp eax, edx |
73 | je .double_choice |
73 | je .double_choice |
74 | 74 | ||
75 | mov [current], eax |
75 | mov [current], eax |
76 | call choice_ball |
76 | call choice_ball |
77 | call paint_ball ;á ç « ¯à®à¨á㥬 ®¢ë© ¢ë¡à ë© è ਪ |
77 | call paint_ball ;á ç « ¯à®à¨á㥬 ®¢ë© ¢ë¡à ë© è ਪ |
78 | 78 | ||
79 | test edx, edx ;cmp [current], 0 |
79 | test edx, edx ;cmp [current], 0 |
80 | jz still |
80 | jz still |
81 | mov eax, edx |
81 | mov eax, edx |
82 | 82 | ||
83 | @@: |
83 | @@: |
84 | call redraw_cell ; 㦥 ¯®â®¬ 㡥६ à ¬ªã ®â áâ ண® |
84 | call redraw_cell ; 㦥 ¯®â®¬ 㡥६ à ¬ªã ®â áâ ண® |
85 | call paint_ball |
85 | call paint_ball |
86 | jmp still |
86 | jmp still |
87 | 87 | ||
88 | .double_choice: |
88 | .double_choice: |
89 | mov [current], 0 |
89 | mov [current], 0 |
90 | jmp @B |
90 | jmp @B |
91 | 91 | ||
92 | .blank: ; ¦ â ï ª®¯ª - ¯ãáâ |
92 | .blank: ; ¦ â ï ª®¯ª - ¯ãáâ |
93 | test edx, edx ;cmp [current], 0 |
93 | test edx, edx ;cmp [current], 0 |
94 | jz still |
94 | jz still |
95 | mov [dest], eax ;ª®¯ªã § 票ï -> ¢ [dest] |
95 | mov [dest], eax ;ª®¯ªã § 票ï -> ¢ [dest] |
96 | mov eax, edx ;¯ à ¬¥âà ¢ eax |
96 | mov eax, edx ;¯ à ¬¥âà ¢ eax |
97 | call test_path ;¢ë§ë¢ ¥¬ ४ãàá¨î test_path |
97 | call test_path ;¢ë§ë¢ ¥¬ ४ãàá¨î test_path |
98 | call zero_cheked |
98 | call zero_cheked |
99 | jnc still |
99 | jnc still |
100 | 100 | ||
101 | ;^^^^^^^^^^^^^^^^^ move_ball proc |
101 | ;^^^^^^^^^^^^^^^^^ move_ball proc |
102 | mov eax, [current] |
102 | mov eax, [current] |
103 | mov cl, byte [eax + lineBall - 2] |
103 | mov cl, byte [eax + lineBall - 2] |
104 | mov byte [eax + lineBall - 2], 0 |
104 | mov byte [eax + lineBall - 2], 0 |
105 | mov eax, [dest] |
105 | mov eax, [dest] |
106 | mov byte [eax + lineBall - 2], cl |
106 | mov byte [eax + lineBall - 2], cl |
107 | 107 | ||
108 | mov eax, [current] |
108 | mov eax, [current] |
109 | call redraw_cell |
109 | call redraw_cell |
110 | mov eax, [dest] |
110 | mov eax, [dest] |
111 | call paint_ball |
111 | call paint_ball |
112 | mov [current], 0 |
112 | mov [current], 0 |
113 | ;^^^^^^^^^^^^^^^^^ move_ball endp |
113 | ;^^^^^^^^^^^^^^^^^ move_ball endp |
114 | 114 | ||
115 | call find_line |
115 | call find_line |
116 | call vanish_balls |
116 | call vanish_balls |
117 | call zero_cheked |
117 | call zero_cheked |
118 | 118 | ||
119 | cmp [countVanishBall], 0 |
119 | cmp [countVanishBall], 0 |
120 | je new_3_balls |
120 | je new_3_balls |
121 | movzx eax, [countVanishBall] |
121 | movzx eax, [countVanishBall] |
122 | inc eax |
122 | inc eax |
123 | add [score], eax |
123 | add [score], eax |
124 | sub [countAllBall], al |
124 | sub [countAllBall], al |
125 | call redraw_score |
125 | call redraw_score |
126 | jmp still |
126 | jmp still |
127 | 127 | ||
128 | .exit: |
128 | .exit: |
129 | mcall -1 ;¢ë室¨¬ |
129 | mcall -1 ;¢ë室¨¬ |
130 | 130 | ||
131 | new_3_balls: |
131 | new_3_balls: |
132 | 132 | ||
133 | rept 3 num |
133 | rept 3 num |
134 | { |
134 | { |
135 | mov dl, [newColor#num] |
135 | mov dl, [newColor#num] |
136 | call add_new_ball |
136 | call add_new_ball |
137 | call test_new_ball |
137 | call test_new_ball |
138 | cmp [countAllBall],81 |
138 | cmp [countAllBall],81 |
139 | je .record_li |
139 | je .record_li |
140 | } |
140 | } |
141 | 141 | ||
142 | call generate_new___new_color |
142 | call generate_new___new_color |
143 | call paint_new_color |
143 | call paint_new_color |
144 | jmp still |
144 | jmp still |
145 | 145 | ||
146 | .record_li: |
146 | .record_li: |
147 | mov eax, [score] |
147 | mov eax, [score] |
148 | cmp eax, [record] |
148 | cmp eax, [record] |
149 | jbe still |
149 | jbe still |
150 | mov [record], eax |
150 | mov [record], eax |
151 | jmp START |
151 | jmp START |
152 | 152 | ||
153 | zero_cheked: ;®¡ã«¥¨¥ ¬ âà¨æë cheked |
153 | zero_cheked: ;®¡ã«¥¨¥ ¬ âà¨æë cheked |
154 | pushfd |
154 | pushfd |
155 | mov eax, lineBall |
155 | mov eax, lineBall |
156 | mov ecx, 81 |
156 | mov ecx, 81 |
157 | @@: |
157 | @@: |
158 | and byte [eax], 0x7 |
158 | and byte [eax], 0x7 |
159 | inc eax |
159 | inc eax |
160 | loop @B |
160 | loop @B |
161 | popfd |
161 | popfd |
162 | ret |
162 | ret |
163 | 163 | ||
164 | random: ; edx := random [0..(ebx-1)] |
164 | random: ; edx := random [0..(ebx-1)] |
165 | mov eax, 134775813 |
165 | mov eax, 134775813 |
166 | mul [TC_U_SYSTEM_RANDSEED] |
166 | mul [TC_U_SYSTEM_RANDSEED] |
167 | inc eax |
167 | inc eax |
168 | mov [ TC_U_SYSTEM_RANDSEED], eax |
168 | mov [ TC_U_SYSTEM_RANDSEED], eax |
169 | xor edx, edx |
169 | xor edx, edx |
170 | div ebx |
170 | div ebx |
171 | ret |
171 | ret |
172 | 172 | ||
173 | generate_new___new_color: |
173 | generate_new___new_color: |
174 | rept 3 num |
174 | rept 3 num |
175 | { |
175 | { |
176 | mov ebx, 7 |
176 | mov ebx, 7 |
177 | call random |
177 | call random |
178 | inc dl |
178 | inc dl |
179 | mov [newColor#num], dl |
179 | mov [newColor#num], dl |
180 | } |
180 | } |
181 | ret |
181 | ret |
182 | 182 | ||
183 | add_new_ball: ;¢ dl - 梥â è ਪ |
183 | add_new_ball: ;¢ dl - 梥â è ਪ |
184 | mov ebp, edx |
184 | mov ebp, edx |
185 | mov ebx, 81 |
185 | mov ebx, 81 |
186 | sub bl, [countAllBall] |
186 | sub bl, [countAllBall] |
187 | call random |
187 | call random |
188 | mov ecx, edx |
188 | mov ecx, edx |
189 | mov eax, lineBall-1 |
189 | mov eax, lineBall-1 |
190 | inc ecx |
190 | inc ecx |
191 | @@: |
191 | @@: |
192 | inc eax |
192 | inc eax |
193 | test byte [eax], 0x7 |
193 | test byte [eax], 0x7 |
194 | jnz @B |
194 | jnz @B |
195 | loop @B |
195 | loop @B |
196 | 196 | ||
197 | ;⥯¥àì ã á ¢ eax - ¤à¥á 襣® è ਪ |
197 | ;⥯¥àì ã á ¢ eax - ¤à¥á 襣® è ਪ |
198 | mov edx, ebp |
198 | mov edx, ebp |
199 | or byte [eax], dl |
199 | or byte [eax], dl |
200 | inc [countAllBall] |
200 | inc [countAllBall] |
201 | ;¯®«ã稬 ID ª®¯ª¨ |
201 | ;¯®«ã稬 ID ª®¯ª¨ |
202 | sub eax, lineBall-2 |
202 | sub eax, lineBall-2 |
203 | mov [dest], eax |
203 | mov [dest], eax |
204 | ret |
204 | ret |
205 | 205 | ||
206 | test_new_ball: |
206 | test_new_ball: |
207 | call paint_ball |
207 | call paint_ball |
208 | 208 | ||
209 | call find_line |
209 | call find_line |
210 | call vanish_balls |
210 | call vanish_balls |
211 | call zero_cheked |
211 | call zero_cheked |
212 | 212 | ||
213 | cmp [countVanishBall], 0 |
213 | cmp [countVanishBall], 0 |
214 | je @F |
214 | je @F |
215 | movzx eax, [countVanishBall] |
215 | movzx eax, [countVanishBall] |
216 | inc eax |
216 | inc eax |
217 | add [score], eax |
217 | add [score], eax |
218 | sub [countAllBall], al |
218 | sub [countAllBall], al |
219 | call redraw_score |
219 | call redraw_score |
220 | @@: |
220 | @@: |
221 | ret |
221 | ret |
222 | 222 | ||
223 | if lang eq ru |
223 | if lang eq ru |
224 | szTitle db '¢¥âë¥ «¨¨¨ v 0.3',0 |
224 | szTitle db '¢¥âë¥ «¨¨¨ v 0.3',0 |
225 | szNewGame db 'F2 - ®¢ ï ¨£à ',0 |
225 | szNewGame db 'F2 - ®¢ ï ¨£à ',0 |
226 | szRecord db '¥ª®à¤',0 |
226 | szRecord db '¥ª®à¤',0 |
227 | szScore db '窨',0 |
227 | szScore db '窨',0 |
228 | else |
228 | else |
229 | szTitle db 'Color lines v 0.3',0 |
229 | szTitle db 'Color lines v 0.3',0 |
230 | szNewGame db 'F2 - new game',0 |
230 | szNewGame db 'F2 - new game',0 |
231 | szRecord db 'Record',0 |
231 | szRecord db 'Record',0 |
232 | szScore db 'Score',0 |
232 | szScore db 'Score',0 |
233 | end if |
233 | end if |
234 | 234 | ||
235 | 235 | ||
236 | blank = 0xB8C2D3 |
236 | blank = 0xB8C2D3 |
237 | brown = 0x804000 |
237 | brown = 0x804000 |
238 | red = 0xff0000 |
238 | red = 0xff0000 |
239 | yellow = 0xffff00 |
239 | yellow = 0xffff00 |
240 | green = 0x008000 |
240 | green = 0x008000 |
241 | cyan = 0x00ffff |
241 | cyan = 0x00ffff |
242 | blue = 0x0000ff |
242 | blue = 0x0000ff |
243 | purple = 0x800080 |
243 | purple = 0x800080 |
244 | 244 | ||
245 | tableColor dd blank,brown,red,yellow,green,cyan,blue,purple |
245 | tableColor dd blank,brown,red,yellow,green,cyan,blue,purple |
246 | 246 | ||
247 | lineCoord: |
247 | lineCoord: |
248 | rept 9 coory:0 |
248 | rept 9 coory:0 |
249 | { |
249 | { |
250 | rept 9 coorx:0 |
250 | rept 9 coorx:0 |
251 | \{ |
251 | \{ |
252 | dw coorx*256+coory |
252 | dw coorx*256+coory |
253 | 253 | ||
254 | \} |
254 | \} |
255 | } |
255 | } |
256 | 256 | ||
257 | record dd 25 |
257 | record dd 25 |
258 | 258 | ||
259 | lineBall db 81 dup ? |
259 | lineBall db 81 dup ? |
260 | score dd ? |
260 | score dd ? |
261 | baseAddr dd ? |
261 | baseAddr dd ? |
262 | current dd ? |
262 | current dd ? |
263 | dest dd ? |
263 | dest dd ? |
264 | 264 | ||
265 | newColor1 db ? |
265 | newColor1 db ? |
266 | newColor2 db ? |
266 | newColor2 db ? |
267 | newColor3 db ? |
267 | newColor3 db ? |
268 | 268 | ||
269 | countVanishBall db ? |
269 | countVanishBall db ? |
270 | countAllBall db ? |
270 | countAllBall db ? |
271 | 271 | ||
272 | TC_U_SYSTEM_RANDSEED dd ? |
272 | TC_U_SYSTEM_RANDSEED dd ? |
273 | bitID dd ? |
273 | bitID dd ? |
274 | 274 | ||
275 | I_END: |
275 | I_END: |