~hangman8086-devs/hangman8086/trunk

3.1.3 by Fabien LOISON
* Startup screen implemented
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
;;
3.1.5 by Fabien LOISON
* ASCII Art exported in a separate file (asciiart.res)
36
;; Contains the function for playing sounds.
3.1.3 by Fabien LOISON
* Startup screen implemented
37
;;
38
;; Index:
7.2.4 by Fabien LOISON
* Some small fixes
39
;;     _play_sound(SOUND) -- Plays a sound.
3.1.3 by Fabien LOISON
* Startup screen implemented
40
;;
41
42
43
7.2.4 by Fabien LOISON
* Some small fixes
44
;===================================================== _play_sound(SOUND) ====
5.1.12 by Fabien LOISON
* Some code/comment improvement...
45
;; Plays a sound.
3.1.3 by Fabien LOISON
* Startup screen implemented
46
47
;; Usage:
48
;; mov SOUND, offset <mysound>
49
;; call _play_sound
50
51
;; Function arg:
52
SOUND dw 0 ;The adress of the sound to play.
53
54
55
_play_sound:
56
57
;Backup registers
58
push ax
59
push bx
60
push cx
61
push dx
62
63
;Turn speaker on
64
mov  dx, 0x61
65
in   al, dx
66
or   al, 0x03
67
out  dx, al
68
69
;Sound loop
70
mov bx, SOUND
71
mov dx, 0
72
73
sound_loop:
74
    ;Play sound
75
    mov ax, [bx]
76
    or  ax, 3
77
    out 0x42, al ;output low
78
    xchg ah, al
79
    out 0x42, al ;output high
80
81
    ;Point to the next field (duration)
82
    inc bx
83
    inc bx
84
85
    ;Sleep during the given duration
86
    push ax
87
    mov cx, [bx]
88
    mov ah, 0x86
89
    int 0x15
90
    pop ax
91
92
    ;Point to the next field (sound)
93
    inc bx
94
    inc bx
95
96
    ;Check if it is finished or not
97
    cmp [bx], 0
98
    jne sound_loop
99
100
;Turn speaker off
101
mov  dx, 0x61
102
in   al, dx
103
and  al, 0xfc
104
out  dx, al
105
106
;Restore registers
107
pop dx
108
pop cx
109
pop bx
110
pop ax
111
112
ret
113
114