-
Notifications
You must be signed in to change notification settings - Fork 2
/
modWaveOut.pas
96 lines (78 loc) · 2.88 KB
/
modWaveOut.pas
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
unit modWaveOut;
{' /*******************************************************************************
' modWaveOut.bas within vbSpec.vbp
'
' API declarations and support routines for proving beeper emulation using
' the Windows waveOut* API fucntions.
'
' Author: Chris Cowley <ccowley@grok.co.uk>
'
' Copyright (C)1999-2000 Grok Developments Ltd.
' http://www.grok.co.uk/
'
' This program 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 2
' 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, write to the Free Software
' Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
'
' *******************************************************************************/}
interface
uses windows, mmsystem;
{$I 'OrionZEm.inc'}
{$IFDEF USE_SOUND}
// We can only have beeper emulation in the USE_SOUND build
// Function for moving waveform data from a VB byte array into a block of memory
// allocated by GlobalAlloc()
//This was not declared in Delphi RTL at all ? Odd..
procedure RtlMoveMemory(Dest: POINTER; Source:POINTER; Length:integer);external 'kernel32.dll';
const
NUM_WAV_BUFFERS = 50;
WAVE_FREQUENCY = 22050;
WAV_BUFFER_SIZE = 441; //(WAVE_FREQUENCY \ NUM_WAV_BUFFERS)
// Variables and constants used by the beeper emulation
var
glphWaveOut : integer = -1;
ghMem: array[1..NUM_WAV_BUFFERS+1] of HGLOBAL;
gpMem: array[1..NUM_WAV_BUFFERS+1] of Pointer;
gtWavFormat: TWAVEFORMATEX;
gtWavHdr: array[1..NUM_WAV_BUFFERS+1] of WAVEHDR;
gcWaveOut: array[0..48000] of Byte;
glWavePtr: integer;
glWaveAddTStates: integer;
{$ENDIF}
procedure AddSoundWave(ts : integer);
implementation
uses modAY8912, modOrion, MainWin;
var
WCount : integer = 0;
lCounter : integer = 0;
procedure AddSoundWave(ts : integer);
begin
{$IFDEF USE_SOUND}
WCount := WCount + 1;
If WCount = 800 Then
begin
AY8912Update_8;
WCount := 0;
End;
lCounter := lCounter + ts;
While lCounter >= glWaveAddTStates do
begin
If AYEnabled Then
gcWaveOut[glWavePtr] := glBeeperVal + RenderByte()
else
gcWaveOut[glWavePtr] := glBeeperVal;
glWavePtr := glWavePtr + 1;
lCounter := lCounter - glWaveAddTStates;
end;
{$ENDIF}
End;
end.