diff --git a/.gitignore b/.gitignore
index e5296e6..27f87e3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -95,3 +95,10 @@ build/windows/example/Release Pro/
build/windows/example/Debug Pro/
TIC80.sublime-project
TIC80.sublime-workspace
+build/windows/wren/Release/
+build/windows/wren/Debug/
+build/windows/wren/x64/
+build/uwp/wren/x64/
+build/uwp/wren/Release/
+build/uwp/wren/ARM/
+build/uwp/wren/Debug/
diff --git a/3rd-party b/3rd-party
index c3f37f4..b21ee19 160000
--- a/3rd-party
+++ b/3rd-party
@@ -1 +1 @@
-Subproject commit c3f37f4431282db7f1a99a89f90767fa20481a84
+Subproject commit b21ee19badc2c4f315df49ecbfc7830517b98955
diff --git a/Makefile b/Makefile
index 6a008f8..0411d4c 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,7 @@ INCLUDES= \
-I$(3RD_PARTY)/zlib-1.2.8 \
-I$(3RD_PARTY)/giflib-5.1.4/lib \
-I$(3RD_PARTY)/SDL2-2.0.7/include \
+ -I$(3RD_PARTY)/wren-0.1.0/src/include \
-I$(3RD_PARTY)/moonscript \
-I$(BLIPBUF_LIB) \
-I$(DUKTAPE_LIB) \
@@ -31,6 +32,7 @@ MINGW_LINKER_FLAGS= \
-lz \
-lgif \
-llua \
+ -lwren \
-lcomdlg32 \
-lws2_32 \
-mwindows
@@ -61,6 +63,7 @@ LINUX_LINKER_LTO_FLAGS= \
-D_GNU_SOURCE \
-lSDL2 \
-llua \
+ -lwren \
-lgif \
-ldl \
-lm \
@@ -71,6 +74,7 @@ LINUX_LINKER_LTO_FLAGS= \
LINUX_LINKER_FLAGS= \
-D_GNU_SOURCE \
-llua5.3 \
+ -lwren \
-ldl \
-lm \
-lpthread \
@@ -93,6 +97,7 @@ EMS_OPT= \
EMS_LINKER_FLAGS= \
-L$(PRE_BUILT)/emscripten \
-llua \
+ -lwren \
-lgif \
-lz
@@ -105,7 +110,7 @@ MACOSX_OPT= \
MACOSX_LIBS= \
-L$(PRE_BUILT)/macos \
-L/usr/local/lib \
- -lSDL2 -lm -liconv -lobjc -llua -lz -lgif \
+ -lSDL2 -lm -liconv -lobjc -llua -lwren -lz -lgif \
-Wl,-framework,CoreAudio \
-Wl,-framework,AudioToolbox \
-Wl,-framework,ForceFeedback \
@@ -159,6 +164,7 @@ DEMO_ASSETS= \
bin/assets/jsdemo.tic.dat \
bin/assets/luademo.tic.dat \
bin/assets/moondemo.tic.dat \
+ bin/assets/wrendemo.tic.dat \
bin/assets/benchmark.tic.dat \
bin/assets/config.tic.dat
@@ -286,16 +292,19 @@ bin/jsapi.o: src/jsapi.c $(TIC80_H)
bin/luaapi.o: src/luaapi.c $(TIC80_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
+bin/wrenapi.o: src/wrenapi.c $(TIC80_H)
+ $(CC) $< $(OPT) $(INCLUDES) -c -o $@
+
bin/duktape.o: $(DUKTAPE_LIB)/duktape.c $(TIC80_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
-TIC80_SRC = src/tic80.c src/tic.c $(BLIP_SRC) src/jsapi.c src/luaapi.c $(DUKTAPE_LIB)/duktape.c
-TIC80_O = bin/tic80.o bin/tic.o bin/tools.o bin/blip_buf.o bin/jsapi.o bin/luaapi.o bin/duktape.o bin/gif.o
+TIC80_SRC = src/tic80.c src/tic.c $(BLIP_SRC) src/jsapi.c src/luaapi.c src/wrenapi.c $(DUKTAPE_LIB)/duktape.c
+TIC80_O = bin/tic80.o bin/tic.o bin/tools.o bin/blip_buf.o bin/jsapi.o bin/luaapi.o bin/wrenapi.o bin/duktape.o bin/gif.o
TIC80_A = bin/libtic80.a
TIC80_DLL = bin/tic80.dll
$(TIC80_DLL): $(TIC80_O)
- $(CC) $(OPT) -shared $(TIC80_O) -L$(PRE_BUILT)/mingw -llua -lgif -Wl,--out-implib,$(TIC80_A) -o $@
+ $(CC) $(OPT) -shared $(TIC80_O) -L$(PRE_BUILT)/mingw -llua -lwren -lgif -Wl,--out-implib,$(TIC80_A) -o $@
emscripten:
$(EMS_CC) $(SOURCES) $(TIC80_SRC) $(OPT) $(INCLUDES) $(EMS_OPT) $(EMS_LINKER_FLAGS) -o build/html/tic.js
@@ -391,6 +400,9 @@ bin/assets/jsdemo.tic.dat: demos/jsdemo.tic
bin/assets/luademo.tic.dat: demos/luademo.tic
$(BIN2TXT) $< $@ -z
+bin/assets/wrendemo.tic.dat: demos/wrendemo.tic
+ $(BIN2TXT) $< $@ -z
+
bin/assets/moondemo.tic.dat: demos/moondemo.tic
$(BIN2TXT) $< $@ -z
diff --git a/bin/assets/wrendemo.tic.dat b/bin/assets/wrendemo.tic.dat
new file mode 100644
index 0000000..c6713cd
--- /dev/null
+++ b/bin/assets/wrendemo.tic.dat
@@ -0,0 +1 @@
+0x78, 0xda, 0x63, 0x5c, 0xc0, 0xc4, 0x40, 0x08, 0xfc, 0xfb, 0x0f, 0x04, 0x4a, 0x4a, 0x4a, 0xfd, 0x1d, 0x1d, 0x1d, 0xfd, 0x20, 0x1a, 0xc8, 0xed, 0xff, 0xff, 0x01, 0x8e, 0xff, 0xff, 0x7f, 0xff, 0x4e, 0x49, 0xe9, 0xff, 0xbb, 0x8e, 0x8e, 0x0f, 0xef, 0x94, 0x9a, 0x3e, 0xbc, 0xfb, 0xdf, 0xff, 0xe1, 0xff, 0x87, 0xfe, 0x0f, 0x1f, 0x60, 0x18, 0xbb, 0xfe, 0xff, 0x78, 0xf5, 0xff, 0x47, 0xd2, 0xcf, 0x30, 0x0a, 0x06, 0x14, 0x80, 0xe3, 0x0a, 0x14, 0x77, 0x60, 0xf8, 0x03, 0xcc, 0xd6, 0x07, 0xc6, 0xe3, 0x7f, 0x86, 0x0f, 0xff, 0x81, 0x71, 0xfb, 0xef, 0x7f, 0x3f, 0xc3, 0x7f, 0x60, 0xdc, 0xbd, 0xef, 0x07, 0xc6, 0x5f, 0x07, 0x14, 0x83, 0xe2, 0x93, 0xe1, 0xc3, 0xfb, 0x77, 0xff, 0xff, 0xbf, 0x7b, 0x47, 0xa9, 0x7e, 0xd6, 0x85, 0x8c, 0x0c, 0xfa, 0xfa, 0x0a, 0x25, 0x99, 0x25, 0x39, 0xa9, 0x56, 0x0a, 0x0a, 0xe9, 0x89, 0xb9, 0xa9, 0x10, 0x0e, 0x17, 0x50, 0x34, 0xb1, 0xb4, 0x24, 0x23, 0xbf, 0xc8, 0x0a, 0x22, 0x9a, 0x92, 0x5a, 0x96, 0x9a, 0x93, 0x5f, 0x90, 0x5a, 0x04, 0x92, 0x49, 0x49, 0x2d, 0x4e, 0x06, 0x2a, 0x57, 0x28, 0x06, 0xca, 0x97, 0x80, 0x79, 0x45, 0x99, 0x05, 0x25, 0x99, 0xf9, 0x79, 0x20, 0x49, 0x08, 0xc7, 0x4a, 0xa1, 0xbc, 0x28, 0x35, 0x8f, 0x8b, 0x2b, 0x39, 0x27, 0xb1, 0xb8, 0x58, 0xc1, 0x1d, 0x64, 0x44, 0x66, 0xb1, 0x42, 0x88, 0xa7, 0x73, 0x35, 0x17, 0x17, 0x67, 0x72, 0x7e, 0x5e, 0x71, 0x49, 0x51, 0x69, 0x72, 0x89, 0x42, 0x5e, 0x6a, 0xb9, 0x86, 0x66, 0x35, 0x17, 0x27, 0x67, 0x7c, 0x89, 0xad, 0x01, 0x88, 0xaa, 0xb0, 0xb5, 0x34, 0x03, 0xd1, 0x95, 0xb6, 0x46, 0x26, 0x5c, 0x9c, 0xb5, 0x5c, 0x9c, 0x5c, 0x9c, 0x40, 0x4d, 0x10, 0x35, 0x99, 0x69, 0x1a, 0x40, 0xb6, 0x5e, 0x52, 0x49, 0x9e, 0x86, 0x81, 0x26, 0x58, 0x04, 0xa4, 0x2e, 0xbe, 0x52, 0xd7, 0x10, 0xc8, 0xac, 0x45, 0x55, 0x60, 0x88, 0xac, 0x40, 0x1b, 0x8b, 0x02, 0x23, 0x98, 0x82, 0x0a, 0xdb, 0xf8, 0x0a, 0x6c, 0x26, 0x18, 0x23, 0x2b, 0x80, 0x9b, 0x00, 0x44, 0x20, 0x05, 0xc9, 0x39, 0xc5, 0x1a, 0x86, 0xc6, 0x9a, 0x50, 0x5e, 0x71, 0x41, 0x91, 0x86, 0xa1, 0xb6, 0x86, 0x46, 0x7c, 0x89, 0xaa, 0x99, 0x81, 0xa6, 0xbe, 0xb1, 0x41, 0x8d, 0x81, 0xa6, 0x96, 0x91, 0x4e, 0x7c, 0x85, 0x4e, 0x7c, 0xa5, 0x8e, 0xa1, 0x89, 0x8e, 0xb1, 0x8e, 0x01, 0x10, 0x1a, 0xe9, 0x18, 0xc1, 0x34, 0x14, 0x14, 0x65, 0xe6, 0x95, 0x68, 0x28, 0x79, 0xb8, 0xfa, 0xf8, 0xf8, 0x2b, 0x84, 0xfb, 0x07, 0xf9, 0xb8, 0x28, 0x2a, 0xe9, 0x58, 0x98, 0x00, 0x91, 0x26, 0xc4, 0x0e, 0x60, 0x70, 0xc4, 0x97, 0x80, 0x2c, 0xad, 0xe5, 0xaa, 0xe5, 0xb4, 0xa3, 0x2c, 0x91, 0x31, 0xb3, 0x70, 0x19, 0x40, 0x58, 0xa0, 0xd2, 0x02, 0x46, 0x0b, 0x18, 0x85, 0x94, 0xcd, 0xd8, 0x75, 0xe7, 0xdf, 0xfb, 0xb3, 0xab, 0x3b, 0xd3, 0x5d, 0x95, 0x19, 0x61, 0x7c, 0x18, 0xcd, 0x03, 0xd4, 0x23, 0xc2, 0x23, 0xe3, 0xa2, 0x62, 0x62, 0x60, 0x92, 0xeb, 0xe7, 0xe5, 0xd7, 0xea, 0x63, 0x60, 0x92, 0xaa, 0x72, 0xc1, 0xcd, 0xa3, 0xb4, 0x30, 0x31, 0xb2, 0xf6, 0xdc, 0xa5, 0x5a, 0x9d, 0xd6, 0xa9, 0x0b, 0x73, 0x57, 0xe9, 0x5c, 0x5a, 0x35, 0x33, 0xf7, 0xd0, 0xa9, 0x5b, 0x57, 0xe2, 0xee, 0xbd, 0xbb, 0x06, 0x00, 0xb4, 0xc0, 0x51, 0xda,
\ No newline at end of file
diff --git a/build/android/jni/src/Android.mk b/build/android/jni/src/Android.mk
index 6b456a1..a73a590 100644
--- a/build/android/jni/src/Android.mk
+++ b/build/android/jni/src/Android.mk
@@ -16,6 +16,7 @@ LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/$(THIRD_PARTY_PATH)/blip-buf \
$(LOCAL_PATH)/$(THIRD_PARTY_PATH)/SDL2_net-2.0.1 \
$(LOCAL_PATH)/$(THIRD_PARTY_PATH)/moonscript \
+ $(LOCAL_PATH)/$(THIRD_PARTY_PATH)/wren-0.1.0\src\include \
$(LOCAL_PATH)/../../../../include
# Add your application source files here...
@@ -46,13 +47,14 @@ LOCAL_SRC_FILES := \
$(SRC_PATH)/net.c \
$(SRC_PATH)/luaapi.c \
$(SRC_PATH)/jsapi.c \
+ $(SRC_PATH)/wrenapi.c \
$(SRC_PATH)/tic.c \
$(SRC_PATH)/dialog.c \
$(SRC_PATH)/menu.c \
$(SRC_PATH)/surf.c \
$(SRC_PATH)/tic80.c
-LOCAL_SHARED_LIBRARIES := SDL2 lua z gif
+LOCAL_SHARED_LIBRARIES := SDL2 lua z gif wren
LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog
diff --git a/build/android/jni/wren/Android.mk b/build/android/jni/wren/Android.mk
new file mode 100644
index 0000000..1e101a6
--- /dev/null
+++ b/build/android/jni/wren/Android.mk
@@ -0,0 +1,6 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := wren
+LOCAL_SRC_FILES := ../../../../3rd-party/pre-built/android/wren/$(TARGET_ARCH_ABI)/libwren.so
+include $(PREBUILT_SHARED_LIBRARY)
diff --git a/build/android/src/com/nesbox/tic/TIC.java b/build/android/src/com/nesbox/tic/TIC.java
index 35723d8..7320c68 100644
--- a/build/android/src/com/nesbox/tic/TIC.java
+++ b/build/android/src/com/nesbox/tic/TIC.java
@@ -13,6 +13,7 @@ public class TIC extends SDLActivity
return new String[] {
"SDL2",
"lua",
+ "wren",
"z",
"gif",
"main"
diff --git a/build/uwp/tic/tic.sln b/build/uwp/tic/tic.sln
index dc4ac55..acd7e65 100644
--- a/build/uwp/tic/tic.sln
+++ b/build/uwp/tic/tic.sln
@@ -15,6 +15,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2-UWP", "..\..\..\3rd-pa
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib-uwp", "..\..\..\3rd-party\zlib-1.2.8\winrt\zlib-uwp\zlib-uwp.vcxproj", "{978F53DB-F959-4CB4-84A7-463AF29949BE}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wren", "..\wren\wren.vcxproj", "{BBB0D01A-B124-416C-BE26-E6993154A555}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
@@ -103,6 +105,18 @@ Global
{978F53DB-F959-4CB4-84A7-463AF29949BE}.Release|x64.Build.0 = Release|x64
{978F53DB-F959-4CB4-84A7-463AF29949BE}.Release|x86.ActiveCfg = Release|Win32
{978F53DB-F959-4CB4-84A7-463AF29949BE}.Release|x86.Build.0 = Release|Win32
+ {BBB0D01A-B124-416C-BE26-E6993154A555}.Debug|ARM.ActiveCfg = Debug|ARM
+ {BBB0D01A-B124-416C-BE26-E6993154A555}.Debug|ARM.Build.0 = Debug|ARM
+ {BBB0D01A-B124-416C-BE26-E6993154A555}.Debug|x64.ActiveCfg = Debug|x64
+ {BBB0D01A-B124-416C-BE26-E6993154A555}.Debug|x64.Build.0 = Debug|x64
+ {BBB0D01A-B124-416C-BE26-E6993154A555}.Debug|x86.ActiveCfg = Debug|Win32
+ {BBB0D01A-B124-416C-BE26-E6993154A555}.Debug|x86.Build.0 = Debug|Win32
+ {BBB0D01A-B124-416C-BE26-E6993154A555}.Release|ARM.ActiveCfg = Release|ARM
+ {BBB0D01A-B124-416C-BE26-E6993154A555}.Release|ARM.Build.0 = Release|ARM
+ {BBB0D01A-B124-416C-BE26-E6993154A555}.Release|x64.ActiveCfg = Release|x64
+ {BBB0D01A-B124-416C-BE26-E6993154A555}.Release|x64.Build.0 = Release|x64
+ {BBB0D01A-B124-416C-BE26-E6993154A555}.Release|x86.ActiveCfg = Release|Win32
+ {BBB0D01A-B124-416C-BE26-E6993154A555}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/build/uwp/tic/tic.vcxproj.user b/build/uwp/tic/tic.vcxproj.user
index 92e604f..2eac851 100644
--- a/build/uwp/tic/tic.vcxproj.user
+++ b/build/uwp/tic/tic.vcxproj.user
@@ -15,7 +15,7 @@
XboxOne
- UWPRemoteDebugger
+ AppHostLocalDebugger
XboxOne
diff --git a/build/uwp/tic80/tic80.vcxproj b/build/uwp/tic80/tic80.vcxproj
index a020cad..344f5e0 100644
--- a/build/uwp/tic80/tic80.vcxproj
+++ b/build/uwp/tic80/tic80.vcxproj
@@ -35,6 +35,7 @@
+
@@ -43,6 +44,9 @@
{53802f21-41da-4ac1-8b62-0dac2ccb8af8}
+
+ {bbb0d01a-b124-416c-be26-e6993154a555}
+
{9c39acf1-5f52-4a2b-a467-9f2805d6174b}
@@ -143,7 +147,7 @@
NotUsing
false
- ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+ ..\..\..\include;..\..\..\3rd-party\wren-0.1.0\src\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
LUA_COMPAT_5_2;_CRT_SECURE_NO_WARNINGS;TIC80_SHARED;_WINDLL;%(PreprocessorDefinitions)
false
@@ -159,7 +163,7 @@
NotUsing
false
- ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+ ..\..\..\include;..\..\..\3rd-party\wren-0.1.0\src\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
LUA_COMPAT_5_2;_CRT_SECURE_NO_WARNINGS;TIC80_SHARED;_WINDLL;%(PreprocessorDefinitions)
false
@@ -175,7 +179,7 @@
NotUsing
false
- ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+ ..\..\..\include;..\..\..\3rd-party\wren-0.1.0\src\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
LUA_COMPAT_5_2;_CRT_SECURE_NO_WARNINGS;TIC80_SHARED;_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions)
false
@@ -191,7 +195,7 @@
NotUsing
false
- ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+ ..\..\..\include;..\..\..\3rd-party\wren-0.1.0\src\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
LUA_COMPAT_5_2;_CRT_SECURE_NO_WARNINGS;TIC80_SHARED;_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions)
false
@@ -207,7 +211,7 @@
NotUsing
false
- ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+ ..\..\..\include;..\..\..\3rd-party\wren-0.1.0\src\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
LUA_COMPAT_5_2;_CRT_SECURE_NO_WARNINGS;TIC80_SHARED;_WINDLL;%(PreprocessorDefinitions)
false
@@ -223,7 +227,7 @@
NotUsing
false
- ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+ ..\..\..\include;..\..\..\3rd-party\wren-0.1.0\src\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
LUA_COMPAT_5_2;_CRT_SECURE_NO_WARNINGS;TIC80_SHARED;_WINDLL;%(PreprocessorDefinitions)
false
diff --git a/build/uwp/tic80/tic80.vcxproj.filters b/build/uwp/tic80/tic80.vcxproj.filters
index 2dc1824..ef8abed 100644
--- a/build/uwp/tic80/tic80.vcxproj.filters
+++ b/build/uwp/tic80/tic80.vcxproj.filters
@@ -36,5 +36,8 @@
src\ext
+
+ src
+
\ No newline at end of file
diff --git a/build/uwp/wren/wren.vcxproj b/build/uwp/wren/wren.vcxproj
new file mode 100644
index 0000000..901b188
--- /dev/null
+++ b/build/uwp/wren/wren.vcxproj
@@ -0,0 +1,210 @@
+
+
+
+
+ Debug
+ ARM
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ ARM
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {bbb0d01a-b124-416c-be26-e6993154a555}
+ StaticLibrary
+ wren
+ 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\wren-0.1.0\src\include;..\..\..\3rd-party\wren-0.1.0\src\optional;..\..\..\3rd-party\wren-0.1.0\src\vm;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+
+
+ Console
+ false
+ false
+
+
+
+
+ NotUsing
+ false
+ false
+ ..\..\..\3rd-party\wren-0.1.0\src\include;..\..\..\3rd-party\wren-0.1.0\src\optional;..\..\..\3rd-party\wren-0.1.0\src\vm;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+
+
+ Console
+ false
+ false
+
+
+
+
+ NotUsing
+ false
+ false
+ ..\..\..\3rd-party\wren-0.1.0\src\include;..\..\..\3rd-party\wren-0.1.0\src\optional;..\..\..\3rd-party\wren-0.1.0\src\vm;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+
+
+ Console
+ false
+ false
+
+
+
+
+ NotUsing
+ false
+ false
+ ..\..\..\3rd-party\wren-0.1.0\src\include;..\..\..\3rd-party\wren-0.1.0\src\optional;..\..\..\3rd-party\wren-0.1.0\src\vm;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+
+
+ Console
+ false
+ false
+
+
+
+
+ NotUsing
+ false
+ false
+ ..\..\..\3rd-party\wren-0.1.0\src\include;..\..\..\3rd-party\wren-0.1.0\src\optional;..\..\..\3rd-party\wren-0.1.0\src\vm;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+
+
+ Console
+ false
+ false
+
+
+
+
+ NotUsing
+ false
+ false
+ ..\..\..\3rd-party\wren-0.1.0\src\include;..\..\..\3rd-party\wren-0.1.0\src\optional;..\..\..\3rd-party\wren-0.1.0\src\vm;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)
+
+
+ Console
+ false
+ false
+
+
+
+
+
+
\ No newline at end of file
diff --git a/build/uwp/wren/wren.vcxproj.filters b/build/uwp/wren/wren.vcxproj.filters
new file mode 100644
index 0000000..360f98c
--- /dev/null
+++ b/build/uwp/wren/wren.vcxproj.filters
@@ -0,0 +1,43 @@
+
+
+
+
+ {7ad0ea3c-f232-4a85-aa42-acd2fd0f1d6b}
+
+
+ {530552c5-b8aa-496d-8bd6-255dc647f6b8}
+
+
+ {9e502f35-bbe6-4594-980c-c1645d31225e}
+
+
+
+
+ src\vm
+
+
+ src\vm
+
+
+ src\vm
+
+
+ src\vm
+
+
+ src\vm
+
+
+ src\vm
+
+
+ src\vm
+
+
+ src\optional
+
+
+ src\optional
+
+
+
\ No newline at end of file
diff --git a/build/windows/example/example.vcxproj b/build/windows/example/example.vcxproj
index 8982b6b..ab0a909 100644
--- a/build/windows/example/example.vcxproj
+++ b/build/windows/example/example.vcxproj
@@ -1,5 +1,5 @@
-
+
Debug Pro
@@ -58,52 +58,52 @@
Application
true
- v140
+ v140_xp
Unicode
Application
true
- v140
+ v140_xp
Unicode
Application
false
- v140
+ v140_xp
true
Unicode
Application
false
- v140
+ v140_xp
true
Unicode
Application
true
- v140
+ v140_xp
Unicode
Application
true
- v140
+ v140_xp
Unicode
Application
false
- v140
+ v140_xp
true
Unicode
Application
false
- v140
+ v140_xp
true
Unicode
diff --git a/build/windows/lua/lua.vcxproj.user b/build/windows/lua/lua.vcxproj.user
new file mode 100644
index 0000000..be25078
--- /dev/null
+++ b/build/windows/lua/lua.vcxproj.user
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/build/windows/tic/tic.sln b/build/windows/tic/tic.sln
index 6e45ff4..8fa78d5 100644
--- a/build/windows/tic/tic.sln
+++ b/build/windows/tic/tic.sln
@@ -1,9 +1,12 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.25420.1
+# Visual Studio 15
+VisualStudioVersion = 15.0.27130.2024
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tic", "tic.vcxproj", "{B6ECC66E-26FA-42C2-8F6C-E4338424F38A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {D7CC5189-C399-AC94-ECB2-9A3CD8DEE122} = {D7CC5189-C399-AC94-ECB2-9A3CD8DEE122}
+ EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua", "..\lua\lua.vcxproj", "{57D2471B-3138-495E-AF18-6E290D098FFC}"
EndProject
@@ -12,6 +15,9 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gif", "..\gif\gif.vcxproj", "{6EA9D998-7557-4AED-ABFC-142F9960C9B6}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tic80", "..\tic80\tic80.vcxproj", "{C4D8BC10-EBF6-42BB-9B5D-6712FB428A50}"
+ ProjectSection(ProjectDependencies) = postProject
+ {D7CC5189-C399-AC94-ECB2-9A3CD8DEE122} = {D7CC5189-C399-AC94-ECB2-9A3CD8DEE122}
+ EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example", "..\example\example.vcxproj", "{86CAA9C1-C61A-40D8-AC77-33D94754C824}"
EndProject
@@ -19,6 +25,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2", "..\..\..\3rd-party\
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2main", "..\..\..\3rd-party\SDL2-2.0.7\VisualC\SDLmain\SDLmain.vcxproj", "{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wren_lib", "..\wren\wren_lib.vcxproj", "{D7CC5189-C399-AC94-ECB2-9A3CD8DEE122}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug Pro|x64 = Debug Pro|x64
@@ -159,8 +167,27 @@ Global
{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|x64.Build.0 = Release|x64
{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|x86.ActiveCfg = Release|Win32
{DA956FD3-E142-46F2-9DD5-C78BEBB56B7A}.Release|x86.Build.0 = Release|Win32
+ {D7CC5189-C399-AC94-ECB2-9A3CD8DEE122}.Debug Pro|x64.ActiveCfg = Debug|x64
+ {D7CC5189-C399-AC94-ECB2-9A3CD8DEE122}.Debug Pro|x64.Build.0 = Debug|x64
+ {D7CC5189-C399-AC94-ECB2-9A3CD8DEE122}.Debug Pro|x86.ActiveCfg = Debug|Win32
+ {D7CC5189-C399-AC94-ECB2-9A3CD8DEE122}.Debug Pro|x86.Build.0 = Debug|Win32
+ {D7CC5189-C399-AC94-ECB2-9A3CD8DEE122}.Debug|x64.ActiveCfg = Debug|x64
+ {D7CC5189-C399-AC94-ECB2-9A3CD8DEE122}.Debug|x64.Build.0 = Debug|x64
+ {D7CC5189-C399-AC94-ECB2-9A3CD8DEE122}.Debug|x86.ActiveCfg = Debug|Win32
+ {D7CC5189-C399-AC94-ECB2-9A3CD8DEE122}.Debug|x86.Build.0 = Debug|Win32
+ {D7CC5189-C399-AC94-ECB2-9A3CD8DEE122}.Release Pro|x64.ActiveCfg = Release|x64
+ {D7CC5189-C399-AC94-ECB2-9A3CD8DEE122}.Release Pro|x64.Build.0 = Release|x64
+ {D7CC5189-C399-AC94-ECB2-9A3CD8DEE122}.Release Pro|x86.ActiveCfg = Release|Win32
+ {D7CC5189-C399-AC94-ECB2-9A3CD8DEE122}.Release Pro|x86.Build.0 = Release|Win32
+ {D7CC5189-C399-AC94-ECB2-9A3CD8DEE122}.Release|x64.ActiveCfg = Release|x64
+ {D7CC5189-C399-AC94-ECB2-9A3CD8DEE122}.Release|x64.Build.0 = Release|x64
+ {D7CC5189-C399-AC94-ECB2-9A3CD8DEE122}.Release|x86.ActiveCfg = Release|Win32
+ {D7CC5189-C399-AC94-ECB2-9A3CD8DEE122}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {00596857-9AA6-41D1-915F-305DA18C13AE}
+ EndGlobalSection
EndGlobal
diff --git a/build/windows/tic/tic.vcxproj b/build/windows/tic/tic.vcxproj
index 72fd65b..80dfa79 100644
--- a/build/windows/tic/tic.vcxproj
+++ b/build/windows/tic/tic.vcxproj
@@ -211,7 +211,7 @@
Disabled
_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_5_2;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
MultiThreadedDebug
- ..\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\SDL2_net-2.0.1
+ ..\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\SDL2_net-2.0.1;..\..\..\3rd-party\wren-0.1.0\src\include
Windows
@@ -228,7 +228,7 @@
Disabled
TIC80_PRO;_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_5_2;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
MultiThreadedDebug
- ..\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\SDL2_net-2.0.1
+ ..\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\SDL2_net-2.0.1;..\..\..\3rd-party\wren-0.1.0\src\include
Windows
@@ -245,7 +245,7 @@
Disabled
_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_5_2;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
MultiThreadedDebug
- ..\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\SDL2_net-2.0.1
+ ..\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\SDL2_net-2.0.1;..\..\..\3rd-party\wren-0.1.0\src\include
Windows
@@ -262,7 +262,7 @@
Disabled
TIC80_PRO;_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_5_2;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
MultiThreadedDebug
- ..\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\SDL2_net-2.0.1
+ ..\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\SDL2_net-2.0.1;..\..\..\3rd-party\wren-0.1.0\src\include
Windows
@@ -281,7 +281,7 @@
true
_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_5_2;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
MultiThreaded
- ..\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\SDL2_net-2.0.1
+ ..\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\SDL2_net-2.0.1;..\..\..\3rd-party\wren-0.1.0\src\include
Windows
@@ -302,7 +302,7 @@
true
TIC80_PRO;_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_5_2;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
MultiThreaded
- ..\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\SDL2_net-2.0.1
+ ..\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\SDL2_net-2.0.1;..\..\..\3rd-party\wren-0.1.0\src\include
Windows
@@ -323,7 +323,7 @@
true
_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_5_2;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
MultiThreaded
- ..\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\SDL2_net-2.0.1
+ ..\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\SDL2_net-2.0.1;..\..\..\3rd-party\wren-0.1.0\src\include
Windows
@@ -344,7 +344,7 @@
true
TIC80_PRO;_CRT_SECURE_NO_WARNINGS;LUA_COMPAT_5_2;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
MultiThreaded
- ..\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\SDL2_net-2.0.1
+ ..\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\SDL2_net-2.0.1;..\..\..\3rd-party\wren-0.1.0\src\include
Windows
diff --git a/build/windows/tic80/tic80.vcxproj b/build/windows/tic80/tic80.vcxproj
index a0cc0e2..ddfff3b 100644
--- a/build/windows/tic80/tic80.vcxproj
+++ b/build/windows/tic80/tic80.vcxproj
@@ -43,6 +43,7 @@
+
@@ -51,6 +52,9 @@
{57d2471b-3138-495e-af18-6e290d098ffc}
+
+ {d7cc5189-c399-ac94-ecb2-9a3cd8dee122}
+
{C4D8BC10-EBF6-42BB-9B5D-6712FB428A50}
@@ -172,7 +176,7 @@
Level3
Disabled
WIN32;_DEBUG;_WINDOWS;_USRDLL;TIC80_EXPORTS;%(PreprocessorDefinitions)
- ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript
+ ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript;..\..\..\3rd-party\wren-0.1.0\src\include
MultiThreadedDebug
@@ -187,7 +191,7 @@
Level3
Disabled
TIC80_PRO;WIN32;_DEBUG;_WINDOWS;_USRDLL;TIC80_EXPORTS;%(PreprocessorDefinitions)
- ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript
+ ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript;..\..\..\3rd-party\wren-0.1.0\src\include
MultiThreadedDebug
@@ -202,7 +206,7 @@
Level3
Disabled
_DEBUG;_WINDOWS;_USRDLL;TIC80_EXPORTS;%(PreprocessorDefinitions)
- ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript
+ ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript;..\..\..\3rd-party\wren-0.1.0\src\include
MultiThreadedDebug
@@ -217,7 +221,7 @@
Level3
Disabled
TIC80_PRO;_DEBUG;_WINDOWS;_USRDLL;TIC80_EXPORTS;%(PreprocessorDefinitions)
- ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript
+ ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript;..\..\..\3rd-party\wren-0.1.0\src\include
MultiThreadedDebug
@@ -234,7 +238,7 @@
true
true
WIN32;NDEBUG;_WINDOWS;_USRDLL;TIC80_EXPORTS;%(PreprocessorDefinitions)
- ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript
+ ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript;..\..\..\3rd-party\wren-0.1.0\src\include
MultiThreaded
@@ -253,7 +257,7 @@
true
true
TIC80_PRO;WIN32;NDEBUG;_WINDOWS;_USRDLL;TIC80_EXPORTS;%(PreprocessorDefinitions)
- ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript
+ ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript;..\..\..\3rd-party\wren-0.1.0\src\include
MultiThreaded
@@ -272,7 +276,7 @@
true
true
NDEBUG;_WINDOWS;_USRDLL;TIC80_EXPORTS;%(PreprocessorDefinitions)
- ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript
+ ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript;..\..\..\3rd-party\wren-0.1.0\src\include
MultiThreaded
@@ -291,7 +295,7 @@
true
true
TIC80_PRO;NDEBUG;_WINDOWS;_USRDLL;TIC80_EXPORTS;%(PreprocessorDefinitions)
- ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript
+ ..\..\..\include;..\..\..\3rd-party\lua-5.3.1\src;..\..\..\3rd-party\giflib-5.1.4\lib;..\..\..\3rd-party\duktape-2.2.0\src;..\..\..\3rd-party\blip-buf;..\..\..\3rd-party\moonscript;..\..\..\3rd-party\wren-0.1.0\src\include
MultiThreaded
diff --git a/build/windows/tic80/tic80.vcxproj.filters b/build/windows/tic80/tic80.vcxproj.filters
index 4f9b12f..b2f865e 100644
--- a/build/windows/tic80/tic80.vcxproj.filters
+++ b/build/windows/tic80/tic80.vcxproj.filters
@@ -36,5 +36,8 @@
src\ext
+
+ src
+
\ No newline at end of file
diff --git a/build/windows/tic80/tic80.vcxproj.user b/build/windows/tic80/tic80.vcxproj.user
new file mode 100644
index 0000000..be25078
--- /dev/null
+++ b/build/windows/tic80/tic80.vcxproj.user
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/build/windows/wren/wren_lib.vcxproj b/build/windows/wren/wren_lib.vcxproj
new file mode 100644
index 0000000..edeb00b
--- /dev/null
+++ b/build/windows/wren/wren_lib.vcxproj
@@ -0,0 +1,194 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {D7CC5189-C399-AC94-ECB2-9A3CD8DEE122}
+ true
+ Win32Proj
+ wren_lib
+ 8.1
+
+
+
+ StaticLibrary
+ true
+ MultiByte
+ v140_xp
+
+
+ StaticLibrary
+ true
+ MultiByte
+ v140_xp
+
+
+ StaticLibrary
+ false
+ MultiByte
+ v140_xp
+ true
+
+
+ StaticLibrary
+ false
+ MultiByte
+ v140_xp
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(SolutionDir)$(Configuration)\
+ $(Configuration)\
+ $(ProjectName)
+ .lib
+
+
+ $(SolutionDir)$(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
+ $(ProjectName)
+ .lib
+
+
+ $(SolutionDir)$(Configuration)\
+ $(Configuration)\
+ $(ProjectName)
+ .lib
+
+
+ $(SolutionDir)$(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\
+ $(ProjectName)
+ .lib
+
+
+
+ NotUsing
+ Level3
+ _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+ ..\..\..\3rd-party\wren-0.1.0\src\include;..\..\..\3rd-party\wren-0.1.0\src\vm;..\..\..\3rd-party\wren-0.1.0\src\optional;%(AdditionalIncludeDirectories)
+ EditAndContinue
+ Disabled
+ CompileAsC
+ MultiThreadedDebug
+
+
+ Windows
+ true
+
+
+
+
+ NotUsing
+ Level3
+ _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+ ..\..\..\3rd-party\wren-0.1.0\src\include;..\..\..\3rd-party\wren-0.1.0\src\vm;..\..\..\3rd-party\wren-0.1.0\src\optional;%(AdditionalIncludeDirectories)
+ EditAndContinue
+ Disabled
+ CompileAsC
+ MultiThreadedDebug
+
+
+ Windows
+ true
+
+
+
+
+ NotUsing
+ Level3
+ NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+ ..\..\..\3rd-party\wren-0.1.0\src\include;..\..\..\3rd-party\wren-0.1.0\src\vm;..\..\..\3rd-party\wren-0.1.0\src\optional;%(AdditionalIncludeDirectories)
+ Full
+ true
+ true
+ false
+ true
+ CompileAsC
+ MultiThreaded
+
+
+ Windows
+ true
+ true
+
+
+
+
+ NotUsing
+ Level3
+ NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+ ..\..\..\3rd-party\wren-0.1.0\src\include;..\..\..\3rd-party\wren-0.1.0\src\vm;..\..\..\3rd-party\wren-0.1.0\src\optional;%(AdditionalIncludeDirectories)
+ Full
+ true
+ true
+ false
+ true
+ CompileAsC
+ MultiThreaded
+
+
+ Windows
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/build/windows/wren/wren_lib.vcxproj.filters b/build/windows/wren/wren_lib.vcxproj.filters
new file mode 100644
index 0000000..f90565f
--- /dev/null
+++ b/build/windows/wren/wren_lib.vcxproj.filters
@@ -0,0 +1,75 @@
+
+
+
+
+ {CB60FAAF-B72D-55BB-E046-4363CC728A49}
+
+
+ {E8795900-D405-880B-3DB4-880B295F880B}
+
+
+
+
+ optional
+
+
+ optional
+
+
+ vm
+
+
+ vm
+
+
+ vm
+
+
+ vm
+
+
+ vm
+
+
+ vm
+
+
+ vm
+
+
+ vm
+
+
+ vm
+
+
+
+
+ optional
+
+
+ optional
+
+
+ vm
+
+
+ vm
+
+
+ vm
+
+
+ vm
+
+
+ vm
+
+
+ vm
+
+
+ vm
+
+
+
\ No newline at end of file
diff --git a/build/windows/wren/wren_lib.vcxproj.user b/build/windows/wren/wren_lib.vcxproj.user
new file mode 100644
index 0000000..be25078
--- /dev/null
+++ b/build/windows/wren/wren_lib.vcxproj.user
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/demos/wrendemo.tic b/demos/wrendemo.tic
new file mode 100644
index 0000000..71ceee3
Binary files /dev/null and b/demos/wrendemo.tic differ
diff --git a/src/console.c b/src/console.c
index 40ffc08..c81e722 100644
--- a/src/console.c
+++ b/src/console.c
@@ -46,6 +46,7 @@ typedef enum
LuaScript,
MoonScript,
JavaScript,
+ WrenScript,
} ScriptLang;
#if defined(__WINDOWS__) || defined(__LINUX__) || defined(__MACOSX__)
@@ -73,6 +74,7 @@ static const char* ExeExt = ".exe";
static const char DefaultLuaTicPath[] = TIC_LOCAL "default.tic";
static const char DefaultMoonTicPath[] = TIC_LOCAL "default_moon.tic";
static const char DefaultJSTicPath[] = TIC_LOCAL "default_js.tic";
+static const char DefaultWrenTicPath[] = TIC_LOCAL "default_wren.tic";
static const char* getName(const char* name, const char* ext)
{
@@ -417,7 +419,10 @@ static void* getDemoCart(Console* console, ScriptLang script, s32* size)
strcpy(path, DefaultMoonTicPath);
break;
case JavaScript:
- strcpy(path, DefaultJSTicPath);
+ strcpy(path, DefaultJSTicPath);
+ break;
+ case WrenScript:
+ strcpy(path, DefaultWrenTicPath);
break;
}
@@ -442,6 +447,11 @@ static void* getDemoCart(Console* console, ScriptLang script, s32* size)
#include "../bin/assets/moondemo.tic.dat"
};
+ static const u8 WrenDemoRom[] =
+ {
+ #include "../bin/assets/wrendemo.tic.dat"
+ };
+
const u8* demo = NULL;
s32 romSize = 0;
@@ -459,6 +469,10 @@ static void* getDemoCart(Console* console, ScriptLang script, s32* size)
demo = JsDemoRom;
romSize = sizeof JsDemoRom;
break;
+ case WrenScript:
+ demo = WrenDemoRom;
+ romSize = sizeof WrenDemoRom;
+ break;
}
u8* data = NULL;
@@ -491,6 +505,8 @@ static void onConsoleLoadDemoCommandConfirmed(Console* console, const char* para
data = getDemoCart(console, MoonScript, &size);
else if(strcmp(param, DefaultJSTicPath) == 0)
data = getDemoCart(console, JavaScript, &size);
+ else if(strcmp(param, DefaultWrenTicPath) == 0)
+ data = getDemoCart(console, WrenScript, &size);
const char* name = getCartName(param);
@@ -530,12 +546,12 @@ static bool hasExt(const char* name, const char* ext)
static bool hasProjectExt(const char* name)
{
- return hasExt(name, PROJECT_LUA_EXT) || hasExt(name, PROJECT_MOON_EXT) || hasExt(name, PROJECT_JS_EXT);
+ return hasExt(name, PROJECT_LUA_EXT) || hasExt(name, PROJECT_MOON_EXT) || hasExt(name, PROJECT_JS_EXT) || hasExt(name, PROJECT_WREN_EXT);
}
static const char* projectComment(const char* name)
{
- return hasExt(name, PROJECT_JS_EXT) ? "//" : "--";
+ return hasExt(name, PROJECT_JS_EXT) || hasExt(name, PROJECT_WREN_EXT) ? "//" : "--";
}
static void buf2str(const void* data, s32 size, char* ptr, bool flip)
@@ -925,6 +941,9 @@ static void onConsoleLoadCommandConfirmed(Console* console, const char* param)
if(!fsExistsFile(console->fs, name))
name = getName(param, PROJECT_JS_EXT);
+ if(!fsExistsFile(console->fs, name))
+ name = getName(param, PROJECT_WREN_EXT);
+
void* data = fsLoadFile(console->fs, name, &size);
if(data)
@@ -1053,6 +1072,8 @@ static void onConsoleNewCommandConfirmed(Console* console, const char* param)
loadDemo(console, MoonScript);
else if(strcmp(param, "js") == 0 || strcmp(param, "javascript") == 0)
loadDemo(console, JavaScript);
+ else if(strcmp(param, "wren") == 0)
+ loadDemo(console, WrenScript);
else
{
printError(console, "\nunknown parameter: ");
@@ -1317,6 +1338,10 @@ static void onConsoleConfigCommand(Console* console, const char* param)
{
onConsoleLoadDemoCommand(console, DefaultJSTicPath);
}
+ else if(strcmp(param, "default wren") == 0)
+ {
+ onConsoleLoadDemoCommand(console, DefaultWrenTicPath);
+ }
else
{
printError(console, "\nunknown parameter: ");
diff --git a/src/machine.h b/src/machine.h
index b2c073b..4c226f5 100644
--- a/src/machine.h
+++ b/src/machine.h
@@ -28,7 +28,11 @@
#define SFX_DEF_SPEED (1 << SFX_SPEED_BITS)
-#define API_KEYWORDS {"TIC", "SCN", "OVR", "print", "cls", "pix", "line", "rect", "rectb", \
+#define TIC_FN "TIC"
+#define SCN_FN "SCN"
+#define OVR_FN "OVR"
+
+#define API_KEYWORDS {TIC_FN, SCN_FN, OVR_FN, "print", "cls", "pix", "line", "rect", "rectb", \
"spr", "btn", "btnp", "sfx", "map", "mget", "mset", "peek", "poke", "peek4", "poke4", \
"memcpy", "memset", "trace", "pmem", "time", "exit", "font", "mouse", "circ", "circb", "tri", "textri", \
"clip", "music", "sync", "reset", "key", "keyp"}
@@ -121,6 +125,7 @@ typedef struct
{
struct duk_hthread* js;
struct lua_State* lua;
+ struct WrenVM* wren;
};
blip_buffer_t* blip;
@@ -159,3 +164,4 @@ void parseCode(const tic_script_config* config, const char* start, u8* color, co
const tic_script_config* getLuaScriptConfig();
const tic_script_config* getMoonScriptConfig();
const tic_script_config* getJsScriptConfig();
+const tic_script_config* getWrenScriptConfig();
diff --git a/src/studio.h b/src/studio.h
index 2e870a7..a49336e 100644
--- a/src/studio.h
+++ b/src/studio.h
@@ -64,6 +64,7 @@
#define PROJECT_LUA_EXT ".lua"
#define PROJECT_MOON_EXT ".moon"
#define PROJECT_JS_EXT ".js"
+#define PROJECT_WREN_EXT ".wren"
typedef struct
{
diff --git a/src/surf.c b/src/surf.c
index d2e981f..fe19316 100644
--- a/src/surf.c
+++ b/src/surf.c
@@ -395,6 +395,7 @@ static bool addMenuItem(const char* name, const char* info, s32 id, void* ptr, b
|| hasExt(name, PROJECT_LUA_EXT)
|| hasExt(name, PROJECT_MOON_EXT)
|| hasExt(name, PROJECT_JS_EXT)
+ || hasExt(name, PROJECT_WREN_EXT)
#endif
)
{
diff --git a/src/tic.c b/src/tic.c
index e62772c..9db3ea9 100644
--- a/src/tic.c
+++ b/src/tic.c
@@ -561,6 +561,7 @@ void tic_close(tic_mem* memory)
getLuaScriptConfig()->close(memory);
getMoonScriptConfig()->close(memory);
getJsScriptConfig()->close(memory);
+ getWrenScriptConfig()->close(memory);
blip_delete(machine->blip);
@@ -1528,10 +1529,16 @@ static bool isJavascript(const char* code)
|| compareMetatag(code, "script", "javascript", getJsScriptConfig()->singleComment);
}
+static bool isWren(const char* code)
+{
+ return compareMetatag(code, "script", "wren", getWrenScriptConfig()->singleComment);
+}
+
static const tic_script_config* getScriptConfig(const char* code)
{
if(isMoonscript(code)) return getMoonScriptConfig();
if(isJavascript(code)) return getJsScriptConfig();
+ if(isWren(code)) return getWrenScriptConfig();
return getLuaScriptConfig();
}
diff --git a/src/wrenapi.c b/src/wrenapi.c
new file mode 100644
index 0000000..f3f935c
--- /dev/null
+++ b/src/wrenapi.c
@@ -0,0 +1,1370 @@
+// MIT License
+
+// Copyright (c) 2017 Vadim Grigoruk @nesbox // grigoruk@gmail.com
+
+// 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 "machine.h"
+#include "tools.h"
+#include "wren.h"
+
+static WrenHandle* game_class;
+static WrenHandle* new_handle;
+static WrenHandle* update_handle;
+static WrenHandle* scanline_handle;
+static WrenHandle* overlap_handle;
+
+static bool loaded = false;
+
+static char const* tic_wren_api = "\n\
+class TIC {\n\
+ foreign static btn(id)\n\
+ foreign static btnp(id)\n\
+ foreign static btnp(id, hold, period)\n\
+ foreign static key(id)\n\
+ foreign static keyp(id)\n\
+ foreign static keyp(id, hold, period)\n\
+ foreign static mouse()\n\
+ foreign static font(text)\n\
+ foreign static font(text, x, y)\n\
+ foreign static font(text, x, y, alpha_color)\n\
+ foreign static font(text, x, y, alpha_color, w, h)\n\
+ foreign static font(text, x, y, alpha_color, w, h, fixed)\n\
+ foreign static font(text, x, y, alpha_color, w, h, fixed, scale)\n\
+ foreign static spr(id)\n\
+ foreign static spr(id, x, y)\n\
+ foreign static spr(id, x, y, alpha_color)\n\
+ foreign static spr(id, x, y, alpha_color, scale)\n\
+ foreign static spr(id, x, y, alpha_color, scale, flip)\n\
+ foreign static spr(id, x, y, alpha_color, scale, flip, rotate)\n\
+ foreign static spr(id, x, y, alpha_color, scale, flip, rotate, cell_width, cell_height)\n\
+ foreign static map(cell_x, cell_y)\n\
+ foreign static map(cell_x, cell_y, cell_w, cell_h)\n\
+ foreign static map(cell_x, cell_y, cell_w, cell_h, x, y)\n\
+ foreign static map(cell_x, cell_y, cell_w, cell_h, x, y, alpha_color)\n\
+ foreign static map(cell_x, cell_y, cell_w, cell_h, x, y, alpha_color, scale)\n\
+ foreign static mset(cell_x, cell_y)\n\
+ foreign static mset(cell_x, cell_y, index)\n\
+ foreign static mget(cell_x, cell_y)\n\
+ foreign static textri(x1, y1, x2, y2, x3, y3, u1, v1, u2, v2, u3, v3)\n\
+ foreign static textri(x1, y1, x2, y2, x3, y3, u1, v1, u2, v2, u3, v3, use_map)\n\
+ foreign static textri(x1, y1, x2, y2, x3, y3, u1, v1, u2, v2, u3, v3, use_map, alpha_color)\n\
+ foreign static pix(x, y)\n\
+ foreign static pix(x, y, color)\n\
+ foreign static line(x0, y0, x1, y1, color)\n\
+ foreign static circ(x, y, radius, color)\n\
+ foreign static circb(x, y, radius, color)\n\
+ foreign static rect(x, y, w, h, color)\n\
+ foreign static rectb(x, y, w, h, color)\n\
+ foreign static tri(x1, y1, x2, y2, x3, y3, color)\n\
+ foreign static cls()\n\
+ foreign static cls(color)\n\
+ foreign static clip()\n\
+ foreign static clip(x, y, w, h)\n\
+ foreign static peek(addr)\n\
+ foreign static poke(addr, val)\n\
+ foreign static peek4(addr)\n\
+ foreign static poke4(addr, val)\n\
+ foreign static memcpy(dst, src, size)\n\
+ foreign static memset(dst, src, size)\n\
+ foreign static pmem(index, val)\n\
+ foreign static sfx(id)\n\
+ foreign static sfx(id, note)\n\
+ foreign static sfx(id, note, duration)\n\
+ foreign static sfx(id, note, duration, channel)\n\
+ foreign static sfx(id, note, duration, channel, volume)\n\
+ foreign static sfx(id, note, duration, channel, volume, speed)\n\
+ foreign static music()\n\
+ foreign static music(track)\n\
+ foreign static music(track, frame)\n\
+ foreign static music(track, frame, loop)\n\
+ foreign static time()\n\
+ foreign static sync()\n\
+ foreign static sync(mask)\n\
+ foreign static sync(mask, bank)\n\
+ foreign static sync(mask, bank, tocart)\n\
+ foreign static reset()\n\
+ foreign static exit()\n\
+ foreign static map_width__\n\
+ foreign static map_height__\n\
+ foreign static spritesize__\n\
+ foreign static print__(v, x, y, color, fixed, scale)\n\
+ foreign static trace__(msg, color)\n\
+ foreign static spr__(id, x, y, alpha_color, scale, flip, rotate)\n\
+ foreign static mgeti__(index)\n\
+ static print(v) { TIC.print__(v.toString, 0, 0, 15, false, 1) }\n\
+ static print(v,x,y) { TIC.print__(v.toString, x, y, 15, false, 1) }\n\
+ static print(v,x,y,color) { TIC.print__(v.toString, x, y, color, false, 1) }\n\
+ static print(v,x,y,color,fixed) { TIC.print__(v.toString, x, y, color, fixed, 1) }\n\
+ static print(v,x,y,color,fixed,scale) { TIC.print__(v.toString, x, y, color, fixed, scale) }\n\
+ static trace(v) { TIC.trace__(v.toString, 15) }\n\
+ static trace(v,color) { TIC.trace__(v.toString, color) }\n\
+ static map(cell_x, cell_y, cell_w, cell_h, x, y, alpha_color, scale, remap) {\n\
+ var map_w = TIC.map_width__\n\
+ var map_h = TIC.map_height__\n\
+ var size = TIC.spritesize__ * scale\n\
+ var jj = y\n\
+ var ii = x\n\
+ var flip = 0\n\
+ var rotate = 0\n\
+ for (j in cell_y...cell_y+cell_h) {\n\
+ ii = x\n\
+ for (i in cell_x...cell_x+cell_w) {\n\
+ var mi = i\n\
+ var mj = j\n\
+ while(mi < 0) mi = mi + map_w\n\
+ while(mj < 0) mj = mj + map_h\n\
+ while(mi >= map_w) mi = mi - map_w\n\
+ while(mj >= map_h) mj = mj - map_h\n\
+ var index = mi + mj * map_w\n\
+ var tile_index = TIC.mgeti__(index)\n\
+ var ret = remap.call(tile_index, mi, mj)\n\
+ if (ret.type == List) {\n\
+ tile_index = ret[0]\n\
+ flip = ret[1]\n\
+ rotate = ret[2]\n\
+ } else if (ret.type == Num) {\n\
+ tile_index = ret\n\
+ }\n\
+ TIC.spr__(tile_index, ii, jj, alpha_color, scale, flip, rotate)\n\
+ ii = ii + size\n\
+ }\n\
+ jj = jj + size\n\
+ }\n\
+ }\n\
+ " TIC_FN "(){}\n\
+ " SCN_FN "(row){}\n\
+ " OVR_FN "(){}\n\
+}\n";
+
+static inline void wrenError(WrenVM* vm, const char* msg)
+{
+ wrenEnsureSlots(vm, 1);
+ wrenSetSlotString(vm, 0, msg);
+ wrenAbortFiber(vm, 0);
+}
+
+static inline s32 getWrenNumber(WrenVM* vm, s32 index)
+{
+ return (s32)wrenGetSlotDouble(vm, index);
+}
+
+static inline bool isNumber(WrenVM* vm, s32 index)
+{
+ return wrenGetSlotType(vm, index) == WREN_TYPE_NUM;
+}
+
+static inline bool isString(WrenVM* vm, s32 index)
+{
+ return wrenGetSlotType(vm, index) == WREN_TYPE_STRING;
+}
+
+static inline bool isList(WrenVM* vm, s32 index)
+{
+ return wrenGetSlotType(vm, index) == WREN_TYPE_LIST;
+}
+
+static void closeWren(tic_mem* tic)
+{
+ tic_machine* machine = (tic_machine*)tic;
+ if(machine->wren)
+ {
+ // release handles
+ if (loaded)
+ {
+ wrenReleaseHandle(machine->wren, new_handle);
+ wrenReleaseHandle(machine->wren, update_handle);
+ wrenReleaseHandle(machine->wren, scanline_handle);
+ wrenReleaseHandle(machine->wren, overlap_handle);
+ if (game_class != NULL) {
+ wrenReleaseHandle(machine->wren, game_class);
+ }
+ }
+
+ wrenFreeVM(machine->wren);
+ machine->wren = NULL;
+
+ }
+ loaded = false;
+}
+
+static tic_machine* getWrenMachine(WrenVM* vm)
+{
+ tic_machine* machine = wrenGetUserData(vm);
+
+ return machine;
+}
+
+static void wren_map_width(WrenVM* vm)
+{
+ wrenSetSlotDouble(vm, 0, TIC_MAP_WIDTH);
+}
+
+static void wren_map_height(WrenVM* vm)
+{
+ wrenSetSlotDouble(vm, 0, TIC_MAP_HEIGHT);
+}
+
+static void wren_mgeti(WrenVM* vm)
+{
+
+ s32 index = getWrenNumber(vm, 1);
+
+ if(index < 0 || index >= TIC_MAP_WIDTH * TIC_MAP_HEIGHT) {
+ wrenSetSlotDouble(vm, 0, 0);
+ return;
+ }
+
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+ wrenSetSlotDouble(vm, 0, *(memory->ram.map.data + index));
+}
+
+static void wren_spritesize(WrenVM* vm)
+{
+ wrenSetSlotDouble(vm, 0, TIC_SPRITESIZE);
+}
+
+static void wren_btn(WrenVM* vm)
+{
+ tic_machine* machine = getWrenMachine(vm);
+
+ s32 top = wrenGetSlotCount(vm);
+
+ if (top == 1)
+ {
+ wrenSetSlotBool(vm, 0, machine->memory.ram.input.gamepads.data);
+ }
+ else if (top == 2)
+ {
+ s32 index = getWrenNumber(vm, 1) & 0xf;
+ wrenSetSlotBool(vm, 0, machine->memory.ram.input.gamepads.data & (1 << index));
+ }
+
+}
+
+static void wren_btnp(WrenVM* vm)
+{
+ tic_machine* machine = getWrenMachine(vm);
+ tic_mem* memory = (tic_mem*)machine;
+
+ s32 top = wrenGetSlotCount(vm);
+
+ if (top == 1)
+ {
+ wrenSetSlotBool(vm, 0, memory->api.btnp(memory, -1, -1, -1));
+ }
+ else if(top == 2)
+ {
+ s32 index = getWrenNumber(vm, 1) & 0xf;
+
+ wrenSetSlotBool(vm, 0, memory->api.btnp(memory, index, -1, -1));
+ }
+ else if (top == 4)
+ {
+ s32 index = getWrenNumber(vm, 1) & 0xf;
+ u32 hold = getWrenNumber(vm, 2);
+ u32 period = getWrenNumber(vm, 3);
+
+ wrenSetSlotBool(vm, 0, memory->api.btnp(memory, index, hold, period));
+ }
+}
+
+static void wren_key(WrenVM* vm)
+{
+ tic_machine* machine = getWrenMachine(vm);
+ tic_mem* tic = &machine->memory;
+
+ s32 top = wrenGetSlotCount(vm);
+
+ if (top == 1)
+ {
+ wrenSetSlotBool(vm, 0, tic->api.key(tic, tic_key_unknown));
+ }
+ else if (top == 2)
+ {
+ tic_key key = getWrenNumber(vm, 1);
+
+ if(key < tic_keys_count)
+ wrenSetSlotBool(vm, 0, tic->api.key(tic, key));
+ else
+ {
+ wrenError(vm, "unknown keyboard code\n");
+ return;
+ }
+ }
+}
+
+static void wren_keyp(WrenVM* vm)
+{
+ tic_machine* machine = getWrenMachine(vm);
+ tic_mem* tic = &machine->memory;
+
+ s32 top = wrenGetSlotCount(vm);
+
+ if (top == 1)
+ {
+ wrenSetSlotBool(vm, 0, tic->api.keyp(tic, tic_key_unknown, -1, -1));
+ }
+ else
+ {
+ tic_key key = getWrenNumber(vm, 1);
+
+ if(key >= tic_keys_count)
+ {
+ wrenError(vm, "unknown keyboard code\n");
+ }
+ else
+ {
+ if(top == 2)
+ {
+ wrenSetSlotBool(vm, 0, tic->api.keyp(tic, key, -1, -1));
+ }
+ else if(top == 4)
+ {
+ u32 hold = getWrenNumber(vm, 2);
+ u32 period = getWrenNumber(vm, 3);
+
+ wrenSetSlotBool(vm, 0, tic->api.keyp(tic, key, hold, period));
+ }
+ }
+ }
+}
+
+
+static void wren_mouse(WrenVM* vm)
+{
+ tic_machine* machine = getWrenMachine(vm);
+
+ const tic80_mouse* mouse = &machine->memory.ram.input.mouse;
+
+ wrenEnsureSlots(vm, 4);
+ wrenSetSlotNewList(vm, 0);
+ wrenSetSlotDouble(vm, 1, mouse->x);
+ wrenInsertInList(vm, 0, 0, 1);
+ wrenSetSlotDouble(vm, 1, mouse->y);
+ wrenInsertInList(vm, 0, 1, 1);
+ wrenSetSlotBool(vm, 1, mouse->left);
+ wrenInsertInList(vm, 0, 2, 1);
+ wrenSetSlotBool(vm, 1, mouse->middle);
+ wrenInsertInList(vm, 0, 3, 1);
+ wrenSetSlotBool(vm, 1, mouse->right);
+ wrenInsertInList(vm, 0, 4, 1);
+}
+
+static void wren_print(WrenVM* vm)
+{
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+
+ const char* text = wrenGetSlotString(vm, 1);
+
+ s32 x = getWrenNumber(vm, 2);
+ s32 y = getWrenNumber(vm, 3);
+
+ s32 color = getWrenNumber(vm, 4) % TIC_PALETTE_SIZE;
+
+ bool fixed = wrenGetSlotBool(vm, 5);
+
+ s32 scale = getWrenNumber(vm, 6);
+
+ if(scale == 0)
+ {
+ wrenSetSlotDouble(vm, 0, 0);
+ return;
+ }
+
+ s32 size = memory->api.text_ex(memory, text, x, y, color, fixed, scale);
+
+ wrenSetSlotDouble(vm, 0, size);
+}
+
+static void wren_font(WrenVM* vm)
+{
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+ s32 top = wrenGetSlotCount(vm);
+
+ if(top > 1)
+ {
+ const char* text = NULL;
+ if (isString(vm, 1))
+ {
+ text = wrenGetSlotString(vm, 1);
+ }
+
+ s32 x = 0;
+ s32 y = 0;
+ s32 width = TIC_SPRITESIZE;
+ s32 height = TIC_SPRITESIZE;
+ u8 chromakey = 0;
+ bool fixed = false;
+ s32 scale = 1;
+
+ if(top > 3)
+ {
+ x = getWrenNumber(vm, 2);
+ y = getWrenNumber(vm, 3);
+
+ if(top > 4)
+ {
+ chromakey = getWrenNumber(vm, 4);
+
+ if(top > 6)
+ {
+ width = getWrenNumber(vm, 5);
+ height = getWrenNumber(vm, 6);
+
+ if(top > 7)
+ {
+ fixed = wrenGetSlotBool(vm, 7);
+
+ if(top > 8)
+ {
+ scale = getWrenNumber(vm, 8);
+ }
+ }
+ }
+ }
+ }
+
+ if(scale == 0)
+ {
+ wrenSetSlotDouble(vm, 0, 0);
+ return;
+ }
+
+ s32 size = drawText(memory, text ? text : "null", x, y, width, height, chromakey, scale, fixed ? drawSpriteFont : drawFixedSpriteFont);
+ wrenSetSlotDouble(vm, 0, size);
+ }
+}
+
+static void wren_trace(WrenVM* vm)
+{
+ tic_machine* machine = getWrenMachine(vm);
+
+ const char* text = wrenGetSlotString(vm, 1);
+ u8 color = (u8)getWrenNumber(vm, 2);
+
+ machine->data->trace(machine->data->data, text, color);
+}
+
+static void wren_spr(WrenVM* vm)
+{
+ s32 top = wrenGetSlotCount(vm);
+
+ s32 index = 0;
+ s32 x = 0;
+ s32 y = 0;
+ s32 w = 1;
+ s32 h = 1;
+ s32 scale = 1;
+ tic_flip flip = tic_no_flip;
+ tic_rotate rotate = tic_no_rotate;
+ static u8 colors[TIC_PALETTE_SIZE];
+ s32 count = 0;
+
+ if(top > 1)
+ {
+ index = getWrenNumber(vm, 1);
+
+ if(top > 3)
+ {
+ x = getWrenNumber(vm, 2);
+ y = getWrenNumber(vm, 3);
+
+ if(top > 4)
+ {
+ if(isList(vm, 4))
+ {
+ for(s32 i = 0; i < TIC_PALETTE_SIZE; i++)
+ {
+ wrenGetListElement(vm, 4, i, 0); // todo, can be bug cause in slot 0 is object?
+ if(isNumber(vm, 0))
+ {
+ colors[i] = getWrenNumber(vm, 0);
+ count++;
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+ else
+ {
+ colors[0] = getWrenNumber(vm, 4);
+ count = 1;
+ }
+
+ if(top > 5)
+ {
+ scale = getWrenNumber(vm, 5);
+
+ if(top > 6)
+ {
+ flip = getWrenNumber(vm, 6);
+
+ if(top > 7)
+ {
+ rotate = getWrenNumber(vm, 7);
+
+ if(top > 9)
+ {
+ w = getWrenNumber(vm, 8);
+ h = getWrenNumber(vm, 9);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+
+ memory->api.sprite_ex(memory, &memory->ram.tiles, index, x, y, w, h, colors, count, scale, flip, rotate);
+}
+
+static void wren_spr_internal(WrenVM* vm)
+{
+ s32 index = getWrenNumber(vm, 1);
+ s32 x = getWrenNumber(vm, 2);
+ s32 y = getWrenNumber(vm, 3);
+
+ static u8 colors[TIC_PALETTE_SIZE];
+ s32 count = 0;
+
+ if(isList(vm, 4)) {
+ for(s32 i = 0; i < TIC_PALETTE_SIZE; i++) {
+ wrenGetListElement(vm, 4, i, 0); // todo, can be bug cause in slot 0 is object?
+ if(isNumber(vm, 0)) {
+ colors[i] = getWrenNumber(vm, 0);
+ count++;
+ } else {
+ break;
+ }
+ }
+ }
+ else
+ {
+ colors[0] = getWrenNumber(vm, 4);
+ count = 1;
+ }
+
+ s32 scale = getWrenNumber(vm, 5);
+ s32 flip = getWrenNumber(vm, 6);
+ s32 rotate = getWrenNumber(vm, 7);
+
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+
+ memory->api.sprite_ex(memory, &memory->ram.tiles, index, x, y, 1, 1, colors, count, scale, flip, rotate);
+}
+
+static void wren_map(WrenVM* vm)
+{
+ s32 x = 0;
+ s32 y = 0;
+ s32 w = TIC_MAP_SCREEN_WIDTH;
+ s32 h = TIC_MAP_SCREEN_HEIGHT;
+ s32 sx = 0;
+ s32 sy = 0;
+ u8 chromakey = -1;
+ s32 scale = 1;
+
+ s32 top = wrenGetSlotCount(vm);
+
+ if(top > 2)
+ {
+ x = getWrenNumber(vm, 1);
+ y = getWrenNumber(vm, 2);
+
+ if(top > 4)
+ {
+ w = getWrenNumber(vm, 3);
+ h = getWrenNumber(vm, 4);
+
+ if(top > 6)
+ {
+ sx = getWrenNumber(vm, 5);
+ sy = getWrenNumber(vm, 6);
+
+ if(top > 7)
+ {
+ chromakey = getWrenNumber(vm, 7);
+
+ if(top > 8)
+ {
+ scale = getWrenNumber(vm, 8);
+ }
+ }
+ }
+ }
+ }
+
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+
+ memory->api.map(memory, &memory->ram.map, &memory->ram.tiles, x, y, w, h, sx, sy, chromakey, scale);
+}
+
+static void wren_mset(WrenVM* vm)
+{
+
+ s32 x = getWrenNumber(vm, 1);
+ s32 y = getWrenNumber(vm, 2);
+ u8 value = getWrenNumber(vm, 3);
+
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+
+ memory->api.map_set(memory, &memory->ram.map, x, y, value);
+}
+
+static void wren_mget(WrenVM* vm)
+{
+ s32 x = getWrenNumber(vm, 1);
+ s32 y = getWrenNumber(vm, 2);
+
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+
+ u8 value = memory->api.map_get(memory, &memory->ram.map, x, y);
+ wrenSetSlotDouble(vm, 0, value);
+}
+
+static void wren_textri(WrenVM* vm)
+{
+ int top = wrenGetSlotCount(vm);
+
+ float pt[12];
+
+ for (s32 i = 0; i < COUNT_OF(pt); i++){
+ pt[i] = (float)getWrenNumber(vm, i + 1);
+ }
+
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+ u8 chroma = 0xff;
+ bool use_map = false;
+
+ // check for use map
+ if (top > 13){
+ use_map = wrenGetSlotBool(vm, 13);
+ }
+
+ // check for chroma
+ if (top > 14){
+ chroma = (u8)getWrenNumber(vm, 14);
+ }
+
+ memory->api.textri(memory, pt[0], pt[1], // xy 1
+ pt[2], pt[3], // xy 2
+ pt[4], pt[5], // xy 3
+ pt[6], pt[7], // uv 1
+ pt[8], pt[9], // uv 2
+ pt[10], pt[11], // uv 3
+ use_map, // use map
+ chroma); // chroma
+}
+
+static void wren_pix(WrenVM* vm)
+{
+ int top = wrenGetSlotCount(vm);
+
+ s32 x = getWrenNumber(vm, 1);
+ s32 y = getWrenNumber(vm, 2);
+
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+
+ if(top > 3)
+ {
+ s32 color = getWrenNumber(vm, 3);
+ memory->api.pixel(memory, x, y, color);
+ }
+ else
+ {
+ wrenSetSlotDouble(vm, 0, memory->api.get_pixel(memory, x, y));
+ }
+}
+
+static void wren_line(WrenVM* vm)
+{
+ s32 x0 = getWrenNumber(vm, 1);
+ s32 y0 = getWrenNumber(vm, 2);
+ s32 x1 = getWrenNumber(vm, 3);
+ s32 y1 = getWrenNumber(vm, 4);
+ s32 color = getWrenNumber(vm, 5);
+
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+
+ memory->api.line(memory, x0, y0, x1, y1, color);
+}
+
+static void wren_circ(WrenVM* vm)
+{
+ s32 radius = getWrenNumber(vm, 3);
+ if(radius < 0) {
+ return;
+ }
+
+ s32 x = getWrenNumber(vm, 1);
+ s32 y = getWrenNumber(vm, 2);
+ s32 color = getWrenNumber(vm, 4);
+
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+
+ memory->api.circle(memory, x, y, radius, color);
+}
+
+static void wren_circb(WrenVM* vm)
+{
+ s32 radius = getWrenNumber(vm, 3);
+ if(radius < 0) return;
+
+ s32 x = getWrenNumber(vm, 1);
+ s32 y = getWrenNumber(vm, 2);
+ s32 color = getWrenNumber(vm, 4);
+
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+
+ memory->api.circle_border(memory, x, y, radius, color);
+}
+
+static void wren_rect(WrenVM* vm)
+{
+ s32 x = getWrenNumber(vm, 1);
+ s32 y = getWrenNumber(vm, 2);
+ s32 w = getWrenNumber(vm, 3);
+ s32 h = getWrenNumber(vm, 4);
+ s32 color = getWrenNumber(vm, 5);
+
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+
+ memory->api.rect(memory, x, y, w, h, color);
+}
+
+static void wren_rectb(WrenVM* vm)
+{
+ s32 x = getWrenNumber(vm, 1);
+ s32 y = getWrenNumber(vm, 2);
+ s32 w = getWrenNumber(vm, 3);
+ s32 h = getWrenNumber(vm, 4);
+ s32 color = getWrenNumber(vm, 5);
+
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+
+ memory->api.rect_border(memory, x, y, w, h, color);
+}
+
+static void wren_tri(WrenVM* vm)
+{
+ s32 pt[6];
+
+ for(s32 i = 0; i < COUNT_OF(pt); i++){
+ pt[i] = getWrenNumber(vm, i+1);
+ }
+
+ s32 color = getWrenNumber(vm, 7);
+
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+
+ memory->api.tri(memory, pt[0], pt[1], pt[2], pt[3], pt[4], pt[5], color);
+}
+
+static void wren_cls(WrenVM* vm)
+{
+ int top = wrenGetSlotCount(vm);
+
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+
+ memory->api.clear(memory, top == 1 ? 0 : getWrenNumber(vm, 1));
+}
+
+static void wren_clip(WrenVM* vm)
+{
+ s32 top = wrenGetSlotCount(vm);
+
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+
+ if(top == 1)
+ {
+ memory->api.clip(memory, 0, 0, TIC80_WIDTH, TIC80_HEIGHT);
+ }
+ else
+ {
+ s32 x = getWrenNumber(vm, 1);
+ s32 y = getWrenNumber(vm, 2);
+ s32 w = getWrenNumber(vm, 3);
+ s32 h = getWrenNumber(vm, 4);
+
+ memory->api.clip(memory, x, y, w, h);
+ }
+}
+
+static void wren_peek(WrenVM* vm)
+{
+ tic_machine* machine = getWrenMachine(vm);
+
+ s32 address = getWrenNumber(vm, 1);
+
+ if(address >= 0 && address < sizeof(tic_ram))
+ {
+ wrenSetSlotDouble(vm, 0, *((u8*)&machine->memory.ram + address));
+ }
+}
+
+static void wren_poke(WrenVM* vm)
+{
+ tic_machine* machine = getWrenMachine(vm);
+
+ s32 address = getWrenNumber(vm, 1);
+ u8 value = getWrenNumber(vm, 2) & 0xff;
+
+ if(address >= 0 && address < sizeof(tic_ram))
+ {
+ *((u8*)&machine->memory.ram + address) = value;
+ }
+}
+
+static void wren_peek4(WrenVM* vm)
+{
+ s32 address = getWrenNumber(vm, 1);
+
+ if(address >= 0 && address < sizeof(tic_ram)*2)
+ {
+ wrenSetSlotDouble(vm, 0, tic_tool_peek4((u8*)&getWrenMachine(vm)->memory.ram, address));
+ }
+}
+
+static void wren_poke4(WrenVM* vm)
+{
+ s32 address = getWrenNumber(vm, 1);
+ u8 value = getWrenNumber(vm, 2);
+
+ if(address >= 0 && address < sizeof(tic_ram)*2)
+ {
+ tic_tool_poke4((u8*)&getWrenMachine(vm)->memory.ram, address, value);
+ }
+}
+
+static void wren_memcpy(WrenVM* vm)
+{
+ s32 dest = getWrenNumber(vm, 1);
+ s32 src = getWrenNumber(vm, 2);
+ s32 size = getWrenNumber(vm, 3);
+ s32 bound = sizeof(tic_ram) - size;
+
+ if(size >= 0 && size <= sizeof(tic_ram) && dest >= 0 && src >= 0 && dest <= bound && src <= bound)
+ {
+ u8* base = (u8*)&getWrenMachine(vm)->memory;
+ memcpy(base + dest, base + src, size);
+ }
+}
+
+static void wren_memset(WrenVM* vm)
+{
+ s32 dest = getWrenNumber(vm, 1);
+ u8 value = getWrenNumber(vm, 2);
+ s32 size = getWrenNumber(vm, 3);
+ s32 bound = sizeof(tic_ram) - size;
+
+ if(size >= 0 && size <= sizeof(tic_ram) && dest >= 0 && dest <= bound)
+ {
+ u8* base = (u8*)&getWrenMachine(vm)->memory;
+ memset(base + dest, value, size);
+ }
+}
+
+static void wren_pmem(WrenVM* vm)
+{
+ s32 top = wrenGetSlotCount(vm);
+ tic_machine* machine = getWrenMachine(vm);
+ tic_mem* memory = &machine->memory;
+
+ u32 index = getWrenNumber(vm, 1);
+
+ if(index < TIC_PERSISTENT_SIZE)
+ {
+ s32 val = memory->persistent.data[index];
+
+ if(top > 2)
+ {
+ memory->persistent.data[index] = getWrenNumber(vm, 2);
+ }
+
+ wrenSetSlotDouble(vm, 0, val);
+ }
+ else wrenError(vm, "invalid persistent memory index\n");
+}
+
+static void wren_sfx(WrenVM* vm)
+{
+ s32 top = wrenGetSlotCount(vm);
+
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+
+ s32 index = getWrenNumber(vm, 1);
+
+ if(index < SFX_COUNT)
+ {
+
+ s32 note = -1;
+ s32 octave = -1;
+ s32 duration = -1;
+ s32 channel = 0;
+ s32 volume = MAX_VOLUME;
+ s32 speed = SFX_DEF_SPEED;
+
+ if (index >= 0)
+ {
+ tic_sample* effect = memory->ram.sfx.samples.data + index;
+
+ note = effect->note;
+ octave = effect->octave;
+ speed = effect->speed;
+ }
+
+ if(top > 2)
+ {
+ if(isNumber(vm, 2))
+ {
+ s32 id = getWrenNumber(vm, 2);
+ note = id % NOTES;
+ octave = id / NOTES;
+ }
+ else if(isString(vm, 2))
+ {
+ const char* noteStr = wrenGetSlotString(vm, 2);
+
+ if(!tic_tool_parse_note(noteStr, ¬e, &octave))
+ {
+ wrenError(vm, "invalid note, should be like C#4\n");
+ return;
+ }
+ }
+
+ if(top > 3)
+ {
+ duration = getWrenNumber(vm, 3);
+
+ if(top > 4)
+ {
+ channel = getWrenNumber(vm, 4);
+
+ if(top > 5)
+ {
+ volume = getWrenNumber(vm, 5);
+
+ if(top > 6)
+ {
+ speed = getWrenNumber(vm, 6);
+ }
+ }
+ }
+ }
+ }
+
+ if (channel >= 0 && channel < TIC_SOUND_CHANNELS)
+ {
+ memory->api.sfx_stop(memory, channel);
+ memory->api.sfx_ex(memory, index, note, octave, duration, channel, volume & 0xf, speed);
+ }
+ else wrenError(vm, "unknown channel\n");
+ }
+ else wrenError(vm, "unknown sfx index\n");
+}
+
+static void wren_music(WrenVM* vm)
+{
+ s32 top = wrenGetSlotCount(vm);
+
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+
+ s32 track = -1;
+ s32 frame = -1;
+ s32 row = -1;
+ bool loop = true;
+
+ if(top > 1)
+ {
+ track = getWrenNumber(vm, 1);
+
+ if(top > 2)
+ {
+ frame = getWrenNumber(vm, 2);
+
+ if(top > 3)
+ {
+ row = getWrenNumber(vm, 3);
+
+ if(top > 4)
+ {
+ loop = wrenGetSlotBool(vm, 4);
+ }
+ }
+ }
+ }
+
+ memory->api.music(memory, track, frame, row, loop);
+}
+
+static void wren_time(WrenVM* vm)
+{
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+
+ wrenSetSlotDouble(vm, 0, memory->api.time(memory));
+}
+
+static void wren_sync(WrenVM* vm)
+{
+ tic_mem* memory = (tic_mem*)getWrenMachine(vm);
+
+ bool toCart = true;
+ u32 mask = 0;
+ s32 bank = 0;
+
+ s32 top = wrenGetSlotCount(vm);
+
+ if(top > 1)
+ {
+ mask = getWrenNumber(vm, 1);
+
+ if(top > 2)
+ {
+ bank = getWrenNumber(vm, 2);
+
+ if(top > 3)
+ {
+ toCart = wrenGetSlotBool(vm, 3);
+ }
+ }
+ }
+
+ if(bank >= 0 && bank < TIC_BANKS)
+ memory->api.sync(memory, mask, bank, toCart);
+ else wrenError(vm, "sync() error, invalid bank");
+}
+
+static void wren_reset(WrenVM* vm)
+{
+ tic_machine* machine = getWrenMachine(vm);
+
+ machine->state.initialized = false;
+}
+
+static void wren_exit(WrenVM* vm)
+{
+ tic_machine* machine = getWrenMachine(vm);
+
+ machine->data->exit(machine->data->data);
+}
+
+static const char* const ApiKeywords[] = API_KEYWORDS;
+
+static WrenForeignMethodFn foreignTicMethods(const char* signature)
+{
+
+ if (strcmp(signature, "static TIC.btn(_)" ) == 0) return wren_btn;
+ if (strcmp(signature, "static TIC.btnp(_)" ) == 0) return wren_btnp;
+ if (strcmp(signature, "static TIC.btnp(_,_,_)" ) == 0) return wren_btnp;
+ if (strcmp(signature, "static TIC.key(_)" ) == 0) return wren_key;
+ if (strcmp(signature, "static TIC.keyp(_)" ) == 0) return wren_keyp;
+ if (strcmp(signature, "static TIC.keyp(_,_,_)" ) == 0) return wren_keyp;
+ if (strcmp(signature, "static TIC.mouse()" ) == 0) return wren_mouse;
+
+ if (strcmp(signature, "static TIC.font(_)" ) == 0) return wren_font;
+ if (strcmp(signature, "static TIC.font(_,_,_)" ) == 0) return wren_font;
+ if (strcmp(signature, "static TIC.font(_,_,_,_)" ) == 0) return wren_font;
+ if (strcmp(signature, "static TIC.font(_,_,_,_,_,_)" ) == 0) return wren_font;
+ if (strcmp(signature, "static TIC.font(_,_,_,_,_,_,_)" ) == 0) return wren_font;
+ if (strcmp(signature, "static TIC.font(_,_,_,_,_,_,_,_)" ) == 0) return wren_font;
+
+ if (strcmp(signature, "static TIC.spr(_)" ) == 0) return wren_spr;
+ if (strcmp(signature, "static TIC.spr(_,_,_)" ) == 0) return wren_spr;
+ if (strcmp(signature, "static TIC.spr(_,_,_,_)" ) == 0) return wren_spr;
+ if (strcmp(signature, "static TIC.spr(_,_,_,_,_)" ) == 0) return wren_spr;
+ if (strcmp(signature, "static TIC.spr(_,_,_,_,_,_)" ) == 0) return wren_spr;
+ if (strcmp(signature, "static TIC.spr(_,_,_,_,_,_,_)" ) == 0) return wren_spr;
+ if (strcmp(signature, "static TIC.spr(_,_,_,_,_,_,_,_,_)" ) == 0) return wren_spr;
+
+ if (strcmp(signature, "static TIC.map(_,_)" ) == 0) return wren_map;
+ if (strcmp(signature, "static TIC.map(_,_,_,_)" ) == 0) return wren_map;
+ if (strcmp(signature, "static TIC.map(_,_,_,_,_,_)" ) == 0) return wren_map;
+ if (strcmp(signature, "static TIC.map(_,_,_,_,_,_,_)" ) == 0) return wren_map;
+ if (strcmp(signature, "static TIC.map(_,_,_,_,_,_,_,_)" ) == 0) return wren_map;
+
+ if (strcmp(signature, "static TIC.mset(_,_)" ) == 0) return wren_mset;
+ if (strcmp(signature, "static TIC.mset(_,_,_)" ) == 0) return wren_mset;
+ if (strcmp(signature, "static TIC.mget(_,_)" ) == 0) return wren_mget;
+
+ if (strcmp(signature, "static TIC.textri(_,_,_,_,_,_,_,_,_,_,_,_)" ) == 0) return wren_textri;
+ if (strcmp(signature, "static TIC.textri(_,_,_,_,_,_,_,_,_,_,_,_,_)" ) == 0) return wren_textri;
+ if (strcmp(signature, "static TIC.textri(_,_,_,_,_,_,_,_,_,_,_,_,_,_)" ) == 0) return wren_textri;
+
+ if (strcmp(signature, "static TIC.pix(_,_)" ) == 0) return wren_pix;
+ if (strcmp(signature, "static TIC.pix(_,_,_)" ) == 0) return wren_pix;
+ if (strcmp(signature, "static TIC.line(_,_,_,_,_)" ) == 0) return wren_line;
+ if (strcmp(signature, "static TIC.circ(_,_,_,_)" ) == 0) return wren_circ;
+ if (strcmp(signature, "static TIC.circb(_,_,_,_)" ) == 0) return wren_circb;
+ if (strcmp(signature, "static TIC.rect(_,_,_,_,_)" ) == 0) return wren_rect;
+ if (strcmp(signature, "static TIC.rectb(_,_,_,_,_)" ) == 0) return wren_rectb;
+ if (strcmp(signature, "static TIC.tri(_,_,_,_,_,_,_)" ) == 0) return wren_tri;
+
+ if (strcmp(signature, "static TIC.cls()" ) == 0) return wren_cls;
+ if (strcmp(signature, "static TIC.cls(_)" ) == 0) return wren_cls;
+ if (strcmp(signature, "static TIC.clip()" ) == 0) return wren_clip;
+ if (strcmp(signature, "static TIC.clip(_,_,_,_)" ) == 0) return wren_clip;
+
+ if (strcmp(signature, "static TIC.peek(_)" ) == 0) return wren_peek;
+ if (strcmp(signature, "static TIC.poke(_,_)" ) == 0) return wren_poke;
+ if (strcmp(signature, "static TIC.peek4(_)" ) == 0) return wren_peek4;
+ if (strcmp(signature, "static TIC.poke4(_,_)" ) == 0) return wren_poke4;
+ if (strcmp(signature, "static TIC.memcpy(_,_,_)" ) == 0) return wren_memcpy;
+ if (strcmp(signature, "static TIC.memset(_,_,_)" ) == 0) return wren_memset;
+ if (strcmp(signature, "static TIC.pmem(_,_)" ) == 0) return wren_pmem;
+
+ if (strcmp(signature, "static TIC.sfx(_)" ) == 0) return wren_sfx;
+ if (strcmp(signature, "static TIC.sfx(_,_)" ) == 0) return wren_sfx;
+ if (strcmp(signature, "static TIC.sfx(_,_,_)" ) == 0) return wren_sfx;
+ if (strcmp(signature, "static TIC.sfx(_,_,_,_)" ) == 0) return wren_sfx;
+ if (strcmp(signature, "static TIC.sfx(_,_,_,_,_)" ) == 0) return wren_sfx;
+ if (strcmp(signature, "static TIC.sfx(_,_,_,_,_,_)" ) == 0) return wren_sfx;
+ if (strcmp(signature, "static TIC.music()" ) == 0) return wren_music;
+ if (strcmp(signature, "static TIC.music(_)" ) == 0) return wren_music;
+ if (strcmp(signature, "static TIC.music(_,_)" ) == 0) return wren_music;
+ if (strcmp(signature, "static TIC.music(_,_,_)" ) == 0) return wren_music;
+
+ if (strcmp(signature, "static TIC.time()" ) == 0) return wren_time;
+ if (strcmp(signature, "static TIC.sync()" ) == 0) return wren_sync;
+ if (strcmp(signature, "static TIC.sync(_)" ) == 0) return wren_sync;
+ if (strcmp(signature, "static TIC.sync(_,_)" ) == 0) return wren_sync;
+ if (strcmp(signature, "static TIC.sync(_,_,_)" ) == 0) return wren_sync;
+ if (strcmp(signature, "static TIC.reset()" ) == 0) return wren_reset;
+ if (strcmp(signature, "static TIC.exit()" ) == 0) return wren_exit;
+
+ // internal functions
+ if (strcmp(signature, "static TIC.map_width__" ) == 0) return wren_map_width;
+ if (strcmp(signature, "static TIC.map_height__" ) == 0) return wren_map_height;
+ if (strcmp(signature, "static TIC.spritesize__" ) == 0) return wren_spritesize;
+ if (strcmp(signature, "static TIC.print__(_,_,_,_,_,_)" ) == 0) return wren_print;
+ if (strcmp(signature, "static TIC.trace__(_,_)" ) == 0) return wren_trace;
+ if (strcmp(signature, "static TIC.spr__(_,_,_,_,_,_,_)" ) == 0) return wren_spr_internal;
+ if (strcmp(signature, "static TIC.mgeti__(_)" ) == 0) return wren_mgeti;
+
+ return NULL;
+}
+
+static WrenForeignMethodFn bindForeignMethod(
+ WrenVM* vm, const char* module, const char* className,
+ bool isStatic, const char* signature)
+{
+
+ if (strcmp(module, "main") != 0) return NULL;
+
+ // For convenience, concatenate all of the method qualifiers into a single
+ // signature string.
+ char fullName[256];
+ fullName[0] = '\0';
+ if (isStatic) {
+ strcat(fullName, "static ");
+ }
+
+ strcat(fullName, className);
+ strcat(fullName, ".");
+ strcat(fullName, signature);
+
+ WrenForeignMethodFn method = NULL;
+
+ method = foreignTicMethods(fullName);
+
+ return method;
+}
+
+static void initAPI(tic_machine* machine)
+{
+ wrenSetUserData(machine->wren, machine);
+
+ if (wrenInterpret(machine->wren, tic_wren_api) != WREN_RESULT_SUCCESS)
+ {
+ machine->data->error(machine->data->data, "can't load Tic wren api");
+ }
+}
+
+static void reportError(WrenVM* vm, WrenErrorType type, const char* module, int line, const char* message)
+{
+ tic_machine* machine = getWrenMachine(vm);
+
+ char buffer[1024];
+
+ if (module)
+ {
+ snprintf(buffer, sizeof buffer, "\"%s\", %d ,\"%s\"",module, line, message);
+ } else {
+ snprintf(buffer, sizeof buffer, "%d, \"%s\"",line, message);
+ }
+
+ machine->data->error(machine->data->data, buffer);
+}
+
+static void writeFn(WrenVM* vm, const char* text)
+{
+ tic_machine* machine = getWrenMachine(vm);
+ u8 color = tic_color_blue;
+ machine->data->trace(machine->data->data, text ? text : "null", color);
+}
+
+static bool initWren(tic_mem* tic, const char* code)
+{
+ tic_machine* machine = (tic_machine*)tic;
+ closeWren(tic);
+
+ WrenConfiguration config;
+ wrenInitConfiguration(&config);
+
+ config.bindForeignMethodFn = bindForeignMethod;
+
+ config.errorFn = reportError;
+ config.writeFn = writeFn;
+
+ WrenVM* vm = machine->wren = wrenNewVM(&config);
+
+ initAPI(machine);
+
+ if (wrenInterpret(machine->wren, code) != WREN_RESULT_SUCCESS){
+ return false;
+ }
+
+ loaded = true;
+
+ // make handles
+ wrenEnsureSlots(vm, 1);
+ wrenGetVariable(vm, "main", "Game", 0);
+ game_class = wrenGetSlotHandle(vm, 0); // handle from game class
+
+ new_handle = wrenMakeCallHandle(vm, "new()");
+ update_handle = wrenMakeCallHandle(vm, TIC_FN "()");
+ scanline_handle = wrenMakeCallHandle(vm, SCN_FN "(_)");
+ overlap_handle = wrenMakeCallHandle(vm, OVR_FN "()");
+
+ // create game class
+ if (game_class)
+ {
+ wrenEnsureSlots(vm, 1);
+ wrenSetSlotHandle(vm, 0, game_class);
+ wrenCall(vm, new_handle);
+ wrenReleaseHandle(machine->wren, game_class); // release game class handle
+ game_class = NULL;
+ if (wrenGetSlotCount(vm) == 0) {
+ machine->data->error(machine->data->data, "Error in game class :(");
+ return false;
+ }
+ game_class = wrenGetSlotHandle(vm, 0); // handle from game object
+ } else {
+ machine->data->error(machine->data->data, "'Game class' isn't found :(");
+ return false;
+ }
+
+ return true;
+}
+
+static void callWrenTick(tic_mem* tic)
+{
+ tic_machine* machine = (tic_machine*)tic;
+ WrenVM* vm = machine->wren;
+
+ if(vm && game_class)
+ {
+ wrenEnsureSlots(vm, 1);
+ wrenSetSlotHandle(vm, 0, game_class);
+ wrenCall(vm, update_handle);
+ }
+}
+
+static void callWrenScanline(tic_mem* memory, s32 row, void* data)
+{
+ tic_machine* machine = (tic_machine*)memory;
+ WrenVM* vm = machine->wren;
+
+ if(vm && game_class)
+ {
+ wrenEnsureSlots(vm, 2);
+ wrenSetSlotHandle(vm, 0, game_class);
+ wrenSetSlotDouble(vm, 1, row);
+ wrenCall(vm, scanline_handle);
+ }
+}
+
+static void callWrenOverlap(tic_mem* memory, void* data)
+{
+ tic_machine* machine = (tic_machine*)memory;
+ WrenVM* vm = machine->wren;
+
+ if (vm && game_class)
+ {
+ wrenEnsureSlots(vm, 1);
+ wrenSetSlotHandle(vm, 0, game_class);
+ wrenCall(vm, overlap_handle);
+ }
+}
+
+static const char* const WrenKeywords [] =
+{
+ "false", "true", "null", "break", "class", "construct",
+ "else", "for", "foreign", "if", "import", "in", "is",
+ "return", "static", "super", "var", "while", "this"
+};
+
+static const tic_outline_item* getWrenOutline(const char* code, s32* size)
+{
+ enum{Size = sizeof(tic_outline_item)};
+
+ *size = 0;
+
+ static tic_outline_item* items = NULL;
+
+ return items;
+}
+
+static const tic_script_config WrenSyntaxConfig =
+{
+ .init = initWren,
+ .close = closeWren,
+ .tick = callWrenTick,
+ .scanline = callWrenScanline,
+ .overlap = callWrenOverlap,
+
+ .getOutline = getWrenOutline,
+ .parse = parseCode,
+
+ .blockCommentStart = "/*",
+ .blockCommentEnd = "*/",
+ .blockStringStart = NULL,
+ .blockStringEnd = NULL,
+ .singleComment = "//",
+
+ .keywords = WrenKeywords,
+ .keywordsCount = COUNT_OF(WrenKeywords),
+
+ .api = ApiKeywords,
+ .apiCount = COUNT_OF(ApiKeywords),
+};
+
+const tic_script_config* getWrenScriptConfig()
+{
+ return &WrenSyntaxConfig;
+}