From 392e006a4acd68b49f1a5d046ff053b00a660e71 Mon Sep 17 00:00:00 2001 From: Matheus Lessa Date: Mon, 16 Oct 2017 01:03:05 -0200 Subject: [PATCH] first version working with no option to disable live reloading --- src/console.c | 192 +++++++++++++++++++++++++++++--------------------- src/console.h | 10 ++- src/studio.c | 161 ++++++++++++++++++++++-------------------- 3 files changed, 206 insertions(+), 157 deletions(-) diff --git a/src/console.c b/src/console.c index 967a980..39f0133 100644 --- a/src/console.c +++ b/src/console.c @@ -122,7 +122,7 @@ static void consolePrint(Console* console, const char* text, u8 color) console->cursor.x = 0; console->cursor.y++; } - else + else { s32 offset = console->cursor.x + console->cursor.y * CONSOLE_BUFFER_WIDTH; *(console->buffer + offset) = symbol; @@ -182,7 +182,7 @@ static void drawCursor(Console* console, s32 x, s32 y, u8 symbol) if(inverse) console->tic->api.rect(console->tic, x-1, y-1, TIC_FONT_WIDTH+1, TIC_FONT_HEIGHT+1, CONSOLE_CURSOR_COLOR); - + console->tic->api.draw_char(console->tic, symbol, x, y, inverse ? TIC_COLOR_BG : CONSOLE_FRONT_TEXT_COLOR); } @@ -260,7 +260,7 @@ static void processConsoleDel(Console* console) { char* pos = console->inputBuffer + console->inputPosition; size_t size = strlen(pos); - memmove(pos, pos + 1, size); + memmove(pos, pos + 1, size); } static void processConsoleBackspace(Console* console) @@ -269,7 +269,7 @@ static void processConsoleBackspace(Console* console) { console->inputPosition--; - processConsoleDel(console); + processConsoleDel(console); } } @@ -322,7 +322,7 @@ static bool onConsoleLoadSectionCommand(Console* console, const char* param) if(param) { - static const char* Sections[] = + static const char* Sections[] = { "sprites", "map", @@ -416,21 +416,21 @@ static void* getDemoCart(Console* console, tic_script_lang script, s32* size) return data; } - static const u8 LuaDemoRom[] = + static const u8 LuaDemoRom[] = { #include "../bin/assets/luademo.tic.dat" }; - static const u8 JsDemoRom[] = + static const u8 JsDemoRom[] = { #include "../bin/assets/jsdemo.tic.dat" }; - static const u8 MoonDemoRom[] = + static const u8 MoonDemoRom[] = { #include "../bin/assets/moondemo.tic.dat" }; - + const u8* demo = NULL; s32 romSize = 0; @@ -467,7 +467,7 @@ static void onConsoleLoadDemoCommandConfirmed(Console* console, const char* para s32 size = 0; console->showGameMenu = false; - + if(strcmp(param, DefaultLuaTicPath) == 0) data = getDemoCart(console, tic_script_lua, &size); else if(strcmp(param, DefaultMoonTicPath) == 0) @@ -499,7 +499,7 @@ static void onConsoleLoadCommandConfirmed(Console* console, const char* param) s32 size = 0; const char* name = getRomName(param); - void* data = strcmp(name, CONFIG_TIC_PATH) == 0 + void* data = strcmp(name, CONFIG_TIC_PATH) == 0 ? fsLoadRootFile(console->fs, name, &size) : fsLoadFile(console->fs, name, &size); @@ -568,7 +568,7 @@ static void onConsoleLoadDemoCommand(Console* console, const char* param) { if(studioCartChanged()) { - static const char* Rows[] = + static const char* Rows[] = { "YOU HAVE", "UNSAVED CHANGES", @@ -589,7 +589,7 @@ static void onConsoleLoadCommand(Console* console, const char* param) { if(studioCartChanged()) { - static const char* Rows[] = + static const char* Rows[] = { "YOU HAVE", "UNSAVED CHANGES", @@ -615,7 +615,7 @@ static void loadDemo(Console* console, tic_script_lang script) { loadRom(console->tic, data, size, false); - SDL_free(data); + SDL_free(data); } SDL_memset(console->romName, 0, sizeof console->romName); @@ -651,7 +651,7 @@ static void onConsoleNewCommand(Console* console, const char* param) { if(studioCartChanged()) { - static const char* Rows[] = + static const char* Rows[] = { "YOU HAVE", "UNSAVED CHANGES", @@ -779,42 +779,42 @@ static void installDemoCart(FileSystem* fs, const char* name, const void* cart, static void onConsoleInstallDemosCommand(Console* console, const char* param) { - static const u8 DemoFire[] = + static const u8 DemoFire[] = { #include "../bin/assets/fire.tic.dat" }; - static const u8 DemoP3D[] = + static const u8 DemoP3D[] = { #include "../bin/assets/p3d.tic.dat" }; - static const u8 DemoSFX[] = + static const u8 DemoSFX[] = { #include "../bin/assets/sfx.tic.dat" }; - static const u8 DemoPalette[] = + static const u8 DemoPalette[] = { #include "../bin/assets/palette.tic.dat" }; - static const u8 DemoFont[] = + static const u8 DemoFont[] = { #include "../bin/assets/font.tic.dat" }; - static const u8 DemoMusic[] = + static const u8 DemoMusic[] = { #include "../bin/assets/music.tic.dat" }; - static const u8 GameQuest[] = + static const u8 GameQuest[] = { #include "../bin/assets/quest.tic.dat" }; - static const u8 GameTetris[] = + static const u8 GameTetris[] = { #include "../bin/assets/tetris.tic.dat" }; @@ -942,7 +942,7 @@ static void onImportCover(const char* name, const void* buffer, size_t size, voi printLine(console); printBack(console, name); - printBack(console, " successfully imported"); + printBack(console, " successfully imported"); } else printError(console, "\ncover image too big :("); } @@ -950,9 +950,9 @@ static void onImportCover(const char* name, const void* buffer, size_t size, voi gif_close(image); } - else printError(console, "\nfile importing error :("); + else printError(console, "\nfile importing error :("); } - else printBack(console, "\nonly .gif files can be imported :|"); + else printBack(console, "\nonly .gif files can be imported :|"); } else printBack(console, "\nfile not imported :|"); @@ -1006,7 +1006,7 @@ static void onImportSprites(const char* name, const void* buffer, size_t size, v } else printError(console, "\nfile importing error :("); } - else printBack(console, "\nonly .gif files can be imported :|"); + else printBack(console, "\nonly .gif files can be imported :|"); } else printBack(console, "\nfile not imported :|"); @@ -1091,7 +1091,7 @@ static void exportCover(Console* console) else { printBack(console, "\ncover image is empty, run game and\npress [F7] to assign cover image"); - commandDone(console); + commandDone(console); } } @@ -1215,7 +1215,7 @@ typedef struct const char* cartName; } AppFileReadParam; -typedef struct +typedef struct { u8* data; size_t size; @@ -1272,7 +1272,7 @@ static void onConsoleExportHtmlCommand(Console* console, const char* name) writeMemoryString(&output, "