temporary disabled html export
This commit is contained in:
parent
e55b2a2f9a
commit
2bfe213f61
|
@ -1 +1 @@
|
||||||
Subproject commit b2e59affe6cb68b403d3b3d2f0f83b794a37c318
|
Subproject commit ad41cab4620ac249ea8414ebd83b6e636cc024a5
|
|
@ -335,8 +335,6 @@ if(NOT EMSCRIPTEN)
|
||||||
|
|
||||||
list(APPEND DEMO_CARTS
|
list(APPEND DEMO_CARTS
|
||||||
${CMAKE_SOURCE_DIR}/config.tic
|
${CMAKE_SOURCE_DIR}/config.tic
|
||||||
${CMAKE_SOURCE_DIR}/build/html/index.html
|
|
||||||
${CMAKE_SOURCE_DIR}/build/html/tic.js
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(DEMO_CARTS_OUT)
|
set(DEMO_CARTS_OUT)
|
||||||
|
@ -383,7 +381,6 @@ set(TIC80LIB_SRC
|
||||||
${TIC80LIB_DIR}/dialog.c
|
${TIC80LIB_DIR}/dialog.c
|
||||||
${TIC80LIB_DIR}/menu.c
|
${TIC80LIB_DIR}/menu.c
|
||||||
${TIC80LIB_DIR}/surf.c
|
${TIC80LIB_DIR}/surf.c
|
||||||
${TIC80LIB_DIR}/html.c
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(TIC80_OUTPUTS tic80 tic80pro)
|
set(TIC80_OUTPUTS tic80 tic80pro)
|
||||||
|
|
File diff suppressed because one or more lines are too long
179
src/console.c
179
src/console.c
|
@ -1858,124 +1858,6 @@ static void *ticMemmem(const void* haystack, size_t hlen, const void* needle, si
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
Console* console;
|
|
||||||
const char* cartName;
|
|
||||||
} AppFileReadParam;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
u8* data;
|
|
||||||
size_t size;
|
|
||||||
} MemoryBuffer;
|
|
||||||
|
|
||||||
static void writeMemoryData(MemoryBuffer* memory, const u8* src, size_t size)
|
|
||||||
{
|
|
||||||
memcpy(memory->data + memory->size, src, size);
|
|
||||||
memory->size += size;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void writeMemoryString(MemoryBuffer* memory, const char* str)
|
|
||||||
{
|
|
||||||
size_t size = strlen(str);
|
|
||||||
memcpy(memory->data + memory->size, str, size);
|
|
||||||
memory->size += size;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void onConsoleExportHtmlCommand(Console* console, const char* name)
|
|
||||||
{
|
|
||||||
tic_mem* tic = console->tic;
|
|
||||||
|
|
||||||
char cartName[FILENAME_MAX];
|
|
||||||
strcpy(cartName, name);
|
|
||||||
|
|
||||||
{
|
|
||||||
static const char HtmlExt[] = ".html";
|
|
||||||
const char* pos = NULL;
|
|
||||||
|
|
||||||
if((pos = strstr(name, HtmlExt)) && strcmp(pos, HtmlExt) == 0);
|
|
||||||
else strcat(cartName, HtmlExt);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern const u8 EmbedIndexZip[];
|
|
||||||
extern const s32 EmbedIndexZipSize;
|
|
||||||
extern const u8 EmbedTicJsZip[];
|
|
||||||
extern const s32 EmbedTicJsZipSize;
|
|
||||||
|
|
||||||
static const char Placeholder[] = "<script async type=\"text/javascript\" src=\"tic.js\"></script>";
|
|
||||||
|
|
||||||
u8* EmbedIndex = NULL;
|
|
||||||
u32 EmbedIndexSize = unzip(&EmbedIndex, EmbedIndexZip, EmbedIndexZipSize);
|
|
||||||
|
|
||||||
u8* EmbedTicJs = NULL;
|
|
||||||
u32 EmbedTicJsSize = unzip(&EmbedTicJs, EmbedTicJsZip, EmbedTicJsZipSize);
|
|
||||||
|
|
||||||
u8* ptr = ticMemmem(EmbedIndex, EmbedIndexSize, Placeholder, sizeof(Placeholder)-1);
|
|
||||||
|
|
||||||
if(ptr)
|
|
||||||
{
|
|
||||||
MemoryBuffer output = {(u8*)malloc(EmbedTicJsSize * 2), 0};
|
|
||||||
|
|
||||||
if(output.data)
|
|
||||||
{
|
|
||||||
writeMemoryData(&output, EmbedIndex, ptr - EmbedIndex);
|
|
||||||
writeMemoryString(&output, "<script type='text/javascript'>\n");
|
|
||||||
|
|
||||||
u8* buffer = (u8*)malloc(sizeof(tic_cartridge));
|
|
||||||
|
|
||||||
if(buffer)
|
|
||||||
{
|
|
||||||
writeMemoryString(&output, "var cartridge = [");
|
|
||||||
|
|
||||||
s32 size = tic->api.save(&tic->cart, buffer);
|
|
||||||
|
|
||||||
if(size)
|
|
||||||
{
|
|
||||||
// zip buffer
|
|
||||||
{
|
|
||||||
unsigned long outSize = sizeof(tic_cartridge);
|
|
||||||
u8* output = (u8*)malloc(outSize);
|
|
||||||
|
|
||||||
compress2(output, &outSize, buffer, size, Z_BEST_COMPRESSION);
|
|
||||||
free(buffer);
|
|
||||||
|
|
||||||
buffer = output;
|
|
||||||
size = outSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
u8* ptr = buffer;
|
|
||||||
u8* end = ptr + size;
|
|
||||||
|
|
||||||
char value[] = "999,";
|
|
||||||
while(ptr != end)
|
|
||||||
{
|
|
||||||
sprintf(value, "%i,", *ptr++);
|
|
||||||
writeMemoryString(&output, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
free(buffer);
|
|
||||||
|
|
||||||
writeMemoryString(&output, "];\n");
|
|
||||||
|
|
||||||
writeMemoryData(&output, EmbedTicJs, EmbedTicJsSize);
|
|
||||||
writeMemoryString(&output, "</script>\n");
|
|
||||||
|
|
||||||
ptr += sizeof(Placeholder)-1;
|
|
||||||
writeMemoryData(&output, ptr, EmbedIndexSize - (ptr - EmbedIndex));
|
|
||||||
|
|
||||||
fsGetFileData(onFileDownloaded, cartName, output.data, output.size, DEFAULT_CHMOD, console);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
free(EmbedIndex);
|
|
||||||
free(EmbedTicJs);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CAN_EXPORT)
|
#if defined(CAN_EXPORT)
|
||||||
|
|
||||||
static void* embedCart(Console* console, s32* size)
|
static void* embedCart(Console* console, s32* size)
|
||||||
|
@ -2054,20 +1936,15 @@ static void onConsoleExportNativeCommand(Console* console, const char* cartName)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char* getExportName(Console* console, bool html)
|
static const char* getExportName(Console* console)
|
||||||
{
|
{
|
||||||
static char name[FILENAME_MAX];
|
static char name[FILENAME_MAX];
|
||||||
|
|
||||||
strcpy(name, strlen(console->romName) ? console->romName : "game");
|
strcpy(name, strlen(console->romName) ? console->romName : "game");
|
||||||
|
|
||||||
if(html)
|
|
||||||
strcat(name, ".html");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#if defined(__TIC_WINDOWS__)
|
#if defined(__TIC_WINDOWS__)
|
||||||
strcat(name, ExeExt);
|
strcat(name, ExeExt);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -2076,42 +1953,38 @@ static void onConsoleExportCommand(Console* console, const char* param)
|
||||||
{
|
{
|
||||||
if(param)
|
if(param)
|
||||||
{
|
{
|
||||||
if(strcmp(param, "html") == 0) onConsoleExportHtmlCommand(console, getExportName(console, true));
|
if(strcmp(param, "native") == 0)
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if(strcmp(param, "native") == 0)
|
|
||||||
{
|
|
||||||
#if defined(CAN_EXPORT)
|
#if defined(CAN_EXPORT)
|
||||||
onConsoleExportNativeCommand(console, getExportName(console, false));
|
onConsoleExportNativeCommand(console, getExportName(console));
|
||||||
#else
|
#else
|
||||||
|
|
||||||
printBack(console, "\nnative export isn't supported on this platform\n");
|
printBack(console, "\nnative export isn't supported on this platform\n");
|
||||||
commandDone(console);
|
commandDone(console);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if(strcmp(param, "sprites") == 0)
|
else if(strcmp(param, "sprites") == 0)
|
||||||
{
|
{
|
||||||
exportSprites(console);
|
exportSprites(console);
|
||||||
}
|
}
|
||||||
else if(strcmp(param, "map") == 0)
|
else if(strcmp(param, "map") == 0)
|
||||||
{
|
{
|
||||||
exportMap(console);
|
exportMap(console);
|
||||||
}
|
}
|
||||||
else if(strcmp(param, "cover") == 0)
|
else if(strcmp(param, "cover") == 0)
|
||||||
{
|
{
|
||||||
exportCover(console);
|
exportCover(console);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printError(console, "\nunknown parameter: ");
|
printError(console, "\nunknown parameter: ");
|
||||||
printError(console, param);
|
printError(console, param);
|
||||||
commandDone(console);
|
commandDone(console);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
onConsoleExportHtmlCommand(console, getExportName(console, true));
|
onConsoleExportNativeCommand(console, getExportName(console));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2465,7 +2338,7 @@ static const struct
|
||||||
#endif
|
#endif
|
||||||
{"add", NULL, "add file", onConsoleAddCommand},
|
{"add", NULL, "add file", onConsoleAddCommand},
|
||||||
{"get", NULL, "download file", onConsoleGetCommand},
|
{"get", NULL, "download file", onConsoleGetCommand},
|
||||||
{"export", NULL, "export html or native game", onConsoleExportCommand},
|
{"export", NULL, "export native game", onConsoleExportCommand},
|
||||||
{"import", NULL, "import sprites from .gif", onConsoleImportCommand},
|
{"import", NULL, "import sprites from .gif", onConsoleImportCommand},
|
||||||
{"del", NULL, "delete file or dir", onConsoleDelCommand},
|
{"del", NULL, "delete file or dir", onConsoleDelCommand},
|
||||||
{"cls", NULL, "clear screen", onConsoleClsCommand},
|
{"cls", NULL, "clear screen", onConsoleClsCommand},
|
||||||
|
|
37
src/html.c
37
src/html.c
|
@ -1,37 +0,0 @@
|
||||||
// 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 <tic80_types.h>
|
|
||||||
|
|
||||||
const u8 EmbedIndexZip[] =
|
|
||||||
{
|
|
||||||
#include "../bin/assets/index.html.dat"
|
|
||||||
};
|
|
||||||
|
|
||||||
const s32 EmbedIndexZipSize = sizeof EmbedIndexZip;
|
|
||||||
|
|
||||||
const u8 EmbedTicJsZip[] =
|
|
||||||
{
|
|
||||||
#include "../bin/assets/tic.js.dat"
|
|
||||||
};
|
|
||||||
|
|
||||||
const s32 EmbedTicJsZipSize = sizeof EmbedTicJsZip;
|
|
Loading…
Reference in New Issue