273 lines
4.6 KiB
C++
273 lines
4.6 KiB
C++
#define WIN32_LEAN_AND_MEAN
|
|
#define WIN32_EXTRA_LEAN
|
|
#include "synth.h"
|
|
#include <GL/gl.h>
|
|
#include "glext.h"
|
|
#include "mark_small.h"
|
|
|
|
#ifndef SCREENWIDTH
|
|
//#define SCREENWIDTH 1280
|
|
#define SCREENWIDTH 320
|
|
#endif
|
|
|
|
#ifndef SCREENHEIGHT
|
|
//#define SCREENHEIGHT 720
|
|
#define SCREENHEIGHT 180
|
|
#endif
|
|
|
|
#ifndef ASPECTOFFSET
|
|
#define ASPECTOFFSET 0.375f
|
|
#endif
|
|
|
|
#define shaderCountOffset 14
|
|
|
|
#define ATOM_EDIT 0xC018
|
|
#define ATOM_STATIC 0xC019
|
|
|
|
#define SCENE_LENGTH (SAMPLES_PER_TICK * 64)
|
|
|
|
#pragma data_seg(".aspectOffset")
|
|
static const float gfAspectOffset = ASPECTOFFSET;
|
|
|
|
#pragma data_seg(".scebeLength")
|
|
static const int giSceneLength = SCENE_LENGTH;
|
|
|
|
//#define PFD_HACK
|
|
#define SHADER_WARMUP
|
|
//#define WINDOWED
|
|
#define START_BLACK
|
|
|
|
#pragma data_seg(".Shader0")
|
|
#include "mark_small.h"
|
|
|
|
struct FAKEDEVMODE
|
|
{
|
|
BYTE _a[36];
|
|
DWORD dmSize;
|
|
DWORD dmFields;
|
|
struct
|
|
{
|
|
BYTE _b[4];
|
|
DWORD pfdFlags;
|
|
} pfd;
|
|
BYTE _c[56];
|
|
DWORD width;
|
|
DWORD height;
|
|
BYTE _d[8];
|
|
};
|
|
|
|
#pragma data_seg("fcw")
|
|
static WORD fcw = 0x0E7f;
|
|
|
|
#pragma data_seg(".devmode")
|
|
static FAKEDEVMODE devmode = {
|
|
"", sizeof(devmode), DM_PELSWIDTH | DM_PELSHEIGHT, "", PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL, "", SCREENWIDTH, SCREENHEIGHT, ""
|
|
};
|
|
|
|
#pragma bss_seg(".mainbss")
|
|
static PFNGLCREATESHADERPROGRAMEXTPROC glCreateShaderProgramEXT;
|
|
static PFNGLUSEPROGRAMPROC glUseProgram;
|
|
static PFNGLUNIFORM3FPROC glUniform3f;
|
|
|
|
#pragma data_seg(".fltused")
|
|
int _fltused = 1;
|
|
|
|
#pragma data_seg(".glCreateShaderProgramEXT")
|
|
static const char* sglCreateShaderProgramEXT = "glCreateShaderProgramEXT";
|
|
|
|
#pragma data_seg(".glUseProgram")
|
|
static const char* sglUseProgram = "glUseProgram";
|
|
|
|
#pragma data_seg(".glUniform3f")
|
|
static const char* sglUniform3f = "glUniform3f";
|
|
|
|
#pragma code_seg(".main")
|
|
void _cdecl main()
|
|
{
|
|
_asm
|
|
{
|
|
fldcw [fcw]
|
|
|
|
xor esi, esi
|
|
|
|
push esi
|
|
push esi
|
|
push esi
|
|
push esi
|
|
|
|
#ifndef WINDOWED
|
|
push esi
|
|
push esi
|
|
push esi
|
|
push esi
|
|
push WS_POPUP | WS_VISIBLE | WS_MAXIMIZE
|
|
push esi
|
|
push ATOM_STATIC
|
|
push esi
|
|
push CDS_FULLSCREEN
|
|
push offset devmode
|
|
push esi
|
|
push esi
|
|
push offset lpSoundBuffer
|
|
push _4klang_render
|
|
push esi
|
|
push esi
|
|
call CreateThread
|
|
call ChangeDisplaySettings
|
|
call CreateWindowExA
|
|
#else
|
|
push SCREENHEIGHT
|
|
push SCREENWIDTH
|
|
push esi
|
|
push esi
|
|
push WS_EX_APPWINDOW | WS_VISIBLE | WS_SYSMENU
|
|
push esi
|
|
push ATOM_STATIC
|
|
push esi
|
|
push esi
|
|
push esi
|
|
push offset lpSoundBuffer
|
|
push _4klang_render
|
|
push esi
|
|
push esi
|
|
call CreateThread
|
|
call CreateWindowExA
|
|
#endif
|
|
|
|
push eax
|
|
call GetDC
|
|
mov edi, eax
|
|
|
|
push esi
|
|
#ifdef START_BLACK
|
|
push edi
|
|
#endif
|
|
push edi
|
|
#ifdef PFD_HACK
|
|
push esi
|
|
push 8
|
|
#else
|
|
push esi
|
|
push offset devmode.pfd
|
|
push edi
|
|
call ChoosePixelFormat
|
|
push eax
|
|
#endif
|
|
push edi
|
|
call SetPixelFormat
|
|
call wglCreateContext
|
|
push eax
|
|
push edi
|
|
call wglMakeCurrent
|
|
#ifdef START_BLACK
|
|
call SwapBuffers
|
|
#endif
|
|
call ShowCursor
|
|
|
|
xor ebx, ebx
|
|
|
|
shaderwarmup :
|
|
#ifdef SHADER_WARMUP
|
|
push 1
|
|
push 1
|
|
push - 1
|
|
push - 1
|
|
#endif
|
|
push offset mark_fs_0
|
|
push GL_FRAGMENT_SHADER
|
|
push sglCreateShaderProgramEXT
|
|
call wglGetProcAddress
|
|
call eax
|
|
#ifdef SHADER_WARMUP
|
|
push eax
|
|
push sglUseProgram
|
|
call wglGetProcAddress
|
|
call eax
|
|
#endif
|
|
inc byte ptr[mark_fs_0 + shaderCountOffset]
|
|
|
|
cmp ebx, 9
|
|
jnz skip
|
|
mov byte ptr[mark_fs_0 + shaderCountOffset], 'A'
|
|
skip:
|
|
#ifdef SHADER_WARMUP
|
|
push gfAspectOffset
|
|
push dword ptr[devmode.height]
|
|
fild dword ptr[esp]
|
|
fstp dword ptr[esp]
|
|
push ebx
|
|
fild dword ptr[esp]
|
|
fstp dword ptr[esp]
|
|
push esi
|
|
push sglUniform3f
|
|
call wglGetProcAddress
|
|
call eax
|
|
call glRecti
|
|
#endif
|
|
inc ebx
|
|
cmp ebx, 12
|
|
jnz shaderwarmup
|
|
|
|
push 0x20
|
|
push offset WaveHDR
|
|
push esi
|
|
push esi
|
|
push esi
|
|
push offset WaveFMT
|
|
push -1
|
|
push offset hWaveOut
|
|
call waveOutOpen
|
|
push [hWaveOut]
|
|
call waveOutWrite
|
|
}
|
|
|
|
do
|
|
{
|
|
_asm
|
|
{
|
|
push 0xC
|
|
push offset MMTime
|
|
push [hWaveOut]
|
|
call waveOutGetPosition
|
|
|
|
push esi
|
|
push esi
|
|
push esi
|
|
push esi
|
|
push esi
|
|
push edi
|
|
push 1
|
|
push 1
|
|
push -1
|
|
push -1
|
|
push gfAspectOffset
|
|
push dword ptr[devmode.height]
|
|
fild dword ptr[esp]
|
|
fstp dword ptr[esp]
|
|
push dword ptr[MMTime.u.sample]
|
|
fild dword ptr[esp]
|
|
fild giSceneLength
|
|
fdiv
|
|
fst dword ptr[esp]
|
|
push esi
|
|
push esi
|
|
fistp dword ptr[esp]
|
|
pop eax
|
|
inc eax
|
|
push eax
|
|
push sglUseProgram
|
|
call wglGetProcAddress
|
|
call eax
|
|
|
|
push sglUniform3f
|
|
call wglGetProcAddress
|
|
call eax
|
|
call glRecti
|
|
call SwapBuffers
|
|
call PeekMessage
|
|
}
|
|
} while (MMTime.u.sample < MAX_SAMPLES && !GetAsyncKeyState(VK_ESCAPE));
|
|
|
|
ExitProcess(0);
|
|
}
|