From 7ae40127f15f8f2cb963a7efeb018f7887ebc1ea Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 20 Dec 2018 18:29:16 +0800 Subject: =?UTF-8?q?*=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/SDL2.dll | Bin 1242112 -> 1242112 bytes bin/cembed.exe | Bin 0 -> 41984 bytes bin/jin.exe | Bin 1675776 -> 1676800 bytes bin/lua51.dll | Bin 364544 -> 364544 bytes build/vc++/3rdparty/cembed/cembed.vcxproj | 130 ++++++++ build/vc++/3rdparty/cembed/cembed.vcxproj.filters | 6 + build/vc++/3rdparty/cembed/cembed.vcxproj.user | 4 + build/vc++/jin.sln | 13 +- build/vc++/jin.vcxproj | 267 ---------------- build/vc++/jin.vcxproj.filters | 373 ---------------------- build/vc++/jin.vcxproj.user | 14 - build/vc++/jin/jin.vcxproj | 2 +- build/vc++/libjin-lua/libjin-lua.vcxproj | 260 +++++++++++++++ build/vc++/libjin-lua/libjin-lua.vcxproj.filters | 357 +++++++++++++++++++++ build/vc++/libjin-lua/libjin-lua.vcxproj.user | 14 + build/vc++/resource.h | Bin 858 -> 0 bytes src/3rdparty/cembed/cembed.c | 230 +++++++++++++ src/libjin/common/je_object.h | 1 + src/lua/embed/scripts/ai.lua | 26 ++ src/lua/embed/scripts/boot.lua | 139 ++++++++ src/lua/embed/scripts/graphics.lua | 139 ++++++++ src/lua/embed/scripts/graphics.lua.h | 104 ++++-- src/lua/embed/scripts/keyboard.lua | 17 + src/lua/embed/scripts/mouse.lua | 16 + src/lua/embed/scripts/net.lua | 7 + src/lua/embed/scripts/path.lua | 16 + 26 files changed, 1457 insertions(+), 678 deletions(-) create mode 100644 bin/cembed.exe create mode 100644 build/vc++/3rdparty/cembed/cembed.vcxproj create mode 100644 build/vc++/3rdparty/cembed/cembed.vcxproj.filters create mode 100644 build/vc++/3rdparty/cembed/cembed.vcxproj.user delete mode 100644 build/vc++/jin.vcxproj delete mode 100644 build/vc++/jin.vcxproj.filters delete mode 100644 build/vc++/jin.vcxproj.user create mode 100644 build/vc++/libjin-lua/libjin-lua.vcxproj create mode 100644 build/vc++/libjin-lua/libjin-lua.vcxproj.filters create mode 100644 build/vc++/libjin-lua/libjin-lua.vcxproj.user delete mode 100644 build/vc++/resource.h create mode 100644 src/3rdparty/cembed/cembed.c create mode 100644 src/lua/embed/scripts/ai.lua create mode 100644 src/lua/embed/scripts/boot.lua create mode 100644 src/lua/embed/scripts/graphics.lua create mode 100644 src/lua/embed/scripts/keyboard.lua create mode 100644 src/lua/embed/scripts/mouse.lua create mode 100644 src/lua/embed/scripts/net.lua create mode 100644 src/lua/embed/scripts/path.lua diff --git a/bin/SDL2.dll b/bin/SDL2.dll index 22a805d..1784df8 100644 Binary files a/bin/SDL2.dll and b/bin/SDL2.dll differ diff --git a/bin/cembed.exe b/bin/cembed.exe new file mode 100644 index 0000000..dd580c5 Binary files /dev/null and b/bin/cembed.exe differ diff --git a/bin/jin.exe b/bin/jin.exe index eb1ec38..9f205e0 100644 Binary files a/bin/jin.exe and b/bin/jin.exe differ diff --git a/bin/lua51.dll b/bin/lua51.dll index 080ff13..975804a 100644 Binary files a/bin/lua51.dll and b/bin/lua51.dll differ diff --git a/build/vc++/3rdparty/cembed/cembed.vcxproj b/build/vc++/3rdparty/cembed/cembed.vcxproj new file mode 100644 index 0000000..04e1300 --- /dev/null +++ b/build/vc++/3rdparty/cembed/cembed.vcxproj @@ -0,0 +1,130 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {DE837ACB-AA3B-4C91-9CA1-395D1B85E11F} + cembed + 10.0.17134.0 + + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + $(SolutionDir)..\..\bin + + + $(SolutionDir)..\..\bin + + + + Level3 + Disabled + true + true + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + + + Level3 + Disabled + true + true + + + + + Level3 + MaxSpeed + true + true + true + true + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + true + + + true + true + + + + + + + + + \ No newline at end of file diff --git a/build/vc++/3rdparty/cembed/cembed.vcxproj.filters b/build/vc++/3rdparty/cembed/cembed.vcxproj.filters new file mode 100644 index 0000000..3600749 --- /dev/null +++ b/build/vc++/3rdparty/cembed/cembed.vcxproj.filters @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/build/vc++/3rdparty/cembed/cembed.vcxproj.user b/build/vc++/3rdparty/cembed/cembed.vcxproj.user new file mode 100644 index 0000000..be25078 --- /dev/null +++ b/build/vc++/3rdparty/cembed/cembed.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/build/vc++/jin.sln b/build/vc++/jin.sln index a1f5d5f..b1807ac 100644 --- a/build/vc++/jin.sln +++ b/build/vc++/jin.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27703.2047 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjin-lua", "jin.vcxproj", "{A3E35ECA-62EB-45CE-8152-674FBC7F7A3B}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjin-lua", "libjin-lua\libjin-lua.vcxproj", "{A3E35ECA-62EB-45CE-8152-674FBC7F7A3B}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjin", "libjin\libjin.vcxproj", "{9EE02090-C15E-4520-9C05-C435E45EF2FC}" EndProject @@ -47,6 +47,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "luax", "3rdparty\luax\luax. EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Lua51", "3rdparty\Lua51\Lua51.vcxproj", "{4156CD69-6FC4-4B32-B008-BB94C8AE17F5}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cembed", "3rdparty\cembed\cembed.vcxproj", "{DE837ACB-AA3B-4C91-9CA1-395D1B85E11F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -183,6 +185,14 @@ Global {4156CD69-6FC4-4B32-B008-BB94C8AE17F5}.Release|x64.Build.0 = Release|x64 {4156CD69-6FC4-4B32-B008-BB94C8AE17F5}.Release|x86.ActiveCfg = Release|Win32 {4156CD69-6FC4-4B32-B008-BB94C8AE17F5}.Release|x86.Build.0 = Release|Win32 + {DE837ACB-AA3B-4C91-9CA1-395D1B85E11F}.Debug|x64.ActiveCfg = Debug|x64 + {DE837ACB-AA3B-4C91-9CA1-395D1B85E11F}.Debug|x64.Build.0 = Debug|x64 + {DE837ACB-AA3B-4C91-9CA1-395D1B85E11F}.Debug|x86.ActiveCfg = Debug|Win32 + {DE837ACB-AA3B-4C91-9CA1-395D1B85E11F}.Debug|x86.Build.0 = Debug|Win32 + {DE837ACB-AA3B-4C91-9CA1-395D1B85E11F}.Release|x64.ActiveCfg = Release|x64 + {DE837ACB-AA3B-4C91-9CA1-395D1B85E11F}.Release|x64.Build.0 = Release|x64 + {DE837ACB-AA3B-4C91-9CA1-395D1B85E11F}.Release|x86.ActiveCfg = Release|Win32 + {DE837ACB-AA3B-4C91-9CA1-395D1B85E11F}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -206,6 +216,7 @@ Global {45AC0438-98A8-4369-A21D-BBCBE7995B34} = {2A2F610D-E42B-426F-8DC8-79E0C6FCCDD2} {C6B16179-5640-4D41-8756-0525D25EB569} = {65DFFFA6-F434-47FB-9DB2-DCF019060B92} {4156CD69-6FC4-4B32-B008-BB94C8AE17F5} = {2A2F610D-E42B-426F-8DC8-79E0C6FCCDD2} + {DE837ACB-AA3B-4C91-9CA1-395D1B85E11F} = {65DFFFA6-F434-47FB-9DB2-DCF019060B92} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {633D8D43-3349-43F7-8835-7D7F58BAD2A8} diff --git a/build/vc++/jin.vcxproj b/build/vc++/jin.vcxproj deleted file mode 100644 index cfc6eba..0000000 --- a/build/vc++/jin.vcxproj +++ /dev/null @@ -1,267 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {A3E35ECA-62EB-45CE-8152-674FBC7F7A3B} - jin - 8.1 - libjin-lua - - - - StaticLibrary - true - v141 - MultiByte - - - StaticLibrary - false - v141 - true - MultiByte - - - Application - true - v141 - MultiByte - - - Application - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - $(SolutionDir)..\..\bin - *.cdf;*.cache;*.obj;*.obj.enc;*.ilk;*.ipdb;*.iobj;*.resources;*.tlb;*.tli;*.tlh;*.tmp;*.rsp;*.pgc;*.pgd;*.meta;*.tlog;*.manifest;*.res;*.pch;*.exp;*.idb;*.rep;*.xdc;*.pdb;*_manifest.rc;*.bsc;*.sbr;*.xml;*.metagen;*.bi - $(ProjectName) - - - $(SolutionDir)..\..\bin - *.cdf;*.cache;*.obj;*.obj.enc;*.ilk;*.ipdb;*.iobj;*.resources;*.tlb;*.tli;*.tlh;*.tmp;*.rsp;*.pgc;*.pgd;*.meta;*.tlog;*.manifest;*.res;*.pch;*.exp;*.idb;*.rep;*.xdc;*.pdb;*_manifest.rc;*.bsc;*.sbr;*.xml;*.metagen;*.bi - $(ProjectName) - - - - Level3 - true - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(SolutionDir)..\..\src\;$(SolutionDir)..\..\src\3rdparty\LuaJIT-2.0.5\include;$(SolutionDir)..\..\src\3rdparty\;$(SolutionDir)..\..\src\3rdparty\SDL2\include;$(SolutionDir)..\..\src\lua;%(AdditionalIncludeDirectories) - CompileAsCpp - $(IntDir)/%(RelativeDir)/ - Size - true - Disabled - true - - - opengl32.lib;lua51.lib;SDL2main.lib;SDL2.lib;%(AdditionalDependencies) - $(SolutionDir)libs\SDL2-2.0.5\lib\x86;$(SolutionDir)libs\LuaJIT-2.0.5\src;%(AdditionalLibraryDirectories) - Windows - - - - - true - - - - - Level3 - Disabled - true - - - - - Level3 - true - true - true - _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(SolutionDir)..\..\src\;$(SolutionDir)..\..\src\3rdparty\LuaJIT-2.0.5\include;$(SolutionDir)..\..\src\3rdparty\;$(SolutionDir)..\..\src\3rdparty\SDL2\include;$(SolutionDir)..\..\src\lua;%(AdditionalIncludeDirectories) - CompileAsCpp - $(IntDir)/%(RelativeDir)/ - Size - MinSpace - - - true - true - opengl32.lib;lua51.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies) - $(SolutionDir)libs\SDL2-2.0.5\lib\x86;$(SolutionDir)libs\LuaJIT-2.0.5\src;%(AdditionalLibraryDirectories) - Windows - - - - - - - Level3 - MaxSpeed - true - true - true - - - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {45ac0438-98a8-4369-a21d-bbcbe7995b34} - - - {9ee02090-c15e-4520-9c05-c435e45ef2fc} - - - - - - \ No newline at end of file diff --git a/build/vc++/jin.vcxproj.filters b/build/vc++/jin.vcxproj.filters deleted file mode 100644 index 029c097..0000000 --- a/build/vc++/jin.vcxproj.filters +++ /dev/null @@ -1,373 +0,0 @@ - - - - - {f3e85b81-1688-49e4-b85c-65d99ddafad9} - - - {2264d908-20ee-41c2-8bdc-bc1117959c4f} - - - {923b475a-00e2-4b8f-925a-ca1e5f9b4689} - - - {7957774a-4f34-4255-ab2e-8da9b6c71983} - - - {ee920041-8798-4827-be04-49f9342ba092} - - - {6b79b5bf-69c1-458c-81f3-b386b340d39b} - - - {4eb54d6d-e336-42f6-8670-d271a458eb56} - - - {b042ed61-32e5-4e86-b4f3-1a293de8918d} - - - {b13ee8dc-41fc-42b3-8b64-f9c261ebfc73} - - - {8a740640-925a-4cf6-94d5-89283824a141} - - - {563ed6fb-3d82-4905-b128-835f3818cc4f} - - - {1ed523c3-e203-487f-a13f-a35396f814f3} - - - {7fd81749-f776-4e5c-b6e2-33372a143560} - - - {2a701538-aeee-4f48-a285-0b848c9a3b81} - - - {98c4385b-893c-4d60-bb82-2a19ee5ff527} - - - {5b69329e-0aa2-4c77-be52-69c09fdbac65} - - - {0340fbad-0c07-4923-afd2-183424c70967} - - - {9cf92f3f-bcc5-442b-aa92-c88eeb1c5e45} - - - {579f12b8-5758-4be5-9cd7-e1fa62fdef74} - - - {fc3fecf1-63e8-4d28-97a7-bf6a1817f57b} - - - {352f5242-a96e-4cd1-a2e2-15777d354e42} - - - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\audio - - - source\modules\audio - - - source\modules\bit - - - source\modules\core - - - source\modules\event - - - source\modules\filesystem - - - source\modules\joypad - - - source\modules\keyboard - - - source\modules\math - - - source\modules\mouse - - - source\modules\net - - - source\modules\net - - - source\modules\net - - - source\modules\thread - - - source\modules\time - - - source\modules\graphics - - - source\common - - - source\modules\ai - - - source\modules\ai - - - source\modules\ai - - - source\modules\time - - - source\common - - - source\common - - - source\modules\graphics - - - source\common - - - source\modules\graphics - - - source\modules\graphics - - - source\common - - - source\common - - - source\common - - - source - - - - - resource - - - source\resources - - - source\modules\net - - - source\modules\thread - - - source\common - - - source\common - - - source\common - - - source\embed - - - source\embed\scripts - - - source\embed\scripts - - - source\embed\scripts - - - source\embed\scripts - - - source\embed\scripts - - - source\embed\scripts - - - source\embed\scripts - - - source\modules\time - - - source\common - - - source\common - - - source\common - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\graphics - - - source\modules\ai - - - source\modules\ai - - - source\modules\ai - - - source\modules\audio - - - source\modules\audio - - - source\modules\bit - - - source\modules\core - - - source\modules\event - - - source\modules\filesystem - - - source\modules\joypad - - - source\modules\keyboard - - - source\modules\math - - - source\modules\mouse - - - source\modules\net - - - source\modules\net - - - source\modules\time - - - source\common - - - source\modules\graphics - - - source\modules\graphics - - - source\common - - - source\modules - - - source\common - - - source - - - - - resource - - - - - resource - - - \ No newline at end of file diff --git a/build/vc++/jin.vcxproj.user b/build/vc++/jin.vcxproj.user deleted file mode 100644 index fbd2421..0000000 --- a/build/vc++/jin.vcxproj.user +++ /dev/null @@ -1,14 +0,0 @@ - - - - $(ProjectDir)..\..\bin - WindowsLocalDebugger - - - $(ProjectDir)..\..\bin - WindowsLocalDebugger - - - false - - \ No newline at end of file diff --git a/build/vc++/jin/jin.vcxproj b/build/vc++/jin/jin.vcxproj index 7c0c145..98ae932 100644 --- a/build/vc++/jin/jin.vcxproj +++ b/build/vc++/jin/jin.vcxproj @@ -143,7 +143,7 @@ - + {a3e35eca-62eb-45ce-8152-674fbc7f7a3b} diff --git a/build/vc++/libjin-lua/libjin-lua.vcxproj b/build/vc++/libjin-lua/libjin-lua.vcxproj new file mode 100644 index 0000000..57d1837 --- /dev/null +++ b/build/vc++/libjin-lua/libjin-lua.vcxproj @@ -0,0 +1,260 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {A3E35ECA-62EB-45CE-8152-674FBC7F7A3B} + jin + 8.1 + libjin-lua + + + + StaticLibrary + true + v141 + MultiByte + + + StaticLibrary + false + v141 + true + MultiByte + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + $(SolutionDir)..\..\bin + *.cdf;*.cache;*.obj;*.obj.enc;*.ilk;*.ipdb;*.iobj;*.resources;*.tlb;*.tli;*.tlh;*.tmp;*.rsp;*.pgc;*.pgd;*.meta;*.tlog;*.manifest;*.res;*.pch;*.exp;*.idb;*.rep;*.xdc;*.pdb;*_manifest.rc;*.bsc;*.sbr;*.xml;*.metagen;*.bi + $(ProjectName) + + + $(SolutionDir)..\..\bin + *.cdf;*.cache;*.obj;*.obj.enc;*.ilk;*.ipdb;*.iobj;*.resources;*.tlb;*.tli;*.tlh;*.tmp;*.rsp;*.pgc;*.pgd;*.meta;*.tlog;*.manifest;*.res;*.pch;*.exp;*.idb;*.rep;*.xdc;*.pdb;*_manifest.rc;*.bsc;*.sbr;*.xml;*.metagen;*.bi + $(ProjectName) + + + + Level3 + true + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(SolutionDir)..\..\src\;$(SolutionDir)..\..\src\3rdparty\LuaJIT-2.0.5\include;$(SolutionDir)..\..\src\3rdparty\;$(SolutionDir)..\..\src\3rdparty\SDL2\include;$(SolutionDir)..\..\src\lua;%(AdditionalIncludeDirectories) + CompileAsCpp + $(IntDir)/%(RelativeDir)/ + Size + true + Disabled + true + + + opengl32.lib;lua51.lib;SDL2main.lib;SDL2.lib;%(AdditionalDependencies) + $(SolutionDir)libs\SDL2-2.0.5\lib\x86;$(SolutionDir)libs\LuaJIT-2.0.5\src;%(AdditionalLibraryDirectories) + Windows + + + + + true + + + + + Level3 + Disabled + true + + + + + Level3 + true + true + true + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..\src\;$(SolutionDir)..\..\..\src\3rdparty\LuaJIT-2.0.5\include;$(SolutionDir)..\..\..\src\3rdparty\;$(SolutionDir)..\..\..\src\3rdparty\SDL2\include;$(SolutionDir)..\..\..\src\lua;%(AdditionalIncludeDirectories) + CompileAsCpp + $(IntDir)/%(RelativeDir)/ + Size + MinSpace + + + true + true + opengl32.lib;lua51.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies) + $(SolutionDir)libs\SDL2-2.0.5\lib\x86;$(SolutionDir)libs\LuaJIT-2.0.5\src;%(AdditionalLibraryDirectories) + Windows + + + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {45ac0438-98a8-4369-a21d-bbcbe7995b34} + + + {9ee02090-c15e-4520-9c05-c435e45ef2fc} + + + + + + \ No newline at end of file diff --git a/build/vc++/libjin-lua/libjin-lua.vcxproj.filters b/build/vc++/libjin-lua/libjin-lua.vcxproj.filters new file mode 100644 index 0000000..bf1010a --- /dev/null +++ b/build/vc++/libjin-lua/libjin-lua.vcxproj.filters @@ -0,0 +1,357 @@ + + + + + {f3e85b81-1688-49e4-b85c-65d99ddafad9} + + + {2264d908-20ee-41c2-8bdc-bc1117959c4f} + + + {923b475a-00e2-4b8f-925a-ca1e5f9b4689} + + + {7957774a-4f34-4255-ab2e-8da9b6c71983} + + + {ee920041-8798-4827-be04-49f9342ba092} + + + {6b79b5bf-69c1-458c-81f3-b386b340d39b} + + + {4eb54d6d-e336-42f6-8670-d271a458eb56} + + + {b042ed61-32e5-4e86-b4f3-1a293de8918d} + + + {b13ee8dc-41fc-42b3-8b64-f9c261ebfc73} + + + {8a740640-925a-4cf6-94d5-89283824a141} + + + {563ed6fb-3d82-4905-b128-835f3818cc4f} + + + {1ed523c3-e203-487f-a13f-a35396f814f3} + + + {7fd81749-f776-4e5c-b6e2-33372a143560} + + + {2a701538-aeee-4f48-a285-0b848c9a3b81} + + + {98c4385b-893c-4d60-bb82-2a19ee5ff527} + + + {5b69329e-0aa2-4c77-be52-69c09fdbac65} + + + {0340fbad-0c07-4923-afd2-183424c70967} + + + {9cf92f3f-bcc5-442b-aa92-c88eeb1c5e45} + + + {fc3fecf1-63e8-4d28-97a7-bf6a1817f57b} + + + {352f5242-a96e-4cd1-a2e2-15777d354e42} + + + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\audio + + + source\modules\audio + + + source\modules\bit + + + source\modules\core + + + source\modules\event + + + source\modules\filesystem + + + source\modules\joypad + + + source\modules\keyboard + + + source\modules\math + + + source\modules\mouse + + + source\modules\net + + + source\modules\net + + + source\modules\net + + + source\modules\thread + + + source\modules\time + + + source\modules\graphics + + + source\common + + + source\modules\ai + + + source\modules\ai + + + source\modules\ai + + + source\modules\time + + + source\common + + + source\common + + + source\modules\graphics + + + source\common + + + source\modules\graphics + + + source\modules\graphics + + + source\common + + + source\common + + + source\common + + + source + + + + + source\resources + + + source\modules\net + + + source\modules\thread + + + source\common + + + source\common + + + source\common + + + source\embed + + + source\embed\scripts + + + source\embed\scripts + + + source\embed\scripts + + + source\embed\scripts + + + source\embed\scripts + + + source\embed\scripts + + + source\embed\scripts + + + source\modules\time + + + source\common + + + source\common + + + source\common + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\graphics + + + source\modules\ai + + + source\modules\ai + + + source\modules\ai + + + source\modules\audio + + + source\modules\audio + + + source\modules\bit + + + source\modules\core + + + source\modules\event + + + source\modules\filesystem + + + source\modules\joypad + + + source\modules\keyboard + + + source\modules\math + + + source\modules\mouse + + + source\modules\net + + + source\modules\net + + + source\modules\time + + + source\common + + + source\modules\graphics + + + source\modules\graphics + + + source\common + + + source\modules + + + source\common + + + source + + + \ No newline at end of file diff --git a/build/vc++/libjin-lua/libjin-lua.vcxproj.user b/build/vc++/libjin-lua/libjin-lua.vcxproj.user new file mode 100644 index 0000000..a8fee8c --- /dev/null +++ b/build/vc++/libjin-lua/libjin-lua.vcxproj.user @@ -0,0 +1,14 @@ + + + + $(ProjectDir)..\..\..\bin + WindowsLocalDebugger + + + $(ProjectDir)..\..\..\bin + WindowsLocalDebugger + + + false + + \ No newline at end of file diff --git a/build/vc++/resource.h b/build/vc++/resource.h deleted file mode 100644 index fdc6053..0000000 Binary files a/build/vc++/resource.h and /dev/null differ diff --git a/src/3rdparty/cembed/cembed.c b/src/3rdparty/cembed/cembed.c new file mode 100644 index 0000000..0488b67 --- /dev/null +++ b/src/3rdparty/cembed/cembed.c @@ -0,0 +1,230 @@ +/* +** Copyright (c) 2018 rxi +** +** Permission is hereby granted, free of charge, to any person obtaining a copy +** of this software and associated documentation files (the "Software"), to +** deal in the Software without restriction, including without limitation the +** rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +** sell copies of the Software, and to permit persons to whom the Software is +** furnished to do so, subject to the following conditions: +** +** The above copyright notice and this permission notice shall be included in +** all copies or substantial portions of the Software. +** +** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +** FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +** IN THE SOFTWARE. +**/ + +#include +#include +#include +#include +#include + +#define VERSION "v0.2" + + +typedef struct { + FILE *fp; + unsigned char buf[4096]; + int idx; + int eof_idx; +} BufferedFile; + + +static BufferedFile bf_writer(FILE *fp) { + BufferedFile bf = { .fp = fp }; + return bf; +} + + +static BufferedFile bf_reader(FILE *fp) { + BufferedFile bf = { .fp = fp,.idx = sizeof(bf.buf),.eof_idx = -1 }; + return bf; +} + + +static void bf_flush(BufferedFile *bf) { + fwrite(bf->buf, 1, bf->idx, bf->fp); + bf->idx = 0; +} + + +static void bf_write_byte(BufferedFile *bf, char b) { + bf->buf[bf->idx++] = b; + if (bf->idx == sizeof(bf->buf)) { bf_flush(bf); } +} + + +static int bf_read_byte(BufferedFile *bf) { + if (bf->idx == sizeof(bf->buf)) { + int n = fread(bf->buf, 1, sizeof(bf->buf), bf->fp); + if (n != sizeof(bf->buf)) { bf->eof_idx = n; } + bf->idx = 0; + } + if (bf->idx == bf->eof_idx) { return EOF; } + return bf->buf[bf->idx++]; +} + + +static void error(const char *fmt, ...) { + va_list vp; + fprintf(stderr, "Error: "); + va_start(vp, fmt); + vfprintf(stderr, fmt, vp); + va_end(vp); + fprintf(stderr, "\n"); + exit(EXIT_FAILURE); +} + + +static void safename(char *dst, const char *filename) { + const char *p = filename; + char *q = dst; + while (*p) { + if (isalpha(*p) || isdigit(*p)) { + *q = *p; + } + else { + *q = '_'; + } + q++; p++; + } + *q = '\0'; +} + + +static void write_byte_string(BufferedFile *bf, unsigned char n) { + if (n >= 100) { bf_write_byte(bf, '0' + (n / 100) % 10); } + if (n >= 10) { bf_write_byte(bf, '0' + (n / 10) % 10); } + bf_write_byte(bf, '0' + n % 10); +} + + +static void write_embedded(FILE *fp, const char *filename, + const char *varprefix, int nostatic, int zerobyte) +{ + FILE *infp = fopen(filename, "rb"); + if (!infp) { + error("failed to open file '%s'", filename); + } + + char varname[256]; + if (strlen(filename) >= sizeof(varname)) { + error("filename too long"); + } + safename(varname, filename); + + if (!nostatic) { fprintf(fp, "static "); } + fprintf(fp, "unsigned char %s%s[] = {", varprefix, varname); + BufferedFile inbf = bf_reader(infp); + BufferedFile bf = bf_writer(fp); + int n = 0; + + for (;;) { + int chr = bf_read_byte(&inbf); + if (chr == EOF) { break; } + if (n > 0) { bf_write_byte(&bf, ','); } + if (n % 20 == 0) { bf_write_byte(&bf, '\n'); } + write_byte_string(&bf, chr); + n++; + } + + bf_flush(&bf); + if (zerobyte) { fprintf(fp, ",0"); } + fprintf(fp, "\n};\n\n"); + + fclose(infp); +} + + +static void print_help(void) { + printf( + "Usage: cembed [OPTION]... [FILE]...\n" + "Create C header with file data embedded in char arrays\n" + "\n" + " -o output file\n" + " -p prefix to place before variable names\n" + " -s omits `static` keyword\n" + " -z adds zero byte to end of array\n" + " -h display this help message\n" + " -v display version number\n"); +} + + +int main(int argc, char **argv) { + char **arg = argv + 1; + char **arg_end = argv + argc; + + /* defaults */ + const char *outfile = NULL; + const char *prefix = ""; + int zerobyte = 0; + int nostatic = 0; + + /* handle options */ + while (arg != arg_end && (*arg)[0] == '-') { + switch ((*arg)[1]) { + case 'h': + print_help(); + exit(EXIT_SUCCESS); + break; + + case 'v': + printf("cembed " VERSION "\n"); + exit(EXIT_SUCCESS); + break; + + case 's': + nostatic = 1; + break; + + case 'z': + zerobyte = 1; + break; + + case 'o': + arg++; + if (arg == arg_end) { error("expected filename after option '-o'"); } + outfile = *arg; + break; + + case 'p': + arg++; + if (arg == arg_end) { error("expected prefix after option '-p'"); } + prefix = *arg; + break; + + default: + error("invalid option '%s'", *arg); + break; + } + + arg++; + } + + /* no file arguments: print help */ + if (arg == arg_end) { + print_help(); + exit(EXIT_SUCCESS); + } + + /* open output */ + FILE *fp = outfile ? fopen(outfile, "wb") : stdout; + if (!fp) { error("failed to open output file '%s'", outfile); } + + /* write files */ + while (arg != arg_end) { + write_embedded(fp, *arg, prefix, nostatic, zerobyte); + arg++; + } + + /* clean up */ + if (fp != stdout) { fclose(fp); } + return EXIT_SUCCESS; +} diff --git a/src/libjin/common/je_object.h b/src/libjin/common/je_object.h index 677b474..581500f 100644 --- a/src/libjin/common/je_object.h +++ b/src/libjin/common/je_object.h @@ -11,6 +11,7 @@ namespace JinEngine { public: virtual ~Object() {}; + }; } // namespace JinEngine diff --git a/src/lua/embed/scripts/ai.lua b/src/lua/embed/scripts/ai.lua new file mode 100644 index 0000000..a69da84 --- /dev/null +++ b/src/lua/embed/scripts/ai.lua @@ -0,0 +1,26 @@ +/* graphics.lua */ +static const char* ai_lua = R"( +jin.ai = jin.ai or {} + +local ja = jin.ai + +ja.StateMachineType = { + STEPWISE = 1, + ITERATIVE = 2, +} + + + +)"; + + +//local sp = jin.graphics.newSprite() +//local sm = jin.ai.newStateMachine(jin.StateMachineMode.STEPWISE, sp) +//sm:addState("run") +//sm:addEnterCallback("run", function(spr) +// spr:setRun() +//end) +// +//function jin.core.onUpdate(dt) +// sm:update() +//end diff --git a/src/lua/embed/scripts/boot.lua b/src/lua/embed/scripts/boot.lua new file mode 100644 index 0000000..4b97b69 --- /dev/null +++ b/src/lua/embed/scripts/boot.lua @@ -0,0 +1,139 @@ +/* boot.lua */ +static const char* boot_lua = R"( +local cwd = jin.args['cwd'] or '.' +jin.filesystem.init() +jin.filesystem.mount(cwd) + +------------------------------------------------------------------------- +-- Config game +------------------------------------------------------------------------- + +jin.config = {} +if jin.filesystem.exist("config.lua") then + xpcall(function()jin.config = require "config" end, function()end) +end +jin.config.width = jin.config.width or 580 +jin.config.height = jin.config.height or 450 +jin.config.vsync = jin.config.vsync or true +jin.config.title = jin.config.title or ("jin v" .. jin.version) +jin.config.resizable = jin.config.resizable or false +jin.config.fullscreen = jin.config.fullscreen or false +jin.config.fps = jin.config.fps or 60 +jin.config.icon = jin.config.icon or "" + +------------------------------------------------------------------------- +-- Default game loop +------------------------------------------------------------------------- + +local function call(func, ...) + if func then + return func(...) + end +end + +local step = jin.time.step +jin.time.step = nil + +function jin.core.run() + jin.graphics.reset() + call(jin.core.onLoad) + local dt = 0 + while jin.core.running() do + for _, e in pairs(jin.event.poll()) do + if e.type == "KeyDown" then + jin.keyboard.set(e.key, true) + elseif e.type == "KeyUp" then + jin.keyboard.set(e.key, false) + end + call(jin.core.onEvent, e) + end + step() + dt = jin.time.getDelta() + call(jin.core.onUpdate, dt) + jin.graphics.clear() + call(jin.core.onDraw) + jin.graphics.present() + jin.time.sleep(0.001) + end +end + +------------------------------------------------------------------------- +-- Boot game +------------------------------------------------------------------------- + +-- Display error message. +local function onError(msg) + jin.audio.destroy() + jin.graphics.showWindow() + local err = "Error:\n" .. msg .. "\n" .. debug.traceback() + jin.graphics.reset() + jin.graphics.setClearColor(100, 100, 100, 255) + jin.graphics.clear() + jin.graphics.print(err, 5, 5) + jin.graphics.present() + while jin.core.running() do + for _, e in pairs(jin.event.poll()) do + if e.type == "Quit" then + jin.core.stop() + end + end + jin.time.sleep(0.001) + end +end + +-- No game screen. +local function noGame() + jin.graphics.showWindow() + jin.graphics.reset() + jin.graphics.setClearColor(100, 100, 100, 255) + jin.graphics.clear() + jin.graphics.print("No Game", 5, 5) + jin.graphics.present() + while jin.core.running() do + for _, e in pairs(jin.event.poll()) do + if e.type == "Quit" then + jin.core.stop() + end + end + jin.time.sleep(0.001) + end +end + +local function boot() + if jin.filesystem.exist("main.lua") then + call(function() + require"main" + jin.core.run() + end) + else + noGame() + end +end + +------------------------------------------------------------------------- +-- Initialize sub systems +------------------------------------------------------------------------- + +jin.audio.init() +jin.graphics.init(jin.config) + +------------------------------------------------------------------------- +-- Boot game +------------------------------------------------------------------------- + +xpcall(boot, onError) + +------------------------------------------------------------------------- +-- Destroy sub-systems +------------------------------------------------------------------------- + +jin.graphics.destroy() +jin.audio.destroy() + +------------------------------------------------------------------------- +-- Quit game +------------------------------------------------------------------------- + +jin.core.quit() + +)"; \ No newline at end of file diff --git a/src/lua/embed/scripts/graphics.lua b/src/lua/embed/scripts/graphics.lua new file mode 100644 index 0000000..0a66127 --- /dev/null +++ b/src/lua/embed/scripts/graphics.lua @@ -0,0 +1,139 @@ +/* graphics.lua */ +static const char* graphics_lua = R"( +jin.graphics = jin.graphics or {} + +local jg = jin.graphics + +jg.RenderMode = { + FILL = 1, + LINE = 2, +} + +jg.SpriteOrigin = { + TOPLEFT = 0, + TOPCENTER = 1, + TOPRIGHT = 2, + MIDDLELEFT = 3, + MIDDLECENTER = 4, + MIDDLERIGHT = 5, + BOTTOMLEFT = 6, + BOTTOMCENTER = 7, + BOTTOMRIGHT = 8 +} + +jg.SpriteMode = { + SINGLE = 1, + RANDOM = 2, + ANIMATED = 3 +} + +-- built in shaders +jg.Shaders = { + Font = nil, + Texture = nil, + Sprite = nil, + SpriteSheet = nil, + Default = nil +} + +local function compileBuiltInShaders() + jg.Shaders.Font = jg.newShader([[ + #VERTEX_SHADER + Vertex vert(Vertex v) + { + return v; + } + #END_VERTEX_SHADER + #FRAGMENT_SHADER + Color frag(Color col, Texture tex, Vertex v) + { + return Color(col.rgb, texel(tex, v.uv).a); + } + #END_FRAGMENT_SHADER + ]]) + jg.Shaders.Texture = jg.newShader([[ + #VERTEX_SHADER + Vertex vert(Vertex v) + { + return v; + } + #END_VERTEX_SHADER + #FRAGMENT_SHADER + Color frag(Color col, Texture tex, Vertex v) + { + return col * texel(tex, v.uv); + } + #END_FRAGMENT_SHADER + ]]) + jg.Shaders.Sprite = jg.newShader([[ + #VERTEX_SHADER + Vertex vert(Vertex v) + { + return v; + } + #END_VERTEX_SHADER + #FRAGMENT_SHADER + Color frag(Color col, Texture tex, Vertex v) + { + return col * texel(tex, v.uv); + } + #END_FRAGMENT_SHADER + ]]) + jg.Shaders.SpriteSheet = jg.newShader([[ + #VERTEX_SHADER + Vertex vert(Vertex v) + { + return v; + } + #END_VERTEX_SHADER + #FRAGMENT_SHADER + Color frag(Color col, Texture tex, Vertex v) + { + return col * texel(tex, v.uv); + } + #END_FRAGMENT_SHADER + ]]) + jg.Shaders.Default = jg.newShader([[ + #VERTEX_SHADER + Vertex vert(Vertex v) + { + return v; + } + #END_VERTEX_SHADER + #FRAGMENT_SHADER + Color frag(Color col, Texture tex, Vertex v) + { + return col * texel(tex, v.uv); + } + #END_FRAGMENT_SHADER + ]]) +end + +local _init = jg.init +local initialized = false +jg.init = function(setting) + if initialized then + return initialized + end + initialized = _init(setting) + if initialized then + compileBuiltInShaders() + jg.useShader(jg.Shaders.Default) + end + return initialized +end + +jg.unuseShader = function() + jg.useShader(jg.Shaders.Default) +end + +-- Reset all attributes to default value. +jg.reset = function() + jg.setColor(255, 255, 255, 255) + jg.setClearColor(0, 0, 0, 255) + jg.clear() + jg.unsetFont() + jg.unuseShader() +end + +)"; \ No newline at end of file diff --git a/src/lua/embed/scripts/graphics.lua.h b/src/lua/embed/scripts/graphics.lua.h index 1dddbf5..0a66127 100644 --- a/src/lua/embed/scripts/graphics.lua.h +++ b/src/lua/embed/scripts/graphics.lua.h @@ -27,44 +27,104 @@ jg.SpriteMode = { ANIMATED = 3 } -local default_shader = nil -local default_shader_source = [[ -#VERTEX_SHADER - -Vertex vert(Vertex v) -{ - return v; +-- built in shaders +jg.Shaders = { + Font = nil, + Texture = nil, + Sprite = nil, + SpriteSheet = nil, + Default = nil } -#END_VERTEX_SHADER - -#FRAGMENT_SHADER - -Color frag(Color col, Texture tex, Vertex v) -{ - return col * texel(tex, v.uv); -} - -#END_FRAGMENT_SHADER -]] +local function compileBuiltInShaders() + jg.Shaders.Font = jg.newShader([[ + #VERTEX_SHADER + Vertex vert(Vertex v) + { + return v; + } + #END_VERTEX_SHADER + #FRAGMENT_SHADER + Color frag(Color col, Texture tex, Vertex v) + { + return Color(col.rgb, texel(tex, v.uv).a); + } + #END_FRAGMENT_SHADER + ]]) + jg.Shaders.Texture = jg.newShader([[ + #VERTEX_SHADER + Vertex vert(Vertex v) + { + return v; + } + #END_VERTEX_SHADER + #FRAGMENT_SHADER + Color frag(Color col, Texture tex, Vertex v) + { + return col * texel(tex, v.uv); + } + #END_FRAGMENT_SHADER + ]]) + jg.Shaders.Sprite = jg.newShader([[ + #VERTEX_SHADER + Vertex vert(Vertex v) + { + return v; + } + #END_VERTEX_SHADER + #FRAGMENT_SHADER + Color frag(Color col, Texture tex, Vertex v) + { + return col * texel(tex, v.uv); + } + #END_FRAGMENT_SHADER + ]]) + jg.Shaders.SpriteSheet = jg.newShader([[ + #VERTEX_SHADER + Vertex vert(Vertex v) + { + return v; + } + #END_VERTEX_SHADER + #FRAGMENT_SHADER + Color frag(Color col, Texture tex, Vertex v) + { + return col * texel(tex, v.uv); + } + #END_FRAGMENT_SHADER + ]]) + jg.Shaders.Default = jg.newShader([[ + #VERTEX_SHADER + Vertex vert(Vertex v) + { + return v; + } + #END_VERTEX_SHADER + #FRAGMENT_SHADER + Color frag(Color col, Texture tex, Vertex v) + { + return col * texel(tex, v.uv); + } + #END_FRAGMENT_SHADER + ]]) +end local _init = jg.init local initialized = false - jg.init = function(setting) if initialized then return initialized end initialized = _init(setting) if initialized then - default_shader = jg.newShader(default_shader_source) - jg.useShader(default_shader) + compileBuiltInShaders() + jg.useShader(jg.Shaders.Default) end return initialized end jg.unuseShader = function() - jg.useShader(default_shader) + jg.useShader(jg.Shaders.Default) end -- Reset all attributes to default value. diff --git a/src/lua/embed/scripts/keyboard.lua b/src/lua/embed/scripts/keyboard.lua new file mode 100644 index 0000000..e989928 --- /dev/null +++ b/src/lua/embed/scripts/keyboard.lua @@ -0,0 +1,17 @@ + +static const char* keyboard_lua = R"( +jin.keyboard = jin.keyboard or {} + +local jk = jin.keyboard + +local keys = {} + +function jin.keyboard.isPressed(k) + return keys[k] +end + +function jin.keyboard.set(k, status) + keys[k] = status +end + +)"; diff --git a/src/lua/embed/scripts/mouse.lua b/src/lua/embed/scripts/mouse.lua new file mode 100644 index 0000000..ca070a3 --- /dev/null +++ b/src/lua/embed/scripts/mouse.lua @@ -0,0 +1,16 @@ +static const char* mouse_lua = R"( +jin.mouse = jin.mouse or {} + +local jm = jin.mouse + +local button = {} + +function jin.mouse.isDown(btn) + return button[btn] +end + +function jin.mouse.set(btn, status) + button[btn] = status +end + +)"; \ No newline at end of file diff --git a/src/lua/embed/scripts/net.lua b/src/lua/embed/scripts/net.lua new file mode 100644 index 0000000..a986ce6 --- /dev/null +++ b/src/lua/embed/scripts/net.lua @@ -0,0 +1,7 @@ +/* net.lua */ +static const char* net_lua = R"( +jin.net = jin.net or {} + +local jn = jin.net + +)"; \ No newline at end of file diff --git a/src/lua/embed/scripts/path.lua b/src/lua/embed/scripts/path.lua new file mode 100644 index 0000000..f7e1ec3 --- /dev/null +++ b/src/lua/embed/scripts/path.lua @@ -0,0 +1,16 @@ +/* path.lua */ +static const char* path_lua = R"( +jin.path = jin.path or {} + +local jp = jin.path + +-- game root directory +jin._root = nil + +-- return full path of a given path +function jin.path.full(path) + local root = jin._dir .. '/' .. jin._argv[2] + return root .. '/' .. path +end + +)"; \ No newline at end of file -- cgit v1.1-26-g67d0