From eb1e75c969f707b1e409c0a4cdd28c16ebd030b1 Mon Sep 17 00:00:00 2001 From: alice Date: Mon, 26 Aug 2024 14:03:36 +0100 Subject: [PATCH] `build`, `src`: Remove trailing spaces --- build/tools/bin2txt.c | 2 +- src/api.h | 6 +- src/api/js.c | 44 +-- src/api/lua.c | 6 +- src/api/luaapi.c | 70 ++--- src/api/moonscript.c | 2 +- src/api/mruby.c | 20 +- src/api/python.c | 292 +++++++++--------- src/api/scheme.c | 24 +- src/api/squirrel.c | 88 +++--- src/api/wasm.c | 26 +- src/cart.c | 12 +- src/core/core.c | 30 +- src/core/core.h | 6 +- src/core/draw.c | 54 ++-- src/core/io.c | 2 +- src/script.c | 6 +- src/studio/config.c | 8 +- src/studio/editors/code.c | 206 ++++++------ src/studio/editors/map.c | 94 +++--- src/studio/editors/music.c | 170 +++++----- src/studio/editors/music.h | 2 +- src/studio/editors/sfx.c | 82 ++--- src/studio/editors/sfx.h | 2 +- src/studio/editors/sprite.c | 112 +++---- src/studio/editors/sprite.h | 2 +- src/studio/editors/world.c | 2 +- src/studio/fs.c | 24 +- src/studio/net.c | 28 +- src/studio/project.c | 12 +- src/studio/screens/console.c | 24 +- src/studio/screens/console.h | 2 +- src/studio/screens/mainmenu.c | 52 ++-- src/studio/screens/menu.c | 20 +- src/studio/screens/run.c | 4 +- src/studio/screens/run.h | 2 +- src/studio/screens/start.c | 34 +- src/studio/screens/surf.c | 26 +- src/studio/studio.c | 138 ++++----- src/studio/system.h | 2 +- .../baremetalpi/customchargenerator.cpp | 10 +- src/system/baremetalpi/customchargenerator.h | 4 +- src/system/baremetalpi/customscreen.cpp | 30 +- src/system/baremetalpi/customscreen.h | 2 +- src/system/baremetalpi/kernel.cpp | 4 +- src/system/baremetalpi/keycodes.h | 6 +- src/system/baremetalpi/syscore.h | 2 +- src/system/baremetalpi/utils.cpp | 2 +- .../libretro-common/include/libretro.h | 4 +- src/system/libretro/tic80_libretro.c | 2 +- src/system/n3ds/keyboard.c | 6 +- src/system/n3ds/utils.c | 6 +- src/system/sdl/main.c | 114 +++---- src/system/sdl/player.c | 6 +- src/tic.h | 8 +- src/tic_assert.h | 2 +- src/tilesheet.c | 2 +- src/tools.c | 2 +- 58 files changed, 975 insertions(+), 975 deletions(-) diff --git a/build/tools/bin2txt.c b/build/tools/bin2txt.c index 3c3f43dfd..d06cf3c26 100644 --- a/build/tools/bin2txt.c +++ b/build/tools/bin2txt.c @@ -68,7 +68,7 @@ int main(int argc, char** argv) memcpy(buffer, output, size); } - free(output); + free(output); } else printf("memory error :(\n"); } diff --git a/src/api.h b/src/api.h index 99d812942..728cfa5cd 100644 --- a/src/api.h +++ b/src/api.h @@ -40,7 +40,7 @@ typedef struct TraceOutput trace; ErrorOutput error; ExitCallback exit; - + CounterCallback counter; FreqCallback freq; u64 start; @@ -88,9 +88,9 @@ typedef struct } tic_rect; // SYNC DEFINITION TABLE -// .--------------------------------- - - - +// .--------------------------------- - - - // | CART | RAM | INDEX -// |---------+---------------+------- - - - +// |---------+---------------+------- - - - // | | | #define TIC_SYNC_LIST(macro) \ macro(tiles, tiles, 0) \ diff --git a/src/api/js.c b/src/api/js.c index 3d67e82b1..2fe58d4f7 100644 --- a/src/api/js.c +++ b/src/api/js.c @@ -70,14 +70,14 @@ static void js_dump_obj(JSContext *ctx, FILE *f, JSValueConst val) const char *str; tic_core* core = getCore(ctx); - + str = JS_ToCString(ctx, val); - if (str) + if (str) { core->data->error(core->data->data, str); JS_FreeCString(ctx, str); } - else + else { core->data->error(core->data->data, "[exception]\n"); } @@ -87,13 +87,13 @@ static void js_std_dump_error1(JSContext *ctx, JSValueConst exception_val) { JSValue val; bool is_error; - + is_error = JS_IsError(ctx, exception_val); js_dump_obj(ctx, stdout, exception_val); - if (is_error) + if (is_error) { val = JS_GetPropertyStr(ctx, exception_val, "stack"); - if (!JS_IsUndefined(val)) + if (!JS_IsUndefined(val)) { js_dump_obj(ctx, stdout, val); } @@ -104,7 +104,7 @@ static void js_std_dump_error1(JSContext *ctx, JSValueConst exception_val) static void js_std_dump_error(JSContext *ctx) { JSValue exception_val; - + exception_val = JS_GetException(ctx); js_std_dump_error1(ctx, exception_val); JS_FreeValue(ctx, exception_val); @@ -243,7 +243,7 @@ static JSValue js_spr(JSContext *ctx, JSValueConst this_val, s32 argc, JSValueCo s32 scale = getInteger2(ctx, argv[4], 1); - tic_flip flip = JS_IsBool(argv[5]) + tic_flip flip = JS_IsBool(argv[5]) ? JS_ToBool(ctx, argv[5]) ? tic_horz_flip : tic_no_flip : getInteger2(ctx, argv[5], tic_no_flip); @@ -294,7 +294,7 @@ static JSValue js_key(JSContext *ctx, JSValueConst this_val, s32 argc, JSValueCo if(key < tic_keys_count) return JS_NewBool(ctx, core->api.key(tic, key)); - else + else { JSValue err = JS_NewError(ctx); JS_SetPropertyStr(ctx, err, "message", JS_NewString(ctx, "unknown keyboard code")); @@ -328,7 +328,7 @@ static JSValue js_keyp(JSContext *ctx, JSValueConst this_val, s32 argc, JSValueC return JS_NewBool(ctx, core->api.keyp(tic, key, hold, period)); } - else + else { throwError(ctx, "unknown keyboard code"); } @@ -419,12 +419,12 @@ static void remapCallback(void* data, s32 x, s32 y, RemapResult* result) RemapData* remap = (RemapData*)data; JSContext* ctx = remap->ctx; - JSValue res = JS_Call(ctx, remap->func, JS_UNDEFINED, 3, + JSValue res = JS_Call(ctx, remap->func, JS_UNDEFINED, 3, (JSValueConst[]) { - JS_NewInt32(ctx, result->index), - JS_NewInt32(ctx, x), - JS_NewInt32(ctx, y), + JS_NewInt32(ctx, result->index), + JS_NewInt32(ctx, x), + JS_NewInt32(ctx, y), }); if(JS_IsArray(ctx, res)) @@ -830,7 +830,7 @@ static JSValue js_textri(JSContext *ctx, JSValueConst this_val, s32 argc, JSValu count = 1; } - core->api.textri(tic, + core->api.textri(tic, pt[0], pt[1], // xy 1 pt[2], pt[3], // xy 2 pt[4], pt[5], // xy 3 @@ -889,7 +889,7 @@ static JSValue js_ttri(JSContext *ctx, JSValueConst this_val, s32 argc, JSValueC pt[10], pt[11], // uv 3 src, // texture source colors, count, // chroma - z[0], z[1], z[2], depth); // depth + z[0], z[1], z[2], depth); // depth return JS_UNDEFINED; } @@ -1196,11 +1196,11 @@ static void callJavascriptBoot(tic_mem* tic) static const char* const JsKeywords [] = { - "await", "break", "case", "catch", "class", "const", "continue", "debugger", - "default", "delete", "do", "else", "enum", "export", "extends", "false", - "finally", "for", "function", "if", "implements", "import", "in", "instanceof", - "interface", "let", "new", "null", "package", "private", "protected", - "public", "return", "super", "switch", "static", "this", "throw", "try", + "await", "break", "case", "catch", "class", "const", "continue", "debugger", + "default", "delete", "do", "else", "enum", "export", "extends", "false", + "finally", "for", "function", "if", "implements", "import", "in", "instanceof", + "interface", "let", "new", "null", "package", "private", "protected", + "public", "return", "super", "switch", "static", "this", "throw", "try", "true", "typeof", "var", "void", "while", "with", "yield", "of" }; @@ -1266,7 +1266,7 @@ static const tic_outline_item* getJsOutline(const char* code, s32* size) return items; } -static void evalJs(tic_mem* tic, const char* code) +static void evalJs(tic_mem* tic, const char* code) { tic_core* core = (tic_core*)tic; core->data->error(core->data->data, "TODO: JS eval not yet implemented\n."); diff --git a/src/api/lua.c b/src/api/lua.c index 0c118cdfa..d9610426b 100644 --- a/src/api/lua.c +++ b/src/api/lua.c @@ -60,7 +60,7 @@ static const char* const LuaKeywords [] = "and", "break", "do", "else", "elseif", "end", "false", "for", "function", "goto", "if", "in", "local", "nil", "not", "or", "repeat", - "return", "then", "true", "until", "while", + "return", "then", "true", "until", "while", "self" }; @@ -126,7 +126,7 @@ static const tic_outline_item* getLuaOutline(const char* code, s32* size) return items; } -static void evalLua(tic_mem* tic, const char* code) +static void evalLua(tic_mem* tic, const char* code) { tic_core* core = (tic_core*)tic; lua_State* lua = core->currentVM; @@ -206,7 +206,7 @@ static const u8 DemoCar[] = #include "../build/assets/car.tic.dat" }; -TIC_EXPORT const tic_script EXPORT_SCRIPT(Lua) = +TIC_EXPORT const tic_script EXPORT_SCRIPT(Lua) = { .id = 10, .name = "lua", diff --git a/src/api/luaapi.c b/src/api/luaapi.c index 170556de1..da995b819 100644 --- a/src/api/luaapi.c +++ b/src/api/luaapi.c @@ -217,7 +217,7 @@ static s32 lua_pix(lua_State* lua) { s32 x = getLuaNumber(lua, 1); s32 y = getLuaNumber(lua, 2); - + tic_core* core = getLuaCore(lua); tic_mem* tic = (tic_mem*)core; @@ -309,7 +309,7 @@ static s32 lua_circ(lua_State* lua) s32 top = lua_gettop(lua); if(top == 4) - { + { tic_core* core = getLuaCore(lua); tic_mem* tic = (tic_mem*)core; @@ -351,7 +351,7 @@ static s32 lua_elli(lua_State* lua) s32 top = lua_gettop(lua); if(top == 5) - { + { tic_core* core = getLuaCore(lua); tic_mem* tic = (tic_mem*)core; @@ -376,7 +376,7 @@ static s32 lua_ellib(lua_State* lua) { tic_core* core = getLuaCore(lua); tic_mem* tic = (tic_mem*)core; - + s32 x = getLuaNumber(lua, 1); s32 y = getLuaNumber(lua, 2); s32 a = getLuaNumber(lua, 3); @@ -400,7 +400,7 @@ static s32 lua_tri(lua_State* lua) for(s32 i = 0; i < COUNT_OF(pt); i++) pt[i] = lua_tonumber(lua, i+1); - + s32 color = getLuaNumber(lua, 7); tic_core* core = getLuaCore(lua); @@ -423,7 +423,7 @@ static s32 lua_trib(lua_State* lua) for(s32 i = 0; i < COUNT_OF(pt); i++) pt[i] = lua_tonumber(lua, i+1); - + s32 color = getLuaNumber(lua, 7); tic_core* core = getLuaCore(lua); @@ -455,11 +455,11 @@ static s32 lua_textri(lua_State* lua) s32 count = 0; bool use_map = false; - // check for use map + // check for use map if (top >= 13) use_map = lua_toboolean(lua, 13); - // check for chroma + // check for chroma if(top >= 14) { if(lua_istable(lua, 14)) @@ -480,14 +480,14 @@ static s32 lua_textri(lua_State* lua) } } } - else + else { colors[0] = getLuaNumber(lua, 14); count = 1; } } - core->api.textri(tic, + core->api.textri(tic, pt[0], pt[1], // xy 1 pt[2], pt[3], // xy 2 pt[4], pt[5], // xy 3 @@ -523,11 +523,11 @@ static s32 lua_ttri(lua_State* lua) // check for texture src if (top >= 13) { - src = lua_isboolean(lua, 13) - ? (lua_toboolean(lua, 13) ? tic_map_texture : tic_tiles_texture) + src = lua_isboolean(lua, 13) + ? (lua_toboolean(lua, 13) ? tic_map_texture : tic_tiles_texture) : lua_tointeger(lua, 13); } - // check for chroma + // check for chroma if(top >= 14) { if(lua_istable(lua, 14)) @@ -548,7 +548,7 @@ static s32 lua_ttri(lua_State* lua) } } } - else + else { colors[0] = getLuaNumber(lua, 14); count = 1; @@ -663,7 +663,7 @@ static s32 lua_btn(lua_State* lua) { luaL_error(lua, "invalid params, btn [ id ]\n"); return 0; - } + } return 1; } @@ -683,7 +683,7 @@ static s32 lua_spr(lua_State* lua) static u8 colors[TIC_PALETTE_SIZE]; s32 count = 0; - if(top >= 1) + if(top >= 1) { index = getLuaNumber(lua, 1); @@ -712,7 +712,7 @@ static s32 lua_spr(lua_State* lua) } } } - else + else { colors[0] = getLuaNumber(lua, 4); count = 1; @@ -827,7 +827,7 @@ static s32 lua_map(lua_State* lua) s32 top = lua_gettop(lua); - if(top >= 2) + if(top >= 2) { x = getLuaNumber(lua, 1); y = getLuaNumber(lua, 2); @@ -862,7 +862,7 @@ static s32 lua_map(lua_State* lua) } } } - else + else { colors[0] = getLuaNumber(lua, 7); count = 1; @@ -888,7 +888,7 @@ static s32 lua_map(lua_State* lua) luaL_unref(lua, LUA_REGISTRYINDEX, data.reg); return 0; - } + } } } } @@ -1041,7 +1041,7 @@ static s32 lua_sfx(lua_State* lua) speed = getLuaNumber(lua, 6); } } - } + } } } @@ -1140,7 +1140,7 @@ static s32 lua_key(lua_State* lua) { luaL_error(lua, "invalid params, key [code]\n"); return 0; - } + } return 1; } @@ -1311,7 +1311,7 @@ static s32 lua_print(lua_State* lua) { s32 top = lua_gettop(lua); - if(top >= 1) + if(top >= 1) { tic_core* core = getLuaCore(lua); tic_mem* tic = (tic_mem*)core; @@ -1411,7 +1411,7 @@ static s32 lua_pmem(lua_State *lua) lua_pushinteger(lua, val); - return 1; + return 1; } luaL_error(lua, "invalid persistent tic index\n"); @@ -1425,7 +1425,7 @@ static s32 lua_time(lua_State *lua) { tic_core* core = getLuaCore(lua); tic_mem* tic = (tic_mem*)core; - + lua_pushnumber(lua, core->api.time(tic)); return 1; @@ -1447,7 +1447,7 @@ static s32 lua_exit(lua_State *lua) tic_mem* tic = (tic_mem*)core; core->api.exit(tic); - + return 0; } @@ -1611,13 +1611,13 @@ void luaapi_open(lua_State *lua) void luaapi_init(tic_core* core) { - static const struct{lua_CFunction func; const char* name;} ApiItems[] = + static const struct{lua_CFunction func; const char* name;} ApiItems[] = { #define API_FUNC_DEF(name, ...) {lua_ ## name, #name}, TIC_API_LIST(API_FUNC_DEF) #undef API_FUNC_DEF -#if defined(BUILD_DEPRECATED) +#if defined(BUILD_DEPRECATED) {lua_textri, "textri"}, #endif }; @@ -1644,7 +1644,7 @@ void luaapi_close(tic_mem* tic) ** Message handler which appends stract trace to exceptions. ** This function was extractred from lua.c. */ -static s32 msghandler (lua_State *lua) +static s32 msghandler (lua_State *lua) { const char *msg = lua_tostring(lua, 1); if (msg == NULL) /* is error object not a string? */ @@ -1664,7 +1664,7 @@ static s32 msghandler (lua_State *lua) ** Please use this function for all top level lua functions. ** This function was extractred from lua.c (and stripped of signal handling) */ -static s32 docall (lua_State *lua, s32 narg, s32 nres) +static s32 docall (lua_State *lua, s32 narg, s32 nres) { s32 status = 0; s32 base = lua_gettop(lua) - narg; /* function index */ @@ -1684,10 +1684,10 @@ void luaapi_tick(tic_mem* tic) if(lua) { lua_getglobal(lua, TIC_FN); - if(lua_isfunction(lua, -1)) + if(lua_isfunction(lua, -1)) { - if(docall(lua, 0, 0) != LUA_OK) - { + if(docall(lua, 0, 0) != LUA_OK) + { core->data->error(core->data->data, lua_tostring(lua, -1)); return; } @@ -1708,8 +1708,8 @@ void luaapi_tick(tic_mem* tic) } #endif } - else - { + else + { lua_pop(lua, 1); core->data->error(core->data->data, "'function TIC()...' isn't found :("); } diff --git a/src/api/moonscript.c b/src/api/moonscript.c index 3c48907e2..97bf08b39 100644 --- a/src/api/moonscript.c +++ b/src/api/moonscript.c @@ -196,7 +196,7 @@ static const u8 MarkRom[] = #include "../build/assets/moonmark.tic.dat" }; -TIC_EXPORT const tic_script EXPORT_SCRIPT(Moon) = +TIC_EXPORT const tic_script EXPORT_SCRIPT(Moon) = { .id = 13, .name = "moon", diff --git a/src/api/mruby.c b/src/api/mruby.c index d08d13e7f..6ef6f771f 100644 --- a/src/api/mruby.c +++ b/src/api/mruby.c @@ -64,7 +64,7 @@ static mrb_value mrb_peek(mrb_state* mrb, mrb_value self) static mrb_value mrb_poke(mrb_state* mrb, mrb_value self) { tic_core* core = getMRubyMachine(mrb); tic_mem* tic = (tic_mem*)core; - + mrb_int address, value; mrb_int bits = BITS_IN_BYTE; @@ -78,7 +78,7 @@ static mrb_value mrb_poke(mrb_state* mrb, mrb_value self) static mrb_value mrb_peek1(mrb_state* mrb, mrb_value self) { tic_core* core = getMRubyMachine(mrb); tic_mem* tic = (tic_mem*)core; - + mrb_int address; mrb_get_args(mrb, "i", &address); @@ -89,7 +89,7 @@ static mrb_value mrb_peek1(mrb_state* mrb, mrb_value self) static mrb_value mrb_poke1(mrb_state* mrb, mrb_value self) { tic_core* core = getMRubyMachine(mrb); tic_mem* tic = (tic_mem*)core; - + mrb_int address, value; mrb_get_args(mrb, "ii", &address, &value); @@ -102,7 +102,7 @@ static mrb_value mrb_poke1(mrb_state* mrb, mrb_value self) static mrb_value mrb_peek2(mrb_state* mrb, mrb_value self) { tic_core* core = getMRubyMachine(mrb); tic_mem* tic = (tic_mem*)core; - + mrb_int address; mrb_get_args(mrb, "i", &address); @@ -113,7 +113,7 @@ static mrb_value mrb_peek2(mrb_state* mrb, mrb_value self) static mrb_value mrb_poke2(mrb_state* mrb, mrb_value self) { tic_core* core = getMRubyMachine(mrb); tic_mem* tic = (tic_mem*)core; - + mrb_int address, value; mrb_get_args(mrb, "ii", &address, &value); @@ -126,7 +126,7 @@ static mrb_value mrb_poke2(mrb_state* mrb, mrb_value self) static mrb_value mrb_peek4(mrb_state* mrb, mrb_value self) { tic_core* core = getMRubyMachine(mrb); tic_mem* tic = (tic_mem*)core; - + mrb_int address; mrb_get_args(mrb, "i", &address); @@ -137,7 +137,7 @@ static mrb_value mrb_peek4(mrb_state* mrb, mrb_value self) static mrb_value mrb_poke4(mrb_state* mrb, mrb_value self) { tic_core* core = getMRubyMachine(mrb); tic_mem* tic = (tic_mem*)core; - + mrb_int address, value; mrb_get_args(mrb, "ii", &address, &value); @@ -364,7 +364,7 @@ static mrb_value mrb_clip(mrb_state* mrb, mrb_value self) static mrb_value mrb_btnp(mrb_state* mrb, mrb_value self) { tic_core* core = getMRubyMachine(mrb); tic_mem* tic = (tic_mem*)core; - + mrb_int index, hold, period; mrb_int argc = mrb_get_args(mrb, "|iii", &index, &hold, &period); @@ -391,7 +391,7 @@ static mrb_value mrb_btnp(mrb_state* mrb, mrb_value self) static mrb_value mrb_btn(mrb_state* mrb, mrb_value self) { tic_core* core = getMRubyMachine(mrb); tic_mem* tic = (tic_mem*)core; - + mrb_int index, hold, period; mrb_int argc = mrb_get_args(mrb, "|i", &index, &hold, &period); @@ -808,7 +808,7 @@ static mrb_value mrb_key(mrb_state* mrb, mrb_value self) static mrb_value mrb_keyp(mrb_state* mrb, mrb_value self) { tic_core* core = getMRubyMachine(mrb); tic_mem* tic = (tic_mem*)core; - + mrb_int key, hold, period; mrb_int argc = mrb_get_args(mrb, "|iii", &key, &hold, &period); diff --git a/src/api/python.c b/src/api/python.c index d2e7fba0a..0da8e5846 100644 --- a/src/api/python.c +++ b/src/api/python.c @@ -21,7 +21,7 @@ static void pkpy_setglobal_2(pkpy_vm* vm, const char* name){ pkpy_setglobal(vm, pkpy_name(name)); } -static bool get_core(pkpy_vm* vm, tic_core** core) +static bool get_core(pkpy_vm* vm, tic_core** core) { bool ok = pkpy_getglobal(vm, N._tic_core); if(!ok) return false; @@ -30,16 +30,16 @@ static bool get_core(pkpy_vm* vm, tic_core** core) return ok; } -static bool setup_core(pkpy_vm* vm, tic_core* core) +static bool setup_core(pkpy_vm* vm, tic_core* core) { if (!pkpy_push_voidp(vm, core)) return false; return pkpy_setglobal(vm, N._tic_core); } //index should be a positive index -static int prepare_colorindex(pkpy_vm* vm, int index, u8 * buffer) +static int prepare_colorindex(pkpy_vm* vm, int index, u8 * buffer) { - if (pkpy_is_int(vm, index)) + if (pkpy_is_int(vm, index)) { int value; pkpy_to_int(vm, index, &value); @@ -51,8 +51,8 @@ static int prepare_colorindex(pkpy_vm* vm, int index, u8 * buffer) buffer[0] = value; return 1; } - } - else + } + else { //should be a list then pkpy_getglobal(vm, N.len); pkpy_push_null(vm); @@ -65,7 +65,7 @@ static int prepare_colorindex(pkpy_vm* vm, int index, u8 * buffer) list_len = (list_len < TIC_PALETTE_SIZE)?(list_len):(TIC_PALETTE_SIZE); - for(int i = 0; i < list_len; i++) + for(int i = 0; i < list_len; i++) { int list_val; pkpy_dup(vm, index); //get the list @@ -81,7 +81,7 @@ static int prepare_colorindex(pkpy_vm* vm, int index, u8 * buffer) } } -static int py_trace(pkpy_vm* vm) +static int py_trace(pkpy_vm* vm) { pkpy_CString message; int color; @@ -94,7 +94,7 @@ static int py_trace(pkpy_vm* vm) pkpy_to_int(vm, 1, &color); tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; - if (pkpy_check_error(vm)) + if (pkpy_check_error(vm)) { return 0; } @@ -103,23 +103,23 @@ static int py_trace(pkpy_vm* vm) return 0; } -static int py_cls(pkpy_vm* vm) +static int py_cls(pkpy_vm* vm) { - + int color; pkpy_to_int(vm, 0, &color); tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; - if (pkpy_check_error(vm)) + if (pkpy_check_error(vm)) return 0; core->api.cls(tic, (u8) color); return 0; } -static int py_btn(pkpy_vm* vm) +static int py_btn(pkpy_vm* vm) { - + int button_id; tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; @@ -132,9 +132,9 @@ static int py_btn(pkpy_vm* vm) return 1; } -static int py_btnp(pkpy_vm* vm) +static int py_btnp(pkpy_vm* vm) { - + int button_id; int hold; int period; @@ -151,9 +151,9 @@ static int py_btnp(pkpy_vm* vm) return 1; } -static int py_circ(pkpy_vm* vm) +static int py_circ(pkpy_vm* vm) { - + int x; int y; int radius; @@ -171,9 +171,9 @@ static int py_circ(pkpy_vm* vm) return 0; } -static int py_circb(pkpy_vm* vm) +static int py_circb(pkpy_vm* vm) { - + int x; int y; int radius; @@ -191,9 +191,9 @@ static int py_circb(pkpy_vm* vm) return 0; } -static int py_elli(pkpy_vm* vm) +static int py_elli(pkpy_vm* vm) { - + int x; int y; int a; @@ -213,9 +213,9 @@ static int py_elli(pkpy_vm* vm) return 0; } -static int py_ellib(pkpy_vm* vm) +static int py_ellib(pkpy_vm* vm) { - + int x; int y; int a; @@ -235,9 +235,9 @@ static int py_ellib(pkpy_vm* vm) return 0; } -static int py_clip(pkpy_vm* vm) +static int py_clip(pkpy_vm* vm) { - + int x; int y; int w; @@ -255,9 +255,9 @@ static int py_clip(pkpy_vm* vm) return 0; } -static int py_exit(pkpy_vm* vm) +static int py_exit(pkpy_vm* vm) { - + tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; if(pkpy_check_error(vm)) @@ -267,9 +267,9 @@ static int py_exit(pkpy_vm* vm) return 0; } -static int py_fget(pkpy_vm* vm) +static int py_fget(pkpy_vm* vm) { - + int sprite_id; int flag; @@ -284,9 +284,9 @@ static int py_fget(pkpy_vm* vm) return 1; } -static int py_fset(pkpy_vm* vm) +static int py_fset(pkpy_vm* vm) { - + int sprite_id; int flag; bool set_to; @@ -302,9 +302,9 @@ static int py_fset(pkpy_vm* vm) return 0; } -static int py_font(pkpy_vm* vm) +static int py_font(pkpy_vm* vm) { - + pkpy_CString text; int x; int y; @@ -329,12 +329,12 @@ static int py_font(pkpy_vm* vm) return 0; } - if (scale == 0) + if (scale == 0) { pkpy_push_int(vm, 0); return 1; - } - + } + u8 chromakey = (u8) chromakey_raw; s32 size = core->api.font(tic, text, x, y, &chromakey, 1, width, height, fixed, scale, alt); @@ -343,9 +343,9 @@ static int py_font(pkpy_vm* vm) return 1; } -static int py_key(pkpy_vm* vm) +static int py_key(pkpy_vm* vm) { - + int key_id; pkpy_to_int(vm, 0, &key_id); @@ -363,9 +363,9 @@ static int py_key(pkpy_vm* vm) return 1; } -static int py_keyp(pkpy_vm* vm) +static int py_keyp(pkpy_vm* vm) { - + int key_id; int hold; int period; @@ -387,9 +387,9 @@ static int py_keyp(pkpy_vm* vm) return 1; } -static int py_line(pkpy_vm* vm) +static int py_line(pkpy_vm* vm) { - + double x0; double y0; double x1; @@ -430,9 +430,9 @@ static void remap_callback(void* data, s32 x, s32 y, RemapResult* result) { result->rotate = rotate; } -static int py_map(pkpy_vm* vm) +static int py_map(pkpy_vm* vm) { - + int x; int y; int w; @@ -455,21 +455,21 @@ static int py_map(pkpy_vm* vm) pkpy_to_int(vm, 7, &scale); used_remap = !pkpy_is_none(vm, 8); tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) return 0; //last element on the stack should be the function, so no need to adjust anything - if (used_remap) + if (used_remap) core->api.map(tic, x, y, w, h, sx, sy, colors, color_count, scale, remap_callback, vm); - else + else core->api.map(tic, x, y, w, h, sx, sy, colors, color_count, scale, NULL, NULL); return 0; } static int py_memcpy(pkpy_vm* vm) { - - + + int dest; int src; int size; @@ -478,7 +478,7 @@ static int py_memcpy(pkpy_vm* vm) { pkpy_to_int(vm, 1, &src); pkpy_to_int(vm, 2, &size); tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) return 0; core->api.memcpy(tic, dest, src, size); @@ -487,8 +487,8 @@ static int py_memcpy(pkpy_vm* vm) { } static int py_memset(pkpy_vm* vm) { - - + + int dest; int value; int size; @@ -497,7 +497,7 @@ static int py_memset(pkpy_vm* vm) { pkpy_to_int(vm, 1, &value); pkpy_to_int(vm, 2, &size); tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) return 0; core->api.memset(tic, dest, value, size); @@ -506,15 +506,15 @@ static int py_memset(pkpy_vm* vm) { } static int py_mget(pkpy_vm* vm) { - - + + int x; int y; pkpy_to_int(vm, 0, &x); pkpy_to_int(vm, 1, &y); tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) return 0; int value = core->api.mget(tic, x, y); @@ -524,8 +524,8 @@ static int py_mget(pkpy_vm* vm) { } static int py_mset(pkpy_vm* vm) { - - + + int x; int y; int tile_id; @@ -534,7 +534,7 @@ static int py_mset(pkpy_vm* vm) { pkpy_to_int(vm, 1, &y); pkpy_to_int(vm, 2, &tile_id); tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) return 0; core->api.mset(tic, x, y, tile_id); @@ -544,10 +544,10 @@ static int py_mset(pkpy_vm* vm) { static int py_mouse(pkpy_vm* vm) { - + tic_core* core; get_core(vm, &core); - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) return 0; tic_point pos = core->api.mouse((tic_mem*)core); @@ -566,8 +566,8 @@ static int py_mouse(pkpy_vm* vm) { } static int py_music(pkpy_vm* vm) { - - + + int track; int frame; int row; @@ -584,7 +584,7 @@ static int py_music(pkpy_vm* vm) { pkpy_to_int(vm, 5, &tempo); pkpy_to_int(vm, 6, &speed); tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) return 0; if (track > MUSIC_TRACKS - 1 ) @@ -599,15 +599,15 @@ static int py_music(pkpy_vm* vm) { } static int py_peek(pkpy_vm* vm) { - - + + int address; int bits; pkpy_to_int(vm, 0, &address); pkpy_to_int(vm, 1, &bits); tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) return 0; int value = core->api.peek(tic, address, bits); @@ -617,13 +617,13 @@ static int py_peek(pkpy_vm* vm) { } static int py_peek1(pkpy_vm* vm) { - - + + int address; pkpy_to_int(vm, 0, &address); tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) return 0; int value = core->api.peek1(tic, address); @@ -633,13 +633,13 @@ static int py_peek1(pkpy_vm* vm) { } static int py_peek2(pkpy_vm* vm) { - - + + int address; pkpy_to_int(vm, 0, &address); tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) return 0; int value = core->api.peek2(tic, address); @@ -649,13 +649,13 @@ static int py_peek2(pkpy_vm* vm) { } static int py_peek4(pkpy_vm* vm) { - - + + int address; pkpy_to_int(vm, 0, &address); tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) return 0; int value = core->api.peek4(tic, address); @@ -665,7 +665,7 @@ static int py_peek4(pkpy_vm* vm) { } static int py_pix(pkpy_vm* vm) { - + int x; int y; int color = -1; @@ -676,7 +676,7 @@ static int py_pix(pkpy_vm* vm) { tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) return 0; if(color >= 0) { //set the pixel @@ -690,7 +690,7 @@ static int py_pix(pkpy_vm* vm) { } static int py_pmem(pkpy_vm* vm) { - + int index; bool provided_value = false; int value; @@ -701,7 +701,7 @@ static int py_pmem(pkpy_vm* vm) { pkpy_to_int(vm, 1, &value); } tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) return 0; if (index >= TIC_PERSISTENT_SIZE) { @@ -719,8 +719,8 @@ static int py_pmem(pkpy_vm* vm) { } static int py_poke(pkpy_vm* vm) { - - + + int address; int value; int bits; @@ -729,7 +729,7 @@ static int py_poke(pkpy_vm* vm) { pkpy_to_int(vm, 1, &value); pkpy_to_int(vm, 2, &bits); tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) return 0; core->api.poke(tic, address, value, bits); @@ -738,15 +738,15 @@ static int py_poke(pkpy_vm* vm) { } static int py_poke1(pkpy_vm* vm) { - - + + int address; int value; pkpy_to_int(vm, 0, &address); pkpy_to_int(vm, 1, &value); tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) return 0; core->api.poke1(tic, address, value); @@ -755,15 +755,15 @@ static int py_poke1(pkpy_vm* vm) { } static int py_poke2(pkpy_vm* vm) { - - + + int address; int value; pkpy_to_int(vm, 0, &address); pkpy_to_int(vm, 1, &value); tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) return 0; core->api.poke2(tic, address, value); @@ -772,15 +772,15 @@ static int py_poke2(pkpy_vm* vm) { } static int py_poke4(pkpy_vm* vm) { - - + + int address; int value; pkpy_to_int(vm, 0, &address); pkpy_to_int(vm, 1, &value); tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) return 0; core->api.poke4(tic, address, value); @@ -789,8 +789,8 @@ static int py_poke4(pkpy_vm* vm) { } static int py_print(pkpy_vm* vm) { - - + + pkpy_CString text; int x; int y; @@ -820,9 +820,9 @@ static int py_print(pkpy_vm* vm) { return 1; } -static int py_rect(pkpy_vm* vm) +static int py_rect(pkpy_vm* vm) { - + int x; int y; int w; @@ -842,9 +842,9 @@ static int py_rect(pkpy_vm* vm) return 0; } -static int py_rectb(pkpy_vm* vm) +static int py_rectb(pkpy_vm* vm) { - + int x; int y; int w; @@ -864,9 +864,9 @@ static int py_rectb(pkpy_vm* vm) return 0; } -static int py_sfx(pkpy_vm* vm) +static int py_sfx(pkpy_vm* vm) { - + int sfx_id; bool parse_note_flag = false; @@ -892,7 +892,7 @@ static int py_sfx(pkpy_vm* vm) pkpy_to_int(vm, 4, &volume); pkpy_to_int(vm, 5, &speed); tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) goto cleanup; s32 note, octave; @@ -901,7 +901,7 @@ static int py_sfx(pkpy_vm* vm) pkpy_error(vm, "RuntimeError", pkpy_string("invalid note, should like C#4\n")); goto cleanup; //error in future; } - + } else { note = int_note % NOTES; octave = int_note/ NOTES; @@ -925,9 +925,9 @@ cleanup : return 0; } -static int py_spr(pkpy_vm* vm) +static int py_spr(pkpy_vm* vm) { - + int spr_id; int x; int y; @@ -950,7 +950,7 @@ static int py_spr(pkpy_vm* vm) pkpy_to_int(vm, 7, &w); pkpy_to_int(vm, 8, &h); tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) return 0; core->api.spr(tic, spr_id, x, y, w, h, colors, color_count, scale, flip, rotate); @@ -961,7 +961,7 @@ static int py_spr(pkpy_vm* vm) static int py_reset(pkpy_vm* vm) { tic_core* core; get_core(vm, &core); - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) return 0; core->state.initialized = false; @@ -969,9 +969,9 @@ static int py_reset(pkpy_vm* vm) { return 0; } -static int py_sync(pkpy_vm* vm) +static int py_sync(pkpy_vm* vm) { - + int mask; int bank; bool tocart; @@ -993,9 +993,9 @@ static int py_sync(pkpy_vm* vm) return 0; } -static int py_time(pkpy_vm* vm) +static int py_time(pkpy_vm* vm) { - + tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; if(pkpy_check_error(vm)) return 0; @@ -1005,9 +1005,9 @@ static int py_time(pkpy_vm* vm) return 1; } -static int py_tstamp(pkpy_vm* vm) +static int py_tstamp(pkpy_vm* vm) { - + tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; if(pkpy_check_error(vm)) return 0; @@ -1017,9 +1017,9 @@ static int py_tstamp(pkpy_vm* vm) return 1; } -static int py_tri(pkpy_vm* vm) +static int py_tri(pkpy_vm* vm) { - + double x1; double y1; double x2; @@ -1043,9 +1043,9 @@ static int py_tri(pkpy_vm* vm) return 0; } -static int py_trib(pkpy_vm* vm) +static int py_trib(pkpy_vm* vm) { - + double x1; double y1; double x2; @@ -1069,9 +1069,9 @@ static int py_trib(pkpy_vm* vm) return 0; } -static int py_ttri(pkpy_vm* vm) +static int py_ttri(pkpy_vm* vm) { - + double x1; double y1; double x2; @@ -1114,15 +1114,15 @@ static int py_ttri(pkpy_vm* vm) pkpy_to_float(vm, 16, &z3); tic_core* core; get_core(vm, &core); tic_mem* tic = (tic_mem*)core; - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) return 0; core->api.ttri( - tic, - x1,y1,x2,y2,x3,y3, - u1,v1,u2,v2,u3,v3, - texsrc, - colors,color_count, + tic, + x1,y1,x2,y2,x3,y3, + u1,v1,u2,v2,u3,v3, + texsrc, + colors,color_count, z1,z2,z3, z1 != 0 || z2 != 0 || z3 != 0 ); @@ -1138,7 +1138,7 @@ static int py_vbank(pkpy_vm* vm) { if (!pkpy_is_none(vm, 0)) pkpy_to_int(vm, 0, &bank_id); get_core(vm, &core); - if(pkpy_check_error(vm)) + if(pkpy_check_error(vm)) return 0; tic_mem* tic = (tic_mem*) core; @@ -1326,7 +1326,7 @@ static bool setup_c_bindings(pkpy_vm* vm) { return true; } -void closePython(tic_mem* tic) +void closePython(tic_mem* tic) { tic_core* core = (tic_core*)tic; @@ -1341,13 +1341,13 @@ static void report_error(tic_core* core, char* prefix) { pkpy_vm* vm = core->currentVM; core->data->error(core->data->data, prefix); char* message; - if (!pkpy_clear_error(vm, &message)) + if (!pkpy_clear_error(vm, &message)) core->data->error(core->data->data, "error was thrown but not register (pocketpy c binding bug)"); else core->data->error(core->data->data, message); } -static bool initPython(tic_mem* tic, const char* code) +static bool initPython(tic_mem* tic, const char* code) { N._tic_core = pkpy_name("_tic_core"); N.len = pkpy_name("len"); @@ -1375,7 +1375,7 @@ static bool initPython(tic_mem* tic, const char* code) return false; } - if(!pkpy_exec(vm, code)) + if(!pkpy_exec(vm, code)) { report_error(core, "error while processing the main code\n"); @@ -1385,10 +1385,10 @@ static bool initPython(tic_mem* tic, const char* code) return true; } -void callPythonTick(tic_mem* tic) +void callPythonTick(tic_mem* tic) { tic_core* core = (tic_core*)tic; - if (!core->currentVM) + if (!core->currentVM) return; if(!pkpy_getglobal(core->currentVM, N.TIC)) return; @@ -1402,11 +1402,11 @@ void callPythonTick(tic_mem* tic) } void callPythonBoot(tic_mem* tic) { tic_core* core = (tic_core*)tic; - if (!core->currentVM) + if (!core->currentVM) return; if(!pkpy_getglobal(core->currentVM, N.BOOT)) return; - + pkpy_push_null(core->currentVM); if(!pkpy_vectorcall(core->currentVM, 0)){ report_error(core, "error while running BOOT\n"); @@ -1417,7 +1417,7 @@ void callPythonBoot(tic_mem* tic) { void callPythonScanline(tic_mem* tic, s32 row, void* data) { tic_core* core = (tic_core*)tic; - if (!core->currentVM) + if (!core->currentVM) return; if(!pkpy_getglobal(core->currentVM, N.SCN)) return; @@ -1433,7 +1433,7 @@ void callPythonScanline(tic_mem* tic, s32 row, void* data) { void callPythonBorder(tic_mem* tic, s32 row, void* data) { tic_core* core = (tic_core*)tic; - if (!core->currentVM) + if (!core->currentVM) return; if(!pkpy_getglobal(core->currentVM, N.BDR)) return; @@ -1449,7 +1449,7 @@ void callPythonBorder(tic_mem* tic, s32 row, void* data) { void callPythonMenu(tic_mem* tic, s32 index, void* data) { tic_core* core = (tic_core*)tic; - if (!core->currentVM) + if (!core->currentVM) return; if(pkpy_getglobal(core->currentVM, N.MENU)) return; @@ -1465,19 +1465,19 @@ void callPythonMenu(tic_mem* tic, s32 index, void* data) { static bool is_alnum_(char c) { return ( - (c >= 'a' && c <= 'z') - || (c >= 'A' && c <= 'Z') - || (c >= '0' && c <= '9') + (c >= 'a' && c <= 'z') + || (c >= 'A' && c <= 'Z') + || (c >= '0' && c <= '9') || (c == '_') ); } -static const tic_outline_item* getPythonOutline(const char* code, s32* size) +static const tic_outline_item* getPythonOutline(const char* code, s32* size) { *size = 0; static tic_outline_item* items = NULL; - if (items) + if (items) { free(items); items = NULL; @@ -1487,7 +1487,7 @@ static const tic_outline_item* getPythonOutline(const char* code, s32* size) start: if (*code == 0) goto end; - else if (strncmp(code, "def", 3) == 0) { code += 3; goto next_word_ws; } + else if (strncmp(code, "def", 3) == 0) { code += 3; goto next_word_ws; } else if (*code == '#') { code++; goto comment; } else if (strncmp(code, "\"\"\"", 3) == 0) { code += 3; goto multiline_string; } else if (*code == '"') { code++; goto string; } @@ -1502,7 +1502,7 @@ next_word_ws : next_word : if (is_alnum_(*code)) { code++; goto next_word; } else //store item - { + { items = realloc(items, (*size + 1) * sizeof(tic_outline_item)); items[*size].pos = name_start; items[*size].size = (s32)(code - name_start); @@ -1540,13 +1540,13 @@ multiline_string_escape : } -void evalPython(tic_mem* tic, const char* code) +void evalPython(tic_mem* tic, const char* code) { tic_core* core = (tic_core*)tic; pkpy_vm* vm = core->currentVM; if (!vm) return; - if(!pkpy_exec(vm, code)) + if(!pkpy_exec(vm, code)) { report_error(core, "error while evaluating the code\n"); } diff --git a/src/api/scheme.c b/src/api/scheme.c index 522601bdd..84c38c3f4 100644 --- a/src/api/scheme.c +++ b/src/api/scheme.c @@ -76,7 +76,7 @@ s7_pointer scheme_pix(s7_scheme* sc, s7_pointer args) else{ return s7_make_integer(sc, core->api.pix(tic, x, y, 0, true)); } - + } s7_pointer scheme_line(s7_scheme* sc, s7_pointer args) { @@ -166,7 +166,7 @@ s7_pointer scheme_btn(s7_scheme* sc, s7_pointer args) // btn(id) -> pressed tic_core* core = getSchemeCore(sc); tic_mem* tic = (tic_mem*)core; const s32 id = s7_integer(s7_car(args)); - + return s7_make_boolean(sc, core->api.btn(tic, id)); } s7_pointer scheme_btnp(s7_scheme* sc, s7_pointer args) @@ -178,7 +178,7 @@ s7_pointer scheme_btnp(s7_scheme* sc, s7_pointer args) const int argn = s7_list_length(sc, args); const s32 hold = argn > 1 ? s7_integer(s7_cadr(args)) : -1; const s32 period = argn > 2 ? s7_integer(s7_caddr(args)) : -1; - + return s7_make_boolean(sc, core->api.btnp(tic, id, hold, period)); } @@ -215,7 +215,7 @@ s7_pointer scheme_sfx(s7_scheme* sc, s7_pointer args) // sfx(id note=-1 duration=-1 channel=0 volume=15 speed=0) tic_core* core = getSchemeCore(sc); tic_mem* tic = (tic_mem*)core; const s32 id = s7_integer(s7_car(args)); - + const int argn = s7_list_length(sc, args); int note = -1; int octave = -1; @@ -252,7 +252,7 @@ s7_pointer scheme_sfx(s7_scheme* sc, s7_pointer args) /* } */ } } - + const s32 duration = argn > 2 ? s7_integer(s7_caddr(args)) : -1; const s32 channel = argn > 3 ? s7_integer(s7_cadddr(args)) : 0; @@ -512,7 +512,7 @@ s7_pointer scheme_mouse(s7_scheme* sc, s7_pointer args) tic_core* core = getSchemeCore(sc); tic_mem* tic = (tic_mem*)core; const tic_point point = core->api.mouse(tic); const tic80_mouse* mouse = &((tic_core*)tic)->memory.ram->input.mouse; - + return s7_cons(sc, s7_make_integer(sc, point.x), s7_cons(sc, s7_make_integer(sc, point.y), @@ -616,7 +616,7 @@ s7_pointer scheme_ttri(s7_scheme* sc, s7_pointer args) const int argn = s7_list_length(sc, args); const tic_texture_src texsrc = (tic_texture_src)(argn > 12 ? s7_integer(s7_list_ref(sc, args, 12)) : 0); - + static u8 trans_colors[TIC_PALETTE_SIZE]; u8 trans_count = 0; @@ -732,7 +732,7 @@ s7_pointer scheme_fset(s7_scheme* sc, s7_pointer args) const u8 flag = s7_integer(s7_cadr(args)); const bool val = s7_boolean(sc, s7_caddr(args)); core->api.fset(tic, sprite_id, flag, val); - return s7_nil(sc); + return s7_nil(sc); } s7_pointer scheme_fft(s7_scheme* sc, s7_pointer args) @@ -766,10 +766,10 @@ static void initAPI(tic_core* core) #define API_FUNC_DEF(name, desc, helpstr, count, reqcount, ...) \ {scheme_ ## name, desc "\n" helpstr, count, reqcount, "t80::" #name}, - + static const struct{s7_function func; const char* helpstr; int count; int reqcount; const char* name;} ApiItems[] = {TIC_API_LIST(API_FUNC_DEF)}; - + #undef API_FUNC_DEF for (s32 i = 0; i < COUNT_OF(ApiItems); i++) { @@ -847,7 +847,7 @@ static bool initScheme(tic_mem* tic, const char* code) s7_define_variable(sc, TicCore, s7_make_c_pointer(sc, core)); s7_load_c_string(sc, code, strlen(code)); - + const bool isTicDefined = s7_is_defined(sc, ticFnName); if (!isTicDefined) { @@ -1029,7 +1029,7 @@ void evalScheme(tic_mem* tic, const char* code) { return; sc = core->currentVM; } - + s7_eval_c_string(sc, code); } diff --git a/src/api/squirrel.c b/src/api/squirrel.c index 590c17231..4ba1b76fe 100644 --- a/src/api/squirrel.c +++ b/src/api/squirrel.c @@ -48,7 +48,7 @@ static s32 getSquirrelNumber(HSQUIRRELVM vm, s32 index) SQInteger i; if (SQ_SUCCEEDED(sq_getinteger(vm, index, &i))) return (s32)i; - + return (s32)getSquirrelFloat(vm, index); } @@ -85,13 +85,13 @@ static tic_core* getSquirrelCore(HSQUIRRELVM vm) #endif } -void squirrel_compilerError(HSQUIRRELVM vm, const SQChar* desc, const SQChar* source, +void squirrel_compilerError(HSQUIRRELVM vm, const SQChar* desc, const SQChar* source, SQInteger line, SQInteger column) { tic_core* core = getSquirrelCore(vm); char buffer[1024]; snprintf(buffer, 1023, "%.40s line %.6d column %.6d: %s\n", source, (int)line, (int)column, desc); - + if (core->data) core->data->error(core->data->data, buffer); } @@ -106,7 +106,7 @@ static SQInteger squirrel_errorHandler(HSQUIRRELVM vm) { char buffer[100]; snprintf(buffer, 99, "%.40s %.40s %.6d\n", si.funcname, si.source, (int)si.line); - + if (core->data) core->data->error(core->data->data, buffer); ++level; @@ -118,7 +118,7 @@ static SQInteger squirrel_errorHandler(HSQUIRRELVM vm) static SQInteger squirrel_peek(HSQUIRRELVM vm) { - tic_core* core = getSquirrelCore(vm); tic_mem* tic = (tic_mem*)core; + tic_core* core = getSquirrelCore(vm); tic_mem* tic = (tic_mem*)core; SQInteger top = sq_gettop(vm); // check number of args @@ -258,7 +258,7 @@ static SQInteger squirrel_pix(HSQUIRRELVM vm) { s32 x = getSquirrelNumber(vm, 2); s32 y = getSquirrelNumber(vm, 3); - + tic_core* core = getSquirrelCore(vm); tic_mem* tic = (tic_mem*)core; if(top >= 4) @@ -346,7 +346,7 @@ static SQInteger squirrel_circ(HSQUIRRELVM vm) SQInteger top = sq_gettop(vm); if(top == 5) - { + { s32 x = getSquirrelNumber(vm, 2); s32 y = getSquirrelNumber(vm, 3); s32 radius = getSquirrelNumber(vm, 4); @@ -433,7 +433,7 @@ static SQInteger squirrel_tri(HSQUIRRELVM vm) for(s32 i = 0; i < COUNT_OF(pt); i++) pt[i] = getSquirrelFloat(vm, i + 2); - + s32 color = getSquirrelNumber(vm, 8); tic_core* core = getSquirrelCore(vm); tic_mem* tic = (tic_mem*)core; @@ -455,7 +455,7 @@ static SQInteger squirrel_trib(HSQUIRRELVM vm) for(s32 i = 0; i < COUNT_OF(pt); i++) pt[i] = getSquirrelFloat(vm, i + 2); - + s32 color = getSquirrelNumber(vm, 8); tic_core* core = getSquirrelCore(vm); tic_mem* tic = (tic_mem*)core; @@ -488,7 +488,7 @@ static SQInteger squirrel_ttri(HSQUIRRELVM vm) { src = getSquirrelNumber(vm, 14); } - // check for chroma + // check for chroma if(OT_ARRAY == sq_gettype(vm, 15)) { for(s32 i = 0; i < TIC_PALETTE_SIZE; i++) @@ -508,7 +508,7 @@ static SQInteger squirrel_ttri(HSQUIRRELVM vm) } } } - else + else { colors[0] = getSquirrelNumber(vm, 15); count = 1; @@ -618,7 +618,7 @@ static SQInteger squirrel_btn(HSQUIRRELVM vm) else { return sq_throwerror(vm, "invalid params, btn [ id ]\n"); - } + } return 1; } @@ -638,7 +638,7 @@ static SQInteger squirrel_spr(HSQUIRRELVM vm) static u8 colors[TIC_PALETTE_SIZE]; s32 count = 0; - if(top >= 2) + if(top >= 2) { index = getSquirrelNumber(vm, 2); @@ -668,7 +668,7 @@ static SQInteger squirrel_spr(HSQUIRRELVM vm) } } } - else + else { colors[0] = getSquirrelNumber(vm, 5); count = 1; @@ -756,7 +756,7 @@ static void remapCallback(void* data, s32 x, s32 y, RemapResult* result) HSQUIRRELVM vm = remap->vm; SQInteger top = sq_gettop(vm); - + sq_pushobject(vm, remap->reg); sq_pushroottable(vm); sq_pushinteger(vm, result->index); @@ -803,7 +803,7 @@ static SQInteger squirrel_map(HSQUIRRELVM vm) SQInteger top = sq_gettop(vm); - if(top >= 3) + if(top >= 3) { x = getSquirrelNumber(vm, 2); y = getSquirrelNumber(vm, 3); @@ -839,7 +839,7 @@ static SQInteger squirrel_map(HSQUIRRELVM vm) } } } - else + else { colors[0] = getSquirrelNumber(vm, 8); count = 1; @@ -867,7 +867,7 @@ static SQInteger squirrel_map(HSQUIRRELVM vm) sq_release(vm, &data.reg); return 0; - } + } } } } @@ -1020,7 +1020,7 @@ static SQInteger squirrel_sfx(HSQUIRRELVM vm) speed = getSquirrelNumber(vm, 7); } } - } + } } } @@ -1118,7 +1118,7 @@ static SQInteger squirrel_key(HSQUIRRELVM vm) else { return sq_throwerror(vm, "invalid params, key [code]\n"); - } + } return 1; } @@ -1211,7 +1211,7 @@ static const char* printString(HSQUIRRELVM vm, s32 index) { sq_getstring(vm, -1, &text); } - + return (const char*)text; } @@ -1255,14 +1255,14 @@ static SQInteger squirrel_font(HSQUIRRELVM vm) if(top >= 9) { scale = getSquirrelNumber(vm, 9); - + if (top >= 10) { SQBool b = SQFalse; sq_getbool(vm, 10, &b); alt = (b != SQFalse); } - + } } } @@ -1288,7 +1288,7 @@ static SQInteger squirrel_print(HSQUIRRELVM vm) { SQInteger top = sq_gettop(vm); - if(top >= 2) + if(top >= 2) { tic_core* core = getSquirrelCore(vm); tic_mem* tic = (tic_mem*)core; @@ -1319,7 +1319,7 @@ static SQInteger squirrel_print(HSQUIRRELVM vm) if(top >= 7) { scale = getSquirrelNumber(vm, 7); - + if (top >= 8) { SQBool b = SQFalse; @@ -1390,7 +1390,7 @@ static SQInteger squirrel_pmem(HSQUIRRELVM vm) sq_pushinteger(vm, val); - return 1; + return 1; } return sq_throwerror(vm, "invalid persistent tic index\n"); } @@ -1402,7 +1402,7 @@ static SQInteger squirrel_pmem(HSQUIRRELVM vm) static SQInteger squirrel_time(HSQUIRRELVM vm) { tic_core* core = getSquirrelCore(vm); tic_mem* tic = (tic_mem*)core; - + sq_pushfloat(vm, (SQFloat)(core->api.time(tic))); return 1; @@ -1411,7 +1411,7 @@ static SQInteger squirrel_time(HSQUIRRELVM vm) static SQInteger squirrel_tstamp(HSQUIRRELVM vm) { tic_core* core = getSquirrelCore(vm); tic_mem* tic = (tic_mem*)core; - + sq_pushinteger(vm, core->api.tstamp(tic)); return 1; @@ -1421,7 +1421,7 @@ static SQInteger squirrel_exit(HSQUIRRELVM vm) { tic_core* core = getSquirrelCore(vm); tic_mem* tic = (tic_mem*)core; core->api.exit(tic); - + return 0; } @@ -1499,7 +1499,7 @@ static SQInteger squirrel_fset(HSQUIRRELVM vm) sq_getbool(vm, 4, &value); core->api.fset(tic, index, flag, value); - return 0; + return 0; } } } @@ -1583,9 +1583,9 @@ static void squirrel_open_builtins(HSQUIRRELVM vm) static void initAPI(tic_core* core) { HSQUIRRELVM vm = core->currentVM; - + sq_setcompilererrorhandler(vm, squirrel_compilerError); - + sq_pushregistrytable(vm); sq_pushstring(vm, TicCore, -1); sq_pushuserpointer(core->currentVM, core); @@ -1640,7 +1640,7 @@ static bool initSquirrel(tic_mem* tic, const char* code) sq_settop(vm, 0); - if((SQ_FAILED(sq_compilebuffer(vm, code, strlen(code), "squirrel", SQTrue))) || + if((SQ_FAILED(sq_compilebuffer(vm, code, strlen(code), "squirrel", SQTrue))) || (sq_pushroottable(vm), false) || (SQ_FAILED(sq_call(vm, 1, SQFalse, SQTrue)))) { @@ -1651,7 +1651,7 @@ static bool initSquirrel(tic_mem* tic, const char* code) if (core->data) core->data->error(core->data->data, errorString); - + sq_pop(vm, 2); // error and error string return false; @@ -1674,7 +1674,7 @@ static void errorReport(tic_mem* tic) if (core->data) core->data->error(core->data->data, errorString); - sq_pop(vm, 3); // remove string, error and root table. + sq_pop(vm, 3); // remove string, error and root table. } static void callSquirrelTick(tic_mem* tic) @@ -1702,8 +1702,8 @@ static void callSquirrelTick(tic_mem* tic) { sq_pushroottable(vm); sq_pushstring(vm, OVR_FN, -1); - - if(SQ_SUCCEEDED(sq_get(vm, -2))) + + if(SQ_SUCCEEDED(sq_get(vm, -2))) { OVR(core) { @@ -1712,15 +1712,15 @@ static void callSquirrelTick(tic_mem* tic) if(SQ_FAILED(sq_call(vm, 1, SQFalse, SQTrue))) { errorReport(tic); - } + } } } - else sq_poptop(vm); + else sq_poptop(vm); } #endif } - else - { + else + { sq_pop(vm, 1); if (core->data) core->data->error(core->data->data, "'function TIC()...' isn't found :("); @@ -1882,10 +1882,10 @@ void evalSquirrel(tic_mem* tic, const char* code) { return; vm = core->currentVM; } - + sq_settop(vm, 0); - if((SQ_FAILED(sq_compilebuffer(vm, code, strlen(code), "squirrel", SQTrue))) || + if((SQ_FAILED(sq_compilebuffer(vm, code, strlen(code), "squirrel", SQTrue))) || (sq_pushroottable(vm), false) || (SQ_FAILED(sq_call(vm, 1, SQFalse, SQTrue)))) { @@ -1910,7 +1910,7 @@ static const u8 MarkRom[] = #include "../build/assets/squirrelmark.tic.dat" }; -TIC_EXPORT const tic_script EXPORT_SCRIPT(Squirrel) = +TIC_EXPORT const tic_script EXPORT_SCRIPT(Squirrel) = { .id = 15, .name = "squirrel", diff --git a/src/api/wasm.c b/src/api/wasm.c index d389b6d65..d5c960cfd 100644 --- a/src/api/wasm.c +++ b/src/api/wasm.c @@ -291,14 +291,14 @@ m3ApiRawFunction(wasmtic_ttri) m3ApiGetArg (float, z1) m3ApiGetArg (float, z2) m3ApiGetArg (float, z3) - m3ApiGetArg (bool, depth) + m3ApiGetArg (bool, depth) if (trans_colors == NULL) { colorCount = 0; } tic_core* core = getWasmCore(runtime); tic_mem* tic = (tic_mem*)core; - - core->api.ttri(tic, x1, y1, x2, y2, x3, y3, + + core->api.ttri(tic, x1, y1, x2, y2, x3, y3, u1, v1, u2, v2, u3, v3, texsrc, trans_colors, colorCount, z1, z2, z3, depth); m3ApiSuccess(); @@ -365,7 +365,7 @@ m3ApiRawFunction(wasmtic_btnp) // -1 is the "default" placeholder for index, hold, and period but the TIC side API // knows this so we don't need to do any transaction, we can just pass the -1 values - // straight thru + // straight thru m3ApiReturn(core->api.btnp((tic_mem *)core, index, hold, period)); @@ -414,7 +414,7 @@ m3ApiRawFunction(wasmtic_fget) m3ApiGetArg (int32_t, sprite_index); m3ApiGetArg (int8_t, flag); - + tic_core* core = getWasmCore(runtime); tic_mem* tic = (tic_mem*)core; m3ApiReturn(core->api.fget(tic, sprite_index, flag)); @@ -441,7 +441,7 @@ m3ApiRawFunction(wasmtic_mget) m3ApiGetArg (int32_t, x); m3ApiGetArg (int32_t, y); - + tic_core* core = getWasmCore(runtime); tic_mem* tic = (tic_mem*)core; m3ApiReturn(core->api.mget(tic, x, y)); @@ -579,7 +579,7 @@ m3ApiRawFunction(wasmtic_pmem) tic_core* core = getWasmCore(runtime); tic_mem* tic = (tic_mem*)core; // read value - if (value == -1) { + if (value == -1) { writeToStorage = false; }; @@ -590,7 +590,7 @@ m3ApiRawFunction(wasmtic_pmem) u32 val = core->api.pmem(tic, address, value, writeToStorage); m3ApiReturn(val); } - + m3ApiSuccess(); } @@ -683,7 +683,7 @@ static void wasm_remap(void* data, s32 x, s32 y, RemapResult* result) { *rdata->wasm_result = *result; M3Result res = m3_CallV(fun, rdata->data, x, y, m3ApiPtrToOffset(rdata->wasm_result)); - if (res) { + if (res) { rdata->core->data->error(rdata->core->data->data, res); return; } @@ -704,7 +704,7 @@ m3ApiRawFunction(wasmtic_map) colorCount = 0; } m3ApiGetArg (int8_t, scale) m3ApiGetArg (i32, map_data_ptr) - + tic_core* core = getWasmCore(runtime); tic_mem* tic = (tic_mem*)core; // depends on their only being 1 module, which SHOULD:tm: be true @@ -716,7 +716,7 @@ m3ApiRawFunction(wasmtic_map) info.wasm_result = (RemapResult*)m3ApiOffsetToPtr(map_data->res_ptr); } // defaults - if (x == -1) { x = 0; } + if (x == -1) { x = 0; } if (y == -1) { y = 0; } if (w == -1) { w = 30; } if (h == -1) { h = 17; } @@ -791,7 +791,7 @@ m3ApiRawFunction(wasmtic_font) m3ApiSuccess(); } -// audio +// audio // id [note] [duration=-1] [channel=0] [volume=15] [speed=0] m3ApiRawFunction(wasmtic_sfx) @@ -810,7 +810,7 @@ m3ApiRawFunction(wasmtic_sfx) if (channel >= 0 && channel < TIC_SOUND_CHANNELS) { core->api.sfx(tic, sfx_id, note, octave, duration, channel, volumeLeft & 0xf, volumeRight & 0xf, speed); - } + } m3ApiSuccess(); } diff --git a/src/cart.c b/src/cart.c index da90785b9..5fec3ff66 100644 --- a/src/cart.c +++ b/src/cart.c @@ -172,10 +172,10 @@ void tic_cart_load(tic_cartridge* cart, const u8* buffer, s32 size) case CHUNK_FLAGS: LOAD_CHUNK(cart->banks[chunk->bank].flags); break; case CHUNK_SCREEN: LOAD_CHUNK(cart->banks[chunk->bank].screen); break; case CHUNK_LANG: LOAD_CHUNK(cart->lang); break; - case CHUNK_BINARY: + case CHUNK_BINARY: binary[chunk->bank] = (struct BinaryChunk){chunkSize(chunk), ptr}; break; - case CHUNK_CODE: + case CHUNK_CODE: code[chunk->bank] = (struct CodeChunk){chunkSize(chunk), (char*)ptr}; break; #if defined(BUILD_DEPRECATED) @@ -191,14 +191,14 @@ void tic_cart_load(tic_cartridge* cart, const u8* buffer, s32 size) { if(image->width == TIC80_WIDTH && image->height == TIC80_HEIGHT) for (s32 i = 0; i < TIC80_WIDTH * TIC80_HEIGHT; i++) - tic_tool_poke4(cart->bank0.screen.data, i, + tic_tool_poke4(cart->bank0.screen.data, i, tic_nearest_color(cart->bank0.palette.vbank0.colors, (const tic_rgb*)&image->palette[image->buffer[i]], TIC_PALETTE_SIZE)); gif_close(image); } } break; - case CHUNK_PATTERNS_DEP: + case CHUNK_PATTERNS_DEP: { // workaround to load deprecated music patterns section // and automatically convert volume value to a command @@ -330,11 +330,11 @@ s32 tic_cart_save(const tic_cartridge* cart, u8* buffer) } const char* ptr; - if (cart->binary.size) + if (cart->binary.size) { ptr = cart->binary.data; s32 remaining = cart->binary.size; - for (s32 i = cart->binary.size / TIC_BANK_SIZE; i >= 0; --i, ptr += TIC_BANK_SIZE) + for (s32 i = cart->binary.size / TIC_BANK_SIZE; i >= 0; --i, ptr += TIC_BANK_SIZE) { buffer = saveFixedChunk(buffer, CHUNK_BINARY, ptr, MIN(remaining, TIC_BANK_SIZE), i); remaining -= TIC_BANK_SIZE; diff --git a/src/core/core.c b/src/core/core.c index 812ae32f3..61c099ec8 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -78,7 +78,7 @@ void tic_api_poke(tic_mem* memory, s32 address, u8 value, s32 bits) tic_core* core = (tic_core*)memory; u8* ram = (u8*)memory->ram; enum{RamBits = sizeof(tic_ram) * BITS_IN_BYTE}; - + switch(bits) { case 1: if(address < RamBits / 1) tic_tool_poke1(ram, address, value); break; @@ -194,10 +194,10 @@ void tic_api_sync(tic_mem* tic, u32 mask, s32 bank, bool toCart) { tic_core* core = (tic_core*)tic; - static const struct { s32 bank; s32 ram; s32 size; u8 mask; } Sections[] = - { + static const struct { s32 bank; s32 ram; s32 size; u8 mask; } Sections[] = + { #define TIC_SYNC_DEF(CART, RAM, ...) { offsetof(tic_bank, CART), offsetof(tic_ram, RAM), sizeof(tic_##CART), tic_sync_##CART }, - TIC_SYNC_LIST(TIC_SYNC_DEF) + TIC_SYNC_LIST(TIC_SYNC_DEF) #undef TIC_SYNC_DEF }; @@ -229,7 +229,7 @@ void tic_api_sync(tic_mem* tic, u32 mask, s32 bank, bool toCart) { sync(tic->ram->data + Sections[i].ram, (u8*)bankPtr + Sections[i].bank, size, toCart); } - } + } } core->state.synced |= mask; @@ -301,30 +301,30 @@ static void resetVbank(tic_mem* memory) static void font2ram(tic_mem* memory) { memory->ram->font = (tic_font) { - .regular = + .regular = { - .data = + .data = { #include "font.inl" }, { { - .width = TIC_FONT_WIDTH, + .width = TIC_FONT_WIDTH, .height = TIC_FONT_HEIGHT, } - } + } }, - .alt = + .alt = { - .data = + .data = { #include "altfont.inl" }, { { - .width = TIC_ALTFONT_WIDTH, - .height = TIC_FONT_HEIGHT, + .width = TIC_ALTFONT_WIDTH, + .height = TIC_FONT_HEIGHT, } } }, @@ -567,7 +567,7 @@ void tic_core_tick_end(tic_mem* memory) core->state.gamepads.previous.data = input->gamepads.data; // SECURITY: we do not use `memory.ram.input` here because it is - // untrustworthy since the cartridge could have modified it to + // untrustworthy since the cartridge could have modified it to // inject artificial keyboard/gamepad events. core->state.keyboard.previous.data = core->state.keyboard.now.data; core->state.gamepads.previous.data = core->state.gamepads.now.data; @@ -677,7 +677,7 @@ void tic_core_blit_ex(tic_mem* tic, tic_blit_callback clb) s32 offsetX1 = vbank1(core)->vars.offset.x; for(s32 x = TIC80_WIDTH; x != 2 * TIC80_WIDTH; ++x) - *rowPtr++ = blitpix(tic, (x + offsetX0) % TIC80_WIDTH + start0, + *rowPtr++ = blitpix(tic, (x + offsetX0) % TIC80_WIDTH + start0, (x + offsetX1) % TIC80_WIDTH + start1, &pal0, &pal1); } diff --git a/src/core/core.h b/src/core/core.h index 273072b1f..cffede324 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -106,7 +106,7 @@ typedef struct u32 holds[sizeof(tic80_gamepads) * BITS_IN_BYTE]; } gamepads; - struct + struct { tic80_keyboard previous; tic80_keyboard now; @@ -151,7 +151,7 @@ typedef struct tic_tick tick; tic_blit_callback callback; - + u32 synced; struct @@ -181,7 +181,7 @@ typedef struct struct blip_t* left; struct blip_t* right; } blip; - + s32 samplerate; tic_tick_data* data; tic_core_state_data state; diff --git a/src/core/draw.c b/src/core/draw.c index a690a7144..79e5b2020 100644 --- a/src/core/draw.c +++ b/src/core/draw.c @@ -512,28 +512,28 @@ static void drawEllipse(tic_mem* memory, s32 x0, s32 y0, s32 x1, s32 y1, u8 colo s64 dx = 4 * (1 - a) * b * b, dy = 4 * (b1 + 1) * a * a; /* error increment */ s64 err = dx + dy + b1 * a * a, e2; /* error of 1.step */ - if (x0 > x1) { x0 = x1; x1 += a; } /* if called with swapped pos32s */ + if (x0 > x1) { x0 = x1; x1 += a; } /* if called with swapped pos32s */ if (y0 > y1) y0 = y1; /* .. exchange them */ y0 += (b + 1) / 2; y1 = y0 - b1; /* starting pixel */ a *= 8 * a; b1 = 8 * b * b; - do + do { pix(memory, x1, y0, color); /* I. Quadrant */ pix(memory, x0, y0, color); /* II. Quadrant */ pix(memory, x0, y1, color); /* III. Quadrant */ pix(memory, x1, y1, color); /* IV. Quadrant */ e2 = 2 * err; - if (e2 <= dy) { y0++; y1--; err += dy += a; } /* y step */ + if (e2 <= dy) { y0++; y1--; err += dy += a; } /* y step */ if (e2 >= dx || 2 * err > dy) { x0++; x1--; err += dx += b1; } /* x step */ } while (x0 <= x1); - while (y0-y1 < b) + while (y0-y1 < b) { /* too early stop of flat ellipses a=1 */ pix(memory, x0 - 1, y0, color); /* -> finish tip of ellipse */ - pix(memory, x1 + 1, y0++, color); + pix(memory, x1 + 1, y0++, color); pix(memory, x0 - 1, y1, color); - pix(memory, x1 + 1, y1--, color); + pix(memory, x1 + 1, y1--, color); } } @@ -555,7 +555,7 @@ static void drawSidesBuffer(tic_mem* memory, s32 y0, s32 y1, u8 color) s32 yt = MAX(core->state.clip.t, y0); s32 yb = MIN(core->state.clip.b, y1 + 1); u8 final_color = mapColor(&core->memory, color); - for (s32 y = yt; y < yb; y++) + for (s32 y = yt; y < yb; y++) { s32 xl = MAX(SidesBuffer.Left[y], core->state.clip.l); s32 xr = MIN(SidesBuffer.Right[y] + 1, core->state.clip.r); @@ -638,7 +638,7 @@ typedef union double d[3]; } Vec3; -typedef struct +typedef struct { void* data; const Vec2* v[3]; @@ -687,7 +687,7 @@ static void drawTri(tic_mem* tic, const Vec2* v0, const Vec2* v1, const Vec2* v2 Vec2 p = {min.x + Center, min.y + Center}; s32 c = (i + 1) % 3, n = (i + 2) % 3; - + d[i].x = (a.v[c]->y - a.v[n]->y) / area; d[i].y = (a.v[n]->x - a.v[c]->x) / area; s.d[i] = edgeFn(a.v[c], a.v[n], &p) / area; @@ -724,7 +724,7 @@ void tic_api_tri(tic_mem* tic, float x1, float y1, float x2, float y2, float x3, drawTri(tic, &(Vec2){x1, y1}, &(Vec2){x2, y2}, - &(Vec2){x3, y3}, + &(Vec2){x3, y3}, triColorShader, &color); } @@ -779,8 +779,8 @@ static inline bool shaderStart(const ShaderAttr* a, Vec3* vars, s32 pixel) vars->y += a->w.d[i] * t->d.y; } - if(data->depth) - vars->x /= vars->z, + if(data->depth) + vars->x /= vars->z, vars->y /= vars->z; return true; @@ -843,21 +843,21 @@ static tic_color triTexVbankShader(const ShaderAttr* a, s32 pixel) return shaderEnd(a, &vars, pixel, data->mapping[tic_tool_peek4(data->vram->data, iv * TIC80_WIDTH + iu)]); } -void tic_api_ttri(tic_mem* tic, - float x1, float y1, - float x2, float y2, - float x3, float y3, - float u1, float v1, - float u2, float v2, - float u3, float v3, - tic_texture_src texsrc, u8* colors, s32 count, +void tic_api_ttri(tic_mem* tic, + float x1, float y1, + float x2, float y2, + float x3, float y3, + float u1, float v1, + float u2, float v2, + float u3, float v3, + tic_texture_src texsrc, u8* colors, s32 count, float z1, float z2, float z3, bool depth) { // do not use depth if user passed z=0.0 if(z1 < FLT_EPSILON || z2 < FLT_EPSILON || z3 < FLT_EPSILON) depth = false; - TexData texData = + TexData texData = { .sheet = getTileSheetFromSegment(tic, tic->ram->vram.blit.segment), .mapping = getPalette(tic, colors, count), @@ -866,7 +866,7 @@ void tic_api_ttri(tic_mem* tic, .depth = depth, }; - TexVert t[] = + TexVert t[] = { {x1, y1, u1, v1, z1}, {x2, y2, u2, v2, z2}, @@ -875,22 +875,22 @@ void tic_api_ttri(tic_mem* tic, if(depth) for(s32 i = 0; i != COUNT_OF(t); ++i) - t[i].d.x /= t[i].d.z, - t[i].d.y /= t[i].d.z, + t[i].d.x /= t[i].d.z, + t[i].d.y /= t[i].d.z, t[i].d.z = 1.0 / t[i].d.z; - static const PixelShader Shaders[] = + static const PixelShader Shaders[] = { [tic_tiles_texture] = triTexTileShader, [tic_map_texture] = triTexMapShader, [tic_vbank_texture] = triTexVbankShader, }; - + if(texsrc >= 0 && texsrc < COUNT_OF(Shaders)) drawTri(tic, (const Vec2*)&t[0], (const Vec2*)&t[1], - (const Vec2*)&t[2], + (const Vec2*)&t[2], Shaders[texsrc], &texData); } diff --git a/src/core/io.c b/src/core/io.c index aedce6037..c2ce8b9cd 100644 --- a/src/core/io.c +++ b/src/core/io.c @@ -127,7 +127,7 @@ bool tic_api_keyp(tic_mem* tic, tic_key key, s32 hold, s32 period) tic_point tic_api_mouse(tic_mem* memory) { - return memory->ram->input.mouse.relative + return memory->ram->input.mouse.relative ? (tic_point){memory->ram->input.mouse.rx, memory->ram->input.mouse.ry} : (tic_point){memory->ram->input.mouse.x - TIC80_OFFSET_LEFT, memory->ram->input.mouse.y - TIC80_OFFSET_TOP}; } diff --git a/src/script.c b/src/script.c index 4c4453558..ddce20ebb 100644 --- a/src/script.c +++ b/src/script.c @@ -75,7 +75,7 @@ extern tic_script EXPORT_SCRIPT(Python); #endif -static const tic_script *Scripts[MAX_SUPPORTED_LANGS + 1] = +static const tic_script *Scripts[MAX_SUPPORTED_LANGS + 1] = { #if defined(TIC_RUNTIME_STATIC) #if defined (TIC_BUILD_WITH_LUA) @@ -131,7 +131,7 @@ static s32 compareScripts(const void* a, const void* b) { const tic_script* script1 = *(const tic_script**)a; const tic_script* script2 = *(const tic_script**)b; - + if (script1->id < script2->id) return -1; if (script1->id > script2->id) return 1; return 0; @@ -167,7 +167,7 @@ const tic_script* tic_get_script(tic_mem* memory) { FOREACH_LANG(script) { - if(script->id == memory->cart.lang + if(script->id == memory->cart.lang || strcmp(tic_tool_metatag(memory->cart.code.data, "script", script->singleComment), script->name) == 0) return script; } diff --git a/src/studio/config.c b/src/studio/config.c index f89e159e1..a7078bdf3 100644 --- a/src/studio/config.c +++ b/src/studio/config.c @@ -39,7 +39,7 @@ #define JSON(...) #__VA_ARGS__ -static void readConfig(Config* config) +static void readConfig(Config* config) { const char* json = config->cart->code.data; @@ -87,7 +87,7 @@ static void setDefault(Config* config) { .cart = config->cart, .uiScale = 4, - .options = + .options = { #if defined(CRT_SHADER_SUPPORT) .crt = false, @@ -219,7 +219,7 @@ void initConfig(Config* config, Studio* studio, tic_fs* fs) free(data); } - else saveConfig(config, false); + else saveConfig(config, false); } loadOptions(config); @@ -267,7 +267,7 @@ static void saveOptions(Config* config) "tabSize":%i #endif }) - , + , #if defined(CRT_SHADER_SUPPORT) bool2str(options->crt), #endif diff --git a/src/studio/editors/code.c b/src/studio/editors/code.c index 6b6377259..92acd399a 100644 --- a/src/studio/editors/code.c +++ b/src/studio/editors/code.c @@ -89,10 +89,10 @@ static void unpackState(Code* code, bool pos_undo) if (first_change != NULL) { - //we actually will want to go the one before the first change, as if + //we actually will want to go the one before the first change, as if //we were about to make the change //ternary to make sure we don't go one before the beginning - if (pos_undo) + if (pos_undo) code->cursor.position = first_change == code->src ? code->src : (first_change - 1); else code->cursor.position = stored_pos; @@ -124,7 +124,7 @@ tic_color getCodeColor(Code* code) if(size <= delta) return tic_color_yellow; if(size <= delta*2) return tic_color_orange; return tic_color_red; - } + } return tic_color_white; } @@ -156,7 +156,7 @@ static void drawStatus(Code* code) } tic_api_print(code->tic, code->status.line, 0, StatusY, getConfig(code->studio)->theme.code.BG, true, 1, false); - tic_api_print(code->tic, code->status.size, TIC80_WIDTH - (s32)strlen(code->status.size) * TIC_FONT_WIDTH, + tic_api_print(code->tic, code->status.size, TIC80_WIDTH - (s32)strlen(code->status.size) * TIC_FONT_WIDTH, StatusY, getConfig(code->studio)->theme.code.BG, true, 1, false); } @@ -169,7 +169,7 @@ static char* getPosByLine(char* ptr, s32 line) if(*ptr++ == '\n') y++; } - return ptr; + return ptr; } static char* getNextLineByPos(Code* code, char* pos) @@ -254,7 +254,7 @@ static inline void drawChar(tic_mem* tic, char symbol, s32 x, s32 y, u8 color, b tic_api_print(tic, (char[]){symbol, '\0'}, x, y, color, true, 1, alt); } -static int drawTab(Code* code, s32 x, s32 y, u8 color) +static int drawTab(Code* code, s32 x, s32 y, u8 color) { tic_mem* tic = code->tic; s32 tab_size = getConfig(code->studio)->options.tabSize; @@ -263,7 +263,7 @@ static int drawTab(Code* code, s32 x, s32 y, u8 color) while (count < tab_size) { drawChar(tic, '\t', x, y, color, code->altFont); count++; - if (x / getFontWidth(code) % tab_size == 0) + if (x / getFontWidth(code) % tab_size == 0) break; x += getFontWidth(code); } @@ -313,7 +313,7 @@ static void drawCode(Code* code, bool withCursor) const u8* colors = (const u8*)&getConfig(code->studio)->theme.code; const CodeState* syntaxPointer = code->state; - struct { char* start; char* end; } selection = + struct { char* start; char* end; } selection = { MIN(code->cursor.selection, code->cursor.position), MAX(code->cursor.selection, code->cursor.position) @@ -345,7 +345,7 @@ static void drawCode(Code* code, bool withCursor) drawChar(code->tic, symbol, x, y, tic_color_dark_grey, code->altFont); } } - else + else { if(code->shadowText) drawChar(code->tic, symbol, x+1, y+1, 0, code->altFont); @@ -598,7 +598,7 @@ static void parseCode(const tic_script* config, const char* start, CodeState* st while(true) { const char* pos = strchr(blockStart, *blockStdStringStart); - + if(pos) { if(*(pos-1) == '\\' && *(pos-2) != '\\') blockStart = pos + 1; @@ -675,8 +675,8 @@ static void parseCode(const tic_script* config, const char* start, CodeState* st char c = *ptr; if(isdigit(c)) ptr++; - else if(numberStart[0] == '0' - && (numberStart[1] == 'x' || numberStart[1] == 'X') + else if(numberStart[0] == '0' + && (numberStart[1] == 'x' || numberStart[1] == 'X') && isxdigit(numberStart[2])) { if((ptr - numberStart < 2) || isxdigit(c)) ptr++; @@ -974,7 +974,7 @@ static char* leftSexp(Code* code, char* pos) { char* start = code->src; int nesting = 0; - + while (pos >= start) { if (isopenparen_(code, *pos)) @@ -1208,7 +1208,7 @@ static bool structuredDeleteOverride(Code* code, char* pos) // only allow deletion when string is empty return true; } - + return false; } @@ -1283,7 +1283,7 @@ char* findLineEnd(Code* code, char* pos) { char* lineend = pos+1; const char* end = code->src + strlen(code->src); - + while (lineend < end) { if (islineend(*lineend)) break; @@ -1298,7 +1298,7 @@ static void deleteLine(Code* code) char* linestart = code->cursor.position; char* lineend = linestart+1; const char* end = code->src + strlen(code->src); - + if (shouldUseStructuredEdit(code)) { if (islineend(*linestart) || islineend(*lineend)) @@ -1345,7 +1345,7 @@ static void deleteLine(Code* code) free(clipboard); } - + deleteCode(code, linestart, lineend); code->cursor.position = linestart; history(code); @@ -1462,7 +1462,7 @@ static void cutToClipboard(Code* code, bool killSelection) if (killSelection) code->cursor.selection = NULL; - + //no call to history because it gets called in replaceSelection } @@ -1595,17 +1595,17 @@ static void doTab(Code* code, bool shift, bool crtl) { char* cursor_position = code->cursor.position; char* cursor_selection = code->cursor.selection; - + bool has_selection = cursor_selection && cursor_selection != cursor_position; bool modifier_key_pressed = shift || crtl; - + if(has_selection || modifier_key_pressed) { char* start; char* end; - + bool changed = false; - + if(cursor_selection) { start = MIN(cursor_selection, cursor_position); end = MAX(cursor_selection, cursor_position); @@ -1630,25 +1630,25 @@ static void doTab(Code* code, bool shift, bool crtl) end += insertTab(code, line, line); changed = true; } - + line = getNextLineByPos(code, line); if(line >= end) break; } - + if(changed) { - - if(has_selection) + + if(has_selection) { code->cursor.position = start; code->cursor.selection = end; } else if (start <= end) code->cursor.position = end; - + history(code); update(code); } } - else + else { char* line = getLineByPos(code, code->cursor.position); code->cursor.position += insertTab(code, line, code->cursor.position); @@ -1844,7 +1844,7 @@ static void setBookmarkMode(Code* code) item->pos = ptr; item->size = getLineSize(ptr); } - + ptr++; state++; } @@ -2017,7 +2017,7 @@ static void extirpSExp(Code* code) { if (!shouldUseStructuredEdit(code)) return; - + const char* start = code->src; char* pos = code->cursor.position; const char* end = code->src + strlen(code->src); @@ -2162,10 +2162,10 @@ static bool goNextBookmark(Code* code, char* ptr) return false; } -static bool clipboardHasNewline() +static bool clipboardHasNewline() { bool found = false; - if (tic_sys_clipboard_has()) + if (tic_sys_clipboard_has()) { //from what I can see in other usage, this should be a @@ -2173,9 +2173,9 @@ static bool clipboardHasNewline() char* clipboard = tic_sys_clipboard_get(); char* c = clipboard; - while(*c != 0) + while(*c != 0) { - if (*c == '\n') + if (*c == '\n') { found = true; break; @@ -2262,13 +2262,13 @@ static void seekEmptyLineBackward(Code* code) { updateEditor(code); } -static void seekForward(Code* code, char sought) +static void seekForward(Code* code, char sought) { char* start = code->cursor.position; code->cursor.position++; while( - *code->cursor.position != sought - && *code->cursor.position != '\n' + *code->cursor.position != sought + && *code->cursor.position != '\n' && *code->cursor.position != '\0' ) code->cursor.position++; @@ -2279,13 +2279,13 @@ static void seekForward(Code* code, char sought) updateEditor(code); } -static void seekBackward(Code* code, char sought) +static void seekBackward(Code* code, char sought) { char* start = code->cursor.position; code->cursor.position--; while( - code->cursor.position > code->src - && *code->cursor.position != sought + code->cursor.position > code->src + && *code->cursor.position != sought && *code->cursor.position != '\n' ) code->cursor.position--; @@ -2298,7 +2298,7 @@ static void seekBackward(Code* code, char sought) } static void findNextPopupText(Code* code) { - if (*code->popup.text) + if (*code->popup.text) { char* pos = downStrStr(code->src, code->cursor.position, code->popup.text); if (pos == code->cursor.position) @@ -2316,7 +2316,7 @@ static void findNextPopupText(Code* code) { } } -static bool processViPosition(Code* code, bool ctrl, bool alt, bool shift) +static bool processViPosition(Code* code, bool ctrl, bool alt, bool shift) { bool clear = !(shift || ctrl || alt); @@ -2351,7 +2351,7 @@ static bool processViPosition(Code* code, bool ctrl, bool alt, bool shift) else if (shift && keyWasPressed(code->studio, tic_key_6)) { goHome(code); - while (*code->cursor.position == ' ' || *code->cursor.position == '\t') + while (*code->cursor.position == ' ' || *code->cursor.position == '\t') code->cursor.position++; } @@ -2370,7 +2370,7 @@ static bool processViPosition(Code* code, bool ctrl, bool alt, bool shift) else if (shift && keyWasPressed(code->studio, tic_key_5)) { const char* pos = findMatchedDelim(code, code->cursor.position); - if (pos != NULL) + if (pos != NULL) { code->cursor.position = (char*) pos; updateColumn(code); @@ -2396,7 +2396,7 @@ static bool processViPosition(Code* code, bool ctrl, bool alt, bool shift) } static void updateGotoCode(Code* code); -static void processViGoto(Code* code, s32 initial) +static void processViGoto(Code* code, s32 initial) { setCodeMode(code, TEXT_GOTO_MODE); code->popup.text[0] = '0' + initial; @@ -2405,20 +2405,20 @@ static void processViGoto(Code* code, s32 initial) } static char* findStringStart(Code* code, char* pos) { - char sentinel = *pos; + char sentinel = *pos; char* target = pos; //we will scan to the given position pos = getLineByPos(code, pos); //from the beginning of the line char* start = NULL; - + //goto state machine! start: if(pos == target) goto end; else if(*pos == '\\') { pos++; goto escape; } - else if (*pos == sentinel) - { - start=start?NULL:pos; - pos++; + else if (*pos == sentinel) + { + start=start?NULL:pos; + pos++; goto start; } else { pos++; goto start; } @@ -2431,7 +2431,7 @@ escape : static char* findStringEnd(char* pos) { char sentinel = *pos; //can handle single or double quotes - //or anything else I guess + //or anything else I guess if (*pos == '\0') goto end; else pos++; //move past the sentinel so we don't immediately detect the end @@ -2501,8 +2501,8 @@ static void processViChange(Code* code) { code->cursor.position++; } } - //if on a quotation seek to change within the quotation - else if(*code->cursor.position == '"' || *code->cursor.position == '\'') + //if on a quotation seek to change within the quotation + else if(*code->cursor.position == '"' || *code->cursor.position == '\'') { char* start = findStringStart(code, code->cursor.position); if (start == NULL) start = code->cursor.position; @@ -2511,13 +2511,13 @@ static void processViChange(Code* code) { deleteCode(code, start, end); code->cursor.position = start; } - else if(!isalnum_(code, *code->cursor.position)) + else if(!isalnum_(code, *code->cursor.position)) deleteChar(code); else //change the word under the cursor { //only call left word if we are not already on the word border if ( - code->cursor.position > code->src + code->cursor.position > code->src && isalnum_(code, *(code->cursor.position-1)) ) leftWord(code); @@ -2534,7 +2534,7 @@ static char toggleCase(char c) { return c; } -static void processViKeyboard(Code* code) +static void processViKeyboard(Code* code) { tic_mem* tic = code->tic; @@ -2571,10 +2571,10 @@ static void processViKeyboard(Code* code) history(code); //needs to come after the mode switch or won't be honored } - else if (keyWasPressed(code->studio, tic_key_backspace)) + else if (keyWasPressed(code->studio, tic_key_backspace)) backspaceChar(code); - else if (keyWasPressed(code->studio, tic_key_tab)) + else if (keyWasPressed(code->studio, tic_key_tab)) doTab(code, shift, ctrl); else if (enterWasPressed(code->studio)) @@ -2589,7 +2589,7 @@ static void processViKeyboard(Code* code) updateEditor(code); } } - } + } else if(mode == VI_NORMAL) { bool processed = true; @@ -2598,29 +2598,29 @@ static void processViKeyboard(Code* code) if (processViPosition(code, ctrl, alt, shift)); - else if (clear && keyWasPressed(code->studio, tic_key_i)) + else if (clear && keyWasPressed(code->studio, tic_key_i)) setStudioViMode(code->studio, VI_INSERT); - else if (clear && keyWasPressed(code->studio, tic_key_a)) + else if (clear && keyWasPressed(code->studio, tic_key_a)) { setStudioViMode(code->studio, VI_INSERT); rightColumn(code); } - else if (clear && keyWasPressed(code->studio, tic_key_o)) + else if (clear && keyWasPressed(code->studio, tic_key_o)) { setStudioViMode(code->studio, VI_INSERT); goEnd(code); newLine(code); } - else if (shift && keyWasPressed(code->studio, tic_key_o)) + else if (shift && keyWasPressed(code->studio, tic_key_o)) { setStudioViMode(code->studio, VI_INSERT); goHome(code); newLine(code); upLine(code); } - else if (clear && keyWasPressed(code->studio, tic_key_space)) + else if (clear && keyWasPressed(code->studio, tic_key_space)) { size_t col = code->cursor.column; goEnd(code); @@ -2628,7 +2628,7 @@ static void processViKeyboard(Code* code) code->cursor.column = col; upLine(code); } - else if (shift && keyWasPressed(code->studio, tic_key_space)) + else if (shift && keyWasPressed(code->studio, tic_key_space)) { size_t col = code->cursor.column; goHome(code); @@ -2640,7 +2640,7 @@ static void processViKeyboard(Code* code) else if (clear && keyWasPressed(code->studio, tic_key_v)) setStudioViMode(code->studio, VI_SELECT); - else if (clear && keyWasPressed(code->studio, tic_key_slash)) + else if (clear && keyWasPressed(code->studio, tic_key_slash)) setCodeMode(code, TEXT_FIND_MODE); else if(clear && keyWasPressed(code->studio, tic_key_n)) @@ -2660,7 +2660,7 @@ static void processViKeyboard(Code* code) } else if(shift && keyWasPressed(code->studio, tic_key_n)) { - if (*code->popup.text) + if (*code->popup.text) { char* pos = upStrStr(code->src, code->cursor.position, code->popup.text); if (pos == NULL) @@ -2694,9 +2694,9 @@ static void processViKeyboard(Code* code) else if (clear && keyWasPressed(code->studio, tic_key_u)) undo(code); else if (shift && keyWasPressed(code->studio, tic_key_u)) redo(code); - else if (clear && keyWasPressed(code->studio, tic_key_p)) + else if (clear && keyWasPressed(code->studio, tic_key_p)) { - if (clipboardHasNewline()) + if (clipboardHasNewline()) { downLine(code); goHome(code); @@ -2706,9 +2706,9 @@ static void processViKeyboard(Code* code) } else copyFromClipboard(code, false); } - else if (shift && keyWasPressed(code->studio, tic_key_p)) + else if (shift && keyWasPressed(code->studio, tic_key_p)) { - if (clipboardHasNewline()) + if (clipboardHasNewline()) { goHome(code); char* pos = code->cursor.position; @@ -2716,10 +2716,10 @@ static void processViKeyboard(Code* code) code->cursor.position = pos; } else copyFromClipboard(code, false); } - else if (alt && keyWasPressed(code->studio, tic_key_f)) + else if (alt && keyWasPressed(code->studio, tic_key_f)) code->altFont = !code->altFont; - else if (alt && keyWasPressed(code->studio, tic_key_s)) + else if (alt && keyWasPressed(code->studio, tic_key_s)) code->shadowText = !code->shadowText; else if (clear && keyWasPressed(code->studio, tic_key_1)) processViGoto(code, 1); @@ -2736,7 +2736,7 @@ static void processViKeyboard(Code* code) else if (shift && keyWasPressed(code->studio, tic_key_m)) setCodeMode(code, TEXT_BOOKMARK_MODE); else if (clear && keyWasPressed(code->studio, tic_key_m)) toggleBookmark(code, getLineByPos(code, code->cursor.position)); - else if (clear && keyWasPressed(code->studio, tic_key_comma)) + else if (clear && keyWasPressed(code->studio, tic_key_comma)) { if(!goPrevBookmark(code, getPrevLineByPos(code, code->cursor.position))) goPrevBookmark(code, code->src + strlen(code->src)); @@ -2772,15 +2772,15 @@ static void processViKeyboard(Code* code) else if (shift && keyWasPressed(code->studio, tic_key_r)) runGame(code->studio); - else if (clear && keyWasPressed(code->studio, tic_key_c)) + else if (clear && keyWasPressed(code->studio, tic_key_c)) { - setStudioViMode(code->studio, VI_INSERT); + setStudioViMode(code->studio, VI_INSERT); processViChange(code); } else if (shift && keyWasPressed(code->studio, tic_key_c)) { - setStudioViMode(code->studio, VI_INSERT); + setStudioViMode(code->studio, VI_INSERT); char* start = code->cursor.position; goEnd(code); deleteCode(code, start, code->cursor.position); @@ -2807,23 +2807,23 @@ static void processViKeyboard(Code* code) else if (keyWasPressed(code->studio, tic_key_escape)) setStudioViMode(code->studio, VI_NORMAL); - else if (clear && keyWasPressed(code->studio, tic_key_minus)) + else if (clear && keyWasPressed(code->studio, tic_key_minus)) { commentLine(code); setStudioViMode(code->studio, VI_NORMAL); } - else if (clear && keyWasPressed(code->studio, tic_key_y)) + else if (clear && keyWasPressed(code->studio, tic_key_y)) { copyToClipboard(code, false); setStudioViMode(code->studio, VI_NORMAL); } - else if (clear && keyWasPressed(code->studio, tic_key_d)) + else if (clear && keyWasPressed(code->studio, tic_key_d)) { cutToClipboard(code, false); setStudioViMode(code->studio, VI_NORMAL); } - else if (clear && keyWasPressed(code->studio, tic_key_p)) + else if (clear && keyWasPressed(code->studio, tic_key_p)) { copyFromClipboard(code, false); setStudioViMode(code->studio, VI_NORMAL); @@ -2842,7 +2842,7 @@ static void processViKeyboard(Code* code) else if (shift && keyWasPressed(code->studio, tic_key_period)) doTab(code, false, true); - else if (clear && keyWasPressed(code->studio, tic_key_slash)) + else if (clear && keyWasPressed(code->studio, tic_key_slash)) { setStudioViMode(code->studio, VI_NORMAL); setCodeMode(code, TEXT_FIND_MODE); @@ -2865,8 +2865,8 @@ static void processViKeyboard(Code* code) if (processed) updateEditor(code); - } - else if (mode == VI_SEEK) + } + else if (mode == VI_SEEK) { if (keyWasPressed(code->studio, tic_key_escape)) @@ -2884,7 +2884,7 @@ static void processViKeyboard(Code* code) } } } - else if (mode == VI_SEEK_BACK) + else if (mode == VI_SEEK_BACK) { if (keyWasPressed(code->studio, tic_key_escape)) @@ -2910,13 +2910,13 @@ static void processKeyboard(Code* code) enum KeybindMode keymode = getKeybindMode(code); - if (keymode == KEYBIND_VI) + if (keymode == KEYBIND_VI) { processViKeyboard(code); return; } - const bool emacsMode = keymode == KEYBIND_EMACS; + const bool emacsMode = keymode == KEYBIND_EMACS; if (!emacsMode) { @@ -2957,13 +2957,13 @@ static void processKeyboard(Code* code) } bool usedKeybinding = true; - + if(hasJustSwitchedToCodeMode(code->studio)) { setJustSwitchedToCodeMode(code->studio, false); return; // Skip processing other inputs for this frame } - + // handle bookmarks if(keyWasPressed(code->studio, tic_key_f1)) { @@ -3100,7 +3100,7 @@ static void processMouse(Code* code) if(checkMousePos(code->studio, &rect)) { - bool useDrag = (code->mode == TEXT_DRAG_CODE && checkMouseDown(code->studio, &rect, tic_mouse_left)) + bool useDrag = (code->mode == TEXT_DRAG_CODE && checkMouseDown(code->studio, &rect, tic_mouse_left)) || checkMouseDown(code->studio, &rect, tic_mouse_right); setCursor(code->studio, code->mode == TEXT_DRAG_CODE || useDrag ? tic_cursor_hand : tic_cursor_ibeam); @@ -3124,7 +3124,7 @@ static void processMouse(Code* code) code->scroll.start.x = tic_api_mouse(tic).x + code->scroll.x * getFontWidth(code); code->scroll.start.y = tic_api_mouse(tic).y + code->scroll.y * STUDIO_TEXT_HEIGHT; } - else + else { if(checkMouseDblClick(code->studio, &rect, tic_mouse_left)) { @@ -3173,7 +3173,7 @@ static void textDragTick(Code* code) tic_api_cls(code->tic, getConfig(code->studio)->theme.code.BG); - drawCode(code, true); + drawCode(code, true); drawStatus(code); } @@ -3206,7 +3206,7 @@ static void textEditTick(Code* code) tic_api_cls(code->tic, getConfig(code->studio)->theme.code.BG); - drawCode(code, true); + drawCode(code, true); drawStatus(code); } @@ -3306,7 +3306,7 @@ static void textReplaceTick(Code* code) { *code->popup.offset = 0; code->popup.offset += strlen(" WITH:"); - //execute the replace + //execute the replace //if we have a selection only replace within the selection char* start = code->src; @@ -3325,7 +3325,7 @@ static void textReplaceTick(Code* code) pos = downStrStr(code->src, pos, code->popup.text); if (code->cursor.selection != NULL && pos > code->cursor.position) break; - } + } history(code); updateEditor(code); parseSyntaxColor(code); @@ -3338,8 +3338,8 @@ static void textReplaceTick(Code* code) if(*code->popup.text && code->popup.offset == NULL) { code->popup.text[strlen(code->popup.text)-1] = '\0'; - } - else if (*code->popup.text) + } + else if (*code->popup.text) { if (strlen(code->popup.offset) - strlen(" WITH:") > 0) code->popup.text[strlen(code->popup.text)-1] = '\0'; @@ -3464,7 +3464,7 @@ static void drawSidebarBar(Code* code, s32 x, s32 y) tic_api_rect(code->tic, rect.x - 1, rect.y + (code->sidebar.index - code->sidebar.scroll) * STUDIO_TEXT_HEIGHT, rect.w + 1, TIC_FONT_HEIGHT + 2, tic_color_red); - for(const tic_outline_item* ptr = code->sidebar.items, *end = ptr + code->sidebar.size; + for(const tic_outline_item* ptr = code->sidebar.items, *end = ptr + code->sidebar.size; ptr != end; ptr++, y += STUDIO_TEXT_HEIGHT) { // find the first non-space character @@ -3489,7 +3489,7 @@ static void drawSidebarBar(Code* code, s32 x, s32 y) static void normSidebarScroll(Code* code) { - code->sidebar.scroll = code->sidebar.size > TEXT_BUFFER_HEIGHT + code->sidebar.scroll = code->sidebar.size > TEXT_BUFFER_HEIGHT ? CLAMP(code->sidebar.scroll, 0, code->sidebar.size - TEXT_BUFFER_HEIGHT) : 0; } @@ -3544,7 +3544,7 @@ static void processSidebar(Code* code) else if(enterWasPressed(code->studio)) { - updateSidebarCode(code); + updateSidebarCode(code); setCodeMode(code, TEXT_EDIT_MODE); } } @@ -3671,7 +3671,7 @@ static void drawCodeToolbar(Code* code) { tic_api_rect(code->tic, 0, 0, TIC80_WIDTH, TOOLBAR_SIZE, tic_color_white); - static const struct Button {u8 icon; const char* tip;} Buttons[] = + static const struct Button {u8 icon; const char* tip;} Buttons[] = { {tic_icon_hand, "DRAG [right mouse]"}, {tic_icon_find, "FIND [ctrl+f]"}, @@ -3708,7 +3708,7 @@ static void drawCodeToolbar(Code* code) { tic_api_rect(code->tic, rect.x, rect.y, Size, Size, tic_color_grey); drawBitIcon(code->studio, btn->icon, rect.x, rect.y + 1, tic_color_black); - } + } drawBitIcon(code->studio, btn->icon, rect.x, rect.y, active ? tic_color_white : (over ? tic_color_grey : tic_color_light_grey)); } diff --git a/src/studio/editors/map.c b/src/studio/editors/map.c index 790578341..1f51c6bb8 100644 --- a/src/studio/editors/map.c +++ b/src/studio/editors/map.c @@ -148,7 +148,7 @@ static s32 drawSheetButton(Map* map, s32 x, s32 y) } } - drawBitIcon(map->studio, sheetVisible(map) ? tic_icon_up : tic_icon_down, rect.x, rect.y, + drawBitIcon(map->studio, sheetVisible(map) ? tic_icon_up : tic_icon_down, rect.x, rect.y, over ? tic_color_grey : tic_color_light_grey); return x; @@ -210,7 +210,7 @@ static void drawTileIndex(Map* map, s32 x, s32 y) if(sheetVisible(map)) { tic_rect rect = {TIC80_WIDTH - TIC_SPRITESHEET_SIZE - 1, TOOLBAR_SIZE, TIC_SPRITESHEET_SIZE, TIC_SPRITESHEET_SIZE}; - + if(checkMousePos(map->studio, &rect)) { s32 mx = tic_api_mouse(tic).x - rect.x; @@ -272,13 +272,13 @@ static void drawBppButtons(Map* map, s32 x, s32 y) } const char* label = (char[]){Labels[i], '\0'}; - tic_api_print(tic, label, rect.x, rect.y, - mode == map->sheet.blit.mode - ? tic_color_dark_grey - : hover - ? tic_color_grey - : tic_color_light_grey, - true, 1, true); + tic_api_print(tic, label, rect.x, rect.y, + mode == map->sheet.blit.mode + ? tic_color_dark_grey + : hover + ? tic_color_grey + : tic_color_light_grey, + true, 1, true); } } @@ -312,11 +312,11 @@ static void drawBankButtons(Map* map, s32 x, s32 y) } } - drawBitIcon(map->studio, Icons[i], rect.x, rect.y, - i == map->sheet.blit.bank - ? tic_color_dark_grey - : hover - ? tic_color_grey + drawBitIcon(map->studio, Icons[i], rect.x, rect.y, + i == map->sheet.blit.bank + ? tic_color_dark_grey + : hover + ? tic_color_grey : tic_color_light_grey); } } @@ -356,14 +356,14 @@ static void drawPagesButtons(Map* map, s32 x, s32 y) } const char* label = (char[]){i + '1', '\0'}; - tic_api_print(tic, label, rect.x + 1, rect.y + 1, + tic_api_print(tic, label, rect.x + 1, rect.y + 1, active ? tic_color_white - : hover - ? tic_color_grey - : tic_color_light_grey, - true, 1, true); - } + : hover + ? tic_color_grey + : tic_color_light_grey, + true, 1, true); + } } static void drawMapToolbar(Map* map, s32 x, s32 y) @@ -390,7 +390,7 @@ static void drawMapToolbar(Map* map, s32 x, s32 y) x = drawPenButton(map, x, 0); x = drawGridButton(map, x - 5, 0); - drawWorldButton(map, x, 0); + drawWorldButton(map, x, 0); } } @@ -405,13 +405,13 @@ static void drawSheetVBank1(Map* map, s32 x, s32 y) for(s32 i = 1; i < rect.h; i += 4) { - if (blit->page > 0) + if (blit->page > 0) { tic_api_pix(tic, rect.x-1, rect.y + i, tic_color_black, false); tic_api_pix(tic, rect.x-1, rect.y + i + 1, tic_color_black, false); } - if (blit->page < blit->pages - 1) + if (blit->page < blit->pages - 1) { tic_api_pix(tic, rect.x+rect.w, rect.y + i, tic_color_black, false); tic_api_pix(tic, rect.x+rect.w, rect.y + i + 1, tic_color_black, false); @@ -477,7 +477,7 @@ static void drawSheetReg(Map* map, s32 x, s32 y) { if(map->sheet.keep && map->sheet.drag) map->anim.movie = resetMovie(&map->anim.hide); - + map->sheet.drag = false; } } @@ -489,7 +489,7 @@ static void drawSheetReg(Map* map, s32 x, s32 y) tic_blit blit = map->sheet.blit; SCOPE(resetBlitMode(map->tic), tic_api_clip(tic, 0, 0, TIC80_WIDTH, TIC80_HEIGHT)) { - tic_point start = + tic_point start = { x - blit.page * TIC_SPRITESHEET_SIZE + map->anim.pos.page, y - blit.bank * TIC_SPRITESHEET_SIZE + map->anim.pos.bank @@ -684,7 +684,7 @@ static void processMouseDragMode(Map* map) { tic_rect rect = {MAP_X, MAP_Y, MAP_WIDTH, MAP_HEIGHT}; - processScrolling(map, checkMouseDown(map->studio, &rect, tic_mouse_left) || + processScrolling(map, checkMouseDown(map->studio, &rect, tic_mouse_left) || checkMouseDown(map->studio, &rect, tic_mouse_right)); } @@ -753,7 +753,7 @@ static void drawPasteData(Map* map) s32 index = data[i + j * w]; s32 sx = index % TIC_SPRITESHEET_COLS; s32 sy = index / TIC_SPRITESHEET_COLS; - tic_api_spr(tic, sx + map->sheet.blit.pages * sy * TIC_SPRITESHEET_COLS, + tic_api_spr(tic, sx + map->sheet.blit.pages * sy * TIC_SPRITESHEET_COLS, mx + i * TIC_SPRITESIZE, my + j * TIC_SPRITESIZE, 1, 1, NULL, 0, 1, tic_no_flip, tic_no_rotate); } @@ -851,7 +851,7 @@ static bool push(FillStack* stack, s32 x, s32 y) } if(stack->head < (stack->data + FILL_STACK_SIZE-1)) - { + { stack->head++; stack->head->x = x; stack->head->y = y; @@ -929,12 +929,12 @@ static void fillMap(Map* map, s32 x, s32 y, u8 tile) for(s32 i = 0; i < map->sheet.rect.w; i++) tic_api_mset(map->tic, x+i, y+j, (mx+i) + (my+j) * TIC_SPRITESHEET_COLS); - for(s32 i = 0; i < COUNT_OF(dx); i++) + for(s32 i = 0; i < COUNT_OF(dx); i++) { s32 nx = x + dx[i]*map->sheet.rect.w; s32 ny = y + dy[i]*map->sheet.rect.h; - if(nx >= clip.l && nx < clip.r && ny >= clip.t && ny < clip.b) + if(nx >= clip.l && nx < clip.r && ny >= clip.t && ny < clip.b) { bool match = true; for(s32 j = 0; j < map->sheet.rect.h; j++) @@ -948,7 +948,7 @@ static void fillMap(Map* map, s32 x, s32 y, u8 tile) } } } - } + } } static s32 moduloWrap(s32 x, s32 m) @@ -1053,7 +1053,7 @@ static void drawGrid(Map* map) { if(j >= 0 && j < TIC80_HEIGHT) for(s32 i = 0; i < TIC80_WIDTH; i++) - { + { u8 color = tic_api_pix(tic, i, j, 0, true); tic_api_pix(tic, i, j, (color+1)%TIC_PALETTE_SIZE, false); } @@ -1082,8 +1082,8 @@ static void drawMapReg(Map* map) bool space = tic_api_key(tic, tic_key_space); if(handle) - processScrolling(map, - ((space || map->mode == MAP_DRAG_MODE) && checkMouseDown(map->studio, &rect, tic_mouse_left)) || + processScrolling(map, + ((space || map->mode == MAP_DRAG_MODE) && checkMouseDown(map->studio, &rect, tic_mouse_left)) || checkMouseDown(map->studio, &rect, tic_mouse_right)); { @@ -1123,7 +1123,7 @@ static void copySelectionToClipboard(Map* map) tic_rect* sel = &map->select.rect; if(sel->w > 0 && sel->h > 0) - { + { s32 size = sel->w * sel->h + 2; u8* buffer = malloc(size); @@ -1142,10 +1142,10 @@ static void copySelectionToClipboard(Map* map) s32 index = x + y * TIC_MAP_WIDTH; *ptr++ = map->src->data[index]; - } + } toClipboard(buffer, size, true); - free(buffer); + free(buffer); } } } @@ -1238,7 +1238,7 @@ static void processKeyboard(Map* map) } if(tic->ram->input.keyboard.data == 0) return; - + bool ctrl = tic_api_key(tic, tic_key_ctrl); switch(getClipboardEvent(map->studio)) @@ -1248,7 +1248,7 @@ static void processKeyboard(Map* map) case TIC_CLIPBOARD_PASTE: copyFromClipboard(map); break; default: break; } - + if(tic_api_key(tic, tic_key_alt)) return; @@ -1293,7 +1293,7 @@ static void tick(Map* map) processAnim(map->anim.movie, map); // process scroll - if(tic->ram->input.mouse.scrolly < 0) + if(tic->ram->input.mouse.scrolly < 0) { setStudioMode(map->studio, TIC_WORLD_MODE); return; @@ -1325,7 +1325,7 @@ static void tick(Map* map) { tic_rect rect = {MAP_X, MAP_Y, MAP_WIDTH, MAP_HEIGHT}; if(!sheetVisible(map) && checkMousePos(map->studio, &rect) && !tic_api_key(tic, tic_key_space)) - { + { switch(map->mode) { case MAP_DRAW_MODE: @@ -1400,20 +1400,20 @@ void initMap(Map* map, Studio* studio, tic_map* src) .tick = tick, .src = src, .mode = MAP_DRAW_MODE, - .canvas = + .canvas = { .grid = true, .draw = false, .start = {0, 0}, }, - .sheet = + .sheet = { .rect = {0, 0, 1, 1}, .start = {0, 0}, .drag = false, .blit = {0}, }, - .select = + .select = { .rect = {0, 0, 0, 0}, .start = {0, 0}, @@ -1421,10 +1421,10 @@ void initMap(Map* map, Studio* studio, tic_map* src) }, .paste = NULL, .tickCounter = 0, - .scroll = + .scroll = { - .x = 0, - .y = 0, + .x = 0, + .y = 0, .active = false, .gesture = false, .start = {0, 0}, diff --git a/src/studio/editors/music.c b/src/studio/editors/music.c index 750e3d3e7..33b503ea0 100644 --- a/src/studio/editors/music.c +++ b/src/studio/editors/music.c @@ -375,7 +375,7 @@ static void goEnd(Music* music) static void pageUp(Music* music) { music->tracker.edit.y -= TRACKER_ROWS; - if(music->tracker.edit.y < 0) + if(music->tracker.edit.y < 0) music->tracker.edit.y = 0; updateTracker(music); @@ -388,9 +388,9 @@ static void pageDown(Music* music) music->tracker.edit.y += TRACKER_ROWS; s32 rows = getRows(music); - if(music->tracker.edit.y >= rows) + if(music->tracker.edit.y >= rows) music->tracker.edit.y = rows-1; - + updateTracker(music); } @@ -685,7 +685,7 @@ static void copyPianoToClipboard(Music* music, bool cut) memset(pattern->rows, 0, sizeof(tic_track_pattern)); history_add(music->history); } - } + } } } @@ -713,7 +713,7 @@ static void copyPianoFromClipboard(Music* music) memcpy(&header, data, HeaderSize); - if(size == header.size * RowSize + HeaderSize + if(size == header.size * RowSize + HeaderSize && size == sizeof(tic_track_pattern) + HeaderSize) { memcpy(pattern->rows, data + HeaderSize, header.size * RowSize); @@ -765,7 +765,7 @@ static void copyTrackerToClipboard(Music* music, bool cut) } resetSelection(music); - } + } } } @@ -944,7 +944,7 @@ static void delete(Music* music) history_add(music->history); if(music->tracker.select.rect.h <= 0) - downRow(music); + downRow(music); } } @@ -1024,7 +1024,7 @@ static void incNote(Music* music, s32 note, s32 octave) if(index >= 0) { row->note = (index % NOTES) + NoteStart; - row->octave = index / NOTES; + row->octave = index / NOTES; } } } @@ -1067,7 +1067,7 @@ static void processTrackerKeyboard(Music* music) bool shift = tic_api_key(tic, tic_key_shift); bool ctrl = tic_api_key(tic, tic_key_ctrl); - static const struct Handler{u8 key; void(*handler)(Music* music); bool select; bool ctrl;} Handlers[] = + static const struct Handler{u8 key; void(*handler)(Music* music); bool select; bool ctrl;} Handlers[] = { {tic_key_up, upRow, true}, {tic_key_down, downRow, true}, @@ -1145,7 +1145,7 @@ static void processTrackerKeyboard(Music* music) tic_key_y, tic_key_7, tic_key_u, - + // extra keys tic_key_i, tic_key_9, @@ -1162,9 +1162,9 @@ static void processTrackerKeyboard(Music* music) { case ColumnNote: case ColumnSemitone: - if(keyWasPressedOnce(tic, tic_key_z) && shift) + if(keyWasPressedOnce(tic, tic_key_z) && shift) music->last.octave -= 1; - else if(keyWasPressedOnce(tic, tic_key_x) && shift) + else if(keyWasPressedOnce(tic, tic_key_x) && shift) music->last.octave += 1; if (keyWasPressed(music->studio, tic_key_a)) @@ -1188,7 +1188,7 @@ static void processTrackerKeyboard(Music* music) downRow(music); break; - } + } } } break; @@ -1213,7 +1213,7 @@ static void processTrackerKeyboard(Music* music) if(getNote(music) >= 0) { s32 val = sym2dec(getKeyboardText(music->studio)); - + if(val >= 0) { s32 sfx = setDigit(col == 3 ? 1 : 0, getSfx(music), val); @@ -1232,7 +1232,7 @@ static void processTrackerKeyboard(Music* music) if(sym) { const char* val = strchr(MusicCommands, toupper(sym)); - + if(val) setCommand(music, val - MusicCommands); } @@ -1250,7 +1250,7 @@ static void processTrackerKeyboard(Music* music) : setParam2(music, val); } } - break; + break; } history_add(music->history); @@ -1276,8 +1276,8 @@ static void processPatternKeyboard(Music* music) else if(keyWasPressed(music->studio, tic_key_tab)) nextPattern(music); else if(keyWasPressed(music->studio, tic_key_left)) colLeft(music); else if(keyWasPressed(music->studio, tic_key_right)) colRight(music); - else if(keyWasPressed(music->studio, tic_key_down) - || enterWasPressed(music->studio)) + else if(keyWasPressed(music->studio, tic_key_down) + || enterWasPressed(music->studio)) music->tracker.edit.y = music->scroll.pos; else { @@ -1285,7 +1285,7 @@ static void processPatternKeyboard(Music* music) if(val >= 0) { - s32 pattern = setDigit(1 - music->tracker.col & 1, tic_tool_get_pattern_id(getTrack(music), + s32 pattern = setDigit(1 - music->tracker.col & 1, tic_tool_get_pattern_id(getTrack(music), music->frame, channel), val); if(pattern <= MUSIC_PATTERNS) @@ -1293,7 +1293,7 @@ static void processPatternKeyboard(Music* music) setChannelPatternValue(music, pattern, music->frame, channel); if(music->tracker.col == 0) - colRight(music); + colRight(music); } } } @@ -1389,15 +1389,15 @@ static void setPianoValue(Music* music, char sym) case PianoChannel4Column: switch (sym) { - case '+': - case '-': - setChannelPattern(music, delta, music->piano.edit.x / 2); + case '+': + case '-': + setChannelPattern(music, delta, music->piano.edit.x / 2); break; } if(dec >= 0) { - s32 pattern = setDigit(1 - music->piano.edit.x & 1, + s32 pattern = setDigit(1 - music->piano.edit.x & 1, tic_tool_get_pattern_id(getTrack(music), music->piano.edit.y, col), dec); if(pattern <= MUSIC_PATTERNS) @@ -1412,9 +1412,9 @@ static void setPianoValue(Music* music, char sym) { switch (sym) { - case '+': - case '-': - tic_tool_set_track_row_sfx(row, tic_modulo(tic_tool_get_track_row_sfx(row) + delta, SFX_COUNT)); + case '+': + case '-': + tic_tool_set_track_row_sfx(row, tic_modulo(tic_tool_get_track_row_sfx(row) + delta, SFX_COUNT)); break; default: if(dec >= 0) @@ -1541,7 +1541,7 @@ static void processKeyboard(Music* music) bool ctrl = tic_api_key(tic, tic_key_ctrl); bool shift = tic_api_key(tic, tic_key_shift); - + if(tic_api_key(tic, tic_key_alt)) return; @@ -1558,7 +1558,7 @@ static void processKeyboard(Music* music) if(keyWasPressed(music->studio, tic_key_space)) { - stopped + stopped ? playTrack(music) : stopTrack(music); } @@ -1566,7 +1566,7 @@ static void processKeyboard(Music* music) { stopped ? (shift - ? playTrackFromNow(music) + ? playTrackFromNow(music) : playFrame(music)) : stopTrack(music); } @@ -1575,7 +1575,7 @@ static void processKeyboard(Music* music) switch (music->tab) { case MUSIC_TRACKER_TAB: - music->tracker.edit.y >= 0 + music->tracker.edit.y >= 0 ? processTrackerKeyboard(music) : processPatternKeyboard(music); break; @@ -1848,7 +1848,7 @@ static void drawTumbler(Music* music, s32 x, s32 y, s32 index) tic_mem* tic = music->tic; enum{On=36, Off = 52, Width=7, Height=3}; - + tic_rect rect = {x, y, Width, Height}; if(checkMousePos(music->studio, &rect)) @@ -1898,13 +1898,13 @@ static void drawPlayButtons(Music* music) { typedef struct { - u8 icon; - const char* tip; - const char* alt; + u8 icon; + const char* tip; + const char* alt; void(*handler)(Music*); } Button; - static const Button FollowButton = + static const Button FollowButton = { tic_icon_follow, "FOLLOW [ctrl+f]", @@ -1912,7 +1912,7 @@ static void drawPlayButtons(Music* music) toggleFollowMode, }; - static const Button LoopButton = + static const Button LoopButton = { tic_icon_loop, "LOOP", @@ -1920,7 +1920,7 @@ static void drawPlayButtons(Music* music) toggleLoopMode, }; - static const Button SustainButton = + static const Button SustainButton = { tic_icon_sustain, "SUSTAIN NOTES ...", @@ -1928,7 +1928,7 @@ static void drawPlayButtons(Music* music) toggleSustainMode, }; - static const Button PlayFromNowButton = + static const Button PlayFromNowButton = { tic_icon_playnow, "PLAY FROM NOW ...", @@ -1936,7 +1936,7 @@ static void drawPlayButtons(Music* music) playTrackFromNow, }; - static const Button PlayFrameButton = + static const Button PlayFrameButton = { tic_icon_playframe, "PLAY FRAME ...", @@ -1944,7 +1944,7 @@ static void drawPlayButtons(Music* music) playFrame, }; - static const Button PlayTrackButton = + static const Button PlayTrackButton = { tic_icon_right, "PLAY TRACK ...", @@ -1952,7 +1952,7 @@ static void drawPlayButtons(Music* music) playTrack, }; - static const Button StopButton = + static const Button StopButton = { tic_icon_stop, "STOP [enter]", @@ -1964,10 +1964,10 @@ static void drawPlayButtons(Music* music) if(checkPlaying(music)) { - static const Button* Buttons[] = + static const Button* Buttons[] = { - &LoopButton, - &FollowButton, + &LoopButton, + &FollowButton, &SustainButton, &StopButton, }; @@ -1977,10 +1977,10 @@ static void drawPlayButtons(Music* music) } else { - static const Button* Buttons[] = + static const Button* Buttons[] = { - &LoopButton, - &FollowButton, + &LoopButton, + &FollowButton, &SustainButton, &PlayFromNowButton, &PlayFrameButton, @@ -2129,7 +2129,7 @@ static void drawPianoFrames(Music* music, s32 x, s32 y) s32 col = (tic_api_mouse(tic).x - rect.x) * TIC_SOUND_CHANNELS / rect.w; s32 row = (tic_api_mouse(tic).y - rect.y) * MUSIC_FRAMES / rect.h; - // move edit cursor if pattern already selected only + // move edit cursor if pattern already selected only if(col == music->piano.col && row == music->frame) { tic_point pos = {(tic_api_mouse(tic).x - rect.x) * TIC_SOUND_CHANNELS * 2 / rect.w, row}; @@ -2151,10 +2151,10 @@ static void drawPianoFrames(Music* music, s32 x, s32 y) for(s32 c = 0; c < TIC_SOUND_CHANNELS; c++) { - tic_api_rect(tic, x + c * ColWidth, y + 1, + tic_api_rect(tic, x + c * ColWidth, y + 1, ColWidth, MUSIC_FRAMES * TIC_FONT_HEIGHT + (Header - 1), c & 1 ? tic_color_black : tic_color_dark_grey); - tic_api_print(tic, (char[]){'1' + c, '\0'}, x + (ColWidth - (TIC_ALTFONT_WIDTH - 1)) / 2 + c * ColWidth, y + 2, + tic_api_print(tic, (char[]){'1' + c, '\0'}, x + (ColWidth - (TIC_ALTFONT_WIDTH - 1)) / 2 + c * ColWidth, y + 2, tic_color_grey, true, 1, true); @@ -2195,7 +2195,7 @@ static void drawPianoFrames(Music* music, s32 x, s32 y) static void drawStereoSeparator(Music* music, s32 x, s32 y) { tic_mem* tic = music->tic; - static u8 Colors[] = + static u8 Colors[] = { tic_color_dark_green, tic_color_green, tic_color_light_green, tic_color_light_green }; @@ -2211,7 +2211,7 @@ static void drawPianoRoll(Music* music, s32 x, s32 y) { tic_mem* tic = music->tic; - static const struct Button {u8 note; u8 up; u8 down; u8 offset; u8 flip;} Buttons[] = + static const struct Button {u8 note; u8 up; u8 down; u8 offset; u8 flip;} Buttons[] = { {0, 39, 40, 0, tic_no_flip}, {2, 39, 40, 3, tic_horz_flip}, @@ -2235,7 +2235,7 @@ static void drawPianoRoll(Music* music, s32 x, s32 y) for(s32 i = 0; i < COUNT_OF(Buttons); i++) { const struct Button* btn = &Buttons[i]; - tic_api_spr(tic, btn->note == music->piano.note[music->piano.col] ? btn->down : btn->up, + tic_api_spr(tic, btn->note == music->piano.note[music->piano.col] ? btn->down : btn->up, x + btn->offset, y, 1, 1, (u8[]){tic_color_orange}, 1, 1, btn->flip, tic_no_rotate); } } @@ -2264,7 +2264,7 @@ static void drawPianoRowColumn(Music* music, s32 x, s32 y) { music->scroll.active = true; music->scroll.start = tic_api_mouse(tic).y + music->scroll.pos * TIC_FONT_HEIGHT; - } + } } else music->scroll.active = false; } @@ -2293,7 +2293,7 @@ static void drawPianoNoteStatus(Music* music, s32 x, s32 y, s32 xpos, s32 ypos) { { static const char Notes[] = "C D EF G A B"; - tic_api_print(tic, Notes, xpos, ypos, tic_color_dark_grey, true, 1, true); + tic_api_print(tic, Notes, xpos, ypos, tic_color_dark_grey, true, 1, true); } showTooltip(music->studio, "set note"); @@ -2407,11 +2407,11 @@ static void drawPianoNoteColumn(Music* music, s32 x, s32 y) if(noteBeat(music, index) && row->note != NoteStop) { - static u8 Colors[NOTES] = + static u8 Colors[NOTES] = { - tic_color_grey, tic_color_grey, tic_color_light_grey, - tic_color_light_grey, tic_color_light_grey, tic_color_white, - tic_color_white, tic_color_light_grey, tic_color_light_grey, + tic_color_grey, tic_color_grey, tic_color_light_grey, + tic_color_light_grey, tic_color_light_grey, tic_color_white, + tic_color_white, tic_color_light_grey, tic_color_light_grey, tic_color_light_grey, tic_color_grey, tic_color_grey }; @@ -2499,11 +2499,11 @@ static void drawPianoOctaveColumn(Music* music, s32 x, s32 y) } else for(s32 i = 0; i < OCTAVES; i++) - tic_api_rect(tic, x + i * OctaveWidth, y + r * OctaveHeight + (Header + OctaveHeight / 2 - 1), OctaveWidth - 1, 1, tic_color_dark_grey); + tic_api_rect(tic, x + i * OctaveWidth, y + r * OctaveHeight + (Header + OctaveHeight / 2 - 1), OctaveWidth - 1, 1, tic_color_dark_grey); if(noteBeat(music, index)) { - static u8 Colors[OCTAVES] = + static u8 Colors[OCTAVES] = { tic_color_grey, tic_color_grey, tic_color_light_grey, tic_color_white, tic_color_white, tic_color_light_grey, tic_color_grey, tic_color_grey @@ -2517,7 +2517,7 @@ static void drawPianoOctaveColumn(Music* music, s32 x, s32 y) tic_api_rect(tic, x + row->octave * OctaveWidth, y + Header + r * OctaveHeight, OctaveWidth - 1, OctaveHeight - 1, tic_color_orange); } } - else + else for(s32 r = 0; r < TRACKER_ROWS; r++) for(s32 i = 0; i < OCTAVES; i++) tic_api_rect(tic, x + i * OctaveWidth, y + r * OctaveHeight + (Header + OctaveHeight / 2 - 1), OctaveWidth - 1, 1, tic_color_dark_grey); @@ -2583,10 +2583,10 @@ static void drawPianoSfxColumn(Music* music, s32 x, s32 y) tic_api_print(tic, sfx, rect.x + 1, rect.y + 1, tic_color_yellow, true, 1, false); } else - tic_api_print(tic, "--", - x + 1, y + Header + r * TIC_FONT_HEIGHT, + tic_api_print(tic, "--", + x + 1, y + Header + r * TIC_FONT_HEIGHT, noteBeat(music, index) ? tic_color_light_grey : tic_color_grey, true, 1, false); - } + } } else for(s32 r = 0; r < TRACKER_ROWS; r++) @@ -2628,7 +2628,7 @@ static void drawPianoCommandColumn(Music* music, s32 x, s32 y) if(command != tic_music_cmd_empty) { #define MUSIC_CMD_HINT(_, letter, hint) "[" #letter "] " hint, - static const char* Hints[] = + static const char* Hints[] = { MUSIC_CMD_LIST(MUSIC_CMD_HINT) }; @@ -2663,25 +2663,25 @@ static void drawPianoCommandColumn(Music* music, s32 x, s32 y) s32 index = rowIndex(music, r); const tic_track_row* row = &pattern->rows[index]; - tic_api_print(tic, MusicCommands + 1, - x + 1, y + Header + r * TIC_FONT_HEIGHT, + tic_api_print(tic, MusicCommands + 1, + x + 1, y + Header + r * TIC_FONT_HEIGHT, noteBeat(music, index) ? tic_color_grey : tic_color_dark_grey, true, 1, false); if(overRow == r && command > tic_music_cmd_empty) - tic_api_print(tic, (char[]){MusicCommands[command], '\0'}, - x + 1 + (command - 1) * TIC_FONT_WIDTH, y + Header + r * TIC_FONT_HEIGHT, + tic_api_print(tic, (char[]){MusicCommands[command], '\0'}, + x + 1 + (command - 1) * TIC_FONT_WIDTH, y + Header + r * TIC_FONT_HEIGHT, noteBeat(music, index) ? tic_color_light_grey : tic_color_grey, true, 1, false); if(row->command > tic_music_cmd_empty) - tic_api_print(tic, (char[]){MusicCommands[row->command], '\0'}, - x + 1 + (row->command - 1) * TIC_FONT_WIDTH, y + Header + r * TIC_FONT_HEIGHT, + tic_api_print(tic, (char[]){MusicCommands[row->command], '\0'}, + x + 1 + (row->command - 1) * TIC_FONT_WIDTH, y + Header + r * TIC_FONT_HEIGHT, tic_color_light_blue, true, 1, false); - } + } } else for(s32 r = 0; r < TRACKER_ROWS; r++) - tic_api_print(tic, MusicCommands + 1, - x + 1, y + Header + r * TIC_FONT_HEIGHT, + tic_api_print(tic, MusicCommands + 1, + x + 1, y + Header + r * TIC_FONT_HEIGHT, tic_color_dark_grey, true, 1, false); } @@ -2710,7 +2710,7 @@ static void drawPianoXYColumn(Music* music, s32 x, s32 y) char val[sizeof "XY=000"]; sprintf(val, "XY=%03i", (row->param1 << 4) | row->param2); tic_api_print(tic, val, 213, 129, tic_color_yellow, false, 1, true); - } + } } bool left = checkMouseClick(music->studio, &rect, tic_mouse_left); @@ -2760,10 +2760,10 @@ static void drawPianoXYColumn(Music* music, s32 x, s32 y) tic_api_print(tic, xy, x + 1, y + Header + r * TIC_FONT_HEIGHT, tic_color_light_blue, true, 1, false); } else - tic_api_print(tic, "--", - x + 1, y + Header + r * TIC_FONT_HEIGHT, + tic_api_print(tic, "--", + x + 1, y + Header + r * TIC_FONT_HEIGHT, noteBeat(music, index) ? tic_color_light_grey : tic_color_grey, true, 1, false); - } + } } else for(s32 r = 0; r < TRACKER_ROWS; r++) @@ -2851,7 +2851,7 @@ static void scrollNotes(Music* music, s32 delta) rect.y = music->tracker.edit.y; rect.h = 1; } - + for(s32 i = rect.y; i < rect.y + rect.h; i++) { s32 note = pattern->rows[i].note + pattern->rows[i].octave * NOTES - NoteStart; @@ -2950,7 +2950,7 @@ static void tick(Music* music) scrollNotes(music, input->mouse.scrolly > 0 ? 1 : -1); } else - { + { enum{Scroll = NOTES_PER_BEAT}; s32 delta = input->mouse.scrolly > 0 ? -Scroll : Scroll; @@ -2967,7 +2967,7 @@ static void tick(Music* music) { const tic_music_state* pos = getMusicPos(music); - if(pos->music.track == music->track && + if(pos->music.track == music->track && music->tracker.edit.y >= 0 && pos->music.row >= 0) { @@ -3028,7 +3028,7 @@ void initMusic(Music* music, Studio* studio, tic_music* src) .frame = 0, .follow = true, .sustain = false, - .scroll = + .scroll = { .pos = 0, .start = 0, @@ -3044,7 +3044,7 @@ void initMusic(Music* music, Studio* studio, tic_music* src) { .edit = {0, 0}, - .select = + .select = { .start = {0, 0}, .rect = {0, 0, 0, 0}, diff --git a/src/studio/editors/music.h b/src/studio/editors/music.h index 151fafb12..c7b6ac227 100644 --- a/src/studio/editors/music.h +++ b/src/studio/editors/music.h @@ -92,7 +92,7 @@ struct Music u32 tickCounter; struct History* history; - + void(*tick)(Music*); void(*event)(Music*, StudioEvent); }; diff --git a/src/studio/editors/sfx.c b/src/studio/editors/sfx.c index 578757b88..c211122bb 100644 --- a/src/studio/editors/sfx.c +++ b/src/studio/editors/sfx.c @@ -28,7 +28,7 @@ #define SECOND_OCTAVE_KEYBOARD_INDEX 16 #define SECOND_OCTAVE_KEYBOARD_SHIFT 5 -enum +enum { SFX_WAVE_PANEL, SFX_VOLUME_PANEL, @@ -60,7 +60,7 @@ static s32 hold(Sfx* sfx, s32 value) { tic_mem* tic = sfx->tic; - if(tic_api_key(tic, tic_key_ctrl) || + if(tic_api_key(tic, tic_key_ctrl) || tic_api_key(tic, tic_key_shift)) { if(sfx->holdValue < 0) @@ -81,11 +81,11 @@ static void drawCanvasLeds(Sfx* sfx, s32 x, s32 y, s32 canvasTab) { tic_mem* tic = sfx->tic; - enum + enum { - Cols = SFX_TICKS, Rows = 16, + Cols = SFX_TICKS, Rows = 16, Gap = 1, LedWidth = 3 + Gap, LedHeight = 1 + Gap, - Width = LedWidth * Cols + Gap, + Width = LedWidth * Cols + Gap, Height = LedHeight * Rows + Gap }; @@ -182,7 +182,7 @@ static void drawCanvasLeds(Sfx* sfx, s32 x, s32 y, s32 canvasTab) for(s32 r = 0; r < Rows; r++) { tic_api_rect(tic, x + loop->start * LedWidth + 2, y + Gap + r * LedHeight, 1, 1, tic_color_white); - tic_api_rect(tic, x + (loop->start + loop->size-1) * LedWidth + 2, y + Gap + r * LedHeight, 1, 1, tic_color_white); + tic_api_rect(tic, x + (loop->start + loop->size-1) * LedWidth + 2, y + Gap + r * LedHeight, 1, 1, tic_color_white); } } @@ -298,7 +298,7 @@ static void drawVolWaveSelector(Sfx* sfx, s32 x, s32 y) tic_mem* tic = sfx->tic; typedef struct {const char* label; s32 panel; tic_rect rect; const char* tip;} Item; - static const Item Items[] = + static const Item Items[] = { {"WAV", SFX_WAVE_PANEL, {TIC_ALTFONT_WIDTH * 3, 0, TIC_ALTFONT_WIDTH * 3, TIC_FONT_HEIGHT}, "wave data"}, {"VOL", SFX_VOLUME_PANEL, {0, 0, TIC_ALTFONT_WIDTH * 3, TIC_FONT_HEIGHT}, "volume data"}, @@ -332,7 +332,7 @@ static void drawCanvas(Sfx* sfx, s32 x, s32 y, s32 canvasTab) { tic_mem* tic = sfx->tic; - enum + enum { Width = 147, Height = 33 }; @@ -544,7 +544,7 @@ static void processKeyboard(Sfx* sfx) s32 keyboardButton = -1; - static const s32 Keycodes[] = + static const s32 Keycodes[] = { tic_key_z, tic_key_s, @@ -577,7 +577,7 @@ static void processKeyboard(Sfx* sfx) tic_key_y, tic_key_7, tic_key_u, - + // extra keys tic_key_i, tic_key_9, @@ -595,20 +595,20 @@ static void processKeyboard(Sfx* sfx) else { u8 octaveShift = 0; - for(int i = 0; i < COUNT_OF(Keycodes); i++) { + for(int i = 0; i < COUNT_OF(Keycodes); i++) { if(tic_api_key(tic, Keycodes[i])) { - if (sfx->play.tick == 0 && !keyWasPressedOnce(tic, Keycodes[i])) + if (sfx->play.tick == 0 && !keyWasPressedOnce(tic, Keycodes[i])) continue; - keyboardButton = (i > SECOND_OCTAVE_KEYBOARD_INDEX - ? i - SECOND_OCTAVE_KEYBOARD_SHIFT + keyboardButton = (i > SECOND_OCTAVE_KEYBOARD_INDEX + ? i - SECOND_OCTAVE_KEYBOARD_SHIFT : i) % NOTES; - + octaveShift = (i - keyboardButton) / NOTES; } } - if (effect->temp != octaveShift) + if (effect->temp != octaveShift) sfx->play.tick = 0; effect->temp = octaveShift; @@ -618,7 +618,7 @@ static void processKeyboard(Sfx* sfx) { if (keyboardButton != sfx->play.note) sfx->play.tick = 0; - + effect->note = keyboardButton; sfx->play.active = true; } @@ -626,9 +626,9 @@ static void processKeyboard(Sfx* sfx) if(tic_api_key(tic, tic_key_space)) sfx->play.active = true; - if(keyWasPressedOnce(tic, tic_key_z) && shift) + if(keyWasPressedOnce(tic, tic_key_z) && shift) effect->octave--; - else if(keyWasPressedOnce(tic, tic_key_x) && shift) + else if(keyWasPressedOnce(tic, tic_key_x) && shift) effect->octave++; } @@ -693,12 +693,12 @@ static void redoWave(Sfx* sfx) static void drawWavesBar(Sfx* sfx, s32 x, s32 y) { - static struct Button + static struct Button { u8 icon; const char* tip; void(*handler)(Sfx*); - } Buttons[] = + } Buttons[] = { { tic_icon_cut, @@ -752,7 +752,7 @@ static void drawWavesBar(Sfx* sfx, s32 x, s32 y) if(over) drawBitIcon(sfx->studio, it->icon, rect.x, rect.y + 1, tic_color_black); - drawBitIcon(sfx->studio, it->icon, rect.x, rect.y + push, + drawBitIcon(sfx->studio, it->icon, rect.x, rect.y + push, over ? tic_color_white : tic_color_dark_grey); y += Size; @@ -805,7 +805,7 @@ static void drawWaves(Sfx* sfx, s32 x, s32 y) for(s32 i = 0; i < WAVE_VALUES/Scale; i++) { s32 value = tic_tool_peek4(wave->data, i*Scale)/Scale; - tic_api_pix(tic, rect.x + i+1, rect.y + Height - value - 2, + tic_api_pix(tic, rect.x + i+1, rect.y + Height - value - 2, active ? tic_color_red : sel ? tic_color_dark_green : hover ? tic_color_light_grey : tic_color_white, false); } @@ -825,8 +825,8 @@ static void drawWavePanel(Sfx* sfx, s32 x, s32 y) enum {Width = 73, Height = 83, Round = 2}; - typedef struct {s32 x; s32 y; s32 x1; s32 y1; tic_color color;} Edge; - static const Edge Edges[] = + typedef struct {s32 x; s32 y; s32 x1; s32 y1; tic_color color;} Edge; + static const Edge Edges[] = { {Width, Round, Width, Height - Round, tic_color_dark_grey}, {Round, Height, Width - Round, Height, tic_color_dark_grey}, @@ -871,7 +871,7 @@ static void drawWavePanel(Sfx* sfx, s32 x, s32 y) SHOW_TOOLTIP(sfx->studio, "[x=%02i y=%02i]", cx, cy); enum {Border = 1}; - tic_api_rectb(tic, rect.x + cx*Scale - Border, + tic_api_rectb(tic, rect.x + cx*Scale - Border, rect.y + (MaxValue - cy) * Scale - Border, Scale + Border*2, Scale + Border*2, tic_color_dark_green); if(checkMouseDown(sfx->studio, &rect, tic_mouse_left)) @@ -885,7 +885,7 @@ static void drawWavePanel(Sfx* sfx, s32 x, s32 y) } } else unhold(sfx); - } + } for(s32 i = 0; i < WAVE_VALUES; i++) { @@ -909,11 +909,11 @@ static void drawPianoOctave(Sfx* sfx, s32 x, s32 y, s32 octave) { tic_mem* tic = sfx->tic; - enum + enum { Gap = 1, WhiteShadow = 1, WhiteWidth = 3, WhiteHeight = 8, WhiteCount = 7, WhiteWidthGap = WhiteWidth + Gap, - BlackWidth = 3, BlackHeight = 4, BlackCount = 6, + BlackWidth = 3, BlackHeight = 4, BlackCount = 6, BlackOffset = WhiteWidth - (BlackWidth - Gap) / 2, Width = WhiteCount * WhiteWidthGap - Gap, Height = WhiteHeight @@ -922,7 +922,7 @@ static void drawPianoOctave(Sfx* sfx, s32 x, s32 y, s32 octave) tic_rect rect = {x, y, Width, Height}; typedef struct{s32 note; tic_rect rect; bool white;} PianoBtn; - static const PianoBtn Buttons[] = + static const PianoBtn Buttons[] = { {0, WhiteWidthGap * 0, 0, WhiteWidth, WhiteHeight, true}, {2, WhiteWidthGap * 1, 0, WhiteWidth, WhiteHeight, true}, @@ -987,10 +987,10 @@ static void drawPianoOctave(Sfx* sfx, s32 x, s32 y, s32 octave) { const PianoBtn* btn = Buttons + i; const tic_rect* rect = &btn->rect; - tic_api_rect(tic, x + rect->x, y + rect->y, rect->w, rect->h, - active && effect->note == btn->note ? tic_color_red : - btn->white - ? hover == btn->note ? tic_color_light_grey : tic_color_white + tic_api_rect(tic, x + rect->x, y + rect->y, rect->w, rect->h, + active && effect->note == btn->note ? tic_color_red : + btn->white + ? hover == btn->note ? tic_color_light_grey : tic_color_white : hover == btn->note ? tic_color_dark_grey : tic_color_black); if(btn->white) @@ -1019,9 +1019,9 @@ static void drawSpeedPanel(Sfx* sfx, s32 x, s32 y) { tic_mem* tic = sfx->tic; - enum + enum { - Count = 8, Gap = 1, ColWidth = 1, ColWidthGap = ColWidth + Gap, + Count = 8, Gap = 1, ColWidth = 1, ColWidthGap = ColWidth + Gap, Width = Count * ColWidthGap - Gap, Height = 5, MaxSpeed = (1 << SFX_SPEED_BITS) / 2 }; @@ -1058,7 +1058,7 @@ static void drawSelectorPanel(Sfx* sfx, s32 x, s32 y) enum { - Size = 3, Gap = 1, SizeGap = Size + Gap, + Size = 3, Gap = 1, SizeGap = Size + Gap, GroupGap = 2, Groups = 4, Cols = 4, Rows = SFX_COUNT / (Cols * Groups), GroupWidth = Cols * SizeGap - Gap, Width = (GroupWidth + GroupGap) * Groups - GroupGap, Height = Rows * SizeGap - Gap @@ -1096,7 +1096,7 @@ static void drawSelectorPanel(Sfx* sfx, s32 x, s32 y) static const u8 EmptyEffect[sizeof(tic_sample)] = {0}; bool empty = memcmp(sfx->src->samples.data + i, EmptyEffect, sizeof EmptyEffect) == 0; - tic_api_rect(tic, x + c * SizeGap + g * (GroupWidth + GroupGap), y + r * SizeGap, Size, Size, + tic_api_rect(tic, x + c * SizeGap + g * (GroupWidth + GroupGap), y + r * SizeGap, Size, Size, sfx->index == i ? tic_color_light_green : hover == i ? tic_color_grey : empty ? tic_color_dark_grey : tic_color_light_grey); } } @@ -1145,7 +1145,7 @@ static void tick(Sfx* sfx) if(sfx->play.active) sfx->play.tick++; - else + else sfx->play.tick = 0; } @@ -1166,7 +1166,7 @@ void initSfx(Sfx* sfx, Studio* studio, tic_sfx* src) { if(sfx->history) history_delete(sfx->history); if(sfx->waveHistory) history_delete(sfx->waveHistory); - + *sfx = (Sfx) { .studio = studio, @@ -1177,7 +1177,7 @@ void initSfx(Sfx* sfx, Studio* studio, tic_sfx* src) .volwave = SFX_VOLUME_PANEL, .hoverWave = -1, .holdValue = -1, - .play = + .play = { .note = -1, .active = false, diff --git a/src/studio/editors/sfx.h b/src/studio/editors/sfx.h index 6d4e9ab3e..0c0ab5679 100644 --- a/src/studio/editors/sfx.h +++ b/src/studio/editors/sfx.h @@ -44,7 +44,7 @@ struct Sfx s32 note; u32 tick; } play; - + struct History* history; struct History* waveHistory; diff --git a/src/studio/editors/sprite.c b/src/studio/editors/sprite.c index f11626ed4..9e9e839cc 100644 --- a/src/studio/editors/sprite.c +++ b/src/studio/editors/sprite.c @@ -506,18 +506,18 @@ static void drawCanvasVBank1(Sprite* sprite, s32 x, s32 y) { switch(sprite->mode) { - case SPRITE_DRAW_MODE: + case SPRITE_DRAW_MODE: processDrawCanvasMouse(sprite, x, y, rect.x, rect.y); drawBrushSlider(sprite, x - 15, y + 20); break; case SPRITE_PICK_MODE: processPickerCanvasMouse(sprite, x, y, rect.x, rect.y); break; case SPRITE_SELECT_MODE: processSelectCanvasMouse(sprite, x, y); break; case SPRITE_FILL_MODE: processFillCanvasMouse(sprite, x, y, rect.x, rect.y); break; - } + } } if(hasCanvasSelection(sprite)) - drawSelection(sprite, x + sprite->select.rect.x * Size - 1, y + sprite->select.rect.y * Size - 1, + drawSelection(sprite, x + sprite->select.rect.x * Size - 1, y + sprite->select.rect.y * Size - 1, sprite->select.rect.w * Size + 2, sprite->select.rect.h * Size + 2); else { @@ -589,27 +589,27 @@ static void rightCanvas(Sprite* sprite) static void rotateSelectRect(Sprite* sprite) { tic_rect rect = sprite->select.rect; - + s32 selection_center_x = rect.x + rect.w/2; s32 selection_center_y = rect.y + rect.h/2; - + // Rotate sprite->select.rect.w = rect.h; sprite->select.rect.h = rect.w; - + // Make the new center be at the position of the previous center sprite->select.rect.x -= (sprite->select.rect.x + sprite->select.rect.w/2) - selection_center_x; sprite->select.rect.y -= (sprite->select.rect.y + sprite->select.rect.h/2) - selection_center_y; - + // Check if we are not out of boundaries if (sprite->select.rect.x < 0) sprite->select.rect.x = 0; if (sprite->select.rect.y < 0) sprite->select.rect.y = 0; - + if (sprite->select.rect.x + sprite->select.rect.w >= sprite->size) { sprite->select.rect.x -= sprite->select.rect.x + sprite->select.rect.w - sprite->size; } - + if (sprite->select.rect.y + sprite->select.rect.h >= sprite->size) { sprite->select.rect.y -= sprite->select.rect.y + sprite->select.rect.h - sprite->size; @@ -633,10 +633,10 @@ static void rotateCanvas(Sprite* sprite) diff = rect.w * (x + 1) -y; buffer[i++] = sprite->select.front[Size - diff]; } - + for (s32 i = 0; iselect.front[i] = buffer[i]; - + rotateSelectRect(sprite); pasteSelection(sprite); history_add(sprite->history); @@ -649,7 +649,7 @@ static void rotateCanvas(Sprite* sprite) static void deleteCanvas(Sprite* sprite) { tic_rect* rect = &sprite->select.rect; - + s32 left = getIndexPosX(sprite) + rect->x; s32 top = getIndexPosY(sprite) + rect->y; s32 right = left + rect->w; @@ -660,17 +660,17 @@ static void deleteCanvas(Sprite* sprite) tic_tilesheet_setpix(&sprite->sheet, pixel_x, pixel_y, sprite->color2); clearCanvasSelection(sprite); - + history_add(sprite->history); } static void flipCanvasHorz(Sprite* sprite) { tic_rect* rect = &sprite->select.rect; - + s32 sprite_x = getIndexPosX(sprite); s32 sprite_y = getIndexPosY(sprite); - + s32 right = sprite_x + rect->x + rect->w/2; s32 bottom = sprite_y + rect->y + rect->h; @@ -689,10 +689,10 @@ static void flipCanvasHorz(Sprite* sprite) static void flipCanvasVert(Sprite* sprite) { tic_rect* rect = &sprite->select.rect; - + s32 sprite_x = getIndexPosX(sprite); s32 sprite_y = getIndexPosY(sprite); - + s32 right = sprite_x + rect->x + rect->w; s32 bottom = sprite_y + rect->y + rect->h/2; @@ -749,7 +749,7 @@ static void drawFlags(Sprite* sprite, s32 x, s32 y) u8 mask = flags[*i++]; or |= mask; and &= mask; - } + } } for(s32 i = 0; i < BITS_IN_BYTE; i++) @@ -773,7 +773,7 @@ static void drawFlags(Sprite* sprite, s32 x, s32 y) while(*i >= 0) flags[*i++] &= ~mask; else - while(*i >= 0) + while(*i >= 0) flags[*i++] |= mask; } } @@ -786,7 +786,7 @@ static void drawFlags(Sprite* sprite, s32 x, s32 y) tic_api_pix(tic, rect.x + 2, rect.y + 2, flagColor, false); else if(over) tic_api_rect(tic, rect.x + 1, rect.y + 1, Size - 2, Size - 2, flagColor); - + if(and & mask) { tic_api_rect(tic, rect.x + 1, rect.y + 1, Size - 2, Size - 2, flagColor); @@ -830,7 +830,7 @@ static void drawFlags(Sprite* sprite, s32 x, s32 y) if(!sprite->flags.edit) tic_api_print(tic, buf, rect.x + 1, rect.y + 2, tic_color_black, false, 1, true); - + tic_api_print(tic, buf, rect.x + 1, rect.y + 1, tic_color_white, false, 1, true); } } @@ -903,7 +903,7 @@ static void drawMoveButtons(Sprite* sprite) static const u8 Icons[] = {tic_icon_bigup, tic_icon_bigdown, tic_icon_bigleft, tic_icon_bigright}; - static const tic_rect Rects[] = + static const tic_rect Rects[] = { {x + (CANVAS_SIZE - TIC_SPRITESIZE)/2, y - TIC_SPRITESIZE, TIC_SPRITESIZE, TIC_SPRITESIZE/2}, {x + (CANVAS_SIZE - TIC_SPRITESIZE)/2, y + CANVAS_SIZE + TIC_SPRITESIZE/2, TIC_SPRITESIZE, TIC_SPRITESIZE/2}, @@ -1029,7 +1029,7 @@ static void drawRGBTools(Sprite* sprite, s32 x, s32 y) { { enum{Size = 5}; - + tic_rect rect = {x, y, Size, Size}; bool over = false; @@ -1062,7 +1062,7 @@ static void drawRGBTools(Sprite* sprite, s32 x, s32 y) { enum{Size = 5}; - + tic_rect rect = {x, y + 8, Size, Size}; bool over = false; bool down = false; @@ -1101,9 +1101,9 @@ static void drawRGBSliders(Sprite* sprite, s32 x, s32 y) enum { - Cols = BITS_IN_BYTE / TIC_PALETTE_BPP, - Rows = sizeof(tic_rgb), - Width = TIC_FONT_WIDTH + 1, + Cols = BITS_IN_BYTE / TIC_PALETTE_BPP, + Rows = sizeof(tic_rgb), + Width = TIC_FONT_WIDTH + 1, Height = TIC_FONT_HEIGHT + 1 }; @@ -1133,14 +1133,14 @@ static void drawRGBSliders(Sprite* sprite, s32 x, s32 y) if(hasFocus) { drawPanelBorder(sprite->tic, rect.x, rect.y, rect.w, rect.h); - tic_api_rect(sprite->tic, rect.x, rect.y, rect.w, rect.h, tic_color_black); + tic_api_rect(sprite->tic, rect.x, rect.y, rect.w, rect.h, tic_color_black); } for(s32 i = 0; i < Rows; i++) { char buf[sizeof "FF"]; sprintf(buf, "%02X", data[i]); - tic_api_print(tic, buf, rect.x + 1, rect.y + i * TIC_FONT_HEIGHT + 1, + tic_api_print(tic, buf, rect.x + 1, rect.y + i * TIC_FONT_HEIGHT + 1, hasFocus ? tic_color_grey : tic_color_light_grey, true, 1, false); } @@ -1332,7 +1332,7 @@ static void drawPaletteVBank1(Sprite* sprite, s32 x, s32 y) else { drawBitIcon(sprite->studio, tic_icon_rgb, rect.x, rect.y+1, tic_color_black); - drawBitIcon(sprite->studio, tic_icon_rgb, rect.x, rect.y, (over ? tic_color_light_grey : tic_color_white)); + drawBitIcon(sprite->studio, tic_icon_rgb, rect.x, rect.y, (over ? tic_color_light_grey : tic_color_white)); } } } @@ -1350,7 +1350,7 @@ static void drawPalette(Sprite* sprite, s32 x, s32 y) static void selectSprite(Sprite* sprite, s32 x, s32 y) { { - s32 size = TIC_SPRITESHEET_SIZE - sprite->size; + s32 size = TIC_SPRITESHEET_SIZE - sprite->size; if(x < 0) x = 0; if(y < 0) y = 0; if(x > size) x = size; @@ -1380,13 +1380,13 @@ static void drawSheetVBank1(Sprite* sprite, s32 x, s32 y) for(s32 i = 1; i < rect.h; i += 4) { - if (sprite->blit.page > 0) + if (sprite->blit.page > 0) { tic_api_pix(tic, rect.x-1, rect.y + i, tic_color_black, false); tic_api_pix(tic, rect.x-1, rect.y + i + 1, tic_color_black, false); } - if (sprite->blit.page < sprite->blit.pages - 1) + if (sprite->blit.page < sprite->blit.pages - 1) { tic_api_pix(tic, rect.x+rect.w, rect.y + i, tic_color_black, false); tic_api_pix(tic, rect.x+rect.w, rect.y + i + 1, tic_color_black, false); @@ -1418,7 +1418,7 @@ static void drawSheet(Sprite* sprite, s32 x, s32 y) tic_blit blit = sprite->blit; SCOPE(tic->ram->vram.blit.segment = TIC_DEFAULT_BLIT_MODE) { - tic_point start = + tic_point start = { x - blit.page * TIC_SPRITESHEET_SIZE + sprite->anim.pos.page, y - blit.bank * TIC_SPRITESHEET_SIZE + sprite->anim.pos.bank @@ -1537,7 +1537,7 @@ static void drawSpriteTools(Sprite* sprite, s32 x, s32 y) { bool pushed = false; bool over = false; - + tic_rect rect = {x + i * Gap, y, TIC_SPRITESIZE, TIC_SPRITESIZE}; if(checkMousePos(sprite->studio, &rect)) @@ -1551,7 +1551,7 @@ static void drawSpriteTools(Sprite* sprite, s32 x, s32 y) if(checkMouseDown(sprite->studio, &rect, tic_mouse_left)) pushed = true; if(checkMouseClick(sprite->studio, &rect, tic_mouse_left)) - { + { if(hasCanvasSelection(sprite)) { CanvasToolsFunc[i](sprite); @@ -1597,7 +1597,7 @@ static void drawTools(Sprite* sprite, s32 x, s32 y) showTooltip(sprite->studio, Tooltips[i]); if(checkMouseClick(sprite->studio, &rect, tic_mouse_left)) - { + { sprite->mode = i; clearCanvasSelection(sprite); @@ -1723,7 +1723,7 @@ static void leftSprite(Sprite* sprite) static void rightSprite(Sprite* sprite) { - if ((sprite->x + sprite->size/TIC_SPRITESIZE) < TIC_SPRITESHEET_COLS) sprite->x++; + if ((sprite->x + sprite->size/TIC_SPRITESIZE) < TIC_SPRITESHEET_COLS) sprite->x++; updateIndex(sprite); } @@ -1797,7 +1797,7 @@ static void drawBankTabs(Sprite* sprite, s32 x, s32 y) if(checkMouseClick(sprite->studio, &rect, tic_mouse_left)) { - if (!current) + if (!current) { switchBanks(sprite); } @@ -1905,7 +1905,7 @@ static void processKeyboard(Sprite* sprite) bool ctrl = tic_api_key(tic, tic_key_ctrl); if(ctrl) - { + { if(keyWasPressed(sprite->studio, tic_key_z)) undo(sprite); else if(keyWasPressed(sprite->studio, tic_key_y)) redo(sprite); @@ -1913,10 +1913,10 @@ static void processKeyboard(Sprite* sprite) else if(keyWasPressed(sprite->studio, tic_key_right)) rightViewport(sprite); else if(keyWasPressed(sprite->studio, tic_key_tab)) - switchBitMode(sprite, sprite->blit.mode == tic_bpp_4 - ? tic_bpp_2 - : sprite->blit.mode == tic_bpp_2 - ? tic_bpp_1 + switchBitMode(sprite, sprite->blit.mode == tic_bpp_4 + ? tic_bpp_2 + : sprite->blit.mode == tic_bpp_2 + ? tic_bpp_1 : tic_bpp_4); } else @@ -1938,7 +1938,7 @@ static void processKeyboard(Sprite* sprite) else if(keyWasPressed(sprite->studio, tic_key_5)) flipCanvasHorz(sprite); else if(keyWasPressed(sprite->studio, tic_key_6)) flipCanvasVert(sprite); else if(keyWasPressed(sprite->studio, tic_key_7)) rotateCanvas(sprite); - else if(keyWasPressed(sprite->studio, tic_key_8)) deleteCanvas(sprite); + else if(keyWasPressed(sprite->studio, tic_key_8)) deleteCanvas(sprite); } } else @@ -1969,7 +1969,7 @@ static void processKeyboard(Sprite* sprite) else if(keyWasPressed(sprite->studio, tic_key_equals)) updateBrushSize(sprite, +1); else if(keyWasPressed(sprite->studio, tic_key_leftbracket)) updateColorIndex(sprite, -1); else if(keyWasPressed(sprite->studio, tic_key_rightbracket)) updateColorIndex(sprite, +1); - } + } } } } @@ -2054,7 +2054,7 @@ static void drawSpriteToolbar(Sprite* sprite) static void scanline(tic_mem* tic, s32 row, void* data) { Sprite* sprite = (Sprite*)data; - + if(row == 0) memcpy(&tic->ram->vram.palette, getBankPalette(sprite->studio, sprite->palette.vbank1), sizeof(tic_palette)); } @@ -2103,13 +2103,13 @@ static void tick(Sprite* sprite) s32 size = sprite->size; s32 delta = input->mouse.scrolly; - if(delta > 0) + if(delta > 0) { if(size < (TIC_SPRITESIZE * TIC_SPRITESIZE)) size <<= 1; } else if(size > TIC_SPRITESIZE) size >>= 1; - updateSpriteSize(sprite, size); + updateSpriteSize(sprite, size); } } @@ -2123,7 +2123,7 @@ static void tick(Sprite* sprite) { tic_api_cls(tic, tic->ram->vram.vars.clear = tic_color_cyan); - static const tic_rect bg[] = + static const tic_rect bg[] = { {0, ToolbarH, SheetX, CanvasY-ToolbarH}, {0, CanvasY, CanvasX, CanvasH}, @@ -2155,14 +2155,14 @@ static void tick(Sprite* sprite) drawBankTabs(sprite, SheetX, 8); - sprite->palette.edit - ? drawRGBSliders(sprite, 24, 91) + sprite->palette.edit + ? drawRGBSliders(sprite, 24, 91) : drawTools(sprite, 12, 96); drawPaletteVBank1(sprite, 24, 112); drawSheetVBank1(sprite, TIC80_WIDTH - TIC_SPRITESHEET_SIZE - 1, 7); drawAdvancedButton(sprite, 4, 11); - + drawSpriteToolbar(sprite); drawToolbar(sprite->studio, tic, false); } @@ -2217,13 +2217,13 @@ void initSprite(Sprite* sprite, Studio* studio, tic_tiles* src) .color = 2, .color2 = 0, .size = TIC_SPRITESIZE, - .palette = + .palette = { .edit = false, .focus = -1, }, .brushSize = 1, - .select = + .select = { .rect = {0,0,0,0}, .start = {0,0}, @@ -2248,7 +2248,7 @@ void initSprite(Sprite* sprite, Studio* studio, tic_tiles* src) }), }, .event = onStudioEvent, - .scanline = scanline, + .scanline = scanline, }; sprite->anim.movie = resetMovie(&sprite->anim.idle); diff --git a/src/studio/editors/sprite.h b/src/studio/editors/sprite.h index c60512b1a..646cfe426 100644 --- a/src/studio/editors/sprite.h +++ b/src/studio/editors/sprite.h @@ -37,7 +37,7 @@ struct Sprite u32 tickCounter; - struct + struct { bool start; tic_point last; diff --git a/src/studio/editors/world.c b/src/studio/editors/world.c index e5b05557b..13ca5165e 100644 --- a/src/studio/editors/world.c +++ b/src/studio/editors/world.c @@ -82,7 +82,7 @@ static void tick(World* world) tic_mem* tic = world->tic; // process scroll - if(tic->ram->input.mouse.scrolly > 0) + if(tic->ram->input.mouse.scrolly > 0) { setStudioMode(world->studio, TIC_MAP_MODE); return; diff --git a/src/studio/fs.c b/src/studio/fs.c index f11a4a176..248107273 100644 --- a/src/studio/fs.c +++ b/src/studio/fs.c @@ -76,7 +76,7 @@ void syncfs() { EM_ASM({Module.syncFSRequests++;}); } -#endif +#endif const char* tic_fs_pathroot(tic_fs* fs, const char* name) { @@ -104,7 +104,7 @@ const char* tic_fs_path(tic_fs* fs, const char* name) strncpy(path, name + 1, sizeof path); else if(strlen(fs->work)) snprintf(path, sizeof path, "%s/%s", fs->work, name); - else + else strncpy(path, name, sizeof path); return tic_fs_pathroot(fs, path); @@ -140,7 +140,7 @@ bool tic_fs_ispubdir(tic_fs* fs) typedef wchar_t FsString; -#define __S(x) L ## x +#define __S(x) L ## x #define _S(x) __S(x) static const FsString* utf8ToString(const char* str) @@ -444,7 +444,7 @@ bool tic_fs_deldir(tic_fs* fs, const char* name) #if defined(__EMSCRIPTEN__) syncfs(); -#endif +#endif return result; #endif @@ -465,7 +465,7 @@ bool tic_fs_delfile(tic_fs* fs, const char* name) #if defined(__EMSCRIPTEN__) syncfs(); -#endif +#endif return result; #endif @@ -593,16 +593,16 @@ bool fs_write(const char* name, const void* buffer, s32 size) } u32 written=0; - + res = f_write(&File, buffer, size, &written); - + f_close(&File); if (res != FR_OK) { return false; } if(written!=size) - { + { dbg("Write size diff %d %d", size, written); return false; } @@ -810,7 +810,7 @@ void* tic_fs_load(tic_fs* fs, const char* name, s32* size) dbg("tic_fs_load x %s\n", name); dbg("fs.dir %s\n", fs->dir); dbg("fs.work %s\n", fs->work); - + if(isPublic(fs)) { dbg("Public ??\n"); @@ -827,7 +827,7 @@ void* tic_fs_load(tic_fs* fs, const char* name, s32* size) FRESULT res = f_stat(fp, &fi); dbg("fstat done %d \n", res); - if(res!=FR_OK) + if(res!=FR_OK) { dbg("NO F_STAT %d\n", res); return NULL; @@ -849,7 +849,7 @@ void* tic_fs_load(tic_fs* fs, const char* name, s32* size) dbg("F_READ %d %ld\n", res, read); f_close(&file); - if(read!=fi.fsize) + if(read!=fi.fsize) { dbg("NO F_READ %d \n", res); return NULL; @@ -880,7 +880,7 @@ void* tic_fs_load(tic_fs* fs, const char* name, s32* size) fclose(file); } - return ptr; + return ptr; #endif } diff --git a/src/studio/net.c b/src/studio/net.c index de85baf6b..ed6f4fc83 100644 --- a/src/studio/net.c +++ b/src/studio/net.c @@ -44,14 +44,14 @@ struct tic_net emscripten_fetch_attr_t attr; }; -static void downloadSucceeded(emscripten_fetch_t *fetch) +static void downloadSucceeded(emscripten_fetch_t *fetch) { FetchData* data = (FetchData*)fetch->userData; - net_get_data getData = + net_get_data getData = { .type = net_get_done, - .done = + .done = { .size = fetch->numBytes, .data = (u8*)fetch->data, @@ -68,14 +68,14 @@ static void downloadSucceeded(emscripten_fetch_t *fetch) emscripten_fetch_close(fetch); } -static void downloadFailed(emscripten_fetch_t *fetch) +static void downloadFailed(emscripten_fetch_t *fetch) { FetchData* data = (FetchData*)fetch->userData; - net_get_data getData = + net_get_data getData = { .type = net_get_error, - .error = + .error = { .code = fetch->status, }, @@ -90,14 +90,14 @@ static void downloadFailed(emscripten_fetch_t *fetch) emscripten_fetch_close(fetch); } -static void downloadProgress(emscripten_fetch_t *fetch) +static void downloadProgress(emscripten_fetch_t *fetch) { FetchData* data = (FetchData*)fetch->userData; - net_get_data getData = + net_get_data getData = { .type = net_get_progress, - .progress = + .progress = { .size = fetch->dataOffset + fetch->numBytes, .total = fetch->totalBytes, @@ -320,7 +320,7 @@ static void n3ds_net_get_thread(net_ctx *ctx) { free(ctx); } -static void n3ds_net_apply_url(net_ctx *ctx, const char *url) +static void n3ds_net_apply_url(net_ctx *ctx, const char *url) { snprintf(ctx->url, URL_SIZE, "http://%s%s", ctx->net->host, url); } @@ -345,7 +345,7 @@ tic_net* tic_net_create(const char* host) void tic_net_get(tic_net* net, const char* url, net_get_callback callback, void* calldata) { - net_ctx ctx = + net_ctx ctx = { .net = net, .callback = callback, @@ -438,7 +438,7 @@ void tic_net_get(tic_net* net, const char* url, net_get_callback callback, void* net->requests[net->count - 1] = get; } -void tic_net_close(tic_net* net) +void tic_net_close(tic_net* net) { for(s32 i = 0; i < net->count; i++) { @@ -448,7 +448,7 @@ void tic_net_close(tic_net* net) { naettClose(it->res); naettFree(it->req); - free(it); + free(it); } } @@ -471,7 +471,7 @@ void tic_net_end(tic_net *net) { s32 status = naettGetStatus(it->res); - net_get_data getData = + net_get_data getData = { .calldata = it->calldata, .url = it->url, diff --git a/src/studio/project.c b/src/studio/project.c index 951c1c44a..0634a1a66 100644 --- a/src/studio/project.c +++ b/src/studio/project.c @@ -29,7 +29,7 @@ #include #include -static const struct BinarySection{const char* tag; s32 count; s32 offset; s32 size; bool flip;} BinarySections[] = +static const struct BinarySection{const char* tag; s32 count; s32 offset; s32 size; bool flip;} BinarySections[] = { {"TILES", TIC_BANK_SPRITES, offsetof(tic_bank, tiles), sizeof(tic_tile), true}, {"SPRITES", TIC_BANK_SPRITES, offsetof(tic_bank, sprites), sizeof(tic_tile), true}, @@ -73,7 +73,7 @@ static char* saveTextSection(char* ptr, const char* data) static char* saveBinaryBuffer(char* ptr, const char* comment, const void* data, s32 size, s32 row, bool flip) { - if(bufferEmpty(data, size)) + if(bufferEmpty(data, size)) return ptr; sprintf(ptr, "%s %03i:", comment, row); @@ -90,7 +90,7 @@ static char* saveBinaryBuffer(char* ptr, const char* comment, const void* data, static char* saveBinarySection(char* ptr, const char* comment, const char* tag, s32 count, const void* data, s32 size, bool flip) { - if(bufferEmpty(data, size * count)) + if(bufferEmpty(data, size * count)) return ptr; sprintf(ptr, "%s <%s>\n", comment, tag); @@ -128,7 +128,7 @@ s32 tic_project_save(const char* name, void* data, const tic_cartridge* cart) { makeTag(section->tag, tag, b); - ptr = saveBinarySection(ptr, comment, tag, section->count, + ptr = saveBinarySection(ptr, comment, tag, section->count, (u8*)&cart->banks[b] + section->offset, section->size, section->flip); } @@ -199,7 +199,7 @@ static bool loadBinarySection(const char* project, const char* comment, const ch memcpy(lineStr, ptr + strlen(comment) + 1, sizeof lineStr - 1); s32 index = atoi(lineStr); - + if(index < count) { ptr += strlen(comment) + sizeof(" 999:") - 1; @@ -209,7 +209,7 @@ static bool loadBinarySection(const char* project, const char* comment, const ch ptr = getLineEnd(ptr); } else break; - } + } } else { diff --git a/src/studio/screens/console.c b/src/studio/screens/console.c index 50b57906f..2f3c5e1eb 100644 --- a/src/studio/screens/console.c +++ b/src/studio/screens/console.c @@ -126,7 +126,7 @@ macro(vbank) \ macro(id) \ ALONE_KEY(macro) - + static const char* WelcomeText = "TIC-80 is a fantasy computer for making, playing and sharing tiny games.\n\n" "It has built-in tools for development: code, sprites, maps, sound editors and the command line, " @@ -1232,7 +1232,7 @@ static void onNewCommandConfirmed(Console* console) { loadDemo(console, ln); done = true; - } + } } if(!done) @@ -1834,14 +1834,14 @@ static void onImportTilesBase(Console* console, const char* name, const void* bu case 1: bpp_scale = 4; break; - case 2: + case 2: bpp_scale = 2; break; default: break; } u32 color1, color2, color3, color4, color; - + for(s32 j = 0, y = params.y, h = y + (params.h ? params.h : img.height); y < h; ++y, ++j) for(s32 i = 0, x = params.x, w = x + ((params.w ? params.w : img.width) / bpp_scale); x < w; ++x, i += bpp_scale) if(x >= 0 && x < TIC_SPRITESHEET_SIZE && y >= 0 && y < TIC_SPRITESHEET_SIZE) @@ -3711,7 +3711,7 @@ static void onHelp_hotkeys(Console* console) free(rowReplaced); #undef OFFSET } - + printFront(console, "\nCode Editor:\n"); FOR(const struct HotkeysRowCodeEditor*, row, HotkeysTextCodeEditor) { @@ -3722,7 +3722,7 @@ static void onHelp_hotkeys(Console* console) free(rowReplaced); #undef OFFSET } - + printFront(console, "\nSprite Editor:\n"); FOR(const struct HotkeysRowSpriteEditor*, row, HotkeysTextSpriteEditor) { @@ -3733,7 +3733,7 @@ static void onHelp_hotkeys(Console* console) free(rowReplaced); #undef OFFSET } - + printFront(console, "\nMap Editor:\n"); FOR(const struct HotkeysRowMapEditor*, row, HotkeysTextMapEditor) { @@ -3744,7 +3744,7 @@ static void onHelp_hotkeys(Console* console) free(rowReplaced); #undef OFFSET } - + printFront(console, "\nSFX Editor:\n"); FOR(const struct HotkeysRowSFXEditor*, row, HotkeysTextSFXEditor) { @@ -4002,8 +4002,8 @@ static void onHttpVersionGet(const net_get_data* data) s32 minor = json_int("minor", 0); s32 patch = json_int("patch", 0); - if((major > TIC_VERSION_MAJOR) - || (major == TIC_VERSION_MAJOR && minor > TIC_VERSION_MINOR) + if((major > TIC_VERSION_MAJOR) + || (major == TIC_VERSION_MAJOR && minor > TIC_VERSION_MINOR) || (major == TIC_VERSION_MAJOR && minor == TIC_VERSION_MINOR && patch > TIC_VERSION_REVISION)) { char msg[TICNAME_MAX]; @@ -4359,7 +4359,7 @@ static void tick(Console* console) } else printBack(console, "\n loading cart..."); } - + tic_api_cls(tic, TIC_COLOR_BG); drawConsoleText(console); @@ -4579,7 +4579,7 @@ void initConsole(Console* console, Studio* studio, tic_fs* fs, tic_net* net, Con exit(1); } else - getStartScreen(console->studio)->embed = true; + getStartScreen(console->studio)->embed = true; } console->active = !start->embed; diff --git a/src/studio/screens/console.h b/src/studio/screens/console.h index 96efa16ba..bea6ff548 100644 --- a/src/studio/screens/console.h +++ b/src/studio/screens/console.h @@ -92,7 +92,7 @@ struct Console bool active; StartArgs args; - + struct { s32 count; diff --git a/src/studio/screens/mainmenu.c b/src/studio/screens/mainmenu.c index 985096273..e40b527e8 100644 --- a/src/studio/screens/mainmenu.c +++ b/src/studio/screens/mainmenu.c @@ -51,7 +51,7 @@ struct StudioMainMenu static void showMainMenu(void* data, s32 pos); -StudioMainMenu* studio_mainmenu_init(Menu *menu, Config *config) +StudioMainMenu* studio_mainmenu_init(Menu *menu, Config *config) { StudioMainMenu* main = NEW(StudioMainMenu); @@ -102,7 +102,7 @@ static void optionFullscreenSet(void* data, s32 pos) static const char OffValue[] = "OFF"; static const char OnValue[] = "ON"; -static MenuOption FullscreenOption = +static MenuOption FullscreenOption = { OPTION_VALUES({OffValue, OnValue}), optionFullscreenGet, @@ -121,7 +121,7 @@ static void optionIntegerScaleSet(void* data, s32 pos) main->options->integerScale = (pos == 1); } -static MenuOption IntegerScaleOption = +static MenuOption IntegerScaleOption = { OPTION_VALUES({OffValue, OnValue}), optionIntegerScaleGet, @@ -141,7 +141,7 @@ static void optionCrtMonitorSet(void* data, s32 pos) main->options->crt = pos == 1; } -static MenuOption CrtMonitorOption = +static MenuOption CrtMonitorOption = { OPTION_VALUES({OffValue, OnValue}), optionCrtMonitorGet, @@ -162,7 +162,7 @@ static void optionVSyncSet(void* data, s32 pos) main->options->vsync = pos == 1; } -static MenuOption VSyncOption = +static MenuOption VSyncOption = { OPTION_VALUES({OffValue, OnValue}), optionVSyncGet, @@ -181,14 +181,14 @@ static void optionVolumeSet(void* data, s32 pos) main->options->volume = pos; } -static MenuOption VolumeOption = +static MenuOption VolumeOption = { OPTION_VALUES( { - "00", "01", "02", "03", - "04", "05", "06", "07", - "08", "09", "10", "11", - "12", "13", "14", "15", + "00", "01", "02", "03", + "04", "05", "06", "07", + "08", "09", "10", "11", + "12", "13", "14", "15", }), optionVolumeGet, optionVolumeSet, @@ -278,7 +278,7 @@ static void optionKeybindModeSet(void* data, s32 pos) main->options->keybindMode = (enum KeybindMode) pos; } -static MenuOption KeybindModeOption = +static MenuOption KeybindModeOption = { OPTION_VALUES({"STANDARD", "EMACS", "VI"}), optionKeybindModeGet, @@ -364,7 +364,7 @@ static void showEditorMenu(void* data, s32 pos) { StudioMainMenu* main = data; - studio_menu_init(main->menu, EditorMenu, + studio_menu_init(main->menu, EditorMenu, COUNT_OF(EditorMenu), EditorMenu_KeybindMode, OptionsMenu_Editor, showOptionsMenu, main); } #endif @@ -420,7 +420,7 @@ static void initGameMenu(StudioMainMenu* main) items[count - 1] = (MenuItem){strdup("BACK"), showMainMenu, .back = true}; main->items = items; - main->count = count; + main->count = count; } } } @@ -514,7 +514,7 @@ static void resetGamepadMenu(void* data, s32 pos); static char MappingItems[TIC_BUTTONS][sizeof "RIGHT - RIGHT"]; -static const char* const ButtonLabels[] = +static const char* const ButtonLabels[] = { "UP", "DOWN", @@ -570,15 +570,15 @@ static void initGamepadButtons(StudioMainMenu* menu) static const char* const KeysList[] = { "...", - "A", "B", "C", "D", "E", "F", "G", "H", - "I", "J", "K", "L", "M", "N", "O", "P", - "Q", "R", "S", "T", "U", "V", "W", "X", - "Y", "Z", "0", "1", "2", "3", "4", "5", - "6", "7", "8", "9", "-", "=", "[", "]", - "\\", ";", "'", "`", ",", ".", "/", "SPCE", - "TAB", "RET", "BACKS","DEL", "INS", "PGUP", "PGDN", "HOME", - "END", "UP", "DOWN", "LEFT", "RIGHT","CAPS", "CTRL", "SHIFT", - "ALT", "ESC", "F1", "F2", "F3", "F4", "F5", "F6", + "A", "B", "C", "D", "E", "F", "G", "H", + "I", "J", "K", "L", "M", "N", "O", "P", + "Q", "R", "S", "T", "U", "V", "W", "X", + "Y", "Z", "0", "1", "2", "3", "4", "5", + "6", "7", "8", "9", "-", "=", "[", "]", + "\\", ";", "'", "`", ",", ".", "/", "SPCE", + "TAB", "RET", "BACKS","DEL", "INS", "PGUP", "PGDN", "HOME", + "END", "UP", "DOWN", "LEFT", "RIGHT","CAPS", "CTRL", "SHIFT", + "ALT", "ESC", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "NP0", "NP1", "NP2", "NP3", "NP4", "NP5", "NP6", "NP7", "NP8", "NP9", "NP+", "NP-", "NP*", "NP/", "NPENT", "NP.", @@ -601,7 +601,7 @@ static void optionGamepadSet(void* data, s32 pos) initGamepadButtons(main); } -static MenuOption GamepadOption = +static MenuOption GamepadOption = { OPTION_VALUES({"1", "2", "3", "4"}), optionGamepadGet, @@ -648,8 +648,8 @@ static void initGamepadMenu(StudioMainMenu* main) initGamepadButtons(main); - studio_menu_init(main->menu, GamepadMenu, COUNT_OF(GamepadMenu), - main->gamepads.key < 0 ? GamepadMenu_Gamepad0 : main->gamepads.key + GamepadMenu_Gamepad0, + studio_menu_init(main->menu, GamepadMenu, COUNT_OF(GamepadMenu), + main->gamepads.key < 0 ? GamepadMenu_Gamepad0 : main->gamepads.key + GamepadMenu_Gamepad0, OptionsMenu_Gamepad, showOptionsMenu, main); main->gamepads.key = -1; diff --git a/src/studio/screens/menu.c b/src/studio/screens/menu.c index 5baf90e2e..9f4fab100 100644 --- a/src/studio/screens/menu.c +++ b/src/studio/screens/menu.c @@ -254,7 +254,7 @@ static void drawMenu(Menu* menu, s32 x, s32 y) { playSystemSfx(menu->studio, 2); updateOption(option, +1, menu->data); - } + } } if(tic_api_btnp(menu->tic, A, -1, -1) || ticEnterWasPressed(tic, -1, -1)) @@ -268,8 +268,8 @@ static void drawMenu(Menu* menu, s32 x, s32 y) onMenuItem(menu, item); } - if((tic_api_btnp(menu->tic, B, -1, -1) - || tic_api_keyp(tic, tic_key_backspace, Hold, Period)) + if((tic_api_btnp(menu->tic, B, -1, -1) + || tic_api_keyp(tic, tic_key_backspace, Hold, Period)) && menu->back) { playSystemSfx(menu->studio, 2); @@ -282,7 +282,7 @@ static void drawMenu(Menu* menu, s32 x, s32 y) { s32 width = it->option ? menu->maxwidth.item + menu->maxwidth.option + 3 * TIC_FONT_WIDTH : it->width; - tic_rect rect = {x + (TIC80_WIDTH - width) / 2 + menu->anim.offset, + tic_rect rect = {x + (TIC80_WIDTH - width) / 2 + menu->anim.offset, y + TextMargin + ItemHeight * (i - menu->pos) - menu->anim.pos, it->width, TIC_FONT_HEIGHT}; if (it->hotkey != tic_key_unknown && tic_api_keyp(tic, it->hotkey, Hold, Period)) @@ -320,10 +320,10 @@ static void drawMenu(Menu* menu, s32 x, s32 y) if(it->option) { drawOptionArrow(menu, it->option, rect.x + menu->maxwidth.item + TIC_FONT_WIDTH, rect.y, tic_icon_left, -1); - drawOptionArrow(menu, it->option, + drawOptionArrow(menu, it->option, rect.x + menu->maxwidth.item + it->option->width + 2 * TIC_FONT_WIDTH, rect.y, tic_icon_right, +1); - printShadow(tic, it->option->values[it->option->pos], + printShadow(tic, it->option->values[it->option->pos], rect.x + menu->maxwidth.item + 2 * TIC_FONT_WIDTH, rect.y, tic_color_yellow); } } @@ -341,16 +341,16 @@ void studio_menu_anim(tic_mem* tic, s32 ticks) s32 ly = Gap - 8 * 32 * 16 / (x - ticks % 16); tic_api_line(tic, 0, ly, TIC80_WIDTH, ly, BG_ANIM_COLOR); - tic_api_line(tic, 0, TIC80_HEIGHT - ly, + tic_api_line(tic, 0, TIC80_HEIGHT - ly, TIC80_WIDTH, TIC80_HEIGHT - ly, BG_ANIM_COLOR); } for(s32 x = -32; x <= 32; x++) { - tic_api_line(tic, TIC80_WIDTH / 2 - x * 4, Gap - 16, + tic_api_line(tic, TIC80_WIDTH / 2 - x * 4, Gap - 16, TIC80_WIDTH / 2 - x * 24, -16, BG_ANIM_COLOR); - tic_api_line(tic, TIC80_WIDTH / 2 - x * 4, TIC80_HEIGHT - Gap + 16, + tic_api_line(tic, TIC80_WIDTH / 2 - x * 4, TIC80_HEIGHT - Gap + 16, TIC80_WIDTH / 2 - x * 24, TIC80_HEIGHT + 16, BG_ANIM_COLOR); } } @@ -438,7 +438,7 @@ void studio_menu_tick(Menu* menu) else { s32 pos = menu->pos + (input->mouse.scrolly < 0 ? +1 : -1); - menu->pos = CLAMP(pos, 0, menu->count - 1); + menu->pos = CLAMP(pos, 0, menu->count - 1); } } } diff --git a/src/studio/screens/run.c b/src/studio/screens/run.c index e2e1986e6..855669bd3 100644 --- a/src/studio/screens/run.c +++ b/src/studio/screens/run.c @@ -54,12 +54,12 @@ static const char* data2md5(const void* data, s32 length) { const char *str = data; MD5_CTX c; - + static char out[33]; MD5_Init(&c); - while (length > 0) + while (length > 0) { MD5_Update(&c, str, length > 512 ? 512: length); diff --git a/src/studio/screens/run.h b/src/studio/screens/run.h index f0c84cd93..ff5341862 100644 --- a/src/studio/screens/run.h +++ b/src/studio/screens/run.h @@ -36,7 +36,7 @@ struct Run tic_tick_data tickData; bool exit; - + char saveid[TICNAME_MAX]; tic_persistent pmem; diff --git a/src/studio/screens/start.c b/src/studio/screens/start.c index e917e8a54..7f5abc895 100644 --- a/src/studio/screens/start.c +++ b/src/studio/screens/start.c @@ -47,18 +47,18 @@ static void reset(Start* start) static void drawHeader(Start* start) { for(s32 i = 0; i < STUDIO_TEXT_BUFFER_SIZE; i++) - tic_api_print(start->tic, (char[]){start->text[i], '\0'}, - (i % STUDIO_TEXT_BUFFER_WIDTH) * STUDIO_TEXT_WIDTH, - (i / STUDIO_TEXT_BUFFER_WIDTH) * STUDIO_TEXT_HEIGHT, + tic_api_print(start->tic, (char[]){start->text[i], '\0'}, + (i % STUDIO_TEXT_BUFFER_WIDTH) * STUDIO_TEXT_WIDTH, + (i / STUDIO_TEXT_BUFFER_WIDTH) * STUDIO_TEXT_HEIGHT, start->color[i], true, 1, false); } -static void chime(Start* start) +static void chime(Start* start) { playSystemSfx(start->studio, 1); } -static void stop_chime(Start* start) +static void stop_chime(Start* start) { sfx_stop(start->tic, 0); } @@ -76,7 +76,7 @@ static void start_console(Start* start) static void tick(Start* start) { - // stages that have a tick count of 0 run in zero time + // stages that have a tick count of 0 run in zero time // (typically this is only used to start/stop audio) while (start->stages[start->stage].ticks == 0) { start->stages[start->stage].fn(start); @@ -131,7 +131,7 @@ void initStart(Start* start, Studio* studio, const char* cart) .embed = false, .ticks = 0, .stage = 0, - .stages = + .stages = { { reset, .ticks = one_second }, { chime, .ticks = immediate }, @@ -141,7 +141,7 @@ void initStart(Start* start, Studio* studio, const char* cart) } }; - static const char* Header[] = + static const char* Header[] = { "", " " TIC_NAME_FULL, @@ -153,7 +153,7 @@ void initStart(Start* start, Studio* studio, const char* cart) strcpy(&start->text[i * STUDIO_TEXT_BUFFER_WIDTH], Header[i]); for(s32 i = 0; i < STUDIO_TEXT_BUFFER_SIZE; i++) - start->color[i] = CLAMP(((i % STUDIO_TEXT_BUFFER_WIDTH) + (i / STUDIO_TEXT_BUFFER_WIDTH)) / 2, + start->color[i] = CLAMP(((i % STUDIO_TEXT_BUFFER_WIDTH) + (i / STUDIO_TEXT_BUFFER_WIDTH)) / 2, tic_color_black, tic_color_dark_grey); #if defined(__EMSCRIPTEN__) @@ -175,39 +175,39 @@ void initStart(Start* start, Studio* studio, const char* cart) { const char* appPath = fs_apppath(); - + s32 appSize = 0; u8* app = fs_read(appPath, &appSize); - + if(app) SCOPE(free(app)) { s32 size = appSize; const u8* ptr = app; - + while(true) { const EmbedHeader* header = (const EmbedHeader*)_memmem(ptr, size, CART_SIG, STRLEN(CART_SIG)); - + if(header) { if(appSize == header->appSize + sizeof(EmbedHeader) + header->cartSize) { u8* data = calloc(1, sizeof(tic_cartridge)); - + if(data) { s32 dataSize = tic_tool_unzip(data, sizeof(tic_cartridge), app + header->appSize + sizeof(EmbedHeader), header->cartSize); - + if(dataSize) { tic_cart_load(&start->tic->cart, data, dataSize); tic_api_reset(start->tic); start->embed = true; } - + free(data); } - + break; } else diff --git a/src/studio/screens/surf.c b/src/studio/screens/surf.c index b26ffa8d9..b5b26a83e 100644 --- a/src/studio/screens/surf.c +++ b/src/studio/screens/surf.c @@ -138,7 +138,7 @@ static void drawBottomToolbar(Surf* surf, s32 x, s32 y) tic_api_print(tic, label, xl, yl, tic_color_white, true, 1, false); } -#ifdef CAN_OPEN_URL +#ifdef CAN_OPEN_URL if(surf->menu.count > 0 && getMenuItem(surf)->hash) { @@ -171,7 +171,7 @@ static void drawMenu(Surf* surf, s32 x, s32 y) { const char* name = surf->menu.items[i].label; - if (ym > (-(TIC_FONT_HEIGHT + 1)) && ym <= TIC80_HEIGHT) + if (ym > (-(TIC_FONT_HEIGHT + 1)) && ym <= TIC80_HEIGHT) { tic_api_print(tic, name, x + MAIN_OFFSET, ym + 1, tic_color_black, false, 1, false); tic_api_print(tic, name, x + MAIN_OFFSET, ym, tic_color_white, false, 1, false); @@ -190,7 +190,7 @@ static bool addMenuItem(const char* name, const char* title, const char* hash, s static const char CartExt[] = CART_EXT; - if(dir + if(dir || tic_tool_has_ext(name, CartExt) || tic_tool_has_ext(name, PngExt) #if defined(TIC80_PRO) @@ -297,8 +297,8 @@ static void updateMenuItemCover(Surf* surf, s32 pos, const u8* cover, s32 size) item->cover = malloc(sizeof(tic_screen)); item->palette = malloc(sizeof(tic_palette)); - if (image->width == TIC80_WIDTH - && image->height == TIC80_HEIGHT + if (image->width == TIC80_WIDTH + && image->height == TIC80_HEIGHT && image->colors <= TIC_PALETTE_SIZE) { memcpy(item->palette, image->palette, image->colors * sizeof(tic_rgb)); @@ -378,9 +378,9 @@ static void requestCover(Surf* surf, SurfItem* item) static void loadCover(Surf* surf) { tic_mem* tic = surf->tic; - + SurfItem* item = getMenuItem(surf); - + if(item->coverLoading) return; @@ -431,7 +431,7 @@ static void loadCover(Surf* surf) } else if(item->hash && !item->cover) { - requestCover(surf, item); + requestCover(surf, item); } } @@ -685,8 +685,8 @@ static void processGamepad(Surf* surf) || ticEnterWasPressed(tic, -1, -1)) { SurfItem* item = getMenuItem(surf); - item->dir - ? changeDirectory(surf, item->name) + item->dir + ? changeDirectory(surf, item->name) : loadCart(surf); } @@ -855,7 +855,7 @@ void initSurf(Surf* surf, Studio* studio, struct Console* console) .init = false, .loading = true, .resume = resume, - .menu = + .menu = { .pos = 0, .items = NULL, @@ -885,7 +885,7 @@ void initSurf(Surf* surf, Studio* studio, struct Console* console) .move = MOVIE_DEF(9, moveDone, {{0, 0, 9, &surf->anim.val.pos, AnimLinear}}), - .gotodir = + .gotodir = { .show = MOVIE_DEF(ANIM, setIdle, { @@ -900,7 +900,7 @@ void initSurf(Surf* surf, Studio* studio, struct Console* console) }), }, - .goback = + .goback = { .show = MOVIE_DEF(ANIM, setIdle, { diff --git a/src/studio/studio.c b/src/studio/studio.c index 6dbe8a420..4b024d507 100644 --- a/src/studio/studio.c +++ b/src/studio/studio.c @@ -428,7 +428,7 @@ char getKeyboardText(Studio* studio) bool shift = tic_api_key(tic, tic_key_shift); return caps - ? key >= tic_key_a && key <= tic_key_z + ? key >= tic_key_a && key <= tic_key_z ? shift ? Symbols[key] : Shift[key] : shift ? Shift[key] : Symbols[key] : shift ? Shift[key] : Symbols[key]; @@ -600,8 +600,8 @@ bool fromClipboard(void* data, s32 size, bool flip, bool remove_white_spaces, bo if (remove_white_spaces) removeWhiteSpaces(clipboard); - bool valid = sameSize - ? strlen(clipboard) == size * 2 + bool valid = sameSize + ? strlen(clipboard) == size * 2 : strlen(clipboard) <= size * 2; if(valid) tic_tool_str2buf(clipboard, (s32)strlen(clipboard), data, flip); @@ -625,7 +625,7 @@ static void drawExtrabar(Studio* studio, tic_mem* tic) s32 x = (COUNT_OF(Modes) + 1) * Size + 17 * TIC_FONT_WIDTH; s32 y = 0; - static struct Icon {u8 id; StudioEvent event; const char* tip;} Icons[] = + static struct Icon {u8 id; StudioEvent event; const char* tip;} Icons[] = { {tic_icon_cut, TIC_TOOLBAR_CUT, "CUT [ctrl+x]"}, {tic_icon_copy, TIC_TOOLBAR_COPY, "COPY [ctrl+c]"}, @@ -737,7 +737,7 @@ static void drawBankIcon(Studio* studio, s32 x, s32 y) if(checkMouseClick(studio, &rect, tic_mouse_left)) { - if(studio->bank.chained) + if(studio->bank.chained) memset(studio->bank.indexes, i, sizeof studio->bank.indexes); else studio->bank.indexes[mode] = i; } @@ -746,12 +746,12 @@ static void drawBankIcon(Studio* studio, s32 x, s32 y) if(i == studio->bank.indexes[mode]) tic_api_rect(tic, rect.x, rect.y, rect.w, rect.h, tic_color_red); - tic_api_print(tic, (char[]){'0' + i, '\0'}, rect.x+1, rect.y+1, - i == studio->bank.indexes[mode] - ? tic_color_white - : over - ? tic_color_red - : tic_color_light_grey, + tic_api_print(tic, (char[]){'0' + i, '\0'}, rect.x+1, rect.y+1, + i == studio->bank.indexes[mode] + ? tic_color_white + : over + ? tic_color_red + : tic_color_light_grey, false, 1, false); } @@ -796,18 +796,18 @@ static inline float bounceOut(float x) { const float n1 = 7.5625; const float d1 = 2.75; - + if (x < 1 / d1) return n1 * x * x; else if (x < 2 / d1) - { + { x -= 1.5 / d1; return n1 * x * x + 0.75; - } + } else if (x < 2.5 / d1) - { + { x -= 2.25 / d1; return n1 * x * x + 0.9375; - } + } else { x -= 2.625 / d1; @@ -984,7 +984,7 @@ static void drawPopup(Studio* studio) enum{Width = TIC80_WIDTH, Height = TIC_FONT_HEIGHT + 1}; tic_api_rect(studio->tic, 0, studio->anim.pos.popup, Width, Height, tic_color_red); - tic_api_print(studio->tic, studio->popup.message, + tic_api_print(studio->tic, studio->popup.message, (s32)(Width - strlen(studio->popup.message) * TIC_FONT_WIDTH)/2, studio->anim.pos.popup + 1, tic_color_white, true, 1, false); @@ -997,7 +997,7 @@ static void drawPopup(Studio* studio) for(s32 i = 0, y = 0; y < (Height + studio->anim.pos.popup); y++, dst += TIC80_MARGIN_RIGHT + TIC80_MARGIN_LEFT) for(s32 x = 0; x < Width; x++) *dst++ = tic_rgba(&bank->palette.vbank0.colors[tic_tool_peek4(tic->ram->vram.screen.data, i++)]); - } + } } } @@ -1078,16 +1078,16 @@ void setStudioEvent(Studio* studio, StudioEvent event) { switch(studio->mode) { - case TIC_CODE_MODE: + case TIC_CODE_MODE: { Code* code = studio->code; - code->event(code, event); + code->event(code, event); } break; - case TIC_SPRITE_MODE: + case TIC_SPRITE_MODE: { Sprite* sprite = studio->banks.sprite[studio->bank.index.sprites]; - sprite->event(sprite, event); + sprite->event(sprite, event); } break; case TIC_MAP_MODE: @@ -1165,7 +1165,7 @@ void studio_exit(Studio* studio) confirmDialog(studio, Rows, COUNT_OF(Rows), exitConfirm, NULL); } - else + else #endif exitConfirm(studio, true, NULL); } @@ -1196,9 +1196,9 @@ void drawBitIcon(Studio* studio, s32 id, s32 x, s32 y, u8 color) static void initRunMode(Studio* studio) { - initRun(studio->run, + initRun(studio->run, #if defined(BUILD_EDITORS) - studio->console, + studio->console, #else NULL, #endif @@ -1334,8 +1334,8 @@ bool checkStudioViMode(Studio* studio, ViMode mode) { static inline bool pointInRect(const tic_point* pt, const tic_rect* rect) { - return (pt->x >= rect->x) - && (pt->x < (rect->x + rect->w)) + return (pt->x >= rect->x) + && (pt->x < (rect->x + rect->w)) && (pt->y >= rect->y) && (pt->y < (rect->y + rect->h)); } @@ -1431,10 +1431,10 @@ void confirmDialog(Studio* studio, const char** text, s32 rows, ConfirmCallback { studio->menuMode = studio->mode; } - + setStudioMode(studio, TIC_MENU_MODE); - static MenuItem Answers[] = + static MenuItem Answers[] = { {"", NULL}, {"(N)O", confirmNo}, @@ -1585,7 +1585,7 @@ void runGame(Studio* studio) memset(fftNormalizedMaxData, 0, sizeof(fftNormalizedMaxData[0]) * FFT_SIZE); } - if(studio->console->args.keepcmd + if(studio->console->args.keepcmd && studio->console->commands.count && studio->console->commands.current >= studio->console->commands.count) { @@ -1749,7 +1749,7 @@ static void switchBank(Studio* studio, s32 bank) for(s32 i = 0; i < COUNT_OF(BankModes); i++) if(BankModes[i] == studio->mode) { - if(studio->bank.chained) + if(studio->bank.chained) memset(studio->bank.indexes, bank, sizeof studio->bank.indexes); else studio->bank.indexes[i] = bank; break; @@ -1758,7 +1758,7 @@ static void switchBank(Studio* studio, s32 bank) #endif -void gotoMenu(Studio* studio) +void gotoMenu(Studio* studio) { setStudioMode(studio, TIC_MENU_MODE); studio_mainmenu_free(studio->mainmenu); @@ -1772,7 +1772,7 @@ static bool enterWasPressedOnce(Studio* studio) } #if defined(BUILD_EDITORS) -// These three are to fix the f1 hotkey conflict +// These three are to fix the f1 hotkey conflict // Add a static variable in studio.c to track the mode switch static bool justSwitchedToCodeMode = false; @@ -1866,26 +1866,26 @@ static void processShortcuts(Studio* studio) if( getConfig(studio)->options.keybindMode == KEYBIND_VI && getStudioViMode(studio) != VI_NORMAL - ) + ) return; switch(studio->mode) { - case TIC_MENU_MODE: - showGameMenu(studio) + case TIC_MENU_MODE: + showGameMenu(studio) ? studio_menu_back(studio->menu) - : setStudioMode(studio, studio->prevMode == TIC_RUN_MODE - ? TIC_CONSOLE_MODE + : setStudioMode(studio, studio->prevMode == TIC_RUN_MODE + ? TIC_CONSOLE_MODE : studio->prevMode); break; - case TIC_RUN_MODE: - showGameMenu(studio) + case TIC_RUN_MODE: + showGameMenu(studio) ? gotoMenu(studio) - : setStudioMode(studio, studio->prevMode == TIC_RUN_MODE - ? TIC_CONSOLE_MODE + : setStudioMode(studio, studio->prevMode == TIC_RUN_MODE + ? TIC_CONSOLE_MODE : studio->prevMode); break; - case TIC_CONSOLE_MODE: + case TIC_CONSOLE_MODE: setStudioMode(studio, TIC_CODE_MODE); break; case TIC_CODE_MODE: @@ -1966,7 +1966,7 @@ static void checkChanges(Studio* studio) "Do you want to reload it?" }; - confirmDialog(studio, Rows, COUNT_OF(Rows), reloadConfirm, NULL); + confirmDialog(studio, Rows, COUNT_OF(Rows), reloadConfirm, NULL); } else console->updateProject(console); } @@ -2088,7 +2088,7 @@ static void renderStudio(Studio* studio) tic_api_cls(tic, 0); } } - + switch(studio->mode) { case TIC_START_MODE: studio->start->tick(studio->start); break; @@ -2097,16 +2097,16 @@ static void renderStudio(Studio* studio) #if defined(BUILD_EDITORS) case TIC_CONSOLE_MODE: studio->console->tick(studio->console); break; - case TIC_CODE_MODE: + case TIC_CODE_MODE: { Code* code = studio->code; code->tick(code); } break; - case TIC_SPRITE_MODE: + case TIC_SPRITE_MODE: { Sprite* sprite = studio->banks.sprite[studio->bank.index.sprites]; - sprite->tick(sprite); + sprite->tick(sprite); } break; case TIC_MAP_MODE: @@ -2165,13 +2165,13 @@ static void updateSystemFont(Studio* studio) }, }, }, - .alt = + .alt = { { 0 }, { { .width = TIC_ALTFONT_WIDTH, - .height = TIC_FONT_HEIGHT, + .height = TIC_FONT_HEIGHT, }, }, } @@ -2268,7 +2268,7 @@ static void doCodeExport(Studio* studio) fwrite(pos, 1, strlen(pos), file); fwrite(studio->code->src, 1, strlen(studio->code->src), file); fclose(file); - } + } } } @@ -2383,7 +2383,7 @@ void studio_tick(Studio* studio, tic80_input input) checkChanges(studio); tic_net_start(studio->net); #endif - + if(studio->toolbarMode) { setStudioMode(studio, studio->toolbarMode); @@ -2392,14 +2392,14 @@ void studio_tick(Studio* studio, tic80_input input) processMouseStates(studio); renderStudio(studio); - + { #if defined(BUILD_EDITORS) Sprite* sprite = studio->banks.sprite[studio->bank.index.sprites]; Map* map = studio->banks.map[studio->bank.index.map]; #endif - tic_blit_callback callback[TIC_MODES_COUNT] = + tic_blit_callback callback[TIC_MODES_COUNT] = { [TIC_MENU_MODE] = {studio_menu_anim_scanline, NULL, NULL, studio->menu}, @@ -2478,7 +2478,7 @@ void studio_sound(Studio* studio) { s32 size = tic->product.samples.count; for(s16* it = tic->product.samples.buffer, *end = it + size; it != end; ++it) - *it = *it * volume / MAX_VOLUME; + *it = *it * volume / MAX_VOLUME; } } @@ -2488,9 +2488,9 @@ static void onStudioLoadConfirmed(Studio* studio, bool yes, void* data) if(yes) { const char* file = data; - showPopupMessage(studio, studio->console->loadCart(studio->console, file) + showPopupMessage(studio, studio->console->loadCart(studio->console, file) ? "cart successfully loaded :)" - : "error: cart not loaded :("); + : "error: cart not loaded :("); } } @@ -2581,7 +2581,7 @@ Bytebattle* getBytebattle(Studio* studio) static StartArgs parseArgs(s32 argc, char **argv) { - static const char *const usage[] = + static const char *const usage[] = { "tic80 [cart] [options]", NULL, @@ -2596,7 +2596,7 @@ static StartArgs parseArgs(s32 argc, char **argv) args.fftlist = 0; #endif - struct argparse_option options[] = + struct argparse_option options[] = { OPT_HELP(), #define CMD_PARAMS_DEF(name, ctype, type, post, help) OPT_##type('\0', #name, &args.name, help), @@ -2688,7 +2688,7 @@ Studio* studio_create(s32 argc, char **argv, s32 samplerate, tic80_pixel_color_f setbuf(stdout, NULL); StartArgs args = parseArgs(argc, argv); - + if (args.version) { printf("%s\n", TIC_VERSION); @@ -2709,14 +2709,14 @@ Studio* studio_create(s32 argc, char **argv, s32 samplerate, tic80_pixel_color_f #if defined(BUILD_EDITORS) .menuMode = TIC_CONSOLE_MODE, - .bank = + .bank = { .chained = true, }, - .anim = + .anim = { - .pos = + .pos = { .popup = -TOOLBAR_SIZE, }, @@ -2746,7 +2746,7 @@ Studio* studio_create(s32 argc, char **argv, s32 samplerate, tic80_pixel_color_f if (fs_exists(path)) { - studio->fs = tic_fs_create(path, + studio->fs = tic_fs_create(path, #if defined(BUILD_EDITORS) studio->net #else @@ -2799,7 +2799,7 @@ Studio* studio_create(s32 argc, char **argv, s32 samplerate, tic80_pixel_color_f studio->mainmenu = NULL; tic_fs_makedir(studio->fs, TIC_LOCAL); tic_fs_makedir(studio->fs, TIC_LOCAL_VERSION); - + initConfig(studio->config, studio, studio->fs); if (studio->config->data.uiScale > maxscale) @@ -2842,11 +2842,11 @@ Studio* studio_create(s32 argc, char **argv, s32 samplerate, tic80_pixel_color_f studio->bytebattle.limit.lower = args.lowerlimit; studio->bytebattle.limit.current - = studio->bytebattle.limit.upper + = studio->bytebattle.limit.upper = args.upperlimit; - studio->bytebattle.battle.left - = studio->bytebattle.battle.time + studio->bytebattle.battle.left + = studio->bytebattle.battle.time = args.battletime * 60 * 1000; if (args.fftlist) @@ -2870,7 +2870,7 @@ Studio* studio_create(s32 argc, char **argv, s32 samplerate, tic80_pixel_color_f if(getBytebattle(studio)) { studio->console->tick(studio->console); - gotoCode(studio); + gotoCode(studio); } else setStudioMode(studio, TIC_CONSOLE_MODE); diff --git a/src/studio/system.h b/src/studio/system.h index a1ba3a81e..bd930e19c 100644 --- a/src/studio/system.h +++ b/src/studio/system.h @@ -131,7 +131,7 @@ typedef struct #if defined(CRT_SHADER_SUPPORT) bool crt; #endif - + bool fullscreen; bool vsync; bool integerScale; diff --git a/src/system/baremetalpi/customchargenerator.cpp b/src/system/baremetalpi/customchargenerator.cpp index 7138144b7..7ad0914c5 100644 --- a/src/system/baremetalpi/customchargenerator.cpp +++ b/src/system/baremetalpi/customchargenerator.cpp @@ -1,9 +1,9 @@ -#include -#include -#include "customfont.h" +#include +#include +#include "customfont.h" -#define FIRSTCHAR 0x00 -#define LASTCHAR 0xFF +#define FIRSTCHAR 0x00 +#define LASTCHAR 0xFF #define CHARCOUNT (LASTCHAR - FIRSTCHAR + 1) CCharGenerator::CCharGenerator (void) : m_nCharWidth (width) diff --git a/src/system/baremetalpi/customchargenerator.h b/src/system/baremetalpi/customchargenerator.h index 0f22c673e..8ed335bc0 100644 --- a/src/system/baremetalpi/customchargenerator.h +++ b/src/system/baremetalpi/customchargenerator.h @@ -3,7 +3,7 @@ // // Circle - A C++ bare metal environment for Raspberry Pi // Copyright (C) 2014 R. Stange -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or @@ -31,7 +31,7 @@ class CCharGenerator unsigned GetCharWidth (void) const; unsigned GetCharHeight (void) const; unsigned GetUnderline (void) const; - + boolean GetPixel (char chAscii, unsigned nPosX, unsigned nPosY) const; private: diff --git a/src/system/baremetalpi/customscreen.cpp b/src/system/baremetalpi/customscreen.cpp index 6974fe6a4..79f083ab4 100644 --- a/src/system/baremetalpi/customscreen.cpp +++ b/src/system/baremetalpi/customscreen.cpp @@ -3,7 +3,7 @@ // // Circle - A C++ bare metal environment for Raspberry Pi // Copyright (C) 2014-2018 R. Stange -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or @@ -64,7 +64,7 @@ CScreenDevice::~CScreenDevice (void) delete [] m_pBuffer; } m_pBuffer = 0; - + delete m_pFrameBuffer; m_pFrameBuffer = 0; } @@ -212,21 +212,21 @@ int CScreenDevice::Write (const void *pBuffer, size_t nCount) m_SpinLock.Acquire (); m_bUpdated = TRUE; - + InvertCursor (); - + const char *pChar = (const char *) pBuffer; int nResult = 0; while (nCount--) { Write (*pChar++); - + nResult++; } InvertCursor (); - + m_bUpdated = FALSE; m_SpinLock.Release (); @@ -393,7 +393,7 @@ void CScreenDevice::Write (char chChar) } m_nState = ScreenStateStart; break; - + case 'm': SetStandoutMode (m_nParam1); m_nState = ScreenStateStart; @@ -519,13 +519,13 @@ void CScreenDevice::CarriageReturn (void) void CScreenDevice::ClearDisplayEnd (void) { ClearLineEnd (); - + unsigned nPosY = m_nCursorY + m_CharGen.GetCharHeight (); unsigned nOffset = nPosY * m_nPitch; - + TScreenColor *pBuffer = m_pBuffer + nOffset; unsigned nSize = m_nSize / sizeof (TScreenColor) - nOffset; - + while (nSize--) { *pBuffer++ = BLACK_COLOR; @@ -615,7 +615,7 @@ void CScreenDevice::DeleteLines (unsigned nCount) // TODO void CScreenDevice::DisplayChar (char chChar) { // TODO: Insert mode - + if (' ' <= (unsigned char) chChar) { DisplayChar (chChar, m_nCursorX, m_nCursorY, m_Color); @@ -699,7 +699,7 @@ void CScreenDevice::SetStandoutMode (unsigned nMode) case 27: m_Color = NORMAL_COLOR; break; - + case 1: m_Color = HIGH_COLOR; break; @@ -717,7 +717,7 @@ void CScreenDevice::SetStandoutMode (unsigned nMode) void CScreenDevice::Tabulator (void) { unsigned nTabWidth = m_CharGen.GetCharWidth () * 8; - + m_nCursorX = ((m_nCursorX + nTabWidth) / nTabWidth) * nTabWidth; if (m_nCursorX >= m_nWidth) { @@ -780,7 +780,7 @@ void CScreenDevice::InvertCursor (void) { return; } - + for (unsigned y = m_CharGen.GetUnderline (); y < m_CharGen.GetCharHeight (); y++) { for (unsigned x = 0; x < m_CharGen.GetCharWidth (); x++) @@ -813,7 +813,7 @@ TScreenColor CScreenDevice::GetPixel (unsigned nPosX, unsigned nPosY) { return m_pBuffer[m_nPitch * nPosY + nPosX]; } - + return BLACK_COLOR; } diff --git a/src/system/baremetalpi/customscreen.h b/src/system/baremetalpi/customscreen.h index 2c558e9ea..a9e16dc58 100644 --- a/src/system/baremetalpi/customscreen.h +++ b/src/system/baremetalpi/customscreen.h @@ -3,7 +3,7 @@ // // Circle - A C++ bare metal environment for Raspberry Pi // Copyright (C) 2014-2018 R. Stange -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or diff --git a/src/system/baremetalpi/kernel.cpp b/src/system/baremetalpi/kernel.cpp index abc181b8c..3cbff12c0 100644 --- a/src/system/baremetalpi/kernel.cpp +++ b/src/system/baremetalpi/kernel.cpp @@ -1,6 +1,6 @@ // // kernel.cpp -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or @@ -208,7 +208,7 @@ void gamePadStatusHandler (unsigned nDeviceIndex, const TGamePadState *pState) { keyspinlock.Acquire(); - // Just copy buttons and axes. + // Just copy buttons and axes. gamepad.buttons = pState -> buttons; gamepad.naxes = pState -> naxes; for (int i = 0; i< pState->naxes; i++) diff --git a/src/system/baremetalpi/keycodes.h b/src/system/baremetalpi/keycodes.h index 20bf7a347..d9a8836ed 100644 --- a/src/system/baremetalpi/keycodes.h +++ b/src/system/baremetalpi/keycodes.h @@ -2,7 +2,7 @@ // derived from keymap_it -static const tic_keycode TicKeyboardCodes[256] = +static const tic_keycode TicKeyboardCodes[256] = { tic_key_unknown, // KeyNone, 0x00 tic_key_unknown, // KeyNone, 0x01 @@ -53,8 +53,8 @@ tic_key_apostrophe, // '\'', 0x2D tic_key_unknown, // C('?'), 0x2E -- ^ tic_key_leftbracket, // C('?'), 0x2F -- [ tic_key_rightbracket, // '+', 0x30 -- ] -tic_key_unknown, // C('?'), 0x31 -tic_key_unknown, // C('?'), 0x32 +tic_key_unknown, // C('?'), 0x31 +tic_key_unknown, // C('?'), 0x32 tic_key_unknown, // C('?'), 0x33 -- @ tic_key_unknown, // C('?'), 0x34 -- # tic_key_backslash, // '\\', 0x35 diff --git a/src/system/baremetalpi/syscore.h b/src/system/baremetalpi/syscore.h index fc5f23bfb..b75e1e89f 100644 --- a/src/system/baremetalpi/syscore.h +++ b/src/system/baremetalpi/syscore.h @@ -198,7 +198,7 @@ boolean initializeCore() //dbg("Memory: %p\n", &mMemory); //dbg("Snd: %p\n", &mVCHIQSound); - + dbg("Creating tic80 instance..\n"); diff --git a/src/system/baremetalpi/utils.cpp b/src/system/baremetalpi/utils.cpp index 0ca944ce5..3740ae0b6 100644 --- a/src/system/baremetalpi/utils.cpp +++ b/src/system/baremetalpi/utils.cpp @@ -8,7 +8,7 @@ extern "C" { // this functions are absent for circle-stdlib for some reason // (maybe i can't link properly). Since they shouldn't be used -// too much, i'll put some stub here. Chmod is ok since we're on +// too much, i'll put some stub here. Chmod is ok since we're on // fat anyway, symlink won't work either. ftruncate could break // something diff --git a/src/system/libretro/libretro-common/include/libretro.h b/src/system/libretro/libretro-common/include/libretro.h index 3144aeccd..6999033e2 100644 --- a/src/system/libretro/libretro-common/include/libretro.h +++ b/src/system/libretro/libretro-common/include/libretro.h @@ -3196,13 +3196,13 @@ enum retro_savestate_context /* Savestate where you are guaranteed that the same instance will load the save state. * You can store internal pointers to code or data. - * It's still a full serialization and deserialization, and could be loaded or saved at any time. + * It's still a full serialization and deserialization, and could be loaded or saved at any time. * It won't be written to disk or sent over the network. */ RETRO_SAVESTATE_CONTEXT_RUNAHEAD_SAME_INSTANCE = 1, /* Savestate where you are guaranteed that the same emulator binary will load that savestate. - * You can skip anything that would slow down saving or loading state but you can not store internal pointers. + * You can skip anything that would slow down saving or loading state but you can not store internal pointers. * It won't be written to disk or sent over the network. * Example: "Second Instance" runahead */ diff --git a/src/system/libretro/tic80_libretro.c b/src/system/libretro/tic80_libretro.c index 0239d5608..144629021 100644 --- a/src/system/libretro/tic80_libretro.c +++ b/src/system/libretro/tic80_libretro.c @@ -1182,7 +1182,7 @@ RETRO_API bool retro_unserialize(const void *data, size_t size) /** * libretro callback; Gets region of memory. - * + * * https://github.com/nesbox/TIC-80/wiki/ram */ RETRO_API void *retro_get_memory_data(unsigned id) diff --git a/src/system/n3ds/keyboard.c b/src/system/n3ds/keyboard.c index 2eb618096..5b00ee99b 100644 --- a/src/system/n3ds/keyboard.c +++ b/src/system/n3ds/keyboard.c @@ -254,7 +254,7 @@ void n3ds_keyboard_update(tic_n3ds_keyboard *kbd, tic80_input* input) { if (changed) { // apply to TIC-80 kbd->render_dirty = true; - + tic_kbd->data = 0; int buffer_pos = 0; for(i = 0; i < kbd->kd_count && buffer_pos < TIC80_KEY_BUFFER; i++) @@ -299,8 +299,8 @@ void n3ds_gamepad_update(tic_n3ds_keyboard *kbd, tic80_input* input) { // mouse scroll tic_mouse->scrollx = 0; tic_mouse->scrolly = 0; - - if (curr_clock >= kbd->scroll_debounce) { + + if (curr_clock >= kbd->scroll_debounce) { if(key_held & KEY_CSTICK_UP) tic_mouse->scrolly = 1; else if(key_held & KEY_CSTICK_DOWN) diff --git a/src/system/n3ds/utils.c b/src/system/n3ds/utils.c index b8359191b..1764859bf 100644 --- a/src/system/n3ds/utils.c +++ b/src/system/n3ds/utils.c @@ -50,16 +50,16 @@ bool ctr_load_png(C3D_Tex* tex, const char* name, texture_location loc) if (!png_image_begin_read_from_file(&img, name)) { return false; } - + img.format = PNG_FORMAT_ABGR; - + if (loc == TEXTURE_TARGET_VRAM) { C3D_TexInitVRAM(tex, npot(img.width), npot(img.height), GPU_RGBA8); } else { C3D_TexInit(tex, npot(img.width), npot(img.height), GPU_RGBA8); } data = linearAlloc(tex->width * tex->height * sizeof(u32)); - + if (!png_image_finish_read(&img, NULL, data, tex->width * sizeof(u32), NULL)) { linearFree(data); C3D_TexDelete(tex); diff --git a/src/system/sdl/main.c b/src/system/sdl/main.c index fc0f1f9af..3b0eaa7b9 100644 --- a/src/system/sdl/main.c +++ b/src/system/sdl/main.c @@ -72,7 +72,7 @@ #define LOCK_MUTEX(MUTEX) SDL_LockMutex(MUTEX); SCOPE(SDL_UnlockMutex(MUTEX)) -enum +enum { tic_key_board = tic_keys_count + 1, tic_touch_size, @@ -193,7 +193,7 @@ static struct } audioIn; } platform #if defined(TOUCH_INPUT_SUPPORT) -= += { .gamepad.touch.counter = TOUCH_TIMEOUT, .keyboard.touch.useText = false, @@ -302,7 +302,7 @@ static void audioCallback(void* userdata, u8* stream, s32 len) } *stream++ = ((u8*)tic->product.samples.buffer)[tic->product.samples.count * TIC80_SAMPLESIZE - platform.audio.bufferRemaining--]; - } + } } } @@ -358,7 +358,7 @@ static void setWindowIcon() SDL_Surface* surface = SDL_CreateRGBSurfaceFrom(pixels, Size, Size, sizeof(s32) * BITS_IN_BYTE, Size * sizeof(s32), 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000); - + SCOPE(SDL_FreeSurface(surface)) { SDL_SetWindowIcon(platform.window, surface); @@ -426,7 +426,7 @@ static void initTouchKeyboardState(tic_mem* tic, Texture* texture, void** pixels { texture->gpu = GPU_CreateImage(TIC80_FULLWIDTH, TIC80_FULLHEIGHT, GPU_FORMAT_RGBA); GPU_SetAnchor(texture->gpu, 0, 0); - GPU_SetImageFilter(texture->gpu, GPU_FILTER_NEAREST); + GPU_SetImageFilter(texture->gpu, GPU_FILTER_NEAREST); } else #endif @@ -440,7 +440,7 @@ static void initTouchKeyboardState(tic_mem* tic, Texture* texture, void** pixels static void initTouchKeyboard() { tic_mem *tic = tic_core_create(TIC80_SAMPLERATE, SCREEN_FORMAT); - + SCOPE(tic_core_close(tic)) { memcpy(tic->ram->vram.palette.data, studio_config(platform.studio)->cart->bank0.palette.vbank0.data, sizeof(tic_palette)); @@ -450,7 +450,7 @@ static void initTouchKeyboard() initTouchKeyboardState(tic, &platform.keyboard.touch.texture.up, &platform.keyboard.touch.texture.upPixels, false); initTouchKeyboardState(tic, &platform.keyboard.touch.texture.down, &platform.keyboard.touch.texture.downPixels, true); - memset(tic->ram->map.data, 0, sizeof tic->ram->map); + memset(tic->ram->map.data, 0, sizeof tic->ram->map); } } @@ -492,7 +492,7 @@ static void initTouchGamepad() if(!platform.gamepad.touch.pixels) { tic_mem* tic = tic_core_create(TIC80_SAMPLERATE, SCREEN_FORMAT); - + SCOPE(tic_core_close(tic)) { const tic_bank* bank = &studio_config(platform.studio)->cart->bank0; @@ -526,15 +526,15 @@ static void initTouchGamepad() platform.gamepad.touch.texture.gpu = GPU_CreateImage(TEXTURE_SIZE, TEXTURE_SIZE, GPU_FORMAT_RGBA); GPU_SetAnchor(platform.gamepad.touch.texture.gpu, 0, 0); GPU_SetImageFilter(platform.gamepad.touch.texture.gpu, GPU_FILTER_NEAREST); - GPU_SetRGBA(platform.gamepad.touch.texture.gpu, 0xff, 0xff, 0xff, studio_config(platform.studio)->theme.gamepad.touch.alpha); + GPU_SetRGBA(platform.gamepad.touch.texture.gpu, 0xff, 0xff, 0xff, studio_config(platform.studio)->theme.gamepad.touch.alpha); } else #endif { - platform.gamepad.touch.texture.sdl = SDL_CreateTexture(platform.screen.renderer.sdl, SDL_PIXELFORMAT_ABGR8888, + platform.gamepad.touch.texture.sdl = SDL_CreateTexture(platform.screen.renderer.sdl, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STREAMING, TEXTURE_SIZE, TEXTURE_SIZE); SDL_SetTextureBlendMode(platform.gamepad.touch.texture.sdl, SDL_BLENDMODE_BLEND); - SDL_SetTextureAlphaMod(platform.gamepad.touch.texture.sdl, studio_config(platform.studio)->theme.gamepad.touch.alpha); + SDL_SetTextureAlphaMod(platform.gamepad.touch.texture.sdl, studio_config(platform.studio)->theme.gamepad.touch.alpha); } updateTextureBytes(platform.gamepad.touch.texture, platform.gamepad.touch.pixels, TEXTURE_SIZE, TEXTURE_SIZE); @@ -570,7 +570,7 @@ static void initGPU() else #endif { - platform.screen.renderer.sdl = SDL_CreateRenderer(platform.window, -1, + platform.screen.renderer.sdl = SDL_CreateRenderer(platform.window, -1, #if defined(CRT_SHADER_SUPPORT) SDL_RENDERER_SOFTWARE #else @@ -579,7 +579,7 @@ static void initGPU() | (!soft && vsync ? SDL_RENDERER_PRESENTVSYNC : 0) ); - platform.screen.texture.sdl = SDL_CreateTexture(platform.screen.renderer.sdl, SDL_PIXELFORMAT_ABGR8888, + platform.screen.texture.sdl = SDL_CreateTexture(platform.screen.renderer.sdl, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STREAMING, TIC80_FULLWIDTH, TIC80_FULLHEIGHT); } @@ -619,7 +619,7 @@ static void destroyGPU() platform.screen.shader = 0; } - GPU_Quit(); + GPU_Quit(); } #endif @@ -647,12 +647,12 @@ static void calcTextureRect(SDL_Rect* rect) *rect = (SDL_Rect) { - (sw - w) / 2, + (sw - w) / 2, #if defined (TOUCH_INPUT_SUPPORT) // snap the screen up to get a place for the software keyboard sw > sh ? (sh - h) / 2 : 0, #else - (sh - h) / 2, + (sh - h) / 2, #endif w, h }; @@ -697,7 +697,7 @@ static void processMouse() } } - { + { input->mouse.left = mb & SDL_BUTTON_LMASK ? 1 : 0; input->mouse.middle = mb & SDL_BUTTON_MMASK ? 1 : 0; input->mouse.right = mb & SDL_BUTTON_RMASK ? 1 : 0; @@ -719,10 +719,10 @@ static void processKeyboard() // it's weird, but system sends CTRL when you press RALT if(mod & KMOD_RALT) platform.keyboard.state[tic_key_ctrl] = false; - } + } for(s32 i = 0, c = 0; i < COUNT_OF(platform.keyboard.state) && c < TIC80_KEY_BUFFER; i++) - if(platform.keyboard.state[i] + if(platform.keyboard.state[i] // Some programmable keyboards will send key down and up events immediately. // If the key was pressed and released in the same frame, report it as // down for this frame so that it isn't missed. Lying about the key being @@ -808,7 +808,7 @@ static bool isKbdVisible() ; } -static const tic_key KbdLayout[] = +static const tic_key KbdLayout[] = { #include "kbdlayout.inl" }; @@ -938,7 +938,7 @@ static u8 getAxis(SDL_GameController* controller, SDL_GameControllerAxis axis, s static u8 getButton(SDL_GameController* controller, SDL_GameControllerButton button) { return SDL_GameControllerHasButton(controller, button) - ? SDL_GameControllerGetButton(controller, button) + ? SDL_GameControllerGetButton(controller, button) : 0; } @@ -966,19 +966,19 @@ static void processGamepad() if(gamepad) { - gamepad->up = getAxis(controller, SDL_CONTROLLER_AXIS_LEFTY, -1) + gamepad->up = getAxis(controller, SDL_CONTROLLER_AXIS_LEFTY, -1) || getAxis(controller, SDL_CONTROLLER_AXIS_RIGHTY, -1) || getButton(controller, SDL_CONTROLLER_BUTTON_DPAD_UP); - gamepad->down = getAxis(controller, SDL_CONTROLLER_AXIS_LEFTY, +1) + gamepad->down = getAxis(controller, SDL_CONTROLLER_AXIS_LEFTY, +1) || getAxis(controller, SDL_CONTROLLER_AXIS_RIGHTY, +1) || getButton(controller, SDL_CONTROLLER_BUTTON_DPAD_DOWN); - gamepad->left = getAxis(controller, SDL_CONTROLLER_AXIS_LEFTX, -1) + gamepad->left = getAxis(controller, SDL_CONTROLLER_AXIS_LEFTX, -1) || getAxis(controller, SDL_CONTROLLER_AXIS_RIGHTX, -1) || getButton(controller, SDL_CONTROLLER_BUTTON_DPAD_LEFT); - gamepad->right = getAxis(controller, SDL_CONTROLLER_AXIS_LEFTX, +1) + gamepad->right = getAxis(controller, SDL_CONTROLLER_AXIS_LEFTX, +1) || getAxis(controller, SDL_CONTROLLER_AXIS_RIGHTX, +1) || getButton(controller, SDL_CONTROLLER_BUTTON_DPAD_RIGHT); @@ -1009,7 +1009,7 @@ static void processGamepad() #if defined(TOUCH_INPUT_SUPPORT) input->gamepads.data |= platform.gamepad.touch.joystick.data; -#endif +#endif input->gamepads.data |= platform.gamepad.joystick.data; } } @@ -1018,7 +1018,7 @@ static void processGamepad() static void processTouchInput() { s32 devices = SDL_GetNumTouchDevices(); - + for (s32 i = 0; i < devices; i++) if(SDL_GetNumTouchFingers(SDL_GetTouchDevice(i)) > 0) { @@ -1033,7 +1033,7 @@ static void processTouchInput() } #endif -static const u32 KeyboardCodes[tic_keys_count] = +static const u32 KeyboardCodes[tic_keys_count] = { #include "keycodes.inl" }; @@ -1068,7 +1068,7 @@ static void pollEvents() { const tic_mem* tic = studio_mem(platform.studio); if((bool)tic->ram->input.mouse.relative != (bool)SDL_GetRelativeMouseMode()) - SDL_SetRelativeMouseMode(tic->ram->input.mouse.relative ? SDL_TRUE : SDL_FALSE); + SDL_SetRelativeMouseMode(tic->ram->input.mouse.relative ? SDL_TRUE : SDL_FALSE); } ZEROMEM(platform.input); @@ -1165,11 +1165,11 @@ static void pollEvents() #if defined(TOUCH_INPUT_SUPPORT) updateGamepadParts(); -#endif +#endif } break; #if defined(__LINUX__) - case SDL_WINDOWEVENT_FOCUS_GAINED: + case SDL_WINDOWEVENT_FOCUS_GAINED: // lock input for 10 ticks lockInput = 10; break; @@ -1264,19 +1264,19 @@ static void renderKeyboard() { if(key == KbdLayout[k]) { - SDL_Rect src2 = + SDL_Rect src2 = { - (k % Cols) * TIC_SPRITESIZE + TIC80_OFFSET_LEFT, - (k / Cols) * TIC_SPRITESIZE + TIC80_OFFSET_TOP, - TIC_SPRITESIZE, + (k % Cols) * TIC_SPRITESIZE + TIC80_OFFSET_LEFT, + (k / Cols) * TIC_SPRITESIZE + TIC80_OFFSET_TOP, + TIC_SPRITESIZE, TIC_SPRITESIZE, }; - SDL_Rect dst2 = + SDL_Rect dst2 = { - (src2.x - TIC80_OFFSET_LEFT) * rect.w/src.w, - (src2.y - TIC80_OFFSET_TOP) * rect.w/src.w + dst.y, - TIC_SPRITESIZE * rect.w/src.w, + (src2.x - TIC80_OFFSET_LEFT) * rect.w/src.w, + (src2.y - TIC80_OFFSET_TOP) * rect.w/src.w + dst.y, + TIC_SPRITESIZE * rect.w/src.w, TIC_SPRITESIZE * rect.w/src.w, }; @@ -1402,7 +1402,7 @@ bool tic_sys_fullscreen_get() else #endif { - return SDL_GetWindowFlags(platform.window) & SDL_WINDOW_FULLSCREEN_DESKTOP + return SDL_GetWindowFlags(platform.window) & SDL_WINDOW_FULLSCREEN_DESKTOP ? true : false; } } @@ -1417,7 +1417,7 @@ void tic_sys_fullscreen_set(bool value) else #endif { - SDL_SetWindowFullscreen(platform.window, + SDL_SetWindowFullscreen(platform.window, value ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); } } @@ -1486,7 +1486,7 @@ void tic_sys_preseed() static void loadCrtShader() { - static const char VertextShader[] = + static const char VertextShader[] = #if !defined (EMSCRIPTEN) "#version 110" "\n" #endif @@ -1504,7 +1504,7 @@ static void loadCrtShader() "}" "\n" ; - static const char PixelShader[] = + static const char PixelShader[] = #if !defined (EMSCRIPTEN) "#version 110" "\n" #else @@ -1640,7 +1640,7 @@ static void loadCrtShader() ; u32 vertex = GPU_CompileShader(GPU_VERTEX_SHADER, VertextShader); - + if(!vertex) { printf("Failed to load vertex shader: %s\n", GPU_GetShaderMessage()); @@ -1648,18 +1648,18 @@ static void loadCrtShader() } u32 pixel = GPU_CompileShader(GPU_PIXEL_SHADER, PixelShader); - + if(!pixel) { printf("Failed to load pixel shader: %s\n", GPU_GetShaderMessage()); return; } - + if(platform.screen.shader) GPU_FreeShaderProgram(platform.screen.shader); platform.screen.shader = GPU_LinkShaders(vertex, pixel); - + if(platform.screen.shader) { platform.screen.block = GPU_LoadShaderBlock(platform.screen.shader, "gpu_Vertex", "gpu_TexCoord", "gpu_Color", "gpu_ModelViewProjectionMatrix"); @@ -1682,7 +1682,7 @@ void tic_sys_update_config() void tic_sys_default_mapping(tic_mapping* mapping) { - static const SDL_Scancode Scancodes[] = + static const SDL_Scancode Scancodes[] = { SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, @@ -1760,10 +1760,10 @@ static void gpuTick() s32 w, h; SDL_GetWindowSize(platform.window, &w, &h); - s32 offset = tic->ram->input.mouse.x < TIC80_FULLHEIGHT / 2 + s32 offset = tic->ram->input.mouse.x < TIC80_FULLHEIGHT / 2 ? TIC80_FULLWIDTH-TIC80_OFFSET_LEFT : 0; - const SDL_Rect Src[] = + const SDL_Rect Src[] = { {offset, 0, TIC80_OFFSET_LEFT, TIC80_OFFSET_TOP}, // top border {offset, TIC80_FULLHEIGHT-TIC80_OFFSET_TOP, TIC80_OFFSET_LEFT, TIC80_OFFSET_TOP}, // bottom border @@ -1772,7 +1772,7 @@ static void gpuTick() {0, 0, TIC80_FULLWIDTH, TIC80_FULLHEIGHT}, // center }; - const SDL_Rect Dst[] = + const SDL_Rect Dst[] = { {0, 0, w, rect.y}, // top border {0, rect.y + rect.h, w, h - (rect.y + rect.h)}, // bottom border @@ -1911,7 +1911,7 @@ static s32 start(s32 argc, char **argv, const char* folder) const s32 Width = TIC80_FULLWIDTH * studio_config(platform.studio)->uiScale; const s32 Height = TIC80_FULLHEIGHT * studio_config(platform.studio)->uiScale; - s32 flags = SDL_WINDOW_SHOWN + s32 flags = SDL_WINDOW_SHOWN #if !defined(__EMSCRIPTEN__) && !defined(__MACOSX__) | SDL_WINDOW_ALLOW_HIGHDPI #endif @@ -1921,7 +1921,7 @@ static s32 start(s32 argc, char **argv, const char* folder) if(!studio_config(platform.studio)->soft) flags |= SDL_WINDOW_OPENGL; -#endif +#endif platform.window = SDL_CreateWindow(TIC_TITLE, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Width, Height, flags); @@ -1972,7 +1972,7 @@ static s32 start(s32 argc, char **argv, const char* folder) if(platform.keyboard.touch.texture.downPixels) SDL_free(platform.keyboard.touch.texture.downPixels); -#endif +#endif SDL_DestroyWindow(platform.window); SDL_CloseAudioDevice(platform.audio.device); @@ -2035,7 +2035,7 @@ static s32 emsStart(s32 argc, char **argv, const char* folder) Module.filePreloaded = false; - FS.createPreloadedFile(dir, PATH.basename(file), UTF8ToString($3), true, true, + FS.createPreloadedFile(dir, PATH.basename(file), UTF8ToString($3), true, true, function() { Module.filePreloaded = true; @@ -2081,7 +2081,7 @@ s32 main(s32 argc, char **argv) Module.syncFSRequests = 0; var dir = UTF8ToString($0); - + FS.mkdirTree(dir); FS.mount(IDBFS, {}, dir); @@ -2096,7 +2096,7 @@ s32 main(s32 argc, char **argv) #else return start(argc, argv, folder); - + #endif } diff --git a/src/system/sdl/player.c b/src/system/sdl/player.c index bb3702f88..d9d765532 100644 --- a/src/system/sdl/player.c +++ b/src/system/sdl/player.c @@ -73,7 +73,7 @@ static void audioCallback(void* userdata, u8* stream, s32 len) } *stream++ = ((u8*)tic->samples.buffer)[tic->samples.count * TIC80_SAMPLESIZE - state.remaining--]; - } + } } SDL_UnlockMutex(state.mutex); } @@ -94,7 +94,7 @@ s32 runCart(void* cart, s32 size) fprintf(stderr, "Failed to load cart data."); output = 1; } - else + else { SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO); @@ -124,7 +124,7 @@ s32 runCart(void* cart, s32 size) u64 nextTick = SDL_GetPerformanceCounter(); SDL_PauseAudioDevice(audioDevice, 0); - + while(!state.quit) { SDL_Event event; diff --git a/src/tic.h b/src/tic.h index de8ba0dcd..27b63fdb2 100644 --- a/src/tic.h +++ b/src/tic.h @@ -175,7 +175,7 @@ typedef struct typedef struct { - + struct { #if RETRO_IS_BIG_ENDIAN @@ -353,7 +353,7 @@ typedef struct s8 frame; s8 row; } music; - + struct { #if RETRO_IS_BIG_ENDIAN @@ -607,7 +607,7 @@ typedef union u8 reserved[3]; }; - + u8 data[TIC_VRAM_SIZE]; } tic_vram; @@ -707,7 +707,7 @@ typedef enum tic_key_comma, tic_key_period, tic_key_slash, - + tic_key_space, tic_key_tab, diff --git a/src/tic_assert.h b/src/tic_assert.h index 0fe5a0201..ba522db64 100644 --- a/src/tic_assert.h +++ b/src/tic_assert.h @@ -4,7 +4,7 @@ #define static_assert _Static_assert #endif -#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5 +#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5 #define static_assert__(x,line) static char stat_ass ## line[(x) ? +1 : -1] #define static_assert_(x,line) static_assert__(x,line) #define static_assert(x,y) static_assert_(x, __LINE__) diff --git a/src/tilesheet.c b/src/tilesheet.c index 5f2602e69..40c7294f1 100644 --- a/src/tilesheet.c +++ b/src/tilesheet.c @@ -26,7 +26,7 @@ #include static const tic_blit_segment segments[] = { - // +page +nb_pages + // +page +nb_pages // | +bank +bank_size // | | | | +sheet_width // | | | | | +tile_width diff --git a/src/tools.c b/src/tools.c index ab15efc4a..bff64277b 100644 --- a/src/tools.c +++ b/src/tools.c @@ -67,7 +67,7 @@ u32 tic_nearest_color(const tic_rgb* palette, const tic_rgb* color, s32 count) { u32 min = -1; s32 nearest, i = 0; - + for(const tic_rgb *rgb = palette, *end = rgb + count; rgb < end; rgb++, i++) { s32 d[] = {color->r - rgb->r, color->g - rgb->g, color->b - rgb->b};