1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; __ __ _______ __ _ _______ __ __ _______ __ _ ;;
;; | | | || _ || | | || || |_| || _ || | | | ;;
;; | |_| || |_| || |_| || ___|| || |_| || |_| | ;;
;; | || || || | __ | || || | ;;
;; | || || _ || || || || || _ | ;;
;; | _ || _ || | | || |_| || ||_|| || _ || | | | ;;
;; |__| |__||__| |__||_| |__||_______||_| |_||__| |__||_| |__| ;;
;; ;;
;; ;;
;; HANGMAN - An implementation of the Hang Man game in assembly (Emu8086) ;;
;; ;;
;; Copyright (C) 2011 Fabien LOISON ;;
;; Copyright (C) 2011 Mathilde BOUTIGNY ;;
;; Copyright (C) 2011 Vincent PEYROUSE ;;
;; Copyright (C) 2011 Germain CARRÉ ;;
;; Copyright (C) 2011 Matthis FRENAY ;;
;; ;;
;; HangMan is free software: you can redistribute it and/or modify ;;
;; it under the terms of the GNU General Public License as published by ;;
;; the Free Software Foundation, either version 3 of the License, or ;;
;; (at your option) any later version. ;;
;; ;;
;; This program is distributed in the hope that it will be useful, ;;
;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;
;; GNU General Public License for more details. ;;
;; ;;
;; You should have received a copy of the GNU General Public License ;;
;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Contains the options menu.
;;
;; Index:
;; _option_menu() -- Displays the option menu.
;; _draw_option_menu() -- (Re)draws the option menu on the screen.
;;
OPTION_GIBBET db 1
OPTION_GIBBET_ON equ 1
OPTION_GIBBET_OFF equ 0
OPTION_DICT db 0
OPTION_DICT_EN equ 0
OPTION_DICT_FR equ 1
;========================================================= _option_menu() ====
;; Displays the option menu.
;; Using:
;; call _option_menu
_option_menu:
;Flush the input buffer
mov ah, 0x0C
mov al, 0
int 0x21
;Draw the UI
call _draw_ui
;Print the help message
mov HELP_STR, offset option_menu_help
call _print_help
jmp option_menu_refresh
option_menu_snd:
mov SOUND, offset SND_MENU_CH_ITEM
call _draw_option_menu
call _play_sound
jmp option_menu_loop
option_menu_refresh:
call _draw_option_menu
option_menu_loop:
;Wait for input
mov ah, 0x00
int 0x16
cmp al, ' ' ;Space
jz option_menu_validate
cmp al, 0x0D ;Enter
jz option_menu_validate
cmp ah, 0x4B ;Left arrow
jz option_menu_validate
cmp ah, 0x4D ;Right arrow
jz option_menu_validate
cmp ah, 0x50 ;Down arrow
jz option_menu_movedown
cmp ah, 0x48 ;Up arrow
jz option_menu_moveup
cmp ax, 0x011B ;Escape
jz option_menu_end
;Not a valid input
jmp option_menu_loop
;Move down
option_menu_movedown:
inc option_menu_selected
cmp option_menu_selected, option_menu_items_numb
jnz option_menu_snd
mov option_menu_selected, 0
jmp option_menu_snd
;Move up
option_menu_moveup:
dec option_menu_selected
cmp option_menu_selected, -1
jnz option_menu_snd
mov option_menu_selected, option_menu_items_numb
dec option_menu_selected
jmp option_menu_snd
;Validate
option_menu_validate:
mov SOUND, offset SND_MENU_VALID
call _play_sound
;Gibbet
cmp option_menu_selected, OPTION_MENU_GIBBET
jnz option_menu_gibbet_end
not OPTION_GIBBET
and OPTION_GIBBET, 00000001b
option_menu_gibbet_end:
;Dictionary
cmp option_menu_selected, OPTION_MENU_DICT
jnz option_menu_dict_end
not OPTION_DICT
and OPTION_DICT, 00000001b
option_menu_dict_end:
;Dictionary
cmp option_menu_selected, OPTION_MENU_BACK
jnz option_menu_back_end
jmp option_menu_end
option_menu_back_end:
jmp option_menu_refresh
option_menu_end:
ret
;==================================================== _draw_option_menu() ====
;; (Re)draws the option menu on the screen.
;; Using:
;; call _draw_option_menu
_draw_option_menu:
call _clear_working
;Calclulate the position of the first item
mov POS_X, COLS / 2 - 15
mov POS_Y, header_height
add POS_Y, 4
call _move_cursor
mov ah, 0x09
;Print the GIBBET item
cmp OPTION_GIBBET, OPTION_GIBBET_ON
je droption_gibbet_on
;GIBBET = OFF
mov dx, offset option_item_gibbet_off
jmp droption_gibbet_end
droption_gibbet_on: ;GIBBET = ON
mov dx, offset option_item_gibbet_on
droption_gibbet_end:
int 0x21 ;Print
add POS_Y, 2
call _move_cursor
;Print the DICTIONARY item
cmp OPTION_DICT, OPTION_DICT_FR
je droption_dict_fr
;DICT = EN
mov dx, offset option_item_dict_en
jmp droption_dict_end
droption_dict_fr: ;DICT = FR
mov dx, offset option_item_dict_fr
droption_dict_end:
int 0x21 ;Print
add POS_Y, 2
call _move_cursor
;Print the BACK item
mov dx, offset option_item_backmain
int 0x21 ;Print
;=> Print the arrow (selected item)
;Calclulate the position of the selected item
mov POS_X, COLS / 2 - 15 - 2
mov POS_Y, header_height
add POS_Y, 4
mov ah, 0x00
mov al, option_menu_selected
mov bl, 2
mul bl
add pos_y, al
call _move_cursor
mov ah, 0x09
mov al, 0x10
mov bh, 0
mov bl, COLOR_CURSOR ; color
mov cx, 1
int 0x10
ret
;======================== Vars for _option_menu() and _draw_option_menu() ====
option_menu_selected db 0 ;The selected item of the menu
;======================= Datas for _option_menu() and _draw_option_menu() ====
option_menu_help db 0xDA,0x18,0x19,0xBF," Navigate ",0xDA,"Enter",0xBF
db " Validate / Toggle options ",0xDA
db "Esc",0xBF, " Quit$"
option_item_gibbet_on db "Gibbet [ With ] Without $"
option_item_gibbet_off db "Gibbet With [ Without ]$"
OPTION_MENU_GIBBET equ 0
option_item_dict_en db "Dictionary [ English ] French $"
option_item_dict_fr db "Dictionary English [ French ]$"
OPTION_MENU_DICT equ 1
option_item_backmain db "Back$"
OPTION_MENU_BACK equ 2
option_menu_items_numb equ 3
|