From 1c8e5b2945153305d0795921c2b3ea4d0d4e0d1d Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Thu, 9 Nov 2017 20:34:03 +0300 Subject: [PATCH 01/13] no message --- Makefile | 14 +++++--- src/console.c | 93 +++++++++++++++++++++++++++++++++++++++++++++------ src/tic.c | 2 +- 3 files changed, 93 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 052656e..325a5d4 100644 --- a/Makefile +++ b/Makefile @@ -274,16 +274,20 @@ emscripten: 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) -run: mingw +mingw-pro: + $(eval OPT += -DTIC80_PRO) + make mingw OPT="$(OPT)" + +run: mingw-pro $(MINGW_OUTPUT) -linux64-flto: +linux64-lto: $(CC) $(LINUX_INCLUDES) $(SOURCES) $(TIC80_SRC) $(SOURCES_EXT) $(OPT) $(INCLUDES) $(LINUX64_LIBS) $(LINUX_LINKER_FLAGS) -flto -o bin/tic -linux32-flto: +linux32-lto: $(CC) $(LINUX_INCLUDES) $(SOURCES) $(TIC80_SRC) $(SOURCES_EXT) $(OPT) $(INCLUDES) $(LINUX32_LIBS) $(LINUX_LINKER_FLAGS) -flto -o bin/tic -arm-flto: +arm-lto: $(CC) $(OPT_ARM) $(SOURCES) $(TIC80_SRC) $(OPT) $(INCLUDES) $(LINUX_ARM_LIBS) $(LINUX_LINKER_FLAGS) -flto -o bin/tic linux: @@ -339,4 +343,4 @@ bin/assets/moondemo.tic.dat: demos/moondemo.tic $(BIN2TXT) $< $@ -z clean: $(TIC_O) $(TIC80_O) - $(RM) $(TIC_O) $(TIC80_O) + del bin\*.o diff --git a/src/console.c b/src/console.c index fd872e6..66fae40 100644 --- a/src/console.c +++ b/src/console.c @@ -490,6 +490,69 @@ static void onConsoleLoadDemoCommandConfirmed(Console* console, const char* para SDL_free(data); } +static void onCartLoaded(Console* console, const char* name) +{ + strcpy(console->romName, name); + + studioRomLoaded(); + + printBack(console, "\ncart "); + printFront(console, console->romName); + printBack(console, " loaded!\nuse "); + printFront(console, "RUN"); + printBack(console, " command to run it\n"); + +} + +#if defined(TIC80_PRO) + +static void loadProjectCode(Console* console, const void* data, s32 size) +{ + tic_mem* tic = console->tic; + + SDL_memcpy(tic->cart.code.data, data, SDL_min(size, sizeof(tic_code))); +} + +static void loadProject(Console* console, const char* name) +{ + tic_mem* tic = console->tic; + + SDL_memset(&tic->cart, 0, sizeof(tic_cartridge)); + + static struct{const char* name; void(*func)(Console* console, const void* data, s32 size);} ProjectFiles[] = + { + {"code.lua", loadProjectCode}, + {"sprites.gif", NULL}, + {"tiles.gif", NULL}, + {"palette.dat", NULL}, + {"map.dat", NULL}, + {"waves.dat", NULL}, + {"sfx.dat", NULL}, + {"music.dat", NULL}, + {"cover.gif", NULL}, + }; + + for(s32 i = 0; i < COUNT_OF(ProjectFiles); i++) + { + char path[FILENAME_MAX]; + sprintf(path, "%s/%s", name, ProjectFiles[i].name); + + s32 size = 0; + void* data = fsLoadFile(console->fs, path, &size); + + if(data) + { + ProjectFiles[i].func(console, data, size); + SDL_free(data); + } + } + + onCartLoaded(console, name); + + commandDone(console); +} +#endif + static void onConsoleLoadCommandConfirmed(Console* console, const char* param) { if(onConsoleLoadSectionCommand(console, param)) return; @@ -499,6 +562,14 @@ static void onConsoleLoadCommandConfirmed(Console* console, const char* param) s32 size = 0; const char* name = getRomName(param); +#if defined(TIC80_PRO) + if(fsIsDir(console->fs, name)) + { + loadProject(console, name); + return; + } +#endif + void* data = strcmp(name, CONFIG_TIC_PATH) == 0 ? fsLoadRootFile(console->fs, name, &size) : fsLoadFile(console->fs, name, &size); @@ -507,21 +578,16 @@ static void onConsoleLoadCommandConfirmed(Console* console, const char* param) { console->showGameMenu = fsIsInPublicDir(console->fs); - strcpy(console->romName, name); - loadRom(console->tic, data, size, true); - studioRomLoaded(); - - printBack(console, "\ncart "); - printFront(console, console->romName); - printBack(console, " loaded!\nuse "); - printFront(console, "RUN"); - printBack(console, " command to run it\n"); + onCartLoaded(console, name); SDL_free(data); } - else printBack(console, "\ncart loading error"); + else + { + printBack(console, "\ncart loading error"); + } } else printBack(console, "\ncart name is missing"); @@ -676,13 +742,20 @@ typedef struct static bool printFilename(const char* name, const char* info, s32 id, void* data, bool dir) { + PrintFileNameData* printData = data; Console* console = printData->console; printLine(console); +#if defined(TIC80_PRO) + if(dir && SDL_strstr(name, CartExt) == (name + SDL_strlen(name) - SDL_strlen(CartExt))) + dir = false; +#endif + if(dir) { + printBack(console, "["); printBack(console, name); printBack(console, "]"); diff --git a/src/tic.c b/src/tic.c index 6b565b8..99c1a11 100644 --- a/src/tic.c +++ b/src/tic.c @@ -53,7 +53,7 @@ typedef enum CHUNK_TEMP3, // 8 CHUNK_SOUND, // 9 CHUNK_WAVEFORM, // 10 - CHUNK_OLDMUSIC, // 11 + CHUNK_TEMP4, // 11 CHUNK_PALETTE, // 12 CHUNK_PATTERNS, // 13 CHUNK_MUSIC, // 14 From ab46e65c42657b1243d0f4ad891bb67711709c97 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Fri, 10 Nov 2017 16:38:19 +0300 Subject: [PATCH 02/13] no message --- src/console.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/src/console.c b/src/console.c index 66fae40..7b99b02 100644 --- a/src/console.c +++ b/src/console.c @@ -1619,6 +1619,124 @@ static void onConsoleExportCommand(Console* console, const char* param) #endif +#if defined(TIC80_PRO) + +static void buf2str(const void* data, s32 size, char* ptr, bool flip) +{ + enum {Len = 2}; + + for(s32 i = 0; i < size; i++, ptr+=Len) + { + sprintf(ptr, "%02x", ((u8*)data)[i]); + + if(flip) + { + char tmp = ptr[0]; + ptr[0] = ptr[1]; + ptr[1] = tmp; + } + } +} + +static char* printBuf(char* ptr, const void* data, s32 size) +{ + sprintf(ptr, "-- "); + ptr += strlen(ptr); + + buf2str(data, size, ptr, true); + ptr += strlen(ptr); + + sprintf(ptr, "\n"); + ptr += strlen(ptr); + + return ptr; +} + +static char* printTag(char* ptr, const char* tag) +{ + sprintf(ptr, "\n-- %s:\n", tag); + ptr += strlen(ptr); + + return ptr; +} + +static CartSaveResult saveProject(Console* console, const char* name) +{ + tic_mem* tic = console->tic; + + char* stream = (char*)SDL_malloc(sizeof(tic_cartridge) * 3); + + if(stream) + { + char* ptr = stream; + + strcpy(ptr, tic->cart.code.data); + ptr += strlen(ptr); + + { + ptr = printTag(ptr, "PALETTE"); + ptr = printBuf(ptr, tic->cart.palette.data, sizeof tic->cart.palette.data); + } + + { + ptr = printTag(ptr, "TILES"); + + for(s32 i = 0; i < TIC_BANK_SPRITES; i+=16) + ptr = printBuf(ptr, tic->cart.gfx.tiles[i].data, sizeof tic->cart.gfx.tiles / 16); + } + + { + ptr = printTag(ptr, "SPRITES"); + + for(s32 i = 0; i < TIC_BANK_SPRITES; i+=16) + ptr = printBuf(ptr, tic->cart.gfx.sprites[i].data, sizeof tic->cart.gfx.sprites / 16); + } + + { + ptr = printTag(ptr, "MAP"); + + for(s32 i = 0; i < TIC_MAP_WIDTH * TIC_MAP_HEIGHT; i += TIC_MAP_WIDTH) + ptr = printBuf(ptr, &tic->cart.gfx.map.data[i], sizeof tic->cart.gfx.map / TIC_MAP_HEIGHT); + } + + { + ptr = printTag(ptr, "WAVES"); + + for(s32 i = 0; i < ENVELOPES_COUNT; i++) + ptr = printBuf(ptr, tic->cart.sound.sfx.waveform.envelopes[i].data, sizeof(tic_waveform)); + } + + { + ptr = printTag(ptr, "SFX"); + + for(s32 i = 0; i < SFX_COUNT; i++) + ptr = printBuf(ptr, &tic->cart.sound.sfx.data[i], sizeof(tic_sound_effect)); + } + + { + ptr = printTag(ptr, "PATTERNS"); + + for(s32 i = 0; i < MUSIC_PATTERNS; i++) + ptr = printBuf(ptr, &tic->cart.sound.music.patterns.data[i], sizeof(tic_track_pattern)); + } + + { + ptr = printTag(ptr, "TRACKS"); + + for(s32 i = 0; i < MUSIC_TRACKS; i++) + ptr = printBuf(ptr, &tic->cart.sound.music.tracks.data[i], sizeof(tic_track)); + } + + fsWriteFile(name, stream, strlen(stream)); + + SDL_free(stream); + } + + return CART_SAVE_ERROR; +} + +#endif + static CartSaveResult saveCartName(Console* console, const char* name) { tic_mem* tic = console->tic; @@ -1672,7 +1790,11 @@ static CartSaveResult saveCart(Console* console) static void onConsoleSaveCommandConfirmed(Console* console, const char* param) { +#if defined(TIC80_PRO) + CartSaveResult rom = saveProject(console, param); +#else CartSaveResult rom = saveCartName(console, param); +#endif if(rom == CART_SAVE_OK) { From 0e72cdbd8d87a33066708cd799d5414204373f01 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Fri, 10 Nov 2017 17:40:45 +0300 Subject: [PATCH 03/13] no message --- src/console.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/console.c b/src/console.c index 7b99b02..9f006ae 100644 --- a/src/console.c +++ b/src/console.c @@ -1638,9 +1638,22 @@ static void buf2str(const void* data, s32 size, char* ptr, bool flip) } } -static char* printBuf(char* ptr, const void* data, s32 size) +static char* printBuf(char* ptr, const void* data, s32 size, s32 row) { - sprintf(ptr, "-- "); + { + bool empty = true; + const u8* dataPtr = data; + for(s32 i = 0; i < size; i++) + if(*dataPtr++) + { + empty = false; + break; + } + + if(empty) return ptr; + } + + sprintf(ptr, "-- %03i:", row); ptr += strlen(ptr); buf2str(data, size, ptr, true); @@ -1675,56 +1688,56 @@ static CartSaveResult saveProject(Console* console, const char* name) { ptr = printTag(ptr, "PALETTE"); - ptr = printBuf(ptr, tic->cart.palette.data, sizeof tic->cart.palette.data); + ptr = printBuf(ptr, tic->cart.palette.data, sizeof tic->cart.palette.data, 0); } { ptr = printTag(ptr, "TILES"); - for(s32 i = 0; i < TIC_BANK_SPRITES; i+=16) - ptr = printBuf(ptr, tic->cart.gfx.tiles[i].data, sizeof tic->cart.gfx.tiles / 16); + for(s32 i = 0; i < TIC_BANK_SPRITES; i++) + ptr = printBuf(ptr, tic->cart.gfx.tiles[i].data, sizeof(tic_tile), i); } { ptr = printTag(ptr, "SPRITES"); - for(s32 i = 0; i < TIC_BANK_SPRITES; i+=16) - ptr = printBuf(ptr, tic->cart.gfx.sprites[i].data, sizeof tic->cart.gfx.sprites / 16); + for(s32 i = 0; i < TIC_BANK_SPRITES; i++) + ptr = printBuf(ptr, tic->cart.gfx.sprites[i].data, sizeof(tic_tile), i); } { ptr = printTag(ptr, "MAP"); for(s32 i = 0; i < TIC_MAP_WIDTH * TIC_MAP_HEIGHT; i += TIC_MAP_WIDTH) - ptr = printBuf(ptr, &tic->cart.gfx.map.data[i], sizeof tic->cart.gfx.map / TIC_MAP_HEIGHT); + ptr = printBuf(ptr, &tic->cart.gfx.map.data[i], sizeof tic->cart.gfx.map / TIC_MAP_HEIGHT, i/TIC_MAP_WIDTH); } { ptr = printTag(ptr, "WAVES"); for(s32 i = 0; i < ENVELOPES_COUNT; i++) - ptr = printBuf(ptr, tic->cart.sound.sfx.waveform.envelopes[i].data, sizeof(tic_waveform)); + ptr = printBuf(ptr, tic->cart.sound.sfx.waveform.envelopes[i].data, sizeof(tic_waveform), i); } { ptr = printTag(ptr, "SFX"); for(s32 i = 0; i < SFX_COUNT; i++) - ptr = printBuf(ptr, &tic->cart.sound.sfx.data[i], sizeof(tic_sound_effect)); + ptr = printBuf(ptr, &tic->cart.sound.sfx.data[i], sizeof(tic_sound_effect), i); } { ptr = printTag(ptr, "PATTERNS"); for(s32 i = 0; i < MUSIC_PATTERNS; i++) - ptr = printBuf(ptr, &tic->cart.sound.music.patterns.data[i], sizeof(tic_track_pattern)); + ptr = printBuf(ptr, &tic->cart.sound.music.patterns.data[i], sizeof(tic_track_pattern), i); } { ptr = printTag(ptr, "TRACKS"); for(s32 i = 0; i < MUSIC_TRACKS; i++) - ptr = printBuf(ptr, &tic->cart.sound.music.tracks.data[i], sizeof(tic_track)); + ptr = printBuf(ptr, &tic->cart.sound.music.tracks.data[i], sizeof(tic_track), i); } fsWriteFile(name, stream, strlen(stream)); From ac2518c998207eca4146983c04af1e184a578b2b Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Fri, 10 Nov 2017 17:52:52 +0300 Subject: [PATCH 04/13] no message --- src/console.c | 72 ++++++++++----------------------------------------- 1 file changed, 14 insertions(+), 58 deletions(-) diff --git a/src/console.c b/src/console.c index 9f006ae..57e913a 100644 --- a/src/console.c +++ b/src/console.c @@ -1665,11 +1665,14 @@ static char* printBuf(char* ptr, const void* data, s32 size, s32 row) return ptr; } -static char* printTag(char* ptr, const char* tag) +static char* printSection(char* ptr, const char* tag, s32 count, const u8* data, s32 size) { sprintf(ptr, "\n-- %s:\n", tag); ptr += strlen(ptr); + for(s32 i = 0; i < count; i++, data += size) + ptr = printBuf(ptr, data, size, i); + return ptr; } @@ -1681,64 +1684,17 @@ static CartSaveResult saveProject(Console* console, const char* name) if(stream) { - char* ptr = stream; + strcpy(stream, tic->cart.code.data); + char* ptr = stream + strlen(stream); - strcpy(ptr, tic->cart.code.data); - ptr += strlen(ptr); - - { - ptr = printTag(ptr, "PALETTE"); - ptr = printBuf(ptr, tic->cart.palette.data, sizeof tic->cart.palette.data, 0); - } - - { - ptr = printTag(ptr, "TILES"); - - for(s32 i = 0; i < TIC_BANK_SPRITES; i++) - ptr = printBuf(ptr, tic->cart.gfx.tiles[i].data, sizeof(tic_tile), i); - } - - { - ptr = printTag(ptr, "SPRITES"); - - for(s32 i = 0; i < TIC_BANK_SPRITES; i++) - ptr = printBuf(ptr, tic->cart.gfx.sprites[i].data, sizeof(tic_tile), i); - } - - { - ptr = printTag(ptr, "MAP"); - - for(s32 i = 0; i < TIC_MAP_WIDTH * TIC_MAP_HEIGHT; i += TIC_MAP_WIDTH) - ptr = printBuf(ptr, &tic->cart.gfx.map.data[i], sizeof tic->cart.gfx.map / TIC_MAP_HEIGHT, i/TIC_MAP_WIDTH); - } - - { - ptr = printTag(ptr, "WAVES"); - - for(s32 i = 0; i < ENVELOPES_COUNT; i++) - ptr = printBuf(ptr, tic->cart.sound.sfx.waveform.envelopes[i].data, sizeof(tic_waveform), i); - } - - { - ptr = printTag(ptr, "SFX"); - - for(s32 i = 0; i < SFX_COUNT; i++) - ptr = printBuf(ptr, &tic->cart.sound.sfx.data[i], sizeof(tic_sound_effect), i); - } - - { - ptr = printTag(ptr, "PATTERNS"); - - for(s32 i = 0; i < MUSIC_PATTERNS; i++) - ptr = printBuf(ptr, &tic->cart.sound.music.patterns.data[i], sizeof(tic_track_pattern), i); - } - - { - ptr = printTag(ptr, "TRACKS"); - - for(s32 i = 0; i < MUSIC_TRACKS; i++) - ptr = printBuf(ptr, &tic->cart.sound.music.tracks.data[i], sizeof(tic_track), i); - } + ptr = printSection(ptr, "PALETTE", 1, tic->cart.palette.data, sizeof(tic_palette)); + ptr = printSection(ptr, "TILES", TIC_BANK_SPRITES, tic->cart.gfx.tiles[0].data, sizeof(tic_tile)); + ptr = printSection(ptr, "SPRITES", TIC_BANK_SPRITES, tic->cart.gfx.sprites[0].data, sizeof(tic_tile)); + ptr = printSection(ptr, "MAP", TIC_MAP_HEIGHT, tic->cart.gfx.map.data, TIC_MAP_WIDTH); + ptr = printSection(ptr, "WAVES", ENVELOPES_COUNT, tic->cart.sound.sfx.waveform.envelopes[0].data, sizeof(tic_waveform)); + ptr = printSection(ptr, "SFX", SFX_COUNT, (const u8*)&tic->cart.sound.sfx.data, sizeof(tic_sound_effect)); + ptr = printSection(ptr, "PATTERNS", MUSIC_PATTERNS, (const u8*)&tic->cart.sound.music.patterns.data, sizeof(tic_track_pattern)); + ptr = printSection(ptr, "TRACKS", MUSIC_TRACKS, (const u8*)&tic->cart.sound.music.tracks.data, sizeof(tic_track)); fsWriteFile(name, stream, strlen(stream)); From a9781b8ffcbfca1c31315a53cf39f73717389189 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Fri, 10 Nov 2017 17:54:35 +0300 Subject: [PATCH 05/13] no message --- src/console.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/console.c b/src/console.c index 57e913a..505a345 100644 --- a/src/console.c +++ b/src/console.c @@ -1687,14 +1687,14 @@ static CartSaveResult saveProject(Console* console, const char* name) strcpy(stream, tic->cart.code.data); char* ptr = stream + strlen(stream); - ptr = printSection(ptr, "PALETTE", 1, tic->cart.palette.data, sizeof(tic_palette)); - ptr = printSection(ptr, "TILES", TIC_BANK_SPRITES, tic->cart.gfx.tiles[0].data, sizeof(tic_tile)); - ptr = printSection(ptr, "SPRITES", TIC_BANK_SPRITES, tic->cart.gfx.sprites[0].data, sizeof(tic_tile)); - ptr = printSection(ptr, "MAP", TIC_MAP_HEIGHT, tic->cart.gfx.map.data, TIC_MAP_WIDTH); - ptr = printSection(ptr, "WAVES", ENVELOPES_COUNT, tic->cart.sound.sfx.waveform.envelopes[0].data, sizeof(tic_waveform)); - ptr = printSection(ptr, "SFX", SFX_COUNT, (const u8*)&tic->cart.sound.sfx.data, sizeof(tic_sound_effect)); + ptr = printSection(ptr, "PALETTE", 1, tic->cart.palette.data, sizeof(tic_palette)); + ptr = printSection(ptr, "TILES", TIC_BANK_SPRITES, tic->cart.gfx.tiles[0].data, sizeof(tic_tile)); + ptr = printSection(ptr, "SPRITES", TIC_BANK_SPRITES, tic->cart.gfx.sprites[0].data, sizeof(tic_tile)); + ptr = printSection(ptr, "MAP", TIC_MAP_HEIGHT, tic->cart.gfx.map.data, TIC_MAP_WIDTH); + ptr = printSection(ptr, "WAVES", ENVELOPES_COUNT, tic->cart.sound.sfx.waveform.envelopes[0].data, sizeof(tic_waveform)); + ptr = printSection(ptr, "SFX", SFX_COUNT, (const u8*)&tic->cart.sound.sfx.data, sizeof(tic_sound_effect)); ptr = printSection(ptr, "PATTERNS", MUSIC_PATTERNS, (const u8*)&tic->cart.sound.music.patterns.data, sizeof(tic_track_pattern)); - ptr = printSection(ptr, "TRACKS", MUSIC_TRACKS, (const u8*)&tic->cart.sound.music.tracks.data, sizeof(tic_track)); + ptr = printSection(ptr, "TRACKS", MUSIC_TRACKS, (const u8*)&tic->cart.sound.music.tracks.data, sizeof(tic_track)); fsWriteFile(name, stream, strlen(stream)); From e6fd93ad964264e50a5366d073f6acf705da4a21 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Fri, 10 Nov 2017 18:06:39 +0300 Subject: [PATCH 06/13] no message --- src/console.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/console.c b/src/console.c index 505a345..0aaf702 100644 --- a/src/console.c +++ b/src/console.c @@ -1638,20 +1638,19 @@ static void buf2str(const void* data, s32 size, char* ptr, bool flip) } } +static bool bufferEmpty(const u8* data, s32 size) +{ + for(s32 i = 0; i < size; i++) + if(*data++) + return false; + + return true; +} + static char* printBuf(char* ptr, const void* data, s32 size, s32 row) { - { - bool empty = true; - const u8* dataPtr = data; - for(s32 i = 0; i < size; i++) - if(*dataPtr++) - { - empty = false; - break; - } - - if(empty) return ptr; - } + if(bufferEmpty(data, size)) + return ptr; sprintf(ptr, "-- %03i:", row); ptr += strlen(ptr); @@ -1667,7 +1666,10 @@ static char* printBuf(char* ptr, const void* data, s32 size, s32 row) static char* printSection(char* ptr, const char* tag, s32 count, const u8* data, s32 size) { - sprintf(ptr, "\n-- %s:\n", tag); + if(bufferEmpty(data, size * count)) + return ptr; + + sprintf(ptr, "\n-- ### %s:\n", tag); ptr += strlen(ptr); for(s32 i = 0; i < count; i++, data += size) From 035433764102a4fc32b7ba77f5c60136c2dfad28 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Fri, 10 Nov 2017 19:40:44 +0300 Subject: [PATCH 07/13] no message --- src/console.c | 122 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 94 insertions(+), 28 deletions(-) diff --git a/src/console.c b/src/console.c index 0aaf702..9400d44 100644 --- a/src/console.c +++ b/src/console.c @@ -68,21 +68,26 @@ 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* getRomName(const char* name) +static const char* getName(const char* name, const char* ext) { static char path[FILENAME_MAX]; strcpy(path, name); size_t ps = strlen(path); - size_t es = strlen(CartExt); + size_t es = strlen(ext); - if(!(ps > es && strstr(path, CartExt) + es == path + ps)) - strcat(path, CartExt); + if(!(ps > es && strstr(path, ext) + es == path + ps)) + strcat(path, ext); return path; } +static const char* getCartName(const char* name) +{ + return getName(name, CartExt); +} + static void scrollBuffer(char* buffer) { memmove(buffer, buffer + CONSOLE_BUFFER_WIDTH, CONSOLE_BUFFER_SIZE - CONSOLE_BUFFER_WIDTH); @@ -343,7 +348,7 @@ static bool onConsoleLoadSectionCommand(Console* console, const char* param) if(pos) { pos[sizeof(CartExt) - 1] = 0; - const char* name = getRomName(param); + const char* name = getCartName(param); s32 size = 0; void* data = fsLoadFile(console->fs, name, &size); @@ -475,7 +480,7 @@ static void onConsoleLoadDemoCommandConfirmed(Console* console, const char* para else if(strcmp(param, DefaultJSTicPath) == 0) data = getDemoCart(console, tic_script_js, &size); - const char* name = getRomName(param); + const char* name = getCartName(param); strcpy(console->romName, name); @@ -560,7 +565,7 @@ static void onConsoleLoadCommandConfirmed(Console* console, const char* param) if(param) { s32 size = 0; - const char* name = getRomName(param); + const char* name = getCartName(param); #if defined(TIC80_PRO) if(fsIsDir(console->fs, name)) @@ -1621,6 +1626,11 @@ static void onConsoleExportCommand(Console* console, const char* param) #if defined(TIC80_PRO) +static const char* getProjectName(const char* name) +{ + return getName(name, ".ticp"); +} + static void buf2str(const void* data, s32 size, char* ptr, bool flip) { enum {Len = 2}; @@ -1682,28 +1692,85 @@ static CartSaveResult saveProject(Console* console, const char* name) { tic_mem* tic = console->tic; - char* stream = (char*)SDL_malloc(sizeof(tic_cartridge) * 3); + bool success = false; - if(stream) + if(name && strlen(name)) { - strcpy(stream, tic->cart.code.data); - char* ptr = stream + strlen(stream); + char* stream = (char*)SDL_malloc(sizeof(tic_cartridge) * 3); - ptr = printSection(ptr, "PALETTE", 1, tic->cart.palette.data, sizeof(tic_palette)); - ptr = printSection(ptr, "TILES", TIC_BANK_SPRITES, tic->cart.gfx.tiles[0].data, sizeof(tic_tile)); - ptr = printSection(ptr, "SPRITES", TIC_BANK_SPRITES, tic->cart.gfx.sprites[0].data, sizeof(tic_tile)); - ptr = printSection(ptr, "MAP", TIC_MAP_HEIGHT, tic->cart.gfx.map.data, TIC_MAP_WIDTH); - ptr = printSection(ptr, "WAVES", ENVELOPES_COUNT, tic->cart.sound.sfx.waveform.envelopes[0].data, sizeof(tic_waveform)); - ptr = printSection(ptr, "SFX", SFX_COUNT, (const u8*)&tic->cart.sound.sfx.data, sizeof(tic_sound_effect)); - ptr = printSection(ptr, "PATTERNS", MUSIC_PATTERNS, (const u8*)&tic->cart.sound.music.patterns.data, sizeof(tic_track_pattern)); - ptr = printSection(ptr, "TRACKS", MUSIC_TRACKS, (const u8*)&tic->cart.sound.music.tracks.data, sizeof(tic_track)); + if(stream) + { + strcpy(stream, tic->cart.code.data); + char* ptr = stream + strlen(stream); - fsWriteFile(name, stream, strlen(stream)); + ptr = printSection(ptr, "PALETTE", 1, tic->cart.palette.data, sizeof(tic_palette)); + ptr = printSection(ptr, "TILES", TIC_BANK_SPRITES, tic->cart.gfx.tiles[0].data, sizeof(tic_tile)); + ptr = printSection(ptr, "SPRITES", TIC_BANK_SPRITES, tic->cart.gfx.sprites[0].data, sizeof(tic_tile)); + ptr = printSection(ptr, "MAP", TIC_MAP_HEIGHT, tic->cart.gfx.map.data, TIC_MAP_WIDTH); + ptr = printSection(ptr, "WAVES", ENVELOPES_COUNT, tic->cart.sound.sfx.waveform.envelopes[0].data, sizeof(tic_waveform)); + ptr = printSection(ptr, "SFX", SFX_COUNT, (const u8*)&tic->cart.sound.sfx.data, sizeof(tic_sound_effect)); + ptr = printSection(ptr, "PATTERNS", MUSIC_PATTERNS, (const u8*)&tic->cart.sound.music.patterns.data, sizeof(tic_track_pattern)); + ptr = printSection(ptr, "TRACKS", MUSIC_TRACKS, (const u8*)&tic->cart.sound.music.tracks.data, sizeof(tic_track)); - SDL_free(stream); + name = getProjectName(name); + + s32 size = strlen(stream); + if(size && fsSaveFile(console->fs, name, stream, size, true)) + { + strcpy(console->romName, name); + success = true; + studioRomSaved(); + } + + SDL_free(stream); + } } + else if (strlen(console->romName)) + { + return saveProject(console, console->romName); + } + else return CART_SAVE_MISSING_NAME; - return CART_SAVE_ERROR; + return success ? CART_SAVE_OK : CART_SAVE_ERROR; +} + +static void onConsoleSaveProjectCommandConfirmed(Console* console, const char* param) +{ + CartSaveResult rom = saveProject(console, param); + + if(rom == CART_SAVE_OK) + { + printBack(console, "\nproject "); + printFront(console, console->romName); + printBack(console, " saved!\n"); + } + else if(rom == CART_SAVE_MISSING_NAME) + printBack(console, "\nproject name is missing\n"); + else + printBack(console, "\nproject saving error"); + + commandDone(console); +} + +static void onConsoleSaveProjectCommand(Console* console, const char* param) +{ + if(param && strlen(param) && fsExistsFile(console->fs, getProjectName(param))) + { + static const char* Rows[] = + { + "THE PROJECT", + "ALREADY EXISTS", + "", + "DO YOU WANT TO", + "OVERWRITE IT?", + }; + + confirmCommand(console, Rows, COUNT_OF(Rows), param, onConsoleSaveProjectCommandConfirmed); + } + else + { + onConsoleSaveProjectCommandConfirmed(console, param); + } } #endif @@ -1731,7 +1798,7 @@ static CartSaveResult saveCartName(Console* console, const char* name) { s32 size = tic->api.save(&tic->cart, buffer); - name = getRomName(name); + name = getCartName(name); if(size && fsSaveFile(console->fs, name, buffer, size, true)) { @@ -1761,11 +1828,7 @@ static CartSaveResult saveCart(Console* console) static void onConsoleSaveCommandConfirmed(Console* console, const char* param) { -#if defined(TIC80_PRO) - CartSaveResult rom = saveProject(console, param); -#else CartSaveResult rom = saveCartName(console, param); -#endif if(rom == CART_SAVE_OK) { @@ -1783,7 +1846,7 @@ static void onConsoleSaveCommandConfirmed(Console* console, const char* param) static void onConsoleSaveCommand(Console* console, const char* param) { - if(param && strlen(param) && fsExistsFile(console->fs, getRomName(param))) + if(param && strlen(param) && fsExistsFile(console->fs, getCartName(param))) { static const char* Rows[] = { @@ -2019,6 +2082,9 @@ static const struct {"new", NULL, "create new cart", onConsoleNewCommand}, {"load", NULL, "load cart", onConsoleLoadCommand}, {"save", NULL, "save cart", onConsoleSaveCommand}, +#if defined(TIC80_PRO) + {"savep", NULL, "save cart project", onConsoleSaveProjectCommand}, +#endif {"run", NULL, "run loaded cart", onConsoleRunCommand}, {"resume", NULL, "resume run cart", onConsoleResumeCommand}, {"dir", "ls", "show list of files", onConsoleDirCommand}, From 8bfda3eab09621df91d77ea0b78ba8d644113df3 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Fri, 10 Nov 2017 19:42:06 +0300 Subject: [PATCH 08/13] no message --- src/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/console.c b/src/console.c index 9400d44..9345ead 100644 --- a/src/console.c +++ b/src/console.c @@ -2083,7 +2083,7 @@ static const struct {"load", NULL, "load cart", onConsoleLoadCommand}, {"save", NULL, "save cart", onConsoleSaveCommand}, #if defined(TIC80_PRO) - {"savep", NULL, "save cart project", onConsoleSaveProjectCommand}, + {"savep", NULL, "save project", onConsoleSaveProjectCommand}, #endif {"run", NULL, "run loaded cart", onConsoleRunCommand}, {"resume", NULL, "resume run cart", onConsoleResumeCommand}, From bc29543c78f2ba0c46e491db1085468f6ef56c21 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Sat, 11 Nov 2017 14:44:41 +0300 Subject: [PATCH 09/13] added 'loadp' --- src/console.c | 271 ++++++++++++++++++++++++++++++++++++-------------- src/map.c | 2 +- src/music.c | 2 +- src/studio.c | 6 +- src/studio.h | 2 +- src/tic.h | 2 + 6 files changed, 204 insertions(+), 81 deletions(-) diff --git a/src/console.c b/src/console.c index 9345ead..57adc4f 100644 --- a/src/console.c +++ b/src/console.c @@ -509,55 +509,6 @@ static void onCartLoaded(Console* console, const char* name) } -#if defined(TIC80_PRO) - -static void loadProjectCode(Console* console, const void* data, s32 size) -{ - tic_mem* tic = console->tic; - - SDL_memcpy(tic->cart.code.data, data, SDL_min(size, sizeof(tic_code))); -} - -static void loadProject(Console* console, const char* name) -{ - tic_mem* tic = console->tic; - - SDL_memset(&tic->cart, 0, sizeof(tic_cartridge)); - - static struct{const char* name; void(*func)(Console* console, const void* data, s32 size);} ProjectFiles[] = - { - {"code.lua", loadProjectCode}, - {"sprites.gif", NULL}, - {"tiles.gif", NULL}, - {"palette.dat", NULL}, - {"map.dat", NULL}, - {"waves.dat", NULL}, - {"sfx.dat", NULL}, - {"music.dat", NULL}, - {"cover.gif", NULL}, - }; - - for(s32 i = 0; i < COUNT_OF(ProjectFiles); i++) - { - char path[FILENAME_MAX]; - sprintf(path, "%s/%s", name, ProjectFiles[i].name); - - s32 size = 0; - void* data = fsLoadFile(console->fs, path, &size); - - if(data) - { - ProjectFiles[i].func(console, data, size); - SDL_free(data); - } - } - - onCartLoaded(console, name); - - commandDone(console); -} -#endif - static void onConsoleLoadCommandConfirmed(Console* console, const char* param) { if(onConsoleLoadSectionCommand(console, param)) return; @@ -567,14 +518,6 @@ static void onConsoleLoadCommandConfirmed(Console* console, const char* param) s32 size = 0; const char* name = getCartName(param); -#if defined(TIC80_PRO) - if(fsIsDir(console->fs, name)) - { - loadProject(console, name); - return; - } -#endif - void* data = strcmp(name, CONFIG_TIC_PATH) == 0 ? fsLoadRootFile(console->fs, name, &size) : fsLoadFile(console->fs, name, &size); @@ -753,11 +696,6 @@ static bool printFilename(const char* name, const char* info, s32 id, void* data printLine(console); -#if defined(TIC80_PRO) - if(dir && SDL_strstr(name, CartExt) == (name + SDL_strlen(name) - SDL_strlen(CartExt))) - dir = false; -#endif - if(dir) { @@ -1657,6 +1595,17 @@ static bool bufferEmpty(const u8* data, s32 size) return true; } +static char* printText(char* ptr, const char* tag, const char* data) +{ + if(strlen(data) == 0) + return ptr; + + sprintf(ptr, "-- <%s>\n%s\n-- \n", tag, data, tag); + ptr += strlen(ptr); + + return ptr; +} + static char* printBuf(char* ptr, const void* data, s32 size, s32 row) { if(bufferEmpty(data, size)) @@ -1674,17 +1623,20 @@ static char* printBuf(char* ptr, const void* data, s32 size, s32 row) return ptr; } -static char* printSection(char* ptr, const char* tag, s32 count, const u8* data, s32 size) +static char* printBinary(char* ptr, const char* tag, s32 count, const u8* data, s32 size) { if(bufferEmpty(data, size * count)) return ptr; - sprintf(ptr, "\n-- ### %s:\n", tag); + sprintf(ptr, "\n-- <%s>\n", tag); ptr += strlen(ptr); for(s32 i = 0; i < count; i++, data += size) ptr = printBuf(ptr, data, size, i); + sprintf(ptr, "-- \n", tag); + ptr += strlen(ptr); + return ptr; } @@ -1700,17 +1652,19 @@ static CartSaveResult saveProject(Console* console, const char* name) if(stream) { - strcpy(stream, tic->cart.code.data); - char* ptr = stream + strlen(stream); + char* ptr = printText(stream, "CODE", tic->cart.code.data); - ptr = printSection(ptr, "PALETTE", 1, tic->cart.palette.data, sizeof(tic_palette)); - ptr = printSection(ptr, "TILES", TIC_BANK_SPRITES, tic->cart.gfx.tiles[0].data, sizeof(tic_tile)); - ptr = printSection(ptr, "SPRITES", TIC_BANK_SPRITES, tic->cart.gfx.sprites[0].data, sizeof(tic_tile)); - ptr = printSection(ptr, "MAP", TIC_MAP_HEIGHT, tic->cart.gfx.map.data, TIC_MAP_WIDTH); - ptr = printSection(ptr, "WAVES", ENVELOPES_COUNT, tic->cart.sound.sfx.waveform.envelopes[0].data, sizeof(tic_waveform)); - ptr = printSection(ptr, "SFX", SFX_COUNT, (const u8*)&tic->cart.sound.sfx.data, sizeof(tic_sound_effect)); - ptr = printSection(ptr, "PATTERNS", MUSIC_PATTERNS, (const u8*)&tic->cart.sound.music.patterns.data, sizeof(tic_track_pattern)); - ptr = printSection(ptr, "TRACKS", MUSIC_TRACKS, (const u8*)&tic->cart.sound.music.tracks.data, sizeof(tic_track)); + // TODO: flip data for palette + ptr = printBinary(ptr, "PALETTE", 1, tic->cart.palette.data, sizeof(tic_palette)); + ptr = printBinary(ptr, "TILES", TIC_BANK_SPRITES, tic->cart.gfx.tiles[0].data, sizeof(tic_tile)); + ptr = printBinary(ptr, "SPRITES", TIC_BANK_SPRITES, tic->cart.gfx.sprites[0].data, sizeof(tic_tile)); + ptr = printBinary(ptr, "MAP", TIC_MAP_HEIGHT, tic->cart.gfx.map.data, TIC_MAP_WIDTH); + ptr = printBinary(ptr, "WAVES", ENVELOPES_COUNT, tic->cart.sound.sfx.waveform.envelopes[0].data, sizeof(tic_waveform)); + ptr = printBinary(ptr, "SFX", SFX_COUNT, (const u8*)&tic->cart.sound.sfx.data, sizeof(tic_sound_effect)); + ptr = printBinary(ptr, "PATTERNS", MUSIC_PATTERNS, (const u8*)&tic->cart.sound.music.patterns.data, sizeof(tic_track_pattern)); + ptr = printBinary(ptr, "TRACKS", MUSIC_TRACKS, (const u8*)&tic->cart.sound.music.tracks.data, sizeof(tic_track)); + + // TODO: add cover name = getProjectName(name); @@ -1773,6 +1727,174 @@ static void onConsoleSaveProjectCommand(Console* console, const char* param) } } +static bool loadProject(Console* console, const char* data, s32 size) +{ + tic_mem* tic = console->tic; + + char* project = (char*)SDL_malloc(size+1); + + bool done = false; + + if(project) + { + SDL_memcpy(project, data, size); + project[size] = '\0'; + + tic_cartridge* cart = (tic_cartridge*)SDL_malloc(sizeof(tic_cartridge)); + + if(cart) + { + SDL_memset(cart, 0, sizeof(tic_cartridge)); + + // TODO: init default palette here + { + memcpy(&cart->palette, &tic->cart.palette, sizeof(tic_palette)); + } + + const char* projectEnd = project + strlen(project); + + { + const char* tag = "CODE"; + char tagbuf[64]; + sprintf(tagbuf, "-- <%s>\n", tag); + + const char* start = SDL_strstr(project, tagbuf); + + if(start) + { + start += strlen(tagbuf); + + if(start < projectEnd) + { + sprintf(tagbuf, "\n-- ", tag); + const char* end = SDL_strstr(start, tagbuf); + + s32 size = end - start; + if(size > 0) + { + SDL_memcpy(cart->code.data, start, end - start); + done = true; + } + } + } + } + + { + const char* tag = "TILES"; + char tagbuf[64]; + sprintf(tagbuf, "-- <%s>\n", tag); + + const char* start = SDL_strstr(project, tagbuf); + + if(start) + { + start += strlen(tagbuf); + + if(start < projectEnd) + { + sprintf(tagbuf, "\n-- ", tag); + const char* end = SDL_strstr(start, tagbuf); + + s32 size = end - start; + if(size > 0) + { + s32 count = 256; + s32 size = sizeof(tic_tile) * 2; + + const char* ptr = start; + + while(ptr < end) + { + char lineStr[] = "999"; + memcpy(lineStr, ptr + strlen("-- "), strlen(lineStr)); + + s32 index = SDL_atoi(lineStr); + + if(index < count) + { + ptr += strlen("-- 999:"); + str2buf(ptr, size, cart->gfx.tiles[index].data, true); + ptr += size + 1; + } + } + + done = true; + } + } + } + } + + if(done) + { + SDL_memcpy(&tic->cart, cart, sizeof(tic_cartridge)); + } + + SDL_free(cart); + } + + + SDL_free(project); + } + + return done; +} + +static void onConsoleLoadProjectCommandConfirmed(Console* console, const char* param) +{ + // if(onConsoleLoadProjectSectionCommand(console, param)) return; + + if(param) + { + s32 size = 0; + const char* name = getProjectName(param); + + void* data = fsLoadFile(console->fs, name, &size); + + if(data && loadProject(console, data, size)) + { + strcpy(console->romName, name); + + studioRomLoaded(); + + printBack(console, "\nproject "); + printFront(console, console->romName); + printBack(console, " loaded!\nuse "); + printFront(console, "RUN"); + printBack(console, " command to run it\n"); + + SDL_free(data); + } + else + { + printBack(console, "\nproject loading error"); + } + } + else printBack(console, "\nproject name is missing"); + + commandDone(console); +} + +static void onConsoleLoadProjectCommand(Console* console, const char* param) +{ + if(studioCartChanged()) + { + static const char* Rows[] = + { + "YOU HAVE", + "UNSAVED CHANGES", + "", + "DO YOU REALLY WANT", + "TO LOAD PROJECT?", + }; + + confirmCommand(console, Rows, COUNT_OF(Rows), param, onConsoleLoadProjectCommandConfirmed); + } + else + { + onConsoleLoadProjectCommandConfirmed(console, param); + } +} + #endif static CartSaveResult saveCartName(Console* console, const char* name) @@ -2083,6 +2205,7 @@ static const struct {"load", NULL, "load cart", onConsoleLoadCommand}, {"save", NULL, "save cart", onConsoleSaveCommand}, #if defined(TIC80_PRO) + {"loadp", NULL, "load project", onConsoleLoadProjectCommand}, {"savep", NULL, "save project", onConsoleSaveProjectCommand}, #endif {"run", NULL, "run loaded cart", onConsoleRunCommand}, diff --git a/src/map.c b/src/map.c index 3efc8e0..4c4538d 100644 --- a/src/map.c +++ b/src/map.c @@ -999,7 +999,7 @@ static void copyFromClipboard(Map* map) { u8* data = SDL_malloc(size); - str2buf(clipboard, data, true); + str2buf(clipboard, strlen(clipboard), data, true); if(data[0] * data[1] == size - 2) { diff --git a/src/music.c b/src/music.c index 2cf74e5..5ca4ba8 100644 --- a/src/music.c +++ b/src/music.c @@ -598,7 +598,7 @@ static void copyFromClipboard(Music* music) { u8* data = SDL_malloc(size); - str2buf(clipboard, data, true); + str2buf(clipboard, strlen(clipboard), data, true); ClipboardHeader header = {0}; diff --git a/src/studio.c b/src/studio.c index 3a0f8ac..4824673 100644 --- a/src/studio.c +++ b/src/studio.c @@ -342,13 +342,11 @@ void toClipboard(const void* data, s32 size, bool flip) } } -void str2buf(const char* str, void* buf, bool flip) +void str2buf(const char* str, s32 size, void* buf, bool flip) { char val[] = "0x00"; const char* ptr = str; - s32 size = (s32)strlen(str); - for(s32 i = 0; i < size/2; i++) { if(flip) @@ -378,7 +376,7 @@ bool fromClipboard(void* data, s32 size, bool flip) { bool valid = strlen(clipboard) == size * 2; - if(valid) str2buf(clipboard, data, flip); + if(valid) str2buf(clipboard, strlen(clipboard), data, flip); SDL_free(clipboard); diff --git a/src/studio.h b/src/studio.h index 17eb748..2163eec 100644 --- a/src/studio.h +++ b/src/studio.h @@ -146,7 +146,7 @@ EditorMode getStudioMode(); void exitStudio(); u32 unzip(u8** dest, const u8* source, size_t size); -void str2buf(const char* str, void* buf, bool flip); +void str2buf(const char* str, s32 size, void* buf, bool flip); void toClipboard(const void* data, s32 size, bool flip); bool fromClipboard(void* data, s32 size, bool flip); diff --git a/src/tic.h b/src/tic.h index afce57f..d788dbe 100644 --- a/src/tic.h +++ b/src/tic.h @@ -29,6 +29,8 @@ #define TIC_VERSION_MAJOR 0 #define TIC_VERSION_MINOR 47 #define TIC_VERSION_PATCH 0 + +// TODO: add PRO postfix to title #define TIC_VERSION_STATUS "" #define TIC_MAKE_VERSION(major, minor, patch) ((major) * 10000 + (minor) * 100 + (patch)) From b3ad8ef8f62b3e100e4e013e379a13b294912357 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Sat, 11 Nov 2017 15:57:21 +0300 Subject: [PATCH 10/13] no message --- src/console.c | 174 ++++++++++++++++++++++++-------------------------- 1 file changed, 82 insertions(+), 92 deletions(-) diff --git a/src/console.c b/src/console.c index 57adc4f..f0572e2 100644 --- a/src/console.c +++ b/src/console.c @@ -1595,7 +1595,7 @@ static bool bufferEmpty(const u8* data, s32 size) return true; } -static char* printText(char* ptr, const char* tag, const char* data) +static char* saveTextSection(char* ptr, const char* tag, const char* data) { if(strlen(data) == 0) return ptr; @@ -1623,7 +1623,7 @@ static char* printBuf(char* ptr, const void* data, s32 size, s32 row) return ptr; } -static char* printBinary(char* ptr, const char* tag, s32 count, const u8* data, s32 size) +static char* saveBinarySection(char* ptr, const char* tag, s32 count, const u8* data, s32 size) { if(bufferEmpty(data, size * count)) return ptr; @@ -1652,17 +1652,17 @@ static CartSaveResult saveProject(Console* console, const char* name) if(stream) { - char* ptr = printText(stream, "CODE", tic->cart.code.data); + char* ptr = saveTextSection(stream, "CODE", tic->cart.code.data); // TODO: flip data for palette - ptr = printBinary(ptr, "PALETTE", 1, tic->cart.palette.data, sizeof(tic_palette)); - ptr = printBinary(ptr, "TILES", TIC_BANK_SPRITES, tic->cart.gfx.tiles[0].data, sizeof(tic_tile)); - ptr = printBinary(ptr, "SPRITES", TIC_BANK_SPRITES, tic->cart.gfx.sprites[0].data, sizeof(tic_tile)); - ptr = printBinary(ptr, "MAP", TIC_MAP_HEIGHT, tic->cart.gfx.map.data, TIC_MAP_WIDTH); - ptr = printBinary(ptr, "WAVES", ENVELOPES_COUNT, tic->cart.sound.sfx.waveform.envelopes[0].data, sizeof(tic_waveform)); - ptr = printBinary(ptr, "SFX", SFX_COUNT, (const u8*)&tic->cart.sound.sfx.data, sizeof(tic_sound_effect)); - ptr = printBinary(ptr, "PATTERNS", MUSIC_PATTERNS, (const u8*)&tic->cart.sound.music.patterns.data, sizeof(tic_track_pattern)); - ptr = printBinary(ptr, "TRACKS", MUSIC_TRACKS, (const u8*)&tic->cart.sound.music.tracks.data, sizeof(tic_track)); + ptr = saveBinarySection(ptr, "PALETTE", 1, tic->cart.palette.data, sizeof(tic_palette)); + ptr = saveBinarySection(ptr, "TILES", TIC_BANK_SPRITES, tic->cart.gfx.tiles[0].data, sizeof(tic_tile)); + ptr = saveBinarySection(ptr, "SPRITES", TIC_BANK_SPRITES, tic->cart.gfx.sprites[0].data, sizeof(tic_tile)); + ptr = saveBinarySection(ptr, "MAP", TIC_MAP_HEIGHT, tic->cart.gfx.map.data, TIC_MAP_WIDTH); + ptr = saveBinarySection(ptr, "WAVES", ENVELOPES_COUNT, tic->cart.sound.sfx.waveform.envelopes[0].data, sizeof(tic_waveform)); + ptr = saveBinarySection(ptr, "SFX", SFX_COUNT, (const u8*)&tic->cart.sound.sfx.data, sizeof(tic_sound_effect)); + ptr = saveBinarySection(ptr, "PATTERNS", MUSIC_PATTERNS, (const u8*)&tic->cart.sound.music.patterns.data, sizeof(tic_track_pattern)); + ptr = saveBinarySection(ptr, "TRACKS", MUSIC_TRACKS, (const u8*)&tic->cart.sound.music.tracks.data, sizeof(tic_track)); // TODO: add cover @@ -1727,6 +1727,64 @@ static void onConsoleSaveProjectCommand(Console* console, const char* param) } } +static void loadTextSection(const char* project, const char* tag, void* dst, s32 size) +{ + char tagbuf[64]; + sprintf(tagbuf, "-- <%s>\n", tag); + + const char* start = SDL_strstr(project, tagbuf); + + if(start) + { + start += strlen(tagbuf); + + if(start < project + strlen(project)) + { + sprintf(tagbuf, "\n-- ", tag); + const char* end = SDL_strstr(start, tagbuf); + + if(end > start) + SDL_memcpy(dst, start, SDL_min(size, end - start)); + } + } +} + +static void loadBinarySection(const char* project, const char* tag, s32 count, void* dst, s32 size) +{ + char tagbuf[64]; + sprintf(tagbuf, "-- <%s>\n", tag); + + const char* start = SDL_strstr(project, tagbuf); + + if(start) + { + start += strlen(tagbuf); + + sprintf(tagbuf, "\n-- ", tag); + const char* end = SDL_strstr(start, tagbuf); + + if(end > start) + { + const char* ptr = start; + + while(ptr < end) + { + char lineStr[] = "999"; + memcpy(lineStr, ptr + strlen("-- "), strlen(lineStr)); + + s32 index = SDL_atoi(lineStr); + + if(index < count) + { + ptr += strlen("-- 999:"); + str2buf(ptr, size*2, (u8*)dst + size*index, true); + ptr += size*2 + 1; + } + } + } + } +} + static bool loadProject(Console* console, const char* data, s32 size) { tic_mem* tic = console->tic; @@ -1745,93 +1803,25 @@ static bool loadProject(Console* console, const char* data, s32 size) if(cart) { SDL_memset(cart, 0, sizeof(tic_cartridge)); + // TODO: init default palette here??? - // TODO: init default palette here - { - memcpy(&cart->palette, &tic->cart.palette, sizeof(tic_palette)); - } + loadTextSection(project, "CODE", cart->code.data, sizeof(tic_code)); - const char* projectEnd = project + strlen(project); + loadBinarySection(project, "PALETTE", 1, cart->palette.data, sizeof(tic_palette)); + loadBinarySection(project, "TILES", TIC_BANK_SPRITES, &cart->gfx.tiles, sizeof(tic_tile)); + loadBinarySection(project, "SPRITES", TIC_BANK_SPRITES, &cart->gfx.sprites, sizeof(tic_tile)); + loadBinarySection(project, "MAP", TIC_MAP_HEIGHT, cart->gfx.map.data, TIC_MAP_WIDTH); + loadBinarySection(project, "WAVES", ENVELOPES_COUNT, &cart->sound.sfx.waveform.envelopes, sizeof(tic_waveform)); + loadBinarySection(project, "SFX", SFX_COUNT, cart->sound.sfx.data, sizeof(tic_sound_effect)); + loadBinarySection(project, "PATTERNS", MUSIC_PATTERNS, cart->sound.music.patterns.data, sizeof(tic_track_pattern)); + loadBinarySection(project, "TRACKS", MUSIC_TRACKS, cart->sound.music.tracks.data, sizeof(tic_track)); - { - const char* tag = "CODE"; - char tagbuf[64]; - sprintf(tagbuf, "-- <%s>\n", tag); - - const char* start = SDL_strstr(project, tagbuf); - - if(start) - { - start += strlen(tagbuf); - - if(start < projectEnd) - { - sprintf(tagbuf, "\n-- ", tag); - const char* end = SDL_strstr(start, tagbuf); - - s32 size = end - start; - if(size > 0) - { - SDL_memcpy(cart->code.data, start, end - start); - done = true; - } - } - } - } - - { - const char* tag = "TILES"; - char tagbuf[64]; - sprintf(tagbuf, "-- <%s>\n", tag); - - const char* start = SDL_strstr(project, tagbuf); - - if(start) - { - start += strlen(tagbuf); - - if(start < projectEnd) - { - sprintf(tagbuf, "\n-- ", tag); - const char* end = SDL_strstr(start, tagbuf); - - s32 size = end - start; - if(size > 0) - { - s32 count = 256; - s32 size = sizeof(tic_tile) * 2; - - const char* ptr = start; - - while(ptr < end) - { - char lineStr[] = "999"; - memcpy(lineStr, ptr + strlen("-- "), strlen(lineStr)); - - s32 index = SDL_atoi(lineStr); - - if(index < count) - { - ptr += strlen("-- 999:"); - str2buf(ptr, size, cart->gfx.tiles[index].data, true); - ptr += size + 1; - } - } - - done = true; - } - } - } - } - - if(done) - { - SDL_memcpy(&tic->cart, cart, sizeof(tic_cartridge)); - } + SDL_memcpy(&tic->cart, cart, sizeof(tic_cartridge)); SDL_free(cart); - } + done = true; + } SDL_free(project); } From af7469a2d7807537f5aaf7ae5f1dd385c13ee7c1 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Sat, 11 Nov 2017 16:41:51 +0300 Subject: [PATCH 11/13] no message --- src/console.c | 63 +++++++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/src/console.c b/src/console.c index f0572e2..af0e6c6 100644 --- a/src/console.c +++ b/src/console.c @@ -1606,7 +1606,7 @@ static char* saveTextSection(char* ptr, const char* tag, const char* data) return ptr; } -static char* printBuf(char* ptr, const void* data, s32 size, s32 row) +static char* saveBinaryBuffer(char* ptr, const void* data, s32 size, s32 row, bool flip) { if(bufferEmpty(data, size)) return ptr; @@ -1614,7 +1614,7 @@ static char* printBuf(char* ptr, const void* data, s32 size, s32 row) sprintf(ptr, "-- %03i:", row); ptr += strlen(ptr); - buf2str(data, size, ptr, true); + buf2str(data, size, ptr, flip); ptr += strlen(ptr); sprintf(ptr, "\n"); @@ -1623,7 +1623,7 @@ static char* printBuf(char* ptr, const void* data, s32 size, s32 row) return ptr; } -static char* saveBinarySection(char* ptr, const char* tag, s32 count, const u8* data, s32 size) +static char* saveBinarySection(char* ptr, const char* tag, s32 count, const void* data, s32 size, bool flip) { if(bufferEmpty(data, size * count)) return ptr; @@ -1631,8 +1631,8 @@ static char* saveBinarySection(char* ptr, const char* tag, s32 count, const u8* sprintf(ptr, "\n-- <%s>\n", tag); ptr += strlen(ptr); - for(s32 i = 0; i < count; i++, data += size) - ptr = printBuf(ptr, data, size, i); + for(s32 i = 0; i < count; i++, data = (u8*)data + size) + ptr = saveBinaryBuffer(ptr, data, size, i, flip); sprintf(ptr, "-- \n", tag); ptr += strlen(ptr); @@ -1640,6 +1640,21 @@ static char* saveBinarySection(char* ptr, const char* tag, s32 count, const u8* return ptr; } +typedef struct {char* tag; s32 count; s32 offset; s32 size; bool flip;} BinarySection; +static const BinarySection BinarySections[] = +{ + {"PALETTE", 1, offsetof(tic_cartridge, palette.data), sizeof(tic_palette), false}, + {"TILES", TIC_BANK_SPRITES, offsetof(tic_cartridge, gfx.tiles), sizeof(tic_tile), true}, + {"SPRITES", TIC_BANK_SPRITES, offsetof(tic_cartridge, gfx.sprites), sizeof(tic_tile), true}, + {"MAP", TIC_MAP_HEIGHT, offsetof(tic_cartridge, gfx.map), TIC_MAP_WIDTH, true}, + {"WAVES", ENVELOPES_COUNT, offsetof(tic_cartridge,sound.sfx.waveform.envelopes), sizeof(tic_waveform), true}, + {"SFX", SFX_COUNT, offsetof(tic_cartridge, sound.sfx.data), sizeof(tic_sound_effect), true}, + {"PATTERNS", MUSIC_PATTERNS, offsetof(tic_cartridge, sound.music.patterns), sizeof(tic_track_pattern), true}, + {"TRACKS", MUSIC_TRACKS, offsetof(tic_cartridge, sound.music.tracks), sizeof(tic_track), true}, + + // TODO: add cover +}; + static CartSaveResult saveProject(Console* console, const char* name) { tic_mem* tic = console->tic; @@ -1654,17 +1669,11 @@ static CartSaveResult saveProject(Console* console, const char* name) { char* ptr = saveTextSection(stream, "CODE", tic->cart.code.data); - // TODO: flip data for palette - ptr = saveBinarySection(ptr, "PALETTE", 1, tic->cart.palette.data, sizeof(tic_palette)); - ptr = saveBinarySection(ptr, "TILES", TIC_BANK_SPRITES, tic->cart.gfx.tiles[0].data, sizeof(tic_tile)); - ptr = saveBinarySection(ptr, "SPRITES", TIC_BANK_SPRITES, tic->cart.gfx.sprites[0].data, sizeof(tic_tile)); - ptr = saveBinarySection(ptr, "MAP", TIC_MAP_HEIGHT, tic->cart.gfx.map.data, TIC_MAP_WIDTH); - ptr = saveBinarySection(ptr, "WAVES", ENVELOPES_COUNT, tic->cart.sound.sfx.waveform.envelopes[0].data, sizeof(tic_waveform)); - ptr = saveBinarySection(ptr, "SFX", SFX_COUNT, (const u8*)&tic->cart.sound.sfx.data, sizeof(tic_sound_effect)); - ptr = saveBinarySection(ptr, "PATTERNS", MUSIC_PATTERNS, (const u8*)&tic->cart.sound.music.patterns.data, sizeof(tic_track_pattern)); - ptr = saveBinarySection(ptr, "TRACKS", MUSIC_TRACKS, (const u8*)&tic->cart.sound.music.tracks.data, sizeof(tic_track)); - - // TODO: add cover + for(s32 i = 0; i < COUNT_OF(BinarySections); i++) + { + const BinarySection* section = &BinarySections[i]; + ptr = saveBinarySection(ptr, section->tag, section->count, (u8*)&tic->cart + section->offset, section->size, section->flip); + } name = getProjectName(name); @@ -1749,7 +1758,7 @@ static void loadTextSection(const char* project, const char* tag, void* dst, s32 } } -static void loadBinarySection(const char* project, const char* tag, s32 count, void* dst, s32 size) +static void loadBinarySection(const char* project, const char* tag, s32 count, void* dst, s32 size, bool flip) { char tagbuf[64]; sprintf(tagbuf, "-- <%s>\n", tag); @@ -1777,7 +1786,7 @@ static void loadBinarySection(const char* project, const char* tag, s32 count, v if(index < count) { ptr += strlen("-- 999:"); - str2buf(ptr, size*2, (u8*)dst + size*index, true); + str2buf(ptr, size*2, (u8*)dst + size*index, flip); ptr += size*2 + 1; } } @@ -1807,15 +1816,12 @@ static bool loadProject(Console* console, const char* data, s32 size) loadTextSection(project, "CODE", cart->code.data, sizeof(tic_code)); - loadBinarySection(project, "PALETTE", 1, cart->palette.data, sizeof(tic_palette)); - loadBinarySection(project, "TILES", TIC_BANK_SPRITES, &cart->gfx.tiles, sizeof(tic_tile)); - loadBinarySection(project, "SPRITES", TIC_BANK_SPRITES, &cart->gfx.sprites, sizeof(tic_tile)); - loadBinarySection(project, "MAP", TIC_MAP_HEIGHT, cart->gfx.map.data, TIC_MAP_WIDTH); - loadBinarySection(project, "WAVES", ENVELOPES_COUNT, &cart->sound.sfx.waveform.envelopes, sizeof(tic_waveform)); - loadBinarySection(project, "SFX", SFX_COUNT, cart->sound.sfx.data, sizeof(tic_sound_effect)); - loadBinarySection(project, "PATTERNS", MUSIC_PATTERNS, cart->sound.music.patterns.data, sizeof(tic_track_pattern)); - loadBinarySection(project, "TRACKS", MUSIC_TRACKS, cart->sound.music.tracks.data, sizeof(tic_track)); - + for(s32 i = 0; i < COUNT_OF(BinarySections); i++) + { + const BinarySection* section = &BinarySections[i]; + loadBinarySection(project, section->tag, section->count, (u8*)cart + section->offset, section->size, section->flip); + } + SDL_memcpy(&tic->cart, cart, sizeof(tic_cartridge)); SDL_free(cart); @@ -1831,6 +1837,7 @@ static bool loadProject(Console* console, const char* data, s32 size) static void onConsoleLoadProjectCommandConfirmed(Console* console, const char* param) { + // TODO: do we need this??? // if(onConsoleLoadProjectSectionCommand(console, param)) return; if(param) @@ -2140,6 +2147,8 @@ static void onConsoleRamCommand(Console* console, const char* param) "\n| ADDR | INFO | SIZE |" \ "\n+-------+-------------------+-------+"); +// TODO: use 'offsetof' here + #define ADDR_RECORD(addr, name) {(s32)((u8*)&addr - (u8*)console->tic), name} const struct{s32 addr; const char* info;} Layout[] = From 9442d592430153463b54c945fcb6db575b268516 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Sat, 11 Nov 2017 16:57:39 +0300 Subject: [PATCH 12/13] added cover saving --- src/console.c | 36 +++++++++++++++++++++++------------- src/tic.h | 2 +- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/console.c b/src/console.c index af0e6c6..8e2f642 100644 --- a/src/console.c +++ b/src/console.c @@ -1651,8 +1651,6 @@ static const BinarySection BinarySections[] = {"SFX", SFX_COUNT, offsetof(tic_cartridge, sound.sfx.data), sizeof(tic_sound_effect), true}, {"PATTERNS", MUSIC_PATTERNS, offsetof(tic_cartridge, sound.music.patterns), sizeof(tic_track_pattern), true}, {"TRACKS", MUSIC_TRACKS, offsetof(tic_cartridge, sound.music.tracks), sizeof(tic_track), true}, - - // TODO: add cover }; static CartSaveResult saveProject(Console* console, const char* name) @@ -1675,6 +1673,8 @@ static CartSaveResult saveProject(Console* console, const char* name) ptr = saveBinarySection(ptr, section->tag, section->count, (u8*)&tic->cart + section->offset, section->size, section->flip); } + saveBinarySection(ptr, "COVER", 1, &tic->cart.cover, tic->cart.cover.size + sizeof(s32), true); + name = getProjectName(name); s32 size = strlen(stream); @@ -1776,19 +1776,27 @@ static void loadBinarySection(const char* project, const char* tag, s32 count, v { const char* ptr = start; - while(ptr < end) + if(size > 0) { - char lineStr[] = "999"; - memcpy(lineStr, ptr + strlen("-- "), strlen(lineStr)); - - s32 index = SDL_atoi(lineStr); - - if(index < count) + while(ptr < end) { - ptr += strlen("-- 999:"); - str2buf(ptr, size*2, (u8*)dst + size*index, flip); - ptr += size*2 + 1; - } + static char lineStr[] = "999"; + memcpy(lineStr, ptr + sizeof("-- ") - 1, sizeof lineStr - 1); + + s32 index = SDL_atoi(lineStr); + + if(index < count) + { + ptr += sizeof("-- 999:") - 1; + str2buf(ptr, size*2, (u8*)dst + size*index, flip); + ptr += size*2 + 1; + } + } + } + else + { + ptr += sizeof("-- 999:") - 1; + str2buf(ptr, end - ptr, (u8*)dst, flip); } } } @@ -1821,6 +1829,8 @@ static bool loadProject(Console* console, const char* data, s32 size) const BinarySection* section = &BinarySections[i]; loadBinarySection(project, section->tag, section->count, (u8*)cart + section->offset, section->size, section->flip); } + + loadBinarySection(project, "COVER", 1, &cart->cover, -1, true); SDL_memcpy(&tic->cart, cart, sizeof(tic_cartridge)); diff --git a/src/tic.h b/src/tic.h index d788dbe..183d25c 100644 --- a/src/tic.h +++ b/src/tic.h @@ -304,8 +304,8 @@ typedef struct typedef struct { - u8 data [TIC80_WIDTH * TIC80_HEIGHT * sizeof(u32)]; s32 size; + u8 data [TIC80_WIDTH * TIC80_HEIGHT * sizeof(u32)]; } tic_cover_image; typedef struct From 71681de873ef47a79240cf2870423330ed028160 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Sat, 11 Nov 2017 17:15:06 +0300 Subject: [PATCH 13/13] no message --- src/console.c | 49 ++++++++++++++++++++----------------------------- src/tic.h | 10 +++++++--- 2 files changed, 27 insertions(+), 32 deletions(-) diff --git a/src/console.c b/src/console.c index 8e2f642..fe42a1c 100644 --- a/src/console.c +++ b/src/console.c @@ -1820,7 +1820,7 @@ static bool loadProject(Console* console, const char* data, s32 size) if(cart) { SDL_memset(cart, 0, sizeof(tic_cartridge)); - // TODO: init default palette here??? + SDL_memcpy(&cart->palette, &tic->config.palette.data, sizeof(tic_palette)); loadTextSection(project, "CODE", cart->code.data, sizeof(tic_code)); @@ -1847,9 +1847,6 @@ static bool loadProject(Console* console, const char* data, s32 size) static void onConsoleLoadProjectCommandConfirmed(Console* console, const char* param) { - // TODO: do we need this??? - // if(onConsoleLoadProjectSectionCommand(console, param)) return; - if(param) { s32 size = 0; @@ -2157,34 +2154,28 @@ static void onConsoleRamCommand(Console* console, const char* param) "\n| ADDR | INFO | SIZE |" \ "\n+-------+-------------------+-------+"); -// TODO: use 'offsetof' here - -#define ADDR_RECORD(addr, name) {(s32)((u8*)&addr - (u8*)console->tic), name} - - const struct{s32 addr; const char* info;} Layout[] = + static const struct{s32 addr; const char* info;} Layout[] = { - ADDR_RECORD(console->tic->ram.vram.screen, "SCREEN"), - ADDR_RECORD(console->tic->ram.vram.palette, "PALETTE"), - ADDR_RECORD(console->tic->ram.vram.mapping, "PALETTE MAP"), - ADDR_RECORD(console->tic->ram.vram.vars.colors, "BORDER/BG COLOR"), - ADDR_RECORD(console->tic->ram.vram.vars.offset, "SCREEN OFFSET"), - ADDR_RECORD(console->tic->ram.vram.vars.mask, "GAMEPAD MASK"), - ADDR_RECORD(console->tic->ram.vram.input.gamepad, "GAMEPAD"), - ADDR_RECORD(console->tic->ram.vram.input.reserved, "..."), - ADDR_RECORD(console->tic->ram.gfx.tiles, "SPRITES"), - ADDR_RECORD(console->tic->ram.gfx.map, "MAP"), - ADDR_RECORD(console->tic->ram.persistent, "PERSISTENT MEMORY"), - ADDR_RECORD(console->tic->ram.registers, "SOUND REGISTERS"), - ADDR_RECORD(console->tic->ram.sound.sfx.waveform, "WAVEFORMS"), - ADDR_RECORD(console->tic->ram.sound.sfx.data, "SFX"), - ADDR_RECORD(console->tic->ram.sound.music.patterns.data, "MUSIC PATTERNS"), - ADDR_RECORD(console->tic->ram.sound.music.tracks.data, "MUSIC TRACKS"), - ADDR_RECORD(console->tic->ram.music_pos, "MUSIC POS"), - {TIC_RAM_SIZE, "..."}, + {offsetof(tic_ram, vram.screen), "SCREEN"}, + {offsetof(tic_ram, vram.palette), "PALETTE"}, + {offsetof(tic_ram, vram.mapping), "PALETTE MAP"}, + {offsetof(tic_ram, vram.vars.colors), "BORDER/BG COLOR"}, + {offsetof(tic_ram, vram.vars.offset), "SCREEN OFFSET"}, + {offsetof(tic_ram, vram.vars.mask), "GAMEPAD MASK"}, + {offsetof(tic_ram, vram.input.gamepad), "GAMEPAD"}, + {offsetof(tic_ram, vram.input.reserved), "..."}, + {offsetof(tic_ram, gfx.tiles), "SPRITES"}, + {offsetof(tic_ram, gfx.map), "MAP"}, + {offsetof(tic_ram, persistent), "PERSISTENT MEMORY"}, + {offsetof(tic_ram, registers), "SOUND REGISTERS"}, + {offsetof(tic_ram, sound.sfx.waveform), "WAVEFORMS"}, + {offsetof(tic_ram, sound.sfx.data), "SFX"}, + {offsetof(tic_ram, sound.music.patterns.data), "MUSIC PATTERNS"}, + {offsetof(tic_ram, sound.music.tracks.data), "MUSIC TRACKS"}, + {offsetof(tic_ram, music_pos), "MUSIC POS"}, + {TIC_RAM_SIZE, "..."}, }; -#undef ADDR_RECORD - enum{Last = COUNT_OF(Layout)-1}; for(s32 i = 0; i < Last; i++) diff --git a/src/tic.h b/src/tic.h index 183d25c..eb80ae2 100644 --- a/src/tic.h +++ b/src/tic.h @@ -29,17 +29,21 @@ #define TIC_VERSION_MAJOR 0 #define TIC_VERSION_MINOR 47 #define TIC_VERSION_PATCH 0 - -// TODO: add PRO postfix to title #define TIC_VERSION_STATUS "" +#if defined(TIC80_PRO) +#define TIC_VERSION_POST " Pro" +#else +#define TIC_VERSION_POST "" +#endif + #define TIC_MAKE_VERSION(major, minor, patch) ((major) * 10000 + (minor) * 100 + (patch)) #define TIC_VERSION TIC_MAKE_VERSION(MYPROJ_VERSION_MAJOR, MYPROJ_VERSION_MINOR, MYPROJ_VERSION_PATCH) #define DEF2STR2(x) #x #define DEF2STR(x) DEF2STR2(x) -#define TIC_VERSION_LABEL DEF2STR(TIC_VERSION_MAJOR) "." DEF2STR(TIC_VERSION_MINOR) "." DEF2STR(TIC_VERSION_PATCH) TIC_VERSION_STATUS +#define TIC_VERSION_LABEL DEF2STR(TIC_VERSION_MAJOR) "." DEF2STR(TIC_VERSION_MINOR) "." DEF2STR(TIC_VERSION_PATCH) TIC_VERSION_STATUS TIC_VERSION_POST #define TIC_PACKAGE "com.nesbox.tic" #define TIC_NAME "TIC-80" #define TIC_NAME_FULL TIC_NAME " tiny computer"