Merge lp:~hangman8086-devs/hangman8086/competition-mode into lp:hangman8086
- competition-mode
- Merge into trunk
Proposed by
Fabien LOISON
Status: | Merged |
---|---|
Approved by: | Fabien LOISON |
Approved revision: | 15 |
Merged at revision: | 9 |
Proposed branch: | lp:~hangman8086-devs/hangman8086/competition-mode |
Merge into: | lp:hangman8086 |
Diff against target: |
855 lines (+674/-9) (has conflicts) 10 files modified
Makefile (+1/-0) asciiart.res (+13/-0) game.asm (+73/-1) main.asm (+3/-0) mainfunc.asm (+238/-2) modesel.asm (+235/-0) playsnd.asm (+2/-2) singlepl.asm (+107/-2) sounds.res (+1/-1) words.res (+1/-1) Text conflict in mainfunc.asm |
To merge this branch: | bzr merge lp:~hangman8086-devs/hangman8086/competition-mode |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Hangman 8086 Developers | Pending | ||
Review via email: mp+65092@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Makefile' |
2 | --- Makefile 2011-05-26 14:19:39 +0000 |
3 | +++ Makefile 2011-06-18 14:28:29 +0000 |
4 | @@ -20,6 +20,7 @@ |
5 | cd buildenv/ && ./makeenv.sh |
6 | |
7 | debug: |
8 | + mkdir -p ./buildenv/MyBuild/ |
9 | rm -f ./buildenv/MyBuild/* |
10 | cp *.asm *.res ./buildenv/MyBuild/ |
11 | mv ./buildenv/MyBuild/main.asm ./buildenv/MyBuild/00main.asm |
12 | |
13 | === modified file 'asciiart.res' |
14 | --- asciiart.res 2011-05-26 14:19:39 +0000 |
15 | +++ asciiart.res 2011-06-18 14:28:29 +0000 |
16 | @@ -52,6 +52,19 @@ |
17 | |
18 | |
19 | |
20 | +;============================================================ Header Logo ==== |
21 | +gameover db " _____ ____ $" |
22 | + db " / ____| / __ \ $" |
23 | + db " | | __ __ _ _ __ ___ ___ | | | |__ _____ _ __ $" |
24 | + db " | | |_ |/ _` | '_ ` _ \ / _ \ | | | |\ \ / / _ \ '__|$" |
25 | + db " | |__| | (_| | | | | | | __/ | |__| | \ V / __/ | $" |
26 | + db " \_____|\__,_|_| |_| |_|\___| \____/ \_/ \___|_| $" |
27 | + |
28 | +gameover_len equ 56 |
29 | +gameover_height equ 6 |
30 | + |
31 | + |
32 | + |
33 | ;========================================================= Startup Screen ==== |
34 | startup_scr db " ____ _____ ____ _____ _____ _ __ __ $" |
35 | db " | __ )| ____/ ___|_ _| ____| / \ | \/ | $" |
36 | |
37 | === modified file 'game.asm' |
38 | --- game.asm 2011-05-29 15:04:29 +0000 |
39 | +++ game.asm 2011-06-18 14:28:29 +0000 |
40 | @@ -52,6 +52,8 @@ |
41 | GAME_STATUS_WIN equ 1 |
42 | GAME_STATUS_ABORT equ 2 |
43 | |
44 | +SCORE dw 0 |
45 | +PLAYER dw "UNNAMED " |
46 | |
47 | |
48 | ;============================================================ _play(WORD) ==== |
49 | @@ -59,6 +61,7 @@ |
50 | |
51 | ;; Usage: |
52 | ;; mov WORD, offset <word> |
53 | +;; mov PLAYER, offset <playername> |
54 | ;; call _play |
55 | |
56 | ;; Function args: |
57 | @@ -87,9 +90,9 @@ |
58 | play_main_loop: |
59 | call _clear_working |
60 | call _print_gword |
61 | - |
62 | call _print_tried_letters |
63 | call _print_gibbet |
64 | + call _print_score |
65 | |
66 | ;Check if the play win |
67 | ;For checking we search underscores in play_gword... It is not very |
68 | @@ -474,6 +477,75 @@ |
69 | |
70 | |
71 | |
72 | +;========================================================= _print_score() ==== |
73 | +;; Print the score in competition mode). |
74 | + |
75 | +;; Usage: |
76 | +;; call _print_tried_letters |
77 | + |
78 | + |
79 | +_print_score: |
80 | + |
81 | +;Backup registers |
82 | +push ax |
83 | +push bx |
84 | +push cx |
85 | +push dx |
86 | + |
87 | +;Check if we are in competition mode |
88 | +cmp MODE, MODE_COMPETITION |
89 | +jnz prn_score_end |
90 | + |
91 | +;Set the scorebar |
92 | +mov ah, 0x07 |
93 | +mov al, 0 ; Clear |
94 | +mov bh, COLOR_SCORE |
95 | +mov ch, header_height + 1 ;y1 |
96 | +mov cl, 0 ;x1 |
97 | +mov dh, header_height + 1 ;y2 |
98 | +mov dl, COLS ;x2 |
99 | +int 0x10 |
100 | + |
101 | +;Paste the player name |
102 | +mov MEMCPY_SRC, offset PLAYER |
103 | +mov MEMCPY_DEST, offset prn_score_str |
104 | +add MEMCPY_DEST, 2 |
105 | +mov MEMCPY_LEN, 8 |
106 | +call _memcpy |
107 | + |
108 | +;Convert the score into string and paste it |
109 | +mov ax, SCORE |
110 | +mov I2S_INT, ax |
111 | +call _inttostr |
112 | +mov MEMCPY_SRC, offset I2S_STR |
113 | +add MEMCPY_DEST, 11 |
114 | +mov MEMCPY_LEN, 4 |
115 | +call _memcpy |
116 | + |
117 | +;Print the string |
118 | +mov POS_X, 0 |
119 | +mov POS_Y, header_height + 1 |
120 | +call _move_cursor |
121 | +mov ah, 0x09 |
122 | +mov dx, offset prn_score_str |
123 | +int 0x21 |
124 | + |
125 | +prn_score_end: |
126 | + |
127 | +;Restore registers |
128 | +pop dx |
129 | +pop cx |
130 | +pop bx |
131 | +pop ax |
132 | + |
133 | +ret |
134 | + |
135 | + |
136 | +;Data |
137 | +prn_score_str db " ",0xC0,"12345678",0xD9," ",0xC0,"1234",0xD9,"$" |
138 | + |
139 | + |
140 | + |
141 | ;========================================================== _game_anima() ==== |
142 | ;; Displays an animation when the player loose or win. |
143 | |
144 | |
145 | === modified file 'main.asm' |
146 | --- main.asm 2011-05-29 12:22:53 +0000 |
147 | +++ main.asm 2011-06-18 14:28:29 +0000 |
148 | @@ -53,6 +53,8 @@ |
149 | COLOR_HEADER equ 00101111b ;Color of the Header an help area |
150 | COLOR_ACTIVE equ 00001111b ;Color of the Menu/Game/Animation area |
151 | COLOR_CURSOR equ 00000010b ;Color of the menu cursor |
152 | +COLOR_FIELD equ 00101111b ;Color of the input fields |
153 | +COLOR_SCORE equ 00000010b ;Color of the score bar |
154 | |
155 | |
156 | |
157 | @@ -65,6 +67,7 @@ |
158 | include "game.asm" ;Contains the game functions. |
159 | include "singlepl.asm" ;Contains the single player mode. |
160 | include "options.asm" ;Contains the options menu. |
161 | +include "modesel.asm" ;Contains the mode selection menu. |
162 | |
163 | ;RESOURCE |
164 | include "asciiart.res" ;Contains the ASCII art of the game. |
165 | |
166 | === modified file 'mainfunc.asm' |
167 | --- mainfunc.asm 2011-06-14 15:39:14 +0000 |
168 | +++ mainfunc.asm 2011-06-18 14:28:29 +0000 |
169 | @@ -37,7 +37,7 @@ |
170 | ;; |
171 | ;; Index: |
172 | ;; _draw_ui() -- Draws the user interface on the screen. |
173 | -;; _clear_working -- Clears the working part of the screen. |
174 | +;; _clear_working() -- Clears the working part of the screen. |
175 | ;; _print_header() -- Prints the HANGMAN logo on the screen. |
176 | ;; _print_help(HELP_STR) -- Prints the help message on the bottom of |
177 | ;; the screen. |
178 | @@ -51,6 +51,10 @@ |
179 | ;; MEMCPY_LEN) |
180 | ;; _strlen(STRLEN_STR) -- Counts the number of bytes that composes |
181 | ;; a string. |
182 | +;; _inttostr(I2S_INT) -- Convert integers into strings. |
183 | +;; _input_field(IF_MSG, -- Display an input field. |
184 | +;; IF_MAXLEN, |
185 | +;; IF_EWD) |
186 | ;; |
187 | |
188 | |
189 | @@ -283,7 +287,7 @@ |
190 | ;; call _input_letter |
191 | |
192 | ;; Returns: |
193 | -LETTER db 0 ;An upper case letter |
194 | +LETTER db 0 ;An upper case letter (or KB_ESC, KB_BKSP, KB_ENTER). |
195 | |
196 | |
197 | _input_letter: |
198 | @@ -473,6 +477,7 @@ |
199 | ret |
200 | |
201 | |
202 | +<<<<<<< TREE |
203 | ;Args: |
204 | I2S_INT db 0 ;The number to convert |
205 | |
206 | @@ -497,3 +502,234 @@ |
207 | |
208 | ret |
209 | |
210 | +======= |
211 | + |
212 | +;===================================================== _inttostr(I2S_INT) ==== |
213 | +;; Convert integers into strings. |
214 | + |
215 | +;; Usage: |
216 | +;; mov I2S_INT, <int> |
217 | +;; call _inttostr |
218 | + |
219 | +;; Args: |
220 | +I2S_INT dw 0 ;The integer to convert |
221 | + |
222 | +;; Return: |
223 | +I2S_STR dw "0000" ;The result string |
224 | + |
225 | + |
226 | +_inttostr: |
227 | + |
228 | +;Backup registers |
229 | +push ax |
230 | +push bx |
231 | +push cx |
232 | +push dx |
233 | + |
234 | +;"Split" the number |
235 | +mov ax, I2S_INT |
236 | +mov bx, 10 |
237 | +mov cx, 4 |
238 | +i2s_split_loop: |
239 | +mov dx, 0 |
240 | +div bx |
241 | +push dx |
242 | +dec cx |
243 | +cmp cx, 0 |
244 | +jnz i2s_split_loop |
245 | + |
246 | +;Convert in string |
247 | +mov bx, offset I2S_STR |
248 | +mov cx, 4 |
249 | +i2s_str_loop: |
250 | +pop ax |
251 | +add ax, '0' |
252 | +mov [bx], al |
253 | +inc bx |
254 | +dec cx |
255 | +cmp cx, 0 |
256 | +jnz i2s_str_loop |
257 | + |
258 | +;Restore registers |
259 | +pop dx |
260 | +pop cx |
261 | +pop bx |
262 | +pop ax |
263 | + |
264 | +ret |
265 | + |
266 | + |
267 | + |
268 | +;================================ _input_field(IF_MSG, IF_MAXLEN, IF_EWD) ==== |
269 | +;; Display an input field. |
270 | + |
271 | +;; Usage: |
272 | +;; mov IF_MSG, offset <src> |
273 | +;; mov IF_MAXLEN, <len> |
274 | +;; mov IF_EWD, <0/1> |
275 | +;; call _input_field |
276 | + |
277 | +;; Function args: |
278 | +IF_MSG dw 0 ; The message address (must end with '$') |
279 | +IF_MAXLEN db 0 ; The maximum len of the input (max = 30) |
280 | +IF_EWD db 0 ; End with $ ? (0 = False, 1 = True) |
281 | + |
282 | +;; Returns: |
283 | +IF_WORD db "-------------------------------" ; The input word |
284 | + |
285 | + |
286 | +_input_field: |
287 | + |
288 | +;Backup registers |
289 | +push ax |
290 | +push bx |
291 | +push cx |
292 | +push dx |
293 | + |
294 | +;Clear the screen (draw the UI) |
295 | +call _draw_ui |
296 | +mov HELP_STR, offset if_help |
297 | +call _print_help |
298 | + |
299 | +;Fill IF_WORD with spaces or $ |
300 | +mov cl, 31 |
301 | +mov bx, offset IF_WORD |
302 | +if_fill_word_loop: |
303 | + cmp IF_EWD, 1 ; ' ' or '$' ? |
304 | + je if_fill_word_dollard |
305 | + mov [bx], ' ' |
306 | + jmp if_fill_word_dollard_end |
307 | + if_fill_word_dollard: |
308 | + mov [bx], '$' |
309 | + if_fill_word_dollard_end: |
310 | + inc bx |
311 | + dec cl |
312 | + cmp cl, 0 |
313 | + jne if_fill_word_loop |
314 | + |
315 | +;Display the message |
316 | + ;Center the message |
317 | + mov ax, IF_MSG |
318 | + mov STRLEN_STR, ax |
319 | + call _strlen |
320 | + mov ah, 0 |
321 | + mov al, STRLEN_LEN |
322 | + mov bl, 2 |
323 | + div bl |
324 | + mov ah, COLS / 2 |
325 | + sub ah, al |
326 | + mov POS_X, ah |
327 | + mov POS_Y, header_height |
328 | + add POS_Y, 5 |
329 | + call _move_cursor |
330 | + ;Print the message |
331 | + mov ah, 0x09 |
332 | + mov dx, IF_MSG |
333 | + int 0x21 |
334 | + |
335 | +;Display the field |
336 | + ;Center the field |
337 | + mov ah, 0 |
338 | + mov al, IF_MAXLEN |
339 | + mov bl, 2 |
340 | + div bl |
341 | + mov ah, COLS / 2 |
342 | + sub ah, al |
343 | + mov POS_X, ah |
344 | + add POS_Y, 2 |
345 | + call _move_cursor |
346 | + ;print the field |
347 | + mov ah, 0x07 |
348 | + mov al, 0 ; Clear |
349 | + mov bh, COLOR_FIELD ; Color |
350 | + mov ch, POS_Y ; x1 |
351 | + mov cl, POS_X ; x1 |
352 | + mov dh, POS_Y ; y2 |
353 | + mov dl, POS_X ; x2 |
354 | + add dl, IF_MAXLEN ; ~~ |
355 | + inc dl ; ~~ |
356 | + int 0x10 |
357 | + |
358 | +mov if_wlen, 0 |
359 | + |
360 | +;Intput field main loop |
361 | +if_loop: |
362 | + call _input_letter |
363 | + cmp LETTER, KB_ENTER ; Validate |
364 | + je if_loop_end |
365 | + cmp LETTER, KB_ESC ; skip esc |
366 | + je if_loop |
367 | + cmp LETTER, KB_BKSP ; Remove last letter |
368 | + je if_loop_bksp |
369 | + |
370 | + ;Add the letter if the buffer is not full |
371 | + mov ah, IF_MAXLEN |
372 | + cmp if_wlen, ah |
373 | + je if_loop |
374 | + |
375 | + ;buff |
376 | + mov bx, offset IF_WORD |
377 | + mov ah, 0 |
378 | + mov al, if_wlen |
379 | + add bx, ax |
380 | + mov al, LETTER |
381 | + mov [bx], al |
382 | + inc if_wlen |
383 | + |
384 | + ;disp |
385 | + inc POS_X |
386 | + call _move_cursor |
387 | + mov ah, 0x06 |
388 | + mov dl, LETTER |
389 | + int 0x21 |
390 | + |
391 | + jmp if_loop |
392 | + |
393 | + if_loop_bksp: |
394 | + cmp if_wlen, 0 ;empty |
395 | + je if_loop |
396 | + |
397 | + ;buff |
398 | + mov bx, offset IF_WORD |
399 | + mov ah, 0 |
400 | + mov al, if_wlen |
401 | + add bx, ax |
402 | + dec bx |
403 | + cmp IF_EWD, 1 |
404 | + je if_loop_ewd |
405 | + mov [bx], ' ' |
406 | + jmp if_loop_ewdend |
407 | + if_loop_ewd: |
408 | + mov [bx], '$' |
409 | + if_loop_ewdend: |
410 | + dec if_wlen |
411 | + |
412 | + ;disp |
413 | + call _move_cursor |
414 | + mov ah, 0x06 |
415 | + mov dl, ' ' |
416 | + int 0x21 |
417 | + dec POS_X |
418 | + |
419 | + jmp if_loop |
420 | + |
421 | + if_loop_end: |
422 | + |
423 | +;Restore registers |
424 | +pop dx |
425 | +pop cx |
426 | +pop bx |
427 | +pop ax |
428 | + |
429 | +ret |
430 | + |
431 | + |
432 | +;Var |
433 | +if_wlen db 0 |
434 | + |
435 | +;Help |
436 | +if_help db 0xDA,"A-Z",0xBF," Try a letter ",0xDA,"Enter",0xBF," Validate" |
437 | + db " $" |
438 | + |
439 | + |
440 | +>>>>>>> MERGE-SOURCE |
441 | |
442 | === added file 'modesel.asm' |
443 | --- modesel.asm 1970-01-01 00:00:00 +0000 |
444 | +++ modesel.asm 2011-06-18 14:28:29 +0000 |
445 | @@ -0,0 +1,235 @@ |
446 | +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
447 | +;; __ __ _______ __ _ _______ __ __ _______ __ _ ;; |
448 | +;; | | | || _ || | | || || |_| || _ || | | | ;; |
449 | +;; | |_| || |_| || |_| || ___|| || |_| || |_| | ;; |
450 | +;; | || || || | __ | || || | ;; |
451 | +;; | || || _ || || || || || _ | ;; |
452 | +;; | _ || _ || | | || |_| || ||_|| || _ || | | | ;; |
453 | +;; |__| |__||__| |__||_| |__||_______||_| |_||__| |__||_| |__| ;; |
454 | +;; ;; |
455 | +;; ;; |
456 | +;; HANGMAN - An implementation of the Hang Man game in assembly (Emu8086) ;; |
457 | +;; ;; |
458 | +;; Copyright (C) 2011 Fabien LOISON ;; |
459 | +;; Copyright (C) 2011 Mathilde BOUTIGNY ;; |
460 | +;; Copyright (C) 2011 Vincent PEYROUSE ;; |
461 | +;; Copyright (C) 2011 Germain CARRÉ ;; |
462 | +;; Copyright (C) 2011 Matthis FRENAY ;; |
463 | +;; ;; |
464 | +;; HangMan is free software: you can redistribute it and/or modify ;; |
465 | +;; it under the terms of the GNU General Public License as published by ;; |
466 | +;; the Free Software Foundation, either version 3 of the License, or ;; |
467 | +;; (at your mode) any later version. ;; |
468 | +;; ;; |
469 | +;; This program is distributed in the hope that it will be useful, ;; |
470 | +;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; |
471 | +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; |
472 | +;; GNU General Public License for more details. ;; |
473 | +;; ;; |
474 | +;; You should have received a copy of the GNU General Public License ;; |
475 | +;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;; |
476 | +;; ;; |
477 | +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
478 | + |
479 | + |
480 | +;; |
481 | +;; Contains the mode selection menu. |
482 | +;; |
483 | +;; Index: |
484 | +;; _mode_menu() -- Displays the mode selection menu. |
485 | +;; _draw_mode_menu() -- (Re)draws the mode selection menu on the screen. |
486 | +;; |
487 | + |
488 | + |
489 | + |
490 | +MODE db 0 |
491 | +MODE_PRACTICE equ 0 |
492 | +MODE_COMPETITION equ 1 |
493 | + |
494 | + |
495 | + |
496 | +;=========================================================== _mode_menu() ==== |
497 | +;; Displays the mode selection menu. |
498 | + |
499 | +;; Using: |
500 | +;; call _mode_menu |
501 | + |
502 | + |
503 | +_mode_menu: |
504 | + |
505 | +;Flush the input buffer |
506 | +mov ah, 0x0C |
507 | +mov al, 0 |
508 | +int 0x21 |
509 | + |
510 | +;Set the variables to theire default |
511 | +mov MODE, MODE_PRACTICE |
512 | +mov mode_menu_selected, MODE_MENU_PRACTICE |
513 | + |
514 | +;Draw the UI |
515 | +call _draw_ui |
516 | + |
517 | +;Print the help message |
518 | +mov HELP_STR, offset mode_menu_help |
519 | +call _print_help |
520 | +jmp mode_menu_refresh |
521 | + |
522 | +mode_menu_snd: |
523 | + mov SOUND, offset SND_MENU_CH_ITEM |
524 | + call _draw_mode_menu |
525 | + call _play_sound |
526 | + jmp mode_menu_loop |
527 | + |
528 | +mode_menu_refresh: |
529 | + call _draw_mode_menu |
530 | + |
531 | +mode_menu_loop: |
532 | + ;Wait for input |
533 | + mov ah, 0x00 |
534 | + int 0x16 |
535 | + |
536 | + cmp al, ' ' ;Space |
537 | + jz mode_menu_validate |
538 | + cmp al, 0x0D ;Enter |
539 | + jz mode_menu_validate |
540 | + cmp ah, 0x50 ;Down arrow |
541 | + jz mode_menu_movedown |
542 | + cmp ah, 0x48 ;Up arrow |
543 | + jz mode_menu_moveup |
544 | + cmp ax, 0x011B ;Escape |
545 | + jz mode_menu_backtomain |
546 | + |
547 | + ;Not a valid input |
548 | + jmp mode_menu_loop |
549 | + |
550 | + ;Move down |
551 | + mode_menu_movedown: |
552 | + inc mode_menu_selected |
553 | + |
554 | + cmp mode_menu_selected, mode_menu_items_numb |
555 | + jnz mode_menu_snd |
556 | + |
557 | + mov mode_menu_selected, 0 |
558 | + jmp mode_menu_snd |
559 | + |
560 | + ;Move up |
561 | + mode_menu_moveup: |
562 | + dec mode_menu_selected |
563 | + |
564 | + cmp mode_menu_selected, -1 |
565 | + jnz mode_menu_snd |
566 | + |
567 | + mov mode_menu_selected, mode_menu_items_numb |
568 | + dec mode_menu_selected |
569 | + jmp mode_menu_snd |
570 | + |
571 | + ;Validate |
572 | + mode_menu_validate: |
573 | + mov SOUND, offset SND_MENU_VALID |
574 | + call _play_sound |
575 | + |
576 | + ;Practice |
577 | + cmp mode_menu_selected, MODE_MENU_PRACTICE |
578 | + jnz mode_menu_practice_end |
579 | + mov MODE, MODE_PRACTICE |
580 | + jmp mode_menu_end |
581 | + mode_menu_practice_end: |
582 | + |
583 | + ;Competition |
584 | + cmp mode_menu_selected, MODE_MENU_COMPETITION |
585 | + jnz mode_menu_competition_end |
586 | + mov MODE, MODE_COMPETITION |
587 | + jmp mode_menu_end |
588 | + mode_menu_competition_end: |
589 | + |
590 | + ;Back |
591 | + cmp mode_menu_selected, MODE_MENU_BACK |
592 | + jnz mode_menu_back_end |
593 | + jmp mode_menu_backtomain |
594 | + mode_menu_back_end: |
595 | + |
596 | + jmp mode_menu_refresh |
597 | + |
598 | +mode_menu_backtomain: |
599 | +mov MODE, -1 |
600 | + |
601 | +mode_menu_end: |
602 | + |
603 | +ret |
604 | + |
605 | + |
606 | + |
607 | +;====================================================== _draw_mode_menu() ==== |
608 | +;; (Re)draws the mdoe selection menu on the screen. |
609 | + |
610 | +;; Using: |
611 | +;; call _draw_mode_menu |
612 | + |
613 | + |
614 | +_draw_mode_menu: |
615 | + |
616 | +;Center the menu |
617 | +mov pos_x, (COLS-mode_menu_items_len)/2 |
618 | +mov pos_y, header_height |
619 | +add pos_y, 4 |
620 | + |
621 | +;Prepare the print |
622 | +mov ah, 0x09 |
623 | +mov dx, offset mode_menu_items |
624 | + |
625 | +mov cx, mode_menu_items_numb |
626 | + |
627 | +;Draw items |
628 | +draw_mode_menu_loop: |
629 | + call _move_cursor |
630 | + int 0x21 |
631 | + add pos_y, 2 |
632 | + add dx, mode_menu_items_len |
633 | + dec cx |
634 | + cmp cx, 0 |
635 | + jne draw_mode_menu_loop |
636 | + |
637 | + |
638 | +;Display the cursor on the selected item |
639 | +mov pos_y, header_height |
640 | +add pos_y, 4 |
641 | +mov ah, 0x00 |
642 | +mov al, mode_menu_selected |
643 | +mov bl, 2 |
644 | +mul bl |
645 | +add pos_y, al |
646 | + |
647 | +call _move_cursor |
648 | + |
649 | +mov ah, 0x09 |
650 | +mov al, 0x10 |
651 | +mov bh, 0 |
652 | +mov bl, COLOR_CURSOR ; color |
653 | +mov cx, 1 |
654 | +int 0x10 |
655 | + |
656 | +ret |
657 | + |
658 | + |
659 | + |
660 | +;============================ Vars for _mode_menu() and _draw_mode_menu() ==== |
661 | +mode_menu_selected db 0 ;The selected item of the menu |
662 | + |
663 | + |
664 | + |
665 | +;=========================== Datas for _mode_menu() and _draw_mode_menu() ==== |
666 | +mode_menu_help db 0xDA,0x18,0x19,0xBF," Navigate ",0xDA,"Enter",0xBF |
667 | + db " Validate ",0xDA |
668 | + db "Esc",0xBF, " Quit$" |
669 | + |
670 | +mode_menu_items db " Practice $" |
671 | + db " Competition $" |
672 | + db " Back $" |
673 | +mode_menu_items_len equ 16 |
674 | +mode_menu_items_numb equ 3 |
675 | + |
676 | +MODE_MENU_PRACTICE equ 0 |
677 | +MODE_MENU_COMPETITION equ 1 |
678 | +MODE_MENU_BACK equ 2 |
679 | + |
680 | + |
681 | |
682 | === modified file 'playsnd.asm' |
683 | --- playsnd.asm 2011-05-26 14:19:39 +0000 |
684 | +++ playsnd.asm 2011-06-18 14:28:29 +0000 |
685 | @@ -36,12 +36,12 @@ |
686 | ;; Contains the function for playing sounds. |
687 | ;; |
688 | ;; Index: |
689 | -;; _play_sound() -- Plays a sound. |
690 | +;; _play_sound(SOUND) -- Plays a sound. |
691 | ;; |
692 | |
693 | |
694 | |
695 | -;========================================================== _play_sound() ==== |
696 | +;===================================================== _play_sound(SOUND) ==== |
697 | ;; Plays a sound. |
698 | |
699 | ;; Usage: |
700 | |
701 | === modified file 'singlepl.asm' |
702 | --- singlepl.asm 2011-05-31 13:03:40 +0000 |
703 | +++ singlepl.asm 2011-06-18 14:28:29 +0000 |
704 | @@ -56,6 +56,29 @@ |
705 | push cx |
706 | push dx |
707 | |
708 | +;Get the mode |
709 | +call _mode_menu |
710 | + |
711 | +;Back to the main menu if necessary |
712 | +cmp MODE, -1 |
713 | +je sp_end |
714 | + |
715 | +;Ask the players name if the competition mode is selected |
716 | +cmp MODE, MODE_COMPETITION |
717 | +jne sp_plname_end |
718 | +mov IF_MSG, offset sp_msg_plname |
719 | +mov IF_MAXLEN, 8 |
720 | +mov IF_EWD, 0 |
721 | +call _input_field |
722 | +mov MEMCPY_SRC, offset IF_WORD |
723 | +mov MEMCPY_DEST, offset PLAYER |
724 | +mov MEMCPY_LEN, 8 |
725 | +call _memcpy |
726 | +;Set the score to 0 |
727 | +mov SCORE, 0 |
728 | +sp_plname_end: |
729 | +nop |
730 | + |
731 | sp_start: |
732 | ;Get a random word from the dict |
733 | ;"Random" number |
734 | @@ -89,9 +112,30 @@ |
735 | call _play |
736 | |
737 | ;Check the game status |
738 | -cmp GAME_STATUS, GAME_STATUS_ABORT |
739 | +cmp GAME_STATUS, GAME_STATUS_ABORT ;Abort ? |
740 | je sp_end |
741 | -jmp sp_start |
742 | + |
743 | +cmp GAME_STATUS, GAME_STATUS_WIN ; Win && competition ? |
744 | +jnz sp_win_end |
745 | +cmp MODE, MODE_COMPETITION |
746 | +jnz sp_start |
747 | + |
748 | +mov ah, 0 |
749 | +mov al, play_lives |
750 | +cmp OPTION_GIBBET, OPTION_GIBBET_OFF |
751 | +jnz sp_gibbet_end |
752 | +add ax, 6 ;bonus |
753 | +sp_gibbet_end: |
754 | +add SCORE, ax |
755 | + |
756 | +sp_win_end: |
757 | + |
758 | +cmp GAME_STATUS, GAME_STATUS_LOOSE ; Loose && competition ? |
759 | +jnz sp_start |
760 | +cmp MODE, MODE_COMPETITION |
761 | +jnz sp_start |
762 | + |
763 | +call _sp_gameover |
764 | |
765 | sp_end: |
766 | |
767 | @@ -104,3 +148,64 @@ |
768 | ret |
769 | |
770 | |
771 | +;Datas |
772 | +sp_msg_plname db "Please enter your name:$" |
773 | + |
774 | + |
775 | + |
776 | +;========================================================= _sp_gameover() ==== |
777 | +;; Prints the game over screen |
778 | + |
779 | +;; Usage: |
780 | +;; call _sp_gameover |
781 | + |
782 | + |
783 | +_sp_gameover: |
784 | + |
785 | +call _draw_ui |
786 | + |
787 | +mov POS_X, (COLS-gameover_len)/2 |
788 | +mov POS_Y, header_height + 3 |
789 | + |
790 | +mov ah, 0x09 |
791 | +mov dx, offset gameover |
792 | + |
793 | +sp_gameover_loop: |
794 | + call _move_cursor |
795 | + int 0x21 |
796 | + inc POS_Y |
797 | + add dx, gameover_len |
798 | + cmp POS_Y, gameover_height + header_height + 3 |
799 | + jne sp_gameover_loop |
800 | + |
801 | +add POS_Y, 2 |
802 | +mov POS_X, (COLS-sp_go_score_len)/2 |
803 | +call _move_cursor |
804 | + |
805 | +mov ax, SCORE |
806 | +mov I2S_INT, ax |
807 | +call _inttostr |
808 | + |
809 | +mov MEMCPY_SRC, offset I2S_STR |
810 | +mov MEMCPY_DEST, offset sp_go_score |
811 | +add MEMCPY_DEST, 15 |
812 | +mov MEMCPY_LEN, 4 |
813 | +call _memcpy |
814 | + |
815 | +mov ah, 0x09 |
816 | +mov dx, offset sp_go_score |
817 | +int 0x21 |
818 | + |
819 | +;wait |
820 | +mov ah, 0x86 |
821 | +mov cx, 64 |
822 | +int 0x15 |
823 | + |
824 | +ret |
825 | + |
826 | + |
827 | +;datas |
828 | +sp_go_score db "Your score is: 1234$" |
829 | +sp_go_score_len equ 20 |
830 | + |
831 | + |
832 | |
833 | === modified file 'sounds.res' |
834 | --- sounds.res 2011-06-14 15:39:14 +0000 |
835 | +++ sounds.res 2011-06-18 14:28:29 +0000 |
836 | @@ -33,7 +33,7 @@ |
837 | |
838 | |
839 | ;; |
840 | -;; Contains the sounds. |
841 | +;; Contains the sounds ressources. |
842 | ;; |
843 | |
844 | |
845 | |
846 | === modified file 'words.res' |
847 | --- words.res 2011-06-07 15:36:09 +0000 |
848 | +++ words.res 2011-06-18 14:28:29 +0000 |
849 | @@ -33,7 +33,7 @@ |
850 | |
851 | |
852 | ;; |
853 | -;; Contains the word list for the single player mode. |
854 | +;; Contains the word lists for the single player mode. |
855 | ;; |
856 | |
857 |