~hangman8086-devs/hangman8086/trunk

5.1.4 by Fabien LOISON
* Bug fix in _main_menu()
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;      __   __  _______  __    _  _______  __   __  _______  __    _       ;;
3
;;     |  | |  ||   _   ||  |  | ||       ||  |_|  ||   _   ||  |  | |      ;;
4
;;     |  |_|  ||  |_|  ||   |_| ||    ___||       ||  |_|  ||   |_| |      ;;
5
;;     |       ||       ||       ||   | __ |       ||       ||       |      ;;
6
;;     |       ||       ||  _    ||   ||  ||       ||       ||  _    |      ;;
7
;;     |   _   ||   _   || | |   ||   |_| || ||_|| ||   _   || | |   |      ;;
8
;;     |__| |__||__| |__||_|  |__||_______||_|   |_||__| |__||_|  |__|      ;;
9
;;                                                                          ;;
10
;;                                                                          ;;
11
;;  HANGMAN - An implementation of the Hang Man game in assembly (Emu8086)  ;;
12
;;                                                                          ;;
13
;;  Copyright (C) 2011  Fabien LOISON                                       ;;
14
;;  Copyright (C) 2011  Mathilde BOUTIGNY                                   ;;
15
;;  Copyright (C) 2011  Vincent PEYROUSE                                    ;;
16
;;  Copyright (C) 2011  Germain CARRÉ                                       ;;
17
;;  Copyright (C) 2011  Matthis FRENAY                                      ;;
18
;;                                                                          ;;
19
;;  HangMan is free software: you can redistribute it and/or modify         ;;
20
;;  it under the terms of the GNU General Public License as published by    ;;
21
;;  the Free Software Foundation, either version 3 of the License, or       ;;
22
;;  (at your option) any later version.                                     ;;
23
;;                                                                          ;;
24
;;  This program is distributed in the hope that it will be useful,         ;;
25
;;  but WITHOUT ANY WARRANTY; without even the implied warranty of          ;;
26
;;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           ;;
27
;;  GNU General Public License for more details.                            ;;
28
;;                                                                          ;;
29
;;  You should have received a copy of the GNU General Public License       ;;
30
;;  along with this program.  If not, see <http://www.gnu.org/licenses/>.   ;;
31
;;                                                                          ;;
32
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
33
34
35
;;
36
;; Contains the single player mode.
37
;;
38
;; Index:
10.1.3 by Fabien LOISON
* _new_sp_score() implemented
39
;;     _single_player()    -- Play in single player mode.
40
;;     _sp_gameover()      -- Prints the game over screen
5.1.4 by Fabien LOISON
* Bug fix in _main_menu()
41
;;
42
43
44
45
;======================================================= _single_player() ====
46
;; Play in single player mode.
47
48
;; Usage:
49
;; call _single_player
50
51
52
_single_player:
53
54
;Backup registers
55
push ax
56
push bx
57
push cx
58
push dx
59
7.2.2 by Fabien LOISON
* Mode selection menu implemented
60
;Get the mode
61
call _mode_menu
62
7.2.3 by Fabien LOISON
* Get the player name for practice mode
63
;Back to the main menu if necessary
7.2.2 by Fabien LOISON
* Mode selection menu implemented
64
cmp MODE, -1
65
je  sp_end
66
7.2.7 by Fabien LOISON
* score implemented in sp mode
67
;Ask the players name if the competition mode is selected
7.2.3 by Fabien LOISON
* Get the player name for practice mode
68
cmp MODE, MODE_COMPETITION
69
jne sp_plname_end
70
mov IF_MSG, offset sp_msg_plname
71
mov IF_MAXLEN, 8
72
mov IF_EWD, 0
73
call _input_field
74
mov MEMCPY_SRC, offset IF_WORD
7.2.7 by Fabien LOISON
* score implemented in sp mode
75
mov MEMCPY_DEST, offset PLAYER
7.2.3 by Fabien LOISON
* Get the player name for practice mode
76
mov MEMCPY_LEN, 8
77
call _memcpy
7.2.7 by Fabien LOISON
* score implemented in sp mode
78
;Set the score to 0
79
mov SCORE, 0
7.2.3 by Fabien LOISON
* Get the player name for practice mode
80
sp_plname_end:
81
nop
82
5.1.11 by Fabien LOISON
* Help added in the animation screen
83
sp_start:
5.1.8 by Fabien LOISON
* The word is now choosen "randomly" in a word list
84
;Get a random word from the dict
85
    ;"Random" number
5.1.12 by Fabien LOISON
* Some code/comment improvement...
86
    mov ah, 0x2C ; Get system time
5.1.8 by Fabien LOISON
* The word is now choosen "randomly" in a word list
87
    int 0x21     ;
88
    mov ah, 0
5.1.12 by Fabien LOISON
* Some code/comment improvement...
89
    mov al, dh   ; Seconds
90
    mov bl, cl   ; Minutes
5.1.8 by Fabien LOISON
* The word is now choosen "randomly" in a word list
91
    mul bl
92
    mov ah, 0
93
    mov bl, WORD_LIST_LEN
94
    idiv bl
95
96
    ;RAND * WORD_LEN
97
    mov al, ah
98
    mov ah, 0
99
    mov bl, WORD_LEN
100
    mul bl
101
102
    ;Adress of the word
6.1.4 by Fabien LOISON
* French dict added
103
    cmp OPTION_DICT, OPTION_DICT_FR
104
    je  sp_dict_fr
105
    mov bx, offset WORD_LIST_EN
106
    jmp sp_dict_end
107
    sp_dict_fr:
108
    mov bx, offset WORD_LIST_FR
109
    sp_dict_end:
5.1.8 by Fabien LOISON
* The word is now choosen "randomly" in a word list
110
    add bx, ax
111
112
mov WORD, bx
5.1.4 by Fabien LOISON
* Bug fix in _main_menu()
113
call _play
114
5.1.11 by Fabien LOISON
* Help added in the animation screen
115
;Check the game status
7.2.7 by Fabien LOISON
* score implemented in sp mode
116
cmp GAME_STATUS, GAME_STATUS_ABORT ;Abort ?
5.1.11 by Fabien LOISON
* Help added in the animation screen
117
je  sp_end
7.2.7 by Fabien LOISON
* score implemented in sp mode
118
119
cmp GAME_STATUS, GAME_STATUS_WIN ; Win && competition ?
120
jnz sp_win_end
121
cmp MODE, MODE_COMPETITION
122
jnz sp_start
123
124
mov ah, 0
125
mov al, play_lives
126
cmp OPTION_GIBBET, OPTION_GIBBET_OFF
127
jnz sp_gibbet_end
128
add ax, 6 ;bonus
129
sp_gibbet_end:
130
add SCORE, ax
131
132
sp_win_end:
133
134
cmp GAME_STATUS, GAME_STATUS_LOOSE ; Loose && competition ?
135
jnz sp_start
136
cmp MODE, MODE_COMPETITION
137
jnz sp_start
5.1.11 by Fabien LOISON
* Help added in the animation screen
138
10.1.4 by Fabien LOISON
* Score insertion implemented for sp mode
139
mov NSPS_NAME, offset PLAYER
140
mov ax, SCORE
141
mov NSPS_SCORE, ax
142
call _new_sp_score
143
7.2.8 by Fabien LOISON
* Game Over screen implemented in sp mode
144
call _sp_gameover
145
5.1.11 by Fabien LOISON
* Help added in the animation screen
146
sp_end:
147
5.1.4 by Fabien LOISON
* Bug fix in _main_menu()
148
;Restore registers
149
pop dx
150
pop cx
151
pop bx
152
pop ax
153
154
ret
155
156
7.2.3 by Fabien LOISON
* Get the player name for practice mode
157
;Datas
158
sp_msg_plname db "Please enter your name:$"
159
160
7.2.8 by Fabien LOISON
* Game Over screen implemented in sp mode
161
162
;========================================================= _sp_gameover() ====
163
;; Prints the game over screen
164
165
;; Usage:
166
;; call _sp_gameover
167
168
169
_sp_gameover:
170
171
call _draw_ui
172
173
mov POS_X, (COLS-gameover_len)/2
174
mov POS_Y, header_height + 3
175
176
mov ah, 0x09
177
mov dx, offset gameover
178
179
sp_gameover_loop:
180
    call _move_cursor
181
    int 0x21
182
    inc POS_Y
183
    add dx, gameover_len
184
    cmp POS_Y, gameover_height + header_height + 3
185
    jne sp_gameover_loop
186
187
add POS_Y, 2
188
mov POS_X, (COLS-sp_go_score_len)/2
189
call _move_cursor
190
191
mov ax, SCORE
192
mov I2S_INT, ax
193
call _inttostr
194
195
mov MEMCPY_SRC, offset I2S_STR
196
mov MEMCPY_DEST, offset sp_go_score
197
add MEMCPY_DEST, 15
198
mov MEMCPY_LEN, 4
199
call _memcpy
200
201
mov ah, 0x09
202
mov dx, offset sp_go_score
203
int 0x21
204
205
;wait
206
mov ah, 0x86
207
mov cx, 64
208
int 0x15
209
210
ret
211
212
213
;datas
214
sp_go_score      db "Your score is: 1234$"
215
sp_go_score_len equ 20
216
217