295 lines
6.4 KiB
C++
295 lines
6.4 KiB
C++
#ifndef _DEBUG
|
|
#define WINDOWED
|
|
//#define NOMUSICTIMING
|
|
#define WIN32_LEAN_AND_MEAN
|
|
#define WIN32_EXTRA_LEAN
|
|
#include <windows.h>
|
|
#include <GL/gl.h>
|
|
#include <GL/glu.h>
|
|
#include "glext.h"
|
|
#include "small.h"
|
|
#include "synth.h"
|
|
|
|
#ifndef ASPECT
|
|
#define ASPECT 1.78
|
|
#endif
|
|
|
|
#ifndef SCREENWIDTH
|
|
#define SCREENWIDTH 640
|
|
#endif
|
|
|
|
#ifndef SCREENHEIGTH
|
|
#define SCREENHEIGTH 360
|
|
#endif
|
|
|
|
#define STR2(x) #x
|
|
#define STR(x) STR2(x)
|
|
|
|
#pragma data_seg(".Shader0")
|
|
#include "mark_0.h"
|
|
#pragma data_seg(".Shader1")
|
|
#include "mark_1.h"
|
|
#pragma data_seg(".Shader2")
|
|
#include "mark_2.h"
|
|
#pragma data_seg(".Shader3")
|
|
#include "mark_3.h"
|
|
|
|
#pragma data_seg(".vertexshader")
|
|
static char* vsh = "varying vec4 Y,Z;void main(){Y=gl_Color;Z=gl_Vertex*vec4("STR( ASPECT )",1,1,1)*.5+.5;gl_Position=gl_Vertex;}";
|
|
|
|
#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(".dms")
|
|
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,SCREENHEIGTH
|
|
};
|
|
|
|
#pragma data_seg(".strings")
|
|
static const char* glCreateProgram = "glCreateProgram";
|
|
#pragma data_seg(".strings9")
|
|
static const char* glCreateShader = "glCreateShader";
|
|
#pragma data_seg(".strings8")
|
|
static const char* glShaderSource = "glShaderSource";
|
|
#pragma data_seg(".strings7")
|
|
static const char* glCompileShader = "glCompileShader";
|
|
#pragma data_seg(".strings6")
|
|
static const char* glAttachShader = "glAttachShader";
|
|
#pragma data_seg(".strings5")
|
|
static const char* glLinkProgram = "glLinkProgram";
|
|
#pragma data_seg(".strings4")
|
|
static const char* glUseProgram = "glUseProgram";
|
|
#pragma data_seg(".strings3")
|
|
static const char* stredit = "edit";
|
|
#pragma data_seg(".strings2")
|
|
static const char* strstatic = "static";
|
|
#pragma data_seg(".strings1")
|
|
static const char* strRED = "RED";
|
|
|
|
#pragma code_seg(".compile")
|
|
unsigned int compileShader(const char* vsh, const char* fsh)
|
|
{
|
|
_asm
|
|
{
|
|
xor edi, edi
|
|
|
|
push glCreateProgram
|
|
call dword ptr [wglGetProcAddress]
|
|
call eax
|
|
mov esi, eax
|
|
|
|
lea ebx,[vsh]
|
|
push GL_VERTEX_SHADER
|
|
push glCreateShader
|
|
call dword ptr [wglGetProcAddress]
|
|
call eax
|
|
|
|
push eax
|
|
push esi
|
|
push glAttachShader
|
|
push eax
|
|
push glCompileShader
|
|
push edi
|
|
push ebx
|
|
push 1
|
|
push eax
|
|
push glShaderSource
|
|
call dword ptr [wglGetProcAddress]
|
|
call eax
|
|
call dword ptr [wglGetProcAddress]
|
|
call eax
|
|
call dword ptr [wglGetProcAddress]
|
|
call eax
|
|
|
|
lea ebx,[fsh]
|
|
push GL_FRAGMENT_SHADER
|
|
push glCreateShader
|
|
call dword ptr [wglGetProcAddress]
|
|
call eax
|
|
|
|
push eax
|
|
push esi
|
|
push glAttachShader
|
|
push eax
|
|
push glCompileShader
|
|
push edi
|
|
push ebx
|
|
push 1
|
|
push eax
|
|
push glShaderSource
|
|
call dword ptr [wglGetProcAddress]
|
|
call eax
|
|
call dword ptr [wglGetProcAddress]
|
|
call eax
|
|
call dword ptr [wglGetProcAddress]
|
|
call eax
|
|
|
|
push esi
|
|
push glLinkProgram
|
|
call dword ptr [wglGetProcAddress]
|
|
call eax
|
|
|
|
mov eax, esi
|
|
}
|
|
}
|
|
|
|
#pragma bss_seg(".introbss")
|
|
static unsigned char gCurScene;
|
|
static int gCurSceneStart;
|
|
static unsigned int shaders[4];
|
|
|
|
#pragma data_seg(".g_SceneLength")
|
|
unsigned char g_SceneLength[]=
|
|
{
|
|
16, 8, 8, 32,
|
|
16, 16, 32,
|
|
16, 16, 32,
|
|
16, 16, 16, 32,
|
|
0
|
|
};
|
|
|
|
#pragma data_seg(".g_SceneShader")
|
|
unsigned char g_SceneShader[]=
|
|
{
|
|
0,0,0,0,
|
|
1,1,1,
|
|
2,2,2,
|
|
3,3,3,3
|
|
};
|
|
|
|
#pragma data_seg(".g_SceneFactor")
|
|
float g_SceneFactor[]=
|
|
{
|
|
0, 0, 0, 1.0f,
|
|
0, 0, 1.0f,
|
|
0, 0, 1.0f,
|
|
0, 1.0f, 1.0f, 2.0f
|
|
};
|
|
|
|
#pragma code_seg(".main")
|
|
void _cdecl main()
|
|
{
|
|
_asm
|
|
{
|
|
xor edi, edi
|
|
}
|
|
|
|
HDC hDC;
|
|
|
|
#ifndef WINDOWED
|
|
_asm
|
|
{
|
|
push CDS_FULLSCREEN
|
|
push offset dmScreenSettings
|
|
call dword ptr [ChangeDisplaySettingsA]
|
|
|
|
push edi
|
|
push edi
|
|
push edi
|
|
push edi
|
|
push edi
|
|
push edi
|
|
push edi
|
|
push edi
|
|
push WS_POPUP | WS_VISIBLE | WS_MAXIMIZE
|
|
push edi
|
|
push stredit
|
|
push edi
|
|
call dword ptr [CreateWindowExA]
|
|
push eax
|
|
call dword ptr [GetDC]
|
|
mov dword ptr [hDC],eax
|
|
}
|
|
#else
|
|
_asm
|
|
{
|
|
push edi
|
|
push edi
|
|
push edi
|
|
push edi
|
|
push SCREENHEIGTH
|
|
push SCREENWIDTH
|
|
push edi
|
|
push edi
|
|
push WS_EX_APPWINDOW | WS_VISIBLE | WS_SYSMENU
|
|
push strRED
|
|
push strstatic
|
|
push edi
|
|
call dword ptr [CreateWindowExA]
|
|
push eax
|
|
call dword ptr [GetDC]
|
|
mov dword ptr [hDC],eax
|
|
}
|
|
#endif
|
|
|
|
_asm
|
|
{
|
|
push offset pfd
|
|
push offset pfd
|
|
push dword ptr [hDC]
|
|
call dword ptr [ChoosePixelFormat]
|
|
push eax
|
|
push dword ptr [hDC]
|
|
call dword ptr [SetPixelFormat]
|
|
|
|
push dword ptr [hDC]
|
|
call dword ptr [wglCreateContext]
|
|
push eax
|
|
push dword ptr [hDC]
|
|
call dword ptr [wglMakeCurrent]
|
|
}
|
|
|
|
_asm
|
|
{
|
|
push mark_h_1
|
|
push vsh
|
|
push mark_h_2
|
|
push vsh
|
|
push mark_h_3
|
|
push vsh
|
|
push mark_h_0
|
|
push vsh
|
|
call dword ptr [compileShader]
|
|
mov dword ptr shaders[0],eax
|
|
call dword ptr [compileShader]
|
|
mov dword ptr shaders[4],eax
|
|
call dword ptr [compileShader]
|
|
mov dword ptr shaders[8],eax
|
|
call dword ptr [compileShader]
|
|
mov dword ptr shaders[12],eax
|
|
}
|
|
|
|
_asm
|
|
{
|
|
push edi
|
|
call dword ptr [ShowCursor]
|
|
call dword ptr [InitSound]
|
|
}
|
|
|
|
float lf_Time= 0.0f;
|
|
do
|
|
{
|
|
int Sample= get_Sample() - gCurSceneStart;
|
|
int SceneEnd= g_SceneLength[ gCurScene ] * (44100 * 60 / 145);//samples per tick
|
|
|
|
((PFNGLUSEPROGRAMPROC)wglGetProcAddress(glUseProgram))(shaders[ g_SceneShader[ gCurScene ] ]);
|
|
lf_Time = (float)Sample / (float)SceneEnd;
|
|
glColor3f((float)gCurScene, lf_Time, lf_Time * lf_Time * g_SceneFactor[ gCurScene ]);
|
|
|
|
glRects(-1, -1, 1, 1);
|
|
SwapBuffers(hDC);
|
|
|
|
if (Sample > SceneEnd)
|
|
{
|
|
gCurSceneStart+= SceneEnd;
|
|
gCurScene++;
|
|
}
|
|
}
|
|
while (g_SceneLength[gCurScene] > 0 && !GetAsyncKeyState(VK_ESCAPE));
|
|
ExitProcess(0);
|
|
}
|
|
#endif |