this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

remove byte battle things for the FFT PR

alice 9af5d608 7d15a931

+7 -258
+2 -2
README.md
··· 1 - # TIC-80 [Lovebyte](https://lovebyte.party/) / [Byte Battle](https://bytebattle.com/) / [FFT](https://en.wikipedia.org/wiki/Fast_Fourier_transform?useskin=vector) version 1 + # TIC-80 [FFT](https://en.wikipedia.org/wiki/Fast_Fourier_transform?useskin=vector) version 2 2 3 - TIC-80 upstream builds with Byte Battle + FFT support. 3 + TIC-80 upstream build with FFT support. 4 4 5 5 Prior work: 6 6 * https://github.com/glastonbridge/TIC-80
-1
src/api/wren.c
··· 1568 1568 if (strcmp(signature, "static TIC.fget(_,_)" ) == 0) return wren_fget; 1569 1569 if (strcmp(signature, "static TIC.fset(_,_,_)" ) == 0) return wren_fset; 1570 1570 1571 - //bytebattle patch 1572 1571 if (strcmp(signature, "static TIC.fft(_)" ) == 0) return wren_fft; 1573 1572 1574 1573 // internal functions
+4 -53
src/studio/editors/code.c
··· 109 109 history_add(code->history); 110 110 } 111 111 112 - tic_color getCodeColor(Code* code) 113 - { 114 - Lovebyte* lb = getLovebyte(code->studio); 115 - 116 - if(lb) 117 - { 118 - s32 size = strlen(code->src) - lb->limit.lower; 119 - 120 - if(size <= 0) return tic_color_light_green; 121 - 122 - s32 delta = (lb->limit.current - lb->limit.lower) / 2; 123 - 124 - if(size <= delta) return tic_color_yellow; 125 - if(size <= delta*2) return tic_color_orange; 126 - return tic_color_red; 127 - } 128 - 129 - return tic_color_white; 130 - } 131 - 132 112 static void drawStatus(Code* code) 133 113 { 134 114 enum {Height = TIC_FONT_HEIGHT + 1, StatusY = TIC80_HEIGHT - TIC_FONT_HEIGHT}; 135 115 136 - Lovebyte* lb = getLovebyte(code->studio); 137 - 138 - if(lb) 139 - { 140 - tic_api_rect(code->tic, 0, TIC80_HEIGHT - Height, TIC80_WIDTH, Height, getCodeColor(code)); 141 - if(!lb->battle.hidetime) 142 - { 143 - sprintf(code->status.size, "%i/%i", (u32)strlen(code->src), lb->limit.current); 144 - 145 - char buf[sizeof "00:00"]; 146 - s32 sec = lb->battle.left / 1000; 147 - sprintf(buf, "%02i:%02i", sec / 60, sec % 60); 148 - 149 - tic_api_print(code->tic, buf, (TIC80_WIDTH - sizeof "00:00" * TIC_FONT_WIDTH) / 2, 150 - StatusY, getConfig(code->studio)->theme.code.BG, true, 1, false); 151 - } 152 - 153 - tic_api_print(code->tic, code->status.line, 0, StatusY, getConfig(code->studio)->theme.code.BG, true, 1, false); 154 - tic_api_print(code->tic, code->status.size, TIC80_WIDTH - (s32)strlen(code->status.size) * TIC_FONT_WIDTH, 155 - StatusY, getConfig(code->studio)->theme.code.BG, true, 1, false); 156 - } 157 - else 158 116 { 159 117 tic_api_rect(code->tic, 0, TIC80_HEIGHT - Height, TIC80_WIDTH, Height, code->status.color); 160 118 tic_api_print(code->tic, code->status.line, 0, StatusY, getConfig(code->studio)->theme.code.BG, true, 1, false); ··· 513 471 code->cursor.delay = TEXT_CURSOR_DELAY; 514 472 515 473 { 516 - if(getLovebyte(code->studio)) 517 - { 518 - sprintf(code->status.line, "%i:%i", line + 1, column + 1); 519 - } 520 - else 521 - { 522 - sprintf(code->status.line, "line %i/%i col %i", line + 1, getLinesCount(code) + 1, column + 1); 523 - s32 codeLen = strlen(code->src); 524 - sprintf(code->status.size, "size %i/%i", codeLen, MAX_CODE); 525 - code->status.color = codeLen > MAX_CODE ? tic_color_red : tic_color_white; 526 - } 474 + sprintf(code->status.line, "line %i/%i col %i", line + 1, getLinesCount(code) + 1, column + 1); 475 + s32 codeLen = strlen(code->src); 476 + sprintf(code->status.size, "size %i/%i", codeLen, MAX_CODE); 477 + code->status.color = codeLen > MAX_CODE ? tic_color_red : tic_color_white; 527 478 } 528 479 } 529 480
+1 -162
src/studio/studio.c
··· 219 219 tic_fs* fs; 220 220 s32 samplerate; 221 221 tic_font systemFont; 222 - 223 - Lovebyte lovebyte; 224 - 225 222 }; 226 223 227 224 #if defined(BUILD_EDITORS) ··· 1710 1707 return tic_sys_counter_get() * 1000 / tic_sys_freq_get(); 1711 1708 } 1712 1709 1713 - static void hideBattleTime(Studio* studio) 1714 - { 1715 - studio->lovebyte.battle.hidetime = !studio->lovebyte.battle.hidetime; 1716 - } 1717 - 1718 - static void startBattle(Studio* studio) 1719 - { 1720 - studio->lovebyte.battle.started = getTime(); 1721 - } 1722 1710 1723 1711 #if defined(TIC80_PRO) 1724 1712 ··· 1847 1835 } 1848 1836 else if(keyWasPressedOnce(studio, tic_key_f8)) takeScreenshot(studio); 1849 1837 else if(keyWasPressedOnce(studio, tic_key_f9)) startVideoRecord(studio); 1850 - else if(keyWasPressedOnce(studio, tic_key_f10)) hideBattleTime(studio); 1851 - else if(keyWasPressedOnce(studio, tic_key_f12)) startBattle(studio); 1852 1838 else if(studio->mode == TIC_RUN_MODE && keyWasPressedOnce(studio, tic_key_f7)) 1853 1839 setCoverImage(studio); 1854 1840 ··· 2179 2165 tic->ram->input.mouse.scrollx *= -1; 2180 2166 } 2181 2167 2182 - #if defined(BUILD_EDITORS) 2183 - static void doCodeExport(Studio* studio) 2184 - { 2185 - char pos[sizeof studio->lovebyte.last.postag]; 2186 - { 2187 - s32 x = 0, y = 0; 2188 - 2189 - if(studio->mode != TIC_RUN_MODE) 2190 - { 2191 - codeGetPos(studio->code, &x, &y); 2192 - x++; y++; 2193 - } 2194 - 2195 - sprintf(pos, "-- pos: %i,%i\n", x, y); 2196 - } 2197 - 2198 - if(strcmp(studio->lovebyte.last.postag, pos) || strcmp(studio->lovebyte.last.code.data, studio->code->src)) 2199 - { 2200 - FILE* file = fopen(studio->lovebyte.exp, "wb"); 2201 - 2202 - if(file) 2203 - { 2204 - strcpy(studio->lovebyte.last.postag, pos); 2205 - strcpy(studio->lovebyte.last.code.data, studio->code->src); 2206 - 2207 - fwrite(pos, 1, strlen(pos), file); 2208 - fwrite(studio->code->src, 1, strlen(studio->code->src), file); 2209 - fclose(file); 2210 - } 2211 - } 2212 - } 2213 - 2214 - static void doCodeImport(Studio* studio) 2215 - { 2216 - FILE* file = fopen(studio->lovebyte.imp, "rb"); 2217 - 2218 - if(file) 2219 - { 2220 - static tic_code code; 2221 - code.data[fread(code.data, 1, sizeof(tic_code), file)] = '\0'; 2222 - 2223 - char* end = strchr(code.data, '\n'); 2224 - 2225 - if(end) 2226 - { 2227 - static const char PosTag[] = "-- pos: "; 2228 - enum{TagSize = sizeof PosTag - 1}; 2229 - 2230 - if(memcmp(code.data, PosTag, TagSize) == 0) 2231 - { 2232 - char* start = code.data + TagSize; 2233 - char* sep = strchr(start, ','); 2234 - 2235 - if(sep) 2236 - { 2237 - *sep = *end = '\0'; 2238 - s32 x = atoi(start); 2239 - s32 y = atoi(sep + 1); 2240 - 2241 - if(x == 0 && y == 0) 2242 - { 2243 - if(studio->mode != TIC_RUN_MODE) 2244 - runGame(studio); 2245 - } 2246 - else 2247 - { 2248 - s32 offset = end - code.data + 1; 2249 - memcpy(studio->code->src, code.data + offset, sizeof(tic_code) - offset); 2250 - codeSetPos(studio->code, x - 1, y - 1); 2251 - 2252 - if(studio->mode == TIC_RUN_MODE) 2253 - setStudioMode(studio, TIC_CODE_MODE); 2254 - } 2255 - } 2256 - } 2257 - } 2258 - 2259 - fclose(file); 2260 - } 2261 - } 2262 - #endif 2263 - 2264 2168 2265 2169 static void blitCursor(Studio* studio) 2266 2170 { ··· 2373 2277 2374 2278 #if defined(BUILD_EDITORS) 2375 2279 tic_net_end(studio->net); 2376 - 2377 - { 2378 - Lovebyte* lb = &(studio->lovebyte); 2379 - if(lb->battle.started) 2380 - { 2381 - u32 passed = getTime() - lb->battle.started; 2382 - lb->battle.left = lb->battle.time - passed; 2383 - 2384 - if(lb->battle.left > 0) 2385 - { 2386 - s32 delta = lb->battle.time / (lb->limit.upper - lb->limit.lower); 2387 - lb->limit.current = lb->limit.upper - passed / delta; 2388 - } 2389 - else 2390 - { 2391 - lb->battle.left = 0; 2392 - lb->limit.current = lb->limit.lower; 2393 - } 2394 - } 2395 - 2396 - if(lb->delay) 2397 - if(lb->ticks++ < lb->delay) 2398 - return; 2399 - 2400 - if(lb->exp) 2401 - doCodeExport(studio); 2402 - else if(lb->imp) 2403 - doCodeImport(studio); 2404 - 2405 - lb->ticks = 0; 2406 - } 2407 2280 #endif 2408 2281 } 2409 2282 ··· 2508 2381 2509 2382 free(studio->fs); 2510 2383 2511 - if(studio->lovebyte.exp) free(studio->lovebyte.exp); 2512 - if(studio->lovebyte.imp) free(studio->lovebyte.imp); 2513 - 2514 2384 free(studio); 2515 - } 2516 - 2517 - Lovebyte* getLovebyte(Studio* studio) 2518 - { 2519 - return studio->lovebyte.exp || studio->lovebyte.imp ? &(studio->lovebyte) : NULL; 2520 2385 } 2521 2386 2522 2387 static StartArgs parseArgs(s32 argc, char **argv) ··· 2527 2392 NULL, 2528 2393 }; 2529 2394 2530 - StartArgs args = {.volume = -1, .lowerlimit = 256, .upperlimit = 512, .fftlist = 0}; 2395 + StartArgs args = {.volume = -1, .fftlist = 0}; 2531 2396 2532 2397 struct argparse_option options[] = 2533 2398 { ··· 2535 2400 #define CMD_PARAMS_DEF(name, ctype, type, post, help) OPT_##type('\0', #name, &args.name, help), 2536 2401 CMD_PARAMS_LIST(CMD_PARAMS_DEF) 2537 2402 #undef CMD_PARAMS_DEF 2538 - OPT_GROUP("LOVEBYTE options:\n"), 2539 - OPT_STRING('e', "codeexport", &args.codeexport, "export code to filename"), 2540 - OPT_STRING('i', "codeimport", &args.codeimport, "import code from filename"), 2541 - OPT_INTEGER('d', "delay", &args.delay, "codeexport / codeimport update interval in ticks"), 2542 - OPT_INTEGER('l', "lowerlimit", &args.lowerlimit, "lower limit for code size (256 by default)"), 2543 - OPT_INTEGER('u', "upperlimit", &args.upperlimit, "upper limit for code size (512 by default)"), 2544 - OPT_INTEGER('b', "battletime", &args.battletime, "battletime in minutes"), 2545 - OPT_GROUP("FFT options:\n"), 2546 2403 OPT_BOOLEAN('o', "fftlist", &args.fftlist, "list FFT devices"), 2547 2404 OPT_STRING('p', "fftdevice", &args.fftdevice, "name of the device to use with FFT"), 2548 2405 OPT_END(), ··· 2638 2495 2639 2496 .samplerate = samplerate, 2640 2497 .net = tic_net_create(TIC_WEBSITE), 2641 - 2642 - .lovebyte = {0}, 2643 2498 #endif 2644 2499 .tic = tic_core_create(samplerate, format), 2645 2500 }; ··· 2739 2594 studio->config->data.options.vsync |= args.vsync; 2740 2595 studio->config->data.soft |= args.soft; 2741 2596 studio->config->data.cli |= args.cli; 2742 - 2743 - if(args.codeexport) 2744 - studio->lovebyte.exp = strdup(args.codeexport); 2745 - else if(args.codeimport) 2746 - studio->lovebyte.imp = strdup(args.codeimport); 2747 - 2748 - studio->lovebyte.delay = args.delay; 2749 - studio->lovebyte.limit.lower = args.lowerlimit; 2750 - 2751 - studio->lovebyte.limit.current 2752 - = studio->lovebyte.limit.upper 2753 - = args.upperlimit; 2754 - 2755 - studio->lovebyte.battle.left 2756 - = studio->lovebyte.battle.time 2757 - = args.battletime * 60 * 1000; 2758 2597 2759 2598 if (args.fftlist) 2760 2599 {
-40
src/studio/studio.h
··· 95 95 CMD_PARAMS_LIST(CMD_PARAMS_DEF) 96 96 #undef CMD_PARAMS_DEF 97 97 98 - const char *codeexport; 99 - const char *codeimport; 100 - s32 delay; 101 - s32 lowerlimit; 102 - s32 upperlimit; 103 - s32 battletime; 104 98 s32 fftlist; 105 99 const char *fftdevice; 106 100 } StartArgs; ··· 286 280 void map2ram(tic_ram* ram, const tic_map* src); 287 281 void tiles2ram(tic_ram* ram, const tic_tiles* src); 288 282 void fadePalette(tic_palette* pal, s32 value); 289 - 290 - typedef struct 291 - { 292 - char* exp; 293 - char* imp; 294 - 295 - struct 296 - { 297 - tic_code code; 298 - char postag[32]; 299 - } last; 300 - 301 - s32 delay; 302 - s32 ticks; 303 - 304 - struct 305 - { 306 - s32 lower; 307 - s32 upper; 308 - s32 current; 309 - } limit; 310 - 311 - struct 312 - { 313 - s32 started; 314 - s32 time; 315 - s32 left; 316 - 317 - bool hidetime; 318 - } battle; 319 - 320 - } Lovebyte; 321 - 322 - Lovebyte* getLovebyte(Studio* studio);