diff --git a/.gitignore b/.gitignore
index 183df4b..ad5ae32 100644
--- a/.gitignore
+++ b/.gitignore
@@ -115,3 +115,10 @@ build/windows/sdl-gpu/Debug/
build/windows/sdl-gpu/Debug Pro/
build/windows/sdl-gpu/Release/
build/windows/sdl-gpu/Release Pro/
+build/uwp/sdl-gpu-static/Debug/
+build/uwp/sdl-gpu-static/Debug Pro/
+build/uwp/sdl-gpu-static/Release/
+build/uwp/sdl-gpu-static/Release Pro/
+build/uwp/sdl-gpu-static/ARM/
+build/uwp/sdl-gpu-static/x64/
+build/uwp/tic/packages/
diff --git a/3rd-party b/3rd-party
index f9e1081..c326432 160000
--- a/3rd-party
+++ b/3rd-party
@@ -1 +1 @@
-Subproject commit f9e108123796f9bb8bbe6c8b87239bb09fec14d0
+Subproject commit c326432f2ca415f4c63268a8ebff2221e03038e7
diff --git a/build/uwp/sdl-gpu-static/sdl-gpu-static.vcxproj b/build/uwp/sdl-gpu-static/sdl-gpu-static.vcxproj
new file mode 100644
index 0000000..a2bf10d
--- /dev/null
+++ b/build/uwp/sdl-gpu-static/sdl-gpu-static.vcxproj
@@ -0,0 +1,220 @@
+
+
+
+
+ Debug
+ ARM
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ ARM
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+
+
+
+
+
+
+
+
+ {361dfddb-f86e-4c2c-abee-03acf4b8ac33}
+ StaticLibrary
+ sdl_gpu_static
+ en-US
+ 14.0
+ true
+ Windows Store
+ 10.0.14393.0
+ 10.0.14393.0
+ 10.0
+
+
+
+ StaticLibrary
+ true
+ v140
+
+
+ StaticLibrary
+ true
+ v140
+
+
+ StaticLibrary
+ true
+ v140
+
+
+ StaticLibrary
+ false
+ true
+ v140
+
+
+ StaticLibrary
+ false
+ true
+ v140
+
+
+ StaticLibrary
+ false
+ true
+ v140
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+ false
+
+
+ false
+
+
+ false
+
+
+ false
+
+
+ false
+
+
+
+ NotUsing
+ false
+ false
+ ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+ SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions)
+
+
+ Console
+ false
+ false
+
+
+
+
+ NotUsing
+ false
+ false
+ ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+ SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions)
+
+
+ Console
+ false
+ false
+
+
+
+
+ NotUsing
+ false
+ false
+ ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+ SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions)
+
+
+ Console
+ false
+ false
+
+
+
+
+ NotUsing
+ false
+ false
+ ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+ SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions)
+
+
+ Console
+ false
+ false
+
+
+
+
+ NotUsing
+ false
+ false
+ ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+ SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions)
+
+
+ Console
+ false
+ false
+
+
+
+
+ NotUsing
+ false
+ false
+ ..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\sdl-gpu\src;..\..\..\3rd-party\sdl-gpu\src\externals\glew;..\..\..\3rd-party\sdl-gpu\src\externals\glew\GL;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image;..\..\..\3rd-party\sdl-gpu\src\externals\stb_image_write;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+ SDL_GPU_DISABLE_GLES_1;SDL_GPU_DISABLE_GLES_3;SDL_GPU_DISABLE_OPENGL;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions)
+
+
+ Console
+ false
+ false
+
+
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
\ No newline at end of file
diff --git a/build/uwp/sdl-gpu-static/sdl-gpu-static.vcxproj.filters b/build/uwp/sdl-gpu-static/sdl-gpu-static.vcxproj.filters
new file mode 100644
index 0000000..8d95540
--- /dev/null
+++ b/build/uwp/sdl-gpu-static/sdl-gpu-static.vcxproj.filters
@@ -0,0 +1,28 @@
+
+
+
+
+ {c3550c01-2588-4878-8d79-ead29ff8053e}
+
+
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+
\ No newline at end of file
diff --git a/build/uwp/tic/packages.config b/build/uwp/tic/packages.config
new file mode 100644
index 0000000..70c3dea
--- /dev/null
+++ b/build/uwp/tic/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/build/uwp/tic/tic.sln b/build/uwp/tic/tic.sln
index 3623212..924a807 100644
--- a/build/uwp/tic/tic.sln
+++ b/build/uwp/tic/tic.sln
@@ -19,6 +19,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wren", "..\wren\wren.vcxpro
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "studio", "..\studio\studio.vcxproj", "{6A22403A-6CF5-49F2-A012-EC04C9496306}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdl-gpu-static", "..\sdl-gpu-static\sdl-gpu-static.vcxproj", "{361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
@@ -131,6 +133,18 @@ Global
{6A22403A-6CF5-49F2-A012-EC04C9496306}.Release|x64.Build.0 = Release|x64
{6A22403A-6CF5-49F2-A012-EC04C9496306}.Release|x86.ActiveCfg = Release|Win32
{6A22403A-6CF5-49F2-A012-EC04C9496306}.Release|x86.Build.0 = Release|Win32
+ {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Debug|ARM.ActiveCfg = Debug|ARM
+ {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Debug|ARM.Build.0 = Debug|ARM
+ {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Debug|x64.ActiveCfg = Debug|x64
+ {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Debug|x64.Build.0 = Debug|x64
+ {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Debug|x86.ActiveCfg = Debug|Win32
+ {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Debug|x86.Build.0 = Debug|Win32
+ {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Release|ARM.ActiveCfg = Release|ARM
+ {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Release|ARM.Build.0 = Release|ARM
+ {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Release|x64.ActiveCfg = Release|x64
+ {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Release|x64.Build.0 = Release|x64
+ {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Release|x86.ActiveCfg = Release|Win32
+ {361DFDDB-F86E-4C2C-ABEE-03ACF4B8AC33}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/build/uwp/tic/tic.vcxproj b/build/uwp/tic/tic.vcxproj
index d6dfff2..d6b886b 100644
--- a/build/uwp/tic/tic.vcxproj
+++ b/build/uwp/tic/tic.vcxproj
@@ -109,7 +109,7 @@
4453;28204
false
NotUsing
- ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+ ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
_WINSOCK_DEPRECATED_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_5_2;_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions)
@@ -125,7 +125,7 @@
4453;28204
false
NotUsing
- ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+ ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
_WINSOCK_DEPRECATED_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_5_2;_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions)
@@ -141,7 +141,7 @@
4453;28204
false
NotUsing
- ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+ ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
_WINSOCK_DEPRECATED_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_5_2;_UNICODE;UNICODE;%(PreprocessorDefinitions)
@@ -157,7 +157,7 @@
4453;28204
false
NotUsing
- ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+ ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
_WINSOCK_DEPRECATED_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_5_2;_UNICODE;UNICODE;%(PreprocessorDefinitions)
@@ -173,7 +173,7 @@
4453;28204
false
NotUsing
- ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+ ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
_WINSOCK_DEPRECATED_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_5_2;_UNICODE;UNICODE;%(PreprocessorDefinitions)
@@ -189,7 +189,7 @@
4453;28204
false
NotUsing
- ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+ ..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\sdl-gpu\include;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2_net-2.0.1;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
_WINSOCK_DEPRECATED_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_5_2;_UNICODE;UNICODE;%(PreprocessorDefinitions)
@@ -203,6 +203,7 @@
Designer
+
@@ -219,6 +220,9 @@
{89e9b32e-a86a-47c3-a948-d2b1622925ce}
+
+ {361dfddb-f86e-4c2c-abee-03acf4b8ac33}
+
{6a22403a-6cf5-49f2-a012-ec04c9496306}
@@ -255,5 +259,12 @@
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
\ No newline at end of file
diff --git a/build/uwp/tic/tic.vcxproj.filters b/build/uwp/tic/tic.vcxproj.filters
index 6d7316c..ed685a2 100644
--- a/build/uwp/tic/tic.vcxproj.filters
+++ b/build/uwp/tic/tic.vcxproj.filters
@@ -45,6 +45,7 @@
+
diff --git a/build/uwp/tic/tic.vcxproj.user b/build/uwp/tic/tic.vcxproj.user
index 2eac851..62e3277 100644
--- a/build/uwp/tic/tic.vcxproj.user
+++ b/build/uwp/tic/tic.vcxproj.user
@@ -11,7 +11,7 @@
XboxOne
- UWPRemoteDebugger
+ WindowsDeviceDebugger
XboxOne
diff --git a/build/windows/studio/studio.vcxproj b/build/windows/studio/studio.vcxproj
index 32b1618..ea20fd2 100644
--- a/build/windows/studio/studio.vcxproj
+++ b/build/windows/studio/studio.vcxproj
@@ -168,7 +168,7 @@
Level3
Disabled
- WIN32;_DEBUG;_WINDOWS;_USRDLL;STUDIO_EXPORTS;%(PreprocessorDefinitions)
+ TIC80_PRO;WIN32;_DEBUG;_WINDOWS;_USRDLL;STUDIO_EXPORTS;%(PreprocessorDefinitions)
..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\wren-0.1.0\src\include
MultiThreadedDebug
@@ -198,7 +198,7 @@
Level3
Disabled
- _DEBUG;_WINDOWS;_USRDLL;STUDIO_EXPORTS;%(PreprocessorDefinitions)
+ TIC80_PRO;_DEBUG;_WINDOWS;_USRDLL;STUDIO_EXPORTS;%(PreprocessorDefinitions)
..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\wren-0.1.0\src\include
MultiThreadedDebug
@@ -234,7 +234,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_WINDOWS;_USRDLL;STUDIO_EXPORTS;%(PreprocessorDefinitions)
+ TIC80_PRO;WIN32;NDEBUG;_WINDOWS;_USRDLL;STUDIO_EXPORTS;%(PreprocessorDefinitions)
..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\wren-0.1.0\src\include
MultiThreaded
@@ -272,7 +272,7 @@
MaxSpeed
true
true
- NDEBUG;_WINDOWS;_USRDLL;STUDIO_EXPORTS;%(PreprocessorDefinitions)
+ TIC80_PRO;NDEBUG;_WINDOWS;_USRDLL;STUDIO_EXPORTS;%(PreprocessorDefinitions)
..\include;..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\zlib-1.2.8;..\..\..\3rd-party\SDL2-2.0.7\include;..\..\..\3rd-party\wren-0.1.0\src\include
MultiThreaded
diff --git a/data/shaders/common.frag b/data/shaders/common.frag
deleted file mode 100644
index 289cb44..0000000
--- a/data/shaders/common.frag
+++ /dev/null
@@ -1,11 +0,0 @@
-
-in vec4 color;
-in vec2 texCoord;
-out vec4 fragColor;
-
-uniform sampler2D tex;
-
-void main(void)
-{
- fragColor = texture2D(tex, texCoord) * color;
-}
\ No newline at end of file
diff --git a/data/shaders/crt-geom.frag b/data/shaders/crt-geom.frag
deleted file mode 100644
index f7d55b8..0000000
--- a/data/shaders/crt-geom.frag
+++ /dev/null
@@ -1,23 +0,0 @@
-#define distortion 0.08
-
-in vec2 texCoord;
-out vec4 fragColor;
-
-uniform sampler2D tex;
-
-vec2 radialDistortion(vec2 coord) {
- vec2 cc = coord - vec2(0.5);
- float dist = dot(cc, cc) * distortion;
- return coord + cc * (1.0 - dist) * dist;
-}
-
-void main(void) {
- vec4 rgba = texture2D(tex, radialDistortion(texCoord));
-
- vec4 intensity = fract(gl_FragCoord.y * (0.5 * 4.0 / 3.0)) > 0.5
- ? vec4(0)
- : smoothstep(0.2, 0.8, rgba) + normalize(rgba);
-
- fragColor = intensity * -0.25 + rgba * 1.1;
-
-}
\ No newline at end of file
diff --git a/data/shaders/crt-lottes.frag b/data/shaders/crt-lottes.frag
deleted file mode 100644
index 570126b..0000000
--- a/data/shaders/crt-lottes.frag
+++ /dev/null
@@ -1,126 +0,0 @@
-in vec2 texCoord;
-out vec4 fragColor;
-
-uniform sampler2D tex;
-uniform float trg_w;
-uniform float trg_h;
-
-// Emulated input resolution.
-vec2 res=vec2(256.0,144.0);
-
-vec2 trg=vec2(trg_w, trg_h);
-
-// Hardness of scanline.
-// -8.0 = soft
-// -16.0 = medium
-float hardScan=-8.0;
-
-// Hardness of pixels in scanline.
-// -2.0 = soft
-// -4.0 = hard
-float hardPix=-3.0;
-
-// Display warp.
-// 0.0 = none
-// 1.0/8.0 = extreme
-vec2 warp=vec2(1.0/32.0,1.0/24.0);
-
-// Amount of shadow mask.
-float maskDark=0.5;
-float maskLight=1.5;
-
-//------------------------------------------------------------------------
-
-// sRGB to Linear.
-// Assuing using sRGB typed textures this should not be needed.
-float ToLinear1(float c){return(c<=0.04045)?c/12.92:pow((c+0.055)/1.055,2.4);}
-vec3 ToLinear(vec3 c){return vec3(ToLinear1(c.r),ToLinear1(c.g),ToLinear1(c.b));}
-
-// Linear to sRGB.
-// Assuing using sRGB typed textures this should not be needed.
-float ToSrgb1(float c){return(c<0.0031308?c*12.92:1.055*pow(c,0.41666)-0.055);}
-vec3 ToSrgb(vec3 c){return vec3(ToSrgb1(c.r),ToSrgb1(c.g),ToSrgb1(c.b));}
-
-// Nearest emulated sample given floating point position and texel offset.
-// Also zero's off screen.
-vec3 Fetch(vec2 pos,vec2 off){
- pos=(floor(pos*res+off)+vec2(0.5,0.5))/res;
- return ToLinear(1.2 * texture2D(tex,pos.xy,-16.0).rgb);} //vec2???
-
-// Distance in emulated pixels to nearest texel.
-vec2 Dist(vec2 pos){pos=pos*res;return -((pos-floor(pos))-vec2(0.5));}
-
-// 1D Gaussian.
-float Gaus(float pos,float scale){return exp2(scale*pos*pos);}
-
-// 3-tap Gaussian filter along horz line.
-vec3 Horz3(vec2 pos,float off){
- vec3 b=Fetch(pos,vec2(-1.0,off));
- vec3 c=Fetch(pos,vec2( 0.0,off));
- vec3 d=Fetch(pos,vec2( 1.0,off));
- float dst=Dist(pos).x;
- // Convert distance to weight.
- float scale=hardPix;
- float wb=Gaus(dst-1.0,scale);
- float wc=Gaus(dst+0.0,scale);
- float wd=Gaus(dst+1.0,scale);
- // Return filtered sample.
- return (b*wb+c*wc+d*wd)/(wb+wc+wd);}
-
-// 5-tap Gaussian filter along horz line.
-vec3 Horz5(vec2 pos,float off){
- vec3 a=Fetch(pos,vec2(-2.0,off));
- vec3 b=Fetch(pos,vec2(-1.0,off));
- vec3 c=Fetch(pos,vec2( 0.0,off));
- vec3 d=Fetch(pos,vec2( 1.0,off));
- vec3 e=Fetch(pos,vec2( 2.0,off));
- float dst=Dist(pos).x;
- // Convert distance to weight.
- float scale=hardPix;
- float wa=Gaus(dst-2.0,scale);
- float wb=Gaus(dst-1.0,scale);
- float wc=Gaus(dst+0.0,scale);
- float wd=Gaus(dst+1.0,scale);
- float we=Gaus(dst+2.0,scale);
- // Return filtered sample.
- return (a*wa+b*wb+c*wc+d*wd+e*we)/(wa+wb+wc+wd+we);}
-
-// Return scanline weight.
-float Scan(vec2 pos,float off){
- float dst=Dist(pos).y;
- return Gaus(dst+off,hardScan);}
-
-// Allow nearest three lines to effect pixel.
-vec3 Tri(vec2 pos){
- vec3 a=Horz3(pos,-1.0);
- vec3 b=Horz5(pos, 0.0);
- vec3 c=Horz3(pos, 1.0);
- float wa=Scan(pos,-1.0);
- float wb=Scan(pos, 0.0);
- float wc=Scan(pos, 1.0);
- return a*wa+b*wb+c*wc;}
-
-// Distortion of scanlines, and end of screen alpha.
-vec2 Warp(vec2 pos){
- pos=pos*2.0-1.0;
- pos*=vec2(1.0+(pos.y*pos.y)*warp.x,1.0+(pos.x*pos.x)*warp.y);
- return pos*0.5+0.5;}
-
-// Shadow mask.
-vec3 Mask(vec2 pos){
- pos.x+=pos.y*3.0;
- vec3 mask=vec3(maskDark,maskDark,maskDark);
- pos.x=fract(pos.x/6.0);
- if(pos.x<0.333)mask.r=maskLight;
- else if(pos.x<0.666)mask.g=maskLight;
- else mask.b=maskLight;
- return mask;}
-
-void main()
-{
-// maskDark=maskLight;
- vec2 pos=Warp(gl_FragCoord.xy/trg);
- fragColor.rgb=Tri(vec2(pos.s, 1.0 - pos.t))*Mask(gl_FragCoord.xy);
- fragColor.a=1.0;
- fragColor = vec4(ToSrgb(fragColor.rgb), fragColor.a);
-}
diff --git a/data/shaders/crt-simple.frag b/data/shaders/crt-simple.frag
deleted file mode 100644
index 00fd3bc..0000000
--- a/data/shaders/crt-simple.frag
+++ /dev/null
@@ -1,15 +0,0 @@
-in vec2 texCoord;
-out vec4 fragColor;
-
-uniform sampler2D tex;
-
-void main(void)
-{
- vec4 rgba = texture2D(tex, texCoord);
-
- vec4 intensity = fract(gl_FragCoord.y * (0.5 * 4.0 / 3.0)) > 0.5
- ? vec4(0)
- : smoothstep(0.2, 0.8, rgba) + normalize(rgba);
-
- fragColor = intensity * -0.25 + rgba * 1.1;
-}
diff --git a/data/shaders/common.vert b/src/ext/shader/common.vert
similarity index 59%
rename from data/shaders/common.vert
rename to src/ext/shader/common.vert
index 8fcb0f0..f82e14d 100644
--- a/data/shaders/common.vert
+++ b/src/ext/shader/common.vert
@@ -1,14 +1,19 @@
-attribute vec3 gpu_Vertex;
+CODE(
+
+precision highp float;
+precision mediump int;
+
+attribute vec2 gpu_Vertex;
attribute vec2 gpu_TexCoord;
-attribute vec4 gpu_Color;
+attribute mediump vec4 gpu_Color;
uniform mat4 gpu_ModelViewProjectionMatrix;
-varying vec4 color;
+varying mediump vec4 color;
varying vec2 texCoord;
void main(void)
{
color = gpu_Color;
texCoord = vec2(gpu_TexCoord);
- gl_Position = gpu_ModelViewProjectionMatrix * vec4(gpu_Vertex, 1.0);
-}
\ No newline at end of file
+ gl_Position = gpu_ModelViewProjectionMatrix * vec4(gpu_Vertex, 0.0, 1.0);
+})
\ No newline at end of file
diff --git a/src/ext/shader/crt-lottes.frag b/src/ext/shader/crt-lottes.frag
new file mode 100644
index 0000000..355f646
--- /dev/null
+++ b/src/ext/shader/crt-lottes.frag
@@ -0,0 +1,127 @@
+CODE(
+
+precision highp float;
+
+varying vec2 texCoord;
+uniform sampler2D source;
+uniform float trg_w;
+uniform float trg_h;
+
+// Emulated input resolution.
+vec2 res=vec2(256.0,144.0);
+vec2 trg=vec2(trg_w, trg_h);
+
+// Hardness of scanline.
+// -8.0 = soft
+// -16.0 = medium
+float hardScan=-8.0;
+
+// Hardness of pixels in scanline.
+// -2.0 = soft
+// -4.0 = hard
+float hardPix=-3.0;
+
+// Display warp.
+// 0.0 = none
+// 1.0/8.0 = extreme
+vec2 warp=vec2(1.0/32.0,1.0/24.0);
+
+// Amount of shadow mask.
+float maskDark=0.5;
+float maskLight=1.5;
+
+//------------------------------------------------------------------------
+
+// sRGB to Linear.
+// Assuing using sRGB typed textures this should not be needed.
+float ToLinear1(float c){return(c<=0.04045)?c/12.92:pow((c+0.055)/1.055,2.4);}
+vec3 ToLinear(vec3 c){return vec3(ToLinear1(c.r),ToLinear1(c.g),ToLinear1(c.b));}
+
+// Linear to sRGB.
+// Assuing using sRGB typed textures this should not be needed.
+float ToSrgb1(float c){return(c<0.0031308?c*12.92:1.055*pow(c,0.41666)-0.055);}
+vec3 ToSrgb(vec3 c){return vec3(ToSrgb1(c.r),ToSrgb1(c.g),ToSrgb1(c.b));}
+
+// Nearest emulated sample given floating point position and texel offset.
+// Also zero's off screen.
+vec3 Fetch(vec2 pos,vec2 off){
+ pos=(floor(pos*res+off)+vec2(0.5,0.5))/res;
+ return ToLinear(1.2 * texture2D(source,pos.xy,-16.0).rgb);}
+
+// Distance in emulated pixels to nearest texel.
+vec2 Dist(vec2 pos){pos=pos*res;return -((pos-floor(pos))-vec2(0.5));}
+
+// 1D Gaussian.
+float Gaus(float pos,float scale){return exp2(scale*pos*pos);}
+
+// 3-tap Gaussian filter along horz line.
+vec3 Horz3(vec2 pos,float off){
+ vec3 b=Fetch(pos,vec2(-1.0,off));
+ vec3 c=Fetch(pos,vec2( 0.0,off));
+ vec3 d=Fetch(pos,vec2( 1.0,off));
+ float dst=Dist(pos).x;
+ // Convert distance to weight.
+ float scale=hardPix;
+ float wb=Gaus(dst-1.0,scale);
+ float wc=Gaus(dst+0.0,scale);
+ float wd=Gaus(dst+1.0,scale);
+ // Return filtered sample.
+ return (b*wb+c*wc+d*wd)/(wb+wc+wd);}
+
+// 5-tap Gaussian filter along horz line.
+vec3 Horz5(vec2 pos,float off){
+ vec3 a=Fetch(pos,vec2(-2.0,off));
+ vec3 b=Fetch(pos,vec2(-1.0,off));
+ vec3 c=Fetch(pos,vec2( 0.0,off));
+ vec3 d=Fetch(pos,vec2( 1.0,off));
+ vec3 e=Fetch(pos,vec2( 2.0,off));
+ float dst=Dist(pos).x;
+ // Convert distance to weight.
+ float scale=hardPix;
+ float wa=Gaus(dst-2.0,scale);
+ float wb=Gaus(dst-1.0,scale);
+ float wc=Gaus(dst+0.0,scale);
+ float wd=Gaus(dst+1.0,scale);
+ float we=Gaus(dst+2.0,scale);
+ // Return filtered sample.
+ return (a*wa+b*wb+c*wc+d*wd+e*we)/(wa+wb+wc+wd+we);}
+
+// Return scanline weight.
+float Scan(vec2 pos,float off){
+ float dst=Dist(pos).y;
+ return Gaus(dst+off,hardScan);}
+
+// Allow nearest three lines to effect pixel.
+vec3 Tri(vec2 pos){
+ vec3 a=Horz3(pos,-1.0);
+ vec3 b=Horz5(pos, 0.0);
+ vec3 c=Horz3(pos, 1.0);
+ float wa=Scan(pos,-1.0);
+ float wb=Scan(pos, 0.0);
+ float wc=Scan(pos, 1.0);
+ return a*wa+b*wb+c*wc;}
+
+// Distortion of scanlines, and end of screen alpha.
+vec2 Warp(vec2 pos){
+ pos=pos*2.0-1.0;
+ pos*=vec2(1.0+(pos.y*pos.y)*warp.x,1.0+(pos.x*pos.x)*warp.y);
+ return pos*0.5+0.5;}
+
+// Shadow mask.
+vec3 Mask(vec2 pos){
+ pos.x+=pos.y*3.0;
+ vec3 mask=vec3(maskDark,maskDark,maskDark);
+ pos.x=fract(pos.x/6.0);
+ if(pos.x<0.333)mask.r=maskLight;
+ else if(pos.x<0.666)mask.g=maskLight;
+ else mask.b=maskLight;
+ return mask;}
+
+void main() {
+ vec2 pos = gl_FragCoord.xy/trg.xy;
+ hardScan=-12.0;
+// maskDark=maskLight;
+ pos=Warp(gl_FragCoord.xy/trg.xy);
+ gl_FragColor.rgb=Tri(vec2(pos.s, 1.0 - pos.t))*Mask(gl_FragCoord.xy);
+ gl_FragColor = vec4(ToSrgb(gl_FragColor.rgb), 1.0);
+})
\ No newline at end of file
diff --git a/src/map.c b/src/map.c
index 16a5a34..a40891e 100644
--- a/src/map.c
+++ b/src/map.c
@@ -1006,9 +1006,10 @@ static void copyFromClipboard(Map* map)
static void processKeyboard(Map* map)
{
tic_mem* tic = map->tic;
- map->sheet.show = false;
if(tic->ram.input.keyboard.data == 0) return;
+
+ map->sheet.show = false;
bool shift = tic->api.key(tic, tic_key_shift);
bool ctrl = tic->api.key(tic, tic_key_ctrl);
diff --git a/src/system.c b/src/system.c
index 7fc2e93..5e683e6 100644
--- a/src/system.c
+++ b/src/system.c
@@ -14,7 +14,7 @@
#endif
#define STUDIO_UI_SCALE 4
-#define STUDIO_PIXEL_FORMAT SDL_PIXELFORMAT_ARGB8888
+#define STUDIO_PIXEL_FORMAT SDL_PIXELFORMAT_ABGR8888
#define TEXTURE_SIZE (TIC80_FULLWIDTH)
#define OFFSET_LEFT ((TIC80_FULLWIDTH-TIC80_WIDTH)/2)
#define OFFSET_TOP ((TIC80_FULLHEIGHT-TIC80_HEIGHT)/2)
@@ -1060,95 +1060,47 @@ static void emstick()
#endif
-Uint32 load_shader(GPU_ShaderEnum shader_type, const char* filename)
-{
- SDL_RWops* rwops;
- Uint32 shader;
- char* source;
- int header_size, file_size;
- const char* header = "";
- GPU_Renderer* renderer = GPU_GetCurrentRenderer();
-
- // Open file
- rwops = SDL_RWFromFile(filename, "rb");
- if(rwops == NULL)
- {
- GPU_PushErrorCode("load_shader", GPU_ERROR_FILE_NOT_FOUND, "Shader file \"%s\" not found", filename);
- return 0;
- }
-
- // Get file size
- file_size = SDL_RWseek(rwops, 0, SEEK_END);
- SDL_RWseek(rwops, 0, SEEK_SET);
-
- // Get size from header
- if(renderer->shader_language == GPU_LANGUAGE_GLSL)
- {
- if(renderer->max_shader_version >= 120)
- header = "#version 120\n";
- else
- header = "#version 110\n"; // Maybe this is good enough?
- }
- else if(renderer->shader_language == GPU_LANGUAGE_GLSLES)
- header = "#version 100\nprecision mediump int;\nprecision mediump float;\n";
-
- header_size = strlen(header);
-
- // Allocate source buffer
- source = (char*)malloc(sizeof(char)*(header_size + file_size + 1));
-
- // Prepend header
- strcpy(source, header);
-
- // Read in source code
- SDL_RWread(rwops, source + strlen(source), 1, file_size);
- source[header_size + file_size] = '\0';
-
- // Compile the shader
- shader = GPU_CompileShader(shader_type, source);
-
- // Clean up
- free(source);
- SDL_RWclose(rwops);
-
- return shader;
-}
+#define CODE(...) #__VA_ARGS__
-GPU_ShaderBlock load_shader_program(Uint32* p, const char* vertex_shader_file, const char* fragment_shader_file)
+u32 load_shader_program()
{
Uint32 v, f;
- v = load_shader(GPU_VERTEX_SHADER, vertex_shader_file);
+
+ static const char* VertexShader =
+ #include "ext/shader/common.vert"
+ ;
+
+ v = GPU_CompileShader(GPU_VERTEX_SHADER, VertexShader);
if(!v)
- GPU_LogError("Failed to load vertex shader (%s): %s\n", vertex_shader_file, GPU_GetShaderMessage());
-
- f = load_shader(GPU_PIXEL_SHADER, fragment_shader_file);
+ GPU_LogError("Failed to load vertex shader: %s\n", GPU_GetShaderMessage());
+
+ static const char* PixelShader =
+ #include "ext/shader/crt-lottes.frag"
+ ;
+
+ f = GPU_CompileShader(GPU_PIXEL_SHADER, PixelShader);
if(!f)
- GPU_LogError("Failed to load fragment shader (%s): %s\n", fragment_shader_file, GPU_GetShaderMessage());
+ GPU_LogError("Failed to load fragment shader: %s\n", GPU_GetShaderMessage());
- *p = GPU_LinkShaders(v, f);
+ u32 p = GPU_LinkShaders(v, f);
- if(!*p)
+ if(!p)
{
GPU_ShaderBlock b = {-1, -1, -1, -1};
- GPU_LogError("Failed to link shader program (%s + %s): %s\n", vertex_shader_file, fragment_shader_file, GPU_GetShaderMessage());
- return b;
+ GPU_LogError("Failed to link shader program: %s\n", GPU_GetShaderMessage());
+ return p;
}
{
- GPU_ShaderBlock block = GPU_LoadShaderBlock(*p, "gpu_Vertex", "gpu_TexCoord", "gpu_Color", "gpu_ModelViewProjectionMatrix");
- GPU_ActivateShaderProgram(*p, &block);
+ GPU_ShaderBlock block = GPU_LoadShaderBlock(p, "gpu_Vertex", "gpu_TexCoord", "gpu_Color", "gpu_ModelViewProjectionMatrix");
+ GPU_ActivateShaderProgram(p, &block);
- return block;
+ return p;
}
}
-void free_shader(Uint32 p)
-{
- GPU_FreeShaderProgram(p);
-}
-
#include
static s32 start(s32 argc, char **argv, const char* folder)
@@ -1176,12 +1128,11 @@ static s32 start(s32 argc, char **argv, const char* folder)
GPU_Target* screen = GPU_Init(Width, Height, GPU_INIT_DISABLE_VSYNC);
- GPU_Image* texture = GPU_CreateImage(TIC80_FULLWIDTH, TIC80_FULLHEIGHT, GPU_FORMAT_BGRA);
+ GPU_Image* texture = GPU_CreateImage(TIC80_FULLWIDTH, TIC80_FULLHEIGHT, GPU_FORMAT_RGBA);
GPU_SetAnchor(texture, 0, 0);
GPU_SetImageFilter(texture, GPU_FILTER_NEAREST);
- u32 crt_shader = 0;
- load_shader_program(&crt_shader, "data/shaders/common.vert", "data/shaders/crt-lottes.frag");
+ u32 crt_shader = load_shader_program(&crt_shader);
{
u64 nextTick = SDL_GetPerformanceCounter();
@@ -1240,10 +1191,8 @@ static s32 start(s32 argc, char **argv, const char* folder)
SDL_CloseAudioDevice(platform.audio.device);
- free_shader(crt_shader);
-
+ GPU_FreeShaderProgram(crt_shader);
GPU_FreeImage(texture);
-
GPU_Quit();
return 0;
diff --git a/src/tic.c b/src/tic.c
index 355edec..3f55c4a 100644
--- a/src/tic.c
+++ b/src/tic.c
@@ -27,6 +27,7 @@
#include
#include
#include
+#include
#include "ticapi.h"
#include "tools.h"
@@ -823,10 +824,8 @@ static struct
{
s16 Left[TIC80_HEIGHT];
s16 Right[TIC80_HEIGHT];
- float ULeft[TIC80_HEIGHT];
- float VLeft[TIC80_HEIGHT];
- float URight[TIC80_HEIGHT];
- float VRight[TIC80_HEIGHT];
+ s32 ULeft[TIC80_HEIGHT];
+ s32 VLeft[TIC80_HEIGHT];
} SidesBuffer;
static void initSidesBuffer()
@@ -852,14 +851,12 @@ static void setSideTexPixel(s32 x, s32 y, float u, float v)
if (x < SidesBuffer.Left[yy])
{
SidesBuffer.Left[yy] = x;
- SidesBuffer.ULeft[yy] = u;
- SidesBuffer.VLeft[yy] = v;
+ SidesBuffer.ULeft[yy] = u*65536.0f;
+ SidesBuffer.VLeft[yy] = v*65536.0f;
}
if (x > SidesBuffer.Right[yy])
{
SidesBuffer.Right[yy] = x;
- SidesBuffer.URight[yy] = u;
- SidesBuffer.VRight[yy] = v;
}
}
}
@@ -1015,22 +1012,37 @@ static void api_textri(tic_mem* memory, float x1, float y1, float x2, float y2,
V0.x = (float)x1; V0.y = (float)y1; V0.u = (float)u1; V0.v = (float)v1;
V1.x = (float)x2; V1.y = (float)y2; V1.u = (float)u2; V1.v = (float)v2;
V2.x = (float)x3; V2.y = (float)y3; V2.u = (float)u3; V2.v = (float)v3;
+
+ // calculate the slope of the surface
+ // use floats here
+ double denom = (V0.x - V2.x) * (V1.y - V2.y) - (V1.x - V2.x) * (V0.y - V2.y);
+ if (denom == 0.0)
+ {
+ return;
+ }
+ double id = 1.0 / denom;
+ float dudx, dvdx;
+ // this is the UV slope across the surface
+ dudx = ((V0.u - V2.u) * (V1.y - V2.y) - (V1.u - V2.u) * (V0.y - V2.y)) * id;
+ dvdx = ((V0.v - V2.v) * (V1.y - V2.y) - (V1.v - V2.v) * (V0.y - V2.y)) * id;
+ // convert to fixed
+ s32 dudxs = dudx * 65536.0f;
+ s32 dvdxs = dvdx * 65536.0f;
+
initSidesBuffer();
ticTexLine(memory, &V0, &V1);
ticTexLine(memory, &V1, &V2);
ticTexLine(memory, &V2, &V0);
-
+
{
for (s32 y = 0; y < TIC80_HEIGHT; y++)
{
float width = SidesBuffer.Right[y] - SidesBuffer.Left[y];
if (width > 0)
{
- float du = (SidesBuffer.URight[y] - SidesBuffer.ULeft[y]) / width;
- float dv = (SidesBuffer.VRight[y] - SidesBuffer.VLeft[y]) / width;
- float u = SidesBuffer.ULeft[y];
- float v = SidesBuffer.VLeft[y];
+ s32 u = SidesBuffer.ULeft[y];
+ s32 v = SidesBuffer.VLeft[y];
for (s32 x = (s32)SidesBuffer.Left[y]; x <= (s32)SidesBuffer.Right[y]; ++x)
{
@@ -1040,8 +1052,8 @@ static void api_textri(tic_mem* memory, float x1, float y1, float x2, float y2,
{
enum {MapWidth = TIC_MAP_WIDTH * TIC_SPRITESIZE, MapHeight = TIC_MAP_HEIGHT * TIC_SPRITESIZE};
- s32 iu = (s32)u % MapWidth;
- s32 iv = (s32)v % MapHeight;
+ s32 iu = (u >> 16) % MapWidth;
+ s32 iv = (v >> 16) % MapHeight;
while (iu < 0) iu += MapWidth;
while (iv < 0) iv += MapHeight;
@@ -1056,16 +1068,16 @@ static void api_textri(tic_mem* memory, float x1, float y1, float x2, float y2,
{
enum{SheetWidth = TIC_SPRITESHEET_SIZE, SheetHeight = TIC_SPRITESHEET_SIZE * TIC_SPRITE_BANKS};
- s32 iu = (s32)(u) & (SheetWidth - 1);
- s32 iv = (s32)(v) & (SheetHeight - 1);
+ s32 iu = (u>>16) & (SheetWidth - 1);
+ s32 iv = (v>>16) & (SheetHeight - 1);
const u8 *buffer = &ptr[((iu >> 3) + ((iv >> 3) << 4)) << 5];
u8 color = tic_tool_peek4(buffer, (iu & 7) + ((iv & 7) << 3));
if (color != chroma)
setPixel(machine, x, y, color);
}
}
- u += du;
- v += dv;
+ u += dudxs;
+ v += dvdxs;
}
}
}
@@ -1073,6 +1085,7 @@ static void api_textri(tic_mem* memory, float x1, float y1, float x2, float y2,
}
+
static void api_sprite(tic_mem* memory, const tic_tiles* src, s32 index, s32 x, s32 y, u8* colors, s32 count)
{
drawSprite(memory, src, index, x, y, colors, count, 1, tic_no_flip, tic_no_rotate);
diff --git a/src/tools.c b/src/tools.c
index 807f530..3b9f397 100644
--- a/src/tools.c
+++ b/src/tools.c
@@ -88,20 +88,20 @@ u32 tic_tool_find_closest_color(const tic_rgb* palette, const tic_rgb* color)
u32* tic_palette_blit(const tic_palette* srcpal)
{
- static u32 pal[TIC_PALETTE_SIZE] = {0};
-
- const u8* src = srcpal->data;
-
- memset(pal, 0xff, sizeof pal);
+ static u32 pal[TIC_PALETTE_SIZE];
+ const tic_rgb* src = srcpal->colors;
+ const tic_rgb* end = src + TIC_PALETTE_SIZE;
u8* dst = (u8*)pal;
- const u8* end = src + sizeof(tic_palette);
- enum{RGB = sizeof(tic_rgb)};
-
- for(; src != end; dst++, src+=RGB)
- for(s32 j = 0; j < RGB; j++)
- *dst++ = *(src+(RGB-1)-j);
+ while(src != end)
+ {
+ *dst++ = src->r;
+ *dst++ = src->g;
+ *dst++ = src->b;
+ *dst++ = 0xff;
+ src++;
+ }
return pal;
-}
\ No newline at end of file
+}