Merge lp:~matboutigny/hangman8086/two_players_mode into lp:hangman8086

Proposed by Fabien LOISON
Status: Merged
Approved by: Fabien LOISON
Approved revision: 13
Merged at revision: 10
Proposed branch: lp:~matboutigny/hangman8086/two_players_mode
Merge into: lp:hangman8086
Diff against target: 283 lines (+249/-1)
3 files modified
main.asm (+1/-0)
mainmenu.asm (+8/-1)
twopl.asm (+240/-0)
To merge this branch: bzr merge lp:~matboutigny/hangman8086/two_players_mode
Reviewer Review Type Date Requested Status
Hangman 8086 Developers Pending
Review via email: mp+65096@code.launchpad.net
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 'main.asm'
2--- main.asm 2011-06-18 11:36:33 +0000
3+++ main.asm 2011-06-18 15:52:31 +0000
4@@ -66,6 +66,7 @@
5 include "stscreen.asm" ;Contains the function that print the startup screen.
6 include "game.asm" ;Contains the game functions.
7 include "singlepl.asm" ;Contains the single player mode.
8+include "twopl.asm" ;Contains the two player mode.
9 include "options.asm" ;Contains the options menu.
10 include "modesel.asm" ;Contains the mode selection menu.
11
12
13=== modified file 'mainmenu.asm'
14--- mainmenu.asm 2011-05-29 12:22:53 +0000
15+++ mainmenu.asm 2011-06-18 15:52:31 +0000
16@@ -133,6 +133,13 @@
17 jmp _main_menu
18 main_menu_sp_end:
19
20+ ;Two players
21+ cmp main_menu_selected, MAIN_MENU_TWO_PLAYERS
22+ jne main_menu_tp_end
23+ call _two_players
24+ jmp _main_menu
25+ main_menu_tp_end:
26+
27 ;Options
28 cmp main_menu_selected, MAIN_MENU_OPTIONS
29 jne main_menu_option_end
30@@ -225,7 +232,7 @@
31 main_menu_items_numb equ 5
32
33 MAIN_MENU_SINGLE_PLAYER equ 0
34-MAIN_MENU_TWO_PLAYER equ 1
35+MAIN_MENU_TWO_PLAYERS equ 1
36 MAIN_MENU_OPTIONS equ 2
37 MAIN_MENU_SCORES equ 3
38 MAIN_MENU_QUIT equ 4
39
40=== added file 'twopl.asm'
41--- twopl.asm 1970-01-01 00:00:00 +0000
42+++ twopl.asm 2011-06-18 15:52:31 +0000
43@@ -0,0 +1,240 @@
44+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
45+;; __ __ _______ __ _ _______ __ __ _______ __ _ ;;
46+;; | | | || _ || | | || || |_| || _ || | | | ;;
47+;; | |_| || |_| || |_| || ___|| || |_| || |_| | ;;
48+;; | || || || | __ | || || | ;;
49+;; | || || _ || || || || || _ | ;;
50+;; | _ || _ || | | || |_| || ||_|| || _ || | | | ;;
51+;; |__| |__||__| |__||_| |__||_______||_| |_||__| |__||_| |__| ;;
52+;; ;;
53+;; ;;
54+;; HANGMAN - An implementation of the Hang Man game in assembly (Emu8086) ;;
55+;; ;;
56+;; Copyright (C) 2011 Fabien LOISON ;;
57+;; Copyright (C) 2011 Mathilde BOUTIGNY ;;
58+;; Copyright (C) 2011 Vincent PEYROUSE ;;
59+;; Copyright (C) 2011 Germain CARRÉ ;;
60+;; Copyright (C) 2011 Matthis FRENAY ;;
61+;; ;;
62+;; HangMan is free software: you can redistribute it and/or modify ;;
63+;; it under the terms of the GNU General Public License as published by ;;
64+;; the Free Software Foundation, either version 3 of the License, or ;;
65+;; (at your option) any later version. ;;
66+;; ;;
67+;; This program is distributed in the hope that it will be useful, ;;
68+;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;
69+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;
70+;; GNU General Public License for more details. ;;
71+;; ;;
72+;; You should have received a copy of the GNU General Public License ;;
73+;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;
74+;; ;;
75+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
76+
77+
78+;;
79+;; Contains the two players mode.
80+;;
81+;; Index:
82+;; _two_players() -- Play in two players mode.
83+;;
84+
85+
86+
87+;======================================================= _two_players() ====
88+;; Play in two players mode.
89+
90+;; Usage:
91+;; call _two_players
92+
93+
94+_two_players:
95+
96+;Backup registers
97+
98+push ax
99+push bx
100+push cx
101+push dx
102+
103+;Ask the first player's name
104+
105+mov IF_MSG, offset tp_msg_fplname
106+mov IF_MAXLEN, 8
107+mov IF_EWD, 0
108+call _input_field
109+mov MEMCPY_SRC, offset IF_WORD
110+mov MEMCPY_DEST, offset tp_fplname
111+mov MEMCPY_LEN, 8
112+call _memcpy
113+nop
114+
115+;Ask the second player's name
116+
117+mov IF_MSG, offset tp_msg_splname
118+mov IF_MAXLEN, 8
119+mov IF_EWD, 0
120+call _input_field
121+mov MEMCPY_SRC, offset IF_WORD
122+mov MEMCPY_DEST, offset tp_splname
123+mov MEMCPY_LEN, 8
124+call _memcpy
125+nop
126+
127+
128+
129+;Game loop.
130+
131+mov cx, 3
132+tp_game_loop:
133+
134+;Ask the first player's secret word.
135+
136+mov MEMCPY_SRC, offset tp_fplname
137+mov MEMCPY_DEST, offset tp_msg_fplword
138+mov MEMCPY_LEN, 8
139+call _memcpy
140+mov IF_MSG, offset tp_msg_fplword
141+mov IF_MAXLEN, 26
142+mov IF_EWD, 1
143+call _input_field
144+mov MEMCPY_SRC, offset IF_WORD
145+mov MEMCPY_DEST, offset tp_fplword
146+mov MEMCPY_LEN, 26
147+call _memcpy
148+nop
149+
150+;Let's play with the second player !
151+
152+mov WORD, offset tp_fplword
153+call _play
154+
155+;Count the second player's lives.
156+
157+mov ax, 0
158+mov al, play_lives
159+add play_sp_lives, al
160+
161+;Abort game.
162+
163+cmp GAME_STATUS, GAME_STATUS_ABORT
164+je tp_end
165+
166+;Ask the second player's secret word.
167+
168+mov MEMCPY_SRC, offset tp_splname
169+mov MEMCPY_DEST, offset tp_msg_splword
170+mov MEMCPY_LEN, 8
171+call _memcpy
172+mov IF_MSG, offset tp_msg_splword
173+mov IF_MAXLEN, 26
174+mov IF_EWD, 1
175+call _input_field
176+mov MEMCPY_SRC, offset IF_WORD
177+mov MEMCPY_DEST, offset tp_splword
178+mov MEMCPY_LEN, 26
179+call _memcpy
180+nop
181+
182+;Let's play with the first player !
183+
184+mov WORD, offset tp_splword
185+call _play
186+
187+;Count the first player's lives.
188+
189+mov ax, 0
190+mov al, play_lives
191+add play_fp_lives, al
192+
193+;Abort game.
194+
195+cmp GAME_STATUS, GAME_STATUS_ABORT
196+je tp_end
197+
198+;Game loop.
199+
200+dec cx
201+cmp cx, 0
202+jne tp_game_loop
203+
204+;Put the number of lives of the second player in bx.
205+
206+mov ax, 0
207+mov al, play_sp_lives
208+
209+;Jump to fp_win if the first player win.
210+
211+call _draw_ui
212+
213+cmp play_fp_lives, al
214+jg fp_win
215+
216+;Display message if second player win.
217+
218+mov POS_X, (COLS-24)/2
219+mov POS_Y, header_height + 4
220+call _move_cursor
221+mov MEMCPY_SRC, offset tp_splname
222+mov MEMCPY_DEST, offset tp_msg_win
223+mov MEMCPY_LEN, 8
224+call _memcpy
225+mov ah, 0x09
226+mov dx, offset tp_msg_win
227+int 0x21
228+
229+;wait
230+mov ah, 0x86
231+mov cx, 124
232+int 0x15
233+
234+jmp tp_end
235+
236+;Display message if first player win.
237+
238+fp_win:
239+mov POS_X, (COLS-24)/2
240+mov POS_Y, header_height + 4
241+call _move_cursor
242+mov MEMCPY_SRC, offset tp_fplname
243+mov MEMCPY_DEST, offset tp_msg_win
244+mov MEMCPY_LEN, 8
245+call _memcpy
246+mov ah, 0x09
247+mov dx, offset tp_msg_win
248+int 0x21
249+
250+;wait
251+mov ah, 0x86
252+mov cx, 124
253+int 0x15
254+
255+tp_end:
256+
257+;Restore registers
258+
259+pop dx
260+pop cx
261+pop bx
262+pop ax
263+
264+
265+ret
266+
267+
268+;Datas
269+
270+tp_msg_fplname db "Please enter the first player's name:$"
271+tp_fplname db "--------"
272+tp_msg_splname db "Please enter the second player's name:$"
273+tp_splname db "--------"
274+
275+tp_msg_fplword db "******** enter your secret word:$"
276+tp_fplword db "-------------------------"
277+tp_msg_splword db "******** enter your secret word:$"
278+tp_splword db "-------------------------"
279+
280+tp_msg_win db "******** is the winner !$"
281+
282+play_fp_lives db 0
283+play_sp_lives db 0

Subscribers

People subscribed via source and target branches