diff --git a/src/code.c b/src/code.c index 8919b4e..9337c8e 100644 --- a/src/code.c +++ b/src/code.c @@ -74,8 +74,8 @@ static void drawCode(Code* code, bool withCursor) u8* colorPointer = code->colorBuffer; - struct { char* start; char* end; } selection = {SDL_min(code->cursor.selection, code->cursor.position), - SDL_max(code->cursor.selection, code->cursor.position)}; + struct { char* start; char* end; } selection = {MIN(code->cursor.selection, code->cursor.position), + MAX(code->cursor.selection, code->cursor.position)}; struct { s32 x; s32 y; char symbol; } cursor = {-1, -1, 0}; @@ -425,8 +425,8 @@ static bool replaceSelection(Code* code) if(sel && sel != pos) { - char* start = SDL_min(sel, pos); - char* end = SDL_max(sel, pos); + char* start = MIN(sel, pos); + char* end = MAX(sel, pos); memmove(start, end, strlen(end) + 1); @@ -525,8 +525,8 @@ static void copyToClipboard(Code* code) if(sel && sel != pos) { - start = SDL_min(sel, pos); - size = SDL_max(sel, pos) - start; + start = MIN(sel, pos); + size = MAX(sel, pos) - start; } else { @@ -534,14 +534,14 @@ static void copyToClipboard(Code* code) size = getNextLine(code) - start; } - char* clipboard = (char*)SDL_malloc(size+1); + char* clipboard = (char*)malloc(size+1); if(clipboard) { memcpy(clipboard, start, size); clipboard[size] = '\0'; - SDL_SetClipboardText(clipboard); - SDL_free(clipboard); + setClipboardText(clipboard); + free(clipboard); } } @@ -554,9 +554,9 @@ static void cutToClipboard(Code* code) static void copyFromClipboard(Code* code) { - if(SDL_HasClipboardText()) + if(hasClipboardText()) { - char* clipboard = SDL_GetClipboardText(); + char* clipboard = getClipboardText(); if(clipboard) { @@ -590,7 +590,7 @@ static void copyFromClipboard(Code* code) parseSyntaxColor(code); } - SDL_free(clipboard); + free(clipboard); } } } @@ -633,8 +633,8 @@ static void doTab(Code* code, bool shift, bool crtl) bool changed = false; if(cursor_selection) { - start = SDL_min(cursor_selection, cursor_position); - end = SDL_max(cursor_selection, cursor_position); + start = MIN(cursor_selection, cursor_position); + end = MAX(cursor_selection, cursor_position); } else { start = end = cursor_position; } @@ -684,8 +684,8 @@ static void setFindMode(Code* code) { if(code->cursor.selection) { - const char* end = SDL_max(code->cursor.position, code->cursor.selection); - const char* start = SDL_min(code->cursor.position, code->cursor.selection); + const char* end = MAX(code->cursor.position, code->cursor.selection); + const char* start = MIN(code->cursor.position, code->cursor.selection); size_t len = end - start; if(len > 0 && len < sizeof code->popup.text - 1) @@ -709,7 +709,8 @@ static int funcCompare(const void* a, const void* b) if(item1->pos == NULL) return 1; if(item2->pos == NULL) return -1; - return SDL_strcasecmp(item1->name, item2->name); + // return SDL_strcasecmp(item1->name, item2->name); + return strcmp(item1->name, item2->name); } static void normalizeScroll(Code* code) @@ -761,8 +762,10 @@ static void initOutlineMode(Code* code) char buffer[STUDIO_TEXT_BUFFER_WIDTH] = {0}; char filter[STUDIO_TEXT_BUFFER_WIDTH] = {0}; - SDL_strlcpy(filter, code->popup.text, sizeof(filter)); - SDL_strlwr(filter); + strncpy(filter, code->popup.text, sizeof(filter)); + + // TODO: uncomment this + // SDL_strlwr(filter); const tic_script_config* config = tic->api.get_script_config(tic); @@ -779,12 +782,14 @@ static void initOutlineMode(Code* code) { out->pos = code->src + item->pos; memset(out->name, 0, STUDIO_TEXT_BUFFER_WIDTH); - memcpy(out->name, out->pos, SDL_min(item->size, STUDIO_TEXT_BUFFER_WIDTH-1)); + memcpy(out->name, out->pos, MIN(item->size, STUDIO_TEXT_BUFFER_WIDTH-1)); if(*filter) { - SDL_strlcpy(buffer, out->name, sizeof(buffer)); - SDL_strlwr(buffer); + strncpy(buffer, out->name, sizeof(buffer)); + + // TODO: uncomment this + // SDL_strlwr(buffer); if(strstr(buffer, filter)) out++; else out->pos = NULL; @@ -865,106 +870,106 @@ static void commentLine(Code* code) parseSyntaxColor(code); } -static void processKeydown(Code* code, SDL_Keycode keycode) -{ - switch(keycode) - { - case SDLK_LCTRL: - case SDLK_RCTRL: - case SDLK_LSHIFT: - case SDLK_RSHIFT: - case SDLK_LALT: - case SDLK_RALT: - return; - } +// static void processKeydown(Code* code, tic_keycode keycode) +// { +// switch(keycode) +// { +// case SDLK_LCTRL: +// case SDLK_RCTRL: +// case SDLK_LSHIFT: +// case SDLK_RSHIFT: +// case SDLK_LALT: +// case SDLK_RALT: +// return; +// } - switch(getClipboardEvent(keycode)) - { - case TIC_CLIPBOARD_CUT: cutToClipboard(code); break; - case TIC_CLIPBOARD_COPY: copyToClipboard(code); break; - case TIC_CLIPBOARD_PASTE: copyFromClipboard(code); break; - default: break; - } +// switch(getClipboardEvent(keycode)) +// { +// case TIC_CLIPBOARD_CUT: cutToClipboard(code); break; +// case TIC_CLIPBOARD_COPY: copyToClipboard(code); break; +// case TIC_CLIPBOARD_PASTE: copyFromClipboard(code); break; +// default: break; +// } - SDL_Keymod keymod = SDL_GetModState(); +// SDL_Keymod keymod = SDL_GetModState(); - switch(keycode) - { - case SDLK_UP: - case SDLK_DOWN: - case SDLK_LEFT: - case SDLK_RIGHT: - case SDLK_HOME: - case SDLK_END: - case SDLK_PAGEUP: - case SDLK_PAGEDOWN: +// switch(keycode) +// { +// case SDLK_UP: +// case SDLK_DOWN: +// case SDLK_LEFT: +// case SDLK_RIGHT: +// case SDLK_HOME: +// case SDLK_END: +// case SDLK_PAGEUP: +// case SDLK_PAGEDOWN: - if(!(keymod & KMOD_SHIFT)) code->cursor.selection = NULL; - else if(code->cursor.selection == NULL) code->cursor.selection = code->cursor.position; - } +// if(!(keymod & KMOD_SHIFT)) code->cursor.selection = NULL; +// else if(code->cursor.selection == NULL) code->cursor.selection = code->cursor.position; +// } - if(keymod & TIC_MOD_CTRL) - { - if(keymod & KMOD_CTRL) - { - switch(keycode) - { - case SDLK_LEFT: leftWord(code); break; - case SDLK_RIGHT: rightWord(code); break; - case SDLK_TAB: doTab(code, keymod & KMOD_SHIFT, keymod & KMOD_CTRL); break; - } - } - else if(keymod & KMOD_GUI) - { - switch(keycode) - { - case SDLK_LEFT: goHome(code); break; - case SDLK_RIGHT: goEnd(code); break; - } - } +// if(keymod & TIC_MOD_CTRL) +// { +// if(keymod & KMOD_CTRL) +// { +// switch(keycode) +// { +// case SDLK_LEFT: leftWord(code); break; +// case SDLK_RIGHT: rightWord(code); break; +// case SDLK_TAB: doTab(code, keymod & KMOD_SHIFT, keymod & KMOD_CTRL); break; +// } +// } +// else if(keymod & KMOD_GUI) +// { +// switch(keycode) +// { +// case SDLK_LEFT: goHome(code); break; +// case SDLK_RIGHT: goEnd(code); break; +// } +// } - switch(keycode) - { - case SDLK_a: selectAll(code); break; - case SDLK_z: undo(code); break; - case SDLK_y: redo(code); break; - case SDLK_f: setCodeMode(code, TEXT_FIND_MODE); break; - case SDLK_g: setCodeMode(code, TEXT_GOTO_MODE); break; - case SDLK_o: setCodeMode(code, TEXT_OUTLINE_MODE); break; - case SDLK_SLASH: commentLine(code); break; - case SDLK_HOME: goCodeHome(code); break; - case SDLK_END: goCodeEnd(code); break; - } - } - else if(keymod & KMOD_ALT) - { - switch(keycode) - { - case SDLK_LEFT: leftWord(code); break; - case SDLK_RIGHT: rightWord(code); break; - } - } - else - { - switch(keycode) - { - case SDLK_UP: upLine(code); break; - case SDLK_DOWN: downLine(code); break; - case SDLK_LEFT: leftColumn(code); break; - case SDLK_RIGHT: rightColumn(code); break; - case SDLK_HOME: goHome(code); break; - case SDLK_END: goEnd(code); break; - case SDLK_PAGEUP: pageUp(code); break; - case SDLK_PAGEDOWN: pageDown(code); break; - case SDLK_DELETE: deleteChar(code); break; - case SDLK_BACKSPACE: backspaceChar(code); break; - case SDLK_RETURN: newLine(code); break; - case SDLK_TAB: doTab(code, keymod & KMOD_SHIFT, keymod & KMOD_CTRL); break; - } - } +// switch(keycode) +// { +// case SDLK_a: selectAll(code); break; +// case SDLK_z: undo(code); break; +// case SDLK_y: redo(code); break; +// case SDLK_f: setCodeMode(code, TEXT_FIND_MODE); break; +// case SDLK_g: setCodeMode(code, TEXT_GOTO_MODE); break; +// case SDLK_o: setCodeMode(code, TEXT_OUTLINE_MODE); break; +// case SDLK_SLASH: commentLine(code); break; +// case SDLK_HOME: goCodeHome(code); break; +// case SDLK_END: goCodeEnd(code); break; +// } +// } +// else if(keymod & KMOD_ALT) +// { +// switch(keycode) +// { +// case SDLK_LEFT: leftWord(code); break; +// case SDLK_RIGHT: rightWord(code); break; +// } +// } +// else +// { +// switch(keycode) +// { +// case SDLK_UP: upLine(code); break; +// case SDLK_DOWN: downLine(code); break; +// case SDLK_LEFT: leftColumn(code); break; +// case SDLK_RIGHT: rightColumn(code); break; +// case SDLK_HOME: goHome(code); break; +// case SDLK_END: goEnd(code); break; +// case SDLK_PAGEUP: pageUp(code); break; +// case SDLK_PAGEDOWN: pageDown(code); break; +// case SDLK_DELETE: deleteChar(code); break; +// case SDLK_BACKSPACE: backspaceChar(code); break; +// case SDLK_RETURN: newLine(code); break; +// case SDLK_TAB: doTab(code, keymod & KMOD_SHIFT, keymod & KMOD_CTRL); break; +// } +// } - updateEditor(code); -} +// updateEditor(code); +// } static void processGestures(Code* code) { @@ -993,7 +998,7 @@ static void processMouse(Code* code) { if(checkMousePos(&code->rect)) { - setCursor(SDL_SYSTEM_CURSOR_IBEAM); + setCursor(tic_cursor_ibeam); if(code->scroll.active) { @@ -1019,16 +1024,16 @@ static void processMouse(Code* code) char* position = code->cursor.position; setCursorPosition(code, x + code->scroll.x, y + code->scroll.y); - if(SDL_GetModState() & KMOD_SHIFT) - { - code->cursor.selection = code->cursor.position; - code->cursor.position = position; - } - else if(!code->cursor.mouseDownPosition) - { - code->cursor.selection = code->cursor.position; - code->cursor.mouseDownPosition = code->cursor.position; - } + // if(SDL_GetModState() & KMOD_SHIFT) + // { + // code->cursor.selection = code->cursor.position; + // code->cursor.position = position; + // } + // else if(!code->cursor.mouseDownPosition) + // { + // code->cursor.selection = code->cursor.position; + // code->cursor.mouseDownPosition = code->cursor.position; + // } } else { @@ -1163,10 +1168,10 @@ static void textFindTick(Code* code) // case SDLK_RIGHT: // if(*code->popup.text) // { - // SDL_Keycode keycode = event->key.keysym.sym; + // tic_keycode keycode = event->key.keysym.sym; // bool reverse = keycode == SDLK_UP || keycode == SDLK_LEFT; // char* (*func)(const char*, const char*, const char*) = reverse ? upStrStr : downStrStr; - // char* from = reverse ? SDL_min(code->cursor.position, code->cursor.selection) : SDL_max(code->cursor.position, code->cursor.selection); + // char* from = reverse ? MIN(code->cursor.position, code->cursor.selection) : MAX(code->cursor.position, code->cursor.selection); // char* pos = func(code->src, from, code->popup.text); // updateFindCode(code, pos); // } @@ -1285,7 +1290,7 @@ static void drawOutlineBar(Code* code, s32 x, s32 y) if(mx < OUTLINE_SIZE && code->outline.items[mx].pos) { - setCursor(SDL_SYSTEM_CURSOR_HAND); + setCursor(tic_cursor_hand); if(checkMouseDown(&rect, tic_mouse_left)) { @@ -1434,7 +1439,7 @@ static void drawCodeToolbar(Code* code) bool over = false; if(checkMousePos(&rect)) { - setCursor(SDL_SYSTEM_CURSOR_HAND); + setCursor(tic_cursor_hand); showTooltip(Tips[i]); @@ -1516,7 +1521,7 @@ static void onStudioEvent(Code* code, StudioEvent event) void initCode(Code* code, tic_mem* tic, tic_code* src) { if(code->outline.items == NULL) - code->outline.items = (OutlineItem*)SDL_malloc(OUTLINE_ITEMS_SIZE); + code->outline.items = (OutlineItem*)malloc(OUTLINE_ITEMS_SIZE); if(code->history) history_delete(code->history); if(code->cursorHistory) history_delete(code->cursorHistory); diff --git a/src/config.c b/src/config.c index 200b2c3..f09137f 100644 --- a/src/config.c +++ b/src/config.c @@ -228,7 +228,7 @@ static void update(Config* config, const u8* buffer, size_t size) static void setDefault(Config* config) { - SDL_memset(&config->data, 0, sizeof(StudioConfig)); + memset(&config->data, 0, sizeof(StudioConfig)); { static const u8 DefaultBiosZip[] = @@ -243,14 +243,14 @@ static void setDefault(Config* config) { update(config, embedBios, size); - SDL_free(embedBios); + free(embedBios); } } } static void saveConfig(Config* config, bool overwrite) { - u8* buffer = SDL_malloc(sizeof(tic_cartridge)); + u8* buffer = malloc(sizeof(tic_cartridge)); if(buffer) { @@ -258,7 +258,7 @@ static void saveConfig(Config* config, bool overwrite) fsSaveRootFile(config->fs, CONFIG_TIC_PATH, buffer, size, overwrite); - SDL_free(buffer); + free(buffer); } } @@ -270,7 +270,7 @@ static void reset(Config* config) static void save(Config* config) { - SDL_memcpy(&config->tic->config, &config->tic->cart, sizeof(tic_cartridge)); + memcpy(&config->tic->config, &config->tic->cart, sizeof(tic_cartridge)); readConfig(config); saveConfig(config, true); @@ -296,7 +296,7 @@ void initConfig(Config* config, tic_mem* tic, FileSystem* fs) { update(config, data, size); - SDL_free(data); + free(data); } else saveConfig(config, false); diff --git a/src/console.c b/src/console.c index e1a9161..bc5e067 100644 --- a/src/console.c +++ b/src/console.c @@ -29,6 +29,7 @@ #include #include +#include #define CONSOLE_CURSOR_COLOR ((tic_color_red)) #define CONSOLE_BACK_TEXT_COLOR ((tic_color_dark_gray)) @@ -49,7 +50,7 @@ typedef enum WrenScript, } ScriptLang; -#if defined(__WINDOWS__) || defined(__LINUX__) || defined(__MACOSX__) +#if defined(__TIC_WINDOWS__) || defined(__LINUX__) || defined(__MACOSX__) #define CAN_EXPORT 1 #endif @@ -67,7 +68,7 @@ typedef struct #endif -#if defined(__WINDOWS__) +#if defined(__TIC_WINDOWS__) static const char* ExeExt = ".exe"; #endif @@ -297,7 +298,7 @@ static void onConsoleExitCommand(Console* console, const char* param) static s32 writeGifData(const tic_mem* tic, u8* dst, const u8* src, s32 width, s32 height) { s32 size = 0; - gif_color* palette = (gif_color*)SDL_malloc(sizeof(gif_color) * TIC_PALETTE_SIZE); + gif_color* palette = (gif_color*)malloc(sizeof(gif_color) * TIC_PALETTE_SIZE); if(palette) { @@ -307,7 +308,7 @@ static s32 writeGifData(const tic_mem* tic, u8* dst, const u8* src, s32 width, s gif_write_data(dst, &size, width, height, src, palette, TIC_PALETTE_BPP); - SDL_free(palette); + free(palette); } return size; @@ -351,7 +352,7 @@ static bool onConsoleLoadSectionCommand(Console* console, const char* param) for(s32 i = 0; i < COUNT_OF(Sections); i++) { sprintf(buf, "%s %s", CART_EXT, Sections[i]); - char* pos = SDL_strstr(param, buf); + char* pos = strstr(param, buf); if(pos) { @@ -362,7 +363,7 @@ static bool onConsoleLoadSectionCommand(Console* console, const char* param) if(data) { - tic_cartridge* cart = (tic_cartridge*)SDL_malloc(sizeof(tic_cartridge)); + tic_cartridge* cart = (tic_cartridge*)malloc(sizeof(tic_cartridge)); if(cart) { @@ -388,12 +389,12 @@ static bool onConsoleLoadSectionCommand(Console* console, const char* param) printFront(console, name); printLine(console); - SDL_free(cart); + free(cart); result = true; } - SDL_free(data); + free(data); } else printBack(console, "\ncart loading error"); @@ -520,7 +521,7 @@ static void onConsoleLoadDemoCommandConfirmed(Console* console, const char* para printFront(console, console->romName); printBack(console, " loaded!\n"); - SDL_free(data); + free(data); } static void onCartLoaded(Console* console, const char* name) @@ -703,7 +704,7 @@ static bool loadTextSection(const char* project, const char* comment, char* dst, char tagstart[16]; sprintf(tagstart, "\n%s <", comment); - const char* ptr = SDL_strstr(project, tagstart); + const char* ptr = strstr(project, tagstart); if(ptr && ptr < end) end = ptr; @@ -711,7 +712,7 @@ static bool loadTextSection(const char* project, const char* comment, char* dst, if(end > start) { - SDL_memcpy(dst, start, SDL_min(size, end - start)); + memcpy(dst, start, MIN(size, end - start)); done = true; } @@ -730,7 +731,7 @@ static bool loadTextSectionBank(const char* project, const char* comment, const char tagbuf[64]; sprintf(tagbuf, "%s <%s>", comment, tag); - const char* start = SDL_strstr(project, tagbuf); + const char* start = strstr(project, tagbuf); bool done = false; if(start) @@ -739,11 +740,11 @@ static bool loadTextSectionBank(const char* project, const char* comment, const start = getLineEnd(start); sprintf(tagbuf, "\n%s ", comment, tag); - const char* end = SDL_strstr(start, tagbuf); + const char* end = strstr(start, tagbuf); if(end > start) { - SDL_memcpy(dst, start, SDL_min(size, end - start)); + memcpy(dst, start, MIN(size, end - start)); done = true; } @@ -757,7 +758,7 @@ static bool loadBinarySection(const char* project, const char* comment, const ch char tagbuf[64]; sprintf(tagbuf, "%s <%s>", comment, tag); - const char* start = SDL_strstr(project, tagbuf); + const char* start = strstr(project, tagbuf); bool done = false; if(start) @@ -766,7 +767,7 @@ static bool loadBinarySection(const char* project, const char* comment, const ch start = getLineEnd(start); sprintf(tagbuf, "\n%s ", comment, tag); - const char* end = SDL_strstr(start, tagbuf); + const char* end = strstr(start, tagbuf); if(end > start) { @@ -779,7 +780,7 @@ static bool loadBinarySection(const char* project, const char* comment, const ch static char lineStr[] = "999"; memcpy(lineStr, ptr + sizeof("-- ") - 1, sizeof lineStr - 1); - s32 index = SDL_atoi(lineStr); + s32 index = atoi(lineStr); if(index < count) { @@ -809,13 +810,13 @@ static bool loadProject(Console* console, const char* name, const char* data, s3 { tic_mem* tic = console->tic; - char* project = (char*)SDL_malloc(size+1); + char* project = (char*)malloc(size+1); bool done = false; if(project) { - SDL_memcpy(project, data, size); + memcpy(project, data, size); project[size] = '\0'; // remove all the '\r' chars @@ -824,12 +825,12 @@ static bool loadProject(Console* console, const char* name, const char* data, s3 for(s = d = project; (*d = *s); d += (*s++ != '\r')); } - tic_cartridge* cart = (tic_cartridge*)SDL_malloc(sizeof(tic_cartridge)); + tic_cartridge* cart = (tic_cartridge*)malloc(sizeof(tic_cartridge)); if(cart) { - SDL_memset(cart, 0, sizeof(tic_cartridge)); - SDL_memcpy(&cart->palette, &tic->config.palette.data, sizeof(tic_palette)); + memset(cart, 0, sizeof(tic_cartridge)); + memcpy(&cart->palette, &tic->config.palette.data, sizeof(tic_palette)); const char* comment = projectComment(name); char tag[16]; @@ -864,12 +865,12 @@ static bool loadProject(Console* console, const char* name, const char* data, s3 if(loadBinarySection(project, comment, "COVER", 1, &cart->cover, -1, true)) done = true; - SDL_memcpy(dst, cart, sizeof(tic_cartridge)); + memcpy(dst, cart, sizeof(tic_cartridge)); - SDL_free(cart); + free(cart); } - SDL_free(project); + free(project); } return done; @@ -886,20 +887,20 @@ static void updateProject(Console* console) if(data) { - tic_cartridge* cart = SDL_malloc(sizeof(tic_cartridge)); + tic_cartridge* cart = malloc(sizeof(tic_cartridge)); if(cart) { if(loadProject(console, console->romName, data, size, cart)) { - SDL_memcpy(&tic->cart, cart, sizeof(tic_cartridge)); + memcpy(&tic->cart, cart, sizeof(tic_cartridge)); studioRomLoaded(); } - SDL_free(cart); + free(cart); } - SDL_free(data); + free(data); } } @@ -928,7 +929,7 @@ static void onConsoleLoadCommandConfirmed(Console* console, const char* param) onCartLoaded(console, name); - SDL_free(data); + free(data); } else { @@ -951,7 +952,7 @@ static void onConsoleLoadCommandConfirmed(Console* console, const char* param) loadProject(console, name, data, size, &console->tic->cart); onCartLoaded(console, name); - SDL_free(data); + free(data); } else { @@ -988,16 +989,16 @@ static void onConfirm(bool yes, void* data) else commandDone(confirmData->console); if(confirmData->param) - SDL_free(confirmData->param); + free(confirmData->param); - SDL_free(confirmData); + free(confirmData); } static void confirmCommand(Console* console, const char** text, s32 rows, const char* param, ConfirmCallback callback) { - CommandConfirmData* data = SDL_malloc(sizeof(CommandConfirmData)); + CommandConfirmData* data = malloc(sizeof(CommandConfirmData)); data->console = console; - data->param = param ? SDL_strdup(param) : NULL; + data->param = param ? strdup(param) : NULL; data->callback = callback; showDialog(text, rows, onConfirm, data); @@ -1054,10 +1055,10 @@ static void loadDemo(Console* console, ScriptLang script) { loadRom(console->tic, data, size, false); - SDL_free(data); + free(data); } - SDL_memset(console->romName, 0, sizeof console->romName); + memset(console->romName, 0, sizeof console->romName); studioRomLoaded(); } @@ -1217,7 +1218,7 @@ static void installDemoCart(FileSystem* fs, const char* name, const void* cart, u8* data = NULL; s32 dataSize = unzip(&data, cart, size); fsSaveFile(fs, name, data, dataSize, true); - SDL_free(data); + free(data); } static void onConsoleInstallDemosCommand(Console* console, const char* param) @@ -1391,7 +1392,7 @@ static void onImportCover(const char* name, const void* buffer, size_t size, voi if(size <= sizeof console->tic->cart.cover.data) { console->tic->cart.cover.size = size; - SDL_memcpy(console->tic->cart.cover.data, buffer, size); + memcpy(console->tic->cart.cover.data, buffer, size); printLine(console); printBack(console, name); @@ -1434,8 +1435,8 @@ static void onImportSprites(const char* name, const void* buffer, size_t size, v Height = TIC_SPRITESHEET_SIZE*2, }; - s32 w = SDL_min(Width, image->width); - s32 h = SDL_min(Height, image->height); + s32 w = MIN(Width, image->width); + s32 h = MIN(Height, image->height); for (s32 y = 0; y < h; y++) for (s32 x = 0; x < w; x++) @@ -1467,8 +1468,8 @@ static void injectMap(Console* console, const void* buffer, s32 size) { enum {Size = sizeof(tic_map)}; - SDL_memset(getBankMap(), 0, Size); - SDL_memcpy(getBankMap(), buffer, SDL_min(size, Size)); + memset(getBankMap(), 0, Size); + memcpy(getBankMap(), buffer, MIN(size, Size)); } static void onImportMap(const char* name, const void* buffer, size_t size, void* data) @@ -1538,7 +1539,7 @@ static void exportCover(Console* console) if(cover->size) { - void* data = SDL_malloc(cover->size); + void* data = malloc(cover->size); memcpy(data, cover->data, cover->size); fsGetFileData(onCoverExported, "cover.gif", data, cover->size, DEFAULT_CHMOD, console); } @@ -1558,11 +1559,11 @@ static void exportSprites(Console* console) }; enum{ Size = Width * Height * sizeof(gif_color)}; - u8* buffer = (u8*)SDL_malloc(Size); + u8* buffer = (u8*)malloc(Size); if(buffer) { - u8* data = (u8*)SDL_malloc(Width * Height); + u8* data = (u8*)malloc(Width * Height); if(data) { @@ -1580,10 +1581,10 @@ static void exportSprites(Console* console) { printError(console, "\nsprite export error :("); commandDone(console); - SDL_free(buffer); + free(buffer); } - SDL_free(data); + free(data); } } } @@ -1604,11 +1605,11 @@ static void exportMap(Console* console) { enum{Size = sizeof(tic_map)}; - void* buffer = SDL_malloc(Size); + void* buffer = malloc(Size); if(buffer) { - SDL_memcpy(buffer, getBankMap()->data, Size); + memcpy(buffer, getBankMap()->data, Size); fsGetFileData(onMapExported, "world.map", buffer, Size, DEFAULT_CHMOD, console); } } @@ -1721,14 +1722,14 @@ static void onConsoleExportHtmlCommand(Console* console, const char* name) if(ptr) { - MemoryBuffer output = {(u8*)SDL_malloc(EmbedTicJsSize * 2), 0}; + MemoryBuffer output = {(u8*)malloc(EmbedTicJsSize * 2), 0}; if(output.data) { writeMemoryData(&output, EmbedIndex, ptr - EmbedIndex); writeMemoryString(&output, "