From 440e40a9a5e69b0919d44228baa427a37c2f935d Mon Sep 17 00:00:00 2001 From: tic Date: Sat, 11 Nov 2017 22:52:12 +0300 Subject: [PATCH 1/4] makefile changes for Linux --- Makefile | 42 +++++++++++++++++++++++++++---- lib/{linux => linux64}/libSDL2.a | Bin lib/{linux => linux64}/libgif.a | Bin lib/{linux => linux64}/liblua.a | Bin lib/{linux => linux64}/libz.a | Bin 5 files changed, 37 insertions(+), 5 deletions(-) rename lib/{linux => linux64}/libSDL2.a (100%) rename lib/{linux => linux64}/libgif.a (100%) rename lib/{linux => linux64}/liblua.a (100%) rename lib/{linux => linux64}/libz.a (100%) diff --git a/Makefile b/Makefile index b7ef3d3..c8259d3 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ CC=gcc OPT=-O3 -Wall -std=c99 OPT_ARM=-D__ARM_LINUX__ +OPT_PRO=-DTIC80_PRO RM= rm -f @@ -31,7 +32,7 @@ LINUX_LIBS= \ LINUX64_LIBS= \ $(LINUX_LIBS) \ - -Llib/linux + -Llib/linux64 LINUX32_LIBS= \ $(LINUX_LIBS) \ @@ -40,6 +41,17 @@ LINUX32_LIBS= \ LINUX_ARM_LIBS= \ -Llib/arm +LINUX_LINKER_LTO_FLAGS= \ + -D_GNU_SOURCE \ + -lSDL2 \ + -llua \ + -lgif \ + -ldl \ + -lm \ + -lpthread \ + -lrt \ + -lz + LINUX_LINKER_FLAGS= \ -D_GNU_SOURCE \ -lSDL2 \ @@ -275,27 +287,47 @@ 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-pro: - $(eval OPT += -DTIC80_PRO) + $(eval OPT += $(OPT_PRO)) make mingw OPT="$(OPT)" run: mingw-pro $(MINGW_OUTPUT) linux64-lto: - $(CC) $(LINUX_INCLUDES) $(SOURCES) $(TIC80_SRC) $(SOURCES_EXT) $(OPT) $(INCLUDES) $(LINUX64_LIBS) $(LINUX_LINKER_FLAGS) -flto -o bin/tic + $(CC) $(LINUX_INCLUDES) $(SOURCES) $(TIC80_SRC) $(SOURCES_EXT) $(OPT) $(INCLUDES) $(LINUX64_LIBS) $(LINUX_LINKER_LTO_FLAGS) -flto -o bin/tic + +linux64-lto-pro: + $(eval OPT += $(OPT_PRO)) + make linux64-lto OPT="$(OPT)" linux32-lto: - $(CC) $(LINUX_INCLUDES) $(SOURCES) $(TIC80_SRC) $(SOURCES_EXT) $(OPT) $(INCLUDES) $(LINUX32_LIBS) $(LINUX_LINKER_FLAGS) -flto -o bin/tic + $(CC) $(LINUX_INCLUDES) $(SOURCES) $(TIC80_SRC) $(SOURCES_EXT) $(OPT) $(INCLUDES) $(LINUX32_LIBS) $(LINUX_LINKER_LTO_FLAGS) -flto -o bin/tic + +linux32-lto-pro: + $(eval OPT += $(OPT_PRO)) + make linux32-lto OPT="$(OPT)" arm-lto: - $(CC) $(OPT_ARM) $(SOURCES) $(TIC80_SRC) $(OPT) $(INCLUDES) $(LINUX_ARM_LIBS) $(LINUX_LINKER_FLAGS) -flto -o bin/tic + $(CC) $(OPT_ARM) $(SOURCES) $(TIC80_SRC) $(OPT) $(INCLUDES) $(LINUX_ARM_LIBS) $(LINUX_LINKER_LTO_FLAGS) -flto -o bin/tic + +arm-lto-pro: + $(eval OPT += $(OPT_PRO)) + make arm-lto OPT="$(OPT)" linux: $(CC) $(LINUX_INCLUDES) $(SOURCES) $(LPEG_SRC) $(GIF_SRC) $(SOURCES_EXT) $(TIC80_SRC) $(OPT) $(INCLUDES) $(LINUX_LIBS) $(LINUX_LINKER_FLAGS) -o bin/tic +linux-pro: + $(eval OPT += $(OPT_PRO)) + make linux OPT="$(OPT)" + macosx: $(CC) $(SOURCES) $(TIC80_SRC) $(SOURCES_EXT) src/ext/file_dialog.m $(OPT) $(MACOSX_OPT) $(INCLUDES) $(MACOSX_LIBS) -o bin/tic +macosx-pro: + $(eval OPT += $(OPT_PRO)) + make macosx OPT="$(OPT)" + bin/res.o: lib/mingw/res.rc lib/mingw/icon.ico windres $< $@ diff --git a/lib/linux/libSDL2.a b/lib/linux64/libSDL2.a similarity index 100% rename from lib/linux/libSDL2.a rename to lib/linux64/libSDL2.a diff --git a/lib/linux/libgif.a b/lib/linux64/libgif.a similarity index 100% rename from lib/linux/libgif.a rename to lib/linux64/libgif.a diff --git a/lib/linux/liblua.a b/lib/linux64/liblua.a similarity index 100% rename from lib/linux/liblua.a rename to lib/linux64/liblua.a diff --git a/lib/linux/libz.a b/lib/linux64/libz.a similarity index 100% rename from lib/linux/libz.a rename to lib/linux64/libz.a From 32203314923a9890db67cce3023146d2fff3b793 Mon Sep 17 00:00:00 2001 From: tic Date: Sun, 12 Nov 2017 14:33:06 +0300 Subject: [PATCH 2/4] makefile fix --- Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index c8259d3..0fa491c 100644 --- a/Makefile +++ b/Makefile @@ -25,10 +25,12 @@ MINGW_LINKER_FLAGS= \ -mwindows LINUX_INCLUDES= \ - `pkg-config --cflags gtk+-3.0` + `pkg-config --cflags gtk+-3.0` \ + `sdl2-config --cflags` LINUX_LIBS= \ - `pkg-config --libs gtk+-3.0` + `pkg-config --libs gtk+-3.0` \ + `sdl2-config --static-libs` LINUX64_LIBS= \ $(LINUX_LIBS) \ @@ -54,7 +56,6 @@ LINUX_LINKER_LTO_FLAGS= \ LINUX_LINKER_FLAGS= \ -D_GNU_SOURCE \ - -lSDL2 \ -llua5.3 \ -ldl \ -lm \ @@ -308,7 +309,7 @@ linux32-lto-pro: make linux32-lto OPT="$(OPT)" arm-lto: - $(CC) $(OPT_ARM) $(SOURCES) $(TIC80_SRC) $(OPT) $(INCLUDES) $(LINUX_ARM_LIBS) $(LINUX_LINKER_LTO_FLAGS) -flto -o bin/tic + $(CC) $(LINUX_INCLUDES) $(OPT_ARM) $(SOURCES) $(TIC80_SRC) $(OPT) $(INCLUDES) $(LINUX_ARM_LIBS) $(LINUX_LINKER_LTO_FLAGS) -flto -o bin/tic arm-lto-pro: $(eval OPT += $(OPT_PRO)) From c3bea5fd4b39152c5d6cd94fef0655d5351efa85 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Fri, 17 Nov 2017 19:47:53 +0300 Subject: [PATCH 3/4] added shading to the Code Editor --- src/code.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/code.c b/src/code.c index aeb31b8..d6d3298 100644 --- a/src/code.c +++ b/src/code.c @@ -83,6 +83,7 @@ static void drawCode(Code* code, bool withCursor) if(code->cursor.selection && pointer >= selection.start && pointer < selection.end) code->tic->api.rect(code->tic, x-1, y-1, TIC_FONT_WIDTH+1, TIC_FONT_HEIGHT+1, getConfig()->theme.code.select); + else code->tic->api.draw_char(code->tic, symbol, x+1, y+1, 0); code->tic->api.draw_char(code->tic, symbol, x, y, *colorPointer); From f27394249ef3e3b219ac73a7b2259509ab5b6dbf Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Fri, 17 Nov 2017 23:37:37 +0300 Subject: [PATCH 4/4] blit api performance optimization --- src/tic.c | 28 +++++++++++----------------- src/tools.c | 24 ++---------------------- src/tools.h | 25 +++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 41 deletions(-) diff --git a/src/tic.c b/src/tic.c index 99c1a11..5e0ab7c 100644 --- a/src/tic.c +++ b/src/tic.c @@ -1647,27 +1647,21 @@ static void api_blit(tic_mem* tic, u32* out, tic_scanline scanline) memset4(&out[0 * TIC80_FULLWIDTH], pal[tic->ram.vram.vars.border], TIC80_FULLWIDTH*Top); - for(s32 r = 0; r < TIC80_HEIGHT; r++) + u32* rowPtr = out + Top*TIC80_FULLWIDTH; + + for(s32 r = 0, y = tic->ram.vram.vars.offset.y; r < TIC80_HEIGHT; r++, y++, rowPtr += TIC80_FULLWIDTH) { - memset4(&out[(r+Top) * TIC80_FULLWIDTH], pal[tic->ram.vram.vars.border], Left); - memset4(&out[(r+Top) * TIC80_FULLWIDTH + Left], pal[tic->ram.vram.vars.bg], TIC80_WIDTH); + memset4(rowPtr, pal[tic->ram.vram.vars.border], Left); + memset4(rowPtr + Left, pal[tic->ram.vram.vars.bg], TIC80_WIDTH); - { - s32 y = r + tic->ram.vram.vars.offset.y; + u32* colPtr = rowPtr + Left; - if(y < 0 || y >= TIC80_HEIGHT) continue; - - for(s32 c = 0; c < TIC80_WIDTH; c++) - { - s32 x = c + tic->ram.vram.vars.offset.x; + if(y >= 0 && y < TIC80_HEIGHT) + for(s32 c = 0, x = tic->ram.vram.vars.offset.x, index = y * TIC80_WIDTH + x; c < TIC80_WIDTH; c++, colPtr++, x++, index++) + if(x >= 0 && x < TIC80_WIDTH) + *colPtr = pal[tic_tool_peek4(tic->ram.vram.screen.data, index)]; - if(x < 0 || x >= TIC80_WIDTH) continue; - - out[(c + Left) + (r+Top) * TIC80_FULLWIDTH] = pal[tic_tool_peek4(tic->ram.vram.screen.data, x + y * TIC80_WIDTH)]; - } - } - - memset4(&out[(r+Top) * TIC80_FULLWIDTH + (TIC80_FULLWIDTH-Right)], pal[tic->ram.vram.vars.border], Right); + memset4(rowPtr + (TIC80_FULLWIDTH-Right), pal[tic->ram.vram.vars.border], Right); if(scanline && (r < TIC80_HEIGHT-1)) { diff --git a/src/tools.c b/src/tools.c index 05c7ea8..b4dab40 100644 --- a/src/tools.c +++ b/src/tools.c @@ -25,28 +25,8 @@ #include -void tic_tool_poke4(void* addr, u32 index, u8 value) -{ - u8* val = (u8*)addr + (index >> 1); - - if(index & 1) - { - *val &= 0x0f; - *val |= (value << 4); - } - else - { - *val &= 0xf0; - *val |= value & 0x0f; - } -} - -u8 tic_tool_peek4(const void* addr, u32 index) -{ - u8 val = ((u8*)addr)[index >> 1]; - - return index & 1 ? val >> 4 : val & 0xf; -} +extern void tic_tool_poke4(void* addr, u32 index, u8 value); +extern u8 tic_tool_peek4(const void* addr, u32 index); s32 tic_tool_get_pattern_id(const tic_track* track, s32 frame, s32 channel) { diff --git a/src/tools.h b/src/tools.h index bfa327b..50e5361 100644 --- a/src/tools.h +++ b/src/tools.h @@ -24,8 +24,29 @@ #include "tic.h" -void tic_tool_poke4(void* addr, u32 index, u8 value); -u8 tic_tool_peek4(const void* addr, u32 index); +inline void tic_tool_poke4(void* addr, u32 index, u8 value) +{ + u8* val = (u8*)addr + (index >> 1); + + if(index & 1) + { + *val &= 0x0f; + *val |= (value << 4); + } + else + { + *val &= 0xf0; + *val |= value & 0x0f; + } +} + +inline u8 tic_tool_peek4(const void* addr, u32 index) +{ + u8 val = ((u8*)addr)[index >> 1]; + + return index & 1 ? val >> 4 : val & 0xf; +} + 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);