port from perforce

This commit is contained in:
2026-04-18 22:31:51 +02:00
commit 8d0ab5b7cc
8409 changed files with 3972376 additions and 0 deletions

91
bp10-4k/src/synth.h Normal file
View File

@@ -0,0 +1,91 @@
#define WIN32_LEAN_AND_MEAN
#define WIN32_EXTRA_LEAN
#include "mmreg.h"
#include "4klang.h"
#define USE_SOUND_THREAD
#pragma bss_seg(".synthnothing")
static float lpSoundBuffer[MAX_SAMPLES];
static HWAVEOUT hWaveOut;
#pragma data_seg(".wavefmt")
WAVEFORMATEX WaveFMT =
{
#ifdef FLOAT_32BIT
WAVE_FORMAT_IEEE_FLOAT,
#else
WAVE_FORMAT_PCM,
#endif
2, // channels
SAMPLE_RATE, // samples per sec
SAMPLE_RATE*sizeof(SAMPLE_TYPE)*2, // bytes per sec
sizeof(SAMPLE_TYPE)*2, // block alignment;
sizeof(SAMPLE_TYPE)*8, // bits per sample
0 // extension not needed
};
#pragma data_seg(".wavehdr")
WAVEHDR WaveHDR =
{
(LPSTR)lpSoundBuffer,
MAX_SAMPLES*sizeof(SAMPLE_TYPE)*2, // MAX_SAMPLES*sizeof(float)*2(stereo)
0,
0,
0,
0,
0,
0
};
#pragma data_seg(".mmtime")
MMTIME MMTime =
{
TIME_SAMPLES,
0
};
#ifdef USE_SOUND_THREAD
#pragma code_seg(".sndthrd")
DWORD WINAPI SoundThread( LPVOID lpParam )
{
_4klang_render(lpSoundBuffer);
return 0;
}
#endif
#pragma code_seg(".initsnd")
extern "C" void InitSound()
{
#ifdef USE_SOUND_THREAD
CreateThread(0, 0, SoundThread, 0, 0, 0);
#else
_4klang_render(lpSoundBuffer);
#endif
_asm
{
push esi
push esi
push esi
push offset WaveFMT
push 0FFFFFFFFh
push offset hWaveOut
call dword ptr [waveOutOpen]
push 20h
push offset WaveHDR
push dword ptr [hWaveOut]
push 20h
push offset WaveHDR
push dword ptr [hWaveOut]
call dword ptr [waveOutPrepareHeader]
call dword ptr [waveOutWrite]
}
}
#pragma code_seg(".time")
extern "C" float get_Time()
{
waveOutGetPosition(hWaveOut, &MMTime, sizeof(MMTIME));
return float(MMTime.u.sample) / SAMPLE_RATE;
}