port from perforce
This commit is contained in:
312
ev14-4k/project/main.compress.cpp
Normal file
312
ev14-4k/project/main.compress.cpp
Normal file
@@ -0,0 +1,312 @@
|
||||
#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
|
||||
#endif
|
||||
|
||||
#ifndef SCREENHEIGHT
|
||||
#define SCREENHEIGHT 720
|
||||
#endif
|
||||
|
||||
#ifndef ASPECTOFFSET
|
||||
#define ASPECTOFFSET 0.375f
|
||||
#endif
|
||||
|
||||
#pragma data_seg(".aspect")
|
||||
static float aspect = ASPECTOFFSET;
|
||||
|
||||
#define SHADER_WARMUP
|
||||
#define WINDOWED
|
||||
|
||||
#pragma data_seg(".Shader0")
|
||||
#include "mark_small.h"
|
||||
|
||||
#pragma data_seg(".pfd")
|
||||
static const PIXELFORMATDESCRIPTOR pfd = {
|
||||
0, 1, PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, 32, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 8
|
||||
};
|
||||
|
||||
#pragma data_seg(".dmScreenSettings")
|
||||
static DEVMODE dmScreenSettings = {
|
||||
"", 0, 0, sizeof(dmScreenSettings), 0, DM_PELSWIDTH | DM_PELSHEIGHT,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", 0, 0, SCREENWIDTH, SCREENHEIGHT
|
||||
};
|
||||
|
||||
#pragma data_seg(".fltused")
|
||||
int _fltused = 1;
|
||||
|
||||
#pragma bss_seg(".mainbss")
|
||||
static int gCurScene = 0;
|
||||
static int gCurSceneStart = 0;
|
||||
static float lf_Time = 0.0f;
|
||||
|
||||
#pragma data_seg(".g_SceneLength")
|
||||
int g_SceneLength[] =
|
||||
{
|
||||
16, 16,
|
||||
16, 8, 8, 8, 8, 16,
|
||||
8, 8, 16, 16,
|
||||
16, 16, 16, 16,
|
||||
0x80000000
|
||||
};
|
||||
#pragma data_seg(".g_SceneShader")
|
||||
int g_SceneShader[] =
|
||||
{
|
||||
0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
1, 1, 1, 1,
|
||||
2, 2, 2, 2
|
||||
};
|
||||
|
||||
|
||||
#pragma data_seg(".glCreateShaderProgramEXT")
|
||||
static const char* sglCreateShaderProgramEXT = "glCreateShaderProgramEXT";
|
||||
|
||||
#pragma data_seg(".glUseProgram")
|
||||
static const char* sglUseProgram = "glUseProgram";
|
||||
|
||||
#pragma data_seg(".glUniform4f")
|
||||
static const char* sglUniform4f = "glUniform4f";
|
||||
|
||||
#define shaderCountOffset 12
|
||||
|
||||
#define ATOM_EDIT 0xC018
|
||||
#define ATOM_STATIC 0xC019
|
||||
|
||||
#pragma code_seg(".main")
|
||||
void _cdecl main()
|
||||
{
|
||||
_asm
|
||||
{
|
||||
xor esi, esi
|
||||
|
||||
#ifndef WINDOWED
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
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 dmScreenSettings
|
||||
call ChangeDisplaySettings
|
||||
call CreateWindowExA
|
||||
#else
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
push SCREENHEIGHT
|
||||
push SCREENWIDTH
|
||||
push esi
|
||||
push esi
|
||||
push WS_EX_APPWINDOW | WS_VISIBLE | WS_SYSMENU
|
||||
push esi
|
||||
push ATOM_STATIC
|
||||
push esi
|
||||
call CreateWindowExA
|
||||
#endif
|
||||
push eax
|
||||
call GetDC
|
||||
mov edi, eax
|
||||
|
||||
push edi
|
||||
push edi
|
||||
push offset pfd
|
||||
push offset pfd
|
||||
push edi
|
||||
call ChoosePixelFormat
|
||||
push eax
|
||||
push edi
|
||||
call SetPixelFormat
|
||||
call wglCreateContext
|
||||
push eax
|
||||
push edi
|
||||
call wglMakeCurrent
|
||||
call SwapBuffers
|
||||
}
|
||||
|
||||
_asm
|
||||
{
|
||||
push 32 // waveOutOpen/waveOutWrite
|
||||
push offset WaveHDR
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
push offset WaveFMT
|
||||
push - 1
|
||||
push offset hWaveOut
|
||||
push 1024 // Sleep
|
||||
push esi // CreateThread
|
||||
push esi
|
||||
push offset lpSoundBuffer
|
||||
push _4klang_render
|
||||
push esi
|
||||
push esi
|
||||
push FALSE // ShowCursor
|
||||
|
||||
#ifdef SHADER_WARMUP
|
||||
push 1 // glRecti
|
||||
push 1
|
||||
push - 1
|
||||
push - 1
|
||||
push 3 // glUseProgram
|
||||
push sglUseProgram
|
||||
#endif
|
||||
push offset mark_fs_0 // glCreateShaderProgramEXT
|
||||
push GL_FRAGMENT_SHADER
|
||||
push sglCreateShaderProgramEXT
|
||||
|
||||
#ifdef SHADER_WARMUP
|
||||
push 1 // glRecti
|
||||
push 1
|
||||
push - 1
|
||||
push - 1
|
||||
push 2 // glUseProgram
|
||||
push sglUseProgram
|
||||
#endif
|
||||
push offset mark_fs_0 // glCreateShaderProgramEXT
|
||||
push GL_FRAGMENT_SHADER
|
||||
push sglCreateShaderProgramEXT
|
||||
|
||||
#ifdef SHADER_WARMUP
|
||||
push 1 // glRecti
|
||||
push 1
|
||||
push - 1
|
||||
push - 1
|
||||
push 1 // glUseProgram
|
||||
push sglUseProgram
|
||||
#endif
|
||||
push offset mark_fs_0 // glCreateShaderProgramEXT
|
||||
push GL_FRAGMENT_SHADER
|
||||
push sglCreateShaderProgramEXT
|
||||
|
||||
call wglGetProcAddress
|
||||
call eax
|
||||
#ifdef SHADER_WARMUP
|
||||
call wglGetProcAddress
|
||||
call eax
|
||||
call glRecti
|
||||
#endif
|
||||
inc byte ptr[mark_fs_0 + 0xC]
|
||||
|
||||
call wglGetProcAddress
|
||||
call eax
|
||||
#ifdef SHADER_WARMUP
|
||||
call wglGetProcAddress
|
||||
call eax
|
||||
call glRecti
|
||||
#endif
|
||||
inc byte ptr[mark_fs_0 + 0xC]
|
||||
|
||||
call wglGetProcAddress
|
||||
call eax
|
||||
#ifdef SHADER_WARMUP
|
||||
call wglGetProcAddress
|
||||
call eax
|
||||
call glRecti
|
||||
#endif
|
||||
inc byte ptr[mark_fs_0 + 0xC]
|
||||
|
||||
call ShowCursor
|
||||
call CreateThread
|
||||
call Sleep
|
||||
call waveOutOpen
|
||||
push hWaveOut
|
||||
call waveOutWrite
|
||||
}
|
||||
|
||||
_asm
|
||||
{
|
||||
introloop:
|
||||
push 12
|
||||
push offset MMTime
|
||||
push hWaveOut
|
||||
call waveOutGetPosition
|
||||
|
||||
mov ecx, MMTime.u.sample
|
||||
sub ecx, gCurSceneStart // ecx = Sample
|
||||
mov eax, gCurScene
|
||||
imul ebx, [eax * 4 + g_SceneLength], SAMPLES_PER_TICK * 8 // ebx = SceneEnd
|
||||
mov eax, [eax * 4 + g_SceneShader]
|
||||
inc eax
|
||||
push eax
|
||||
|
||||
mov lf_Time, ecx
|
||||
fild lf_Time
|
||||
mov lf_Time, ebx
|
||||
fild lf_Time
|
||||
fdiv
|
||||
fst lf_Time
|
||||
|
||||
push sglUseProgram
|
||||
call wglGetProcAddress
|
||||
call eax
|
||||
|
||||
sub esp, 0x10
|
||||
fld aspect
|
||||
fstp dword ptr[esp + 0xc]
|
||||
fild dword ptr[dmScreenSettings.dmPelsHeight]
|
||||
fstp dword ptr[esp + 0x8]
|
||||
fld lf_Time
|
||||
fstp dword ptr[esp + 0x4]
|
||||
fild gCurScene
|
||||
fstp dword ptr[esp]
|
||||
push esi
|
||||
push sglUniform4f
|
||||
call wglGetProcAddress
|
||||
call eax
|
||||
|
||||
push VK_ESCAPE
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
push edi
|
||||
push 1
|
||||
push 1
|
||||
push -1
|
||||
push -1
|
||||
call glRecti
|
||||
call SwapBuffers
|
||||
|
||||
fld1
|
||||
fcomp dword ptr[lf_Time]
|
||||
fnstsw ax
|
||||
test ah, 0x5
|
||||
jp peekmessage
|
||||
|
||||
add dword ptr[gCurSceneStart], ebx
|
||||
inc dword ptr[gCurScene]
|
||||
|
||||
peekmessage:
|
||||
call PeekMessage
|
||||
|
||||
cmp dword ptr[MMTime.u.sample], MAX_SAMPLES
|
||||
jae exit
|
||||
|
||||
call GetAsyncKeyState
|
||||
test ax, ax
|
||||
jz introloop
|
||||
|
||||
exit:
|
||||
push esi
|
||||
call ExitProcess
|
||||
|
||||
}
|
||||
//} while (MMTime.u.sample < MAX_SAMPLES && !GetAsyncKeyState(VK_ESCAPE));
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user