Rev 3494 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3494 | Rev 3510 | ||
---|---|---|---|
1 | ; C4 |
1 | ; C4 |
2 | ; Copyright (c) 2002 Thomas Mathys |
2 | ; Copyright (c) 2002 Thomas Mathys |
3 | ; killer@vantage.ch |
3 | ; killer@vantage.ch |
4 | ; |
4 | ; |
5 | ; This file is part of C4. |
5 | ; This file is part of C4. |
6 | ; |
6 | ; |
7 | ; C4 is free software; you can redistribute it and/or modify |
7 | ; C4 is free software; you can redistribute it and/or modify |
8 | ; it under the terms of the GNU General Public License as published by |
8 | ; it under the terms of the GNU General Public License as published by |
9 | ; the Free Software Foundation; either version 2 of the License, or |
9 | ; the Free Software Foundation; either version 2 of the License, or |
10 | ; (at your option) any later version. |
10 | ; (at your option) any later version. |
11 | ; |
11 | ; |
12 | ; C4 is distributed in the hope that it will be useful, |
12 | ; C4 is distributed in the hope that it will be useful, |
13 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | ; GNU General Public License for more details. |
15 | ; GNU General Public License for more details. |
16 | ; |
16 | ; |
17 | ; You should have received a copy of the GNU General Public License |
17 | ; You should have received a copy of the GNU General Public License |
18 | ; along with C4; if not, write to the Free Software |
18 | ; along with C4; if not, write to the Free Software |
19 | ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 | 20 | ||
21 | bits 32 |
21 | bits 32 |
22 | %include 'mos.inc' |
22 | %include 'mos.inc' |
23 | section .text |
23 | section .text |
24 | %include 'lang_nasm.inc' ;fedesco |
24 | %include 'lang_nasm.inc' ;fedesco |
25 | 25 | ||
26 | 26 | ||
27 | MOS_HEADER01 start,end |
27 | MOS_HEADER01 start,end |
28 | 28 | ||
29 | 29 | ||
30 | 30 | ||
31 | ;********************************************************** |
31 | ;********************************************************** |
32 | ; magic numbers |
32 | ; magic numbers |
33 | ;********************************************************** |
33 | ;********************************************************** |
34 | 34 | ||
35 | ; initial player types |
35 | ; initial player types |
36 | PL1TYPE_INIT equ 0 |
36 | PL1TYPE_INIT equ 0 |
37 | PL2TYPE_INIT equ 4 |
37 | PL2TYPE_INIT equ 4 |
38 | 38 | ||
39 | ; window |
39 | ; window |
40 | WND_WIDTH equ 259 |
40 | WND_WIDTH equ 259 |
41 | WND_HEIGHT equ 300 |
41 | WND_HEIGHT equ 300 |
42 | WND_WORKCOLOR equ 0 |
42 | WND_WORKCOLOR equ 0 |
43 | 43 | ||
44 | ; button dimensions |
44 | ; button dimensions |
45 | BUTTON_HEIGHT equ 12 |
45 | BUTTON_HEIGHT equ 12 |
46 | 46 | ||
47 | BUTTON_NEW_X equ 14 |
47 | BUTTON_NEW_X equ 14 |
48 | BUTTON_NEW_Y equ 30 |
48 | BUTTON_NEW_Y equ 30 |
49 | %if lang = 'it' |
49 | %ifidn lang, 'it' |
50 | BUTTON_NEW_WIDTH equ 56 + 28 |
50 | BUTTON_NEW_WIDTH equ 56 + 28 |
51 | %else |
51 | %else |
52 | BUTTON_NEW_WIDTH equ 56 |
52 | BUTTON_NEW_WIDTH equ 56 |
53 | %endif |
53 | %endif |
54 | 54 | ||
55 | BUTTON_SPIN_WIDTH equ 8 |
55 | BUTTON_SPIN_WIDTH equ 8 |
56 | BUTTON_PL1DN_X equ 228 |
56 | BUTTON_PL1DN_X equ 228 |
57 | BUTTON_PL1DN_Y equ 30 |
57 | BUTTON_PL1DN_Y equ 30 |
58 | BUTTON_PL1UP_X equ (BUTTON_PL1DN_X + BUTTON_SPIN_WIDTH + 1) |
58 | BUTTON_PL1UP_X equ (BUTTON_PL1DN_X + BUTTON_SPIN_WIDTH + 1) |
59 | BUTTON_PL1UP_Y equ BUTTON_PL1DN_Y |
59 | BUTTON_PL1UP_Y equ BUTTON_PL1DN_Y |
60 | 60 | ||
61 | BUTTON_PL2DN_X equ BUTTON_PL1DN_X |
61 | BUTTON_PL2DN_X equ BUTTON_PL1DN_X |
62 | BUTTON_PL2DN_Y equ (BUTTON_PL1DN_Y + 20) |
62 | BUTTON_PL2DN_Y equ (BUTTON_PL1DN_Y + 20) |
63 | BUTTON_PL2UP_X equ (BUTTON_PL2DN_X + BUTTON_SPIN_WIDTH + 1) |
63 | BUTTON_PL2UP_X equ (BUTTON_PL2DN_X + BUTTON_SPIN_WIDTH + 1) |
64 | BUTTON_PL2UP_Y equ BUTTON_PL2DN_Y |
64 | BUTTON_PL2UP_Y equ BUTTON_PL2DN_Y |
65 | 65 | ||
66 | ; label dimensions |
66 | ; label dimensions |
67 | %if lang = 'it' |
67 | %ifidn lang, 'it' |
68 | LABEL_PL1_X equ 90 + 10 |
68 | LABEL_PL1_X equ 90 + 10 |
69 | %else |
69 | %else |
70 | LABEL_PL1_X equ 90 |
70 | LABEL_PL1_X equ 90 |
71 | %endif |
71 | %endif |
72 | LABEL_PL1_Y equ (1 + BUTTON_PL1DN_Y + (BUTTON_HEIGHT-8)/2) |
72 | LABEL_PL1_Y equ (1 + BUTTON_PL1DN_Y + (BUTTON_HEIGHT-8)/2) |
73 | LABEL_PL2_X equ LABEL_PL1_X |
73 | LABEL_PL2_X equ LABEL_PL1_X |
74 | LABEL_PL2_Y equ (1 + BUTTON_PL2DN_Y + (BUTTON_HEIGHT-8)/2) |
74 | LABEL_PL2_Y equ (1 + BUTTON_PL2DN_Y + (BUTTON_HEIGHT-8)/2) |
75 | %if lang = 'it' |
75 | %ifidn lang, 'it' |
76 | LABEL_PL1TYPE_X equ (LABEL_PL1_X + 10*6 - 4) |
76 | LABEL_PL1TYPE_X equ (LABEL_PL1_X + 10*6 - 4) |
77 | %else |
77 | %else |
78 | LABEL_PL1TYPE_X equ (LABEL_PL1_X + 10*6) |
78 | LABEL_PL1TYPE_X equ (LABEL_PL1_X + 10*6) |
79 | %endif |
79 | %endif |
80 | LABEL_PL1TYPE_Y equ LABEL_PL1_Y |
80 | LABEL_PL1TYPE_Y equ LABEL_PL1_Y |
81 | LABEL_PL2TYPE_X equ LABEL_PL1TYPE_X |
81 | LABEL_PL2TYPE_X equ LABEL_PL1TYPE_X |
82 | LABEL_PL2TYPE_Y equ LABEL_PL2_Y |
82 | LABEL_PL2TYPE_Y equ LABEL_PL2_Y |
83 | LABEL_STATUS_X equ 14 |
83 | LABEL_STATUS_X equ 14 |
84 | LABEL_STATUS_Y equ 279 |
84 | LABEL_STATUS_Y equ 279 |
85 | LABEL_STATUS_WIDTH equ 220 |
85 | LABEL_STATUS_WIDTH equ 220 |
86 | LABEL_STATUS_HEIGHT equ 12 |
86 | LABEL_STATUS_HEIGHT equ 12 |
87 | 87 | ||
88 | 88 | ||
89 | 89 | ||
90 | ; board and stones |
90 | ; board and stones |
91 | STONESIZE equ 32 ; stone height and width |
91 | STONESIZE equ 32 ; stone height and width |
92 | GRIDX equ 14 ; upper left corner |
92 | GRIDX equ 14 ; upper left corner |
93 | GRIDY equ 70 |
93 | GRIDY equ 70 |
94 | GRIDSPACING equ (STONESIZE + 1) ; space between lines |
94 | GRIDSPACING equ (STONESIZE + 1) ; space between lines |
95 | GRIDHEIGHT equ (6*GRIDSPACING+1) ; total grid width and height |
95 | GRIDHEIGHT equ (6*GRIDSPACING+1) ; total grid width and height |
96 | GRIDWIDTH equ (7*GRIDSPACING+1) |
96 | GRIDWIDTH equ (7*GRIDSPACING+1) |
97 | GRIDCOLOR equ MOS_RGB(128,128,128) |
97 | GRIDCOLOR equ MOS_RGB(128,128,128) |
98 | 98 | ||
99 | 99 | ||
100 | 100 | ||
101 | ; button id's |
101 | ; button id's |
102 | BT_QUIT equ 1 |
102 | BT_QUIT equ 1 |
103 | BT_NEW equ 2 |
103 | BT_NEW equ 2 |
104 | BT_PLAYER1DN equ 3 |
104 | BT_PLAYER1DN equ 3 |
105 | BT_PLAYER1UP equ 4 |
105 | BT_PLAYER1UP equ 4 |
106 | BT_PLAYER2DN equ 5 |
106 | BT_PLAYER2DN equ 5 |
107 | BT_PLAYER2UP equ 6 |
107 | BT_PLAYER2UP equ 6 |
108 | 108 | ||
109 | 109 | ||
110 | start: |
110 | start: |
111 | jmp main |
111 | jmp main |
112 | 112 | ||
113 | %include "pcx.inc" |
113 | %include "pcx.inc" |
114 | %include "windows.inc" |
114 | %include "windows.inc" |
115 | %include "board.inc" |
115 | %include "board.inc" |
116 | %include "rng.inc" |
116 | %include "rng.inc" |
117 | ; %include "randomai.inc" |
117 | ; %include "randomai.inc" |
118 | %include "ai.inc" |
118 | %include "ai.inc" |
119 | 119 | ||
120 | 120 | ||
121 | 121 | ||
122 | ;********************************************************** |
122 | ;********************************************************** |
123 | ; main program |
123 | ; main program |
124 | ;********************************************************** |
124 | ;********************************************************** |
125 | main: |
125 | main: |
126 | call randomize |
126 | call randomize |
127 | call defineWindow |
127 | call defineWindow |
128 | call decrunchImages |
128 | call decrunchImages |
129 | call newGame |
129 | call newGame |
130 | 130 | ||
131 | .msgpump: |
131 | .msgpump: |
132 | ; wait for event |
132 | ; wait for event |
133 | mov ebx,1 |
133 | mov ebx,1 |
134 | mov eax,MOS_SC_WAITEVENTTIMEOUT |
134 | mov eax,MOS_SC_WAITEVENTTIMEOUT |
135 | int 0x40 |
135 | int 0x40 |
136 | 136 | ||
137 | ; process events |
137 | ; process events |
138 | cmp eax,MOS_EVT_REDRAW |
138 | cmp eax,MOS_EVT_REDRAW |
139 | je short .redraw |
139 | je short .redraw |
140 | cmp eax,MOS_EVT_KEY |
140 | cmp eax,MOS_EVT_KEY |
141 | je short .key |
141 | je short .key |
142 | cmp eax,MOS_EVT_BUTTON |
142 | cmp eax,MOS_EVT_BUTTON |
143 | je short .button |
143 | je short .button |
144 | 144 | ||
145 | call pollMouse |
145 | call pollMouse |
146 | call gameLoop |
146 | call gameLoop |
147 | jmp short .msgpump |
147 | jmp short .msgpump |
148 | 148 | ||
149 | .redraw: |
149 | .redraw: |
150 | call defineWindow |
150 | call defineWindow |
151 | jmp short .msgpump |
151 | jmp short .msgpump |
152 | .key: |
152 | .key: |
153 | call keyboardInput |
153 | call keyboardInput |
154 | jmp short .msgpump |
154 | jmp short .msgpump |
155 | .button: |
155 | .button: |
156 | call handleButton |
156 | call handleButton |
157 | jmp short .msgpump |
157 | jmp short .msgpump |
158 | 158 | ||
159 | 159 | ||
160 | 160 | ||
161 | ;********************************************************** |
161 | ;********************************************************** |
162 | ; button handling function |
162 | ; button handling function |
163 | ;********************************************************** |
163 | ;********************************************************** |
164 | handleButton: |
164 | handleButton: |
165 | mov eax,MOS_SC_GETPRESSEDBUTTON ; get button id |
165 | mov eax,MOS_SC_GETPRESSEDBUTTON ; get button id |
166 | int 0x40 |
166 | int 0x40 |
167 | 167 | ||
168 | cmp al,1 ; button pressed ? |
168 | cmp al,1 ; button pressed ? |
169 | je short .bye ; nope -> nothing to do |
169 | je short .bye ; nope -> nothing to do |
170 | 170 | ||
171 | cmp ah,BT_QUIT ; which button has been pressed ? |
171 | cmp ah,BT_QUIT ; which button has been pressed ? |
172 | je short .quit |
172 | je short .quit |
173 | cmp ah,BT_NEW |
173 | cmp ah,BT_NEW |
174 | je short .new |
174 | je short .new |
175 | cmp ah,BT_PLAYER1DN |
175 | cmp ah,BT_PLAYER1DN |
176 | je short .player1dn |
176 | je short .player1dn |
177 | cmp ah,BT_PLAYER1UP |
177 | cmp ah,BT_PLAYER1UP |
178 | je short .player1up |
178 | je short .player1up |
179 | cmp ah,BT_PLAYER2DN |
179 | cmp ah,BT_PLAYER2DN |
180 | je short .player2dn |
180 | je short .player2dn |
181 | cmp ah,BT_PLAYER2UP |
181 | cmp ah,BT_PLAYER2UP |
182 | je short .player2up |
182 | je short .player2up |
183 | .bye: |
183 | .bye: |
184 | ret |
184 | ret |
185 | .quit: |
185 | .quit: |
186 | MOS_EXIT |
186 | MOS_EXIT |
187 | .new: |
187 | .new: |
188 | call newGame |
188 | call newGame |
189 | ret |
189 | ret |
190 | .player1dn: |
190 | .player1dn: |
191 | mov eax,[player1_type] ; get current type |
191 | mov eax,[player1_type] ; get current type |
192 | or eax,eax ; already zero ? |
192 | or eax,eax ; already zero ? |
193 | jz .bla |
193 | jz .bla |
194 | dec eax ; nope -> decrement |
194 | dec eax ; nope -> decrement |
195 | mov [player1_type],eax ; write back |
195 | mov [player1_type],eax ; write back |
196 | mov edi,label_pl1type ; and update label |
196 | mov edi,label_pl1type ; and update label |
197 | call updatePlayerType |
197 | call updatePlayerType |
198 | .bla: |
198 | .bla: |
199 | ret |
199 | ret |
200 | .player1up: |
200 | .player1up: |
201 | mov eax,[player1_type] ; get current type |
201 | mov eax,[player1_type] ; get current type |
202 | cmp eax,NPLAYERTYPES-1 ; already max ? |
202 | cmp eax,NPLAYERTYPES-1 ; already max ? |
203 | je .bla2 |
203 | je .bla2 |
204 | inc eax ; nope -> increment |
204 | inc eax ; nope -> increment |
205 | mov [player1_type],eax ; write back |
205 | mov [player1_type],eax ; write back |
206 | mov edi,label_pl1type ; update label |
206 | mov edi,label_pl1type ; update label |
207 | call updatePlayerType |
207 | call updatePlayerType |
208 | .bla2: |
208 | .bla2: |
209 | ret |
209 | ret |
210 | .player2dn: |
210 | .player2dn: |
211 | mov eax,[player2_type] ; get current type |
211 | mov eax,[player2_type] ; get current type |
212 | or eax,eax ; already zero ? |
212 | or eax,eax ; already zero ? |
213 | jz .bla3 |
213 | jz .bla3 |
214 | dec eax ; nope -> decrement |
214 | dec eax ; nope -> decrement |
215 | mov [player2_type],eax ; write back |
215 | mov [player2_type],eax ; write back |
216 | mov edi,label_pl2type ; and update label |
216 | mov edi,label_pl2type ; and update label |
217 | call updatePlayerType |
217 | call updatePlayerType |
218 | .bla3: |
218 | .bla3: |
219 | ret |
219 | ret |
220 | .player2up: |
220 | .player2up: |
221 | mov eax,[player2_type] |
221 | mov eax,[player2_type] |
222 | cmp eax,NPLAYERTYPES-1 |
222 | cmp eax,NPLAYERTYPES-1 |
223 | je .bla4 |
223 | je .bla4 |
224 | inc eax |
224 | inc eax |
225 | mov [player2_type],eax |
225 | mov [player2_type],eax |
226 | mov edi,label_pl2type |
226 | mov edi,label_pl2type |
227 | call updatePlayerType |
227 | call updatePlayerType |
228 | .bla4: |
228 | .bla4: |
229 | ret |
229 | ret |
230 | 230 | ||
231 | 231 | ||
232 | 232 | ||
233 | ;********************************************************** |
233 | ;********************************************************** |
234 | ; window definition function |
234 | ; window definition function |
235 | ;********************************************************** |
235 | ;********************************************************** |
236 | defineWindow: |
236 | defineWindow: |
237 | MOS_STARTREDRAW |
237 | MOS_STARTREDRAW |
238 | 238 | ||
239 | mov edi,window |
239 | mov edi,window |
240 | call drawWindow |
240 | call drawWindow |
241 | 241 | ||
242 | mov edi,buttons |
242 | mov edi,buttons |
243 | mov ecx,NBUTTONS |
243 | mov ecx,NBUTTONS |
244 | call drawButtons |
244 | call drawButtons |
245 | 245 | ||
246 | mov edi,labels |
246 | mov edi,labels |
247 | mov ecx,NLABELS |
247 | mov ecx,NLABELS |
248 | call drawLabels |
248 | call drawLabels |
249 | 249 | ||
250 | xor eax,eax |
250 | xor eax,eax |
251 | call drawBoard |
251 | call drawBoard |
252 | 252 | ||
253 | MOS_ENDREDRAW |
253 | MOS_ENDREDRAW |
254 | ret |
254 | ret |
255 | 255 | ||
256 | 256 | ||
257 | 257 | ||
258 | ;********************************************************** |
258 | ;********************************************************** |
259 | ; updateStatusText |
259 | ; updateStatusText |
260 | ; |
260 | ; |
261 | ; input : esi = ptr to new string |
261 | ; input : esi = ptr to new string |
262 | ; output : status bar is updated |
262 | ; output : status bar is updated |
263 | ; destroys : everything |
263 | ; destroys : everything |
264 | ;********************************************************** |
264 | ;********************************************************** |
265 | updateStatusText: |
265 | updateStatusText: |
266 | 266 | ||
267 | ; different text ? |
267 | ; different text ? |
268 | cmp [statusbar + LABEL.caption],esi |
268 | cmp [statusbar + LABEL.caption],esi |
269 | je .bye ; nope -> bye |
269 | je .bye ; nope -> bye |
270 | mov dword [statusbar + LABEL.caption],esi ; yeah -> save & redraw |
270 | mov dword [statusbar + LABEL.caption],esi ; yeah -> save & redraw |
271 | 271 | ||
272 | ; clear background |
272 | ; clear background |
273 | mov ebx,MOS_DWORD(LABEL_STATUS_X,LABEL_STATUS_WIDTH) |
273 | mov ebx,MOS_DWORD(LABEL_STATUS_X,LABEL_STATUS_WIDTH) |
274 | mov ecx,MOS_DWORD(LABEL_STATUS_Y,LABEL_STATUS_HEIGHT) |
274 | mov ecx,MOS_DWORD(LABEL_STATUS_Y,LABEL_STATUS_HEIGHT) |
275 | xor edx,edx |
275 | xor edx,edx |
276 | mov eax,MOS_SC_DRAWBAR |
276 | mov eax,MOS_SC_DRAWBAR |
277 | int 0x40 |
277 | int 0x40 |
278 | 278 | ||
279 | ; redraw label |
279 | ; redraw label |
280 | mov edi,statusbar |
280 | mov edi,statusbar |
281 | mov ecx,1 |
281 | mov ecx,1 |
282 | call drawLabels |
282 | call drawLabels |
283 | .bye: |
283 | .bye: |
284 | ret |
284 | ret |
285 | 285 | ||
286 | 286 | ||
287 | 287 | ||
288 | ;********************************************************** |
288 | ;********************************************************** |
289 | ; updatePlayerType |
289 | ; updatePlayerType |
290 | ; update player type label |
290 | ; update player type label |
291 | ; input: eax = new type |
291 | ; input: eax = new type |
292 | ; edi = address label structure to update |
292 | ; edi = address label structure to update |
293 | ;********************************************************** |
293 | ;********************************************************** |
294 | updatePlayerType: |
294 | updatePlayerType: |
295 | mov ebx,PLAYERTYPELEN ; calculate type string address |
295 | mov ebx,PLAYERTYPELEN ; calculate type string address |
296 | mul ebx |
296 | mul ebx |
297 | add eax,playertypes |
297 | add eax,playertypes |
298 | mov [edi + LABEL.caption],eax ; write address |
298 | mov [edi + LABEL.caption],eax ; write address |
299 | mov ecx,1 ; and redraw label |
299 | mov ecx,1 ; and redraw label |
300 | call drawLabels |
300 | call drawLabels |
301 | ret |
301 | ret |
302 | 302 | ||
303 | 303 | ||
304 | 304 | ||
305 | ;********************************************************** |
305 | ;********************************************************** |
306 | ; board drawing stuff |
306 | ; board drawing stuff |
307 | ;********************************************************** |
307 | ;********************************************************** |
308 | 308 | ||
309 | ; drawBoard |
309 | ; drawBoard |
310 | ; draw whole board |
310 | ; draw whole board |
311 | ; |
311 | ; |
312 | ; input : eax nonzero = clear board background |
312 | ; input : eax nonzero = clear board background |
313 | drawBoard: |
313 | drawBoard: |
314 | 314 | ||
315 | ; clear background ? |
315 | ; clear background ? |
316 | or eax,eax |
316 | or eax,eax |
317 | jz .noclear |
317 | jz .noclear |
318 | mov ebx,MOS_DWORD(GRIDX,GRIDWIDTH) |
318 | mov ebx,MOS_DWORD(GRIDX,GRIDWIDTH) |
319 | mov ecx,MOS_DWORD(GRIDY,GRIDHEIGHT) |
319 | mov ecx,MOS_DWORD(GRIDY,GRIDHEIGHT) |
320 | mov edx,WND_WORKCOLOR |
320 | mov edx,WND_WORKCOLOR |
321 | mov eax,MOS_SC_DRAWBAR |
321 | mov eax,MOS_SC_DRAWBAR |
322 | int 0x40 |
322 | int 0x40 |
323 | .noclear: |
323 | .noclear: |
324 | call drawGrid |
324 | call drawGrid |
325 | call drawStones |
325 | call drawStones |
326 | ret |
326 | ret |
327 | 327 | ||
328 | 328 | ||
329 | 329 | ||
330 | drawGrid: |
330 | drawGrid: |
331 | 331 | ||
332 | ; vertical lines |
332 | ; vertical lines |
333 | mov ebx,MOS_DWORD(GRIDX,GRIDX) |
333 | mov ebx,MOS_DWORD(GRIDX,GRIDX) |
334 | mov ecx,MOS_DWORD(GRIDY,GRIDY+GRIDHEIGHT-1) |
334 | mov ecx,MOS_DWORD(GRIDY,GRIDY+GRIDHEIGHT-1) |
335 | mov edx,GRIDCOLOR |
335 | mov edx,GRIDCOLOR |
336 | mov eax,MOS_SC_DRAWLINE |
336 | mov eax,MOS_SC_DRAWLINE |
337 | mov esi,8 |
337 | mov esi,8 |
338 | .vlines: |
338 | .vlines: |
339 | int 0x40 |
339 | int 0x40 |
340 | add ebx,MOS_DWORD(GRIDSPACING,GRIDSPACING) |
340 | add ebx,MOS_DWORD(GRIDSPACING,GRIDSPACING) |
341 | dec esi |
341 | dec esi |
342 | jnz .vlines |
342 | jnz .vlines |
343 | 343 | ||
344 | ; horizontal lines |
344 | ; horizontal lines |
345 | mov ebx,MOS_DWORD(GRIDX,GRIDX+GRIDWIDTH-1) |
345 | mov ebx,MOS_DWORD(GRIDX,GRIDX+GRIDWIDTH-1) |
346 | mov ecx,MOS_DWORD(GRIDY,GRIDY) |
346 | mov ecx,MOS_DWORD(GRIDY,GRIDY) |
347 | mov esi,7 |
347 | mov esi,7 |
348 | .hlines: |
348 | .hlines: |
349 | int 0x40 |
349 | int 0x40 |
350 | add ecx,MOS_DWORD(GRIDSPACING,GRIDSPACING) |
350 | add ecx,MOS_DWORD(GRIDSPACING,GRIDSPACING) |
351 | dec esi |
351 | dec esi |
352 | jnz .hlines |
352 | jnz .hlines |
353 | 353 | ||
354 | ret |
354 | ret |
355 | 355 | ||
356 | 356 | ||
357 | drawStones: |
357 | drawStones: |
358 | mov ebx,6 |
358 | mov ebx,6 |
359 | .col: |
359 | .col: |
360 | mov ecx,7 |
360 | mov ecx,7 |
361 | .row: |
361 | .row: |
362 | call drawStone |
362 | call drawStone |
363 | loop .row |
363 | loop .row |
364 | dec ebx |
364 | dec ebx |
365 | jnz .col |
365 | jnz .col |
366 | ret |
366 | ret |
367 | 367 | ||
368 | 368 | ||
369 | 369 | ||
370 | ; ecx = column (1..7) |
370 | ; ecx = column (1..7) |
371 | ; ebx = row (1..6) |
371 | ; ebx = row (1..6) |
372 | drawStone: |
372 | drawStone: |
373 | pushad |
373 | pushad |
374 | 374 | ||
375 | ; see which image to draw. |
375 | ; see which image to draw. |
376 | ; the image offset is stored in ebp |
376 | ; the image offset is stored in ebp |
377 | mov eax,BWIDTH ; calculate address |
377 | mov eax,BWIDTH ; calculate address |
378 | mul ebx |
378 | mul ebx |
379 | add eax,ecx |
379 | add eax,ecx |
380 | mov eax,[board+eax*4] ; get stone ? |
380 | mov eax,[board+eax*4] ; get stone ? |
381 | cmp eax,EMPTY ; empty field -> nothing to do |
381 | cmp eax,EMPTY ; empty field -> nothing to do |
382 | je .bye |
382 | je .bye |
383 | mov ebp,redstone ; assume red stone |
383 | mov ebp,redstone ; assume red stone |
384 | cmp eax,PLAYER1 ; red ? |
384 | cmp eax,PLAYER1 ; red ? |
385 | je .stoneok ; yeah -> continue |
385 | je .stoneok ; yeah -> continue |
386 | mov ebp,bluestone ; nope -> use blue stone |
386 | mov ebp,bluestone ; nope -> use blue stone |
387 | .stoneok: |
387 | .stoneok: |
388 | 388 | ||
389 | ; calculate image position (edx) |
389 | ; calculate image position (edx) |
390 | mov eax,GRIDSPACING |
390 | mov eax,GRIDSPACING |
391 | dec ecx |
391 | dec ecx |
392 | mul ecx |
392 | mul ecx |
393 | add eax,GRIDX + 1 |
393 | add eax,GRIDX + 1 |
394 | shl eax,16 |
394 | shl eax,16 |
395 | mov ecx,eax |
395 | mov ecx,eax |
396 | mov eax,GRIDSPACING |
396 | mov eax,GRIDSPACING |
397 | dec ebx |
397 | dec ebx |
398 | mul ebx |
398 | mul ebx |
399 | add eax,GRIDY + 1 |
399 | add eax,GRIDY + 1 |
400 | mov cx,ax |
400 | mov cx,ax |
401 | mov edx,ecx |
401 | mov edx,ecx |
402 | 402 | ||
403 | ; put image (position is already in edx) |
403 | ; put image (position is already in edx) |
404 | mov ebx,ebp ; image address |
404 | mov ebx,ebp ; image address |
405 | mov ecx,MOS_DWORD(STONESIZE,STONESIZE) ; image dimensions |
405 | mov ecx,MOS_DWORD(STONESIZE,STONESIZE) ; image dimensions |
406 | mov eax,MOS_SC_PUTIMAGE |
406 | mov eax,MOS_SC_PUTIMAGE |
407 | int 0x40 |
407 | int 0x40 |
408 | 408 | ||
409 | .bye: |
409 | .bye: |
410 | popad |
410 | popad |
411 | ret |
411 | ret |
412 | 412 | ||
413 | 413 | ||
414 | 414 | ||
415 | decrunchImages: |
415 | decrunchImages: |
416 | mov esi,redpcx ; red stone |
416 | mov esi,redpcx ; red stone |
417 | mov edi,redstone |
417 | mov edi,redstone |
418 | mov ebx,REDPCXSIZE |
418 | mov ebx,REDPCXSIZE |
419 | call loadPCX |
419 | call loadPCX |
420 | mov esi,bluepcx ; blue stone |
420 | mov esi,bluepcx ; blue stone |
421 | mov edi,bluestone |
421 | mov edi,bluestone |
422 | mov ebx,BLUEPCXSIZE |
422 | mov ebx,BLUEPCXSIZE |
423 | call loadPCX |
423 | call loadPCX |
424 | ret |
424 | ret |
425 | 425 | ||
426 | 426 | ||
427 | 427 | ||
428 | resetInput: |
428 | resetInput: |
429 | mov dword [playerinput],0 ; no player input |
429 | mov dword [playerinput],0 ; no player input |
430 | mov dword [mouseinput],0 |
430 | mov dword [mouseinput],0 |
431 | ret |
431 | ret |
432 | 432 | ||
433 | 433 | ||
434 | 434 | ||
435 | ;********************************************************** |
435 | ;********************************************************** |
436 | ; newGame |
436 | ; newGame |
437 | ; set up everything for a game |
437 | ; set up everything for a game |
438 | ; |
438 | ; |
439 | ; input : nothing |
439 | ; input : nothing |
440 | ; output : nothing |
440 | ; output : nothing |
441 | ; destroys : everything |
441 | ; destroys : everything |
442 | ;********************************************************** |
442 | ;********************************************************** |
443 | newGame: |
443 | newGame: |
444 | call boardReset ; reset and redraw board |
444 | call boardReset ; reset and redraw board |
445 | mov eax,1 |
445 | mov eax,1 |
446 | call drawBoard |
446 | call drawBoard |
447 | call resetInput ; reset input |
447 | call resetInput ; reset input |
448 | mov dword [gameover],0 ; game is running |
448 | mov dword [gameover],0 ; game is running |
449 | ret |
449 | ret |
450 | 450 | ||
451 | 451 | ||
452 | 452 | ||
453 | ;********************************************************** |
453 | ;********************************************************** |
454 | ; pollMouse |
454 | ; pollMouse |
455 | ; mouse polling routine |
455 | ; mouse polling routine |
456 | ; |
456 | ; |
457 | ; input : nothing |
457 | ; input : nothing |
458 | ; output : playerinput will be updated, if |
458 | ; output : playerinput will be updated, if |
459 | ; the player clicked on a valid |
459 | ; the player clicked on a valid |
460 | ; field |
460 | ; field |
461 | ; destroys : everything |
461 | ; destroys : everything |
462 | ;********************************************************** |
462 | ;********************************************************** |
463 | pollMouse: |
463 | pollMouse: |
464 | mov ebx,2 |
464 | mov ebx,2 |
465 | mov eax,MOS_SC_GETMOUSEPOSITION |
465 | mov eax,MOS_SC_GETMOUSEPOSITION |
466 | int 0x40 |
466 | int 0x40 |
467 | and eax,1 |
467 | and eax,1 |
468 | jz .mousenotpressed |
468 | jz .mousenotpressed |
469 | .mousepressed: |
469 | .mousepressed: |
470 | mov dword [mouseinput],0 |
470 | mov dword [mouseinput],0 |
471 | call isActiveApp |
471 | call isActiveApp |
472 | or al,al |
472 | or al,al |
473 | jz .notactive1 |
473 | jz .notactive1 |
474 | call getMouseCol |
474 | call getMouseCol |
475 | mov [mouseinput],eax |
475 | mov [mouseinput],eax |
476 | .notactive1: |
476 | .notactive1: |
477 | ret |
477 | ret |
478 | .mousenotpressed: |
478 | .mousenotpressed: |
479 | call isActiveApp |
479 | call isActiveApp |
480 | or al,al |
480 | or al,al |
481 | jz .notactive2 |
481 | jz .notactive2 |
482 | call getMouseCol |
482 | call getMouseCol |
483 | cmp eax,[mouseinput] |
483 | cmp eax,[mouseinput] |
484 | jne .nonewinput |
484 | jne .nonewinput |
485 | cmp dword [playerinput],0 |
485 | cmp dword [playerinput],0 |
486 | jne .nonewinput |
486 | jne .nonewinput |
487 | mov [playerinput],eax |
487 | mov [playerinput],eax |
488 | .nonewinput: |
488 | .nonewinput: |
489 | .notactive2: |
489 | .notactive2: |
490 | mov dword [mouseinput],0 |
490 | mov dword [mouseinput],0 |
491 | ret |
491 | ret |
492 | 492 | ||
493 | 493 | ||
494 | 494 | ||
495 | ;********************************************************** |
495 | ;********************************************************** |
496 | ; getMouseCol |
496 | ; getMouseCol |
497 | ; calculate in which column the mouse is. or so. |
497 | ; calculate in which column the mouse is. or so. |
498 | ; |
498 | ; |
499 | ; input : nothing |
499 | ; input : nothing |
500 | ; output : eax = 0 -> mouse outside board |
500 | ; output : eax = 0 -> mouse outside board |
501 | ; eax = 1..7 -> column |
501 | ; eax = 1..7 -> column |
502 | ; destroys : everything |
502 | ; destroys : everything |
503 | ;********************************************************** |
503 | ;********************************************************** |
504 | getMouseCol: |
504 | getMouseCol: |
505 | 505 | ||
506 | mov ebx,1 ; get mouse position, window relative |
506 | mov ebx,1 ; get mouse position, window relative |
507 | mov eax,MOS_SC_GETMOUSEPOSITION |
507 | mov eax,MOS_SC_GETMOUSEPOSITION |
508 | int 0x40 |
508 | int 0x40 |
509 | 509 | ||
510 | movzx ebx,ax ; y clipping |
510 | movzx ebx,ax ; y clipping |
511 | cmp ebx,GRIDY |
511 | cmp ebx,GRIDY |
512 | jl .outside |
512 | jl .outside |
513 | cmp ebx,GRIDY + GRIDHEIGHT - 1 |
513 | cmp ebx,GRIDY + GRIDHEIGHT - 1 |
514 | jg .outside |
514 | jg .outside |
515 | 515 | ||
516 | shr eax,16 ; calculate column from x coordinate |
516 | shr eax,16 ; calculate column from x coordinate |
517 | sub eax,GRIDX |
517 | sub eax,GRIDX |
518 | js .outside ; negative -> outside of board (left) |
518 | js .outside ; negative -> outside of board (left) |
519 | cdq ; ! |
519 | cdq ; ! |
520 | mov ebx,GRIDSPACING |
520 | mov ebx,GRIDSPACING |
521 | div ebx |
521 | div ebx |
522 | cmp eax,BWIDTH-3 ; right outside of board ? |
522 | cmp eax,BWIDTH-3 ; right outside of board ? |
523 | jg .outside ; yes -> bye |
523 | jg .outside ; yes -> bye |
524 | 524 | ||
525 | inc eax ; xform into range [1,7] |
525 | inc eax ; xform into range [1,7] |
526 | ret |
526 | ret |
527 | .outside: |
527 | .outside: |
528 | xor eax,eax |
528 | xor eax,eax |
529 | ret |
529 | ret |
530 | 530 | ||
531 | 531 | ||
532 | 532 | ||
533 | ;********************************************************** |
533 | ;********************************************************** |
534 | ; isActiveApp |
534 | ; isActiveApp |
535 | ; check wether we're the active application |
535 | ; check wether we're the active application |
536 | ; |
536 | ; |
537 | ; input : nothing |
537 | ; input : nothing |
538 | ; output : al nonzero -> we are the active app |
538 | ; output : al nonzero -> we are the active app |
539 | ; destroys : everything |
539 | ; destroys : everything |
540 | ;********************************************************** |
540 | ;********************************************************** |
541 | isActiveApp: |
541 | isActiveApp: |
542 | 542 | ||
543 | %define PROCINFO (ebp-MOS_PROCESSINFO_size) |
543 | %define PROCINFO (ebp-MOS_PROCESSINFO_size) |
544 | 544 | ||
545 | enter MOS_PROCESSINFO_size,0 |
545 | enter MOS_PROCESSINFO_size,0 |
546 | 546 | ||
547 | ; get process information |
547 | ; get process information |
548 | mov eax,MOS_SC_GETPROCESSINFO |
548 | mov eax,MOS_SC_GETPROCESSINFO |
549 | lea ebx,[ebp-MOS_PROCESSINFO_size] |
549 | lea ebx,[ebp-MOS_PROCESSINFO_size] |
550 | mov ecx,-1 |
550 | mov ecx,-1 |
551 | int 0x40 |
551 | int 0x40 |
552 | 552 | ||
553 | ; set al to 1 if we are the active application |
553 | ; set al to 1 if we are the active application |
554 | cmp ax,[PROCINFO+MOS_PROCESSINFO.windowStackPos] |
554 | cmp ax,[PROCINFO+MOS_PROCESSINFO.windowStackPos] |
555 | sete al |
555 | sete al |
556 | 556 | ||
557 | leave |
557 | leave |
558 | ret |
558 | ret |
559 | %undef PROCINFO |
559 | %undef PROCINFO |
560 | 560 | ||
561 | 561 | ||
562 | 562 | ||
563 | ;********************************************************** |
563 | ;********************************************************** |
564 | ; keyboardInput |
564 | ; keyboardInput |
565 | ; keyboard input handler, called from main loop |
565 | ; keyboard input handler, called from main loop |
566 | ; |
566 | ; |
567 | ; input : nothing |
567 | ; input : nothing |
568 | ; output : playerinput is updated |
568 | ; output : playerinput is updated |
569 | ; destroys : everything |
569 | ; destroys : everything |
570 | ;********************************************************** |
570 | ;********************************************************** |
571 | keyboardInput: |
571 | keyboardInput: |
572 | mov eax,MOS_SC_GETKEY ; get key |
572 | mov eax,MOS_SC_GETKEY ; get key |
573 | int 0x40 |
573 | int 0x40 |
574 | or al,al ; key available ? |
574 | or al,al ; key available ? |
575 | jnz .bye ; no -> bye |
575 | jnz .bye ; no -> bye |
576 | cmp dword [playerinput],0 ; unprocessed input available ? |
576 | cmp dword [playerinput],0 ; unprocessed input available ? |
577 | jne .bye ; yes -> bye |
577 | jne .bye ; yes -> bye |
578 | 578 | ||
579 | sub ah,'1' ; valid key ? |
579 | sub ah,'1' ; valid key ? |
580 | cmp ah,BWIDTH-3 |
580 | cmp ah,BWIDTH-3 |
581 | ja .bye ; treat as unsigned : keys below '1' will |
581 | ja .bye ; treat as unsigned : keys below '1' will |
582 | ; be greater too =) |
582 | ; be greater too =) |
583 | 583 | ||
584 | mov al,ah ; save input |
584 | mov al,ah ; save input |
585 | and eax,255 |
585 | and eax,255 |
586 | inc eax |
586 | inc eax |
587 | mov [playerinput],eax |
587 | mov [playerinput],eax |
588 | 588 | ||
589 | .bye: |
589 | .bye: |
590 | ret |
590 | ret |
591 | 591 | ||
592 | 592 | ||
593 | 593 | ||
594 | ;********************************************************** |
594 | ;********************************************************** |
595 | ; gameLoop |
595 | ; gameLoop |
596 | ; game logic code or however you wish to call it. |
596 | ; game logic code or however you wish to call it. |
597 | ; actually this is not a loop, but is called from |
597 | ; actually this is not a loop, but is called from |
598 | ; the main loop |
598 | ; the main loop |
599 | ;********************************************************** |
599 | ;********************************************************** |
600 | gameLoop: |
600 | gameLoop: |
601 | 601 | ||
602 | ; if the game is over, return |
602 | ; if the game is over, return |
603 | cmp dword [gameover],0 |
603 | cmp dword [gameover],0 |
604 | je .gamerunning |
604 | je .gamerunning |
605 | ret |
605 | ret |
606 | .gamerunning: |
606 | .gamerunning: |
607 | 607 | ||
608 | call updatePlayerStatusText |
608 | call updatePlayerStatusText |
609 | 609 | ||
610 | ; get move |
610 | ; get move |
611 | call getMoveForCurrentPlayer |
611 | call getMoveForCurrentPlayer |
612 | or eax,eax |
612 | or eax,eax |
613 | jnz .moveok |
613 | jnz .moveok |
614 | ret ; no move available -> bye |
614 | ret ; no move available -> bye |
615 | .moveok: |
615 | .moveok: |
616 | 616 | ||
617 | ; make move and update board graphics |
617 | ; make move and update board graphics |
618 | mov ebx,[currentplayer] ; ebx = current player, eax contains already move |
618 | mov ebx,[currentplayer] ; ebx = current player, eax contains already move |
619 | call boardMakeMove |
619 | call boardMakeMove |
620 | call drawStones |
620 | call drawStones |
621 | 621 | ||
622 | ; check wether game is over (either by a win or because the board is full) |
622 | ; check wether game is over (either by a win or because the board is full) |
623 | mov eax,[currentplayer] ; win for current player ? |
623 | mov eax,[currentplayer] ; win for current player ? |
624 | call boardIsWin |
624 | call boardIsWin |
625 | or eax,eax |
625 | or eax,eax |
626 | jz .nowin ; no -> continue |
626 | jz .nowin ; no -> continue |
627 | mov esi,player1wins ; yes -> display message... |
627 | mov esi,player1wins ; yes -> display message... |
628 | cmp dword [currentplayer],PLAYER1 |
628 | cmp dword [currentplayer],PLAYER1 |
629 | je .blubb |
629 | je .blubb |
630 | mov esi,player2wins |
630 | mov esi,player2wins |
631 | .blubb: |
631 | .blubb: |
632 | call updateStatusText |
632 | call updateStatusText |
633 | mov dword [gameover],1 ; ...and end game |
633 | mov dword [gameover],1 ; ...and end game |
634 | ret |
634 | ret |
635 | .nowin: |
635 | .nowin: |
636 | BOARDISFULL ; board full, but no win ? |
636 | BOARDISFULL ; board full, but no win ? |
637 | jnz .notfull ; no -> continue |
637 | jnz .notfull ; no -> continue |
638 | mov esi,itisadraw ; yes -> display message... |
638 | mov esi,itisadraw ; yes -> display message... |
639 | call updateStatusText |
639 | call updateStatusText |
640 | mov dword [gameover],1 ; ...and end game |
640 | mov dword [gameover],1 ; ...and end game |
641 | ret |
641 | ret |
642 | .notfull: |
642 | .notfull: |
643 | 643 | ||
644 | ; switch players and return to main loop |
644 | ; switch players and return to main loop |
645 | BOARDSWITCHPLAYERS |
645 | BOARDSWITCHPLAYERS |
646 | ret |
646 | ret |
647 | 647 | ||
648 | 648 | ||
649 | 649 | ||
650 | ;********************************************************** |
650 | ;********************************************************** |
651 | ; getMoveForCurrentPlayer |
651 | ; getMoveForCurrentPlayer |
652 | ; returns the move made by the current player |
652 | ; returns the move made by the current player |
653 | ; (either cpu or human) |
653 | ; (either cpu or human) |
654 | ; |
654 | ; |
655 | ; input : nothing |
655 | ; input : nothing |
656 | ; output : eax = 0 -> no move made. this is |
656 | ; output : eax = 0 -> no move made. this is |
657 | ; usually the case for human players, |
657 | ; usually the case for human players, |
658 | ; when no valid input is available. |
658 | ; when no valid input is available. |
659 | ; else eax = move number |
659 | ; else eax = move number |
660 | ;********************************************************** |
660 | ;********************************************************** |
661 | getMoveForCurrentPlayer: |
661 | getMoveForCurrentPlayer: |
662 | 662 | ||
663 | ; get type of current player |
663 | ; get type of current player |
664 | mov eax,[player1_type] |
664 | mov eax,[player1_type] |
665 | cmp dword [currentplayer],PLAYER1 |
665 | cmp dword [currentplayer],PLAYER1 |
666 | je .ok |
666 | je .ok |
667 | mov eax,[player2_type] |
667 | mov eax,[player2_type] |
668 | .ok: |
668 | .ok: |
669 | 669 | ||
670 | ; get move for human/cpu player |
670 | ; get move for human/cpu player |
671 | or eax,eax |
671 | or eax,eax |
672 | jnz .cpu |
672 | jnz .cpu |
673 | .human: |
673 | .human: |
674 | mov eax,[playerinput] ; get input |
674 | mov eax,[playerinput] ; get input |
675 | or eax,eax ; input available ? |
675 | or eax,eax ; input available ? |
676 | jz .nomove ; no -> return no move available |
676 | jz .nomove ; no -> return no move available |
677 | call resetInput ; ! |
677 | call resetInput ; ! |
678 | BOARDISVALIDMOVE eax ; valid move `? |
678 | BOARDISVALIDMOVE eax ; valid move `? |
679 | jz .nomove ; no -> return no move available |
679 | jz .nomove ; no -> return no move available |
680 | ret ; valid move available -> return it (eax) |
680 | ret ; valid move available -> return it (eax) |
681 | 681 | ||
682 | .cpu: |
682 | .cpu: |
683 | call dword [aicode] ; call ai machine. cpu level is already in eax |
683 | call dword [aicode] ; call ai machine. cpu level is already in eax |
684 | ret |
684 | ret |
685 | .nomove: |
685 | .nomove: |
686 | xor eax,eax |
686 | xor eax,eax |
687 | ret |
687 | ret |
688 | 688 | ||
689 | 689 | ||
690 | 690 | ||
691 | ;********************************************************** |
691 | ;********************************************************** |
692 | ; update status bar : which player's turn it is |
692 | ; update status bar : which player's turn it is |
693 | ;********************************************************** |
693 | ;********************************************************** |
694 | updatePlayerStatusText: |
694 | updatePlayerStatusText: |
695 | cmp dword [currentplayer],PLAYER2 |
695 | cmp dword [currentplayer],PLAYER2 |
696 | je .player2 |
696 | je .player2 |
697 | mov esi,player1hmnprmpt |
697 | mov esi,player1hmnprmpt |
698 | cmp dword [player1_type],0 |
698 | cmp dword [player1_type],0 |
699 | je .statustextok |
699 | je .statustextok |
700 | mov esi,player1cpuprmpt |
700 | mov esi,player1cpuprmpt |
701 | jmp short .statustextok |
701 | jmp short .statustextok |
702 | .player2: |
702 | .player2: |
703 | mov esi,player2hmnprmpt |
703 | mov esi,player2hmnprmpt |
704 | cmp dword [player2_type],0 |
704 | cmp dword [player2_type],0 |
705 | je .statustextok |
705 | je .statustextok |
706 | mov esi,player2cpuprmpt |
706 | mov esi,player2cpuprmpt |
707 | .statustextok: |
707 | .statustextok: |
708 | call updateStatusText |
708 | call updateStatusText |
709 | ret |
709 | ret |
710 | 710 | ||
711 | 711 | ||
712 | 712 | ||
713 | ;********************************************************** |
713 | ;********************************************************** |
714 | ; initialized data |
714 | ; initialized data |
715 | ;********************************************************** |
715 | ;********************************************************** |
716 | 716 | ||
717 | section .data |
717 | section .data |
718 | 718 | ||
719 | ; |
719 | ; |
720 | ; window definition |
720 | ; window definition |
721 | ; |
721 | ; |
722 | windowtitle db "C4 0.1",0 |
722 | windowtitle db "C4 0.1",0 |
723 | window: |
723 | window: |
724 | istruc WND |
724 | istruc WND |
725 | at WND.xposandsize, dd MOS_DWORD(0,WND_WIDTH) |
725 | at WND.xposandsize, dd MOS_DWORD(0,WND_WIDTH) |
726 | at WND.yposandsize, dd MOS_DWORD(0,WND_HEIGHT) |
726 | at WND.yposandsize, dd MOS_DWORD(0,WND_HEIGHT) |
727 | at WND.workcolor, dd 0x03000000 | WND_WORKCOLOR |
727 | at WND.workcolor, dd 0x03000000 | WND_WORKCOLOR |
728 | at WND.grabcolor, dd 0 |
728 | at WND.grabcolor, dd 0 |
729 | at WND.framecolor, dd 0 |
729 | at WND.framecolor, dd 0 |
730 | at WND.caption, dd windowtitle |
730 | at WND.caption, dd windowtitle |
731 | at WND.captioncolor, dd 0 |
731 | at WND.captioncolor, dd 0 |
732 | at WND.flags, dd WND_CENTER | WND_DEFAULT_GRABCOLOR | WND_DEFAULT_FRAMECOLOR | WND_DEFAULT_CAPTIONCOLOR |
732 | at WND.flags, dd WND_CENTER | WND_DEFAULT_GRABCOLOR | WND_DEFAULT_FRAMECOLOR | WND_DEFAULT_CAPTIONCOLOR |
733 | iend |
733 | iend |
734 | 734 | ||
735 | ; |
735 | ; |
736 | ; button table |
736 | ; button table |
737 | ; |
737 | ; |
738 | buttons: |
738 | buttons: |
739 | istruc BUTTON ; new |
739 | istruc BUTTON ; new |
740 | at BUTTON.xposandsize |
740 | at BUTTON.xposandsize |
741 | dd MOS_DWORD(BUTTON_NEW_X,BUTTON_NEW_WIDTH) |
741 | dd MOS_DWORD(BUTTON_NEW_X,BUTTON_NEW_WIDTH) |
742 | dd MOS_DWORD(BUTTON_NEW_Y,BUTTON_HEIGHT) |
742 | dd MOS_DWORD(BUTTON_NEW_Y,BUTTON_HEIGHT) |
743 | dd BT_NEW |
743 | dd BT_NEW |
744 | dd BUTTON_COLOR_WORK |
744 | dd BUTTON_COLOR_WORK |
745 | iend |
745 | iend |
746 | istruc BUTTON ; player 1 down |
746 | istruc BUTTON ; player 1 down |
747 | at BUTTON.xposandsize |
747 | at BUTTON.xposandsize |
748 | dd MOS_DWORD(BUTTON_PL1DN_X,BUTTON_SPIN_WIDTH) |
748 | dd MOS_DWORD(BUTTON_PL1DN_X,BUTTON_SPIN_WIDTH) |
749 | dd MOS_DWORD(BUTTON_PL1DN_Y,BUTTON_HEIGHT) |
749 | dd MOS_DWORD(BUTTON_PL1DN_Y,BUTTON_HEIGHT) |
750 | dd BT_PLAYER1DN |
750 | dd BT_PLAYER1DN |
751 | dd BUTTON_COLOR_WORK |
751 | dd BUTTON_COLOR_WORK |
752 | iend |
752 | iend |
753 | istruc BUTTON ; player 1 up |
753 | istruc BUTTON ; player 1 up |
754 | at BUTTON.xposandsize |
754 | at BUTTON.xposandsize |
755 | dd MOS_DWORD(BUTTON_PL1UP_X,BUTTON_SPIN_WIDTH) |
755 | dd MOS_DWORD(BUTTON_PL1UP_X,BUTTON_SPIN_WIDTH) |
756 | dd MOS_DWORD(BUTTON_PL1UP_Y,BUTTON_HEIGHT) |
756 | dd MOS_DWORD(BUTTON_PL1UP_Y,BUTTON_HEIGHT) |
757 | dd BT_PLAYER1UP |
757 | dd BT_PLAYER1UP |
758 | dd BUTTON_COLOR_WORK |
758 | dd BUTTON_COLOR_WORK |
759 | iend |
759 | iend |
760 | istruc BUTTON ; player 2 down |
760 | istruc BUTTON ; player 2 down |
761 | at BUTTON.xposandsize |
761 | at BUTTON.xposandsize |
762 | dd MOS_DWORD(BUTTON_PL2DN_X,BUTTON_SPIN_WIDTH) |
762 | dd MOS_DWORD(BUTTON_PL2DN_X,BUTTON_SPIN_WIDTH) |
763 | dd MOS_DWORD(BUTTON_PL2DN_Y,BUTTON_HEIGHT) |
763 | dd MOS_DWORD(BUTTON_PL2DN_Y,BUTTON_HEIGHT) |
764 | dd BT_PLAYER2DN |
764 | dd BT_PLAYER2DN |
765 | dd BUTTON_COLOR_WORK |
765 | dd BUTTON_COLOR_WORK |
766 | iend |
766 | iend |
767 | istruc BUTTON ; player 2 up |
767 | istruc BUTTON ; player 2 up |
768 | at BUTTON.xposandsize |
768 | at BUTTON.xposandsize |
769 | dd MOS_DWORD(BUTTON_PL2UP_X,BUTTON_SPIN_WIDTH) |
769 | dd MOS_DWORD(BUTTON_PL2UP_X,BUTTON_SPIN_WIDTH) |
770 | dd MOS_DWORD(BUTTON_PL2UP_Y,BUTTON_HEIGHT) |
770 | dd MOS_DWORD(BUTTON_PL2UP_Y,BUTTON_HEIGHT) |
771 | dd BT_PLAYER2UP |
771 | dd BT_PLAYER2UP |
772 | dd BUTTON_COLOR_WORK |
772 | dd BUTTON_COLOR_WORK |
773 | iend |
773 | iend |
774 | NBUTTONS equ (($-buttons)/BUTTON_size) |
774 | NBUTTONS equ (($-buttons)/BUTTON_size) |
775 | 775 | ||
776 | 776 | ||
777 | ; |
777 | ; |
778 | ; label table |
778 | ; label table |
779 | ; |
779 | ; |
780 | %if lang = 'it' |
780 | %ifidn lang, 'it' |
781 | newgame db "Nuova partita",0 |
781 | newgame db "Nuova partita",0 |
782 | %else |
782 | %else |
783 | newgame db "New game",0 |
783 | newgame db "New game",0 |
784 | %endif |
784 | %endif |
785 | down db "<",0 |
785 | down db "<",0 |
786 | up db ">",0 |
786 | up db ">",0 |
787 | %if lang = 'it' |
787 | %ifidn lang, 'it' |
788 | pl1 db "Giocatore 1:",0 |
788 | pl1 db "Giocatore 1:",0 |
789 | pl2 db "Giocatore 2:",0 |
789 | pl2 db "Giocatore 2:",0 |
790 | %else |
790 | %else |
791 | pl1 db "Player 1:",0 |
791 | pl1 db "Player 1:",0 |
792 | pl2 db "Player 2:",0 |
792 | pl2 db "Player 2:",0 |
793 | %endif |
793 | %endif |
794 | 794 | ||
795 | %if lang = 'it' |
795 | %ifidn lang, 'it' |
796 | playertypes: |
796 | playertypes: |
797 | db "Umano",0 |
797 | db "Umano",0 |
798 | PLAYERTYPELEN equ ($ - playertypes) |
798 | PLAYERTYPELEN equ ($ - playertypes) |
799 | db "CPU 1 ",0 |
799 | db "CPU 1 ",0 |
800 | db "CPU 2 ",0 |
800 | db "CPU 2 ",0 |
801 | db "CPU 3 ",0 |
801 | db "CPU 3 ",0 |
802 | db "CPU 4 ",0 |
802 | db "CPU 4 ",0 |
803 | db "CPU 5 ",0 |
803 | db "CPU 5 ",0 |
804 | db "CPU 6 ",0 |
804 | db "CPU 6 ",0 |
805 | db "CPU 7 ",0 |
805 | db "CPU 7 ",0 |
806 | db "CPU 8 ",0 |
806 | db "CPU 8 ",0 |
807 | %else |
807 | %else |
808 | playertypes: |
808 | playertypes: |
809 | db "Human ",0 |
809 | db "Human ",0 |
810 | PLAYERTYPELEN equ ($ - playertypes) |
810 | PLAYERTYPELEN equ ($ - playertypes) |
811 | db "CPU level 1 ",0 |
811 | db "CPU level 1 ",0 |
812 | db "CPU level 2 ",0 |
812 | db "CPU level 2 ",0 |
813 | db "CPU level 3 ",0 |
813 | db "CPU level 3 ",0 |
814 | db "CPU level 4 ",0 |
814 | db "CPU level 4 ",0 |
815 | db "CPU level 5 ",0 |
815 | db "CPU level 5 ",0 |
816 | db "CPU level 6 ",0 |
816 | db "CPU level 6 ",0 |
817 | db "CPU level 7 ",0 |
817 | db "CPU level 7 ",0 |
818 | db "CPU level 8 ",0 |
818 | db "CPU level 8 ",0 |
819 | %endif |
819 | %endif |
820 | 820 | ||
821 | NPLAYERTYPES equ (($-playertypes)/PLAYERTYPELEN) |
821 | NPLAYERTYPES equ (($-playertypes)/PLAYERTYPELEN) |
822 | 822 | ||
823 | 823 | ||
824 | labels: |
824 | labels: |
825 | istruc LABEL ; new |
825 | istruc LABEL ; new |
826 | at LABEL.position |
826 | at LABEL.position |
827 | dd MOS_DWORD(BUTTON_NEW_X+4,1+BUTTON_NEW_Y+(BUTTON_HEIGHT-8)/2) |
827 | dd MOS_DWORD(BUTTON_NEW_X+4,1+BUTTON_NEW_Y+(BUTTON_HEIGHT-8)/2) |
828 | dd newgame |
828 | dd newgame |
829 | dd LABEL_COLOR_WORKBUTTON |
829 | dd LABEL_COLOR_WORKBUTTON |
830 | dd LABEL_BGCOLOR_TRANSPARENT |
830 | dd LABEL_BGCOLOR_TRANSPARENT |
831 | iend |
831 | iend |
832 | istruc LABEL ; player 1 down |
832 | istruc LABEL ; player 1 down |
833 | at LABEL.position |
833 | at LABEL.position |
834 | dd MOS_DWORD(BUTTON_PL1DN_X+(BUTTON_SPIN_WIDTH-4)/2,1+BUTTON_PL1DN_Y+(BUTTON_HEIGHT-8)/2) |
834 | dd MOS_DWORD(BUTTON_PL1DN_X+(BUTTON_SPIN_WIDTH-4)/2,1+BUTTON_PL1DN_Y+(BUTTON_HEIGHT-8)/2) |
835 | dd down |
835 | dd down |
836 | dd LABEL_COLOR_WORKBUTTON |
836 | dd LABEL_COLOR_WORKBUTTON |
837 | dd LABEL_BGCOLOR_TRANSPARENT |
837 | dd LABEL_BGCOLOR_TRANSPARENT |
838 | iend |
838 | iend |
839 | istruc LABEL ; player 1 up |
839 | istruc LABEL ; player 1 up |
840 | at LABEL.position |
840 | at LABEL.position |
841 | dd MOS_DWORD(1+BUTTON_PL1UP_X+(BUTTON_SPIN_WIDTH-4)/2,1+BUTTON_PL1UP_Y+(BUTTON_HEIGHT-8)/2) |
841 | dd MOS_DWORD(1+BUTTON_PL1UP_X+(BUTTON_SPIN_WIDTH-4)/2,1+BUTTON_PL1UP_Y+(BUTTON_HEIGHT-8)/2) |
842 | dd up |
842 | dd up |
843 | dd LABEL_COLOR_WORKBUTTON |
843 | dd LABEL_COLOR_WORKBUTTON |
844 | dd LABEL_BGCOLOR_TRANSPARENT |
844 | dd LABEL_BGCOLOR_TRANSPARENT |
845 | iend |
845 | iend |
846 | istruc LABEL ; player 2 down |
846 | istruc LABEL ; player 2 down |
847 | at LABEL.position |
847 | at LABEL.position |
848 | dd MOS_DWORD(BUTTON_PL2DN_X+(BUTTON_SPIN_WIDTH-4)/2,1+BUTTON_PL2DN_Y+(BUTTON_HEIGHT-8)/2) |
848 | dd MOS_DWORD(BUTTON_PL2DN_X+(BUTTON_SPIN_WIDTH-4)/2,1+BUTTON_PL2DN_Y+(BUTTON_HEIGHT-8)/2) |
849 | dd down |
849 | dd down |
850 | dd LABEL_COLOR_WORKBUTTON |
850 | dd LABEL_COLOR_WORKBUTTON |
851 | dd LABEL_BGCOLOR_TRANSPARENT |
851 | dd LABEL_BGCOLOR_TRANSPARENT |
852 | iend |
852 | iend |
853 | istruc LABEL ; player 2 up |
853 | istruc LABEL ; player 2 up |
854 | at LABEL.position |
854 | at LABEL.position |
855 | dd MOS_DWORD(1+BUTTON_PL2UP_X+(BUTTON_SPIN_WIDTH-4)/2,1+BUTTON_PL2UP_Y+(BUTTON_HEIGHT-8)/2) |
855 | dd MOS_DWORD(1+BUTTON_PL2UP_X+(BUTTON_SPIN_WIDTH-4)/2,1+BUTTON_PL2UP_Y+(BUTTON_HEIGHT-8)/2) |
856 | dd up |
856 | dd up |
857 | dd LABEL_COLOR_WORKBUTTON |
857 | dd LABEL_COLOR_WORKBUTTON |
858 | dd LABEL_BGCOLOR_TRANSPARENT |
858 | dd LABEL_BGCOLOR_TRANSPARENT |
859 | iend |
859 | iend |
860 | istruc LABEL ; player 1 |
860 | istruc LABEL ; player 1 |
861 | at LABEL.position |
861 | at LABEL.position |
862 | dd MOS_DWORD(LABEL_PL1_X,LABEL_PL1_Y) |
862 | dd MOS_DWORD(LABEL_PL1_X,LABEL_PL1_Y) |
863 | dd pl1 |
863 | dd pl1 |
864 | dd MOS_RGB(255,255,255) |
864 | dd MOS_RGB(255,255,255) |
865 | dd LABEL_BGCOLOR_TRANSPARENT |
865 | dd LABEL_BGCOLOR_TRANSPARENT |
866 | iend |
866 | iend |
867 | istruc LABEL ; player 2 |
867 | istruc LABEL ; player 2 |
868 | at LABEL.position |
868 | at LABEL.position |
869 | dd MOS_DWORD(LABEL_PL2_X,LABEL_PL2_Y) |
869 | dd MOS_DWORD(LABEL_PL2_X,LABEL_PL2_Y) |
870 | dd pl2 |
870 | dd pl2 |
871 | dd MOS_RGB(255,255,255) |
871 | dd MOS_RGB(255,255,255) |
872 | dd LABEL_BGCOLOR_TRANSPARENT |
872 | dd LABEL_BGCOLOR_TRANSPARENT |
873 | iend |
873 | iend |
874 | statusbar: ; status bar |
874 | statusbar: ; status bar |
875 | istruc LABEL |
875 | istruc LABEL |
876 | at LABEL.position |
876 | at LABEL.position |
877 | dd MOS_DWORD(LABEL_STATUS_X,LABEL_STATUS_Y) |
877 | dd MOS_DWORD(LABEL_STATUS_X,LABEL_STATUS_Y) |
878 | dd 0 |
878 | dd 0 |
879 | dd MOS_RGB(255,255,255) |
879 | dd MOS_RGB(255,255,255) |
880 | dd LABEL_BGCOLOR_TRANSPARENT |
880 | dd LABEL_BGCOLOR_TRANSPARENT |
881 | iend |
881 | iend |
882 | label_pl1type: |
882 | label_pl1type: |
883 | istruc LABEL |
883 | istruc LABEL |
884 | at LABEL.position |
884 | at LABEL.position |
885 | %if lang = 'it' |
885 | %ifidn lang, 'it' |
886 | dd MOS_DWORD(LABEL_PL1TYPE_X + 18,LABEL_PL1TYPE_Y) |
886 | dd MOS_DWORD(LABEL_PL1TYPE_X + 18,LABEL_PL1TYPE_Y) |
887 | %else |
887 | %else |
888 | dd MOS_DWORD(LABEL_PL1TYPE_X,LABEL_PL1TYPE_Y) |
888 | dd MOS_DWORD(LABEL_PL1TYPE_X,LABEL_PL1TYPE_Y) |
889 | %endif |
889 | %endif |
890 | dd playertypes+PL1TYPE_INIT*PLAYERTYPELEN |
890 | dd playertypes+PL1TYPE_INIT*PLAYERTYPELEN |
891 | dd MOS_RGB(255,255,255) |
891 | dd MOS_RGB(255,255,255) |
892 | dd MOS_RGB(0,0,0) |
892 | dd MOS_RGB(0,0,0) |
893 | iend |
893 | iend |
894 | label_pl2type: |
894 | label_pl2type: |
895 | istruc LABEL |
895 | istruc LABEL |
896 | at LABEL.position |
896 | at LABEL.position |
897 | %if lang = 'it' |
897 | %ifidn lang, 'it' |
898 | dd MOS_DWORD(LABEL_PL2TYPE_X + 18,LABEL_PL2TYPE_Y) |
898 | dd MOS_DWORD(LABEL_PL2TYPE_X + 18,LABEL_PL2TYPE_Y) |
899 | %else |
899 | %else |
900 | dd MOS_DWORD(LABEL_PL2TYPE_X,LABEL_PL2TYPE_Y) |
900 | dd MOS_DWORD(LABEL_PL2TYPE_X,LABEL_PL2TYPE_Y) |
901 | %endif |
901 | %endif |
902 | dd playertypes+PL2TYPE_INIT*PLAYERTYPELEN |
902 | dd playertypes+PL2TYPE_INIT*PLAYERTYPELEN |
903 | dd MOS_RGB(255,255,255) |
903 | dd MOS_RGB(255,255,255) |
904 | dd MOS_RGB(0,0,0) |
904 | dd MOS_RGB(0,0,0) |
905 | iend |
905 | iend |
906 | NLABELS equ (($-labels)/LABEL_size) |
906 | NLABELS equ (($-labels)/LABEL_size) |
907 | 907 | ||
908 | 908 | ||
909 | ; player types |
909 | ; player types |
910 | player1_type dd PL1TYPE_INIT |
910 | player1_type dd PL1TYPE_INIT |
911 | player2_type dd PL2TYPE_INIT |
911 | player2_type dd PL2TYPE_INIT |
912 | 912 | ||
913 | 913 | ||
914 | ; status messages |
914 | ; status messages |
915 | %if lang = 'it' |
915 | %ifidn lang, 'it' |
916 | player1hmnprmpt db "Turno del giocatore 1",0 |
916 | player1hmnprmpt db "Turno del giocatore 1",0 |
917 | player2hmnprmpt db "Turno del giocatore 2",0 |
917 | player2hmnprmpt db "Turno del giocatore 2",0 |
918 | player1cpuprmpt db "Attendi, giocatore 1 sta pensando...",0 |
918 | player1cpuprmpt db "Attendi, giocatore 1 sta pensando...",0 |
919 | player2cpuprmpt db "Attendi, giocatore 2 sta pensando...",0 |
919 | player2cpuprmpt db "Attendi, giocatore 2 sta pensando...",0 |
920 | itisadraw db "Pareggio",0 |
920 | itisadraw db "Pareggio",0 |
921 | player1wins db "Vince giocatore 1",0 |
921 | player1wins db "Vince giocatore 1",0 |
922 | player2wins db "Vince Giocatore 2",0 |
922 | player2wins db "Vince Giocatore 2",0 |
923 | %else |
923 | %else |
924 | player1hmnprmpt db "Make your move, player 1.",0 |
924 | player1hmnprmpt db "Make your move, player 1.",0 |
925 | player2hmnprmpt db "Make your move, player 2.",0 |
925 | player2hmnprmpt db "Make your move, player 2.",0 |
926 | player1cpuprmpt db "Player 1 is thinking, please wait...",0 |
926 | player1cpuprmpt db "Player 1 is thinking, please wait...",0 |
927 | player2cpuprmpt db "Player 2 is thinking, please wait...",0 |
927 | player2cpuprmpt db "Player 2 is thinking, please wait...",0 |
928 | itisadraw db "It's a draw.",0 |
928 | itisadraw db "It's a draw.",0 |
929 | player1wins db "Player 1 wins.",0 |
929 | player1wins db "Player 1 wins.",0 |
930 | player2wins db "Player 2 wins.",0 |
930 | player2wins db "Player 2 wins.",0 |
931 | %endif |
931 | %endif |
932 | 932 | ||
933 | 933 | ||
934 | ; pointer to ai player. future releases C4 might |
934 | ; pointer to ai player. future releases C4 might |
935 | ; or might not support different ai players =) |
935 | ; or might not support different ai players =) |
936 | aicode dd aiGetMove |
936 | aicode dd aiGetMove |
937 | 937 | ||
938 | 938 | ||
939 | ; button images |
939 | ; button images |
940 | redpcx: incbin "red.pcx" |
940 | redpcx: incbin "red.pcx" |
941 | REDPCXSIZE equ ($ - redpcx) |
941 | REDPCXSIZE equ ($ - redpcx) |
942 | bluepcx: incbin "blue.pcx" |
942 | bluepcx: incbin "blue.pcx" |
943 | BLUEPCXSIZE equ ($ - bluepcx) |
943 | BLUEPCXSIZE equ ($ - bluepcx) |
944 | 944 | ||
945 | 945 | ||
946 | 946 | ||
947 | ;********************************************************** |
947 | ;********************************************************** |
948 | ; uninitialized data |
948 | ; uninitialized data |
949 | ;********************************************************** |
949 | ;********************************************************** |
950 | 950 | ||
951 | section .bss |
951 | section .bss |
952 | 952 | ||
953 | ; player input |
953 | ; player input |
954 | ; 0 : no input available |
954 | ; 0 : no input available |
955 | ; 1..7 : column to drop stone into |
955 | ; 1..7 : column to drop stone into |
956 | playerinput resd 1 |
956 | playerinput resd 1 |
957 | 957 | ||
958 | mouseinput resd 1 |
958 | mouseinput resd 1 |
959 | gameover resd 1 |
959 | gameover resd 1 |
960 | 960 | ||
961 | redstone resb STONESIZE*STONESIZE*3 |
961 | redstone resb STONESIZE*STONESIZE*3 |
962 | bluestone resb STONESIZE*STONESIZE*3 |
962 | bluestone resb STONESIZE*STONESIZE*3 |
963 | 963 | ||
964 | end:",0 |
964 | end:",0 |
965 | up> |
965 | up> |