port from perforce
This commit is contained in:
31
space4k/4k.sln
Normal file
31
space4k/4k.sln
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "4k", "src\4k.vcxproj", "{478863DD-1156-47FF-8AE2-F7A923BB3998}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "4slang", "src\4slang\4slang.vcxproj", "{E0A366EF-1805-44C7-B644-426FEE32B9D9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
Tiny|Win32 = Tiny|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{478863DD-1156-47FF-8AE2-F7A923BB3998}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{478863DD-1156-47FF-8AE2-F7A923BB3998}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{478863DD-1156-47FF-8AE2-F7A923BB3998}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{478863DD-1156-47FF-8AE2-F7A923BB3998}.Release|Win32.Build.0 = Release|Win32
|
||||
{478863DD-1156-47FF-8AE2-F7A923BB3998}.Tiny|Win32.ActiveCfg = Tiny|Win32
|
||||
{478863DD-1156-47FF-8AE2-F7A923BB3998}.Tiny|Win32.Build.0 = Tiny|Win32
|
||||
{E0A366EF-1805-44C7-B644-426FEE32B9D9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{E0A366EF-1805-44C7-B644-426FEE32B9D9}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{E0A366EF-1805-44C7-B644-426FEE32B9D9}.Release|Win32.ActiveCfg = Debug|Win32
|
||||
{E0A366EF-1805-44C7-B644-426FEE32B9D9}.Release|Win32.Build.0 = Debug|Win32
|
||||
{E0A366EF-1805-44C7-B644-426FEE32B9D9}.Tiny|Win32.ActiveCfg = Debug|Win32
|
||||
{E0A366EF-1805-44C7-B644-426FEE32B9D9}.Tiny|Win32.Build.0 = Debug|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
BIN
space4k/4k.suo
Normal file
BIN
space4k/4k.suo
Normal file
Binary file not shown.
22
space4k/UpgradeLog.XML
Normal file
22
space4k/UpgradeLog.XML
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type='text/xsl' href='_UpgradeReport_Files/UpgradeReport.xslt'?><UpgradeLog>
|
||||
<Properties><Property Name="Solution" Value="4k">
|
||||
</Property><Property Name="Solution File" Value="R:\Code\blu-flame.org\space4k\4k.sln">
|
||||
</Property><Property Name="Date" Value="Wednesday, April 20, 2011">
|
||||
</Property><Property Name="Time" Value="21:03">
|
||||
</Property></Properties><Event ErrorLevel="0" Project="4k" Source="src\4k.vcproj" Description="Converting project file 'R:\Code\blu-flame.org\space4k\src\4k.vcproj'.">
|
||||
</Event><Event ErrorLevel="1" Project="4k" Source="src\4k.vcproj" Description="VCWebServiceProxyGeneratorTool is no longer supported. The tool has been removed from your project settings.">
|
||||
</Event><Event ErrorLevel="1" Project="4k" Source="src\4k.vcproj" Description="MSB8012: $(TargetName) ('4k') does not match the Linker's OutputFile property value 'R:\Code\blu-flame.org\space4k\bin\4k_Debug.exe' ('4k_Debug') in project configuration 'Debug|Win32'. This may cause your project to build incorrectly. To correct this, please make sure that $(TargetName) property value matches the value specified in %(Link.OutputFile).">
|
||||
</Event><Event ErrorLevel="1" Project="4k" Source="src\4k.vcproj" Description="MSB8012: $(TargetPath) ('R:\Code\blu-flame.org\space4k\bin\4k.exe') does not match the Linker's OutputFile property value 'R:\Code\blu-flame.org\space4k\bin\4k_Debug.exe' ('R:\Code\blu-flame.org\space4k\bin\4k_Debug.exe') in project configuration 'Debug|Win32'. This may cause your project to build incorrectly. To correct this, please make sure that $(TargetPath) property value matches the value specified in %(Link.OutputFile).">
|
||||
</Event><Event ErrorLevel="1" Project="4k" Source="src\4k.vcproj" Description="MSB8012: $(TargetName) ('4k') does not match the Linker's OutputFile property value 'R:\Code\blu-flame.org\space4k\bin\4k_Release.exe' ('4k_Release') in project configuration 'Release|Win32'. This may cause your project to build incorrectly. To correct this, please make sure that $(TargetName) property value matches the value specified in %(Link.OutputFile).">
|
||||
</Event><Event ErrorLevel="1" Project="4k" Source="src\4k.vcproj" Description="MSB8012: $(TargetPath) ('R:\Code\blu-flame.org\space4k\bin\4k.exe') does not match the Linker's OutputFile property value 'R:\Code\blu-flame.org\space4k\bin\4k_Release.exe' ('R:\Code\blu-flame.org\space4k\bin\4k_Release.exe') in project configuration 'Release|Win32'. This may cause your project to build incorrectly. To correct this, please make sure that $(TargetPath) property value matches the value specified in %(Link.OutputFile).">
|
||||
</Event><Event ErrorLevel="1" Project="4k" Source="src\4k.vcproj" Description="MSB8012: $(TargetName) ('4k') does not match the Linker's OutputFile property value 'R:\Code\blu-flame.org\space4k\bin\4k_Tiny.exe' ('4k_Tiny') in project configuration 'Tiny|Win32'. This may cause your project to build incorrectly. To correct this, please make sure that $(TargetName) property value matches the value specified in %(Link.OutputFile).">
|
||||
</Event><Event ErrorLevel="1" Project="4k" Source="src\4k.vcproj" Description="MSB8012: $(TargetPath) ('R:\Code\blu-flame.org\space4k\bin\4k.exe') does not match the Linker's OutputFile property value 'R:\Code\blu-flame.org\space4k\bin\4k_Tiny.exe' ('R:\Code\blu-flame.org\space4k\bin\4k_Tiny.exe') in project configuration 'Tiny|Win32'. This may cause your project to build incorrectly. To correct this, please make sure that $(TargetPath) property value matches the value specified in %(Link.OutputFile).">
|
||||
</Event><Event ErrorLevel="0" Project="4k" Source="src\4k.vcproj" Description="Done converting to new project file 'R:\Code\blu-flame.org\space4k\src\4k.vcxproj'.">
|
||||
</Event><Event ErrorLevel="3" Project="4k" Source="src\4k.vcproj" Description="Converted">
|
||||
</Event><Event ErrorLevel="0" Project="4slang" Source="src\4slang\4slang.vcproj" Description="Converting project file 'R:\Code\blu-flame.org\space4k\src\4slang\4slang.vcproj'.">
|
||||
</Event><Event ErrorLevel="1" Project="4slang" Source="src\4slang\4slang.vcproj" Description="VCWebServiceProxyGeneratorTool is no longer supported. The tool has been removed from your project settings.">
|
||||
</Event><Event ErrorLevel="0" Project="4slang" Source="src\4slang\4slang.vcproj" Description="Done converting to new project file 'R:\Code\blu-flame.org\space4k\src\4slang\4slang.vcxproj'.">
|
||||
</Event><Event ErrorLevel="3" Project="4slang" Source="src\4slang\4slang.vcproj" Description="Converted">
|
||||
</Event><Event ErrorLevel="0" Project="" Source="4k.sln" Description="Solution converted successfully">
|
||||
</Event><Event ErrorLevel="3" Project="" Source="4k.sln" Description="Converted">
|
||||
</Event></UpgradeLog>
|
||||
BIN
space4k/link.exe
Normal file
BIN
space4k/link.exe
Normal file
Binary file not shown.
BIN
space4k/msk/bass.4ki
Normal file
BIN
space4k/msk/bass.4ki
Normal file
Binary file not shown.
BIN
space4k/msk/bdrum.4ki
Normal file
BIN
space4k/msk/bdrum.4ki
Normal file
Binary file not shown.
BIN
space4k/msk/hihat-hi.4ki
Normal file
BIN
space4k/msk/hihat-hi.4ki
Normal file
Binary file not shown.
BIN
space4k/msk/hihat-low.4ki
Normal file
BIN
space4k/msk/hihat-low.4ki
Normal file
Binary file not shown.
BIN
space4k/msk/msk.rar
Normal file
BIN
space4k/msk/msk.rar
Normal file
Binary file not shown.
BIN
space4k/msk/new/nightingale.4kp
Normal file
BIN
space4k/msk/new/nightingale.4kp
Normal file
Binary file not shown.
BIN
space4k/msk/new/nightingale.xrns
Normal file
BIN
space4k/msk/new/nightingale.xrns
Normal file
Binary file not shown.
BIN
space4k/msk/nightingale.4kp
Normal file
BIN
space4k/msk/nightingale.4kp
Normal file
Binary file not shown.
BIN
space4k/msk/nightingale.xrns
Normal file
BIN
space4k/msk/nightingale.xrns
Normal file
Binary file not shown.
BIN
space4k/msk/pad.4ki
Normal file
BIN
space4k/msk/pad.4ki
Normal file
Binary file not shown.
BIN
space4k/msk/snare.4ki
Normal file
BIN
space4k/msk/snare.4ki
Normal file
Binary file not shown.
BIN
space4k/nasm.exe
Normal file
BIN
space4k/nasm.exe
Normal file
Binary file not shown.
64
space4k/src/4k.cpp
Normal file
64
space4k/src/4k.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
#ifdef _DEBUG
|
||||
#define D3D_DEBUG_INFO
|
||||
#endif
|
||||
|
||||
#include "includes.h"
|
||||
extern "C" int _fltused = 1;
|
||||
|
||||
#pragma data_seg(".edit")
|
||||
static char* edit = "edit";
|
||||
|
||||
#pragma code_seg(".main")
|
||||
void __cdecl main(void)
|
||||
{
|
||||
_asm
|
||||
{
|
||||
XOR ESI, ESI
|
||||
PUSH ESI
|
||||
PUSH ESI
|
||||
PUSH ESI
|
||||
PUSH ESI
|
||||
PUSH ESI
|
||||
PUSH ESI
|
||||
PUSH HEIGHT
|
||||
PUSH WIDTH
|
||||
PUSH ESI
|
||||
PUSH ESI
|
||||
PUSH WS_VISIBLE
|
||||
PUSH ESI
|
||||
PUSH edit
|
||||
PUSH 0x8
|
||||
CALL dword ptr [CreateWindowExA]
|
||||
MOV dword ptr [wnd], EAX
|
||||
CALL dword ptr [ShowCursor]
|
||||
CALL dword ptr [CreateD3D]
|
||||
CALL dword ptr [InitSound]
|
||||
|
||||
theloop:
|
||||
call dword ptr [get_Time]
|
||||
fstp dword ptr [time]
|
||||
CALL dword ptr [DrawFrame]
|
||||
PUSH VK_ESCAPE
|
||||
CALL dword ptr [GetAsyncKeyState]
|
||||
test eax, eax
|
||||
jz theloop
|
||||
CALL dword ptr [ExitProcess]
|
||||
}
|
||||
// oder static oder EDIT
|
||||
//wnd = CreateWindowEx(WS_EX_TOPMOST, "edit", NULL, WS_POPUP | WS_VISIBLE | WS_MAXIMIZE, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
//wnd = CreateWindowEx(8, "edit", NULL, WS_VISIBLE, 0, 0, WIDTH, HEIGHT, 0, 0, 0, NULL);
|
||||
//d3dPresParas.Windowed = true;
|
||||
//ShowCursor(FALSE);
|
||||
|
||||
//CreateD3D();
|
||||
//InitSound();
|
||||
|
||||
/*while (GetAsyncKeyState(VK_ESCAPE) == 0)
|
||||
{
|
||||
time = get_Time();
|
||||
DrawFrame();
|
||||
}
|
||||
|
||||
ExitProcess(0);*/
|
||||
|
||||
}
|
||||
384
space4k/src/4k.vcproj
Normal file
384
space4k/src/4k.vcproj
Normal file
@@ -0,0 +1,384 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="4k"
|
||||
ProjectGUID="{478863DD-1156-47FF-8AE2-F7A923BB3998}"
|
||||
RootNamespace="My4k"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)bin"
|
||||
IntermediateDirectory="$(SolutionDir)obj\$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
CommandLine=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description=""
|
||||
CommandLine=""
|
||||
Outputs=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
ExceptionHandling="0"
|
||||
RuntimeLibrary="3"
|
||||
FloatingPointModel="2"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
CallingConvention="2"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="opengl32.lib glu32.lib winmm.lib 4klang.obj"
|
||||
OutputFile="$(OutDir)\$(ProjectName)_$(ConfigurationName).exe"
|
||||
GenerateDebugInformation="true"
|
||||
AssemblyDebug="1"
|
||||
ProgramDatabaseFile="$(IntDir)\$(TargetName).pdb"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)bin"
|
||||
IntermediateDirectory="$(SolutionDir)obj\$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
CommandLine=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description=""
|
||||
CommandLine=""
|
||||
Outputs=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="3"
|
||||
WholeProgramOptimization="false"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
ExceptionHandling="0"
|
||||
RuntimeLibrary="2"
|
||||
BufferSecurityCheck="true"
|
||||
FloatingPointModel="2"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="0"
|
||||
CallingConvention="2"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="opengl32.lib glu32.lib winmm.lib 4klang.obj"
|
||||
OutputFile="$(OutDir)\$(ProjectName)_$(ConfigurationName).exe"
|
||||
IgnoreAllDefaultLibraries="false"
|
||||
GenerateDebugInformation="false"
|
||||
SubSystem="0"
|
||||
OptimizeReferences="0"
|
||||
EnableCOMDATFolding="0"
|
||||
LinkTimeCodeGeneration="0"
|
||||
EntryPointSymbol=""
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Tiny|Win32"
|
||||
OutputDirectory="$(SolutionDir)bin"
|
||||
IntermediateDirectory="$(SolutionDir)obj\$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
CommandLine=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description=""
|
||||
CommandLine=""
|
||||
Outputs=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="3"
|
||||
WholeProgramOptimization="false"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
ExceptionHandling="0"
|
||||
RuntimeLibrary="2"
|
||||
BufferSecurityCheck="true"
|
||||
FloatingPointModel="2"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="0"
|
||||
CallingConvention="2"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/CRINKLER /HASHSIZE:200 /HASHTRIES:200 /ORDERTRIES:2000 /COMPMODE:SLOW /REPORT:report.html /PROGRESSGUI"
|
||||
AdditionalDependencies="opengl32.lib glu32.lib winmm.lib 4klang.obj"
|
||||
OutputFile="$(OutDir)\$(ProjectName)_$(ConfigurationName).exe"
|
||||
GenerateManifest="false"
|
||||
IgnoreAllDefaultLibraries="false"
|
||||
GenerateDebugInformation="false"
|
||||
SubSystem="0"
|
||||
OptimizeReferences="0"
|
||||
EnableCOMDATFolding="0"
|
||||
LinkTimeCodeGeneration="0"
|
||||
EntryPointSymbol="main"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="0"
|
||||
ErrorReporting="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Entry Point"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\gl.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Headers"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\4klang.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\config.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\debug.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\demo.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\glext.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\glgraphics.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\glincludes.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\glvariables.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\shaders.h"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Compiling shaders.h"
|
||||
CommandLine=""$(TargetDir)4slang.exe" $(InputDir)world.glsl /out:$(InputPath)
"
|
||||
AdditionalDependencies="shaders.glsl; blur.glsl"
|
||||
Outputs="bla"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Compiling shaders.h"
|
||||
CommandLine=""$(TargetDir)4slang.exe" $(InputDir)world.glsl $(InputDir)blur.glsl $(InputDir)halo.glsl $(InputDir)combine.glsl /out:$(InputPath)
"
|
||||
AdditionalDependencies="shaders.glsl; blur.glsl"
|
||||
Outputs="bla"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Tiny|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="Compiling shaders.h"
|
||||
CommandLine=""$(TargetDir)4slang.exe" $(InputDir)world.glsl $(InputDir)blur.glsl $(InputDir)halo.glsl $(InputDir)combine.glsl /out:$(InputPath)
"
|
||||
AdditionalDependencies="shaders.glsl; blur.glsl"
|
||||
Outputs="bla"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\small.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\synth.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Data"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\world.glsl"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
93
space4k/src/4k.vcproj.FIARA.Frank.user
Normal file
93
space4k/src/4k.vcproj.FIARA.Frank.user
Normal file
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioUserFile
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
ShowAllFiles="false"
|
||||
>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="SHAIKUR"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="SHAIKUR"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Tiny|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="SHAIKUR"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
</VisualStudioUserFile>
|
||||
93
space4k/src/4k.vcproj.Shaikur.Frank.user
Normal file
93
space4k/src/4k.vcproj.Shaikur.Frank.user
Normal file
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioUserFile
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
ShowAllFiles="false"
|
||||
>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="SHAIKUR"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="SHAIKUR"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Tiny|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="SHAIKUR"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
</VisualStudioUserFile>
|
||||
242
space4k/src/4k.vcxproj
Normal file
242
space4k/src/4k.vcxproj
Normal file
@@ -0,0 +1,242 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Tiny|Win32">
|
||||
<Configuration>Tiny</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{478863DD-1156-47FF-8AE2-F7A923BB3998}</ProjectGuid>
|
||||
<RootNamespace>My4k</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Tiny|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Tiny|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)obj\$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)obj\$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Tiny|Win32'">$(SolutionDir)bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Tiny|Win32'">$(SolutionDir)obj\$(Configuration)\</IntDir>
|
||||
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Tiny|Win32'">false</GenerateManifest>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PreBuildEvent>
|
||||
<CustomBuildStep>
|
||||
<Message>
|
||||
</Message>
|
||||
<Command>
|
||||
</Command>
|
||||
<Outputs>%(Outputs)</Outputs>
|
||||
</CustomBuildStep>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ExceptionHandling>
|
||||
</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<CallingConvention>StdCall</CallingConvention>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>opengl32.lib;glu32.lib;winmm.lib;4klang.obj;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(ProjectName)_$(Configuration).exe</OutputFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AssemblyDebug>true</AssemblyDebug>
|
||||
<ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>NotSet</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PreBuildEvent>
|
||||
<CustomBuildStep>
|
||||
<Message>
|
||||
</Message>
|
||||
<Command>
|
||||
</Command>
|
||||
<Outputs>%(Outputs)</Outputs>
|
||||
</CustomBuildStep>
|
||||
<ClCompile>
|
||||
<Optimization>Full</Optimization>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ExceptionHandling>
|
||||
</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>
|
||||
</DebugInformationFormat>
|
||||
<CallingConvention>StdCall</CallingConvention>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>opengl32.lib;glu32.lib;winmm.lib;4klang.obj;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(ProjectName)_$(Configuration).exe</OutputFile>
|
||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>NotSet</SubSystem>
|
||||
<OptimizeReferences>
|
||||
</OptimizeReferences>
|
||||
<EnableCOMDATFolding>
|
||||
</EnableCOMDATFolding>
|
||||
<LinkTimeCodeGeneration>
|
||||
</LinkTimeCodeGeneration>
|
||||
<EntryPointSymbol>
|
||||
</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>NotSet</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Tiny|Win32'">
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PreBuildEvent>
|
||||
<CustomBuildStep>
|
||||
<Message>
|
||||
</Message>
|
||||
<Command>
|
||||
</Command>
|
||||
<Outputs>%(Outputs)</Outputs>
|
||||
</CustomBuildStep>
|
||||
<ClCompile>
|
||||
<Optimization>Full</Optimization>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ExceptionHandling>
|
||||
</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>
|
||||
</DebugInformationFormat>
|
||||
<CallingConvention>StdCall</CallingConvention>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalOptions>/CRINKLER /HASHSIZE:200 /HASHTRIES:200 /ORDERTRIES:2000 /COMPMODE:SLOW /REPORT:report.html /PROGRESSGUI %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalDependencies>opengl32.lib;glu32.lib;winmm.lib;4klang.obj;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>$(OutDir)$(ProjectName)_$(Configuration).exe</OutputFile>
|
||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<SubSystem>NotSet</SubSystem>
|
||||
<OptimizeReferences>
|
||||
</OptimizeReferences>
|
||||
<EnableCOMDATFolding>
|
||||
</EnableCOMDATFolding>
|
||||
<LinkTimeCodeGeneration>
|
||||
</LinkTimeCodeGeneration>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>NotSet</TargetMachine>
|
||||
<LinkErrorReporting>
|
||||
</LinkErrorReporting>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="gl.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="4klang.h" />
|
||||
<ClInclude Include="config.h" />
|
||||
<ClInclude Include="debug.h" />
|
||||
<ClInclude Include="demo.h" />
|
||||
<ClInclude Include="glext.h" />
|
||||
<ClInclude Include="glgraphics.h" />
|
||||
<ClInclude Include="glincludes.h" />
|
||||
<ClInclude Include="glvariables.h" />
|
||||
<CustomBuild Include="shaders.h">
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compiling shaders.h</Message>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(TargetDir)4slang.exe" %(RootDir)%(Directory)world.glsl /out:%(FullPath)
|
||||
</Command>
|
||||
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">shaders.glsl; blur.glsl;%(AdditionalInputs)</AdditionalInputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">bla;%(Outputs)</Outputs>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compiling shaders.h</Message>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(TargetDir)4slang.exe" %(RootDir)%(Directory)world.glsl %(RootDir)%(Directory)blur.glsl %(RootDir)%(Directory)halo.glsl %(RootDir)%(Directory)combine.glsl /out:%(FullPath)
|
||||
</Command>
|
||||
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">shaders.glsl; blur.glsl;%(AdditionalInputs)</AdditionalInputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">bla;%(Outputs)</Outputs>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Tiny|Win32'">Compiling shaders.h</Message>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Tiny|Win32'">"$(TargetDir)4slang.exe" %(RootDir)%(Directory)world.glsl %(RootDir)%(Directory)blur.glsl %(RootDir)%(Directory)halo.glsl %(RootDir)%(Directory)combine.glsl /out:%(FullPath)
|
||||
</Command>
|
||||
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Tiny|Win32'">shaders.glsl; blur.glsl;%(AdditionalInputs)</AdditionalInputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Tiny|Win32'">bla;%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
<ClInclude Include="small.h" />
|
||||
<ClInclude Include="synth.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="world.glsl" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="4slang\4slang.vcxproj">
|
||||
<Project>{e0a366ef-1805-44c7-b644-426fee32b9d9}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
63
space4k/src/4k.vcxproj.filters
Normal file
63
space4k/src/4k.vcxproj.filters
Normal file
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Entry Point">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Headers">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Data">
|
||||
<UniqueIdentifier>{b9740359-42f3-4190-bf64-ba1984c2cbfb}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="gl.cpp">
|
||||
<Filter>Entry Point</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="4klang.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="config.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="debug.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="demo.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="glext.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="glgraphics.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="glincludes.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="glvariables.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="small.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="synth.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="world.glsl">
|
||||
<Filter>Data</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="shaders.h">
|
||||
<Filter>Headers</Filter>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
6
space4k/src/4k.vcxproj.user
Normal file
6
space4k/src/4k.vcxproj.user
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ShowAllFiles>false</ShowAllFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
1452
space4k/src/4klang.asm
Normal file
1452
space4k/src/4klang.asm
Normal file
File diff suppressed because it is too large
Load Diff
22
space4k/src/4klang.h
Normal file
22
space4k/src/4klang.h
Normal file
@@ -0,0 +1,22 @@
|
||||
// some useful song defines for 4klang
|
||||
#define SAMPLE_RATE 44100
|
||||
#define BPM 160.000000
|
||||
#define MAX_INSTRUMENTS 11
|
||||
#define MAX_PATTERNS 97
|
||||
#define PATTERN_SIZE_SHIFT 4
|
||||
#define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT)
|
||||
#define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE)
|
||||
#define SAMPLES_PER_TICK 4134
|
||||
#define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS)
|
||||
#define POLYPHONY 2
|
||||
#define INTEGER_16BIT
|
||||
#define SAMPLE_TYPE short
|
||||
|
||||
#define WINDOWS_OBJECT
|
||||
|
||||
// declaration of the external synth render function, you'll always need that
|
||||
extern "C" void __stdcall _4klang_render(void*);
|
||||
// declaration of the external envelope buffer. access only if you're song was exported with that option
|
||||
extern "C" float _4klang_envelope_buffer;
|
||||
// declaration of the external note buffer. access only if you're song was exported with that option
|
||||
extern "C" int _4klang_note_buffer;
|
||||
924
space4k/src/4klang.inc
Normal file
924
space4k/src/4klang.inc
Normal file
@@ -0,0 +1,924 @@
|
||||
%macro export_func 1
|
||||
global _%1
|
||||
_%1:
|
||||
%endmacro
|
||||
%define USE_SECTIONS
|
||||
%define SAMPLE_RATE 44100
|
||||
%define MAX_INSTRUMENTS 11
|
||||
%define MAX_VOICES 2
|
||||
%define HLD 1
|
||||
%define BPM 172.000000
|
||||
%define MAX_PATTERNS 113
|
||||
%define PATTERN_SIZE_SHIFT 4
|
||||
%define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT)
|
||||
%define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE)
|
||||
%define SAMPLES_PER_TICK 3845
|
||||
%define DEF_LFO_NORMALIZE 0.0000650038
|
||||
%define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS)
|
||||
;%define GO4K_USE_16BIT_OUTPUT
|
||||
;%define GO4K_USE_GROOVE_PATTERN
|
||||
%define GO4K_USE_ENVELOPE_RECORDINGS
|
||||
;%define GO4K_USE_NOTE_RECORDINGS
|
||||
%define GO4K_CLIP_OUTPUT
|
||||
%define GO4K_USE_DST
|
||||
%define GO4K_USE_DLL
|
||||
%define GO4K_USE_PAN
|
||||
%define GO4K_USE_GLOBAL_DLL
|
||||
%define GO4K_USE_ENV_CHECK
|
||||
%define GO4K_USE_ENV_MOD_GM
|
||||
%define GO4K_USE_VCO_CHECK
|
||||
%define GO4K_USE_VCO_PHASE_OFFSET
|
||||
%define GO4K_USE_VCO_SHAPE
|
||||
%define GO4K_USE_VCO_MOD_TM
|
||||
%define GO4K_USE_VCO_MOD_DM
|
||||
%define GO4K_USE_VCO_MOD_GM
|
||||
%define GO4K_USE_VCF_CHECK
|
||||
%define GO4K_USE_VCF_MOD_FM
|
||||
%define GO4K_USE_VCF_HIGH
|
||||
%define GO4K_USE_VCF_BAND
|
||||
%define GO4K_USE_VCF_PEAK
|
||||
%define GO4K_USE_DST_CHECK
|
||||
%define GO4K_USE_DLL_CHORUS_CLAMP
|
||||
%define GO4K_USE_DLL_DAMP
|
||||
%define GO4K_USE_DLL_DC_FILTER
|
||||
%define GO4K_USE_FSTG_CHECK
|
||||
%define GO4K_USE_WAVESHAPER_CLIP
|
||||
%define MAX_DELAY 65536
|
||||
%define MAX_WORKSPACE_SLOTS 8
|
||||
%define GO4K_BEGIN_CMDDEF(def_name)
|
||||
%define GO4K_END_CMDDEF db 0
|
||||
%define GO4K_BEGIN_PARAMDEF(def_name)
|
||||
%define GO4K_END_PARAMDEF
|
||||
GO4K_ENV_ID equ 1
|
||||
%macro GO4K_ENV 5
|
||||
db %1
|
||||
db %2
|
||||
db %3
|
||||
db %4
|
||||
db %5
|
||||
%endmacro
|
||||
%define ATTAC(val) val
|
||||
%define DECAY(val) val
|
||||
%define SUSTAIN(val) val
|
||||
%define RELEASE(val) val
|
||||
%define GAIN(val) val
|
||||
struc go4kENV_val
|
||||
.attac resd 1
|
||||
.decay resd 1
|
||||
.sustain resd 1
|
||||
.release resd 1
|
||||
.gain resd 1
|
||||
.size
|
||||
endstruc
|
||||
struc go4kENV_wrk
|
||||
.state resd 1
|
||||
.level resd 1
|
||||
.gm resd 1
|
||||
.am resd 1
|
||||
.dm resd 1
|
||||
.sm resd 1
|
||||
.rm resd 1
|
||||
.size
|
||||
endstruc
|
||||
%define ENV_STATE_ATTAC 0
|
||||
%define ENV_STATE_DECAY 1
|
||||
%define ENV_STATE_SUSTAIN 2
|
||||
%define ENV_STATE_RELEASE 3
|
||||
%define ENV_STATE_OFF 4
|
||||
GO4K_VCO_ID equ 2
|
||||
%macro GO4K_VCO 8
|
||||
db %1
|
||||
db %2
|
||||
%ifdef GO4K_USE_VCO_PHASE_OFFSET
|
||||
db %3
|
||||
%endif
|
||||
%ifdef GO4K_USE_VCO_GATE
|
||||
db %4
|
||||
%endif
|
||||
db %5
|
||||
%ifdef GO4K_USE_VCO_SHAPE
|
||||
db %6
|
||||
%endif
|
||||
db %7
|
||||
db %8
|
||||
%endmacro
|
||||
%define TRANSPOSE(val) val
|
||||
%define DETUNE(val) val
|
||||
%define PHASE(val) val
|
||||
%define GATES(val) val
|
||||
%define COLOR(val) val
|
||||
%define SHAPE(val) val
|
||||
%define FLAGS(val) val
|
||||
%define SINE 0x01
|
||||
%define TRISAW 0x02
|
||||
%define PULSE 0x04
|
||||
%define NOISE 0x08
|
||||
%define LFO 0x10
|
||||
%define GATE 0x20
|
||||
struc go4kVCO_val
|
||||
.transpose resd 1
|
||||
.detune resd 1
|
||||
%ifdef GO4K_USE_VCO_PHASE_OFFSET
|
||||
.phaseofs resd 1
|
||||
%endif
|
||||
%ifdef GO4K_USE_VCO_GATE
|
||||
.gate resd 1
|
||||
%endif
|
||||
.color resd 1
|
||||
%ifdef GO4K_USE_VCO_SHAPE
|
||||
.shape resd 1
|
||||
%endif
|
||||
.gain resd 1
|
||||
.flags resd 1
|
||||
.size
|
||||
endstruc
|
||||
struc go4kVCO_wrk
|
||||
.phase resd 1
|
||||
.tm resd 1
|
||||
.dm resd 1
|
||||
.fm resd 1
|
||||
.pm resd 1
|
||||
.cm resd 1
|
||||
.sm resd 1
|
||||
.gm resd 1
|
||||
.size
|
||||
endstruc
|
||||
GO4K_VCF_ID equ 3
|
||||
%macro GO4K_VCF 3
|
||||
db %1
|
||||
db %2
|
||||
db %3
|
||||
%endmacro
|
||||
%define LOWPASS 0x1
|
||||
%define HIGHPASS 0x2
|
||||
%define BANDPASS 0x4
|
||||
%define BANDSTOP 0x3
|
||||
%define ALLPASS 0x7
|
||||
%define PEAK 0x8
|
||||
%define FREQUENCY(val) val
|
||||
%define RESONANCE(val) val
|
||||
%define VCFTYPE(val) val
|
||||
struc go4kVCF_val
|
||||
.freq resd 1
|
||||
.res resd 1
|
||||
.type resd 1
|
||||
.size
|
||||
endstruc
|
||||
struc go4kVCF_wrk
|
||||
.low resd 1
|
||||
.high resd 1
|
||||
.band resd 1
|
||||
.freq resd 1
|
||||
.fm resd 1
|
||||
.rm resd 1
|
||||
.size
|
||||
endstruc
|
||||
GO4K_DST_ID equ 4
|
||||
%macro GO4K_DST 2
|
||||
db %1
|
||||
%ifdef GO4K_USE_DST_SH
|
||||
db %2
|
||||
%endif
|
||||
%endmacro
|
||||
%define DRIVE(val) val
|
||||
%define SNHFREQ(val) val
|
||||
struc go4kDST_val
|
||||
.drive resd 1
|
||||
%ifdef GO4K_USE_DST_SH
|
||||
.snhfreq resd 1
|
||||
%endif
|
||||
.size
|
||||
endstruc
|
||||
struc go4kDST_wrk
|
||||
%ifdef GO4K_USE_DST_SH
|
||||
.out resd 1
|
||||
.snhphase resd 1
|
||||
%endif
|
||||
.dm resd 1
|
||||
.sm resd 1
|
||||
.size
|
||||
endstruc
|
||||
GO4K_DLL_ID equ 5
|
||||
%macro GO4K_DLL 8
|
||||
db %1
|
||||
db %2
|
||||
db %3
|
||||
%ifdef GO4K_USE_DLL_DAMP
|
||||
db %4
|
||||
%endif
|
||||
%ifdef GO4K_USE_DLL_CHORUS
|
||||
db %5
|
||||
db %6
|
||||
%endif
|
||||
db %7
|
||||
db %8
|
||||
%endmacro
|
||||
%define PREGAIN(val) val
|
||||
%define DRY(val) val
|
||||
%define FEEDBACK(val) val
|
||||
%define DEPTH(val) val
|
||||
%define DAMP(val) val
|
||||
%define DELAY(val) val
|
||||
%define COUNT(val) val
|
||||
struc go4kDLL_val
|
||||
.pregain resd 1
|
||||
.dry resd 1
|
||||
.feedback resd 1
|
||||
%ifdef GO4K_USE_DLL_DAMP
|
||||
.damp resd 1
|
||||
%endif
|
||||
%ifdef GO4K_USE_DLL_CHORUS
|
||||
.freq resd 1
|
||||
.depth
|
||||
%endif
|
||||
.delay resd 1
|
||||
.count resd 1
|
||||
.size
|
||||
endstruc
|
||||
struc go4kDLL_wrk
|
||||
.index resd 1
|
||||
.store resd 1
|
||||
.dcin resd 1
|
||||
.dcout resd 1
|
||||
%ifdef GO4K_USE_DLL_CHORUS
|
||||
.phase resd 1
|
||||
%endif
|
||||
.buffer resd MAX_DELAY
|
||||
.size
|
||||
endstruc
|
||||
GO4K_FOP_ID equ 6
|
||||
%macro GO4K_FOP 1
|
||||
db %1
|
||||
%endmacro
|
||||
%define OP(val) val
|
||||
%define FOP_POP 0x1
|
||||
%define FOP_ADDP 0x2
|
||||
%define FOP_MULP 0x3
|
||||
%define FOP_PUSH 0x4
|
||||
%define FOP_XCH 0x5
|
||||
%define FOP_ADD 0x6
|
||||
%define FOP_MUL 0x7
|
||||
%define FOP_ADDP2 0x8
|
||||
%define FOP_LOADNOTE 0x9
|
||||
struc go4kFOP_val
|
||||
.flags resd 1
|
||||
.size
|
||||
endstruc
|
||||
struc go4kFOP_wrk
|
||||
.size
|
||||
endstruc
|
||||
GO4K_FST_ID equ 7
|
||||
%macro GO4K_FST 2
|
||||
db %1
|
||||
db %2
|
||||
%endmacro
|
||||
%define AMOUNT(val) val
|
||||
%define DEST(val) val
|
||||
struc go4kFST_val
|
||||
.amount resd 1
|
||||
.op1 resd 1
|
||||
.size
|
||||
endstruc
|
||||
struc go4kFST_wrk
|
||||
.size
|
||||
endstruc
|
||||
GO4K_PAN_ID equ 8
|
||||
%macro GO4K_PAN 1
|
||||
%ifdef GO4K_USE_PAN
|
||||
db %1
|
||||
%endif
|
||||
%endmacro
|
||||
%define PANNING(val) val
|
||||
struc go4kPAN_val
|
||||
%ifdef GO4K_USE_PAN
|
||||
.panning resd 1
|
||||
%endif
|
||||
.size
|
||||
endstruc
|
||||
struc go4kPAN_wrk
|
||||
.pm resd 1
|
||||
.size
|
||||
endstruc
|
||||
GO4K_OUT_ID equ 9
|
||||
%macro GO4K_OUT 2
|
||||
db %1
|
||||
%ifdef GO4K_USE_GLOBAL_DLL
|
||||
db %2
|
||||
%endif
|
||||
%endmacro
|
||||
%define AUXSEND(val) val
|
||||
struc go4kOUT_val
|
||||
.gain resd 1
|
||||
%ifdef GO4K_USE_GLOBAL_DLL
|
||||
.auxsend resd 1
|
||||
%endif
|
||||
.size
|
||||
endstruc
|
||||
struc go4kOUT_wrk
|
||||
.am resd 1
|
||||
.gm resd 1
|
||||
.size
|
||||
endstruc
|
||||
GO4K_ACC_ID equ 10
|
||||
%macro GO4K_ACC 1
|
||||
db %1
|
||||
%endmacro
|
||||
%define OUTPUT 0
|
||||
%define AUX 8
|
||||
%define ACCTYPE(val) val
|
||||
struc go4kACC_val
|
||||
.acctype resd 1
|
||||
.size
|
||||
endstruc
|
||||
struc go4kACC_wrk
|
||||
.size
|
||||
endstruc
|
||||
%ifdef GO4K_USE_FSTG
|
||||
GO4K_FSTG_ID equ 11
|
||||
%macro GO4K_FSTG 2
|
||||
db %1
|
||||
dd %2
|
||||
%endmacro
|
||||
struc go4kFSTG_val
|
||||
.amount resd 1
|
||||
.op1 resd 1
|
||||
.size
|
||||
endstruc
|
||||
struc go4kFSTG_wrk
|
||||
.size
|
||||
endstruc
|
||||
%endif
|
||||
%ifdef GO4K_USE_FSTG
|
||||
%define NUM_COMMANDS 12
|
||||
%else
|
||||
%define NUM_COMMANDS 11
|
||||
%endif
|
||||
struc go4k_instrument
|
||||
.release resd 1
|
||||
.note resd 1
|
||||
.workspace resd 256
|
||||
.dlloutl resd 1
|
||||
.dlloutr resd 1
|
||||
.outl resd 1
|
||||
.outr resd 1
|
||||
.size
|
||||
endstruc
|
||||
struc go4k_synth
|
||||
.instruments resb go4k_instrument.size * MAX_INSTRUMENTS * MAX_VOICES
|
||||
.global resb go4k_instrument.size * MAX_VOICES
|
||||
.size
|
||||
endstruc
|
||||
%ifdef USE_SECTIONS
|
||||
section .g4kmuc1 data align=1
|
||||
%else
|
||||
section .data align=1
|
||||
%endif
|
||||
go4k_patterns
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
db 37, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 44, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 42, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 68, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 71, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 66, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 69, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 90, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 92, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 89, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 85, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 80, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 87, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 95, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 85, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 87, HLD,
|
||||
db 95, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 94, HLD,
|
||||
db 97, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 94, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 65, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 75, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 73, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 77, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 78, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 0, 0, 0, 0, 60, 0, 0, 0, 60, 0, 0, 0, 0, 0, 60, 0,
|
||||
db 60, 0, 60, 0, 60, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, 0,
|
||||
db 0, 0, 60, 0, 60, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, 0,
|
||||
db 0, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 60, 0, 0, 0,
|
||||
db 60, 0, 60, 60, 0, 0, 60, 0, 0, 0, 60, 0, 60, 0, 0, 0,
|
||||
db 0, 0, 0, 60, 0, 0, 60, 0, 0, 0, 60, 0, 60, 0, 60, 0,
|
||||
db 60, 0, 0, 0, 0, 0, 60, 0, 0, 0, 60, 0, 60, 0, 60, 0,
|
||||
db 60, 0, 60, 60, 0, 0, 60, 0, 60, 0, 0, 0, 0, 0, 0, 0,
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, 48, HLD, HLD, HLD, HLD, HLD, 48, HLD,
|
||||
db HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 48, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 48, HLD, HLD, HLD, HLD, HLD, 48, HLD,
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, 60, HLD, HLD, HLD, 0, 0, 0, 0,
|
||||
db 60, HLD, HLD, HLD, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
db 60, HLD, HLD, HLD, 0, 0, 60, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0,
|
||||
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 0, 49, 0,
|
||||
db 49, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 49, 0, 0, 0,
|
||||
db 49, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 47, 0, 44, 0,
|
||||
db 37, 0, 37, 0, 0, 0, 49, 0, 0, 0, 0, 0, 49, 0, 0, 0,
|
||||
db 44, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 44, 0, 0, 0,
|
||||
db 44, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 54, 0, 51, 0,
|
||||
db 44, 0, 44, 0, 0, 0, 56, 0, 0, 0, 0, 0, 44, 0, 0, 0,
|
||||
db 42, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 42, 0, 0, 0,
|
||||
db 42, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 52, 0, 49, 0,
|
||||
db 42, 0, 42, 0, 0, 0, 54, 0, 0, 0, 0, 0, 42, 0, 0, 0,
|
||||
db 49, HLD, 49, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 49, 0, 61, HLD,
|
||||
db 49, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 61, 0, 47, 0, 44, 0,
|
||||
db 37, 0, 37, 0, 0, 0, 49, 0, 0, 0, 59, 0, 49, 0, 49, 0,
|
||||
db 49, 0, 0, 0, 61, 0, 0, 0, 0, 0, 61, 0, 47, 0, 44, 0,
|
||||
db 44, HLD, 44, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 44, 0, 56, HLD,
|
||||
db 44, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 56, 0, 54, 0, 51, 0,
|
||||
db 44, 0, 44, 0, 0, 0, 56, 0, 0, 0, 54, 0, 44, 0, 44, 0,
|
||||
db 44, 0, 0, 0, 56, 0, 0, 0, 0, 0, 56, 0, 54, 0, 51, 0,
|
||||
db 42, HLD, 42, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 42, 0, 54, HLD,
|
||||
db 42, HLD, HLD, HLD, HLD, HLD, 0, 0, 0, 0, 54, 0, 52, 0, 49, 0,
|
||||
db 42, 0, 42, 0, 0, 0, 54, 0, 0, 0, 52, 0, 42, 0, 42, 0,
|
||||
db 42, 0, 0, 0, 54, 0, 0, 0, 0, 0, 54, 0, 52, 0, 49, 0,
|
||||
db 73, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 75, HLD,
|
||||
db 83, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, 82, HLD,
|
||||
db 83, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 82, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 81, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
db 60, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD, HLD,
|
||||
go4k_patterns_end
|
||||
%ifdef USE_SECTIONS
|
||||
section .g4kmuc2 data align=1
|
||||
%else
|
||||
section .data
|
||||
%endif
|
||||
go4k_pattern_lists
|
||||
Instrument0List db 1, 2, 2, 2, 2, 2, 3, 2, 2, 2, 1, 2, 2, 2, 4, 2, 2, 2, 1, 2, 2, 2, 3, 2, 2, 2, 1, 2, 2, 2, 4, 2, 2, 2, 1, 2, 2, 2, 3, 2, 2, 2, 1, 2, 2, 2, 4, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 3, 2, 2, 2, 1, 2, 2, 2, 4, 2, 2, 2, 4, 2, 2, 2, 1, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0,
|
||||
Instrument1List db 5, 2, 2, 2, 2, 2, 6, 2, 2, 2, 5, 2, 2, 2, 7, 2, 2, 2, 5, 2, 2, 2, 6, 2, 2, 2, 5, 2, 2, 2, 8, 2, 2, 2, 5, 2, 2, 2, 6, 2, 2, 2, 5, 2, 2, 2, 7, 2, 2, 2, 5, 2, 2, 2, 6, 2, 2, 2, 5, 2, 2, 2, 8, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 2, 2, 2, 7, 2, 2, 2, 8, 2, 2, 2, 5, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0,
|
||||
Instrument2List db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 10, 11, 12, 13, 14, 2, 15, 2, 10, 2, 12, 2, 9, 2, 0, 0, 0, 0, 16, 11, 14, 2, 17, 10, 2, 2, 14, 11, 9, 18, 15, 19, 10, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
Instrument3List db 20, 2, 2, 2, 2, 2, 21, 2, 2, 2, 22, 2, 2, 2, 22, 2, 2, 2, 23, 2, 2, 2, 21, 2, 2, 2, 23, 2, 2, 2, 24, 2, 2, 2, 22, 2, 2, 2, 21, 2, 2, 2, 22, 2, 2, 2, 22, 2, 2, 2, 23, 2, 2, 2, 21, 2, 2, 2, 23, 2, 2, 2, 24, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 2, 2, 2, 22, 2, 2, 2, 22, 2, 2, 2, 23, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0,
|
||||
Instrument4List db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 0, 0, 0, 0, 0, 0, 0, 28, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 27, 26, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
Instrument5List db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 0, 0, 0, 0, 0, 0, 0, 32, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
Instrument6List db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 34, 34, 35, 34, 34, 34, 35, 34, 34, 34, 35, 34, 34, 34, 35, 34, 34, 34, 35, 34, 34, 34, 35, 34, 34, 34, 35, 34, 34, 34, 35, 34, 34, 34, 35, 34, 34, 34, 35, 34, 34, 34, 35, 34, 34, 34, 35, 34, 34, 34, 35, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0,
|
||||
Instrument7List db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 37, 37, 37, 38, 37, 37, 37, 38, 37, 37, 37, 38, 37, 37, 37, 38, 37, 37, 37, 38, 37, 37, 37, 38, 37, 37, 37, 38, 37, 37, 37, 38, 37, 37, 37, 38, 37, 37, 37, 38, 37, 37, 37, 38, 37, 37, 37, 38, 37, 37, 37, 38, 37, 37, 37, 38, 37, 37, 37, 38, 37, 37, 37, 38, 37, 37, 37, 38, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
Instrument8List db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 40, 41, 42, 41, 43, 44, 45, 44, 40, 41, 42, 41, 46, 47, 48, 47, 40, 41, 42, 41, 43, 44, 45, 44, 40, 41, 42, 41, 43, 44, 45, 44, 49, 50, 51, 52, 53, 54, 55, 56, 49, 50, 51, 52, 57, 58, 59, 60, 4, 2, 2, 2, 1, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0,
|
||||
Instrument9List db 0, 0, 61, 23, 2, 13, 62, 13, 2, 21, 24, 23, 2, 12, 63, 2, 64, 2, 13, 2, 2, 12, 62, 13, 2, 24, 2, 23, 2, 22, 2, 2, 2, 2, 61, 23, 2, 13, 62, 13, 2, 21, 24, 23, 2, 12, 63, 2, 64, 2, 13, 2, 2, 12, 62, 13, 2, 24, 2, 23, 2, 22, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 23, 24, 0, 24, 13, 65, 2, 14, 9, 11, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0,
|
||||
Instrument10List db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 66, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 66, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
go4k_pattern_lists_end
|
||||
%ifdef USE_SECTIONS
|
||||
section .g4kmuc3 data align=1
|
||||
%else
|
||||
section .data
|
||||
%endif
|
||||
go4k_synth_instructions
|
||||
GO4K_BEGIN_CMDDEF(Instrument0)
|
||||
db GO4K_ENV_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_FST_ID
|
||||
db GO4K_FST_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_PAN_ID
|
||||
db GO4K_OUT_ID
|
||||
GO4K_END_CMDDEF
|
||||
GO4K_BEGIN_CMDDEF(Instrument1)
|
||||
db GO4K_ENV_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_FST_ID
|
||||
db GO4K_FST_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_DST_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_DLL_ID
|
||||
db GO4K_PAN_ID
|
||||
db GO4K_OUT_ID
|
||||
GO4K_END_CMDDEF
|
||||
GO4K_BEGIN_CMDDEF(Instrument2)
|
||||
db GO4K_ENV_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_FST_ID
|
||||
db GO4K_FST_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_DST_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_DLL_ID
|
||||
db GO4K_PAN_ID
|
||||
db GO4K_OUT_ID
|
||||
GO4K_END_CMDDEF
|
||||
GO4K_BEGIN_CMDDEF(Instrument3)
|
||||
db GO4K_ENV_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_FST_ID
|
||||
db GO4K_FST_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_DST_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_DLL_ID
|
||||
db GO4K_PAN_ID
|
||||
db GO4K_OUT_ID
|
||||
GO4K_END_CMDDEF
|
||||
GO4K_BEGIN_CMDDEF(Instrument4)
|
||||
db GO4K_ENV_ID
|
||||
db GO4K_ENV_ID
|
||||
db GO4K_FST_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_DLL_ID
|
||||
db GO4K_PAN_ID
|
||||
db GO4K_OUT_ID
|
||||
GO4K_END_CMDDEF
|
||||
GO4K_BEGIN_CMDDEF(Instrument5)
|
||||
db GO4K_ENV_ID
|
||||
db GO4K_ENV_ID
|
||||
db GO4K_FST_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_DLL_ID
|
||||
db GO4K_PAN_ID
|
||||
db GO4K_OUT_ID
|
||||
GO4K_END_CMDDEF
|
||||
GO4K_BEGIN_CMDDEF(Instrument6)
|
||||
db GO4K_ENV_ID
|
||||
db GO4K_ENV_ID
|
||||
db GO4K_FST_ID
|
||||
db GO4K_FST_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_PAN_ID
|
||||
db GO4K_OUT_ID
|
||||
GO4K_END_CMDDEF
|
||||
GO4K_BEGIN_CMDDEF(Instrument7)
|
||||
db GO4K_ENV_ID
|
||||
db GO4K_FST_ID
|
||||
db GO4K_ENV_ID
|
||||
db GO4K_DST_ID
|
||||
db GO4K_FST_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_PAN_ID
|
||||
db GO4K_OUT_ID
|
||||
GO4K_END_CMDDEF
|
||||
GO4K_BEGIN_CMDDEF(Instrument8)
|
||||
db GO4K_ENV_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_FST_ID
|
||||
db GO4K_FST_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_PAN_ID
|
||||
db GO4K_OUT_ID
|
||||
GO4K_END_CMDDEF
|
||||
GO4K_BEGIN_CMDDEF(Instrument9)
|
||||
db GO4K_ENV_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_FST_ID
|
||||
db GO4K_FST_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_DST_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_DLL_ID
|
||||
db GO4K_PAN_ID
|
||||
db GO4K_OUT_ID
|
||||
GO4K_END_CMDDEF
|
||||
GO4K_BEGIN_CMDDEF(Instrument10)
|
||||
db GO4K_ENV_ID
|
||||
db GO4K_FST_ID
|
||||
db GO4K_FST_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_FST_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_VCO_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_PAN_ID
|
||||
db GO4K_OUT_ID
|
||||
GO4K_END_CMDDEF
|
||||
GO4K_BEGIN_CMDDEF(Global)
|
||||
db GO4K_ACC_ID
|
||||
db GO4K_DLL_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_DLL_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_ACC_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_VCF_ID
|
||||
db GO4K_FOP_ID
|
||||
db GO4K_OUT_ID
|
||||
GO4K_END_CMDDEF
|
||||
go4k_synth_instructions_end
|
||||
%ifdef USE_SECTIONS
|
||||
section .g4kmuc4 data align=1
|
||||
%else
|
||||
section .data
|
||||
%endif
|
||||
go4k_synth_parameter_values
|
||||
GO4K_BEGIN_PARAMDEF(Instrument0)
|
||||
GO4K_ENV ATTAC(80),DECAY(128),SUSTAIN(40),RELEASE(80),GAIN(128)
|
||||
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(48),GATES(85),COLOR(97),SHAPE(112),GAIN(128),FLAGS(PULSE)
|
||||
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(64),GATES(85),COLOR(8),SHAPE(120),GAIN(128),FLAGS(TRISAW)
|
||||
GO4K_VCO TRANSPOSE(28),DETUNE(64),PHASE(0),GATES(85),COLOR(64),SHAPE(90),GAIN(128),FLAGS(SINE|LFO)
|
||||
GO4K_FST AMOUNT(72),DEST(1*MAX_WORKSPACE_SLOTS+2)
|
||||
GO4K_FST AMOUNT(56),DEST(2*MAX_WORKSPACE_SLOTS+2)
|
||||
GO4K_FOP OP(FOP_POP)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_FOP OP(FOP_MULP)
|
||||
GO4K_VCF FREQUENCY(16),RESONANCE(64),VCFTYPE(PEAK)
|
||||
GO4K_VCF FREQUENCY(48),RESONANCE(64),VCFTYPE(LOWPASS)
|
||||
GO4K_FOP OP(FOP_PUSH)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_PAN PANNING(88)
|
||||
GO4K_OUT GAIN(24), AUXSEND(16)
|
||||
GO4K_END_PARAMDEF
|
||||
GO4K_BEGIN_PARAMDEF(Instrument1)
|
||||
GO4K_ENV ATTAC(80),DECAY(96),SUSTAIN(96),RELEASE(88),GAIN(128)
|
||||
GO4K_VCO TRANSPOSE(16),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
|
||||
GO4K_FST AMOUNT(73),DEST(14*MAX_WORKSPACE_SLOTS+4)
|
||||
GO4K_FST AMOUNT(65),DEST(7*MAX_WORKSPACE_SLOTS+2)
|
||||
GO4K_FOP OP(FOP_POP)
|
||||
GO4K_VCO TRANSPOSE(64),DETUNE(68),PHASE(64),GATES(0),COLOR(96),SHAPE(112),GAIN(128),FLAGS(TRISAW)
|
||||
GO4K_VCO TRANSPOSE(64),DETUNE(60),PHASE(0),GATES(0),COLOR(96),SHAPE(112),GAIN(128),FLAGS(TRISAW)
|
||||
GO4K_VCO TRANSPOSE(76),DETUNE(64),PHASE(0),GATES(0),COLOR(48),SHAPE(80),GAIN(128),FLAGS(TRISAW)
|
||||
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(64),GAIN(128),FLAGS(SINE)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_DST DRIVE(32), SNHFREQ(128)
|
||||
GO4K_FOP OP(FOP_MULP)
|
||||
GO4K_VCF FREQUENCY(64),RESONANCE(64),VCFTYPE(BANDSTOP)
|
||||
GO4K_VCF FREQUENCY(96),RESONANCE(64),VCFTYPE(LOWPASS)
|
||||
GO4K_DLL PREGAIN(64),DRY(128),FEEDBACK(64),DAMP(64),FREQUENCY(0),DEPTH(0),DELAY(16),COUNT(1)
|
||||
GO4K_PAN PANNING(52)
|
||||
GO4K_OUT GAIN(48), AUXSEND(24)
|
||||
GO4K_END_PARAMDEF
|
||||
GO4K_BEGIN_PARAMDEF(Instrument2)
|
||||
GO4K_ENV ATTAC(72),DECAY(96),SUSTAIN(96),RELEASE(88),GAIN(128)
|
||||
GO4K_VCO TRANSPOSE(16),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
|
||||
GO4K_FST AMOUNT(73),DEST(14*MAX_WORKSPACE_SLOTS+4)
|
||||
GO4K_FST AMOUNT(65),DEST(7*MAX_WORKSPACE_SLOTS+2)
|
||||
GO4K_FOP OP(FOP_POP)
|
||||
GO4K_VCO TRANSPOSE(64),DETUNE(68),PHASE(64),GATES(0),COLOR(96),SHAPE(112),GAIN(128),FLAGS(TRISAW)
|
||||
GO4K_VCO TRANSPOSE(64),DETUNE(60),PHASE(0),GATES(0),COLOR(96),SHAPE(112),GAIN(128),FLAGS(TRISAW)
|
||||
GO4K_VCO TRANSPOSE(76),DETUNE(64),PHASE(0),GATES(0),COLOR(48),SHAPE(80),GAIN(128),FLAGS(TRISAW)
|
||||
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(64),GAIN(128),FLAGS(SINE)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_DST DRIVE(32), SNHFREQ(128)
|
||||
GO4K_FOP OP(FOP_MULP)
|
||||
GO4K_VCF FREQUENCY(64),RESONANCE(64),VCFTYPE(BANDSTOP)
|
||||
GO4K_VCF FREQUENCY(96),RESONANCE(64),VCFTYPE(LOWPASS)
|
||||
GO4K_DLL PREGAIN(64),DRY(128),FEEDBACK(64),DAMP(64),FREQUENCY(0),DEPTH(0),DELAY(16),COUNT(1)
|
||||
GO4K_PAN PANNING(32)
|
||||
GO4K_OUT GAIN(48), AUXSEND(32)
|
||||
GO4K_END_PARAMDEF
|
||||
GO4K_BEGIN_PARAMDEF(Instrument3)
|
||||
GO4K_ENV ATTAC(80),DECAY(96),SUSTAIN(96),RELEASE(88),GAIN(128)
|
||||
GO4K_VCO TRANSPOSE(16),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
|
||||
GO4K_FST AMOUNT(73),DEST(14*MAX_WORKSPACE_SLOTS+4)
|
||||
GO4K_FST AMOUNT(65),DEST(7*MAX_WORKSPACE_SLOTS+2)
|
||||
GO4K_FOP OP(FOP_POP)
|
||||
GO4K_VCO TRANSPOSE(64),DETUNE(68),PHASE(64),GATES(0),COLOR(96),SHAPE(112),GAIN(128),FLAGS(TRISAW)
|
||||
GO4K_VCO TRANSPOSE(64),DETUNE(60),PHASE(0),GATES(0),COLOR(96),SHAPE(112),GAIN(128),FLAGS(TRISAW)
|
||||
GO4K_VCO TRANSPOSE(76),DETUNE(64),PHASE(0),GATES(0),COLOR(48),SHAPE(80),GAIN(128),FLAGS(TRISAW)
|
||||
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(64),GAIN(128),FLAGS(SINE)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_DST DRIVE(32), SNHFREQ(128)
|
||||
GO4K_FOP OP(FOP_MULP)
|
||||
GO4K_VCF FREQUENCY(64),RESONANCE(64),VCFTYPE(BANDSTOP)
|
||||
GO4K_VCF FREQUENCY(96),RESONANCE(64),VCFTYPE(LOWPASS)
|
||||
GO4K_DLL PREGAIN(64),DRY(128),FEEDBACK(64),DAMP(64),FREQUENCY(0),DEPTH(0),DELAY(16),COUNT(1)
|
||||
GO4K_PAN PANNING(76)
|
||||
GO4K_OUT GAIN(48), AUXSEND(24)
|
||||
GO4K_END_PARAMDEF
|
||||
GO4K_BEGIN_PARAMDEF(Instrument4)
|
||||
GO4K_ENV ATTAC(20),DECAY(57),SUSTAIN(29),RELEASE(81),GAIN(128)
|
||||
GO4K_ENV ATTAC(64),DECAY(128),SUSTAIN(128),RELEASE(128),GAIN(128)
|
||||
GO4K_FST AMOUNT(32),DEST(0*MAX_WORKSPACE_SLOTS+2)
|
||||
GO4K_FOP OP(FOP_POP)
|
||||
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(64),GAIN(128),FLAGS(NOISE)
|
||||
GO4K_VCF FREQUENCY(88),RESONANCE(48),VCFTYPE(PEAK)
|
||||
GO4K_FOP OP(FOP_MULP)
|
||||
GO4K_DLL PREGAIN(64),DRY(128),FEEDBACK(0),DAMP(0),FREQUENCY(0),DEPTH(0),DELAY(17),COUNT(1)
|
||||
GO4K_PAN PANNING(72)
|
||||
GO4K_OUT GAIN(96), AUXSEND(48)
|
||||
GO4K_END_PARAMDEF
|
||||
GO4K_BEGIN_PARAMDEF(Instrument5)
|
||||
GO4K_ENV ATTAC(20),DECAY(57),SUSTAIN(29),RELEASE(81),GAIN(128)
|
||||
GO4K_ENV ATTAC(64),DECAY(128),SUSTAIN(128),RELEASE(128),GAIN(128)
|
||||
GO4K_FST AMOUNT(32),DEST(0*MAX_WORKSPACE_SLOTS+2)
|
||||
GO4K_FOP OP(FOP_POP)
|
||||
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(64),GAIN(128),FLAGS(NOISE)
|
||||
GO4K_VCF FREQUENCY(88),RESONANCE(48),VCFTYPE(PEAK)
|
||||
GO4K_FOP OP(FOP_MULP)
|
||||
GO4K_DLL PREGAIN(64),DRY(128),FEEDBACK(64),DAMP(64),FREQUENCY(0),DEPTH(0),DELAY(18),COUNT(1)
|
||||
GO4K_PAN PANNING(72)
|
||||
GO4K_OUT GAIN(48), AUXSEND(24)
|
||||
GO4K_END_PARAMDEF
|
||||
GO4K_BEGIN_PARAMDEF(Instrument6)
|
||||
GO4K_ENV ATTAC(0),DECAY(128),SUSTAIN(128),RELEASE(64),GAIN(128)
|
||||
GO4K_ENV ATTAC(0),DECAY(92),SUSTAIN(0),RELEASE(64),GAIN(128)
|
||||
GO4K_FST AMOUNT(72),DEST(11*MAX_WORKSPACE_SLOTS+7)
|
||||
GO4K_FST AMOUNT(128),DEST(1*MAX_WORKSPACE_SLOTS+2)
|
||||
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(85),COLOR(64),SHAPE(64),GAIN(32),FLAGS(NOISE)
|
||||
GO4K_FOP OP(FOP_MULP)
|
||||
GO4K_FOP OP(FOP_PUSH)
|
||||
GO4K_VCF FREQUENCY(48),RESONANCE(64),VCFTYPE(LOWPASS)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_FOP OP(FOP_MULP)
|
||||
GO4K_VCF FREQUENCY(48),RESONANCE(128),VCFTYPE(BANDPASS)
|
||||
GO4K_VCO TRANSPOSE(71),DETUNE(128),PHASE(0),GATES(0),COLOR(40),SHAPE(80),GAIN(0),FLAGS(SINE)
|
||||
GO4K_VCF FREQUENCY(24),RESONANCE(64),VCFTYPE(HIGHPASS)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_PAN PANNING(52)
|
||||
GO4K_OUT GAIN(48), AUXSEND(2)
|
||||
GO4K_END_PARAMDEF
|
||||
GO4K_BEGIN_PARAMDEF(Instrument7)
|
||||
GO4K_ENV ATTAC(0),DECAY(64),SUSTAIN(112),RELEASE(64),GAIN(128)
|
||||
GO4K_FST AMOUNT(128),DEST(0*MAX_WORKSPACE_SLOTS+2)
|
||||
GO4K_ENV ATTAC(0),DECAY(70),SUSTAIN(0),RELEASE(0),GAIN(128)
|
||||
GO4K_DST DRIVE(32), SNHFREQ(128)
|
||||
GO4K_FST AMOUNT(80),DEST(6*MAX_WORKSPACE_SLOTS+1)
|
||||
GO4K_FOP OP(FOP_POP)
|
||||
GO4K_VCO TRANSPOSE(45),DETUNE(64),PHASE(0),GATES(85),COLOR(64),SHAPE(66),GAIN(128),FLAGS(SINE)
|
||||
GO4K_FOP OP(FOP_MULP)
|
||||
GO4K_PAN PANNING(76)
|
||||
GO4K_OUT GAIN(64), AUXSEND(0)
|
||||
GO4K_END_PARAMDEF
|
||||
GO4K_BEGIN_PARAMDEF(Instrument8)
|
||||
GO4K_ENV ATTAC(0),DECAY(128),SUSTAIN(40),RELEASE(64),GAIN(128)
|
||||
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(48),GATES(85),COLOR(97),SHAPE(112),GAIN(128),FLAGS(PULSE)
|
||||
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(64),GATES(85),COLOR(8),SHAPE(120),GAIN(128),FLAGS(TRISAW)
|
||||
GO4K_VCO TRANSPOSE(28),DETUNE(64),PHASE(0),GATES(85),COLOR(64),SHAPE(90),GAIN(128),FLAGS(SINE|LFO)
|
||||
GO4K_FST AMOUNT(72),DEST(1*MAX_WORKSPACE_SLOTS+2)
|
||||
GO4K_FST AMOUNT(56),DEST(2*MAX_WORKSPACE_SLOTS+2)
|
||||
GO4K_FOP OP(FOP_POP)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_FOP OP(FOP_MULP)
|
||||
GO4K_VCF FREQUENCY(16),RESONANCE(64),VCFTYPE(PEAK)
|
||||
GO4K_VCF FREQUENCY(48),RESONANCE(64),VCFTYPE(LOWPASS)
|
||||
GO4K_FOP OP(FOP_PUSH)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_PAN PANNING(40)
|
||||
GO4K_OUT GAIN(48), AUXSEND(16)
|
||||
GO4K_END_PARAMDEF
|
||||
GO4K_BEGIN_PARAMDEF(Instrument9)
|
||||
GO4K_ENV ATTAC(64),DECAY(96),SUSTAIN(96),RELEASE(88),GAIN(128)
|
||||
GO4K_VCO TRANSPOSE(16),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(64),GAIN(128),FLAGS(SINE|LFO)
|
||||
GO4K_FST AMOUNT(73),DEST(14*MAX_WORKSPACE_SLOTS+4)
|
||||
GO4K_FST AMOUNT(65),DEST(7*MAX_WORKSPACE_SLOTS+2)
|
||||
GO4K_FOP OP(FOP_POP)
|
||||
GO4K_VCO TRANSPOSE(64),DETUNE(68),PHASE(64),GATES(0),COLOR(96),SHAPE(112),GAIN(128),FLAGS(TRISAW)
|
||||
GO4K_VCO TRANSPOSE(64),DETUNE(60),PHASE(0),GATES(0),COLOR(96),SHAPE(112),GAIN(128),FLAGS(TRISAW)
|
||||
GO4K_VCO TRANSPOSE(76),DETUNE(64),PHASE(0),GATES(0),COLOR(48),SHAPE(80),GAIN(128),FLAGS(TRISAW)
|
||||
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(64),GAIN(128),FLAGS(SINE)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_DST DRIVE(32), SNHFREQ(128)
|
||||
GO4K_FOP OP(FOP_MULP)
|
||||
GO4K_VCF FREQUENCY(64),RESONANCE(64),VCFTYPE(BANDSTOP)
|
||||
GO4K_VCF FREQUENCY(96),RESONANCE(64),VCFTYPE(LOWPASS)
|
||||
GO4K_DLL PREGAIN(64),DRY(128),FEEDBACK(64),DAMP(64),FREQUENCY(0),DEPTH(0),DELAY(16),COUNT(1)
|
||||
GO4K_PAN PANNING(64)
|
||||
GO4K_OUT GAIN(64), AUXSEND(48)
|
||||
GO4K_END_PARAMDEF
|
||||
GO4K_BEGIN_PARAMDEF(Instrument10)
|
||||
GO4K_ENV ATTAC(96),DECAY(128),SUSTAIN(128),RELEASE(100),GAIN(128)
|
||||
GO4K_FST AMOUNT(80),DEST(5*MAX_WORKSPACE_SLOTS+4)
|
||||
GO4K_FST AMOUNT(96),DEST(7*MAX_WORKSPACE_SLOTS+4)
|
||||
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(64),GAIN(64),FLAGS(NOISE)
|
||||
GO4K_FOP OP(FOP_PUSH)
|
||||
GO4K_VCF FREQUENCY(64),RESONANCE(64),VCFTYPE(LOWPASS)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_VCF FREQUENCY(22),RESONANCE(64),VCFTYPE(BANDPASS)
|
||||
GO4K_VCO TRANSPOSE(64),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(64),GAIN(128),FLAGS(NOISE)
|
||||
GO4K_FOP OP(FOP_PUSH)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_VCF FREQUENCY(16),RESONANCE(128),VCFTYPE(LOWPASS)
|
||||
GO4K_FST AMOUNT(128),DEST(14*MAX_WORKSPACE_SLOTS+1)
|
||||
GO4K_FOP OP(FOP_POP)
|
||||
GO4K_VCO TRANSPOSE(112),DETUNE(64),PHASE(0),GATES(0),COLOR(64),SHAPE(112),GAIN(128),FLAGS(SINE|LFO)
|
||||
GO4K_FOP OP(FOP_PUSH)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_VCF FREQUENCY(48),RESONANCE(128),VCFTYPE(LOWPASS)
|
||||
GO4K_FOP OP(FOP_ADDP)
|
||||
GO4K_FOP OP(FOP_MULP)
|
||||
GO4K_PAN PANNING(64)
|
||||
GO4K_OUT GAIN(128), AUXSEND(128)
|
||||
GO4K_END_PARAMDEF
|
||||
GO4K_BEGIN_PARAMDEF(Global)
|
||||
GO4K_ACC ACCTYPE(AUX)
|
||||
GO4K_DLL PREGAIN(64),DRY(128),FEEDBACK(120),DAMP(88),FREQUENCY(0),DEPTH(64),DELAY(0),COUNT(8)
|
||||
GO4K_VCF FREQUENCY(32),RESONANCE(128),VCFTYPE(BANDSTOP)
|
||||
GO4K_FOP OP(FOP_XCH)
|
||||
GO4K_DLL PREGAIN(64),DRY(128),FEEDBACK(120),DAMP(88),FREQUENCY(0),DEPTH(64),DELAY(8),COUNT(8)
|
||||
GO4K_VCF FREQUENCY(32),RESONANCE(128),VCFTYPE(BANDSTOP)
|
||||
GO4K_ACC ACCTYPE(OUTPUT)
|
||||
GO4K_VCF FREQUENCY(4),RESONANCE(128),VCFTYPE(HIGHPASS)
|
||||
GO4K_FOP OP(FOP_XCH)
|
||||
GO4K_VCF FREQUENCY(4),RESONANCE(128),VCFTYPE(HIGHPASS)
|
||||
GO4K_FOP OP(FOP_ADDP2)
|
||||
GO4K_OUT GAIN(20), AUXSEND(0)
|
||||
GO4K_END_PARAMDEF
|
||||
go4k_synth_parameter_values_end
|
||||
%ifdef USE_SECTIONS
|
||||
section .g4kmuc5 data align=1
|
||||
%else
|
||||
section .data
|
||||
%endif
|
||||
%ifdef GO4K_USE_DLL
|
||||
global _go4k_delay_times
|
||||
_go4k_delay_times
|
||||
dw 1116
|
||||
dw 1188
|
||||
dw 1276
|
||||
dw 1356
|
||||
dw 1422
|
||||
dw 1492
|
||||
dw 1556
|
||||
dw 1618
|
||||
dw 1140
|
||||
dw 1212
|
||||
dw 1300
|
||||
dw 1380
|
||||
dw 1446
|
||||
dw 1516
|
||||
dw 1580
|
||||
dw 1642
|
||||
dw 15383
|
||||
dw 11537
|
||||
dw 23075
|
||||
%endif
|
||||
BIN
space4k/src/4klang.obj
Normal file
BIN
space4k/src/4klang.obj
Normal file
Binary file not shown.
93
space4k/src/4slang/4slang.cpp
Normal file
93
space4k/src/4slang/4slang.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
// 4slang.cpp : Defines the entry point for the console application.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "LexAnalyzer.h"
|
||||
#include "SemAnalyzer.h"
|
||||
#include "Cruncher.h"
|
||||
#include "Exporter.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
{
|
||||
vector<CString> lk_Filenames;
|
||||
CString ls_OutFile;
|
||||
|
||||
try
|
||||
{
|
||||
for (int i = 1; i < argc; ++i)
|
||||
{
|
||||
_TCHAR* lc_Arg_ = argv[i];
|
||||
if (lc_Arg_[0] == '/')
|
||||
{
|
||||
CString ls_Arg = lc_Arg_ + 1;
|
||||
if (ls_Arg.Left(4).CompareNoCase(_T("out:")) == 0)
|
||||
{
|
||||
ls_OutFile = ls_Arg.Mid(4);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lk_Filenames.push_back(lc_Arg_);
|
||||
}
|
||||
}
|
||||
|
||||
if (lk_Filenames.empty())
|
||||
{
|
||||
wcout << _T("Error: No input file(s) passed to 4slang.") << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ls_OutFile.IsEmpty())
|
||||
{
|
||||
wcout << _T("Error: No output file passed to 4slang.") << endl;
|
||||
return 2;
|
||||
}
|
||||
|
||||
vector<r_Program*> lk_Programs;
|
||||
|
||||
vector<CString>::iterator lk_Iter = lk_Filenames.begin();
|
||||
for (; lk_Iter != lk_Filenames.end(); ++lk_Iter)
|
||||
{
|
||||
wcout << "Crunching " << (LPCTSTR)*lk_Iter << "..." << endl;
|
||||
|
||||
k_LexAnalyzer lk_LexAnalyzer;
|
||||
if (!lk_LexAnalyzer.Parse(*lk_Iter))
|
||||
return 3;
|
||||
|
||||
k_SemAnalyzer lk_SemAnalyzer;
|
||||
lk_SemAnalyzer.Analyze(lk_LexAnalyzer, *lk_Iter);
|
||||
r_Program* lr_Program_ = lk_SemAnalyzer.mr_Program_;
|
||||
|
||||
lk_Programs.push_back(lr_Program_);
|
||||
}
|
||||
|
||||
k_Cruncher lk_Cruncher;
|
||||
lk_Cruncher.Crunch(lk_Programs);
|
||||
|
||||
k_Exporter lk_Exporter;
|
||||
if (!lk_Exporter.Export(lk_Programs, ls_OutFile, lk_Filenames))
|
||||
return 4;
|
||||
}
|
||||
catch (const CString& ls_Exception)
|
||||
{
|
||||
wcout << (LPCTSTR)ls_Exception << endl;
|
||||
#ifdef _DEBUG
|
||||
::MessageBox(NULL, ls_Exception, _T("4slang"), MB_OK);
|
||||
#endif
|
||||
return 5;
|
||||
}
|
||||
catch (LPCTSTR ls_Exception)
|
||||
{
|
||||
wcout << ls_Exception << endl;
|
||||
#ifdef _DEBUG
|
||||
::MessageBox(NULL, ls_Exception, _T("4slang"), MB_OK);
|
||||
#endif
|
||||
return 5;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
181
space4k/src/4slang/4slang.vcproj
Normal file
181
space4k/src/4slang/4slang.vcproj
Normal file
@@ -0,0 +1,181 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="4slang"
|
||||
ProjectGUID="{E0A366EF-1805-44C7-B644-426FEE32B9D9}"
|
||||
RootNamespace="My4slang"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)bin"
|
||||
IntermediateDirectory="$(SolutionDir)obj\$(ProjectName)_$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
UseOfATL="1"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="2"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)\$(ProjectName).exe"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\4slang.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Cruncher.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Exporter.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\LanguageSpecifier.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\LexAnalyzer.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SemAnalyzer.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\stdafx.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Cruncher.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Exporter.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\LanguageSpecifier.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\LexAnalyzer.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SemAnalyzer.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\stdafx.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\targetver.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
37
space4k/src/4slang/4slang.vcproj.FIARA.Frank.user
Normal file
37
space4k/src/4slang/4slang.vcproj.FIARA.Frank.user
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioUserFile
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
ShowAllFiles="false"
|
||||
>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="SHAIKUR"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
</VisualStudioUserFile>
|
||||
37
space4k/src/4slang/4slang.vcproj.Shaikur.Frank.user
Normal file
37
space4k/src/4slang/4slang.vcproj.Shaikur.Frank.user
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioUserFile
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
ShowAllFiles="true"
|
||||
>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments="$(SolutionDir)src\world.glsl $(SolutionDir)src\blur.glsl $(SolutionDir)src\halo.glsl $(SolutionDir)src\combine.glsl /out:$(SolutionDir)src\shaders.h"
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="SHAIKUR"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor="0"
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
</VisualStudioUserFile>
|
||||
75
space4k/src/4slang/4slang.vcxproj
Normal file
75
space4k/src/4slang/4slang.vcxproj
Normal file
@@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{E0A366EF-1805-44C7-B644-426FEE32B9D9}</ProjectGuid>
|
||||
<RootNamespace>My4slang</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseOfAtl>Static</UseOfAtl>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)bin\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)obj\$(ProjectName)_$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="4slang.cpp" />
|
||||
<ClCompile Include="Cruncher.cpp" />
|
||||
<ClCompile Include="Exporter.cpp" />
|
||||
<ClCompile Include="LanguageSpecifier.cpp" />
|
||||
<ClCompile Include="LexAnalyzer.cpp" />
|
||||
<ClCompile Include="SemAnalyzer.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Cruncher.h" />
|
||||
<ClInclude Include="Exporter.h" />
|
||||
<ClInclude Include="LanguageSpecifier.h" />
|
||||
<ClInclude Include="LexAnalyzer.h" />
|
||||
<ClInclude Include="SemAnalyzer.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
63
space4k/src/4slang/4slang.vcxproj.filters
Normal file
63
space4k/src/4slang/4slang.vcxproj.filters
Normal file
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="4slang.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Cruncher.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Exporter.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LanguageSpecifier.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LexAnalyzer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SemAnalyzer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Cruncher.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Exporter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="LanguageSpecifier.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="LexAnalyzer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SemAnalyzer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="stdafx.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="targetver.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
3
space4k/src/4slang/4slang.vcxproj.user
Normal file
3
space4k/src/4slang/4slang.vcxproj.user
Normal file
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
</Project>
|
||||
206
space4k/src/4slang/Cruncher.cpp
Normal file
206
space4k/src/4slang/Cruncher.cpp
Normal file
@@ -0,0 +1,206 @@
|
||||
#include "stdafx.h"
|
||||
#include "Cruncher.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
void k_Cruncher::ReplaceFunctionCalls(r_Scope* ar_Scope_)
|
||||
{
|
||||
for (vector<r_Keyword>::iterator lk_Iter = ar_Scope_->mk_Keywords.begin(); lk_Iter != ar_Scope_->mk_Keywords.end(); ++lk_Iter)
|
||||
{
|
||||
r_Keyword& lr_Keyword = *lk_Iter;
|
||||
|
||||
if (lr_Keyword.me_Type == r_KeywordType::Number)
|
||||
{
|
||||
if (lr_Keyword.ms_Name.Left(2) == _T("0.") && lr_Keyword.ms_Name != _T("0."))
|
||||
lr_Keyword.ms_Name = lr_Keyword.ms_Name.Mid(1);
|
||||
|
||||
if (lr_Keyword.ms_Name[0] != _T('.') && lr_Keyword.ms_Name.Right(2) == _T(".0"))
|
||||
lr_Keyword.ms_Name = lr_Keyword.ms_Name.Left(lr_Keyword.ms_Name.GetLength() - 1);
|
||||
}
|
||||
|
||||
if (lr_Keyword.me_Type == r_KeywordType::FunctionCall)
|
||||
{
|
||||
if (mk_Functions.find(lr_Keyword.ms_Name) != mk_Functions.end())
|
||||
lr_Keyword.ms_Name = mk_Functions[lr_Keyword.ms_Name];
|
||||
}
|
||||
}
|
||||
|
||||
for (vector<r_Scope*>::iterator lk_Iter = ar_Scope_->mk_Scopes.begin(); lk_Iter != ar_Scope_->mk_Scopes.end(); ++lk_Iter)
|
||||
{
|
||||
ReplaceFunctionCalls(*lk_Iter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CString GetVarName(char ac_Char)
|
||||
{
|
||||
if (ac_Char >= 'A' + 104)
|
||||
throw _T("Too many variables and functions! This is not 4k worthy!");
|
||||
|
||||
char* lc_VarNames_[] = {
|
||||
"a",
|
||||
"b",
|
||||
"c",
|
||||
"d",
|
||||
"e",
|
||||
"f",
|
||||
"g",
|
||||
"h",
|
||||
"i",
|
||||
"j",
|
||||
"k",
|
||||
"l",
|
||||
"m",
|
||||
"n",
|
||||
"o",
|
||||
"p",
|
||||
"q",
|
||||
"r",
|
||||
"s",
|
||||
"t",
|
||||
"u",
|
||||
"v",
|
||||
"w",
|
||||
"x",
|
||||
"y",
|
||||
"z",
|
||||
"A",
|
||||
"B",
|
||||
"C",
|
||||
"D",
|
||||
"E",
|
||||
"F",
|
||||
"G",
|
||||
"H",
|
||||
"I",
|
||||
"J",
|
||||
"K",
|
||||
"L",
|
||||
"M",
|
||||
"N",
|
||||
"O",
|
||||
"P",
|
||||
"Q",
|
||||
"R",
|
||||
"S",
|
||||
"T",
|
||||
"U",
|
||||
"V",
|
||||
"W",
|
||||
"X",
|
||||
"Y",
|
||||
"Z",
|
||||
"aa",
|
||||
"ab",
|
||||
"ac",
|
||||
"ad",
|
||||
"ae",
|
||||
"af",
|
||||
"ag",
|
||||
"ah",
|
||||
"ai",
|
||||
"aj",
|
||||
"ak",
|
||||
"al",
|
||||
"am",
|
||||
"an",
|
||||
"ao",
|
||||
"ap",
|
||||
"aq",
|
||||
"ar",
|
||||
"as",
|
||||
"at",
|
||||
"au",
|
||||
"av",
|
||||
"aw",
|
||||
"ax",
|
||||
"ay",
|
||||
"az",
|
||||
"aA",
|
||||
"aB",
|
||||
"aC",
|
||||
"aD",
|
||||
"aE",
|
||||
"aF",
|
||||
"aG",
|
||||
"aH",
|
||||
"aI",
|
||||
"aJ",
|
||||
"aK",
|
||||
"aL",
|
||||
"aM",
|
||||
"aN",
|
||||
"aO",
|
||||
"aP",
|
||||
"aQ",
|
||||
"aR",
|
||||
"aS",
|
||||
"aT",
|
||||
"aU",
|
||||
"aV",
|
||||
"aW",
|
||||
"aX",
|
||||
"aY",
|
||||
"aZ"
|
||||
};
|
||||
|
||||
return CString(lc_VarNames_[ac_Char - 'A']);
|
||||
}
|
||||
|
||||
|
||||
void k_Cruncher::RenameVariables(r_Scope* ar_Scope_, char ac_Name)
|
||||
{
|
||||
char lc_Char = ac_Name;
|
||||
map<CString, r_Keyword*>::iterator lk_KeywordIter = ar_Scope_->mr_SymbolTable.mk_Map.begin();
|
||||
for (; lk_KeywordIter != ar_Scope_->mr_SymbolTable.mk_Map.end(); ++lk_KeywordIter)
|
||||
{
|
||||
r_Keyword* lr_Keyword_ = lk_KeywordIter->second;
|
||||
|
||||
if (!lr_Keyword_->mb_CanBeRenamed)
|
||||
continue;
|
||||
|
||||
r_Keyword* lr_SymbolTableEntry_ = NULL;
|
||||
do
|
||||
{
|
||||
lr_Keyword_->ms_Name = GetVarName(lc_Char++);
|
||||
} while (ar_Scope_->SearchVariable(lr_Keyword_->ms_Name, lr_SymbolTableEntry_));
|
||||
}
|
||||
|
||||
vector<r_SymbolTable*>::iterator lk_Iter = ar_Scope_->mr_SymbolTable.mk_Children.begin();
|
||||
for (; lk_Iter != ar_Scope_->mr_SymbolTable.mk_Children.end(); ++lk_Iter)
|
||||
{
|
||||
r_Scope* lr_Scope_ = (*lk_Iter)->mr_Parent_;
|
||||
RenameVariables(lr_Scope_, lc_Char);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void k_Cruncher::Crunch(vector<r_Program*> ak_Programs)
|
||||
{
|
||||
char lc_FuncName = 'A';
|
||||
|
||||
for (vector<r_Program*>::iterator lk_ProgIter = ak_Programs.begin(); lk_ProgIter != ak_Programs.end(); ++lk_ProgIter)
|
||||
{
|
||||
r_Program* lr_Program_ = *lk_ProgIter;
|
||||
|
||||
for (vector<r_Function*>::iterator lk_Iter = lr_Program_->mk_Functions.begin(); lk_Iter != lr_Program_->mk_Functions.end(); ++lk_Iter)
|
||||
{
|
||||
r_Function* lr_Function_ = *lk_Iter;
|
||||
if (lr_Function_->ms_Name.CompareNoCase(_T("main")) == 0)
|
||||
continue;
|
||||
|
||||
CString ls_NewFuncName = GetVarName(lc_FuncName++);
|
||||
mk_Functions[lr_Function_->ms_Name] = ls_NewFuncName;
|
||||
lr_Function_->ms_Name = ls_NewFuncName;
|
||||
}
|
||||
|
||||
for (vector<r_Function*>::iterator lk_Iter = lr_Program_->mk_Functions.begin(); lk_Iter != lr_Program_->mk_Functions.end(); ++lk_Iter)
|
||||
{
|
||||
ReplaceFunctionCalls(*lk_Iter);
|
||||
}
|
||||
|
||||
ReplaceFunctionCalls(lr_Program_);
|
||||
RenameVariables(lr_Program_, lc_FuncName);
|
||||
}
|
||||
}
|
||||
27
space4k/src/4slang/Cruncher.h
Normal file
27
space4k/src/4slang/Cruncher.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include "SemAnalyzer.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
class k_Cruncher
|
||||
{
|
||||
struct r_NoCaseLess
|
||||
{
|
||||
bool operator () (const CString& as_Left, const CString& as_Right) const
|
||||
{
|
||||
return as_Left.CompareNoCase(as_Right) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
map<CString, CString> mk_Functions;
|
||||
|
||||
k_Cruncher() {}
|
||||
virtual ~k_Cruncher() {}
|
||||
|
||||
void ReplaceFunctionCalls(r_Scope* ar_Scope_);
|
||||
void RenameVariables(r_Scope* ar_Scope_, char ac_Name);
|
||||
void Crunch(vector<r_Program*> ak_Programs);
|
||||
};
|
||||
173
space4k/src/4slang/Exporter.cpp
Normal file
173
space4k/src/4slang/Exporter.cpp
Normal file
@@ -0,0 +1,173 @@
|
||||
#include "stdafx.h"
|
||||
#include "Exporter.h"
|
||||
|
||||
|
||||
static int gi_LastLine = 1;
|
||||
|
||||
|
||||
void ExportScope(r_Scope* ar_Scope_, FILE* ar_File_)
|
||||
{
|
||||
_ftprintf_s(ar_File_, _T("{"));
|
||||
for (vector<r_Keyword>::iterator lk_Iter = ar_Scope_->mk_Keywords.begin(); lk_Iter != ar_Scope_->mk_Keywords.end(); ++lk_Iter)
|
||||
{
|
||||
if (lk_Iter->me_Type == r_KeywordType::Variable)
|
||||
{
|
||||
if (lk_Iter->mb_CanBeRenamed)
|
||||
lk_Iter->ms_Name = lk_Iter->mr_SymbolTableEntry_->ms_Name;
|
||||
}
|
||||
|
||||
if (lk_Iter->mi_LineNumber != gi_LastLine)
|
||||
{
|
||||
for (int i = gi_LastLine; i < lk_Iter->mi_LineNumber; ++i)
|
||||
{
|
||||
//_ftprintf_s(ar_File_, _T("\\n"));
|
||||
}
|
||||
_ftprintf_s(ar_File_, _T("\" // Line %d\n\t\""), gi_LastLine);
|
||||
gi_LastLine = lk_Iter->mi_LineNumber;
|
||||
}
|
||||
|
||||
if (lk_Iter->me_Type == r_KeywordType::Scope)
|
||||
{
|
||||
int li_ScopeId = 0;
|
||||
_stscanf_s(lk_Iter->ms_Name, _T("%d"), &li_ScopeId);
|
||||
ExportScope(ar_Scope_->mk_Scopes[li_ScopeId], ar_File_);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lk_Iter->ms_Name == _T("%"))
|
||||
_ftprintf_s(ar_File_, _T("%%"));
|
||||
else
|
||||
_ftprintf_s(ar_File_, lk_Iter->ms_Name);
|
||||
switch (lk_Iter->me_Type)
|
||||
{
|
||||
case r_KeywordType::Identifier:
|
||||
case r_KeywordType::Type:
|
||||
_ftprintf_s(ar_File_, _T(" "));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
_ftprintf_s(ar_File_, _T("}"));
|
||||
}
|
||||
|
||||
void ExportFunction(r_Function* ar_Function_, FILE* ar_File_)
|
||||
{
|
||||
_ftprintf_s(ar_File_, ar_Function_->ms_ReturnType);
|
||||
_ftprintf_s(ar_File_, _T(" "));
|
||||
_ftprintf_s(ar_File_, ar_Function_->ms_Name);
|
||||
_ftprintf_s(ar_File_, _T("("));
|
||||
for (vector<r_Parameter>::iterator lk_Iter = ar_Function_->mk_Parameters.begin(); lk_Iter != ar_Function_->mk_Parameters.end(); ++lk_Iter)
|
||||
{
|
||||
_ftprintf_s(ar_File_, lk_Iter->ms_VarType);
|
||||
_ftprintf_s(ar_File_, _T(" "));
|
||||
_ftprintf_s(ar_File_, lk_Iter->ms_Name);
|
||||
if (lk_Iter + 1 != ar_Function_->mk_Parameters.end())
|
||||
_ftprintf_s(ar_File_, _T(","));
|
||||
}
|
||||
_ftprintf_s(ar_File_, _T(")"));
|
||||
ExportScope(ar_Function_, ar_File_);
|
||||
}
|
||||
|
||||
|
||||
void ExportProgram(r_Program* ar_Program_, FILE* ar_File_)
|
||||
{
|
||||
_ftprintf_s(ar_File_, _T("\t\""));
|
||||
for (vector<r_Keyword>::iterator lk_Iter = ar_Program_->mk_Keywords.begin(); lk_Iter != ar_Program_->mk_Keywords.end(); ++lk_Iter)
|
||||
{
|
||||
if (lk_Iter->me_Type == r_KeywordType::Variable)
|
||||
{
|
||||
if (lk_Iter->mb_CanBeRenamed)
|
||||
lk_Iter->ms_Name = lk_Iter->mr_SymbolTableEntry_->ms_Name;
|
||||
}
|
||||
|
||||
if (lk_Iter->mi_LineNumber != gi_LastLine)
|
||||
{
|
||||
for (int i = gi_LastLine; i < lk_Iter->mi_LineNumber; ++i)
|
||||
{
|
||||
//_ftprintf_s(ar_File_, _T("\\n"));
|
||||
}
|
||||
_ftprintf_s(ar_File_, _T("\" // Line %d\n\t\""), gi_LastLine);
|
||||
gi_LastLine = lk_Iter->mi_LineNumber;
|
||||
}
|
||||
|
||||
_ftprintf_s(ar_File_, lk_Iter->ms_Name);
|
||||
switch (lk_Iter->me_Type)
|
||||
{
|
||||
case r_KeywordType::Identifier:
|
||||
case r_KeywordType::Type:
|
||||
_ftprintf_s(ar_File_, _T(" "));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (vector<r_Function*>::iterator lk_Iter = ar_Program_->mk_Functions.begin(); lk_Iter != ar_Program_->mk_Functions.end(); ++lk_Iter)
|
||||
{
|
||||
ExportFunction(*lk_Iter, ar_File_);
|
||||
}
|
||||
_ftprintf_s(ar_File_, _T("\""));
|
||||
}
|
||||
|
||||
|
||||
bool k_Exporter::Export(const vector<r_Program*>& ak_Programs, const CString& as_Filename, const vector<CString> ak_SourceFilenames)
|
||||
{
|
||||
FILE* lr_File_ = NULL;
|
||||
_tfopen_s(&lr_File_, as_Filename, _T("w"));
|
||||
if (lr_File_ == NULL)
|
||||
{
|
||||
wcout << _T("Error: Couldn't open ") << (LPCTSTR)as_Filename << _T(" for writing.") << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
_ftprintf_s(lr_File_, _T("#pragma once\n\n"));
|
||||
_ftprintf_s(lr_File_, _T("#pragma data_seg(\".shaderCount\")\n"));
|
||||
CString line; line.Format(_T("static const int shaderCount = %d;\n\n"), ak_Programs.size());
|
||||
_ftprintf_s(lr_File_, line);
|
||||
_ftprintf_s(lr_File_, _T("#pragma data_seg(\".shaders\")\n"));
|
||||
_ftprintf_s(lr_File_, _T("static char* fsh[] = {\n"));
|
||||
std::vector<r_Program*>::const_iterator lk_Iter = ak_Programs.begin();
|
||||
std::vector<CString>::const_iterator lk_FileIter = ak_SourceFilenames.begin();
|
||||
for (; lk_Iter != ak_Programs.end(); ++lk_Iter, ++lk_FileIter)
|
||||
{
|
||||
r_Program* lr_Program_ = *lk_Iter;
|
||||
CString file = *lk_FileIter;
|
||||
_ftprintf_s(lr_File_, _T("//"));
|
||||
_ftprintf_s(lr_File_, file);
|
||||
_ftprintf_s(lr_File_, _T(":\n"));
|
||||
|
||||
gi_LastLine = 1;
|
||||
ExportProgram(lr_Program_, lr_File_);
|
||||
_ftprintf_s(lr_File_, _T(",\n"));
|
||||
}
|
||||
_ftprintf_s(lr_File_, _T("0};\n\n"));
|
||||
|
||||
lk_FileIter = ak_SourceFilenames.begin();
|
||||
for (int i = 0; lk_FileIter != ak_SourceFilenames.end(); ++lk_FileIter, ++i)
|
||||
{
|
||||
CString file = *lk_FileIter;
|
||||
file = file.Mid(file.ReverseFind(_T('\\'))+1);
|
||||
file.Replace(_T("."), _T("_"));
|
||||
file.MakeUpper();
|
||||
_ftprintf_s(lr_File_, _T("#define "));
|
||||
_ftprintf_s(lr_File_, file);
|
||||
line.Format(_T(" %d\n"), i);
|
||||
_ftprintf_s(lr_File_, line);
|
||||
}
|
||||
_ftprintf_s(lr_File_, _T("\n"));
|
||||
|
||||
_ftprintf_s(lr_File_, _T("#pragma data_seg(\".shaderFileName\")\n"));
|
||||
_ftprintf_s(lr_File_, _T("static const char* shaderFileName[] = {\n"));
|
||||
|
||||
lk_FileIter = ak_SourceFilenames.begin();
|
||||
for (; lk_FileIter != ak_SourceFilenames.end(); ++lk_FileIter)
|
||||
{
|
||||
CString file = *lk_FileIter;
|
||||
file.Replace(_T("\\"), _T("\\\\"));
|
||||
_ftprintf_s(lr_File_, _T("\""));
|
||||
_ftprintf_s(lr_File_, file);
|
||||
_ftprintf_s(lr_File_, _T("\",\n"));
|
||||
}
|
||||
_ftprintf_s(lr_File_, _T("0};\n\n"));
|
||||
|
||||
return true;
|
||||
}
|
||||
15
space4k/src/4slang/Exporter.h
Normal file
15
space4k/src/4slang/Exporter.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "SemAnalyzer.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
class k_Exporter
|
||||
{
|
||||
public:
|
||||
k_Exporter() {}
|
||||
virtual ~k_Exporter() {}
|
||||
|
||||
bool Export(const vector<r_Program*>& ak_Programs, const CString& as_Filename, const vector<CString> ak_SourceFilenames);
|
||||
};
|
||||
220
space4k/src/4slang/LanguageSpecifier.cpp
Normal file
220
space4k/src/4slang/LanguageSpecifier.cpp
Normal file
@@ -0,0 +1,220 @@
|
||||
#include "stdafx.h"
|
||||
#include "LanguageSpecifier.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
k_LanguageSpecifier::k_LanguageSpecifier()
|
||||
: mi_LineNumber(1)
|
||||
{
|
||||
mk_Identifiers.push_back(_T("return"));
|
||||
mk_Identifiers.push_back(_T("varying"));
|
||||
mk_Identifiers.push_back(_T("inout"));
|
||||
mk_Identifiers.push_back(_T("in"));
|
||||
mk_Identifiers.push_back(_T("out"));
|
||||
mk_Identifiers.push_back(_T("uniform"));
|
||||
mk_Identifiers.push_back(_T("const"));
|
||||
mk_Identifiers.push_back(_T("then"));
|
||||
mk_Identifiers.push_back(_T("else"));
|
||||
mk_Identifiers.push_back(_T("break"));
|
||||
mk_Identifiers.push_back(_T("struct"));
|
||||
|
||||
mk_ReservedVariables.push_back(_T("gl_FragColor"));
|
||||
mk_ReservedVariables.push_back(_T("gl_FragCoord"));
|
||||
mk_ReservedVariables.push_back(_T("gl_Normal"));
|
||||
mk_ReservedVariables.push_back(_T("gl_Color"));
|
||||
mk_ReservedVariables.push_back(_T("gl_ModelViewMatrix"));
|
||||
mk_ReservedVariables.push_back(_T("gl_ModelViewMatrixInverse"));
|
||||
mk_ReservedVariables.push_back(_T("true"));
|
||||
mk_ReservedVariables.push_back(_T("false"));
|
||||
|
||||
mk_Functions.push_back(_T("if"));
|
||||
mk_Functions.push_back(_T("for"));
|
||||
mk_Functions.push_back(_T("do"));
|
||||
mk_Functions.push_back(_T("while"));
|
||||
mk_Functions.push_back(_T("texture2D"));
|
||||
mk_Functions.push_back(_T("atan"));
|
||||
mk_Functions.push_back(_T("sin"));
|
||||
mk_Functions.push_back(_T("cos"));
|
||||
mk_Functions.push_back(_T("acos"));
|
||||
mk_Functions.push_back(_T("atan"));
|
||||
mk_Functions.push_back(_T("fract"));
|
||||
mk_Functions.push_back(_T("length"));
|
||||
mk_Functions.push_back(_T("floor"));
|
||||
mk_Functions.push_back(_T("ceil"));
|
||||
mk_Functions.push_back(_T("step"));
|
||||
mk_Functions.push_back(_T("smoothstep"));
|
||||
mk_Functions.push_back(_T("normalize"));
|
||||
mk_Functions.push_back(_T("dot"));
|
||||
mk_Functions.push_back(_T("cross"));
|
||||
mk_Functions.push_back(_T("pow"));
|
||||
mk_Functions.push_back(_T("mix"));
|
||||
mk_Functions.push_back(_T("asin"));
|
||||
mk_Functions.push_back(_T("mod"));
|
||||
mk_Functions.push_back(_T("abs"));
|
||||
mk_Functions.push_back(_T("clamp"));
|
||||
mk_Functions.push_back(_T("reflect"));
|
||||
mk_Functions.push_back(_T("refract"));
|
||||
mk_Functions.push_back(_T("min"));
|
||||
mk_Functions.push_back(_T("max"));
|
||||
mk_Functions.push_back(_T("sqrt"));
|
||||
|
||||
mk_Types.push_back(_T("void"));
|
||||
mk_Types.push_back(_T("vec2"));
|
||||
mk_Types.push_back(_T("vec3"));
|
||||
mk_Types.push_back(_T("vec4"));
|
||||
mk_Types.push_back(_T("ivec3"));
|
||||
mk_Types.push_back(_T("ivec4"));
|
||||
mk_Types.push_back(_T("float"));
|
||||
mk_Types.push_back(_T("int"));
|
||||
mk_Types.push_back(_T("bool"));
|
||||
mk_Types.push_back(_T("sampler2D"));
|
||||
|
||||
mk_Symbols.push_back(_T(";"));
|
||||
mk_Symbols.push_back(_T("{"));
|
||||
mk_Symbols.push_back(_T("}"));
|
||||
mk_Symbols.push_back(_T("("));
|
||||
mk_Symbols.push_back(_T(")"));
|
||||
mk_Symbols.push_back(_T("["));
|
||||
mk_Symbols.push_back(_T("]"));
|
||||
mk_Symbols.push_back(_T("."));
|
||||
mk_Symbols.push_back(_T(","));
|
||||
mk_Symbols.push_back(_T("*"));
|
||||
mk_Symbols.push_back(_T("+"));
|
||||
mk_Symbols.push_back(_T("-"));
|
||||
mk_Symbols.push_back(_T("/"));
|
||||
mk_Symbols.push_back(_T("^"));
|
||||
mk_Symbols.push_back(_T("&"));
|
||||
mk_Symbols.push_back(_T("|"));
|
||||
mk_Symbols.push_back(_T("<"));
|
||||
mk_Symbols.push_back(_T(">"));
|
||||
mk_Symbols.push_back(_T("="));
|
||||
mk_Symbols.push_back(_T("%"));
|
||||
mk_Symbols.push_back(_T("!"));
|
||||
mk_Symbols.push_back(_T("?"));
|
||||
mk_Symbols.push_back(_T(":"));
|
||||
}
|
||||
|
||||
|
||||
r_Keyword k_LanguageSpecifier::Classify(const CString& as_Keyword, char* ac_Char_)
|
||||
{
|
||||
r_KeywordType::Enumeration le_Type = r_KeywordType::Variable;
|
||||
if (!as_Keyword.IsEmpty())
|
||||
{
|
||||
if (find(mk_Identifiers.begin(), mk_Identifiers.end(), as_Keyword) != mk_Identifiers.end())
|
||||
{
|
||||
le_Type = r_KeywordType::Identifier;
|
||||
}
|
||||
if (find(mk_Types.begin(), mk_Types.end(), as_Keyword) != mk_Types.end())
|
||||
{
|
||||
char* lc_Pointer_ = ac_Char_;
|
||||
while (*lc_Pointer_ == '\t' || *lc_Pointer_ == '\n' || *lc_Pointer_ == ' ')
|
||||
{
|
||||
++lc_Pointer_;
|
||||
}
|
||||
if (*lc_Pointer_ == '(')
|
||||
le_Type = r_KeywordType::FunctionCall;
|
||||
else if (*lc_Pointer_ == ')')
|
||||
le_Type = r_KeywordType::Identifier;
|
||||
else
|
||||
le_Type = r_KeywordType::Type;
|
||||
}
|
||||
if (find(mk_Functions.begin(), mk_Functions.end(), as_Keyword) != mk_Functions.end())
|
||||
{
|
||||
le_Type = r_KeywordType::FunctionCall;
|
||||
}
|
||||
if (find(mk_ReservedVariables.begin(), mk_ReservedVariables.end(), as_Keyword) != mk_ReservedVariables.end())
|
||||
{
|
||||
le_Type = r_KeywordType::ReservedVariable;
|
||||
}
|
||||
if (find(mk_Symbols.begin(), mk_Symbols.end(), as_Keyword) != mk_Symbols.end())
|
||||
{
|
||||
le_Type = r_KeywordType::Symbol;
|
||||
}
|
||||
}
|
||||
return r_Keyword(le_Type, as_Keyword, mi_LineNumber);
|
||||
}
|
||||
|
||||
|
||||
r_Keyword k_LanguageSpecifier::get_NextKeyword(char** ac_Chars__)
|
||||
{
|
||||
CString ls_Keyword;
|
||||
r_Keyword lr_Keyword(r_KeywordType::Unknown, ls_Keyword, mi_LineNumber);
|
||||
|
||||
char* lc_Char_ = *ac_Chars__;
|
||||
while (*lc_Char_ != 0)
|
||||
{
|
||||
if (lc_Char_[0] == '/' && lc_Char_[1] == '/')
|
||||
{
|
||||
while (*lc_Char_ != '\n' && *lc_Char_ != 0)
|
||||
{
|
||||
if (*lc_Char_ == '\n')
|
||||
++mi_LineNumber;
|
||||
|
||||
++lc_Char_;
|
||||
}
|
||||
|
||||
ls_Keyword = CString();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lc_Char_[0] == '#')
|
||||
{
|
||||
while (*lc_Char_ != '\n' && *lc_Char_ != 0)
|
||||
{
|
||||
if (*lc_Char_ == '\n')
|
||||
++mi_LineNumber;
|
||||
|
||||
++lc_Char_;
|
||||
}
|
||||
|
||||
ls_Keyword = CString();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ls_Keyword.IsEmpty() && (*lc_Char_ == '\t' || *lc_Char_ == '\n' || *lc_Char_ == ' ' || *lc_Char_ == 0))
|
||||
{
|
||||
if (*lc_Char_ == '\n')
|
||||
++mi_LineNumber;
|
||||
|
||||
++lc_Char_;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ls_Keyword.IsEmpty() && (*lc_Char_ >= '0' && *lc_Char_ <= '9'))
|
||||
{
|
||||
char* lc_Pointer_ = lc_Char_;
|
||||
while ((*lc_Pointer_ >= '0' && *lc_Pointer_ <= '9') || (*lc_Pointer_ >= 'A' && *lc_Pointer_ <= 'F') || (*lc_Pointer_ >= 'a' && *lc_Pointer_ <= 'f') || *lc_Pointer_ == 'x' || *lc_Pointer_ == '.')
|
||||
{
|
||||
++lc_Pointer_;
|
||||
}
|
||||
char* ls_Temp_ = new char[lc_Pointer_ - lc_Char_ + 1];
|
||||
ls_Temp_[lc_Pointer_ - lc_Char_] = 0;
|
||||
memcpy_s(ls_Temp_, lc_Pointer_ - lc_Char_, lc_Char_, lc_Pointer_ - lc_Char_);
|
||||
lc_Char_ = lc_Pointer_;
|
||||
lr_Keyword = r_Keyword(r_KeywordType::Number, CString(ls_Temp_), mi_LineNumber);
|
||||
delete [] ls_Temp_;
|
||||
break;
|
||||
}
|
||||
|
||||
ls_Keyword += *lc_Char_++;
|
||||
|
||||
if (find(mk_Symbols.begin(), mk_Symbols.end(), ls_Keyword) != mk_Symbols.end())
|
||||
{
|
||||
lr_Keyword = Classify(ls_Keyword, lc_Char_);
|
||||
break;
|
||||
}
|
||||
|
||||
if ((find(mk_Symbols.begin(), mk_Symbols.end(), CString(*lc_Char_)) != mk_Symbols.end()) || (*lc_Char_ == '\t' || *lc_Char_ == '\n' || *lc_Char_ == '\r' || *lc_Char_ == ' ' || *lc_Char_ == 0))
|
||||
{
|
||||
if (*lc_Char_ == '\n')
|
||||
++mi_LineNumber;
|
||||
|
||||
lr_Keyword = Classify(ls_Keyword, lc_Char_);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*ac_Chars__ = lc_Char_;
|
||||
return lr_Keyword;
|
||||
}
|
||||
58
space4k/src/4slang/LanguageSpecifier.h
Normal file
58
space4k/src/4slang/LanguageSpecifier.h
Normal file
@@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
struct r_KeywordType
|
||||
{
|
||||
enum Enumeration
|
||||
{
|
||||
Identifier,
|
||||
Type,
|
||||
Symbol,
|
||||
Number,
|
||||
FunctionDeclaration,
|
||||
ArgumentDeclaration,
|
||||
VariableDeclaration,
|
||||
Variable,
|
||||
ReservedVariable,
|
||||
Scope, // Reserved for the semantic analyzer
|
||||
FunctionCall, // Reserved for the semantic analyzer
|
||||
Unknown
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
struct r_Keyword
|
||||
{
|
||||
r_Keyword(r_KeywordType::Enumeration ae_Type, const CString& as_Name, int ai_LineNumber)
|
||||
: me_Type(ae_Type)
|
||||
, ms_Name(as_Name)
|
||||
, mi_LineNumber(ai_LineNumber)
|
||||
, mr_SymbolTableEntry_(NULL)
|
||||
, mb_CanBeRenamed(true)
|
||||
{
|
||||
}
|
||||
|
||||
r_KeywordType::Enumeration me_Type;
|
||||
CString ms_Name;
|
||||
int mi_LineNumber;
|
||||
bool mb_CanBeRenamed;
|
||||
r_Keyword* mr_SymbolTableEntry_;
|
||||
};
|
||||
|
||||
|
||||
class k_LanguageSpecifier
|
||||
{
|
||||
std::vector<CString> mk_Identifiers;
|
||||
std::vector<CString> mk_Symbols;
|
||||
std::vector<CString> mk_Functions;
|
||||
std::vector<CString> mk_Types;
|
||||
std::vector<CString> mk_ReservedVariables;
|
||||
int mi_LineNumber;
|
||||
|
||||
public:
|
||||
k_LanguageSpecifier();
|
||||
virtual ~k_LanguageSpecifier() {}
|
||||
|
||||
r_Keyword Classify(const CString& as_Keyword, char* ac_Char_);
|
||||
r_Keyword get_NextKeyword(char** ac_Chars__);
|
||||
};
|
||||
74
space4k/src/4slang/LexAnalyzer.cpp
Normal file
74
space4k/src/4slang/LexAnalyzer.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
#include "stdafx.h"
|
||||
#include "LexAnalyzer.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
char* TextFileRead(const CString& as_FileName)
|
||||
{
|
||||
FILE* lh_File;
|
||||
char* ls_Content_ = NULL;
|
||||
size_t li_Count = 0;
|
||||
|
||||
if (as_FileName.IsEmpty())
|
||||
{
|
||||
throw _T("Error: No file to parse!");
|
||||
}
|
||||
|
||||
_tfopen_s(&lh_File, as_FileName, _T("rt"));
|
||||
if (lh_File == NULL)
|
||||
{
|
||||
CString ls_Message = _T("Error: Can't open ");
|
||||
ls_Message += as_FileName;
|
||||
throw (LPCTSTR)ls_Message;
|
||||
}
|
||||
|
||||
fseek(lh_File, 0, SEEK_END);
|
||||
li_Count = ftell(lh_File);
|
||||
rewind(lh_File);
|
||||
|
||||
if (li_Count <= 0)
|
||||
{
|
||||
CString ls_Message = _T("Error: File ");
|
||||
ls_Message += as_FileName;
|
||||
ls_Message += _T(" was empty or returned negative file size!");
|
||||
throw (LPCTSTR)ls_Message;
|
||||
}
|
||||
|
||||
ls_Content_ = new char[li_Count + 2];
|
||||
ls_Content_[0] = (char)0xBF;
|
||||
ls_Content_ += 1;
|
||||
li_Count = fread_s(ls_Content_, li_Count + 1, sizeof(char), li_Count, lh_File);
|
||||
ls_Content_[li_Count] = 0;
|
||||
|
||||
fclose(lh_File);
|
||||
|
||||
return ls_Content_;
|
||||
}
|
||||
|
||||
|
||||
bool k_LexAnalyzer::Parse(const CString& as_FileName)
|
||||
{
|
||||
char* ls_Text = NULL;
|
||||
try
|
||||
{
|
||||
ls_Text = TextFileRead(as_FileName);
|
||||
}
|
||||
catch (LPCTSTR ls_Error)
|
||||
{
|
||||
wcout << ls_Error << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
r_Keyword lr_Keyword(r_KeywordType::Unknown, CString(), -1);
|
||||
do
|
||||
{
|
||||
lr_Keyword = mk_Glsl.get_NextKeyword(&ls_Text);
|
||||
if (lr_Keyword.me_Type != r_KeywordType::Unknown)
|
||||
{
|
||||
mk_Keywords.push_back(lr_Keyword);
|
||||
}
|
||||
} while (lr_Keyword.me_Type != r_KeywordType::Unknown);
|
||||
|
||||
return true;
|
||||
}
|
||||
19
space4k/src/4slang/LexAnalyzer.h
Normal file
19
space4k/src/4slang/LexAnalyzer.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
#include "LanguageSpecifier.h"
|
||||
|
||||
class k_LexAnalyzer
|
||||
{
|
||||
public:
|
||||
k_LanguageSpecifier mk_Glsl;
|
||||
std::vector<r_Keyword> mk_Keywords;
|
||||
|
||||
k_LexAnalyzer()
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~k_LexAnalyzer()
|
||||
{
|
||||
}
|
||||
|
||||
bool Parse(const CString& as_File);
|
||||
};
|
||||
308
space4k/src/4slang/SemAnalyzer.cpp
Normal file
308
space4k/src/4slang/SemAnalyzer.cpp
Normal file
@@ -0,0 +1,308 @@
|
||||
#include "stdafx.h"
|
||||
#include "SemAnalyzer.h"
|
||||
|
||||
|
||||
void k_SemAnalyzer::ParseScope(r_Scope* ar_Scope_, vector<r_Keyword>::iterator& ak_Iter, k_LexAnalyzer& ak_LexAnalyzer)
|
||||
{
|
||||
if (ak_Iter->ms_Name == _T("{"))
|
||||
++ak_Iter;
|
||||
|
||||
while (ak_Iter != ak_LexAnalyzer.mk_Keywords.end())
|
||||
{
|
||||
r_Keyword& lr_Keyword = *ak_Iter;
|
||||
|
||||
if (lr_Keyword.me_Type == r_KeywordType::Variable)
|
||||
{
|
||||
r_Keyword& lr_LastKeyword = *(ak_Iter - 1);
|
||||
r_Keyword& lr_NextKeyword = *(ak_Iter + 1);
|
||||
if (lr_LastKeyword.ms_Name != _T("."))
|
||||
{
|
||||
if (lr_NextKeyword.ms_Name == _T("("))
|
||||
{
|
||||
if (!ar_Scope_->ParentHasFunction(lr_Keyword.ms_Name))
|
||||
{
|
||||
CString ls_Message = mr_Program_->ms_FileName;
|
||||
ls_Message.AppendFormat(_T("(%d): Function call \""), lr_Keyword.mi_LineNumber);
|
||||
ls_Message += lr_Keyword.ms_Name;
|
||||
ls_Message += _T("\" wasn't declared in the 4slang language specifier!");
|
||||
throw ls_Message;
|
||||
}
|
||||
else
|
||||
{
|
||||
lr_Keyword.me_Type = r_KeywordType::FunctionCall;
|
||||
}
|
||||
}
|
||||
else if (lr_LastKeyword.me_Type == r_KeywordType::Type || lr_LastKeyword.ms_Name == _T(","))
|
||||
{
|
||||
if (lr_LastKeyword.ms_Name == _T(","))
|
||||
{
|
||||
vector<r_Keyword>::iterator lr_LastKeywordIter = ak_Iter;
|
||||
bool lb_VarDecl = false;
|
||||
do
|
||||
{
|
||||
r_Keyword& lr_TempLastKeyword = *lr_LastKeywordIter--;
|
||||
if (lr_TempLastKeyword.me_Type == r_KeywordType::Type)
|
||||
{
|
||||
lb_VarDecl = true;
|
||||
break;
|
||||
}
|
||||
else if (lr_TempLastKeyword.ms_Name == _T("("))
|
||||
{
|
||||
lb_VarDecl = false;
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
if (lb_VarDecl)
|
||||
lr_Keyword.me_Type = r_KeywordType::VariableDeclaration;
|
||||
}
|
||||
else
|
||||
{
|
||||
lr_Keyword.me_Type = r_KeywordType::VariableDeclaration;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lr_Keyword.me_Type = r_KeywordType::ReservedVariable;
|
||||
}
|
||||
}
|
||||
else if (lr_Keyword.ms_Name == _T("{"))
|
||||
{
|
||||
r_Scope* lr_NewScope_ = new r_Scope();
|
||||
lr_NewScope_->mr_ParentScope_ = ar_Scope_;
|
||||
ar_Scope_->mk_Scopes.push_back(lr_NewScope_);
|
||||
ParseScope(lr_NewScope_, ak_Iter, ak_LexAnalyzer);
|
||||
CString ls_ScopeId;
|
||||
ls_ScopeId.Format(_T("%d"), ar_Scope_->mk_Scopes.size() - 1);
|
||||
ar_Scope_->mk_Keywords.push_back(r_Keyword(r_KeywordType::Scope, ls_ScopeId, lr_Keyword.mi_LineNumber));
|
||||
continue;
|
||||
}
|
||||
else if (lr_Keyword.ms_Name == _T("}"))
|
||||
{
|
||||
++ak_Iter;
|
||||
break;
|
||||
}
|
||||
|
||||
ar_Scope_->mk_Keywords.push_back(lr_Keyword);
|
||||
|
||||
++ak_Iter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void k_SemAnalyzer::ParseFunction(r_Function* ar_Function_, vector<r_Keyword>::iterator& ak_Iter, k_LexAnalyzer& ak_LexAnalyzer)
|
||||
{
|
||||
CString ls_LastType;
|
||||
|
||||
while (ak_Iter != ak_LexAnalyzer.mk_Keywords.end())
|
||||
{
|
||||
r_Keyword& lr_Keyword = *ak_Iter;
|
||||
if (lr_Keyword.me_Type == r_KeywordType::Identifier)
|
||||
{
|
||||
ls_LastType = lr_Keyword.ms_Name + _T(" ");
|
||||
}
|
||||
if (lr_Keyword.me_Type == r_KeywordType::Type)
|
||||
{
|
||||
ls_LastType += lr_Keyword.ms_Name;
|
||||
}
|
||||
if (lr_Keyword.me_Type == r_KeywordType::Variable)
|
||||
{
|
||||
lr_Keyword.me_Type = r_KeywordType::ArgumentDeclaration;
|
||||
ar_Function_->mk_Parameters.push_back(r_Parameter(ls_LastType, lr_Keyword.ms_Name, lr_Keyword.mi_LineNumber));
|
||||
ls_LastType = _T("");
|
||||
++ak_Iter;
|
||||
}
|
||||
else if (lr_Keyword.ms_Name == _T("{"))
|
||||
{
|
||||
ParseScope(ar_Function_, ak_Iter, ak_LexAnalyzer);
|
||||
break;
|
||||
}
|
||||
else if (lr_Keyword.ms_Name == _T(";"))
|
||||
{
|
||||
++ak_Iter;
|
||||
break;
|
||||
}
|
||||
|
||||
++ak_Iter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void k_SemAnalyzer::ParseProgram(r_Program* ar_Program_, vector<r_Keyword>::iterator& ak_Iter, k_LexAnalyzer& ak_LexAnalyzer)
|
||||
{
|
||||
bool lb_CanBeRenamed = true;
|
||||
while (ak_Iter != ak_LexAnalyzer.mk_Keywords.end())
|
||||
{
|
||||
r_Keyword& lr_Keyword = *ak_Iter;
|
||||
bool lb_IgnoreKeyword = false;
|
||||
if (lr_Keyword.ms_Name.CompareNoCase(_T("varying")) == 0 ||
|
||||
lr_Keyword.ms_Name.CompareNoCase(_T("attribute")) == 0 ||
|
||||
lr_Keyword.ms_Name.CompareNoCase(_T("uniform")) == 0)
|
||||
{
|
||||
lb_CanBeRenamed = false;
|
||||
}
|
||||
if (lr_Keyword.ms_Name == _T(";"))
|
||||
{
|
||||
lb_CanBeRenamed = true;
|
||||
}
|
||||
|
||||
if (lr_Keyword.me_Type == r_KeywordType::Type)
|
||||
{
|
||||
r_Keyword& lr_NextKeyword = *(ak_Iter + 1);
|
||||
r_Keyword& lr_SuperNextKeyword = *(ak_Iter + 2);
|
||||
|
||||
if (lr_SuperNextKeyword.ms_Name == _T("("))
|
||||
{
|
||||
vector<r_Keyword>::const_iterator lk_TempIter = ak_Iter;
|
||||
do
|
||||
{
|
||||
++lk_TempIter;
|
||||
} while (lk_TempIter->ms_Name != ';' && lk_TempIter->ms_Name != '{');
|
||||
if (lk_TempIter->ms_Name == ';')
|
||||
{
|
||||
ar_Program_->mk_Keywords.push_back(lr_Keyword);
|
||||
lr_NextKeyword.me_Type = r_KeywordType::FunctionCall;
|
||||
ar_Program_->mk_Keywords.push_back(lr_NextKeyword); ++ak_Iter;
|
||||
ar_Program_->mk_Keywords.push_back(*++ak_Iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
++ak_Iter;
|
||||
++ak_Iter;
|
||||
}
|
||||
r_Function* lr_Function_ = new r_Function();
|
||||
lr_Function_->mr_ParentScope_ = ar_Program_;
|
||||
lr_Function_->ms_Name = lr_NextKeyword.ms_Name;
|
||||
lr_Function_->ms_ReturnType = lr_Keyword.ms_Name;
|
||||
if (lk_TempIter->ms_Name != ';')
|
||||
{
|
||||
ParseFunction(lr_Function_, ak_Iter, ak_LexAnalyzer);
|
||||
vector<r_Function*>::iterator lk_Existing = ar_Program_->mk_Functions.begin();
|
||||
for (; lk_Existing != ar_Program_->mk_Functions.end(); ++lk_Existing)
|
||||
{
|
||||
if ((*lk_Existing)->ms_Name.Compare(lr_Function_->ms_Name) == 0)
|
||||
{
|
||||
ar_Program_->mk_Functions.erase(lk_Existing);
|
||||
break;
|
||||
}
|
||||
}
|
||||
ar_Program_->mk_Functions.push_back(lr_Function_);
|
||||
}
|
||||
else
|
||||
{
|
||||
lk_TempIter = ak_Iter;
|
||||
ParseFunction(lr_Function_, ak_Iter, ak_LexAnalyzer);
|
||||
while (lk_TempIter != ak_Iter-1)
|
||||
ar_Program_->mk_Keywords.push_back(*++lk_TempIter);
|
||||
ar_Program_->mk_Functions.push_back(lr_Function_);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
lr_NextKeyword.me_Type = r_KeywordType::VariableDeclaration;
|
||||
lr_NextKeyword.mb_CanBeRenamed = lb_CanBeRenamed;
|
||||
do
|
||||
{
|
||||
if (lr_SuperNextKeyword.ms_Name == _T(","))
|
||||
{
|
||||
if (!lb_IgnoreKeyword)
|
||||
{
|
||||
lb_IgnoreKeyword = true;
|
||||
ar_Program_->mk_Keywords.push_back(lr_Keyword);
|
||||
}
|
||||
lr_NextKeyword = *++ak_Iter;
|
||||
lr_NextKeyword.me_Type = r_KeywordType::VariableDeclaration;
|
||||
lr_NextKeyword.mb_CanBeRenamed = lb_CanBeRenamed;
|
||||
ar_Program_->mk_Keywords.push_back(lr_NextKeyword);
|
||||
lr_SuperNextKeyword = *++ak_Iter;
|
||||
ar_Program_->mk_Keywords.push_back(lr_SuperNextKeyword);
|
||||
}
|
||||
} while (lr_SuperNextKeyword.ms_Name == _T(","));
|
||||
}
|
||||
}
|
||||
|
||||
if (!lb_IgnoreKeyword)
|
||||
{
|
||||
ar_Program_->mk_Keywords.push_back(lr_Keyword);
|
||||
}
|
||||
++ak_Iter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void k_SemAnalyzer::FillSymbolTables(r_Scope* ar_Scope_)
|
||||
{
|
||||
r_SymbolTable& lr_SymbolTable = ar_Scope_->mr_SymbolTable;
|
||||
|
||||
r_Function* lr_Function_ = dynamic_cast<r_Function*>(ar_Scope_);
|
||||
if (lr_Function_ != NULL)
|
||||
{
|
||||
vector<r_Parameter>::iterator lk_ParamIter = lr_Function_->mk_Parameters.begin();
|
||||
for (; lk_ParamIter != lr_Function_->mk_Parameters.end(); ++lk_ParamIter)
|
||||
{
|
||||
lr_SymbolTable.mk_Map[lk_ParamIter->ms_Name] = &(r_Keyword&)(*lk_ParamIter);
|
||||
}
|
||||
}
|
||||
|
||||
vector<r_Keyword>::iterator lk_KeywordIter = ar_Scope_->mk_Keywords.begin();
|
||||
for (; lk_KeywordIter != ar_Scope_->mk_Keywords.end(); ++lk_KeywordIter)
|
||||
{
|
||||
r_Keyword& lr_Keyword = *lk_KeywordIter;
|
||||
if (lr_Keyword.me_Type == r_KeywordType::VariableDeclaration)
|
||||
{
|
||||
lr_SymbolTable.mk_Map[lr_Keyword.ms_Name] = &lr_Keyword;
|
||||
}
|
||||
else if (lr_Keyword.me_Type == r_KeywordType::ArgumentDeclaration && dynamic_cast<r_Program*>(ar_Scope_) == NULL)
|
||||
{
|
||||
lr_SymbolTable.mk_Map[lr_Keyword.ms_Name] = &lr_Keyword;
|
||||
}
|
||||
else if (lr_Keyword.me_Type == r_KeywordType::Variable)
|
||||
{
|
||||
r_Keyword* lr_SymbolTableEntry_ = NULL;
|
||||
if (!ar_Scope_->SearchVariable(lr_Keyword.ms_Name, lr_SymbolTableEntry_))
|
||||
{
|
||||
CString ls_Error = mr_Program_->ms_FileName;
|
||||
ls_Error.AppendFormat(_T("(%d): Syntax error, variable \""), lr_Keyword.mi_LineNumber);
|
||||
ls_Error += lr_Keyword.ms_Name;
|
||||
ls_Error += _T("\" is undefined!");
|
||||
throw ls_Error;
|
||||
}
|
||||
else
|
||||
{
|
||||
lr_Keyword.mr_SymbolTableEntry_ = lr_SymbolTableEntry_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vector<r_Scope*>::iterator lk_ScopeIter = ar_Scope_->mk_Scopes.begin();
|
||||
for (; lk_ScopeIter != ar_Scope_->mk_Scopes.end(); ++lk_ScopeIter)
|
||||
{
|
||||
r_Scope* lr_Scope_ = *lk_ScopeIter;
|
||||
lr_SymbolTable.mk_Children.push_back(&lr_Scope_->mr_SymbolTable);
|
||||
lr_Scope_->mr_SymbolTable.mr_Parent_ = lr_Scope_;
|
||||
FillSymbolTables(lr_Scope_);
|
||||
}
|
||||
|
||||
r_Program* lr_Program_ = dynamic_cast<r_Program*>(ar_Scope_);
|
||||
if (lr_Program_ != NULL)
|
||||
{
|
||||
vector<r_Function*>::iterator lk_FuncIter = lr_Program_->mk_Functions.begin();
|
||||
for (; lk_FuncIter != lr_Program_->mk_Functions.end(); ++lk_FuncIter)
|
||||
{
|
||||
r_Scope* lr_Scope_ = (r_Scope*)*lk_FuncIter;
|
||||
lr_SymbolTable.mk_Children.push_back(&lr_Scope_->mr_SymbolTable);
|
||||
lr_Scope_->mr_SymbolTable.mr_Parent_ = lr_Scope_;
|
||||
FillSymbolTables(lr_Scope_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void k_SemAnalyzer::Analyze(k_LexAnalyzer& ak_LexAnalyzer, const CString& as_FileName)
|
||||
{
|
||||
vector<r_Keyword>::iterator lk_KeywordIter = ak_LexAnalyzer.mk_Keywords.begin();
|
||||
mr_Program_ = new r_Program(as_FileName);
|
||||
ParseProgram(mr_Program_, lk_KeywordIter, ak_LexAnalyzer);
|
||||
FillSymbolTables(mr_Program_);
|
||||
}
|
||||
119
space4k/src/4slang/SemAnalyzer.h
Normal file
119
space4k/src/4slang/SemAnalyzer.h
Normal file
@@ -0,0 +1,119 @@
|
||||
#pragma once
|
||||
|
||||
#include "LexAnalyzer.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
struct r_Scope;
|
||||
|
||||
|
||||
struct r_SymbolTable
|
||||
{
|
||||
map<CString, r_Keyword*> mk_Map;
|
||||
vector<r_SymbolTable*> mk_Children;
|
||||
r_Scope* mr_Parent_;
|
||||
};
|
||||
|
||||
|
||||
struct r_Scope
|
||||
{
|
||||
r_Scope() : mr_ParentScope_(NULL) {};
|
||||
|
||||
vector<r_Keyword> mk_Keywords;
|
||||
vector<CString> mk_Variables;
|
||||
vector<r_Scope*> mk_Scopes;
|
||||
r_Scope* mr_ParentScope_;
|
||||
r_SymbolTable mr_SymbolTable;
|
||||
|
||||
virtual bool ParentHasFunction(const CString& as_Function)
|
||||
{
|
||||
if (mr_ParentScope_ == NULL)
|
||||
return false;
|
||||
|
||||
return mr_ParentScope_->ParentHasFunction(as_Function);
|
||||
}
|
||||
|
||||
bool SearchVariable(const CString& as_Name, r_Keyword*& ar_SymbolTableEntry_)
|
||||
{
|
||||
if (mr_SymbolTable.mk_Map.find(as_Name) == mr_SymbolTable.mk_Map.end())
|
||||
{
|
||||
if (mr_ParentScope_ == NULL)
|
||||
return false;
|
||||
|
||||
return mr_ParentScope_->SearchVariable(as_Name, ar_SymbolTableEntry_);
|
||||
}
|
||||
|
||||
ar_SymbolTableEntry_ = mr_SymbolTable.mk_Map[as_Name];
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct r_Parameter
|
||||
: r_Keyword
|
||||
{
|
||||
r_Parameter(const CString& as_Type, const CString& as_Name, int ai_LineNumber)
|
||||
: r_Keyword(r_KeywordType::VariableDeclaration, as_Name, ai_LineNumber)
|
||||
, ms_VarType(as_Type)
|
||||
{
|
||||
}
|
||||
|
||||
CString ms_VarType;
|
||||
};
|
||||
|
||||
|
||||
struct r_Function : r_Scope
|
||||
{
|
||||
r_Function() : r_Scope() {};
|
||||
|
||||
CString ms_Name;
|
||||
CString ms_ReturnType;
|
||||
vector<r_Parameter> mk_Parameters;
|
||||
};
|
||||
|
||||
|
||||
struct r_Program : r_Scope
|
||||
{
|
||||
r_Program() : r_Scope() {};
|
||||
|
||||
r_Program(LPCTSTR as_FileName) : r_Scope(), ms_FileName(as_FileName) {};
|
||||
|
||||
virtual bool ParentHasFunction(const CString& as_Function)
|
||||
{
|
||||
if (mr_ParentScope_ != NULL)
|
||||
{
|
||||
if (mr_ParentScope_->ParentHasFunction(as_Function))
|
||||
return true;
|
||||
}
|
||||
|
||||
vector<r_Function*>::iterator lk_Iter = mk_Functions.begin();
|
||||
for (; lk_Iter != mk_Functions.end(); ++lk_Iter)
|
||||
{
|
||||
if ((*lk_Iter)->ms_Name == as_Function)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
vector<r_Function*> mk_Functions;
|
||||
CString ms_FileName;
|
||||
};
|
||||
|
||||
|
||||
class k_SemAnalyzer
|
||||
{
|
||||
public:
|
||||
r_Program* mr_Program_;
|
||||
|
||||
k_SemAnalyzer() {}
|
||||
virtual ~k_SemAnalyzer() {}
|
||||
|
||||
void ParseScope(r_Scope* ar_Scope_, vector<r_Keyword>::iterator& ak_Iter, k_LexAnalyzer& ak_LexAnalyzer);
|
||||
void ParseFunction(r_Function* ar_Function_, vector<r_Keyword>::iterator& ak_Iter, k_LexAnalyzer& ak_LexAnalyzer);
|
||||
void ParseProgram(r_Program* ar_Program_, vector<r_Keyword>::iterator& ak_Iter, k_LexAnalyzer& ak_LexAnalyzer);
|
||||
void FillSymbolTables(r_Scope* ar_Scope_);
|
||||
|
||||
void Analyze(k_LexAnalyzer& ak_LexAnalyzer, const CString& as_FileName);
|
||||
};
|
||||
8
space4k/src/4slang/stdafx.cpp
Normal file
8
space4k/src/4slang/stdafx.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// 4slang.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: reference any additional headers you need in STDAFX.H
|
||||
// and not in this file
|
||||
23
space4k/src/4slang/stdafx.h
Normal file
23
space4k/src/4slang/stdafx.h
Normal file
@@ -0,0 +1,23 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "targetver.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
#include <iostream>
|
||||
#include <tchar.h>
|
||||
|
||||
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
|
||||
|
||||
#include <atlbase.h>
|
||||
#include <atlstr.h>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
||||
24
space4k/src/4slang/targetver.h
Normal file
24
space4k/src/4slang/targetver.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
// The following macros define the minimum required platform. The minimum required platform
|
||||
// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
|
||||
// your application. The macros work by enabling all features available on platform versions up to and
|
||||
// including the version specified.
|
||||
|
||||
// Modify the following defines if you have to target a platform prior to the ones specified below.
|
||||
// Refer to MSDN for the latest info on corresponding values for different platforms.
|
||||
#ifndef WINVER // Specifies that the minimum required platform is Windows Vista.
|
||||
#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows.
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
|
||||
#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98.
|
||||
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0.
|
||||
#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE.
|
||||
#endif
|
||||
128
space4k/src/Compiler.cpp
Normal file
128
space4k/src/Compiler.cpp
Normal file
@@ -0,0 +1,128 @@
|
||||
#define COMPILER
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include "small.h"
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <memory.h>
|
||||
#include <tchar.h>
|
||||
#include <ios>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <sstream>
|
||||
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <atlbase.h>
|
||||
#include <atlstr.h>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
unsigned int gui_JumpPositions_[128];
|
||||
unsigned char guc_DemoData_[8192];
|
||||
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, char* cmdLine, int showState)
|
||||
{
|
||||
try
|
||||
{
|
||||
FILE* file;
|
||||
char* content = NULL;
|
||||
size_t count = 0;
|
||||
CStringA msg;
|
||||
|
||||
fopen_s(&file, cmdLine, "rt");
|
||||
if (file == NULL)
|
||||
{
|
||||
msg = "Error: Can't open ";
|
||||
msg += cmdLine;
|
||||
throw (LPCSTR)msg;
|
||||
}
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
count = ftell(file);
|
||||
rewind(file);
|
||||
|
||||
if (count <= 0)
|
||||
{
|
||||
msg = "Error: File ";
|
||||
msg += cmdLine;
|
||||
msg += " was empty or returned negative file size!";
|
||||
fclose(file);
|
||||
throw (LPCSTR)msg;
|
||||
}
|
||||
|
||||
content = new char[count];
|
||||
fread(content, 1, count, file);
|
||||
fclose(file);
|
||||
|
||||
CStringA outFile = cmdLine;
|
||||
outFile = outFile.Left(outFile.GetLength() - 4) + "h";
|
||||
fopen_s(&file, outFile, "w");
|
||||
|
||||
bool includeNewLines = true;
|
||||
|
||||
int outputCount = 0;
|
||||
msg = "#pragma once\n\n#pragma data_seg(\".shader\")\nstatic const char* shader = \""; fwrite(msg, 1, msg.GetLength(), file);
|
||||
bool comment = false;
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
{
|
||||
if (comment == true)
|
||||
{
|
||||
if (content[i] == '\n')
|
||||
{
|
||||
comment = false;
|
||||
if (!includeNewLines)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (content[i] == '\t' || content[i] == '\r')
|
||||
continue;
|
||||
|
||||
if (!includeNewLines && content[i] == '\n')
|
||||
continue;
|
||||
|
||||
if (content[i] == ' ' && content[i+1] == ' ')
|
||||
continue;
|
||||
|
||||
if (content[i] == '/' && content[i+1] == '/')
|
||||
{
|
||||
comment = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (content[i] == '\n')
|
||||
fwrite("\\n", 1, 2, file);
|
||||
else
|
||||
fwrite(&content[i], 1, 1, file);
|
||||
++outputCount;
|
||||
}
|
||||
fwrite("\";\n\n", 1, 4, file);
|
||||
|
||||
msg.Format("#pragma data_seg(\".shaderLength\")\nstatic const int shaderLength = %d;\n\n", outputCount); fwrite(msg, 1, msg.GetLength(), file);
|
||||
msg.Format("#pragma data_seg(\".shaderAmount\")\nstatic const int shaderAmount = %d;\n\n", 8); fwrite(msg, 1, msg.GetLength(), file);
|
||||
msg.Format("#pragma data_seg(\".shaderEntryPoint\")\nstatic char shaderEntryPoint[] = {'a', 0};\n\n"); fwrite(msg, 1, msg.GetLength(), file);
|
||||
msg.Format("#pragma data_seg(\".shaderProfiles\")\nstatic const char* shaderProfiles[] = {\"vs_3_0\", \"ps_3_0\", \"ps_3_0\", \"ps_3_0\", \"ps_3_0\", \"ps_3_0\", \"ps_3_0\", \"tx_1_0\"};\n\n"); fwrite(msg, 1, msg.GetLength(), file);
|
||||
//msg.Format("#pragma bss_seg(\".shaderBss\")\nstatic ID3DXBuffer* shaderBuffers[shaderAmount];"); fwrite(msg, 1, msg.GetLength(), file);
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
catch (LPCSTR e)
|
||||
{
|
||||
std::cerr << e << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
196
space4k/src/Compiler.vcproj
Normal file
196
space4k/src/Compiler.vcproj
Normal file
@@ -0,0 +1,196 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="Compiler"
|
||||
ProjectGUID="{AF4A824A-DAE6-4E28-8982-17D68A79AED1}"
|
||||
RootNamespace="Compiler"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)bin"
|
||||
IntermediateDirectory="$(SolutionDir)obj\$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
UseOfATL="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description=""
|
||||
CommandLine=""
|
||||
Outputs=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)bin"
|
||||
IntermediateDirectory="$(SolutionDir)obj\$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
UseOfATL="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description=""
|
||||
CommandLine=""
|
||||
Outputs=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;"
|
||||
RuntimeLibrary="2"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderThrough="CompilerStdAfx.h"
|
||||
PrecompiledHeaderFile="$(IntDir)\$(TargetName).pch"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
EntryPointSymbol=""
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Compiler"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Compiler.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\compiler.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
65
space4k/src/Compiler.vcproj.FIARA.Frank.user
Normal file
65
space4k/src/Compiler.vcproj.FIARA.Frank.user
Normal file
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<VisualStudioUserFile
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
ShowAllFiles="false"
|
||||
>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments="shaders.hlsl"
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="SHAIKUR"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor="0"
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="SHAIKUR"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
</VisualStudioUserFile>
|
||||
348
space4k/src/compiler.h
Normal file
348
space4k/src/compiler.h
Normal file
@@ -0,0 +1,348 @@
|
||||
#pragma once
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
struct r_OpCodeParams
|
||||
{
|
||||
r_OpCodeParams() {};
|
||||
|
||||
r_OpCodeParams(CStringA as_FunctionName, int ai_Arguments)
|
||||
: ms_FunctionName(as_FunctionName)
|
||||
, mi_Arguments(ai_Arguments)
|
||||
{
|
||||
}
|
||||
|
||||
CStringA ms_FunctionName;
|
||||
int mi_Arguments;
|
||||
};
|
||||
|
||||
|
||||
map<CStringA, int> gk_LabelMap;
|
||||
map<CStringA, int> gk_IndexMap;
|
||||
map<CStringA, int> gk_UsedOpcodes;
|
||||
map<CStringA, r_OpCodeParams> gk_SupportedOpcodes;
|
||||
map<CStringA, int> gk_Supported;
|
||||
CStringA gs_Path;
|
||||
|
||||
|
||||
void CompileOpcodes(const char* as_OpcodeFile, map<CStringA, r_OpCodeParams>& ak_SupportedOpcodes)
|
||||
{
|
||||
ifstream lr_OpcodeInputFile;
|
||||
lr_OpcodeInputFile.open(as_OpcodeFile);
|
||||
if (!lr_OpcodeInputFile)
|
||||
{
|
||||
cerr << "Unable to open opcodes.txt!";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while (!lr_OpcodeInputFile.eof())
|
||||
{
|
||||
char s[255];
|
||||
lr_OpcodeInputFile.getline(s, 255);
|
||||
CStringA ls_Line = s;
|
||||
ls_Line.Trim();
|
||||
int li_NextTab = ls_Line.Find('\t');
|
||||
int li_NextSpace = ls_Line.Find(' ');
|
||||
int li_Cut = min(li_NextSpace, li_NextTab);
|
||||
if (li_Cut == -1)
|
||||
{
|
||||
li_Cut = max(li_NextSpace, li_NextTab);
|
||||
}
|
||||
CStringA ls_Opcode;
|
||||
if (li_Cut != -1)
|
||||
{
|
||||
ls_Opcode = ls_Line.Left(li_Cut);
|
||||
ls_Line = ls_Line.Mid(li_Cut);
|
||||
ls_Line.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
ls_Opcode = ls_Line;
|
||||
ls_Line = "";
|
||||
}
|
||||
|
||||
li_NextTab = ls_Line.Find('\t');
|
||||
li_NextSpace = ls_Line.Find(' ');
|
||||
li_Cut = min(li_NextSpace, li_NextTab);
|
||||
if (li_Cut == -1)
|
||||
{
|
||||
li_Cut = max(li_NextSpace, li_NextTab);
|
||||
}
|
||||
CStringA ls_FunctionName;
|
||||
if (li_Cut != -1)
|
||||
{
|
||||
ls_FunctionName = ls_Line.Left(li_Cut);
|
||||
ls_Line = ls_Line.Mid(li_Cut);
|
||||
ls_Line.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
ls_FunctionName = ls_Line;
|
||||
ls_Line = "";
|
||||
}
|
||||
|
||||
int li_ArgCount = 0;
|
||||
_stscanf_s(ls_Line, _T("%d"), &li_ArgCount);
|
||||
|
||||
ak_SupportedOpcodes[ls_Opcode] = r_OpCodeParams(ls_FunctionName, li_ArgCount);
|
||||
}
|
||||
lr_OpcodeInputFile.close();
|
||||
}
|
||||
|
||||
|
||||
vector<CStringA> GetLinesFromFile(const char* as_DemoFile)
|
||||
{
|
||||
vector<CStringA> lk_Result;
|
||||
|
||||
ifstream lr_File;
|
||||
lr_File.open(as_DemoFile);
|
||||
if (!lr_File)
|
||||
{
|
||||
cerr << "Unable to open input file " << as_DemoFile << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while (!lr_File.eof())
|
||||
{
|
||||
char s[255];
|
||||
lr_File.getline(s, 255);
|
||||
CStringA ls_Input = s;
|
||||
CStringA ls_Line = s;
|
||||
int li_Comment = ls_Line.Find("//");
|
||||
if (li_Comment != -1)
|
||||
ls_Line = ls_Line.Left(li_Comment);
|
||||
ls_Line.Trim();
|
||||
int li_NextTab = ls_Line.Find('\t');
|
||||
int li_NextSpace = ls_Line.Find(' ');
|
||||
int li_Cut = min(li_NextSpace, li_NextTab);
|
||||
if (li_Cut == -1)
|
||||
{
|
||||
li_Cut = max(li_NextSpace, li_NextTab);
|
||||
}
|
||||
CStringA ls_Command;
|
||||
if (li_Cut != -1)
|
||||
{
|
||||
ls_Command = ls_Line.Left(li_Cut);
|
||||
ls_Line = ls_Line.Mid(li_Cut);
|
||||
ls_Line.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
ls_Command = ls_Line;
|
||||
ls_Line = "";
|
||||
}
|
||||
|
||||
int li_SpecialMarker = ls_Command.Find("@");
|
||||
if (li_SpecialMarker == 0)
|
||||
{
|
||||
ls_Command = ls_Command.Mid(1);
|
||||
if (ls_Command.CollateNoCase("include") == 0)
|
||||
{
|
||||
ls_Line.Trim();
|
||||
vector<CStringA> lk_New = GetLinesFromFile(gs_Path + ls_Line);
|
||||
lk_Result.insert(lk_Result.end(), lk_New.begin(), lk_New.end());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
lk_Result.push_back(ls_Input);
|
||||
}
|
||||
|
||||
return lk_Result;
|
||||
}
|
||||
|
||||
|
||||
void CompileDemo(const vector<CStringA>& ak_CodeLines, unsigned int aui_JumpPositions_[128], unsigned char auc_DemoData_[8192], int* ai_DemoSize)
|
||||
{
|
||||
int li_LabelIndex = 0;
|
||||
|
||||
// Find and mark labels, check parameter count
|
||||
int li_ByteCount = 0;
|
||||
int li_Line = 0;
|
||||
vector<CStringA>::const_iterator lk_LinesIterator = ak_CodeLines.begin();
|
||||
for (; lk_LinesIterator != ak_CodeLines.end(); ++lk_LinesIterator)
|
||||
{
|
||||
++li_Line;
|
||||
CStringA ls_Line = *lk_LinesIterator;
|
||||
int li_Comment = ls_Line.Find("//");
|
||||
if (li_Comment != -1)
|
||||
ls_Line = ls_Line.Left(li_Comment);
|
||||
ls_Line.Trim();
|
||||
int li_NextTab = ls_Line.Find('\t');
|
||||
int li_NextSpace = ls_Line.Find(' ');
|
||||
int li_Cut = min(li_NextSpace, li_NextTab);
|
||||
if (li_Cut == -1)
|
||||
{
|
||||
li_Cut = max(li_NextSpace, li_NextTab);
|
||||
}
|
||||
CStringA ls_Command;
|
||||
if (li_Cut != -1)
|
||||
{
|
||||
ls_Command = ls_Line.Left(li_Cut);
|
||||
ls_Line = ls_Line.Mid(li_Cut);
|
||||
ls_Line.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
ls_Command = ls_Line;
|
||||
ls_Line = "";
|
||||
}
|
||||
|
||||
int li_LabelMarker = ls_Command.Find(":");
|
||||
if (li_LabelMarker == 0)
|
||||
{
|
||||
ls_Command = ls_Command.Mid(1);
|
||||
gk_LabelMap[ls_Command] = li_ByteCount;
|
||||
continue;
|
||||
}
|
||||
|
||||
int li_SpecialMarker = ls_Command.Find("@");
|
||||
if (li_SpecialMarker == 0)
|
||||
{
|
||||
ls_Command = ls_Command.Mid(1);
|
||||
if (ls_Command.CollateNoCase("support") == 0)
|
||||
{
|
||||
gk_Supported[ls_Line] = 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
int li_ParamCount = 0;
|
||||
|
||||
while (ls_Line.Find("reg") != -1)
|
||||
{
|
||||
int li_Count = ls_Line.Replace("reg", "255,");
|
||||
li_ParamCount += li_Count;
|
||||
}
|
||||
|
||||
map<CStringA, r_OpCodeParams>::iterator lk_OpcodeIterator = gk_SupportedOpcodes.begin();
|
||||
for (; lk_OpcodeIterator != gk_SupportedOpcodes.end(); ++lk_OpcodeIterator)
|
||||
{
|
||||
if (ls_Command.CompareNoCase(lk_OpcodeIterator->first) == 0)
|
||||
{
|
||||
gk_UsedOpcodes[ls_Command] = 1;
|
||||
li_ParamCount += lk_OpcodeIterator->second.mi_Arguments;
|
||||
li_ByteCount += 1 + li_ParamCount;
|
||||
|
||||
// check arg count
|
||||
int li_Count = ls_Line.Replace(",", ".");
|
||||
if (ls_Line.GetLength() == 0)
|
||||
li_Count--;
|
||||
if (li_Count+1 != li_ParamCount)
|
||||
{
|
||||
ATLTRACE("An error has occurred");
|
||||
cout << "Error at line " << li_Line << ": " << lk_OpcodeIterator->first << " expects " << lk_OpcodeIterator->second.mi_Arguments << " parameters; [" << *lk_LinesIterator << "]" << endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
map<CStringA, int>::iterator lk_Iterator = gk_LabelMap.begin();
|
||||
for (int i = 0; lk_Iterator != gk_LabelMap.end(); ++lk_Iterator, ++i)
|
||||
{
|
||||
CStringA ls_LabelString = ":";
|
||||
ls_LabelString += lk_Iterator->first;
|
||||
aui_JumpPositions_[i] = lk_Iterator->second;
|
||||
gk_IndexMap[ls_LabelString.Mid(1)] = li_LabelIndex++;
|
||||
}
|
||||
|
||||
// compile code
|
||||
int li_DemoDataIndex = 0;
|
||||
|
||||
int li_Index = 0;
|
||||
lk_LinesIterator = ak_CodeLines.begin();
|
||||
for (; lk_LinesIterator != ak_CodeLines.end(); ++lk_LinesIterator)
|
||||
{
|
||||
CStringA ls_Line = *lk_LinesIterator;
|
||||
int li_Comment = ls_Line.Find("//");
|
||||
if (li_Comment != -1)
|
||||
ls_Line = ls_Line.Left(li_Comment);
|
||||
ls_Line.Trim();
|
||||
int li_NextTab = ls_Line.Find('\t');
|
||||
int li_NextSpace = ls_Line.Find(' ');
|
||||
int li_Cut = min(li_NextSpace, li_NextTab);
|
||||
if (li_Cut == -1)
|
||||
{
|
||||
li_Cut = max(li_NextSpace, li_NextTab);
|
||||
}
|
||||
CStringA ls_Command;
|
||||
if (li_Cut != -1)
|
||||
{
|
||||
ls_Command = ls_Line.Left(li_Cut);
|
||||
ls_Line = ls_Line.Mid(li_Cut);
|
||||
ls_Line.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
ls_Command = ls_Line;
|
||||
ls_Line = "";
|
||||
}
|
||||
|
||||
li_Index += ls_Line.Replace("reg", "255,");
|
||||
|
||||
int li_LabelMarker = ls_Command.Find(":");
|
||||
if (li_LabelMarker == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
map<CStringA, int>::iterator lk_Iterator = gk_IndexMap.begin();
|
||||
for (; lk_Iterator != gk_IndexMap.end(); ++lk_Iterator)
|
||||
{
|
||||
CStringA ls_LabelString = ":";
|
||||
ls_LabelString += lk_Iterator->first;
|
||||
char ls_Temp[6];
|
||||
sprintf_s(ls_Temp, 6, "%d", lk_Iterator->second);
|
||||
ls_Line.Replace(ls_LabelString, ls_Temp);
|
||||
}
|
||||
|
||||
map<CStringA, int>::iterator lk_OpcodeIterator = gk_UsedOpcodes.begin();
|
||||
int i = 0;
|
||||
for (; lk_OpcodeIterator != gk_UsedOpcodes.end(); ++lk_OpcodeIterator)
|
||||
{
|
||||
if (ls_Command.CompareNoCase(lk_OpcodeIterator->first) == 0)
|
||||
{
|
||||
li_Index += 1 + gk_SupportedOpcodes[lk_OpcodeIterator->first].mi_Arguments;
|
||||
auc_DemoData_[li_DemoDataIndex++] = i;
|
||||
if (ls_Line.GetLength() != 0)
|
||||
{
|
||||
int li_Comma = -1;
|
||||
do
|
||||
{
|
||||
ls_Line.Trim();
|
||||
li_Comma = ls_Line.Find(',');
|
||||
if (li_Comma != -1)
|
||||
{
|
||||
CStringA ls_Value = ls_Line.Left(li_Comma);
|
||||
ls_Value.Trim();
|
||||
if (ls_Value.GetLength() != 0)
|
||||
{
|
||||
int li_Value;
|
||||
_stscanf_s(ls_Value, _T("%d"), &li_Value);
|
||||
auc_DemoData_[li_DemoDataIndex++] = li_Value;
|
||||
}
|
||||
ls_Line = ls_Line.Mid(li_Comma+1);
|
||||
}
|
||||
else if (ls_Line.GetLength() != 0)
|
||||
{
|
||||
int li_Value;
|
||||
_stscanf_s(ls_Line, _T("%d"), &li_Value);
|
||||
auc_DemoData_[li_DemoDataIndex++] = li_Value;
|
||||
}
|
||||
} while(li_Comma != -1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
(*ai_DemoSize) = li_DemoDataIndex;
|
||||
}
|
||||
|
||||
|
||||
void CompileDemoFromFile(const char* as_DemoFile, unsigned int aui_JumpPositions_[128], unsigned char auc_DemoData_[8192], int* ai_DemoSize)
|
||||
{
|
||||
CompileDemo(GetLinesFromFile(as_DemoFile), aui_JumpPositions_, auc_DemoData_, ai_DemoSize);
|
||||
}
|
||||
6
space4k/src/config.h
Normal file
6
space4k/src/config.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#define WIDTH 640
|
||||
#define HEIGHT 480
|
||||
#define ASPECT 1.6f
|
||||
#define WINDOWED true
|
||||
202
space4k/src/debug.h
Normal file
202
space4k/src/debug.h
Normal file
@@ -0,0 +1,202 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <io.h>
|
||||
static __time64_t gi_ShaderChangedDate[shaderCount];
|
||||
static bool executed;
|
||||
bool ReloadShader()
|
||||
{
|
||||
bool result = false;
|
||||
_finddata_t fdata;
|
||||
for (int i = 0; i < shaderCount; ++i)
|
||||
{
|
||||
long hfile = _findfirst(shaderFileName[i], &fdata);
|
||||
if (hfile != -1)
|
||||
{
|
||||
if (fdata.time_write != gi_ShaderChangedDate[i])
|
||||
{
|
||||
FILE* lh_File;
|
||||
char* ls_Content_ = NULL;
|
||||
size_t li_Count = 0;
|
||||
|
||||
fopen_s(&lh_File, shaderFileName[i], "rt");
|
||||
if (lh_File == NULL)
|
||||
return false;
|
||||
|
||||
fseek(lh_File, 0, SEEK_END);
|
||||
li_Count = ftell(lh_File);
|
||||
rewind(lh_File);
|
||||
|
||||
if (li_Count <= 0)
|
||||
return false;
|
||||
|
||||
ls_Content_ = new char[li_Count + 1];
|
||||
li_Count = fread_s(ls_Content_, li_Count + 1, sizeof(char), li_Count, lh_File);
|
||||
ls_Content_[li_Count] = 0;
|
||||
|
||||
fclose(lh_File);
|
||||
|
||||
if (executed)
|
||||
{
|
||||
delete [] fsh[i];
|
||||
}
|
||||
fsh[i] = ls_Content_;
|
||||
gi_ShaderChangedDate[i] = fdata.time_write;
|
||||
result = true;
|
||||
}
|
||||
_findclose(hfile);
|
||||
}
|
||||
}
|
||||
if (result && !executed)
|
||||
{
|
||||
executed = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void PrintErrors()
|
||||
{
|
||||
GLenum lr_Error = GL_NO_ERROR;
|
||||
int li_ErrorCount = 5;
|
||||
do
|
||||
{
|
||||
lr_Error = glGetError();
|
||||
if (lr_Error != GL_NO_ERROR)
|
||||
{
|
||||
li_ErrorCount--;
|
||||
char* ls_ErrorString = (char*)gluErrorString(lr_Error);
|
||||
if (ls_ErrorString != 0)
|
||||
std::cout << "OPENGL :: ERROR " << ls_ErrorString << std::endl;
|
||||
}
|
||||
if (li_ErrorCount == 0)
|
||||
{
|
||||
std::cout << "OPENGL :: ERROR Too many errors!" << std::endl;
|
||||
break;
|
||||
}
|
||||
} while (lr_Error != GL_NO_ERROR);
|
||||
}
|
||||
|
||||
void printShaderInfoLog(GLhandleARB ah_Shader)
|
||||
{
|
||||
int li_InfologLength = 0;
|
||||
int li_CharsWritten = 0;
|
||||
char* li_InfoLog;
|
||||
|
||||
((PFNGLGETSHADERIVPROC)wglGetProcAddress("glGetShaderiv"))(ah_Shader, GL_INFO_LOG_LENGTH, &li_InfologLength);
|
||||
|
||||
if (li_InfologLength > 0)
|
||||
{
|
||||
li_InfoLog = (char*) malloc(li_InfologLength);
|
||||
|
||||
((PFNGLGETSHADERINFOLOGPROC)wglGetProcAddress("glGetShaderInfoLog"))(ah_Shader, li_InfologLength, &li_CharsWritten, li_InfoLog);
|
||||
|
||||
std::cerr << li_InfoLog << std::endl;
|
||||
free(li_InfoLog);
|
||||
}
|
||||
}
|
||||
|
||||
void printProgramInfoLog(GLhandleARB ah_Program)
|
||||
{
|
||||
int li_InfologLength = 0;
|
||||
int li_CharsWritten = 0;
|
||||
char* ls_InfoLog;
|
||||
|
||||
((PFNGLGETPROGRAMIVPROC)wglGetProcAddress("glGetProgramiv"))(ah_Program, GL_INFO_LOG_LENGTH, &li_InfologLength);
|
||||
|
||||
if (li_InfologLength > 0)
|
||||
{
|
||||
ls_InfoLog = (char *)malloc(li_InfologLength);
|
||||
|
||||
((PFNGLGETPROGRAMINFOLOGPROC)wglGetProcAddress("glGetProgramInfoLog"))(ah_Program, li_InfologLength, &li_CharsWritten, ls_InfoLog);
|
||||
|
||||
std::cerr << ls_InfoLog << std::endl;
|
||||
free(ls_InfoLog);
|
||||
}
|
||||
}
|
||||
|
||||
GLhandleARB createVertexShader(const char* as_Shader)
|
||||
{
|
||||
GLhandleARB lh_Shader = 0;
|
||||
|
||||
lh_Shader = ((PFNGLCREATESHADERPROC)wglGetProcAddress(glCreateShader))(GL_VERTEX_SHADER);
|
||||
|
||||
((PFNGLSHADERSOURCEPROC)wglGetProcAddress(glShaderSource))(lh_Shader, 1, (const char**)&as_Shader, NULL);
|
||||
((PFNGLCOMPILESHADERPROC)wglGetProcAddress(glCompileShader))(lh_Shader);
|
||||
|
||||
int li_Status = 0;
|
||||
((PFNGLGETSHADERIVPROC)wglGetProcAddress("glGetShaderiv"))(lh_Shader, GL_COMPILE_STATUS, &li_Status);
|
||||
|
||||
if (li_Status == GL_FALSE)
|
||||
{
|
||||
std::cerr << "Error compiling vertex shader" << std::endl;
|
||||
printShaderInfoLog(lh_Shader);
|
||||
}
|
||||
|
||||
return lh_Shader;
|
||||
}
|
||||
|
||||
|
||||
GLhandleARB createFragmentShader(const char* as_Shader)
|
||||
{
|
||||
GLhandleARB lh_Shader = 0;
|
||||
lh_Shader = ((PFNGLCREATESHADERPROC)wglGetProcAddress(glCreateShader))(GL_FRAGMENT_SHADER);
|
||||
|
||||
((PFNGLSHADERSOURCEPROC)wglGetProcAddress(glShaderSource))(lh_Shader, 1, (const char**)&as_Shader, NULL);
|
||||
((PFNGLCOMPILESHADERPROC)wglGetProcAddress(glCompileShader))(lh_Shader);
|
||||
|
||||
int li_Status = 0;
|
||||
|
||||
((PFNGLGETSHADERIVPROC)wglGetProcAddress("glGetShaderiv"))(lh_Shader, GL_COMPILE_STATUS, &li_Status);
|
||||
|
||||
if (li_Status == GL_FALSE)
|
||||
{
|
||||
std::cerr << "Error compiling fragment shader" << std::endl;
|
||||
printShaderInfoLog(lh_Shader);
|
||||
}
|
||||
|
||||
return lh_Shader;
|
||||
}
|
||||
|
||||
|
||||
GLhandleARB createProgram(GLhandleARB ah_VertexShader, GLhandleARB ah_FragmentShader)
|
||||
{
|
||||
GLhandleARB lh_Program = 0;
|
||||
|
||||
if (ah_VertexShader + ah_FragmentShader <= 1)
|
||||
{
|
||||
std::cerr << "Cannot create program." << std::endl;
|
||||
return lh_Program;
|
||||
}
|
||||
|
||||
lh_Program = ((PFNGLCREATEPROGRAMPROC)wglGetProcAddress(glCreateProgram))();
|
||||
|
||||
((PFNGLATTACHSHADERPROC)wglGetProcAddress(glAttachShader))(lh_Program, ah_VertexShader);
|
||||
((PFNGLATTACHSHADERPROC)wglGetProcAddress(glAttachShader))(lh_Program, ah_FragmentShader);
|
||||
((PFNGLLINKPROGRAMPROC)wglGetProcAddress(glLinkProgram))(lh_Program);
|
||||
|
||||
int li_Status = 0;
|
||||
|
||||
((PFNGLGETPROGRAMIVPROC)wglGetProcAddress("glGetProgramiv"))(lh_Program, GL_LINK_STATUS, &li_Status);
|
||||
|
||||
if (li_Status == GL_FALSE)
|
||||
{
|
||||
std::cerr << "Error linking shaders." << std::endl;
|
||||
printProgramInfoLog(lh_Program);
|
||||
}
|
||||
|
||||
return lh_Program;
|
||||
}
|
||||
|
||||
void CreateShadersDBG()
|
||||
{
|
||||
for (int i = 0; i < shaderCount; ++i)
|
||||
{
|
||||
std::cout << "Compiling " << shaderFileName[i] << "..." << std::endl;
|
||||
shaders[i] = createProgram(createVertexShader(vertexShader), createFragmentShader(fsh[i]));
|
||||
}
|
||||
PrintErrors();
|
||||
}
|
||||
|
||||
#endif
|
||||
67
space4k/src/demo.h
Normal file
67
space4k/src/demo.h
Normal file
@@ -0,0 +1,67 @@
|
||||
#pragma once
|
||||
|
||||
#pragma data_seg(".scenes")
|
||||
static const unsigned char scenes[] = {0, 1, 1, 40, 80, 80, 255};
|
||||
|
||||
#pragma data_seg(".fromVector")
|
||||
static D3DXVECTOR3 fromVector[] =
|
||||
{
|
||||
D3DXVECTOR3(0,0,0), // don't use
|
||||
D3DXVECTOR3(-1,-1,-3),
|
||||
D3DXVECTOR3(-2,0,3),
|
||||
D3DXVECTOR3(-3,0,2),
|
||||
D3DXVECTOR3(-3,0,-5),
|
||||
D3DXVECTOR3(5,0,-5),
|
||||
};
|
||||
|
||||
#pragma data_seg(".toVector")
|
||||
static D3DXVECTOR3 toVector[] =
|
||||
{
|
||||
D3DXVECTOR3(0,0,0), // don't use
|
||||
D3DXVECTOR3(-1,1,-3),
|
||||
D3DXVECTOR3(1,0,3),
|
||||
D3DXVECTOR3(-2,0,3),
|
||||
D3DXVECTOR3(-3,0,5),
|
||||
D3DXVECTOR3(-5,0,-5),
|
||||
};
|
||||
|
||||
#pragma data_seg(".centerVector")
|
||||
static D3DXVECTOR3 centerVector[] =
|
||||
{
|
||||
D3DXVECTOR3(0,0,0), // don't use
|
||||
D3DXVECTOR3(0,0,-5),
|
||||
D3DXVECTOR3(0,0,5),
|
||||
D3DXVECTOR3(-1,0,0),
|
||||
D3DXVECTOR3(0,0,0),
|
||||
D3DXVECTOR3(0,0,0),
|
||||
};
|
||||
|
||||
#pragma code_seg(".BluePlanetWithNebula")
|
||||
void BluePlanetWithNebula(UINT)
|
||||
{
|
||||
float s = time / (scenes[scene]);
|
||||
fade = x_Min(1,x_Sin(s*_Pi)*14);
|
||||
D3DXVec3Lerp(fromVector, &fromVector[scene], &toVector[scene], s);
|
||||
D3DXMatrixLookAtLH(&viewMatrix, fromVector, ¢erVector[scene], &D3DXVECTOR3(0, 1, 0));
|
||||
D3DXMatrixRotationYawPitchRoll(&worldMatrix, 0, 0, 0);
|
||||
Sphere(earthPixelShader);
|
||||
D3DXMatrixScaling(&worldMatrix, -10.0f, -10.0f, -10.0f);
|
||||
Sphere(skyPixelShader);
|
||||
D3DXMatrixTranslation(&worldMatrix, x_Cos(time*.3)-1.5f, 0.0f, 0.0f);
|
||||
D3DXMatrixScaling(&scaleMatrix, 0.2f, 0.2f, 0.2f);
|
||||
D3DXMatrixMultiply(&worldMatrix, &scaleMatrix, &worldMatrix);
|
||||
Sphere(moonPixelShader);
|
||||
}
|
||||
|
||||
#pragma data_seg(".scenefp")
|
||||
static void (*CallScene[])(UINT) = {
|
||||
0, BluePlanetWithNebula, BluePlanetWithNebula, BluePlanetWithNebula, BluePlanetWithNebula, BluePlanetWithNebula, ExitProcess
|
||||
};
|
||||
|
||||
#pragma code_seg(".RenderScene")
|
||||
inline void RenderScene()
|
||||
{
|
||||
scene = 0;
|
||||
while (time >= scenes[scene]) { time -= scenes[scene++]; };
|
||||
CallScene[scene](0);
|
||||
}
|
||||
64
space4k/src/dx.cpp
Normal file
64
space4k/src/dx.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
#ifdef _DEBUG
|
||||
#define D3D_DEBUG_INFO
|
||||
#endif
|
||||
|
||||
#include "dxincludes.h"
|
||||
extern "C" int _fltused = 1;
|
||||
|
||||
#pragma data_seg(".edit")
|
||||
static char* edit = "edit";
|
||||
|
||||
#pragma code_seg(".main")
|
||||
void __cdecl main(void)
|
||||
{
|
||||
_asm
|
||||
{
|
||||
XOR ESI, ESI
|
||||
PUSH ESI
|
||||
PUSH ESI
|
||||
PUSH ESI
|
||||
PUSH ESI
|
||||
PUSH ESI
|
||||
PUSH ESI
|
||||
PUSH HEIGHT
|
||||
PUSH WIDTH
|
||||
PUSH ESI
|
||||
PUSH ESI
|
||||
PUSH WS_VISIBLE
|
||||
PUSH ESI
|
||||
PUSH edit
|
||||
PUSH 0x8
|
||||
CALL dword ptr [CreateWindowExA]
|
||||
MOV dword ptr [wnd], EAX
|
||||
CALL dword ptr [ShowCursor]
|
||||
CALL dword ptr [CreateD3D]
|
||||
CALL dword ptr [InitSound]
|
||||
|
||||
theloop:
|
||||
call dword ptr [get_Time]
|
||||
fstp dword ptr [time]
|
||||
CALL dword ptr [DrawFrame]
|
||||
PUSH VK_ESCAPE
|
||||
CALL dword ptr [GetAsyncKeyState]
|
||||
test eax, eax
|
||||
jz theloop
|
||||
CALL dword ptr [ExitProcess]
|
||||
}
|
||||
// oder static oder EDIT
|
||||
//wnd = CreateWindowEx(WS_EX_TOPMOST, "edit", NULL, WS_POPUP | WS_VISIBLE | WS_MAXIMIZE, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
//wnd = CreateWindowEx(8, "edit", NULL, WS_VISIBLE, 0, 0, WIDTH, HEIGHT, 0, 0, 0, NULL);
|
||||
//d3dPresParas.Windowed = true;
|
||||
//ShowCursor(FALSE);
|
||||
|
||||
//CreateD3D();
|
||||
//InitSound();
|
||||
|
||||
/*while (GetAsyncKeyState(VK_ESCAPE) == 0)
|
||||
{
|
||||
time = get_Time();
|
||||
DrawFrame();
|
||||
}
|
||||
|
||||
ExitProcess(0);*/
|
||||
|
||||
}
|
||||
305
space4k/src/dxgraphics.h
Normal file
305
space4k/src/dxgraphics.h
Normal file
@@ -0,0 +1,305 @@
|
||||
#pragma once
|
||||
|
||||
#pragma data_seg(".shaderCreationFunctions")
|
||||
static int shaderCreationFunctions[] =
|
||||
{
|
||||
0x16C, //CreateVertexShader
|
||||
0x1A8, //CreatePixelShader
|
||||
0x1A8, //CreatePixelShader
|
||||
0x1A8, //CreatePixelShader
|
||||
0x1A8, //CreatePixelShader
|
||||
0x1A8, //CreatePixelShader
|
||||
0x1A8, //CreatePixelShader
|
||||
0
|
||||
};
|
||||
|
||||
#pragma data_seg(".shaderTargets")
|
||||
static void* shaderTargets[] =
|
||||
{
|
||||
&lightVertexShader,
|
||||
&earthPixelShader,
|
||||
&blurPixelShader,
|
||||
&haloCombinePixelShader,
|
||||
&combinePixelShader,
|
||||
&skyPixelShader,
|
||||
&moonPixelShader,
|
||||
&noiseTextureShader,
|
||||
};
|
||||
|
||||
#pragma code_seg(".CreateD3D")
|
||||
inline void CreateD3D()
|
||||
{
|
||||
_asm
|
||||
{
|
||||
// set the wnd handle to the d3dPresParas
|
||||
mov eax, dword ptr [wnd]
|
||||
mov dword ptr [d3dPresParas + 1Ch],eax
|
||||
|
||||
// create IDirect3D9
|
||||
push D3D_SDK_VERSION
|
||||
call dword ptr [Direct3DCreate9]
|
||||
|
||||
// create IDirect3DDevice9
|
||||
push offset direct3dDevice
|
||||
push offset d3dPresParas
|
||||
push 80h
|
||||
push dword ptr [wnd]
|
||||
push 1
|
||||
push esi
|
||||
push eax
|
||||
mov eax, dword ptr [eax]
|
||||
call dword ptr [eax+40h]
|
||||
|
||||
// Create all shaders in a loop
|
||||
xor ebx, ebx
|
||||
shaderloop:
|
||||
|
||||
// D3DXCompileShader
|
||||
push esi
|
||||
push offset errorBuffer
|
||||
push offset shaderBuffer
|
||||
push esi
|
||||
push dword ptr shaderProfiles[ebx*4]
|
||||
push offset shaderEntryPoint
|
||||
push esi
|
||||
push esi
|
||||
push shaderLength
|
||||
push dword ptr [shader]
|
||||
call dword ptr [D3DXCompileShader]
|
||||
|
||||
// Increment the shader entry point character (from a to z)
|
||||
mov eax, dword ptr [shaderEntryPoint]
|
||||
inc eax
|
||||
mov dword ptr [shaderEntryPoint], eax
|
||||
|
||||
push dword ptr shaderTargets[ebx*4]
|
||||
|
||||
// Call ID3DXBuffer::GetBuffer from the shader error buffer
|
||||
mov eax, dword ptr [errorBuffer]
|
||||
mov eax, dword ptr [eax]
|
||||
push dword ptr [errorBuffer]
|
||||
call dword ptr [eax+0Ch]
|
||||
push eax
|
||||
call dword ptr [OutputDebugStringA]
|
||||
|
||||
// Call ID3DXBuffer::GetBuffer
|
||||
mov eax, dword ptr [shaderBuffer]
|
||||
mov eax, dword ptr [eax]
|
||||
// if it crashes here, check output window, because the shader
|
||||
// has an error and couldn't compile!
|
||||
push dword ptr [shaderBuffer]
|
||||
call dword ptr [eax+0Ch]
|
||||
push eax
|
||||
|
||||
// If we're done, exit the loop
|
||||
mov edx, dword ptr shaderCreationFunctions[ebx*4];
|
||||
test edx, edx
|
||||
jz shaderend
|
||||
|
||||
// Call direct3dDevice::(function name), either CreateVertexShader or CreatePixelShader
|
||||
mov eax, dword ptr [direct3dDevice]
|
||||
mov eax, dword ptr [eax]
|
||||
push dword ptr [direct3dDevice]
|
||||
call dword ptr [eax+edx]
|
||||
inc ebx
|
||||
jmp shaderloop
|
||||
|
||||
shaderend:
|
||||
// Finally create the TextureShader
|
||||
call dword ptr[D3DXCreateTextureShader]
|
||||
|
||||
// Let's keep the device in edi
|
||||
mov edi, dword ptr [direct3dDevice]
|
||||
|
||||
// Create a sphere
|
||||
push esi
|
||||
push offset sphere
|
||||
push 80h
|
||||
push 80h
|
||||
push ecx
|
||||
fld1
|
||||
fstp dword ptr [esp]
|
||||
push edi
|
||||
call dword ptr [D3DXCreateSphere]
|
||||
|
||||
// Create our 3 textures:
|
||||
push esi
|
||||
push offset renderTexture
|
||||
push esi
|
||||
push D3DFMT_A16B16G16R16F
|
||||
push D3DUSAGE_RENDERTARGET
|
||||
push 1
|
||||
push HEIGHT
|
||||
push WIDTH
|
||||
push edi
|
||||
|
||||
push esi
|
||||
push offset blurRenderTexture
|
||||
push esi
|
||||
push D3DFMT_A16B16G16R16F
|
||||
push D3DUSAGE_RENDERTARGET
|
||||
push 1
|
||||
push HEIGHT
|
||||
push WIDTH
|
||||
push edi
|
||||
|
||||
push esi
|
||||
push offset noiseTexture
|
||||
push esi
|
||||
push D3DFMT_A8
|
||||
push D3DUSAGE_DYNAMIC
|
||||
push 1
|
||||
push HEIGHT
|
||||
push WIDTH
|
||||
push edi
|
||||
|
||||
mov ebx, dword ptr [edi]
|
||||
call dword ptr [ebx + 5Ch]
|
||||
call dword ptr [ebx + 5Ch]
|
||||
call dword ptr [ebx + 5Ch]
|
||||
|
||||
// Fill our noise texture:
|
||||
push dword ptr [noiseTextureShader]
|
||||
push dword ptr [noiseTexture]
|
||||
call dword ptr [D3DXFillTextureTX]
|
||||
|
||||
// Get the texture's render surfaces:
|
||||
push offset renderSurface
|
||||
push esi
|
||||
mov eax, dword ptr [renderTexture]
|
||||
push eax
|
||||
mov eax, dword ptr [eax]
|
||||
call dword ptr [eax+48h]
|
||||
|
||||
push offset blurRenderSurface
|
||||
push esi
|
||||
mov eax, dword ptr [blurRenderTexture]
|
||||
push eax
|
||||
mov eax, dword ptr [eax]
|
||||
call dword ptr [eax+48h]
|
||||
|
||||
// Present:
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
push edi
|
||||
|
||||
// Gett the rendertarget surface
|
||||
push offset bufferSurface
|
||||
push esi
|
||||
push edi
|
||||
|
||||
// Set the sampler states:
|
||||
push D3DTADDRESS_WRAP
|
||||
push D3DSAMP_ADDRESSU
|
||||
push esi
|
||||
push edi
|
||||
|
||||
push D3DTADDRESS_WRAP
|
||||
push D3DSAMP_ADDRESSV
|
||||
push esi
|
||||
push edi
|
||||
|
||||
push D3DTADDRESS_WRAP
|
||||
push D3DSAMP_ADDRESSW
|
||||
push esi
|
||||
push edi
|
||||
|
||||
push D3DTEXF_ANISOTROPIC
|
||||
push D3DSAMP_MINFILTER
|
||||
push esi
|
||||
push edi
|
||||
|
||||
push D3DTEXF_ANISOTROPIC
|
||||
push D3DSAMP_MAGFILTER
|
||||
push esi
|
||||
push edi
|
||||
|
||||
mov ebx, dword ptr [edi]
|
||||
call dword ptr [ebx + 114h] //Set sampler state
|
||||
call dword ptr [ebx + 114h] //Set sampler state
|
||||
call dword ptr [ebx + 114h] //Set sampler state
|
||||
call dword ptr [ebx + 114h] //Set sampler state
|
||||
call dword ptr [ebx + 114h] //Set sampler state
|
||||
call dword ptr [ebx + 98h] //Get surface
|
||||
call dword ptr [ebx + 44h] //Present
|
||||
}
|
||||
}
|
||||
|
||||
#pragma code_seg(".sphere")
|
||||
void Sphere(IDirect3DPixelShader9* shader)
|
||||
{
|
||||
D3DXMatrixMultiply(&worldMatrix, &worldMatrix, &viewMatrix);
|
||||
D3DXMatrixMultiply(&viewProjectionMatrix, &worldMatrix, &projectionMatrix);
|
||||
direct3dDevice->SetVertexShaderConstantF(0, worldMatrix, 4);
|
||||
direct3dDevice->SetVertexShaderConstantF(4, viewProjectionMatrix, 4);
|
||||
direct3dDevice->SetPixelShader(shader);
|
||||
direct3dDevice->SetPixelShaderConstantF(0, &time, 1);
|
||||
sphere->DrawSubset(0);
|
||||
}
|
||||
|
||||
void RenderScene();
|
||||
|
||||
#pragma code_seg(".DrawFrame")
|
||||
inline void DrawFrame()
|
||||
{
|
||||
direct3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f), 1.0f, 0);
|
||||
direct3dDevice->BeginScene();
|
||||
|
||||
direct3dDevice->SetVertexShader(lightVertexShader);
|
||||
direct3dDevice->SetTexture(0, noiseTexture);
|
||||
|
||||
D3DXMatrixPerspectiveFovLH(&projectionMatrix, _PiD4, ASPECT, 1.0f, 1024.0f);
|
||||
|
||||
RenderScene();
|
||||
|
||||
//if (false)
|
||||
{//GLOW
|
||||
|
||||
direct3dDevice->SetTexture(0, blurRenderTexture);
|
||||
direct3dDevice->SetTexture(1, renderTexture);
|
||||
|
||||
direct3dDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
|
||||
|
||||
direct3dDevice->StretchRect(bufferSurface, NULL, blurRenderSurface, NULL, D3DTEXF_LINEAR);
|
||||
direct3dDevice->StretchRect(bufferSurface, NULL, renderSurface, NULL, D3DTEXF_LINEAR);
|
||||
|
||||
float zoom=.98f;
|
||||
float intensity=1.5f;
|
||||
direct3dDevice->SetPixelShader(blurPixelShader);
|
||||
direct3dDevice->SetPixelShaderConstantF(0, &zoom, 1);
|
||||
direct3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, screenQuad, sizeof(ScreenQuadVertex));
|
||||
direct3dDevice->StretchRect(bufferSurface, NULL, blurRenderSurface, NULL, D3DTEXF_LINEAR);
|
||||
direct3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, screenQuad, sizeof(ScreenQuadVertex));
|
||||
direct3dDevice->StretchRect(bufferSurface, NULL, blurRenderSurface, NULL, D3DTEXF_LINEAR);
|
||||
direct3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, screenQuad, sizeof(ScreenQuadVertex));
|
||||
direct3dDevice->StretchRect(bufferSurface, NULL, blurRenderSurface, NULL, D3DTEXF_LINEAR);
|
||||
|
||||
direct3dDevice->SetPixelShader(haloCombinePixelShader);
|
||||
direct3dDevice->SetPixelShaderConstantF(0, &intensity, 1);
|
||||
direct3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, screenQuad, sizeof(ScreenQuadVertex));
|
||||
direct3dDevice->StretchRect(bufferSurface, NULL, renderSurface, NULL, D3DTEXF_LINEAR);
|
||||
|
||||
for (int i = 1; i < 8; ++i)
|
||||
{
|
||||
zoom=.9f;
|
||||
intensity = .5f - i/16.0f;
|
||||
direct3dDevice->SetPixelShader(blurPixelShader);
|
||||
direct3dDevice->SetPixelShaderConstantF(0, &zoom, 1);
|
||||
direct3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, screenQuad, sizeof(ScreenQuadVertex));
|
||||
direct3dDevice->StretchRect(bufferSurface, NULL, blurRenderSurface, NULL, D3DTEXF_LINEAR);
|
||||
direct3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, screenQuad, sizeof(ScreenQuadVertex));
|
||||
direct3dDevice->StretchRect(bufferSurface, NULL, blurRenderSurface, NULL, D3DTEXF_LINEAR);
|
||||
|
||||
direct3dDevice->SetPixelShader(combinePixelShader);
|
||||
direct3dDevice->SetPixelShaderConstantF(0, &intensity, 1);
|
||||
direct3dDevice->SetPixelShaderConstantF(1, &fade, 1);
|
||||
direct3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, screenQuad, sizeof(ScreenQuadVertex));
|
||||
direct3dDevice->StretchRect(bufferSurface, NULL, renderSurface, NULL, D3DTEXF_LINEAR);
|
||||
}
|
||||
}
|
||||
|
||||
direct3dDevice->EndScene();
|
||||
direct3dDevice->Present(NULL, NULL, NULL, NULL);
|
||||
}
|
||||
16
space4k/src/dxincludes.h
Normal file
16
space4k/src/dxincludes.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#pragma warning(disable:4201 4238)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#define INITGUID
|
||||
#include <MMSystem.h>
|
||||
#include <D3D9.h>
|
||||
#include <D3DX9.h>
|
||||
#include "config.h"
|
||||
#include "small.h"
|
||||
#include "dxvariables.h"
|
||||
#include "shaders.h"
|
||||
#include "dxgraphics.h"
|
||||
#include "demo.h"
|
||||
#include "synth.h"
|
||||
77
space4k/src/dxvariables.h
Normal file
77
space4k/src/dxvariables.h
Normal file
@@ -0,0 +1,77 @@
|
||||
#pragma once
|
||||
|
||||
#pragma bss_seg(".bss")
|
||||
static float time;
|
||||
static HWND wnd;
|
||||
static HDC dc;
|
||||
static ID3DXMesh* sphere;
|
||||
static IDirect3DDevice9* direct3dDevice;
|
||||
static IDirect3DVertexShader9* lightVertexShader;
|
||||
static IDirect3DPixelShader9* earthPixelShader;
|
||||
static IDirect3DPixelShader9* skyPixelShader;
|
||||
static IDirect3DPixelShader9* blurPixelShader;
|
||||
static IDirect3DPixelShader9* haloCombinePixelShader;
|
||||
static IDirect3DPixelShader9* combinePixelShader;
|
||||
static IDirect3DPixelShader9* moonPixelShader;
|
||||
static ID3DXTextureShader* noiseTextureShader;
|
||||
static IDirect3DTexture9* noiseTexture;
|
||||
static IDirect3DTexture9* renderTexture;
|
||||
static IDirect3DTexture9* blurRenderTexture;
|
||||
static IDirect3DSurface9* renderSurface;
|
||||
static IDirect3DSurface9* blurRenderSurface;
|
||||
static IDirect3DSurface9* bufferSurface;
|
||||
static ID3DXBuffer* shaderBuffer;
|
||||
static ID3DXBuffer* errorBuffer;
|
||||
static D3DXMATRIX viewMatrix, worldMatrix, scaleMatrix, projectionMatrix, viewProjectionMatrix;
|
||||
static int scene;
|
||||
static float fade;
|
||||
|
||||
#pragma code_seg("ScreenQuadVertex")
|
||||
struct ScreenQuadVertex
|
||||
{
|
||||
float x, y, z, w;
|
||||
float u, v;
|
||||
};
|
||||
|
||||
#pragma data_seg(".screenQuad")
|
||||
ScreenQuadVertex screenQuad[] = {
|
||||
{WIDTH, HEIGHT, 0, 1, 1, 1},
|
||||
{-1, HEIGHT, 0, 1, 0, 1},
|
||||
{WIDTH, -1, 0, 1, 1, 0},
|
||||
{-1, -1, 0, 1, 0, 0}
|
||||
};
|
||||
|
||||
#pragma data_seg(".d3dPresParas")
|
||||
D3DPRESENT_PARAMETERS d3dPresParas = {
|
||||
WIDTH,
|
||||
HEIGHT,
|
||||
D3DFMT_A8R8G8B8,
|
||||
1,
|
||||
D3DMULTISAMPLE_4_SAMPLES,
|
||||
0,
|
||||
D3DSWAPEFFECT_DISCARD,
|
||||
0,
|
||||
WINDOWED,
|
||||
true,
|
||||
D3DFMT_D16,
|
||||
0,
|
||||
D3DPRESENT_RATE_DEFAULT,
|
||||
D3DPRESENT_INTERVAL_ONE
|
||||
};
|
||||
|
||||
|
||||
#pragma data_seg(".Pi")
|
||||
#define _Pi tf14_Pi
|
||||
const float tf14_Pi = D3DX_PI;
|
||||
|
||||
#pragma data_seg(".2Pi")
|
||||
#define _2Pi tf14_2Pi
|
||||
const float tf14_2Pi = 2.0f * D3DX_PI;
|
||||
|
||||
#pragma data_seg(".PiD4")
|
||||
#define _PiD4 tf14_PiD4
|
||||
const float tf14_PiD4 = D3DX_PI / 4.0f;
|
||||
|
||||
#pragma data_seg(".4D3")
|
||||
#define _4D3 tf14_4D3
|
||||
const float tf14_4D3 = 4.0f / 3.0f;
|
||||
86
space4k/src/gl.cpp
Normal file
86
space4k/src/gl.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
#ifdef _DEBUG
|
||||
#define D3D_DEBUG_INFO
|
||||
#endif
|
||||
|
||||
#include "glincludes.h"
|
||||
extern "C" int _fltused = 1;
|
||||
|
||||
#pragma data_seg(".edit")
|
||||
static char* edit = "edit";
|
||||
|
||||
#pragma code_seg(".main")
|
||||
void __cdecl main(void)
|
||||
{
|
||||
if (!WINDOWED)
|
||||
{
|
||||
ChangeDisplaySettings (&dmScreenSettings,CDS_FULLSCREEN);
|
||||
_asm
|
||||
{
|
||||
XOR ESI, ESI
|
||||
PUSH ESI
|
||||
PUSH ESI
|
||||
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 edit
|
||||
PUSH 0x8
|
||||
CALL dword ptr [CreateWindowExA]
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_asm
|
||||
{
|
||||
XOR ESI, ESI
|
||||
PUSH ESI
|
||||
PUSH ESI
|
||||
PUSH ESI
|
||||
PUSH ESI
|
||||
PUSH ESI
|
||||
PUSH ESI
|
||||
PUSH HEIGHT
|
||||
PUSH WIDTH
|
||||
PUSH ESI
|
||||
PUSH ESI
|
||||
PUSH WS_POPUP | WS_VISIBLE
|
||||
PUSH ESI
|
||||
PUSH edit
|
||||
PUSH 0x8
|
||||
CALL dword ptr [CreateWindowExA]
|
||||
}
|
||||
}
|
||||
_asm
|
||||
{
|
||||
PUSH EAX
|
||||
CALL dword ptr [GetDC]
|
||||
MOV dword ptr [hdc], EAX
|
||||
CALL dword ptr [ShowCursor]
|
||||
CALL dword ptr [CreateOGL]
|
||||
CALL dword ptr [CreateShaders]
|
||||
CALL dword ptr [InitSound]
|
||||
|
||||
theloop:
|
||||
#ifdef _DEBUG
|
||||
call dword ptr [ReloadShader]
|
||||
test eax, eax
|
||||
jz frameloop
|
||||
CALL dword ptr [CreateShadersDBG]
|
||||
frameloop:
|
||||
#endif
|
||||
call dword ptr [get_Time]
|
||||
fstp dword ptr [time]
|
||||
CALL dword ptr [DrawFrame]
|
||||
PUSH VK_ESCAPE
|
||||
CALL dword ptr [GetAsyncKeyState]
|
||||
test eax, eax
|
||||
jz theloop
|
||||
CALL dword ptr [ExitProcess]
|
||||
}
|
||||
}
|
||||
7271
space4k/src/glext.h
Normal file
7271
space4k/src/glext.h
Normal file
File diff suppressed because it is too large
Load Diff
152
space4k/src/glgraphics.h
Normal file
152
space4k/src/glgraphics.h
Normal file
@@ -0,0 +1,152 @@
|
||||
#pragma once
|
||||
|
||||
#pragma data_seg(".glCreateProgram")
|
||||
static const char* glCreateProgram = "glCreateProgram";
|
||||
|
||||
#pragma data_seg(".glCreateShader")
|
||||
static const char* glCreateShader = "glCreateShader";
|
||||
|
||||
#pragma data_seg(".glShaderSource")
|
||||
static const char* glShaderSource = "glShaderSource";
|
||||
|
||||
#pragma data_seg(".glCompileShader")
|
||||
static const char* glCompileShader = "glCompileShader";
|
||||
|
||||
#pragma data_seg(".glAttachShader")
|
||||
static const char* glAttachShader = "glAttachShader";
|
||||
|
||||
#pragma data_seg(".glLinkProgram")
|
||||
static const char* glLinkProgram = "glLinkProgram";
|
||||
|
||||
#pragma data_seg(".glUseProgram")
|
||||
static const char* glUseProgram = "glUseProgram";
|
||||
|
||||
#pragma data_seg(".glActiveTexture")
|
||||
static const char* glActiveTexture = "glActiveTexture";
|
||||
|
||||
#pragma code_seg(".UseShader")
|
||||
inline void UseShader(GLuint shader)
|
||||
{
|
||||
_asm
|
||||
{
|
||||
mov eax, shader
|
||||
push shaders[eax*4]
|
||||
push dword ptr [glUseProgram]
|
||||
|
||||
call dword ptr [wglGetProcAddress]
|
||||
call eax
|
||||
}
|
||||
}
|
||||
|
||||
#pragma code_seg(".CreateShader")
|
||||
inline void CreateShaders()
|
||||
{
|
||||
_asm
|
||||
{
|
||||
xor esi, esi
|
||||
|
||||
shaderloop:
|
||||
push 8B30h
|
||||
push dword ptr [glCreateShader]
|
||||
push 8B31h
|
||||
push dword ptr [glCreateShader]
|
||||
push dword ptr [glCreateProgram]
|
||||
|
||||
call dword ptr [wglGetProcAddress]
|
||||
call eax
|
||||
mov ebx,eax
|
||||
|
||||
call dword ptr [wglGetProcAddress]
|
||||
call eax
|
||||
mov edi,eax
|
||||
|
||||
call dword ptr [wglGetProcAddress]
|
||||
call eax
|
||||
mov edx,eax
|
||||
lea eax, fsh[esi*4]
|
||||
|
||||
push ebx
|
||||
push dword ptr [glLinkProgram]
|
||||
|
||||
push edx
|
||||
push ebx
|
||||
push dword ptr [glAttachShader]
|
||||
|
||||
push edx
|
||||
push dword ptr [glCompileShader]
|
||||
|
||||
push 0
|
||||
push eax
|
||||
push 1
|
||||
push edx
|
||||
push dword ptr [glShaderSource]
|
||||
|
||||
push edi
|
||||
push ebx
|
||||
push dword ptr [glAttachShader]
|
||||
|
||||
push edi
|
||||
push dword ptr [glCompileShader]
|
||||
|
||||
push 0
|
||||
push offset vertexShader
|
||||
push 1
|
||||
push edi
|
||||
push dword ptr [glShaderSource]
|
||||
|
||||
mov edi, dword ptr [wglGetProcAddress]
|
||||
call edi
|
||||
call eax
|
||||
call edi
|
||||
call eax
|
||||
call edi
|
||||
call eax
|
||||
call edi
|
||||
call eax
|
||||
call edi
|
||||
call eax
|
||||
call edi
|
||||
call eax
|
||||
call edi
|
||||
call eax
|
||||
|
||||
mov dword ptr shaders[esi*4], ebx
|
||||
inc esi
|
||||
test esi, shaderCount
|
||||
jz shaderLoop
|
||||
}
|
||||
}
|
||||
|
||||
#pragma code_seg(".CreateOGL")
|
||||
inline void CreateOGL()
|
||||
{
|
||||
_asm
|
||||
{
|
||||
push hdc
|
||||
push offset pfd
|
||||
push offset pfd
|
||||
push hdc
|
||||
call dword ptr [ChoosePixelFormat]
|
||||
push eax
|
||||
push hdc
|
||||
call dword ptr [SetPixelFormat]
|
||||
call dword ptr [wglCreateContext]
|
||||
push eax
|
||||
push hdc
|
||||
call dword ptr [wglMakeCurrent]
|
||||
}
|
||||
}
|
||||
|
||||
#pragma code_seg(".DrawFrame")
|
||||
void DrawFrame()
|
||||
{
|
||||
glLoadIdentity();
|
||||
glTranslated(1, 1, x_Sin(time)*3);
|
||||
glRotatef(-time * 10, 0, 1, 0);
|
||||
UseShader(WORLD_GLSL);
|
||||
glNormal3f(WIDTH, HEIGHT, ASPECT);
|
||||
glColor3f(time, 0, 0);
|
||||
glRects(-1, -1, 1, 1);
|
||||
|
||||
SwapBuffers(hdc);
|
||||
}
|
||||
17
space4k/src/glincludes.h
Normal file
17
space4k/src/glincludes.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#pragma warning(disable:4201 4238)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#define INITGUID
|
||||
#include <MMSystem.h>
|
||||
#include <GL/GL.h>
|
||||
#include <GL/GLU.h>
|
||||
#include "glext.h"
|
||||
#include "config.h"
|
||||
#include "small.h"
|
||||
#include "shaders.h"
|
||||
#include "glvariables.h"
|
||||
#include "glgraphics.h"
|
||||
#include "debug.h"
|
||||
#include "synth.h"
|
||||
22
space4k/src/glvariables.h
Normal file
22
space4k/src/glvariables.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#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 bss_seg(".bss")
|
||||
static HDC hdc;
|
||||
static float time, fade;
|
||||
static GLuint blurRenderTexture, renderTexture;
|
||||
static GLuint shaders[shaderCount];
|
||||
|
||||
#pragma data_seg(".vertexShader")
|
||||
static const char* vertexShader = "varying vec3 Y,V,W;varying vec4 Z;void main(){Y=gl_Normal;vec4 v=gl_Vertex;Z=gl_Color;gl_Position=gl_Vertex;v.x*=Y.z;V=vec3(gl_ModelViewMatrix*v);W=vec3(gl_ModelViewMatrix*vec4(0,0,-1,1));}";
|
||||
|
||||
#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,WIDTH,HEIGHT
|
||||
};
|
||||
305
space4k/src/graphics.h
Normal file
305
space4k/src/graphics.h
Normal file
@@ -0,0 +1,305 @@
|
||||
#pragma once
|
||||
|
||||
#pragma data_seg(".shaderCreationFunctions")
|
||||
static int shaderCreationFunctions[] =
|
||||
{
|
||||
0x16C, //CreateVertexShader
|
||||
0x1A8, //CreatePixelShader
|
||||
0x1A8, //CreatePixelShader
|
||||
0x1A8, //CreatePixelShader
|
||||
0x1A8, //CreatePixelShader
|
||||
0x1A8, //CreatePixelShader
|
||||
0x1A8, //CreatePixelShader
|
||||
0
|
||||
};
|
||||
|
||||
#pragma data_seg(".shaderTargets")
|
||||
static void* shaderTargets[] =
|
||||
{
|
||||
&lightVertexShader,
|
||||
&earthPixelShader,
|
||||
&blurPixelShader,
|
||||
&haloCombinePixelShader,
|
||||
&combinePixelShader,
|
||||
&skyPixelShader,
|
||||
&moonPixelShader,
|
||||
&noiseTextureShader,
|
||||
};
|
||||
|
||||
#pragma code_seg(".CreateD3D")
|
||||
inline void CreateD3D()
|
||||
{
|
||||
_asm
|
||||
{
|
||||
// set the wnd handle to the d3dPresParas
|
||||
mov eax, dword ptr [wnd]
|
||||
mov dword ptr [d3dPresParas + 1Ch],eax
|
||||
|
||||
// create IDirect3D9
|
||||
push D3D_SDK_VERSION
|
||||
call dword ptr [Direct3DCreate9]
|
||||
|
||||
// create IDirect3DDevice9
|
||||
push offset direct3dDevice
|
||||
push offset d3dPresParas
|
||||
push 80h
|
||||
push dword ptr [wnd]
|
||||
push 1
|
||||
push esi
|
||||
push eax
|
||||
mov eax, dword ptr [eax]
|
||||
call dword ptr [eax+40h]
|
||||
|
||||
// Create all shaders in a loop
|
||||
xor ebx, ebx
|
||||
shaderloop:
|
||||
|
||||
// D3DXCompileShader
|
||||
push esi
|
||||
push offset errorBuffer
|
||||
push offset shaderBuffer
|
||||
push esi
|
||||
push dword ptr shaderProfiles[ebx*4]
|
||||
push offset shaderEntryPoint
|
||||
push esi
|
||||
push esi
|
||||
push shaderLength
|
||||
push dword ptr [shader]
|
||||
call dword ptr [D3DXCompileShader]
|
||||
|
||||
// Increment the shader entry point character (from a to z)
|
||||
mov eax, dword ptr [shaderEntryPoint]
|
||||
inc eax
|
||||
mov dword ptr [shaderEntryPoint], eax
|
||||
|
||||
push dword ptr shaderTargets[ebx*4]
|
||||
|
||||
// Call ID3DXBuffer::GetBuffer from the shader error buffer
|
||||
mov eax, dword ptr [errorBuffer]
|
||||
mov eax, dword ptr [eax]
|
||||
push dword ptr [errorBuffer]
|
||||
call dword ptr [eax+0Ch]
|
||||
push eax
|
||||
call dword ptr [OutputDebugStringA]
|
||||
|
||||
// Call ID3DXBuffer::GetBuffer
|
||||
mov eax, dword ptr [shaderBuffer]
|
||||
mov eax, dword ptr [eax]
|
||||
// if it crashes here, check output window, because the shader
|
||||
// has an error and couldn't compile!
|
||||
push dword ptr [shaderBuffer]
|
||||
call dword ptr [eax+0Ch]
|
||||
push eax
|
||||
|
||||
// If we're done, exit the loop
|
||||
mov edx, dword ptr shaderCreationFunctions[ebx*4];
|
||||
test edx, edx
|
||||
jz shaderend
|
||||
|
||||
// Call direct3dDevice::(function name), either CreateVertexShader or CreatePixelShader
|
||||
mov eax, dword ptr [direct3dDevice]
|
||||
mov eax, dword ptr [eax]
|
||||
push dword ptr [direct3dDevice]
|
||||
call dword ptr [eax+edx]
|
||||
inc ebx
|
||||
jmp shaderloop
|
||||
|
||||
shaderend:
|
||||
// Finally create the TextureShader
|
||||
call dword ptr[D3DXCreateTextureShader]
|
||||
|
||||
// Let's keep the device in edi
|
||||
mov edi, dword ptr [direct3dDevice]
|
||||
|
||||
// Create a sphere
|
||||
push esi
|
||||
push offset sphere
|
||||
push 80h
|
||||
push 80h
|
||||
push ecx
|
||||
fld1
|
||||
fstp dword ptr [esp]
|
||||
push edi
|
||||
call dword ptr [D3DXCreateSphere]
|
||||
|
||||
// Create our 3 textures:
|
||||
push esi
|
||||
push offset renderTexture
|
||||
push esi
|
||||
push D3DFMT_A16B16G16R16F
|
||||
push D3DUSAGE_RENDERTARGET
|
||||
push 1
|
||||
push HEIGHT
|
||||
push WIDTH
|
||||
push edi
|
||||
|
||||
push esi
|
||||
push offset blurRenderTexture
|
||||
push esi
|
||||
push D3DFMT_A16B16G16R16F
|
||||
push D3DUSAGE_RENDERTARGET
|
||||
push 1
|
||||
push HEIGHT
|
||||
push WIDTH
|
||||
push edi
|
||||
|
||||
push esi
|
||||
push offset noiseTexture
|
||||
push esi
|
||||
push D3DFMT_A8
|
||||
push D3DUSAGE_DYNAMIC
|
||||
push 1
|
||||
push HEIGHT
|
||||
push WIDTH
|
||||
push edi
|
||||
|
||||
mov ebx, dword ptr [edi]
|
||||
call dword ptr [ebx + 5Ch]
|
||||
call dword ptr [ebx + 5Ch]
|
||||
call dword ptr [ebx + 5Ch]
|
||||
|
||||
// Fill our noise texture:
|
||||
push dword ptr [noiseTextureShader]
|
||||
push dword ptr [noiseTexture]
|
||||
call dword ptr [D3DXFillTextureTX]
|
||||
|
||||
// Get the texture's render surfaces:
|
||||
push offset renderSurface
|
||||
push esi
|
||||
mov eax, dword ptr [renderTexture]
|
||||
push eax
|
||||
mov eax, dword ptr [eax]
|
||||
call dword ptr [eax+48h]
|
||||
|
||||
push offset blurRenderSurface
|
||||
push esi
|
||||
mov eax, dword ptr [blurRenderTexture]
|
||||
push eax
|
||||
mov eax, dword ptr [eax]
|
||||
call dword ptr [eax+48h]
|
||||
|
||||
// Present:
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
push esi
|
||||
push edi
|
||||
|
||||
// Gett the rendertarget surface
|
||||
push offset bufferSurface
|
||||
push esi
|
||||
push edi
|
||||
|
||||
// Set the sampler states:
|
||||
push D3DTADDRESS_WRAP
|
||||
push D3DSAMP_ADDRESSU
|
||||
push esi
|
||||
push edi
|
||||
|
||||
push D3DTADDRESS_WRAP
|
||||
push D3DSAMP_ADDRESSV
|
||||
push esi
|
||||
push edi
|
||||
|
||||
push D3DTADDRESS_WRAP
|
||||
push D3DSAMP_ADDRESSW
|
||||
push esi
|
||||
push edi
|
||||
|
||||
push D3DTEXF_ANISOTROPIC
|
||||
push D3DSAMP_MINFILTER
|
||||
push esi
|
||||
push edi
|
||||
|
||||
push D3DTEXF_ANISOTROPIC
|
||||
push D3DSAMP_MAGFILTER
|
||||
push esi
|
||||
push edi
|
||||
|
||||
mov ebx, dword ptr [edi]
|
||||
call dword ptr [ebx + 114h] //Set sampler state
|
||||
call dword ptr [ebx + 114h] //Set sampler state
|
||||
call dword ptr [ebx + 114h] //Set sampler state
|
||||
call dword ptr [ebx + 114h] //Set sampler state
|
||||
call dword ptr [ebx + 114h] //Set sampler state
|
||||
call dword ptr [ebx + 98h] //Get surface
|
||||
call dword ptr [ebx + 44h] //Present
|
||||
}
|
||||
}
|
||||
|
||||
#pragma code_seg(".sphere")
|
||||
void Sphere(IDirect3DPixelShader9* shader)
|
||||
{
|
||||
D3DXMatrixMultiply(&worldMatrix, &worldMatrix, &viewMatrix);
|
||||
D3DXMatrixMultiply(&viewProjectionMatrix, &worldMatrix, &projectionMatrix);
|
||||
direct3dDevice->SetVertexShaderConstantF(0, worldMatrix, 4);
|
||||
direct3dDevice->SetVertexShaderConstantF(4, viewProjectionMatrix, 4);
|
||||
direct3dDevice->SetPixelShader(shader);
|
||||
direct3dDevice->SetPixelShaderConstantF(0, &time, 1);
|
||||
sphere->DrawSubset(0);
|
||||
}
|
||||
|
||||
void RenderScene();
|
||||
|
||||
#pragma code_seg(".DrawFrame")
|
||||
inline void DrawFrame()
|
||||
{
|
||||
direct3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f), 1.0f, 0);
|
||||
direct3dDevice->BeginScene();
|
||||
|
||||
direct3dDevice->SetVertexShader(lightVertexShader);
|
||||
direct3dDevice->SetTexture(0, noiseTexture);
|
||||
|
||||
D3DXMatrixPerspectiveFovLH(&projectionMatrix, _PiD4, ASPECT, 1.0f, 1024.0f);
|
||||
|
||||
RenderScene();
|
||||
|
||||
//if (false)
|
||||
{//GLOW
|
||||
|
||||
direct3dDevice->SetTexture(0, blurRenderTexture);
|
||||
direct3dDevice->SetTexture(1, renderTexture);
|
||||
|
||||
direct3dDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
|
||||
|
||||
direct3dDevice->StretchRect(bufferSurface, NULL, blurRenderSurface, NULL, D3DTEXF_LINEAR);
|
||||
direct3dDevice->StretchRect(bufferSurface, NULL, renderSurface, NULL, D3DTEXF_LINEAR);
|
||||
|
||||
float zoom=.98f;
|
||||
float intensity=1.5f;
|
||||
direct3dDevice->SetPixelShader(blurPixelShader);
|
||||
direct3dDevice->SetPixelShaderConstantF(0, &zoom, 1);
|
||||
direct3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, screenQuad, sizeof(ScreenQuadVertex));
|
||||
direct3dDevice->StretchRect(bufferSurface, NULL, blurRenderSurface, NULL, D3DTEXF_LINEAR);
|
||||
direct3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, screenQuad, sizeof(ScreenQuadVertex));
|
||||
direct3dDevice->StretchRect(bufferSurface, NULL, blurRenderSurface, NULL, D3DTEXF_LINEAR);
|
||||
direct3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, screenQuad, sizeof(ScreenQuadVertex));
|
||||
direct3dDevice->StretchRect(bufferSurface, NULL, blurRenderSurface, NULL, D3DTEXF_LINEAR);
|
||||
|
||||
direct3dDevice->SetPixelShader(haloCombinePixelShader);
|
||||
direct3dDevice->SetPixelShaderConstantF(0, &intensity, 1);
|
||||
direct3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, screenQuad, sizeof(ScreenQuadVertex));
|
||||
direct3dDevice->StretchRect(bufferSurface, NULL, renderSurface, NULL, D3DTEXF_LINEAR);
|
||||
|
||||
for (int i = 1; i < 8; ++i)
|
||||
{
|
||||
zoom=.9f;
|
||||
intensity = .5f - i/16.0f;
|
||||
direct3dDevice->SetPixelShader(blurPixelShader);
|
||||
direct3dDevice->SetPixelShaderConstantF(0, &zoom, 1);
|
||||
direct3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, screenQuad, sizeof(ScreenQuadVertex));
|
||||
direct3dDevice->StretchRect(bufferSurface, NULL, blurRenderSurface, NULL, D3DTEXF_LINEAR);
|
||||
direct3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, screenQuad, sizeof(ScreenQuadVertex));
|
||||
direct3dDevice->StretchRect(bufferSurface, NULL, blurRenderSurface, NULL, D3DTEXF_LINEAR);
|
||||
|
||||
direct3dDevice->SetPixelShader(combinePixelShader);
|
||||
direct3dDevice->SetPixelShaderConstantF(0, &intensity, 1);
|
||||
direct3dDevice->SetPixelShaderConstantF(1, &fade, 1);
|
||||
direct3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, screenQuad, sizeof(ScreenQuadVertex));
|
||||
direct3dDevice->StretchRect(bufferSurface, NULL, renderSurface, NULL, D3DTEXF_LINEAR);
|
||||
}
|
||||
}
|
||||
|
||||
direct3dDevice->EndScene();
|
||||
direct3dDevice->Present(NULL, NULL, NULL, NULL);
|
||||
}
|
||||
16
space4k/src/includes.h
Normal file
16
space4k/src/includes.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#pragma warning(disable:4201 4238)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#define INITGUID
|
||||
#include <MMSystem.h>
|
||||
#include <D3D9.h>
|
||||
#include <D3DX9.h>
|
||||
#include "config.h"
|
||||
#include "small.h"
|
||||
#include "variables.h"
|
||||
#include "shaders.h"
|
||||
#include "graphics.h"
|
||||
#include "demo.h"
|
||||
#include "synth.h"
|
||||
133
space4k/src/shaders.h
Normal file
133
space4k/src/shaders.h
Normal file
@@ -0,0 +1,133 @@
|
||||
#pragma once
|
||||
|
||||
#pragma data_seg(".shaderCount")
|
||||
static const int shaderCount = 1;
|
||||
|
||||
#pragma data_seg(".shaders")
|
||||
static char* fsh[] = {
|
||||
//E:\blu-flame.org\space4k\src\world.glsl:
|
||||
"" // Line 1
|
||||
"varying vec3 Y,V,W;" // Line 3
|
||||
"varying vec4 Z;" // Line 4
|
||||
"vec3 r,q;" // Line 5
|
||||
"vec4 o;" // Line 68
|
||||
"vec4 s;" // Line 69
|
||||
"vec3 p[2];float a(vec2 u){" // Line 70
|
||||
"int t=int(u.x*33+u.y*3333);" // Line 10
|
||||
"t=(t<<13)^t;" // Line 11
|
||||
"return 1-float((t*(t*t*15731+789221)+1376312589)&0x7fffffff)/1073741824;}float b(vec2 w){" // Line 12
|
||||
"vec2 t=fract(w);" // Line 17
|
||||
"w-=t;" // Line 18
|
||||
"vec2 v=t*t*(3-2*t);" // Line 19
|
||||
"return mix(" // Line 20
|
||||
"mix(a(w+vec2(0,0)),a(w+vec2(1,0)),v.x)," // Line 21
|
||||
"mix(a(w+vec2(0,1)),a(w+vec2(1,1)),v.x),v.y);}float c(vec3 t,float u){" // Line 22
|
||||
"t=.5+.5*t;" // Line 27
|
||||
"vec3 v=.5+.5*acos(1-abs(t))/3.14;" // Line 28
|
||||
"return " // Line 29
|
||||
"(b(t.yz*u)*v.x+" // Line 30
|
||||
"b(t.xz*u)*v.y+" // Line 31
|
||||
"b(t.xy*u)*v.z)/(v.x+v.y+v.z);}float d(vec4 v,vec3 t){" // Line 32
|
||||
"t+=1;" // Line 38
|
||||
"vec3 u=vec3(mod(t.x,2.),t.y,mod(t.z,2.));" // Line 39
|
||||
"u=v.xyz-u+1;" // Line 40
|
||||
"return length(u)-v.w;}vec3 e(vec4 u,vec3 t){" // Line 41
|
||||
"return normalize(" // Line 46
|
||||
"vec3(d(u,t+vec3(.001,0,0))," // Line 47
|
||||
"d(u,t+vec3(0,.001,0))," // Line 48
|
||||
"d(u,t+vec3(0,0,.001)))-d(u,t));}float f(vec3 u,vec3 t,vec3 v){" // Line 49
|
||||
"return dot(t,v-u);}float g(vec4 t,vec3 u,vec3 v){" // Line 54
|
||||
"return length(v-t.xyz+u*dot(v-t.xyz,u))-t.w;}vec3 h(vec4 t,vec3 u,vec3 v){" // Line 60
|
||||
"return normalize(v-t.xyz+u*dot(v-t.xyz,u));}vec2 i(vec3 v){" // Line 65
|
||||
"float t=d(s,v);" // Line 75
|
||||
"float u=f(p[0],p[1],v);" // Line 76
|
||||
"if(t<u)" // Line 77
|
||||
"return vec2(t,0);" // Line 78
|
||||
"return vec2(u,1);}vec3 j(vec3 u,vec2 t){" // Line 79
|
||||
"if(t.y==.0)" // Line 84
|
||||
"return e(s,u);" // Line 85
|
||||
"else " // Line 87
|
||||
"return p[1];}bool k(vec3 w,vec3 u,out vec2 v){" // Line 88
|
||||
"float t=.0;" // Line 93
|
||||
"while(t<100.)" // Line 94
|
||||
"{" // Line 95
|
||||
"vec3 x=w+u*t;" // Line 96
|
||||
"v=i(x);" // Line 97
|
||||
"if(v.x<=.00001)" // Line 98
|
||||
"{" // Line 99
|
||||
"v.x=t;" // Line 100
|
||||
"return true;}" // Line 101
|
||||
"t+=v.x;}" // Line 104
|
||||
"return false;}float l(vec3 y,vec3 x,float v){" // Line 106
|
||||
"float t=.0;" // Line 111
|
||||
"float u=.1;" // Line 112
|
||||
"for(float w=1.;w<=5.;++w)" // Line 113
|
||||
"t+=1./pow(1.5,w)*(w*u-i(y+x*w*u).x);" // Line 114
|
||||
"return 1.-v*t;}float m(vec3 x,float u,float t){" // Line 115
|
||||
"vec3 w=normalize(o.xyz-x);" // Line 120
|
||||
"float y=.0;" // Line 121
|
||||
"for(float v=1.;v<=u;++v)" // Line 122
|
||||
"{" // Line 123
|
||||
"vec3 z=mix(o.xyz,x,v/u);" // Line 124
|
||||
"y+=i(z).x;}" // Line 125
|
||||
"return min(1.,pow(y/u,t));}vec3 n(vec3 t){" // Line 127
|
||||
"return (1-q.y)*t;}void main(){" // Line 132
|
||||
"r=W;" // Line 137
|
||||
"q=normalize(V-r);" // Line 138
|
||||
"vec3 u=vec3(.6,.7,.8)/3;" // Line 139
|
||||
"vec3 t=vec3(0);" // Line 140
|
||||
"s=vec4(.0,-.5+sin(Z.x)*.5,.0,.5);" // Line 143
|
||||
"p[0]=vec3(.0,-1.,.0);" // Line 144
|
||||
"p[1]=vec3(.0,1.,.0);" // Line 145
|
||||
"o=vec4(.5,1.,-2.,1.);" // Line 146
|
||||
"o.x=sin(Z.x)*2;" // Line 148
|
||||
"o.z=cos(Z.x)*2;" // Line 149
|
||||
"vec2 y;" // Line 151
|
||||
"int x=64;" // Line 152
|
||||
"float v=0;" // Line 153
|
||||
"int w=0;" // Line 154
|
||||
"while(x>0)" // Line 155
|
||||
"{" // Line 156
|
||||
"if(!k(r,q,y))" // Line 157
|
||||
"{" // Line 158
|
||||
"t=n(u);" // Line 159
|
||||
"break ;}" // Line 160
|
||||
"v=max(v,min(1,1-pow(.9,y.x)));" // Line 163
|
||||
"vec3 C=r+q*y.x;" // Line 165
|
||||
"vec3 B=j(C,y);" // Line 166
|
||||
"vec3 A=normalize(o.xyz-C);" // Line 167
|
||||
"float z=5*" // Line 168
|
||||
"dot(B,A)*o." // Line 169
|
||||
"w" // Line 170
|
||||
"*l(C,B,1.5)" // Line 171
|
||||
"*m(C,50,2.);" // Line 172
|
||||
"vec3 D=vec3(0);" // Line 174
|
||||
"if(y.y==1)" // Line 176
|
||||
"{" // Line 177
|
||||
"x=0;" // Line 178
|
||||
"z+=.2;" // Line 179
|
||||
"D=z*vec3(.75,.5,.25);}" // Line 180
|
||||
"else " // Line 183
|
||||
"{" // Line 184
|
||||
"if(w==0)" // Line 186
|
||||
"{" // Line 187
|
||||
"q=normalize(refract(q,B,1));" // Line 188
|
||||
"w=1;}" // Line 189
|
||||
"else " // Line 192
|
||||
"{" // Line 193
|
||||
"q=normalize(refract(-q,B,1));" // Line 194
|
||||
"w=0;}" // Line 195
|
||||
"r+=q*.01;" // Line 198
|
||||
"--x;" // Line 199
|
||||
"D=z*vec3(.7,.8,.9);}" // Line 200
|
||||
"t.xyz=mix(t.xyz,D,.8);}" // Line 203
|
||||
"gl_FragColor=vec4(mix(t,u,v),1);}",
|
||||
0};
|
||||
|
||||
#define WORLD_GLSL 0
|
||||
|
||||
#pragma data_seg(".shaderFileName")
|
||||
static const char* shaderFileName[] = {
|
||||
"E:\\blu-flame.org\\space4k\\src\\world.glsl",
|
||||
0};
|
||||
|
||||
27
space4k/src/shaders.hlsl
Normal file
27
space4k/src/shaders.hlsl
Normal file
@@ -0,0 +1,27 @@
|
||||
sampler r,s,t;
|
||||
float u,v;
|
||||
float4x4 x,y;
|
||||
|
||||
///(noiseShader,tx_1_0)
|
||||
float4 a(float2 h:POSITION,float2 i:PSIZE):COLOR
|
||||
{
|
||||
return noise(h*64)*.5+.5;
|
||||
}
|
||||
|
||||
///(vertexShader,vs_3_0)
|
||||
void b(inout float4 h:POSITION,float3 i:NORMAL,out float3 j[4]:TEXCOORD)
|
||||
{
|
||||
float3 m=mul(x,h);
|
||||
j[0]=mul(x,i);
|
||||
j[1]=m;
|
||||
j[2]=h*.5-.5;
|
||||
j[3]=i;//h*.5+.5;
|
||||
h=mul(y,h);
|
||||
}
|
||||
|
||||
///(testPixelShader,ps_3_0)
|
||||
float4 c(float2 h:TEXCOORD):COLOR
|
||||
{
|
||||
float4 o=tex2D(s,h);
|
||||
return o+tex2D(r,h)*(1-o.a)*2;
|
||||
}
|
||||
92
space4k/src/small.h
Normal file
92
space4k/src/small.h
Normal file
@@ -0,0 +1,92 @@
|
||||
#pragma once
|
||||
|
||||
#pragma code_seg("sm0")
|
||||
|
||||
DWORD x_Ftol(float af_Value)
|
||||
{
|
||||
DWORD ldw_Result;
|
||||
__asm fld af_Value
|
||||
__asm fistp ldw_Result
|
||||
return ldw_Result;
|
||||
}
|
||||
|
||||
#pragma code_seg("sm1")
|
||||
|
||||
float x_Frac(float af_Value)
|
||||
{
|
||||
return af_Value - x_Ftol(af_Value);
|
||||
}
|
||||
|
||||
#pragma code_seg("sm2")
|
||||
|
||||
float x_Abs(float af_Value)
|
||||
{
|
||||
__asm fld af_Value
|
||||
__asm fabs
|
||||
}
|
||||
|
||||
#pragma code_seg("sm3")
|
||||
|
||||
float x_Sin(float af_Value)
|
||||
{
|
||||
__asm fld af_Value
|
||||
__asm fsin
|
||||
}
|
||||
|
||||
#pragma code_seg("sm3b")
|
||||
|
||||
float x_Cos(float af_Value)
|
||||
{
|
||||
__asm fld af_Value
|
||||
__asm fcos
|
||||
}
|
||||
|
||||
#pragma code_seg("sm4")
|
||||
|
||||
float x_Sign(float af_Value)
|
||||
{
|
||||
return af_Value > 0 ? 1.0f : -1.0f;
|
||||
}
|
||||
|
||||
#pragma code_seg("sm5")
|
||||
|
||||
float x_Sqrt(float af_Value)
|
||||
{
|
||||
__asm fld af_Value
|
||||
__asm fsqrt
|
||||
}
|
||||
|
||||
#pragma code_seg("sm7")
|
||||
|
||||
void x_MemCopy(void* av_Dest_, const void* av_Src_, size_t ai_Size)
|
||||
{
|
||||
__asm mov esi, av_Src_
|
||||
__asm mov edi, av_Dest_
|
||||
__asm mov ecx, ai_Size
|
||||
__asm rep movsb
|
||||
}
|
||||
|
||||
#pragma data_seg("smA")
|
||||
|
||||
unsigned long seed=0x12345678;
|
||||
|
||||
#pragma code_seg("sm9")
|
||||
|
||||
void x_Randomize(unsigned long x)
|
||||
{
|
||||
seed = x;
|
||||
}
|
||||
|
||||
#pragma code_seg("smB")
|
||||
|
||||
float x_Rand()
|
||||
{
|
||||
seed = seed * 0x76364873 + 1234567;
|
||||
return (float)(seed & 0x7FFFFFFF) * (const float)(2.0f / (float)0x7FFFFFFF) - 1.0f;
|
||||
}
|
||||
|
||||
#pragma code_seg(".max")
|
||||
float x_Max(float a, float b) { return (a > b) ? a : b; }
|
||||
|
||||
#pragma code_seg(".min")
|
||||
float x_Min(float a, float b) { return (a < b) ? a : b; }
|
||||
76
space4k/src/synth.h
Normal file
76
space4k/src/synth.h
Normal file
@@ -0,0 +1,76 @@
|
||||
#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
|
||||
waveOutOpen ( &hWaveOut, WAVE_MAPPER, &WaveFMT, NULL, 0, CALLBACK_NULL );
|
||||
waveOutPrepareHeader( hWaveOut, &WaveHDR, sizeof(WaveHDR) );
|
||||
waveOutWrite ( hWaveOut, &WaveHDR, sizeof(WaveHDR) );
|
||||
}
|
||||
|
||||
#pragma code_seg(".time")
|
||||
extern "C" float get_Time()
|
||||
{
|
||||
waveOutGetPosition(hWaveOut, &MMTime, sizeof(MMTIME));
|
||||
return float(MMTime.u.sample) / SAMPLE_RATE;
|
||||
}
|
||||
77
space4k/src/variables.h
Normal file
77
space4k/src/variables.h
Normal file
@@ -0,0 +1,77 @@
|
||||
#pragma once
|
||||
|
||||
#pragma bss_seg(".bss")
|
||||
static float time;
|
||||
static HWND wnd;
|
||||
static HDC dc;
|
||||
static ID3DXMesh* sphere;
|
||||
static IDirect3DDevice9* direct3dDevice;
|
||||
static IDirect3DVertexShader9* lightVertexShader;
|
||||
static IDirect3DPixelShader9* earthPixelShader;
|
||||
static IDirect3DPixelShader9* skyPixelShader;
|
||||
static IDirect3DPixelShader9* blurPixelShader;
|
||||
static IDirect3DPixelShader9* haloCombinePixelShader;
|
||||
static IDirect3DPixelShader9* combinePixelShader;
|
||||
static IDirect3DPixelShader9* moonPixelShader;
|
||||
static ID3DXTextureShader* noiseTextureShader;
|
||||
static IDirect3DTexture9* noiseTexture;
|
||||
static IDirect3DTexture9* renderTexture;
|
||||
static IDirect3DTexture9* blurRenderTexture;
|
||||
static IDirect3DSurface9* renderSurface;
|
||||
static IDirect3DSurface9* blurRenderSurface;
|
||||
static IDirect3DSurface9* bufferSurface;
|
||||
static ID3DXBuffer* shaderBuffer;
|
||||
static ID3DXBuffer* errorBuffer;
|
||||
static D3DXMATRIX viewMatrix, worldMatrix, scaleMatrix, projectionMatrix, viewProjectionMatrix;
|
||||
static int scene;
|
||||
static float fade;
|
||||
|
||||
#pragma code_seg("ScreenQuadVertex")
|
||||
struct ScreenQuadVertex
|
||||
{
|
||||
float x, y, z, w;
|
||||
float u, v;
|
||||
};
|
||||
|
||||
#pragma data_seg(".screenQuad")
|
||||
ScreenQuadVertex screenQuad[] = {
|
||||
{WIDTH, HEIGHT, 0, 1, 1, 1},
|
||||
{-1, HEIGHT, 0, 1, 0, 1},
|
||||
{WIDTH, -1, 0, 1, 1, 0},
|
||||
{-1, -1, 0, 1, 0, 0}
|
||||
};
|
||||
|
||||
#pragma data_seg(".d3dPresParas")
|
||||
D3DPRESENT_PARAMETERS d3dPresParas = {
|
||||
WIDTH,
|
||||
HEIGHT,
|
||||
D3DFMT_A8R8G8B8,
|
||||
1,
|
||||
D3DMULTISAMPLE_4_SAMPLES,
|
||||
0,
|
||||
D3DSWAPEFFECT_DISCARD,
|
||||
0,
|
||||
WINDOWED,
|
||||
true,
|
||||
D3DFMT_D16,
|
||||
0,
|
||||
D3DPRESENT_RATE_DEFAULT,
|
||||
D3DPRESENT_INTERVAL_ONE
|
||||
};
|
||||
|
||||
|
||||
#pragma data_seg(".Pi")
|
||||
#define _Pi tf14_Pi
|
||||
const float tf14_Pi = D3DX_PI;
|
||||
|
||||
#pragma data_seg(".2Pi")
|
||||
#define _2Pi tf14_2Pi
|
||||
const float tf14_2Pi = 2.0f * D3DX_PI;
|
||||
|
||||
#pragma data_seg(".PiD4")
|
||||
#define _PiD4 tf14_PiD4
|
||||
const float tf14_PiD4 = D3DX_PI / 4.0f;
|
||||
|
||||
#pragma data_seg(".4D3")
|
||||
#define _4D3 tf14_4D3
|
||||
const float tf14_4D3 = 4.0f / 3.0f;
|
||||
203
space4k/src/world.glsl
Normal file
203
space4k/src/world.glsl
Normal file
@@ -0,0 +1,203 @@
|
||||
#extension GL_EXT_gpu_shader4: enable
|
||||
|
||||
varying vec3 Y,V,W;
|
||||
varying vec4 Z;
|
||||
vec3 ro, rd;
|
||||
|
||||
// Pseudo random number base generator (credits go to iq/rgba)
|
||||
float rnd(vec2 x)
|
||||
{
|
||||
int n = int(x.x * 33 + x.y * 3333);
|
||||
n = (n << 13) ^ n;
|
||||
return 1 - float( (n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824;
|
||||
}
|
||||
|
||||
float smoothrnd(vec2 x)
|
||||
{
|
||||
vec2 a = fract(x);
|
||||
x -= a;
|
||||
vec2 u = a*a*(3-2*a);
|
||||
return mix(
|
||||
mix(rnd(x+vec2(0,0)),rnd(x+vec2(1,0)), u.x),
|
||||
mix(rnd(x+vec2(0,1)),rnd(x+vec2(1,1)), u.x), u.y);
|
||||
}
|
||||
|
||||
float noise3d(vec3 normal, float size)
|
||||
{
|
||||
normal=.5+.5*normal;
|
||||
vec3 w=.5+.5*acos(1-abs(normal))/3.14;
|
||||
return
|
||||
(smoothrnd(normal.yz*size)*w.x+
|
||||
smoothrnd(normal.xz*size)*w.y+
|
||||
smoothrnd(normal.xy*size)*w.z)/(w.x+w.y+w.z);
|
||||
}
|
||||
|
||||
// sphereData -> xyz - position; w - radius
|
||||
float DistanceToSphere(vec4 sphereData, vec3 position)
|
||||
{
|
||||
position += 1;
|
||||
vec3 q = vec3(mod(position.x, 2.0), position.y, mod(position.z, 2.0));
|
||||
q = sphereData.xyz - q + 1;
|
||||
return length(q) - sphereData.w;
|
||||
}
|
||||
|
||||
vec3 NormalOfSphere(vec4 sphereData, vec3 position)
|
||||
{
|
||||
return normalize(
|
||||
vec3(DistanceToSphere(sphereData, position+vec3(0.001,0,0)),
|
||||
DistanceToSphere(sphereData, position+vec3(0,0.001,0)),
|
||||
DistanceToSphere(sphereData, position+vec3(0,0,0.001)))-DistanceToSphere(sphereData, position));
|
||||
}
|
||||
|
||||
float DistanceToPlane(vec3 planePosition, vec3 planeNormal, vec3 position)
|
||||
{
|
||||
return dot(planeNormal, position - planePosition);// + 0.05 * smoothrnd(position.xz*16);
|
||||
}
|
||||
|
||||
// cylinderData -> xyz - position; w - radius
|
||||
float DistanceToCylinder(vec4 cylinderData, vec3 cylinderDirection, vec3 position)
|
||||
{
|
||||
return length(position - cylinderData.xyz + cylinderDirection * dot(position - cylinderData.xyz, cylinderDirection)) - cylinderData.w;
|
||||
}
|
||||
|
||||
vec3 NormalOfCylinder(vec4 cylinderData, vec3 cylinderDirection, vec3 position)
|
||||
{
|
||||
return normalize(position - cylinderData.xyz + cylinderDirection * dot(position - cylinderData.xyz, cylinderDirection));
|
||||
}
|
||||
|
||||
vec4 lightData; // xyz - position; w - strength
|
||||
vec4 sphereData;
|
||||
vec3 planeData[2]; // 0 - position; 1 normal
|
||||
|
||||
// x = distance; y = material id
|
||||
vec2 Distance(vec3 position)
|
||||
{
|
||||
float d1 = DistanceToSphere(sphereData, position);
|
||||
float d2 = DistanceToPlane(planeData[0], planeData[1], position);
|
||||
if (d1 < d2)
|
||||
return vec2(d1, 0);
|
||||
return vec2(d2, 1);
|
||||
}
|
||||
|
||||
vec3 Normal(vec3 position, vec2 distanceData)
|
||||
{
|
||||
if (distanceData.y == 0.0)
|
||||
return NormalOfSphere(sphereData, position);
|
||||
else
|
||||
return planeData[1];
|
||||
}
|
||||
|
||||
bool DistanceField(vec3 ro, vec3 rd, out vec2 result)
|
||||
{
|
||||
float distance = 0.0;
|
||||
while (distance < 100.0)
|
||||
{
|
||||
vec3 position = ro + rd * distance;
|
||||
result = Distance(position);
|
||||
if (result.x <= 0.00001)
|
||||
{
|
||||
result.x = distance;
|
||||
return true;
|
||||
}
|
||||
|
||||
distance += result.x;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
float CalcAmbientOcclusion(vec3 position, vec3 normal, float factor)
|
||||
{
|
||||
float ao = 0.0;
|
||||
float delta = 0.1;
|
||||
for (float i = 1.0; i <= 5.0; ++i)
|
||||
ao += 1.0 / pow(1.5, i) * (i * delta - Distance(position + normal * i * delta).x);
|
||||
return 1.0 - factor * ao;
|
||||
}
|
||||
|
||||
float CalcShadow(vec3 position, float detailLevel, float darknessFactor)
|
||||
{
|
||||
vec3 lightDir = normalize(lightData.xyz - position);
|
||||
float shadow = 0.0;
|
||||
for (float i = 1.0; i <= detailLevel; ++i)
|
||||
{
|
||||
vec3 blendedPosition = mix(lightData.xyz, position, i / detailLevel);
|
||||
shadow += Distance(blendedPosition).x;
|
||||
}
|
||||
return min(1.0, pow(shadow / detailLevel, darknessFactor));
|
||||
}
|
||||
|
||||
vec3 calcSky(vec3 fog)
|
||||
{
|
||||
return (1-rd.y)*fog;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
ro = W; //set ray origin
|
||||
rd = normalize(V - ro); //set ray direction
|
||||
vec3 fog = vec3(0.6,0.7,0.8)/3;
|
||||
vec3 color = vec3(0);
|
||||
|
||||
// init content data
|
||||
sphereData = vec4(0.0, -0.5 + sin(Z.x)*0.5, 0.0, 0.5);
|
||||
planeData[0] = vec3(0.0, -1.0, 0.0);
|
||||
planeData[1] = vec3(0.0, 1.0, 0.0);
|
||||
lightData = vec4(0.5, 1.0, -2.0, 1.0);
|
||||
|
||||
lightData.x = sin (Z.x) * 2;
|
||||
lightData.z = cos (Z.x) * 2;
|
||||
|
||||
vec2 result;
|
||||
int iterations = 64;
|
||||
float fogAmount=0;
|
||||
int inside = 0;
|
||||
while (iterations>0)
|
||||
{
|
||||
if (!DistanceField(ro, rd, result))
|
||||
{
|
||||
color=calcSky(fog);
|
||||
break;
|
||||
}
|
||||
|
||||
fogAmount=max(fogAmount,min(1,1-pow(0.9,result.x)));
|
||||
|
||||
vec3 position = ro + rd * result.x;
|
||||
vec3 normal = Normal(position, result);
|
||||
vec3 lightDir = normalize(lightData.xyz - position);
|
||||
float light = 5 *
|
||||
dot(normal, lightDir) * lightData.w
|
||||
* CalcAmbientOcclusion(position, normal, 1.5)
|
||||
* CalcShadow(position, 50, 2.0);
|
||||
|
||||
vec3 thisColor = vec3(0);
|
||||
|
||||
if (result.y == 1)
|
||||
{
|
||||
iterations = 0;
|
||||
light += 0.2;
|
||||
thisColor = light * vec3(0.75,0.5,0.25);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Glass logic
|
||||
if (inside == 0)
|
||||
{
|
||||
rd = normalize(refract(rd, normal, 1));
|
||||
inside = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
rd = normalize(refract(-rd, normal, 1));
|
||||
inside = 0;
|
||||
}
|
||||
|
||||
ro += rd * 0.01;
|
||||
--iterations;
|
||||
thisColor = light * vec3(0.7,0.8,0.9);
|
||||
}
|
||||
|
||||
color.xyz = mix(color.xyz, thisColor, 0.8);
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(mix(color, fog, fogAmount),1);
|
||||
}
|
||||
Reference in New Issue
Block a user