diff --git a/Makefile b/Makefile
index f32d1f2..4477ca3 100644
--- a/Makefile
+++ b/Makefile
@@ -29,10 +29,6 @@ MINGW_LINKER_FLAGS= \
-lmingw32 \
-lSDL2main \
-lSDL2 \
- -lz \
- -lgif \
- -llua \
- -lwren \
-lcomdlg32 \
-lws2_32 \
-mwindows
diff --git a/build/windows/tic/tic.vcxproj b/build/windows/tic/tic.vcxproj
index 42de149..c81aa64 100644
--- a/build/windows/tic/tic.vcxproj
+++ b/build/windows/tic/tic.vcxproj
@@ -41,9 +41,6 @@
{81ce8daf-ebb2-4761-8e45-b71abcca8c68}
-
- {57d2471b-3138-495e-af18-6e290d098ffc}
-
{6181f6a6-aa1b-4cd2-b306-e242cfde9b20}
diff --git a/src/console.c b/src/console.c
index 64f8233..cfff713 100644
--- a/src/console.c
+++ b/src/console.c
@@ -2540,7 +2540,7 @@ static void checkNewVersion(Console* console)
if(net)
{
- NetVersion version = _netVersionRequest(net);
+ NetVersion version = netVersionRequest(net);
free(net);
if((version.major > TIC_VERSION_MAJOR) ||
diff --git a/src/fs.c b/src/fs.c
index c9c43aa..5271571 100644
--- a/src/fs.c
+++ b/src/fs.c
@@ -174,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;
}
diff --git a/src/main.c b/src/main.c
index 59b0b87..ee8fef2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -899,8 +899,6 @@ static System sysHandlers =
.getPerformanceCounter = getPerformanceCounter,
.getPerformanceFrequency = getPerformanceFrequency,
- .netVersionRequest = netVersionRequest,
- .netDirRequest = netDirRequest,
.netGetRequest = netGetRequest,
.createNet = createNet,
.closeNet = closeNet,
diff --git a/src/net.c b/src/net.c
index 7520f3e..fe81b57 100644
--- a/src/net.c
+++ b/src/net.c
@@ -24,9 +24,8 @@
#include "tic.h"
#include "SDL_net.h"
-#include
-#include
-#include
+#include
+#include
struct Net
{
@@ -178,124 +177,6 @@ static void getRequest(Net* net, const char* path, NetResponse callback, void* d
#endif
-static lua_State* netLuaInit(u8* buffer, s32 size)
-{
- if (buffer && size)
- {
- lua_State* lua = luaL_newstate();
-
- if(lua)
- {
- if(luaL_loadstring(lua, (char*)buffer) == LUA_OK && lua_pcall(lua, 0, LUA_MULTRET, 0) == LUA_OK)
- return lua;
-
- else lua_close(lua);
- }
- }
-
- return NULL;
-}
-
-typedef struct
-{
- ListCallback callback;
- void* data;
-} NetDirData;
-
-static void onDirResponse(u8* buffer, s32 size, void* data)
-{
- NetDirData* netDirData = (NetDirData*)data;
-
- lua_State* lua = netLuaInit(buffer, size);
-
- if(lua)
- {
- {
- lua_getglobal(lua, "folders");
-
- if(lua_type(lua, -1) == LUA_TTABLE)
- {
- s32 count = (s32)lua_rawlen(lua, -1);
-
- for(s32 i = 1; i <= count; i++)
- {
- lua_geti(lua, -1, i);
-
- {
- lua_getfield(lua, -1, "name");
- if(lua_isstring(lua, -1))
- netDirData->callback(lua_tostring(lua, -1), NULL, 0, netDirData->data, true);
-
- lua_pop(lua, 1);
- }
-
- lua_pop(lua, 1);
- }
- }
-
- lua_pop(lua, 1);
- }
-
- {
- lua_getglobal(lua, "files");
-
- if(lua_type(lua, -1) == LUA_TTABLE)
- {
- s32 count = (s32)lua_rawlen(lua, -1);
-
- for(s32 i = 1; i <= count; i++)
- {
- lua_geti(lua, -1, i);
-
- char hash[FILENAME_MAX] = {0};
- char name[FILENAME_MAX] = {0};
-
- {
- lua_getfield(lua, -1, "hash");
- if(lua_isstring(lua, -1))
- strcpy(hash, lua_tostring(lua, -1));
-
- lua_pop(lua, 1);
- }
-
- {
- lua_getfield(lua, -1, "name");
-
- if(lua_isstring(lua, -1))
- strcpy(name, lua_tostring(lua, -1));
-
- lua_pop(lua, 1);
- }
-
- {
- lua_getfield(lua, -1, "id");
-
- if(lua_isinteger(lua, -1))
- netDirData->callback(name, hash, lua_tointeger(lua, -1), netDirData->data, false);
-
- lua_pop(lua, 1);
- }
-
- lua_pop(lua, 1);
- }
- }
-
- lua_pop(lua, 1);
- }
-
- lua_close(lua);
- }
-}
-
-void netDirRequest(Net* net, const char* path, ListCallback callback, void* data)
-{
- char request[FILENAME_MAX] = {'\0'};
- sprintf(request, "/api?fn=dir&path=%s", path);
-
- NetDirData netDirData = {callback, data};
- getRequest(net, request, onDirResponse, &netDirData);
-}
-
typedef struct
{
void* buffer;
@@ -319,43 +200,6 @@ void* netGetRequest(Net* net, const char* path, s32* size)
return netGetData.buffer;
}
-NetVersion netVersionRequest(Net* net)
-{
- NetVersion version =
- {
- .major = TIC_VERSION_MAJOR,
- .minor = TIC_VERSION_MINOR,
- .patch = TIC_VERSION_PATCH,
- };
-
- s32 size = 0;
- void* buffer = netGetRequest(net, "/api?fn=version", &size);
-
- if(buffer && size)
- {
- lua_State* lua = netLuaInit(buffer, size);
-
- if(lua)
- {
- static const char* Fields[] = {"major", "minor", "patch"};
-
- for(s32 i = 0; i < COUNT_OF(Fields); i++)
- {
- lua_getglobal(lua, Fields[i]);
-
- if(lua_isinteger(lua, -1))
- ((s32*)&version)[i] = (s32)lua_tointeger(lua, -1);
-
- lua_pop(lua, 1);
- }
-
- lua_close(lua);
- }
- }
-
- return version;
-}
-
Net* createNet()
{
SDLNet_Init();
diff --git a/src/net.h b/src/net.h
index 0a98117..008930b 100644
--- a/src/net.h
+++ b/src/net.h
@@ -26,16 +26,6 @@
typedef struct Net Net;
-typedef struct
-{
- s32 major;
- s32 minor;
- s32 patch;
-} NetVersion;
-
-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* netGetRequest(Net* net, const char* path, s32* size);
void closeNet(Net* net);
\ No newline at end of file
diff --git a/src/studio.c b/src/studio.c
index 6cc0a27..334fe55 100644
--- a/src/studio.c
+++ b/src/studio.c
@@ -39,12 +39,18 @@
#include "fs.h"
-#include
-#include
#include "net.h"
#include "ext/gif.h"
#include "ext/md5.h"
+#include
+#include
+
+#include
+#include
+#include
+
+
// #define TEXTURE_SIZE (TIC80_FULLWIDTH)
// #define STUDIO_PIXEL_FORMAT SDL_PIXELFORMAT_ARGB8888
#define FRAME_SIZE (TIC80_FULLWIDTH * TIC80_FULLHEIGHT * sizeof(u32))
@@ -3105,16 +3111,6 @@ 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);
@@ -3139,3 +3135,161 @@ void _file_dialog_save(file_dialog_save_callback callback, const char* name, con
{
studioImpl.system->file_dialog_save(callback, name, buffer, size, data, mode);
}
+
+static lua_State* netLuaInit(u8* buffer, s32 size)
+{
+ if (buffer && size)
+ {
+ lua_State* lua = luaL_newstate();
+
+ if(lua)
+ {
+ if(luaL_loadstring(lua, (char*)buffer) == LUA_OK && lua_pcall(lua, 0, LUA_MULTRET, 0) == LUA_OK)
+ return lua;
+
+ else lua_close(lua);
+ }
+ }
+
+ return NULL;
+}
+
+NetVersion netVersionRequest(Net* net)
+{
+ NetVersion version =
+ {
+ .major = TIC_VERSION_MAJOR,
+ .minor = TIC_VERSION_MINOR,
+ .patch = TIC_VERSION_PATCH,
+ };
+
+ s32 size = 0;
+ void* buffer = _netGetRequest(net, "/api?fn=version", &size);
+
+ if(buffer && size)
+ {
+ lua_State* lua = netLuaInit(buffer, size);
+
+ if(lua)
+ {
+ static const char* Fields[] = {"major", "minor", "patch"};
+
+ for(s32 i = 0; i < COUNT_OF(Fields); i++)
+ {
+ lua_getglobal(lua, Fields[i]);
+
+ if(lua_isinteger(lua, -1))
+ ((s32*)&version)[i] = (s32)lua_tointeger(lua, -1);
+
+ lua_pop(lua, 1);
+ }
+
+ lua_close(lua);
+ }
+ }
+
+ return version;
+}
+
+typedef struct
+{
+ ListCallback callback;
+ void* data;
+} NetDirData;
+
+static void onDirResponse(u8* buffer, s32 size, void* data)
+{
+ NetDirData* netDirData = (NetDirData*)data;
+
+ lua_State* lua = netLuaInit(buffer, size);
+
+ if(lua)
+ {
+ {
+ lua_getglobal(lua, "folders");
+
+ if(lua_type(lua, -1) == LUA_TTABLE)
+ {
+ s32 count = (s32)lua_rawlen(lua, -1);
+
+ for(s32 i = 1; i <= count; i++)
+ {
+ lua_geti(lua, -1, i);
+
+ {
+ lua_getfield(lua, -1, "name");
+ if(lua_isstring(lua, -1))
+ netDirData->callback(lua_tostring(lua, -1), NULL, 0, netDirData->data, true);
+
+ lua_pop(lua, 1);
+ }
+
+ lua_pop(lua, 1);
+ }
+ }
+
+ lua_pop(lua, 1);
+ }
+
+ {
+ lua_getglobal(lua, "files");
+
+ if(lua_type(lua, -1) == LUA_TTABLE)
+ {
+ s32 count = (s32)lua_rawlen(lua, -1);
+
+ for(s32 i = 1; i <= count; i++)
+ {
+ lua_geti(lua, -1, i);
+
+ char hash[FILENAME_MAX] = {0};
+ char name[FILENAME_MAX] = {0};
+
+ {
+ lua_getfield(lua, -1, "hash");
+ if(lua_isstring(lua, -1))
+ strcpy(hash, lua_tostring(lua, -1));
+
+ lua_pop(lua, 1);
+ }
+
+ {
+ lua_getfield(lua, -1, "name");
+
+ if(lua_isstring(lua, -1))
+ strcpy(name, lua_tostring(lua, -1));
+
+ lua_pop(lua, 1);
+ }
+
+ {
+ lua_getfield(lua, -1, "id");
+
+ if(lua_isinteger(lua, -1))
+ netDirData->callback(name, hash, lua_tointeger(lua, -1), netDirData->data, false);
+
+ lua_pop(lua, 1);
+ }
+
+ lua_pop(lua, 1);
+ }
+ }
+
+ lua_pop(lua, 1);
+ }
+
+ lua_close(lua);
+ }
+}
+
+void netDirRequest(Net* net, const char* path, ListCallback callback, void* data)
+{
+ char request[FILENAME_MAX] = {'\0'};
+ sprintf(request, "/api?fn=dir&path=%s", path);
+
+ s32 size = 0;
+ void* buffer = _netGetRequest(net, request, &size);
+
+ NetDirData netDirData = {callback, data};
+ onDirResponse(buffer, size, &netDirData);
+}
\ No newline at end of file
diff --git a/src/studio.h b/src/studio.h
index 23210db..3225b1f 100644
--- a/src/studio.h
+++ b/src/studio.h
@@ -227,8 +227,6 @@ typedef struct
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);
@@ -253,11 +251,19 @@ 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);
void _file_dialog_load(file_dialog_load_callback callback, void* data);
void _file_dialog_save(file_dialog_save_callback callback, const char* name, const u8* buffer, size_t size, void* data, u32 mode);
+
+typedef struct
+{
+ s32 major;
+ s32 minor;
+ s32 patch;
+} NetVersion;
+
+NetVersion netVersionRequest(Net* net);
+void netDirRequest(Net* net, const char* path, ListCallback callback, void* data);
diff --git a/src/surf.c b/src/surf.c
index 67a4fd6..41327f3 100644
--- a/src/surf.c
+++ b/src/surf.c
@@ -494,7 +494,6 @@ static void updateMenuItemCover(Surf* surf, const u8* cover, s32 size)
MenuItem* item = &surf->menu.items[surf->menu.pos];
-
item->cover = malloc(sizeof(tic_screen));
gif_image* image = gif_read_data(cover, size);