diff --git a/.gitignore b/.gitignore
index 27f87e3..a871823 100644
--- a/.gitignore
+++ b/.gitignore
@@ -102,3 +102,7 @@ build/uwp/wren/x64/
build/uwp/wren/Release/
build/uwp/wren/ARM/
build/uwp/wren/Debug/
+build/windows/studio/Debug/
+build/windows/studio/Debug Pro/
+build/windows/studio/Release/
+build/windows/studio/Release Pro/
diff --git a/Makefile b/Makefile
index 4773492..e4fc082 100644
--- a/Makefile
+++ b/Makefile
@@ -251,6 +251,12 @@ bin/surf.o: src/surf.c $(TIC80_H) $(TIC_H)
bin/main.o: src/main.c src/keycodes.c $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@
+SDL_NET = \
+ bin/SDLnet.o \
+ bin/SDLnetTCP.o \
+ bin/SDLnetselect.o \
+ bin/net.o
+
TIC_O=\
bin/studio.o \
bin/console.o \
@@ -258,9 +264,6 @@ TIC_O=\
bin/file_dialog.o \
bin/md5.o \
bin/gif.o \
- bin/SDLnet.o \
- bin/SDLnetTCP.o \
- bin/SDLnetselect.o \
bin/fs.o \
bin/tools.o \
bin/start.o \
@@ -272,11 +275,9 @@ TIC_O=\
bin/world.o \
bin/config.o \
bin/code.o \
- bin/net.o \
bin/dialog.o \
bin/menu.o \
- bin/surf.o \
- bin/main.o
+ bin/surf.o
bin/tic80.o: src/tic80.c $(TIC80_H)
$(CC) $< $(OPT) $(INCLUDES) -DTIC80_SHARED -c -o $@
@@ -304,17 +305,23 @@ TIC80_O = bin/tic80.o bin/tic.o bin/tools.o bin/blip_buf.o bin/jsapi.o bin/luaap
TIC80_A = bin/libtic80.a
TIC80_DLL = bin/tic80.dll
+STUDIO_A = bin/libstudio.a
+STUDIO_DLL = bin/studio.dll
+
$(TIC80_DLL): $(TIC80_O)
$(CC) $(OPT) -shared $(TIC80_O) -L$(PRE_BUILT)/mingw -llua -lwren -lgif -Wl,--out-implib,$(TIC80_A) -o $@
+$(STUDIO_DLL): $(DEMO_ASSETS) $(TIC80_DLL) $(TIC_O) bin/html.o
+ $(CC) $(TIC_O) bin/html.o $(TIC80_A) $(OPT) -shared $(INCLUDES) -L$(PRE_BUILT)/mingw -llua -lz -lgif -Wl,--out-implib,$(STUDIO_A) -o $@
+
emscripten:
$(EMS_CC) $(SOURCES) $(TIC80_SRC) $(OPT) $(INCLUDES) $(EMS_OPT) $(EMS_LINKER_FLAGS) -o build/html/tic.js
wasm:
$(EMS_CC) $(SOURCES) $(TIC80_SRC) $(OPT) $(INCLUDES) $(EMS_OPT) -s WASM=1 $(EMS_LINKER_FLAGS) -o build/html/tic.js
-mingw: $(DEMO_ASSETS) $(TIC80_DLL) $(TIC_O) bin/html.o bin/res.o
- $(CC) $(TIC_O) bin/html.o bin/res.o $(TIC80_A) $(OPT) $(INCLUDES) $(MINGW_LINKER_FLAGS) -o $(MINGW_OUTPUT)
+mingw: $(STUDIO_DLL) $(SDL_NET) bin/main.o bin/res.o
+ $(CC) bin/main.o bin/res.o $(STUDIO_A) $(SDL_NET) $(OPT) $(INCLUDES) $(MINGW_LINKER_FLAGS) -o $(MINGW_OUTPUT)
mingw-pro:
$(eval OPT += $(OPT_PRO))
diff --git a/build/windows/studio/studio.vcxproj b/build/windows/studio/studio.vcxproj
new file mode 100644
index 0000000..d9155e4
--- /dev/null
+++ b/build/windows/studio/studio.vcxproj
@@ -0,0 +1,318 @@
+
+
+
+
+ Debug Pro
+ Win32
+
+
+ Debug Pro
+ x64
+
+
+ Debug
+ Win32
+
+
+ Release Pro
+ Win32
+
+
+ Release Pro
+ x64
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ {6181F6A6-AA1B-4CD2-B306-E242CFDE9B20}
+ Win32Proj
+ studio
+ 8.1
+
+
+
+ DynamicLibrary
+ true
+ v140_xp
+ Unicode
+
+
+ DynamicLibrary
+ true
+ v140_xp
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v140_xp
+ true
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v140_xp
+ true
+ Unicode
+
+
+ DynamicLibrary
+ true
+ v140_xp
+ Unicode
+
+
+ DynamicLibrary
+ true
+ v140_xp
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v140_xp
+ true
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v140_xp
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ false
+
+
+ false
+
+
+ false
+
+
+ false
+
+
+
+
+
+ Level3
+ Disabled
+ TIC80_SHARED;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
+
+
+ Windows
+ true
+
+
+
+
+
+
+ Level3
+ Disabled
+ TIC80_SHARED;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
+
+
+ Windows
+ true
+
+
+
+
+
+
+ Level3
+ Disabled
+ TIC80_SHARED;_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
+
+
+ Windows
+ true
+
+
+
+
+
+
+ Level3
+ Disabled
+ TIC80_SHARED;_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
+
+
+ Windows
+ true
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ TIC80_SHARED;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
+
+
+ Windows
+ true
+ true
+ true
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ TIC80_SHARED;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
+
+
+ Windows
+ true
+ true
+ true
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ TIC80_SHARED;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
+
+
+ Windows
+ true
+ true
+ true
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ TIC80_SHARED;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
+
+
+ Windows
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {6ea9d998-7557-4aed-abfc-142f9960c9b6}
+
+
+ {57d2471b-3138-495e-af18-6e290d098ffc}
+
+
+ {c4d8bc10-ebf6-42bb-9b5d-6712fb428a50}
+
+
+ {1dfbdfa2-f204-42ff-b99e-250e4b2eba04}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/build/windows/studio/studio.vcxproj.filters b/build/windows/studio/studio.vcxproj.filters
new file mode 100644
index 0000000..0c852f2
--- /dev/null
+++ b/build/windows/studio/studio.vcxproj.filters
@@ -0,0 +1,76 @@
+
+
+
+
+ {6c183603-0dc2-4093-91e5-1aba3b2b5d08}
+
+
+ {1410c434-08eb-4b70-a278-14955c0ecb28}
+
+
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src
+
+
+ src\ext
+
+
+ src\ext
+
+
+ src\ext
+
+
+
\ No newline at end of file
diff --git a/build/windows/tic/tic.sln b/build/windows/tic/tic.sln
index 8fa78d5..44151a5 100644
--- a/build/windows/tic/tic.sln
+++ b/build/windows/tic/tic.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.27130.2024
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tic", "tic.vcxproj", "{B6ECC66E-26FA-42C2-8F6C-E4338424F38A}"
ProjectSection(ProjectDependencies) = postProject
@@ -27,6 +27,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2main", "..\..\..\3rd-pa
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wren_lib", "..\wren\wren_lib.vcxproj", "{D7CC5189-C399-AC94-ECB2-9A3CD8DEE122}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "studio", "..\studio\studio.vcxproj", "{6181F6A6-AA1B-4CD2-B306-E242CFDE9B20}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug Pro|x64 = Debug Pro|x64
@@ -183,6 +185,22 @@ Global
{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
+ {6181F6A6-AA1B-4CD2-B306-E242CFDE9B20}.Debug Pro|x64.ActiveCfg = Debug Pro|x64
+ {6181F6A6-AA1B-4CD2-B306-E242CFDE9B20}.Debug Pro|x64.Build.0 = Debug Pro|x64
+ {6181F6A6-AA1B-4CD2-B306-E242CFDE9B20}.Debug Pro|x86.ActiveCfg = Debug Pro|Win32
+ {6181F6A6-AA1B-4CD2-B306-E242CFDE9B20}.Debug Pro|x86.Build.0 = Debug Pro|Win32
+ {6181F6A6-AA1B-4CD2-B306-E242CFDE9B20}.Debug|x64.ActiveCfg = Debug|x64
+ {6181F6A6-AA1B-4CD2-B306-E242CFDE9B20}.Debug|x64.Build.0 = Debug|x64
+ {6181F6A6-AA1B-4CD2-B306-E242CFDE9B20}.Debug|x86.ActiveCfg = Debug|Win32
+ {6181F6A6-AA1B-4CD2-B306-E242CFDE9B20}.Debug|x86.Build.0 = Debug|Win32
+ {6181F6A6-AA1B-4CD2-B306-E242CFDE9B20}.Release Pro|x64.ActiveCfg = Release Pro|x64
+ {6181F6A6-AA1B-4CD2-B306-E242CFDE9B20}.Release Pro|x64.Build.0 = Release Pro|x64
+ {6181F6A6-AA1B-4CD2-B306-E242CFDE9B20}.Release Pro|x86.ActiveCfg = Release Pro|Win32
+ {6181F6A6-AA1B-4CD2-B306-E242CFDE9B20}.Release Pro|x86.Build.0 = Release Pro|Win32
+ {6181F6A6-AA1B-4CD2-B306-E242CFDE9B20}.Release|x64.ActiveCfg = Release|x64
+ {6181F6A6-AA1B-4CD2-B306-E242CFDE9B20}.Release|x64.Build.0 = Release|x64
+ {6181F6A6-AA1B-4CD2-B306-E242CFDE9B20}.Release|x86.ActiveCfg = Release|Win32
+ {6181F6A6-AA1B-4CD2-B306-E242CFDE9B20}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/build/windows/tic/tic.vcxproj b/build/windows/tic/tic.vcxproj
index 80dfa79..8dba28a 100644
--- a/build/windows/tic/tic.vcxproj
+++ b/build/windows/tic/tic.vcxproj
@@ -41,46 +41,19 @@
{81ce8daf-ebb2-4761-8e45-b71abcca8c68}
-
- {6ea9d998-7557-4aed-abfc-142f9960c9b6}
-
{57d2471b-3138-495e-af18-6e290d098ffc}
-
- {c4d8bc10-ebf6-42bb-9b5d-6712fb428a50}
-
-
- {1dfbdfa2-f204-42ff-b99e-250e4b2eba04}
+
+ {6181f6a6-aa1b-4cd2-b306-e242cfde9b20}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/build/windows/tic/tic.vcxproj.filters b/build/windows/tic/tic.vcxproj.filters
index b598260..2f23a40 100644
--- a/build/windows/tic/tic.vcxproj.filters
+++ b/build/windows/tic/tic.vcxproj.filters
@@ -15,72 +15,6 @@
-
- src
-
-
- src
-
-
- src
-
-
- src
-
-
- src
-
-
- src
-
-
- src
-
-
- src
-
-
- src
-
-
- src
-
-
- src
-
-
- src\ext
-
-
- src\ext
-
-
- src
-
-
- src
-
-
- src
-
-
- src\ext
-
-
- src
-
-
- src
-
-
- src
-
-
- src
-
-
- src
-
src\ext\net
@@ -93,6 +27,9 @@
src
+
+ src
+
diff --git a/src/fs.c b/src/fs.c
index d2e4861..6c16b0a 100644
--- a/src/fs.c
+++ b/src/fs.c
@@ -105,8 +105,28 @@ bool fsIsInPublicDir(FileSystem* fs)
#if defined(__TIC_WINDOWS__) || defined(__WINRT__)
-#define UTF8ToString(S) (wchar_t *)SDL_iconv_string("UTF-16LE", "UTF-8", (char *)(S), SDL_strlen(S)+1)
-#define StringToUTF8(S) SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(S), (SDL_wcslen(S)+1)*sizeof(wchar_t))
+// #define UTF8ToString(S) (wchar_t *)SDL_iconv_string("UTF-16LE", "UTF-8", (char *)(S), strlen(S)+1)
+// #define StringToUTF8(S) SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(S), (wcslen(S)+1)*sizeof(wchar_t))
+
+static const wchar_t* UTF8ToString(const char* str)
+{
+ // TODO: ugly hack
+ wchar_t* wstr = calloc(1, FILENAME_MAX * sizeof(wchar_t));
+
+ mbstowcs(wstr, str, FILENAME_MAX);
+
+ return wstr;
+}
+
+static char* StringToUTF8(const wchar_t* wstr)
+{
+ // TODO: ugly hack
+ char* str = calloc(1, FILENAME_MAX);
+
+ wcstombs(str, wstr, FILENAME_MAX);
+
+ return str;
+}
FILE* _wfopen(const wchar_t *, const wchar_t *);
int _wremove(const wchar_t *);
@@ -154,7 +174,7 @@ void fsEnumFiles(FileSystem* fs, ListCallback callback, void* data)
if(isPublic(fs))
{
- netDirRequest(fs->net, fs->work + sizeof(TIC_HOST), callback, data);
+ _netDirRequest(fs->net, fs->work + sizeof(TIC_HOST), callback, data);
return;
}
@@ -701,7 +721,7 @@ void* fsLoadFile(FileSystem* fs, const char* name, s32* size)
char path[FILENAME_MAX] = {0};
sprintf(path, "/cart/%s/cart.tic", loadPublicCartData.hash);
- void* data = netGetRequest(fs->net, path, size);
+ void* data = _netGetRequest(fs->net, path, size);
if(data)
fsSaveRootFile(fs, cachePath, data, *size, false);
@@ -798,59 +818,57 @@ void createFileSystem(const char* path, void(*callback)(FileSystem*))
FileSystem* fs = (FileSystem*)malloc(sizeof(FileSystem));
memset(fs, 0, sizeof(FileSystem));
- fs->net = createNet();
+ fs->net = _createNet();
- if(path)
- {
- strcpy(fs->dir, path);
- callback(fs);
- }
- else
- {
+ strcpy(fs->dir, path);
+ callback(fs);
-#if defined(__EMSCRIPTEN__)
+// else
+// {
- strcpy(fs->dir, "/" TIC_PACKAGE "/" TIC_NAME "/");
+// #if defined(__EMSCRIPTEN__)
-#elif defined(__ANDROID__)
+// strcpy(fs->dir, "/" TIC_PACKAGE "/" TIC_NAME "/");
- strcpy(fs->dir, SDL_AndroidGetExternalStoragePath());
- const char AppFolder[] = "/" TIC_NAME "/";
- strcat(fs->dir, AppFolder);
- mkdir(fs->dir, 0700);
+// #elif defined(__ANDROID__)
-#else
+// strcpy(fs->dir, SDL_AndroidGetExternalStoragePath());
+// const char AppFolder[] = "/" TIC_NAME "/";
+// strcat(fs->dir, AppFolder);
+// mkdir(fs->dir, 0700);
- char* path = SDL_GetPrefPath(TIC_PACKAGE, TIC_NAME);
- strcpy(fs->dir, path);
- free(path);
+// #else
-#endif
+// char* path = SDL_GetPrefPath(TIC_PACKAGE, TIC_NAME);
+// strcpy(fs->dir, path);
+// free(path);
+
+// #endif
-#if defined(__EMSCRIPTEN__)
- EM_ASM_
- (
- {
- var dir = "";
- Module.Pointer_stringify($0).split("/").forEach(function(val)
- {
- if(val.length)
- {
- dir += "/" + val;
- FS.mkdir(dir);
- }
- });
+// #if defined(__EMSCRIPTEN__)
+// EM_ASM_
+// (
+// {
+// var dir = "";
+// Module.Pointer_stringify($0).split("/").forEach(function(val)
+// {
+// if(val.length)
+// {
+// dir += "/" + val;
+// FS.mkdir(dir);
+// }
+// });
- FS.mount(IDBFS, {}, dir);
- FS.syncfs(true, function(error)
- {
- if(error) console.log(error);
- else Runtime.dynCall('vi', $1, [$2]);
- });
- }, fs->dir, callback, fs
- );
-#else
- callback(fs);
-#endif
- }
+// FS.mount(IDBFS, {}, dir);
+// FS.syncfs(true, function(error)
+// {
+// if(error) console.log(error);
+// else Runtime.dynCall('vi', $1, [$2]);
+// });
+// }, fs->dir, callback, fs
+// );
+// #else
+// callback(fs);
+// #endif
+ // }
}
\ No newline at end of file
diff --git a/src/main.c b/src/main.c
index 883ef2a..342ac46 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,6 +1,6 @@
#include "main.h"
#include "studio.h"
-
+#include "net.h"
#include
#define STUDIO_UI_SCALE 3
@@ -814,6 +814,98 @@ static void tick()
blitSound();
}
+// should work async with callback
+static const char* getAppFolder()
+{
+
+ static char appFolder[FILENAME_MAX];
+
+#if defined(__EMSCRIPTEN__)
+
+ strcpy(appFolder, "/" TIC_PACKAGE "/" TIC_NAME "/");
+
+#elif defined(__ANDROID__)
+
+ strcpy(appFolder, SDL_AndroidGetExternalStoragePath());
+ const char AppFolder[] = "/" TIC_NAME "/";
+ strcat(appFolder, AppFolder);
+ mkdir(appFolder, 0700);
+
+#else
+
+ char* path = SDL_GetPrefPath(TIC_PACKAGE, TIC_NAME);
+ strcpy(appFolder, path);
+ free(path);
+
+#endif
+
+#if defined(__EMSCRIPTEN__)
+ EM_ASM_
+ (
+ {
+ var dir = "";
+ Module.Pointer_stringify($0).split("/").forEach(function(val)
+ {
+ if(val.length)
+ {
+ dir += "/" + val;
+ FS.mkdir(dir);
+ }
+ });
+
+ FS.mount(IDBFS, {}, dir);
+ FS.syncfs(true, function(error)
+ {
+ if(error) console.log(error);
+ else Runtime.dynCall('vi', $1, [$2]);
+ });
+ }, appFolder, callback, fs
+ );
+#endif
+
+ return appFolder;
+}
+
+void setClipboardText(const char* text)
+{
+ SDL_SetClipboardText(text);
+}
+
+bool hasClipboardText()
+{
+ return SDL_HasClipboardText();
+}
+
+char* getClipboardText()
+{
+ return SDL_GetClipboardText();
+}
+
+u64 getPerformanceCounter()
+{
+ return SDL_GetPerformanceCounter();
+}
+
+u64 getPerformanceFrequency()
+{
+ return SDL_GetPerformanceFrequency();
+}
+
+static System sysHandlers =
+{
+ .setClipboardText = setClipboardText,
+ .hasClipboardText = hasClipboardText,
+ .getClipboardText = getClipboardText,
+ .getPerformanceCounter = getPerformanceCounter,
+ .getPerformanceFrequency = getPerformanceFrequency,
+
+ .netVersionRequest = netVersionRequest,
+ .netDirRequest = netDirRequest,
+ .netGetRequest = netGetRequest,
+ .createNet = createNet,
+ .closeNet = closeNet,
+};
+
s32 main(s32 argc, char **argv)
{
SDL_SetHint(SDL_HINT_WINRT_HANDLE_BACK_BUTTON, "1");
@@ -841,14 +933,14 @@ s32 main(s32 argc, char **argv)
#elif defined(__EMSCRIPTEN__)
SDL_RENDERER_ACCELERATED
#else
- // TODO: uncomment this later
+ // TODO: uncomment this later, also init FS before read config
SDL_RENDERER_ACCELERATED// | (getConfig()->useVsync ? SDL_RENDERER_PRESENTVSYNC : 0)
#endif
);
platform.texture = SDL_CreateTexture(platform.renderer, STUDIO_PIXEL_FORMAT, SDL_TEXTUREACCESS_STREAMING, TEXTURE_SIZE, TEXTURE_SIZE);
- platform.studio = studioInit(argc, argv, platform.audio.spec.freq);
+ platform.studio = studioInit(argc, argv, platform.audio.spec.freq, getAppFolder(), &sysHandlers);
initTouchGamepad();
@@ -902,32 +994,3 @@ s32 main(s32 argc, char **argv)
return 0;
}
-
-
-////////////////////////
-
-
-void setClipboardText(const char* text)
-{
- SDL_SetClipboardText(text);
-}
-
-bool hasClipboardText()
-{
- return SDL_HasClipboardText();
-}
-
-char* getClipboardText()
-{
- return SDL_GetClipboardText();
-}
-
-u64 getPerformanceCounter()
-{
- return SDL_GetPerformanceCounter();
-}
-
-u64 getPerformanceFrequency()
-{
- return SDL_GetPerformanceFrequency();
-}
\ No newline at end of file
diff --git a/src/studio.c b/src/studio.c
index da5fae9..7c227b3 100644
--- a/src/studio.c
+++ b/src/studio.c
@@ -88,6 +88,7 @@ static const EditorMode Modes[] =
static struct
{
Studio studio;
+ System* system;
tic80_local* tic80local;
@@ -2927,13 +2928,15 @@ static void emstick()
#endif
-Studio* studioInit(s32 argc, char **argv, s32 samplerate)
+Studio* studioInit(s32 argc, char **argv, s32 samplerate, const char* folder, System* system)
{
setbuf(stdout, NULL);
studioImpl.argc = argc;
studioImpl.argv = argv;
studioImpl.samplerate = samplerate;
+ studioImpl.system = system;
+
#if defined(__EMSCRIPTEN__)
if(studioImpl.argc == 2)
@@ -2946,7 +2949,7 @@ Studio* studioInit(s32 argc, char **argv, s32 samplerate)
#else
- createFileSystem(argc > 1 && fsExists(argv[1]) ? fsBasename(argv[1]) : NULL, onFSInitialized);
+ createFileSystem(argc > 1 && fsExists(argv[1]) ? fsBasename(argv[1]) : folder, onFSInitialized);
#endif
@@ -3031,7 +3034,7 @@ void studioTick(void* pixels)
void studioClose()
{
- closeNet(studioImpl.surf->net);
+ _closeNet(studioImpl.surf->net);
{
for(s32 i = 0; i < TIC_EDITOR_BANKS; i++)
@@ -3075,4 +3078,54 @@ void studioClose()
// #endif
// exit(0);
+}
+
+void setClipboardText(const char* text)
+{
+ studioImpl.system->setClipboardText(text);
+}
+
+bool hasClipboardText()
+{
+ return studioImpl.system->hasClipboardText();
+}
+
+char* getClipboardText()
+{
+ return studioImpl.system->getClipboardText();
+}
+
+u64 getPerformanceCounter()
+{
+ return studioImpl.system->getPerformanceCounter();
+}
+
+u64 getPerformanceFrequency()
+{
+ return studioImpl.system->getPerformanceFrequency();
+}
+
+NetVersion _netVersionRequest(Net* net)
+{
+ return studioImpl.system->netVersionRequest(net);
+}
+
+void _netDirRequest(Net* net, const char* path, ListCallback callback, void* data)
+{
+ return studioImpl.system->netDirRequest(net, path, callback, data);
+}
+
+void* _netGetRequest(Net* net, const char* path, s32* size)
+{
+ return studioImpl.system->netGetRequest(net, path, size);
+}
+
+Net* _createNet()
+{
+ return studioImpl.system->createNet();
+}
+
+void _closeNet(Net* net)
+{
+ return studioImpl.system->closeNet(net);
}
\ No newline at end of file
diff --git a/src/studio.h b/src/studio.h
index 4e8f105..01f2e07 100644
--- a/src/studio.h
+++ b/src/studio.h
@@ -37,6 +37,7 @@
#include "ticapi.h"
#include "defines.h"
#include "tools.h"
+#include "net.h"
#define TIC_LOCAL ".local/"
#define TIC_CACHE TIC_LOCAL "cache/"
@@ -187,7 +188,7 @@ void showTooltip(const char* text);
tic_key* getKeymap();
-const StudioConfig* getConfig();
+TIC80_API const StudioConfig* getConfig();
void setSpritePixel(tic_tile* tiles, s32 x, s32 y, u8 color);
u8 getSpritePixel(tic_tile* tiles, s32 x, s32 y);
@@ -217,9 +218,25 @@ typedef struct
} Studio;
-Studio* studioInit(s32 argc, char **argv, s32 samplerate);
-void studioTick(void* pixels);
-void studioClose();
+typedef struct
+{
+ void (*setClipboardText)(const char* text);
+ bool (*hasClipboardText)();
+ char* (*getClipboardText)();
+ u64 (*getPerformanceCounter)();
+ u64 (*getPerformanceFrequency)();
+
+ NetVersion (*netVersionRequest)(Net* net);
+ void (*netDirRequest)(Net* net, const char* path, ListCallback callback, void* data);
+ void* (*netGetRequest)(Net* net, const char* path, s32* size);
+ Net* (*createNet)();
+ void (*closeNet)(Net* net);
+
+} System;
+
+TIC80_API Studio* studioInit(s32 argc, char **argv, s32 samplerate, const char* appFolder, System* system);
+TIC80_API void studioTick(void* pixels);
+TIC80_API void studioClose();
char getKeyboardText();
bool isKeyWasDown(tic_key key);
@@ -231,3 +248,9 @@ char* getClipboardText();
u64 getPerformanceCounter();
u64 getPerformanceFrequency();
+
+NetVersion _netVersionRequest(Net* net);
+void _netDirRequest(Net* net, const char* path, ListCallback callback, void* data);
+void* _netGetRequest(Net* net, const char* path, s32* size);
+Net* _createNet();
+void _closeNet(Net* net);
diff --git a/src/surf.c b/src/surf.c
index 98f6d7a..67a4fd6 100644
--- a/src/surf.c
+++ b/src/surf.c
@@ -478,7 +478,7 @@ static void* requestCover(Surf* surf, const char* hash, s32* size)
char path[FILENAME_MAX] = {0};
sprintf(path, "/cart/%s/cover.gif", hash);
- void* data = netGetRequest(surf->net, path, size);
+ void* data = _netGetRequest(surf->net, path, size);
if(data)
{
@@ -865,7 +865,7 @@ void initSurf(Surf* surf, tic_mem* tic, struct Console* console)
.items = NULL,
.count = 0,
},
- .net = createNet(),
+ .net = _createNet(),
};
fsMakeDir(surf->fs, TIC_CACHE);
diff --git a/src/tools.h b/src/tools.h
index c18b037..bb1d121 100644
--- a/src/tools.h
+++ b/src/tools.h
@@ -51,4 +51,4 @@ bool tic_tool_parse_note(const char* noteStr, s32* note, s32* octave);
s32 tic_tool_get_pattern_id(const tic_track* track, s32 frame, s32 channel);
void tic_tool_set_pattern_id(tic_track* track, s32 frame, s32 channel, s32 id);
u32 tic_tool_find_closest_color(const tic_rgb* palette, const tic_rgb* color);
-u32* tic_palette_blit(const tic_palette* src);
\ No newline at end of file
+TIC80_API u32* tic_palette_blit(const tic_palette* src);
\ No newline at end of file