pro_spk:воспроизведение_мелодий_через_встроенный_динамик_компьютера_pc-speaker_в_gnu_linux
Различия
Показаны различия между двумя версиями страницы.
Предыдущая версия справа и слеваПредыдущая версияСледующая версия | Предыдущая версияПоследняя версияСледующая версия справа и слева | ||
pro_spk:воспроизведение_мелодий_через_встроенный_динамик_компьютера_pc-speaker_в_gnu_linux [2019/01/21 20:56] – dwadmin | pro_spk:воспроизведение_мелодий_через_встроенный_динамик_компьютера_pc-speaker_в_gnu_linux [2019/02/13 19:21] – dwadmin | ||
---|---|---|---|
Строка 1: | Строка 1: | ||
====== Воспроизведение мелодий через встроенный динамик компьютера (PC-Speaker) в GNU/Linux ====== | ====== Воспроизведение мелодий через встроенный динамик компьютера (PC-Speaker) в GNU/Linux ====== | ||
- | [[http:// | + | Демонстрационная программа: |
<code pascal> | <code pascal> | ||
Строка 9: | Строка 9: | ||
Program for playing melodys on PC-Speaker. | Program for playing melodys on PC-Speaker. | ||
For GNU/Linux 64 bit version. Root priveleges needed. | For GNU/Linux 64 bit version. Root priveleges needed. | ||
+ | Version: 2. | ||
Written on FreePascal. | Written on FreePascal. | ||
Copyright (C) 2019 Artyomov Alexander | Copyright (C) 2019 Artyomov Alexander | ||
Строка 28: | Строка 29: | ||
{$MODE OBJFPC} | {$MODE OBJFPC} | ||
{$ASMMODE INTEL} | {$ASMMODE INTEL} | ||
+ | {$CODEPAGE UTF8} | ||
uses SysUtils, | uses SysUtils, | ||
- | procedure spkon; | + | procedure spkon; |
- | begin | + | asm |
- | asm | + | |
push rax | push rax | ||
in al, 61h | in al, 61h | ||
Строка 39: | Строка 40: | ||
out 61h, al | out 61h, al | ||
pop rax | pop rax | ||
- | end; | ||
end; | end; | ||
- | procedure spkoff; | + | procedure spkoff; |
- | begin | + | asm |
- | asm | + | |
push rax | push rax | ||
in al, 61h | in al, 61h | ||
Строка 50: | Строка 49: | ||
out 61h, al | out 61h, al | ||
pop rax | pop rax | ||
- | end; | ||
end; | end; | ||
- | procedure spk(b : word ); | + | procedure spk(b : word); |
var hb, lb : byte; | var hb, lb : byte; | ||
- | begin; hb := hi (b); lb := lo (b); | + | begin |
+ | hb := hi(b); lb := lo(b); | ||
asm | asm | ||
push rax | push rax | ||
Строка 84: | Строка 83: | ||
end. | end. | ||
</ | </ | ||
+ | |||
+ | Юнит: [[http:// | ||
+ | |||
+ | <code pascal> | ||
+ | unit spkunit; | ||
+ | |||
+ | {$MODE OBJFPC} | ||
+ | {$ASMMODE INTEL} | ||
+ | {$CODEPAGE UTF8} | ||
+ | |||
+ | { | ||
+ | Unit for playing melodys on PC-Speaker. | ||
+ | For GNU/Linux 64 bit version. Root priveleges needed. | ||
+ | Version: 3. | ||
+ | Written on FreePascal (https:// | ||
+ | Copyright (C) 2000-2019 | ||
+ | http:// | ||
+ | aralni@mail.ru | ||
+ | |||
+ | This program is free software: you can redistribute it and/or modify | ||
+ | it under the terms of the GNU Affero 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. | ||
+ | GNU Affero General Public License for more details. | ||
+ | |||
+ | You should have received a copy of the GNU Affero General Public License | ||
+ | along with this program. | ||
+ | } | ||
+ | |||
+ | interface | ||
+ | |||
+ | uses X86; | ||
+ | |||
+ | procedure spk(b : word); procedure spkon; procedure spkoff; | ||
+ | |||
+ | implementation | ||
+ | |||
+ | procedure spkon; assembler; | ||
+ | asm | ||
+ | push rax | ||
+ | in al, 61h | ||
+ | or al, 03h | ||
+ | out 61h, al | ||
+ | pop rax | ||
+ | end; | ||
+ | procedure spkoff; assembler; | ||
+ | asm | ||
+ | push rax | ||
+ | in al, 61h | ||
+ | or al, 03h | ||
+ | xor al, 03h | ||
+ | out 61h, al | ||
+ | pop rax | ||
+ | end; | ||
+ | procedure spk(b : word); | ||
+ | var hb, lb : byte; | ||
+ | begin | ||
+ | hb := hi(b); lb := lo(b); | ||
+ | asm | ||
+ | push rax | ||
+ | mov al, 0B6h | ||
+ | out 43h, al | ||
+ | mov al, lb | ||
+ | out 42h, al | ||
+ | mov al, hb | ||
+ | out 42h, al | ||
+ | pop rax | ||
+ | end; | ||
+ | end; | ||
+ | |||
+ | initialization | ||
+ | |||
+ | fpioperm($42, | ||
+ | fpioperm($61, | ||
+ | |||
+ | end. | ||
+ | </ | ||
+ | |||
+ | |||
+ | < | ||
+ | <!-- Rating@Mail.ru counter --> | ||
+ | < | ||
+ | var _tmr = window._tmr || (window._tmr = []); | ||
+ | _tmr.push({id: | ||
+ | (function (d, w, id) { | ||
+ | if (d.getElementById(id)) return; | ||
+ | var ts = d.createElement(" | ||
+ | ts.src = (d.location.protocol == " | ||
+ | var f = function () {var s = d.getElementsByTagName(" | ||
+ | if (w.opera == " | ||
+ | })(document, | ||
+ | </ | ||
+ | <img src="// | ||
+ | </ | ||
+ | <!-- // | ||
+ | <!-- Rating@Mail.ru logo --> | ||
+ | <a class=" | ||
+ | <img src="// | ||
+ | style=" | ||
+ | <!-- // | ||
+ | </ |
pro_spk/воспроизведение_мелодий_через_встроенный_динамик_компьютера_pc-speaker_в_gnu_linux.txt · Последнее изменение: 2023/10/01 09:45 — dwadmin