From 335c45f23e7262b1fe4503319af7c214b5ff2575 Mon Sep 17 00:00:00 2001 From: nesbox Date: Thu, 17 Aug 2023 13:40:07 +0200 Subject: [PATCH 01/83] v1.2-dev --- CMakeLists.txt | 2 +- build/android/app/src/main/AndroidManifest.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0579cb47f..7c0ed2527 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.3) set(VERSION_MAJOR 1) -set(VERSION_MINOR 1) +set(VERSION_MINOR 2) set(VERSION_REVISION 0) set(VERSION_STATUS "-dev") string(TIMESTAMP VERSION_YEAR "%Y") diff --git a/build/android/app/src/main/AndroidManifest.xml b/build/android/app/src/main/AndroidManifest.xml index a10559ab2..a95fc9dee 100644 --- a/build/android/app/src/main/AndroidManifest.xml +++ b/build/android/app/src/main/AndroidManifest.xml @@ -4,8 +4,8 @@ --> From 416e81dd784749c73fc500d9abc07a5f6fcdc8af Mon Sep 17 00:00:00 2001 From: nesbox Date: Thu, 17 Aug 2023 18:25:20 +0200 Subject: [PATCH 02/83] fixed ttri function in wasm build, in release build it sets depth to true, no matter what you pass as a parameter, maybe we exceeded arguments count in emscripten --- src/core/draw.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/draw.c b/src/core/draw.c index 6d858c6eb..d19f40256 100644 --- a/src/core/draw.c +++ b/src/core/draw.c @@ -848,6 +848,10 @@ void tic_api_ttri(tic_mem* tic, 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 = { .sheet = getTileSheetFromSegment(tic, tic->ram->vram.blit.segment), From de014e7d5f6d260f4a20155c954accdd8e3a09f5 Mon Sep 17 00:00:00 2001 From: nesbox Date: Thu, 17 Aug 2023 19:53:19 +0200 Subject: [PATCH 03/83] integer scale fix --- src/studio/config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/studio/config.c b/src/studio/config.c index 476d6f7c2..74038e57d 100644 --- a/src/studio/config.c +++ b/src/studio/config.c @@ -31,9 +31,9 @@ #endif #if defined(__TIC_ANDROID__) -#define INTEGER_SCALE_DEFAULT true -#else #define INTEGER_SCALE_DEFAULT false +#else +#define INTEGER_SCALE_DEFAULT true #endif #if defined (TIC_BUILD_WITH_LUA) From 14d748b0d86dba2f8df7c912cfbbbd13d667b1ce Mon Sep 17 00:00:00 2001 From: fabien Date: Wed, 23 Aug 2023 22:23:02 +0200 Subject: [PATCH 04/83] add build instruction for ubuntu 22.04 --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index ea66c9939..371fe97d1 100644 --- a/README.md +++ b/README.md @@ -162,6 +162,14 @@ sudo apt-get install -t jessie-backports liblua5.3-dev git clone --recursive https://github.com/nesbox/TIC-80 && cd TIC-80/build cmake .. make -j4 + +# install software ubuntu 22.04.3 LTS +sudo apt-get install git build-essential ruby-full libsdl2-dev zlib1g-dev +sudo apt-get install liblua5.3-dev +sudo apt-get install libcurl4-openssl-dev +git clone --recursive https://github.com/nesbox/TIC-80 && cd TIC-80/build +cmake .. +make -j4 ``` Install with [Install instructions](#install-instructions) From dbefbc1964281e61394fddb6a673cbf08231bb01 Mon Sep 17 00:00:00 2001 From: nesbox Date: Thu, 24 Aug 2023 14:22:44 +0200 Subject: [PATCH 05/83] #2267: fixed default value for the tile index in remap function --- src/api/js.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/js.c b/src/api/js.c index db5f02ac7..19705ac0d 100644 --- a/src/api/js.c +++ b/src/api/js.c @@ -429,13 +429,13 @@ static void remapCallback(void* data, s32 x, s32 y, RemapResult* result) if(JS_IsArray(ctx, res)) { - result->index = getInteger2(ctx, JS_GetPropertyUint32(ctx, res, 0), result->index); + result->index = JS_IsUndefined(res) ? 0 : getInteger(ctx, JS_GetPropertyUint32(ctx, res, 0)); result->flip = getInteger2(ctx, JS_GetPropertyUint32(ctx, res, 1), result->flip); result->rotate = getInteger2(ctx, JS_GetPropertyUint32(ctx, res, 2), result->rotate); } else { - result->index = getInteger2(ctx, res, result->index); + result->index = JS_IsUndefined(res) ? 0 : getInteger(ctx, res); } } From 7495b7eb1296c2c30ca46aa80502c2dc35b60888 Mon Sep 17 00:00:00 2001 From: nesbox Date: Thu, 24 Aug 2023 14:26:28 +0200 Subject: [PATCH 06/83] #2265: Revert "#2228: fixed right ALT" This reverts commit 94031fee5eca433d9cc157aa9c11df4fea62d849. --- src/system/sdl/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/sdl/main.c b/src/system/sdl/main.c index 6615e1fad..1f0eb52dc 100644 --- a/src/system/sdl/main.c +++ b/src/system/sdl/main.c @@ -700,7 +700,7 @@ static void processKeyboard() platform.keyboard.state[tic_key_shift] = mod & KMOD_SHIFT; platform.keyboard.state[tic_key_ctrl] = mod & (KMOD_CTRL | KMOD_GUI); - platform.keyboard.state[tic_key_alt] = mod & KMOD_ALT; + platform.keyboard.state[tic_key_alt] = mod & KMOD_LALT; platform.keyboard.state[tic_key_capslock] = mod & KMOD_CAPS; // it's weird, but system sends CTRL when you press RALT From 388074e4584e3f9350dbbfca73cbdf62146448c2 Mon Sep 17 00:00:00 2001 From: nesbox Date: Thu, 24 Aug 2023 14:36:50 +0200 Subject: [PATCH 07/83] #2222: fixed directory access rights on Android --- src/studio/fs.c | 2 +- src/system/sdl/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/studio/fs.c b/src/studio/fs.c index 83492be6c..073e0460c 100644 --- a/src/studio/fs.c +++ b/src/studio/fs.c @@ -192,7 +192,7 @@ typedef char FsString; #define tic_stat stat #define tic_remove remove #define tic_fopen fopen -#define tic_mkdir(name) mkdir(name, 0700) +#define tic_mkdir(name) mkdir(name, 0777) #define tic_strncpy strncpy #define tic_strncat strncat diff --git a/src/system/sdl/main.c b/src/system/sdl/main.c index 1f0eb52dc..654d920e1 100644 --- a/src/system/sdl/main.c +++ b/src/system/sdl/main.c @@ -1323,7 +1323,7 @@ static const char* getAppFolder() strcpy(appFolder, SDL_AndroidGetExternalStoragePath()); const char AppFolder[] = "/" TIC_NAME "/"; strcat(appFolder, AppFolder); - mkdir(appFolder, 0700); + mkdir(appFolder, 0777); #else From 0699bf5bb0e57fbfc2e43f771f24b1bb0d410259 Mon Sep 17 00:00:00 2001 From: nesbox Date: Thu, 24 Aug 2023 15:40:24 +0200 Subject: [PATCH 08/83] #2270: fixed sprite drawing on Android --- src/studio/editors/sprite.c | 32 +++++++++++++++++++++++--------- src/studio/editors/sprite.h | 7 ++++++- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/studio/editors/sprite.c b/src/studio/editors/sprite.c index 57907345d..f0841ea5f 100644 --- a/src/studio/editors/sprite.c +++ b/src/studio/editors/sprite.c @@ -231,11 +231,11 @@ static void processDrawCanvasMouse(Sprite* sprite, s32 x, s32 y, s32 sx, s32 sy) { setCursor(sprite->studio, tic_cursor_hand); - s32 brushSize = sprite->brushSize*Size; - s32 mx = toCanvasCoord(Size, brushSize, x, tic_api_mouse(tic).x); - s32 my = toCanvasCoord(Size, brushSize, y, tic_api_mouse(tic).y); - s32 pmx = toCanvasCoord(Size, brushSize, x, sprite->previousMouse.x); - s32 pmy = toCanvasCoord(Size, brushSize, y, sprite->previousMouse.y); + s32 brushSize = sprite->brushSize * Size; + tic_point mouse = tic_api_mouse(tic); + + s32 mx = toCanvasCoord(Size, brushSize, x, mouse.x); + s32 my = toCanvasCoord(Size, brushSize, y, mouse.y); SHOW_TOOLTIP(sprite->studio, "[x=%02i y=%02i]", mx / Size, my / Size); @@ -246,14 +246,30 @@ static void processDrawCanvasMouse(Sprite* sprite, s32 x, s32 y, s32 sx, s32 sy) if(left || right) { + if(!sprite->draw.start) + { + sprite->draw.start = true; + sprite->draw.last = tic_api_mouse(tic); + } + + s32 lx = toCanvasCoord(Size, brushSize, x, sprite->draw.last.x); + s32 ly = toCanvasCoord(Size, brushSize, y, sprite->draw.last.y); + u8 color = left ? sprite->color : sprite->color2; paintLine(sprite, color, - sx + pmx / Size, - sy + pmy / Size, + sx + lx / Size, + sy + ly / Size, sx + mx / Size, sy + my / Size ); + history_add(sprite->history); + + sprite->draw.last = tic_api_mouse(tic); + } + else + { + sprite->draw.start = false; } } } @@ -1977,7 +1993,6 @@ static void tick(Sprite* sprite) { tic_mem* tic = sprite->tic; - if (sprite->tickCounter == 0) sprite->previousMouse = tic_api_mouse(tic); processAnim(sprite->anim.movie, sprite); // process scroll @@ -2053,7 +2068,6 @@ static void tick(Sprite* sprite) drawToolbar(sprite->studio, tic, false); } - sprite->previousMouse = tic_api_mouse(sprite->tic); sprite->tickCounter++; } diff --git a/src/studio/editors/sprite.h b/src/studio/editors/sprite.h index 15c30161d..eb746a0e9 100644 --- a/src/studio/editors/sprite.h +++ b/src/studio/editors/sprite.h @@ -36,7 +36,12 @@ struct Sprite tic_tilesheet sheet; u32 tickCounter; - tic_point previousMouse; + + struct + { + bool start; + tic_point last; + } draw; u16 index; u8 color; From 5b9739967a4fd07a035f72b45133d400a93eb3f5 Mon Sep 17 00:00:00 2001 From: nesbox Date: Thu, 24 Aug 2023 17:19:28 +0200 Subject: [PATCH 09/83] #2229: fixed CRT effect in alone exports --- build/assets/config.tic.dat | 2 +- config.lua | 150 -------------------------------- src/studio/config.c | 60 ------------- src/studio/system.h | 8 -- src/system/sdl/main.c | 166 +++++++++++++++++++++++++++++++++--- 5 files changed, 156 insertions(+), 230 deletions(-) diff --git a/build/assets/config.tic.dat b/build/assets/config.tic.dat index e7a3aca5a..6b8710234 100644 --- a/build/assets/config.tic.dat +++ b/build/assets/config.tic.dat @@ -1 +1 @@ -0x78, 0xda, 0xed, 0x3c, 0x4b, 0x73, 0x1b, 0xc9, 0x79, 0xb3, 0xd6, 0x3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0x3d, 0x4c, 0x91, 0x6b, 0x09, 0x52, 0x96, 0xdb, 0xab, 0xc0, 0x9b, 0xe6, 0x05, 0xb7, 0xb6, 0xcd, 0x5f, 0xee, 0x60, 0x63, 0x22, 0xb6, 0x06, 0xfc, 0xbd, 0xad, 0x20, 0xde, 0xd3, 0x84, 0xa8, 0x7c, 0x72, 0xf1, 0xb0, 0xc2, 0x5f, 0xc6, 0x26, 0x64, 0x8f, 0xef, 0xf9, 0x47, 0x94, 0xca, 0x2b, 0xdc, 0x37, 0x38, 0x68, 0xd2, 0xa7, 0xd2, 0x17, 0x54, 0x76, 0xf2, 0xe2, 0x15, 0x6c, 0xc4, 0x5f, 0x0e, 0xde, 0x85, 0x71, 0xf7, 0x53, 0xc1, 0xf0, 0x42, 0x7b, 0x8d, 0x71, 0xf3, 0x45, 0xb8, 0xf1, 0x5f, 0x86, 0x7d, 0x1c, 0xf1, 0xca, 0x3c, 0x23, 0x77, 0x95, 0xb9, 0x28, 0xb9, 0x7c, 0xe4, 0xdd, 0x37, 0x73, 0x2b, 0xf3, 0x7f, 0x40, 0xfe, 0xe8, 0x4d, \ No newline at end of file +0x78, 0xda, 0xed, 0x5c, 0x4b, 0x6f, 0x1c, 0xc7, 0x11, 0x6e, 0x3d, 0x1c, 0x81, 0x9b, 0x92, 0x14, 0xfa, 0x90, 0x53, 0x00, 0x53, 0xe3, 0x8b, 0x04, 0xac, 0x60, 0x89, 0xab, 0x18, 0x39, 0x2c, 0x0f, 0x34, 0xb9, 0x12, 0x09, 0x8b, 0xa4, 0x40, 0x2e, 0x23, 0xe4, 0xc4, 0x28, 0x32, 0x97, 0x21, 0xb0, 0x91, 0x0c, 0x51, 0x12, 0x91, 0x87, 0x80, 0x1c, 0x79, 0xc8, 0x21, 0x57, 0xeb, 0xa4, 0x24, 0x97, 0x98, 0xe0, 0x21, 0x8f, 0x3f, 0xd0, 0x92, 0x12, 0x27, 0x76, 0x3a, 0x2b, 0x27, 0xce, 0x3b, 0x26, 0xd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 0x2e, 0x36, 0x97, 0xb0, 0x69, 0x5e, 0xbe, 0x78, 0xa1, 0x39, 0xd0, 0xbc, 0xf0, 0xb1, 0xf9, 0xe6, 0x50, 0x54, 0xff, 0xf8, 0xe2, 0xd2, 0x80, 0xfc, 0xb7, 0xf4, 0xc9, 0xa5, 0xab, 0xf3, 0x9f, 0x18, 0xb8, 0x78, 0xf9, 0x52, 0x63, 0x71, 0xe1, 0xda, 0x95, 0x0b, 0x4a, 0xee, 0xe2, 0x85, 0x2b, 0x57, 0xaf, 0x2c, 0x3e, 0xb3, 0x30, 0x1f, 0x19, 0xa9, 0xa5, 0xc5, 0x4f, 0xcd, 0x0f, 0x3d, 0x7b, 0x65, 0xf1, 0xd2, 0xd5, 0xa3, 0x4a, 0x41, 0xf9, 0x44, 0xf9, 0xf8, 0x93, 0x52, 0xa7, 0xdd, 0x75, 0x74, 0xf0, 0xd4, 0x89, 0xe3, 0xf8, 0xe0, 0xb1, 0x27, 0x9e, 0x18, 0x2c, 0x1f, 0x3d, 0x59, 0x79, 0x52, 0x3e, 0x22, 0x2f, 0x8f, 0x95, 0xe6, 0x2f, 0x3d, 0x53, 0xfa, 0x2f, 0x1a, 0xd2, 0xf6, 0xf5, \ No newline at end of file diff --git a/config.lua b/config.lua index e17aaa093..3c5ab46bb 100644 --- a/config.lua +++ b/config.lua @@ -39,156 +39,6 @@ function TIC() print(label,(240-size)//2,(136-6)//2) end -CRT_SHADER= -{ - VERTEX=[[ - #version 110 - attribute vec3 gpu_Vertex; - attribute vec2 gpu_TexCoord; - attribute vec4 gpu_Color; - uniform mat4 gpu_ModelViewProjectionMatrix; - varying vec4 color; - varying vec2 texCoord; - void main(void) - { - color = gpu_Color; - texCoord = vec2(gpu_TexCoord); - gl_Position = gpu_ModelViewProjectionMatrix * vec4(gpu_Vertex, 1.0); - } - ]], - PIXEL=[[ - #version 110 - //precision highp float; - varying vec2 texCoord; - uniform sampler2D source; - uniform float trg_x; - uniform float trg_y; - uniform float trg_w; - uniform float trg_h; - - // Emulated input resolution. - vec2 res=vec2(256.0,144.0); - - // Hardness of scanline. - // -8.0 = soft - // -16.0 = medium - float hardScan=-8.0; - - // Hardness of pixels in scanline. - // -2.0 = soft - // -4.0 = hard - float hardPix=-3.0; - - // Display warp. - // 0.0 = none - // 1.0/8.0 = extreme - vec2 warp=vec2(1.0/64.0,1.0/48.0); - - // Amount of shadow mask. - float maskDark=0.5; - float maskLight=1.5; - - //------------------------------------------------------------------------ - - // sRGB to Linear. - // Assuing using sRGB typed textures this should not be needed. - float ToLinear1(float c){return(c<=0.04045)?c/12.92:pow((c+0.055)/1.055,2.4);} - vec3 ToLinear(vec3 c){return vec3(ToLinear1(c.r),ToLinear1(c.g),ToLinear1(c.b));} - - // Linear to sRGB. - // Assuing using sRGB typed textures this should not be needed. - float ToSrgb1(float c){return(c<0.0031308?c*12.92:1.055*pow(c,0.41666)-0.055);} - vec3 ToSrgb(vec3 c){return vec3(ToSrgb1(c.r),ToSrgb1(c.g),ToSrgb1(c.b));} - - // Nearest emulated sample given floating point position and texel offset. - // Also zero's off screen. - vec3 Fetch(vec2 pos,vec2 off){ - pos=(floor(pos*res+off)+vec2(0.5,0.5))/res; - return ToLinear(1.2 * texture2D(source,pos.xy,-16.0).rgb);} - - // Distance in emulated pixels to nearest texel. - vec2 Dist(vec2 pos){pos=pos*res;return -((pos-floor(pos))-vec2(0.5));} - - // 1D Gaussian. - float Gaus(float pos,float scale){return exp2(scale*pos*pos);} - - // 3-tap Gaussian filter along horz line. - vec3 Horz3(vec2 pos,float off){ - vec3 b=Fetch(pos,vec2(-1.0,off)); - vec3 c=Fetch(pos,vec2( 0.0,off)); - vec3 d=Fetch(pos,vec2( 1.0,off)); - float dst=Dist(pos).x; - // Convert distance to weight. - float scale=hardPix; - float wb=Gaus(dst-1.0,scale); - float wc=Gaus(dst+0.0,scale); - float wd=Gaus(dst+1.0,scale); - // Return filtered sample. - return (b*wb+c*wc+d*wd)/(wb+wc+wd);} - - // 5-tap Gaussian filter along horz line. - vec3 Horz5(vec2 pos,float off){ - vec3 a=Fetch(pos,vec2(-2.0,off)); - vec3 b=Fetch(pos,vec2(-1.0,off)); - vec3 c=Fetch(pos,vec2( 0.0,off)); - vec3 d=Fetch(pos,vec2( 1.0,off)); - vec3 e=Fetch(pos,vec2( 2.0,off)); - float dst=Dist(pos).x; - // Convert distance to weight. - float scale=hardPix; - float wa=Gaus(dst-2.0,scale); - float wb=Gaus(dst-1.0,scale); - float wc=Gaus(dst+0.0,scale); - float wd=Gaus(dst+1.0,scale); - float we=Gaus(dst+2.0,scale); - // Return filtered sample. - return (a*wa+b*wb+c*wc+d*wd+e*we)/(wa+wb+wc+wd+we);} - - // Return scanline weight. - float Scan(vec2 pos,float off){ - float dst=Dist(pos).y; - return Gaus(dst+off,hardScan);} - - // Allow nearest three lines to effect pixel. - vec3 Tri(vec2 pos){ - vec3 a=Horz3(pos,-1.0); - vec3 b=Horz5(pos, 0.0); - vec3 c=Horz3(pos, 1.0); - float wa=Scan(pos,-1.0); - float wb=Scan(pos, 0.0); - float wc=Scan(pos, 1.0); - return a*wa+b*wb+c*wc;} - - // Distortion of scanlines, and end of screen alpha. - vec2 Warp(vec2 pos){ - pos=pos*2.0-1.0; - pos*=vec2(1.0+(pos.y*pos.y)*warp.x,1.0+(pos.x*pos.x)*warp.y); - return pos*0.5+0.5;} - - // Shadow mask. - vec3 Mask(vec2 pos){ - pos.x+=pos.y*3.0; - vec3 mask=vec3(maskDark,maskDark,maskDark); - pos.x=fract(pos.x/6.0); - if(pos.x<0.333)mask.r=maskLight; - else if(pos.x<0.666)mask.g=maskLight; - else mask.b=maskLight; - return mask;} - - void main() { - hardScan=-12.0; - //maskDark=maskLight; - vec2 start=gl_FragCoord.xy-vec2(trg_x, trg_y); - start.y=trg_h-start.y; - - vec2 pos=Warp(start/vec2(trg_w, trg_h)); - - gl_FragColor.rgb=Tri(pos)*Mask(gl_FragCoord.xy); - gl_FragColor = vec4(ToSrgb(gl_FragColor.rgb), 1.0); - } - ]] -} - -- -- 000:eccccccccc888888caaaaaaaca888888cacccccccacc0ccccacc0ccccacc0ccc -- 001:ccccceee8888cceeaaaa0cee888a0ceeccca0ccc0cca0c0c0cca0c0c0cca0c0c diff --git a/src/studio/config.c b/src/studio/config.c index 74038e57d..3f68557d4 100644 --- a/src/studio/config.c +++ b/src/studio/config.c @@ -88,56 +88,6 @@ static void readGlobalBool(lua_State* lua, const char* name, bool* val) lua_pop(lua, 1); } -#if defined(CRT_SHADER_SUPPORT) - -static void readString(lua_State* lua, const char* name, const char** val) -{ - lua_getfield(lua, -1, name); - - if (lua_isstring(lua, -1)) - *val = strdup(lua_tostring(lua, -1)); - - lua_pop(lua, 1); -} - -static void readConfigCrtShader(Config* config, lua_State* lua) -{ - lua_getglobal(lua, "CRT_SHADER"); - - if(lua_type(lua, -1) == LUA_TTABLE) - { - readString(lua, "VERTEX", &config->data.shader.vertex); - readString(lua, "PIXEL", &config->data.shader.pixel); - } - -#if defined (EMSCRIPTEN) - // WebGL supports only version 100 shaders. - // Luckily, the format is nearly identical. - // This code detects the incompatible line(s) at - // the beginning of each shader and patches them - // in-place in memory. - char *s = (char *)config->data.shader.vertex; - if (strncmp("\t\t#version 110", s, 14) == 0) { - // replace the two tabs, with a "//" comment, disabling the #version tag. - s[0] = '/'; - s[1] = '/'; - } - s = (char *)config->data.shader.pixel; - if (strncmp("\t\t#version 110\n\t\t//precision highp float;", s, 41) == 0) { - // replace the two tabs, with a "//" comment, disabling the #version tag. - s[0] = '/'; - s[1] = '/'; - // replace the "//" comment with spaces, enabling the precision statement. - s[17] = ' '; - s[18] = ' '; - } -#endif - - lua_pop(lua, 1); -} - -#endif - static void readCodeTheme(Config* config, lua_State* lua) { lua_getfield(lua, -1, "CODE"); @@ -208,9 +158,6 @@ static void readConfig(Config* config) if(config->data.uiScale <= 0) config->data.uiScale = 1; -#if defined(CRT_SHADER_SUPPORT) - readConfigCrtShader(config, lua); -#endif readTheme(config, lua); } @@ -351,12 +298,5 @@ void freeConfig(Config* config) tic_fs_saveroot(config->fs, OptionsDatPath, &config->data.options, sizeof config->data.options, true); free(config->cart); - -#if defined(CRT_SHADER_SUPPORT) - - free((void*)config->data.shader.vertex); - free((void*)config->data.shader.pixel); -#endif - free(config); } diff --git a/src/studio/system.h b/src/studio/system.h index 3f8219349..c784d1df0 100644 --- a/src/studio/system.h +++ b/src/studio/system.h @@ -119,14 +119,6 @@ typedef struct bool cli; bool soft; -#if defined(CRT_SHADER_SUPPORT) - struct - { - const char* vertex; - const char* pixel; - } shader; -#endif - struct StudioOptions { #if defined(CRT_SHADER_SUPPORT) diff --git a/src/system/sdl/main.c b/src/system/sdl/main.c index 654d920e1..45c2c6fe7 100644 --- a/src/system/sdl/main.c +++ b/src/system/sdl/main.c @@ -1460,16 +1460,160 @@ void tic_sys_preseed() static void loadCrtShader() { - const char* vertextShader = studio_config(platform.studio)->shader.vertex; - const char* pixelShader = studio_config(platform.studio)->shader.pixel; - - if(!vertextShader) - printf("Error: vertex shader is empty.\n"); - - if(!pixelShader) - printf("Error: pixel shader is empty.\n"); - - u32 vertex = GPU_CompileShader(GPU_VERTEX_SHADER, vertextShader); + static const char VertextShader[] = +#if !defined (EMSCRIPTEN) + "#version 110" "\n" +#endif + "attribute vec3 gpu_Vertex;" "\n" + "attribute vec2 gpu_TexCoord;" "\n" + "attribute vec4 gpu_Color;" "\n" + "uniform mat4 gpu_ModelViewProjectionMatrix;" "\n" + "varying vec4 color;" "\n" + "varying vec2 texCoord;" "\n" + "void main(void)" "\n" + "{" "\n" + " color = gpu_Color;" "\n" + " texCoord = vec2(gpu_TexCoord);" "\n" + " gl_Position = gpu_ModelViewProjectionMatrix * vec4(gpu_Vertex, 1.0);" "\n" + "}" "\n" + ; + + static const char PixelShader[] = +#if !defined (EMSCRIPTEN) + "#version 110" "\n" +#else + "precision highp float;" "\n" +#endif + "varying vec2 texCoord;" "\n" + "uniform sampler2D source;" "\n" + "uniform float trg_x;" "\n" + "uniform float trg_y;" "\n" + "uniform float trg_w;" "\n" + "uniform float trg_h;" "\n" + "" "\n" + "// Emulated input resolution." "\n" + "vec2 res=vec2(256.0,144.0);" "\n" + "" "\n" + "// Hardness of scanline." "\n" + "// -8.0 = soft" "\n" + "// -16.0 = medium" "\n" + "float hardScan=-8.0;" "\n" + "" "\n" + "// Hardness of pixels in scanline." "\n" + "// -2.0 = soft" "\n" + "// -4.0 = hard" "\n" + "float hardPix=-3.0;" "\n" + "" "\n" + "// Display warp." "\n" + "// 0.0 = none" "\n" + "// 1.0/8.0 = extreme" "\n" + "vec2 warp=vec2(1.0/64.0,1.0/48.0); " "\n" + "" "\n" + "// Amount of shadow mask." "\n" + "float maskDark=0.5;" "\n" + "float maskLight=1.5;" "\n" + "" "\n" + "//------------------------------------------------------------------------" "\n" + "" "\n" + "// sRGB to Linear." "\n" + "// Assuing using sRGB typed textures this should not be needed." "\n" + "float ToLinear1(float c){return(c<=0.04045)?c/12.92:pow((c+0.055)/1.055,2.4);}" "\n" + "vec3 ToLinear(vec3 c){return vec3(ToLinear1(c.r),ToLinear1(c.g),ToLinear1(c.b));}" "\n" + "" "\n" + "// Linear to sRGB." "\n" + "// Assuing using sRGB typed textures this should not be needed." "\n" + "float ToSrgb1(float c){return(c<0.0031308?c*12.92:1.055*pow(c,0.41666)-0.055);}" "\n" + "vec3 ToSrgb(vec3 c){return vec3(ToSrgb1(c.r),ToSrgb1(c.g),ToSrgb1(c.b));}" "\n" + "" "\n" + "// Nearest emulated sample given floating point position and texel offset." "\n" + "// Also zero's off screen." "\n" + "vec3 Fetch(vec2 pos,vec2 off){" "\n" + " pos=(floor(pos*res+off)+vec2(0.5,0.5))/res;" "\n" + " return ToLinear(1.2 * texture2D(source,pos.xy,-16.0).rgb);}" "\n" + "" "\n" + "// Distance in emulated pixels to nearest texel." "\n" + "vec2 Dist(vec2 pos){pos=pos*res;return -((pos-floor(pos))-vec2(0.5));}" "\n" + " " "\n" + "// 1D Gaussian." "\n" + "float Gaus(float pos,float scale){return exp2(scale*pos*pos);}" "\n" + "" "\n" + "// 3-tap Gaussian filter along horz line." "\n" + "vec3 Horz3(vec2 pos,float off){" "\n" + " vec3 b=Fetch(pos,vec2(-1.0,off));" "\n" + " vec3 c=Fetch(pos,vec2( 0.0,off));" "\n" + " vec3 d=Fetch(pos,vec2( 1.0,off));" "\n" + " float dst=Dist(pos).x;" "\n" + " // Convert distance to weight." "\n" + " float scale=hardPix;" "\n" + " float wb=Gaus(dst-1.0,scale);" "\n" + " float wc=Gaus(dst+0.0,scale);" "\n" + " float wd=Gaus(dst+1.0,scale);" "\n" + " // Return filtered sample." "\n" + " return (b*wb+c*wc+d*wd)/(wb+wc+wd);}" "\n" + "" "\n" + "// 5-tap Gaussian filter along horz line." "\n" + "vec3 Horz5(vec2 pos,float off){" "\n" + " vec3 a=Fetch(pos,vec2(-2.0,off));" "\n" + " vec3 b=Fetch(pos,vec2(-1.0,off));" "\n" + " vec3 c=Fetch(pos,vec2( 0.0,off));" "\n" + " vec3 d=Fetch(pos,vec2( 1.0,off));" "\n" + " vec3 e=Fetch(pos,vec2( 2.0,off));" "\n" + " float dst=Dist(pos).x;" "\n" + " // Convert distance to weight." "\n" + " float scale=hardPix;" "\n" + " float wa=Gaus(dst-2.0,scale);" "\n" + " float wb=Gaus(dst-1.0,scale);" "\n" + " float wc=Gaus(dst+0.0,scale);" "\n" + " float wd=Gaus(dst+1.0,scale);" "\n" + " float we=Gaus(dst+2.0,scale);" "\n" + " // Return filtered sample." "\n" + " return (a*wa+b*wb+c*wc+d*wd+e*we)/(wa+wb+wc+wd+we);}" "\n" + "" "\n" + "// Return scanline weight." "\n" + "float Scan(vec2 pos,float off){" "\n" + " float dst=Dist(pos).y;" "\n" + " return Gaus(dst+off,hardScan);}" "\n" + "" "\n" + "// Allow nearest three lines to effect pixel." "\n" + "vec3 Tri(vec2 pos){" "\n" + " vec3 a=Horz3(pos,-1.0);" "\n" + " vec3 b=Horz5(pos, 0.0);" "\n" + " vec3 c=Horz3(pos, 1.0);" "\n" + " float wa=Scan(pos,-1.0);" "\n" + " float wb=Scan(pos, 0.0);" "\n" + " float wc=Scan(pos, 1.0);" "\n" + " return a*wa+b*wb+c*wc;}" "\n" + "" "\n" + "// Distortion of scanlines, and end of screen alpha." "\n" + "vec2 Warp(vec2 pos){" "\n" + " pos=pos*2.0-1.0; " "\n" + " pos*=vec2(1.0+(pos.y*pos.y)*warp.x,1.0+(pos.x*pos.x)*warp.y);" "\n" + " return pos*0.5+0.5;}" "\n" + "" "\n" + "// Shadow mask." "\n" + "vec3 Mask(vec2 pos){" "\n" + " pos.x+=pos.y*3.0;" "\n" + " vec3 mask=vec3(maskDark,maskDark,maskDark);" "\n" + " pos.x=fract(pos.x/6.0);" "\n" + " if(pos.x<0.333)mask.r=maskLight;" "\n" + " else if(pos.x<0.666)mask.g=maskLight;" "\n" + " else mask.b=maskLight;" "\n" + " return mask;} " "\n" + "" "\n" + "void main() {" "\n" + " hardScan=-12.0;" "\n" + " //maskDark=maskLight;" "\n" + " vec2 start=gl_FragCoord.xy-vec2(trg_x, trg_y);" "\n" + " start.y=trg_h-start.y;" "\n" + "" "\n" + " vec2 pos=Warp(start/vec2(trg_w, trg_h));" "\n" + "" "\n" + " gl_FragColor.rgb=Tri(pos)*Mask(gl_FragCoord.xy);" "\n" + " gl_FragColor = vec4(ToSrgb(gl_FragColor.rgb), 1.0);" "\n" + "}" "\n" + ; + + u32 vertex = GPU_CompileShader(GPU_VERTEX_SHADER, VertextShader); if(!vertex) { @@ -1477,7 +1621,7 @@ static void loadCrtShader() return; } - u32 pixel = GPU_CompileShader(GPU_PIXEL_SHADER, pixelShader); + u32 pixel = GPU_CompileShader(GPU_PIXEL_SHADER, PixelShader); if(!pixel) { From 26dec68fef548bcf81398355c1ecc7fd6c1a3e23 Mon Sep 17 00:00:00 2001 From: nesbox Date: Thu, 24 Aug 2023 18:00:38 +0200 Subject: [PATCH 10/83] temporary disabled fullscreen on linux on startup --- src/studio/config.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/studio/config.c b/src/studio/config.c index 3f68557d4..c827005f5 100644 --- a/src/studio/config.c +++ b/src/studio/config.c @@ -290,6 +290,11 @@ void initConfig(Config* config, Studio* studio, tic_fs* fs) loadConfigData(fs, OptionsDatPath, &config->data.options, sizeof config->data.options); +#if defined(__TIC_LINUX__) + // do not load fullscreen option on Linux + config->data.options.fullscreen = false; +#endif + tic_api_reset(config->tic); } From 7ea81e2e66671e0748cb256610dcbe1bf7bb47ee Mon Sep 17 00:00:00 2001 From: nesbox Date: Fri, 25 Aug 2023 16:54:02 +0200 Subject: [PATCH 11/83] #2268: fixed font() api arguments count --- src/api.h | 16 ++++++++-------- src/api/js.c | 13 ++++--------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/api.h b/src/api.h index 9ce7d5813..d3431176d 100644 --- a/src/api.h +++ b/src/api.h @@ -290,7 +290,7 @@ enum 0, \ void, \ tic_mem*, s32 index, s32 x, s32 y, s32 w, s32 h, \ - u8* trans_colors, u8 trans_count, s32 scale, tic_flip flip, tic_rotate rotate) \ + u8* trans_colors, u8 trans_count, s32 scale, tic_flip flip, tic_rotate rotate) \ \ \ macro(btn, \ @@ -363,7 +363,7 @@ enum "The map can be up to 240 cells wide by 136 deep.\n" \ "This function will draw the desired area of the map to a specified screen position.\n" \ "For example, map(5,5,12,10,0,0) will draw a 12x10 section of the map, " \ - "starting from map coordinates (5,5) to screen position (0,0).\n" \ + "starting from map coordinates (5,5) to screen position (0,0).\n" \ "The map function's last parameter is a powerful callback function " \ "for changing how map cells (sprites) are drawn when map is called.\n" \ "It can be used to rotate, flip and replace sprites while the game is running.\n" \ @@ -379,7 +379,7 @@ enum 1, \ void, \ tic_mem*, s32 x, s32 y, s32 width, s32 height, s32 sx, s32 sy, \ - u8* trans_colors, u8 trans_count, s32 scale, RemapFunc remap, void* data) \ + u8* trans_colors, u8 trans_count, s32 scale, RemapFunc remap, void* data) \ \ \ macro(mget, \ @@ -606,17 +606,17 @@ enum \ \ macro(font, \ - "font(text x y chromakey char_width char_height fixed=false scale=1) -> width", \ + "font(text x y chromakey char_width char_height fixed=false scale=1 alt=false) -> width", \ \ "Print string with font defined in foreground sprites.\n" \ "To simply print to the screen, check out `print()`.\n" \ "To print to the console, check out `trace()`.", \ - 8, \ + 9, \ 6, \ 0, \ s32, \ tic_mem*, const char* text, s32 x, s32 y, \ - u8* trans_colors, u8 trans_count, s32 w, s32 h, bool fixed, s32 scale, bool alt) \ + u8* trans_colors, u8 trans_count, s32 w, s32 h, bool fixed, s32 scale, bool alt) \ \ \ macro(mouse, \ @@ -700,8 +700,8 @@ enum tic_mem*, float x1, float y1, float x2, float y2, float x3, float y3, u8 color) \ \ \ - macro(ttri, \ - "ttri(x1 y1 x2 y2 x3 y3 u1 v1 u2 v2 u3 v3 texsrc=0 chromakey=-1 z1=0 z2=0 z3=0)", \ + macro(ttri, \ + "ttri(x1 y1 x2 y2 x3 y3 u1 v1 u2 v2 u3 v3 texsrc=0 chromakey=-1 z1=0 z2=0 z3=0)", \ \ "It renders a triangle filled with texture from image ram, map ram or vbank.\n" \ "Use in 3D graphics.\n" \ diff --git a/src/api/js.c b/src/api/js.c index 19705ac0d..275311dc9 100644 --- a/src/api/js.c +++ b/src/api/js.c @@ -675,18 +675,13 @@ static JSValue js_font(JSContext *ctx, JSValueConst this_val, s32 argc, JSValueC s32 x = getInteger(ctx, argv[1]); s32 y = getInteger(ctx, argv[2]); u8 chromakey = getInteger(ctx, argv[3]); - s32 width = getInteger2(ctx, argv[4], TIC_SPRITESIZE); - s32 height = getInteger2(ctx, argv[5], TIC_SPRITESIZE); + s32 width = getInteger2(ctx, argv[4], TIC_SPRITESIZE); + s32 height = getInteger2(ctx, argv[5], TIC_SPRITESIZE); bool fixed = JS_ToBool(ctx, argv[6]); - s32 scale = getInteger2(ctx, argv[7], 1); + s32 scale = getInteger2(ctx, argv[7], 1); bool alt = JS_ToBool(ctx, argv[8]); - if(scale == 0) - { - return JS_NewInt32(ctx, 0); - } - - s32 size = tic_api_font(tic, text, x, y, &chromakey, 1, width, height, fixed, scale, alt); + s32 size = scale ? tic_api_font(tic, text, x, y, &chromakey, 1, width, height, fixed, scale, alt) : 0; JS_FreeCString(ctx, text); return JS_NewInt32(ctx, size); From fe6a1569152af5369b8b78b476a30c2449d387b6 Mon Sep 17 00:00:00 2001 From: nesbox Date: Sun, 27 Aug 2023 11:41:07 +0200 Subject: [PATCH 12/83] #2283: update Android version --- build/android/app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/android/app/build.gradle b/build/android/app/build.gradle index 3dc450ef5..592e43d10 100644 --- a/build/android/app/build.gradle +++ b/build/android/app/build.gradle @@ -15,8 +15,8 @@ android { } minSdkVersion 24 targetSdkVersion 31 - versionCode 10000 - versionName "1.00.00" + versionCode 10200 + versionName "1.02.00" ndk { abiFilters 'arm64-v8a' } From e105a6456712cc1bc34ebeb4fc2cbad1873f8aa3 Mon Sep 17 00:00:00 2001 From: sogaiu <983021772@users.noreply.github.com> Date: Tue, 29 Aug 2023 22:44:18 +0900 Subject: [PATCH 13/83] Change janet's withsyms to with-syms --- src/api/janet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/janet.c b/src/api/janet.c index 6b7267863..e46dc8016 100644 --- a/src/api/janet.c +++ b/src/api/janet.c @@ -145,7 +145,7 @@ static const JanetReg janet_c_functions[] = static const char* const JanetKeywords[] = { - "defmacro", "withsyms", "macex1", "macex", + "defmacro", "with-syms", "macex1", "macex", "do", "values", "break" "if", "when", "cond", "match", "each", "for", "loop", "while", From c7da9b57c250e4e36f56761756b050d0e4aabb26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20Su=C3=A1rez?= Date: Mon, 4 Sep 2023 19:33:54 -0500 Subject: [PATCH 14/83] Refactor code.c extracting shouldUseStructuredEdit function --- src/studio/editors/code.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/studio/editors/code.c b/src/studio/editors/code.c index 434125b4a..53a1b2862 100644 --- a/src/studio/editors/code.c +++ b/src/studio/editors/code.c @@ -1095,10 +1095,15 @@ static bool replaceSelection(Code* code) return false; } +static inline bool shouldUseStructuredEdit(Code* code) +{ + return tic_core_script_config(code->tic)->useStructuredEdition; +} + + static bool structuredDeleteOverride(Code* code, char* pos) { - const bool useStructuredEdit = tic_core_script_config(code->tic)->useStructuredEdition; - if (!useStructuredEdit) + if (!shouldUseStructuredEdit(code)) return false; const char* end = code->src + strlen(code->src); @@ -1207,15 +1212,13 @@ static void backspaceWord(Code* code) char* findLineEnd(Code* code, char* pos) { - const bool useStructuredEdit = tic_core_script_config(code->tic)->useStructuredEdition; - char* lineend = pos+1; const char* end = code->src + strlen(code->src); while (lineend < end) { if (islineend(*lineend)) break; - if (useStructuredEdit && iscloseparen_(code, *lineend)) break; + if (shouldUseStructuredEdit(code) && iscloseparen_(code, *lineend)) break; ++lineend; } return lineend; @@ -1227,8 +1230,7 @@ static void deleteLine(Code* code) char* lineend = linestart+1; const char* end = code->src + strlen(code->src); - const bool useStructuredEdit = tic_core_script_config(code->tic)->useStructuredEdition; - if (useStructuredEdit) + if (shouldUseStructuredEdit(code)) { if (islineend(*linestart) || islineend(*lineend)) noop; @@ -1287,8 +1289,10 @@ static void inputSymbolBase(Code* code, char sym) if (strlen(code->src) >= MAX_CODE) return; - const bool useStructuredEdit = tic_core_script_config(code->tic)->useStructuredEdition; - if((useStructuredEdit || getConfig(code->studio)->theme.code.autoDelimiters) && (sym == '(' || sym == '[' || sym == '{')) + const bool useStructuredEdit = shouldUseStructuredEdit(code); + const bool isOpeningDelimiter = sym == '(' || sym == '[' || sym == '{'; + + if((useStructuredEdit || getConfig(code->studio)->theme.code.autoDelimiters) && isOpeningDelimiter) { insertCode(code, code->cursor.position++, (const char[]){sym, matchingDelim(sym), '\0'}); } else if (useStructuredEdit && isdoublequote(sym)) { @@ -1904,8 +1908,7 @@ static void addCommentToLine(Code* code, char* line, size_t size, const char* co static void sexpify(Code* code) { - const bool useStructuredEdit = tic_core_script_config(code->tic)->useStructuredEdition; - if (!useStructuredEdit) + if (!shouldUseStructuredEdit(code)) return; char* pos = code->cursor.position; @@ -1942,8 +1945,7 @@ static void sexpify(Code* code) static void extirpSExp(Code* code) { - const bool useStructuredEdit = tic_core_script_config(code->tic)->useStructuredEdition; - if (!useStructuredEdit) + if (!shouldUseStructuredEdit(code)) return; const char* start = code->src; From 5cbad1881dbbf2b0c17f52f522f6d7f65abb211c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20Su=C3=A1rez?= Date: Mon, 4 Sep 2023 19:40:07 -0500 Subject: [PATCH 15/83] Refactor code.c extracting getKeybindMode function --- src/studio/editors/code.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/studio/editors/code.c b/src/studio/editors/code.c index 53a1b2862..fe5a93632 100644 --- a/src/studio/editors/code.c +++ b/src/studio/editors/code.c @@ -2834,13 +2834,18 @@ static void processViKeyboard(Code* code) } } +static inline enum KeybindMode getKeybindMode(Code* code) +{ + return getConfig(code->studio)->options.keybindMode; +} + static void processKeyboard(Code* code) { tic_mem* tic = code->tic; if(tic->ram->input.keyboard.data == 0) return; - enum KeybindMode keymode = getConfig(code->studio)->options.keybindMode; + enum KeybindMode keymode = getKeybindMode(code); if (keymode == KEYBIND_VI) { From 29de61cf7e319bfd7dc1876d6213fba010b91928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20Su=C3=A1rez?= Date: Mon, 4 Sep 2023 20:20:00 -0500 Subject: [PATCH 16/83] Disable structural editing on non-Emacs modes --- src/studio/editors/code.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/studio/editors/code.c b/src/studio/editors/code.c index fe5a93632..109e6c0fb 100644 --- a/src/studio/editors/code.c +++ b/src/studio/editors/code.c @@ -1095,9 +1095,16 @@ static bool replaceSelection(Code* code) return false; } +static inline enum KeybindMode getKeybindMode(Code* code) +{ + return getConfig(code->studio)->options.keybindMode; +} + + static inline bool shouldUseStructuredEdit(Code* code) { - return tic_core_script_config(code->tic)->useStructuredEdition; + const bool emacsMode = getKeybindMode(code) == KEYBIND_EMACS; + return tic_core_script_config(code->tic)->useStructuredEdition && emacsMode; } @@ -2834,11 +2841,6 @@ static void processViKeyboard(Code* code) } } -static inline enum KeybindMode getKeybindMode(Code* code) -{ - return getConfig(code->studio)->options.keybindMode; -} - static void processKeyboard(Code* code) { tic_mem* tic = code->tic; From 782dd1a97a834969ffb57e3c41887831caa2ea7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20Su=C3=A1rez?= Date: Mon, 4 Sep 2023 20:23:31 -0500 Subject: [PATCH 17/83] Ignore root-level compile_commands.json --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 14f8ae502..bd138dc16 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.ipch *.opendb *.suo +compile_commands.json sexit .vscode/ build/install_manifest.txt @@ -179,4 +180,4 @@ build/mruby_vendor-prefix/ **/zig-cache **/zig-out .cache -*~ \ No newline at end of file +*~ From 850afc65204b4ea105fa0d9f9287c4789f2d6385 Mon Sep 17 00:00:00 2001 From: Andrea Tupini Date: Fri, 8 Sep 2023 19:12:33 +0200 Subject: [PATCH 18/83] update zig files to latest --- demos/bunny/wasmmark/build.zig | 24 ++- demos/bunny/wasmmark/src/main.zig | 68 ++++---- demos/bunny/wasmmark/src/tic80.zig | 247 ++++++++++++++--------------- demos/wasm/build.zig | 24 ++- demos/wasm/src/main.zig | 12 +- demos/wasm/src/tic80.zig | 247 ++++++++++++++--------------- templates/zig/build.zig | 24 ++- templates/zig/src/main.zig | 4 + templates/zig/src/tic80.zig | 238 +++++++++++++-------------- 9 files changed, 435 insertions(+), 453 deletions(-) diff --git a/demos/bunny/wasmmark/build.zig b/demos/bunny/wasmmark/build.zig index d088cf918..4338d1d23 100644 --- a/demos/bunny/wasmmark/build.zig +++ b/demos/bunny/wasmmark/build.zig @@ -1,19 +1,27 @@ const std = @import("std"); -pub fn build(b: *std.build.Builder) void { - const mode = b.standardReleaseOptions(); +pub fn build(b: *std.Build) !void { + const optimize = b.standardOptimizeOption(.{}); + + const lib = b.addSharedLibrary(.{ + .name = "cart", + .root_source_file = .{ .path = "src/main.zig" }, + .target = .{ .cpu_arch = .wasm32, .os_tag = .wasi }, + .optimize = optimize, + }); - const lib = b.addSharedLibrary("cart", "src/main.zig", .unversioned); - lib.setBuildMode(mode); - lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }); lib.import_memory = true; + lib.stack_size = 8192; lib.initial_memory = 65536 * 4; lib.max_memory = 65536 * 4; + lib.export_table = true; + // all the memory below 96kb is reserved for TIC and memory mapped I/O // so our own usage must start above the 96kb mark lib.global_base = 96 * 1024; - lib.stack_size = 8192; - lib.export_symbol_names = &[_][]const u8{ "TIC", "OVR", "BDR", "SCR", "BOOT" }; - lib.install(); + + lib.export_symbol_names = &[_][]const u8{ "TIC", "OVR", "BDR", "BOOT" }; + + b.installArtifact(lib); } diff --git a/demos/bunny/wasmmark/src/main.zig b/demos/bunny/wasmmark/src/main.zig index 9b0215399..729c69adc 100644 --- a/demos/bunny/wasmmark/src/main.zig +++ b/demos/bunny/wasmmark/src/main.zig @@ -138,48 +138,50 @@ export fn TIC() void { } t = t + 1; - -if (tic.btn(0)) { - var i : i32 = 0; - while (i<5) { - addBunny(); - i+=1; + if (tic.btn(0)) { + var i : i32 = 0; + while (i<5) { + addBunny(); + i+=1; + } } -} -if (tic.btn(1)) { - var i : i32 = 0; - while (i<5) { - removeBunny(); - i+=1; + if (tic.btn(1)) { + var i : i32 = 0; + while (i<5) { + removeBunny(); + i+=1; + } } -} -// -- Update -var i : u32 = 0; -while (i Date: Fri, 8 Sep 2023 19:23:41 +0200 Subject: [PATCH 19/83] fix issues in wasmmark --- demos/bunny/wasmmark/src/main.zig | 73 ++++++++++++++----------------- 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/demos/bunny/wasmmark/src/main.zig b/demos/bunny/wasmmark/src/main.zig index 729c69adc..c473f7ac8 100644 --- a/demos/bunny/wasmmark/src/main.zig +++ b/demos/bunny/wasmmark/src/main.zig @@ -8,15 +8,15 @@ const tic = @import("tic80.zig"); const std = @import("std"); const RndGen = std.rand.DefaultPrng; -var rnd : std.rand.Random = undefined; +var rnd: std.rand.Random = undefined; const screenWidth = 240; const screenHeight = 136; const toolbarHeight = 6; -var t : u32 = 0; +var t: u32 = 0; fn randomFloat(lower: f32, greater: f32) f32 { - return rnd.float(f32) * (greater-lower) + lower; + return rnd.float(f32) * (greater - lower) + lower; } const Bunny = struct { @@ -39,11 +39,7 @@ const Bunny = struct { } fn draw(self: Bunny) void { - tic.spr(self.sprite, @floatToInt(i32,self.x), @floatToInt(i32,self.y), .{ - .transparent = &.{1}, - .w = 4, - .h = 4 - }); + tic.spr(self.sprite, @intFromFloat(self.x), @intFromFloat(self.y), .{ .transparent = &.{1}, .w = 4, .h = 4 }); } fn update(self: *Bunny) void { @@ -66,7 +62,6 @@ const Bunny = struct { self.speedY = self.speedY * -1; } } - }; const FPS = struct { @@ -93,9 +88,9 @@ const FPS = struct { }; const MAX_BUNNIES = 1200; -var fps : FPS = undefined; -var bunnyCount : usize = 0; -var bunnies : [MAX_BUNNIES]Bunny = undefined; +var fps: FPS = undefined; +var bunnyCount: usize = 0; +var bunnies: [MAX_BUNNIES]Bunny = undefined; fn addBunny() void { if (bunnyCount >= MAX_BUNNIES) return; @@ -105,58 +100,59 @@ fn addBunny() void { } fn removeBunny() void { - if (bunnyCount==0) return; + if (bunnyCount == 0) return; bunnyCount -= 1; } export fn testscreen() void { - var i : usize = 0; - - while (i<2000) { - // tic.ZERO.* = 0x99; - tic.FRAMEBUFFER[i]=0x56; - // tic.FRAMEBUFFER2.*[i]=0x67; - // tic.ZERO[i]= 0x56; - // bunnies[i].draw(); - i += 1; + var i: usize = 0; + + while (i < 2000) { + // tic.ZERO.* = 0x99; + tic.FRAMEBUFFER[i] = 0x56; + // tic.FRAMEBUFFER2.*[i]=0x67; + // tic.ZERO[i]= 0x56; + // bunnies[i].draw(); + i += 1; } } export fn BOOT() void { - rnd = RndGen.init(0).random(); + var xoshiro = RndGen.init(0); + rnd = xoshiro.random(); fps.initFPS(); addBunny(); } export fn TIC() void { - if (t==0) { + if (t == 0) { tic.music(0, .{}); } - if (t == 6*64*2.375) { + if (t == 6 * 64 * 2.375) { tic.music(1, .{}); } t = t + 1; if (tic.btn(0)) { - var i : i32 = 0; - while (i<5) { + var i: i32 = 0; + while (i < 5) { addBunny(); - i+=1; + i += 1; } } if (tic.btn(1)) { - var i : i32 = 0; - while (i<5) { + var i: i32 = 0; + while (i < 5) { removeBunny(); - i+=1; + i += 1; } } // -- Update - var i : u32 = 0; - while (i Date: Fri, 8 Sep 2023 19:31:26 +0200 Subject: [PATCH 20/83] update zig template readme --- templates/zig/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/templates/zig/README.md b/templates/zig/README.md index 31dec9850..3d788e257 100644 --- a/templates/zig/README.md +++ b/templates/zig/README.md @@ -1,9 +1,9 @@ # ZIG Starter Project Template -This is a ZIG / TIC-80 starter template. To build it, ensure you have a recent development release of Zig 0.10, then run: +This is a ZIG / TIC-80 starter template. To build it, ensure you have the latest stable Zig release (0.11) or the development release (0.12), then run: ``` -zig build +zig build -Doptimize=ReleaseSmall ``` To import the resulting WASM to a cartridge: @@ -20,4 +20,5 @@ import binary zig-out/lib/cart.wasm save ``` -This is assuming you've run TIC-80 with `--fs .` inside your project directory. \ No newline at end of file +This is assuming you've run TIC-80 with `--fs .` inside your project directory. + From 582604665a56a22fc5ac8e6946db4b7d261cda92 Mon Sep 17 00:00:00 2001 From: Cort <1944792+cdwfs@users.noreply.github.com> Date: Sat, 9 Sep 2023 20:38:30 -0700 Subject: [PATCH 21/83] Add me to contributor list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 371fe97d1..c19b01b0d 100644 --- a/README.md +++ b/README.md @@ -258,3 +258,4 @@ You can find iOS/tvOS version here * David St-Hilaire - [GitHub @sthilaid](https://github.com/sthilaid) * Alec Troemel - [Github @alectroemel](https://github.com/AlecTroemel) * Kolten Pearson - [Github @koltenpearson](https://github.com/koltenpearson) +* Cort Stratton - [Github @cdwfs](https://github.com/cdwfs) From 2600b8f4588f63a6625770718873771036201ec6 Mon Sep 17 00:00:00 2001 From: Cort <1944792+cdwfs@users.noreply.github.com> Date: Sat, 9 Sep 2023 20:59:18 -0700 Subject: [PATCH 22/83] Add ESC, function keys, and numpad keys to "help keys" table --- src/studio/screens/console.c | 46 ++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/src/studio/screens/console.c b/src/studio/screens/console.c index db015d50b..3369abf57 100644 --- a/src/studio/screens/console.c +++ b/src/studio/screens/console.c @@ -3143,15 +3143,51 @@ static s32 createKeysTable(char* buf) {63, "CTRL"}, {64, "SHIFT"}, {65, "ALT"}, + {66, "ESC"}, + {67, "F1"}, + {68, "F2"}, + {69, "F3"}, + {70, "F4"}, + {71, "F5"}, + {72, "F6"}, + {73, "F7"}, + {74, "F8"}, + {75, "F9"}, + {76, "F10"}, + {77, "F11"}, + {78, "F12"}, + {78, "NUM0"}, + {79, "NUM1"}, + {80, "NUM2"}, + {81, "NUM3"}, + {82, "NUM4"}, + {83, "NUM5"}, + {84, "NUM6"}, + {85, "NUM7"}, + {86, "NUM8"}, + {87, "NUM9"}, + {88, "NUMPLUS"}, + {89, "NUMMINUS"}, + {90, "NUMMULTIPLY"}, + {91, "NUMDIVIDE"}, + {92, "NUMENTER"}, + {93, "NUMPERIOD"}, }; - int lastAlphaNumeric = 36; - for(const struct Row* row = Rows, *end = row + lastAlphaNumeric; row < end; row++) + int numAlphaNumericRows = 36; + int numNonAlphaNumericRows = COUNT_OF(Rows) - numAlphaNumericRows; + int numRowPairs = MAX(numAlphaNumericRows, numNonAlphaNumericRows); + const struct Row* row = Rows; + for(int i=0; icode, row->key); - if (otherRow < Rows + COUNT_OF(Rows)) + if (i < numAlphaNumericRows) + ptr += sprintf(ptr, "%4d | %-3s |", row->code, row->key); + else + ptr += sprintf(ptr, "%4s | %3s |", "", ""); + + const struct Row* otherRow = row + numAlphaNumericRows; + if (i < numNonAlphaNumericRows) ptr += sprintf(ptr, " | %4d | %-12s |", otherRow->code, otherRow->key); else ptr += sprintf(ptr, " | %4s | %12s |", "", ""); From afb5c919d60f47952ac57cb2060ad45b164cde16 Mon Sep 17 00:00:00 2001 From: Cort <1944792+cdwfs@users.noreply.github.com> Date: Sat, 9 Sep 2023 21:13:21 -0700 Subject: [PATCH 23/83] Fix off-by-one error in keycode table --- src/studio/screens/console.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/studio/screens/console.c b/src/studio/screens/console.c index 3369abf57..2e13ef670 100644 --- a/src/studio/screens/console.c +++ b/src/studio/screens/console.c @@ -3156,22 +3156,22 @@ static s32 createKeysTable(char* buf) {76, "F10"}, {77, "F11"}, {78, "F12"}, - {78, "NUM0"}, - {79, "NUM1"}, - {80, "NUM2"}, - {81, "NUM3"}, - {82, "NUM4"}, - {83, "NUM5"}, - {84, "NUM6"}, - {85, "NUM7"}, - {86, "NUM8"}, - {87, "NUM9"}, - {88, "NUMPLUS"}, - {89, "NUMMINUS"}, - {90, "NUMMULTIPLY"}, - {91, "NUMDIVIDE"}, - {92, "NUMENTER"}, - {93, "NUMPERIOD"}, + {79, "NUM0"}, + {80, "NUM1"}, + {81, "NUM2"}, + {82, "NUM3"}, + {83, "NUM4"}, + {84, "NUM5"}, + {85, "NUM6"}, + {86, "NUM7"}, + {87, "NUM8"}, + {88, "NUM9"}, + {89, "NUMPLUS"}, + {90, "NUMMINUS"}, + {91, "NUMMULTIPLY"}, + {92, "NUMDIVIDE"}, + {93, "NUMENTER"}, + {94, "NUMPERIOD"}, }; int numAlphaNumericRows = 36; From 01af9f4fce938d785aaa9930f40250aa7f643cc2 Mon Sep 17 00:00:00 2001 From: nesbox Date: Sun, 10 Sep 2023 17:37:41 +0200 Subject: [PATCH 24/83] #2299: `help keys` optimization --- src/studio/screens/console.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/studio/screens/console.c b/src/studio/screens/console.c index 2e13ef670..72368e244 100644 --- a/src/studio/screens/console.c +++ b/src/studio/screens/console.c @@ -3072,9 +3072,9 @@ static s32 createVRamTable(char* buf) static s32 createKeysTable(char* buf) { char* ptr = buf; - ptr += sprintf(ptr, "\n+------+-----+ +------+--------------+" - "\n| CODE | KEY | | CODE | KEY |" - "\n+------+-----+ +------+--------------+"); + ptr += sprintf(ptr, "\n+----+------------+ +----+------------+" + "\n|CODE| KEY | |CODE| KEY |" + "\n+----+------------+ +----+------------+"); static const struct Row {s32 code; const char* key;} Rows[] = { @@ -3117,7 +3117,7 @@ static s32 createKeysTable(char* buf) {37, "MINUS"}, {38, "EQUALS"}, {39, "LEFTBRACKET"}, - {40, "RIGHTBRACKET"}, + {40, "RIGHTBRACKT"}, {41, "BACKSLASH"}, {42, "SEMICOLON"}, {43, "APOSTROPHE"}, @@ -3174,26 +3174,12 @@ static s32 createKeysTable(char* buf) {94, "NUMPERIOD"}, }; - int numAlphaNumericRows = 36; - int numNonAlphaNumericRows = COUNT_OF(Rows) - numAlphaNumericRows; - int numRowPairs = MAX(numAlphaNumericRows, numNonAlphaNumericRows); - const struct Row* row = Rows; - for(int i=0; icode, row->key); - else - ptr += sprintf(ptr, "%4s | %3s |", "", ""); - - const struct Row* otherRow = row + numAlphaNumericRows; - if (i < numNonAlphaNumericRows) - ptr += sprintf(ptr, " | %4d | %-12s |", otherRow->code, otherRow->key); - else - ptr += sprintf(ptr, " | %4s | %12s |", "", ""); + ptr += sprintf(ptr, "\n| %2d | %-11s| | %2d | %-11s|", row->code, row->key, alt->code, alt->key); } - ptr += sprintf(ptr, "\n+------+-----+ +------+--------------+\n"); + ptr += sprintf(ptr, "\n+----+------------+ +----+------------+\n"); return strlen(buf); } From 34759b622207fa43be0f83eae8297e4155379de5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20Su=C3=A1rez?= Date: Mon, 11 Sep 2023 20:44:32 -0500 Subject: [PATCH 25/83] Add true, false, nil to FennelKeywords --- src/api/fennel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/api/fennel.c b/src/api/fennel.c index a00962b0e..6f9e04f52 100644 --- a/src/api/fennel.c +++ b/src/api/fennel.c @@ -98,7 +98,8 @@ static const char* const FennelKeywords [] = "lambda", "length", "let", "local", "lshift", "lua", "macro", "macrodebug", "macros", "match", "match-try", "not", "not=", "or", "partial", "pick-args", "pick-values", "quote", "require-macros", - "rshift", "set", "tset", "values", "var", "when", "while", "with-open" + "rshift", "set", "tset", "values", "var", "when", "while", "with-open", + "true", "false", "nil" }; static inline bool fennel_isalnum(char c) From d96f41c3b4b69cf078515268f21283ef1383d44e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20Su=C3=A1rez?= Date: Tue, 12 Sep 2023 18:56:35 -0500 Subject: [PATCH 26/83] Extract Enter-checking funciton in code.c --- src/studio/editors/code.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/studio/editors/code.c b/src/studio/editors/code.c index 109e6c0fb..79e4070e8 100644 --- a/src/studio/editors/code.c +++ b/src/studio/editors/code.c @@ -2471,6 +2471,10 @@ static char toggleCase(char c) { return c; } +static bool enterWasPressed(Code* code) { + return keyWasPressed(code->studio, tic_key_return); +} + static void processViKeyboard(Code* code) { @@ -2514,7 +2518,7 @@ static void processViKeyboard(Code* code) else if (keyWasPressed(code->studio, tic_key_tab)) doTab(code, shift, ctrl); - else if (keyWasPressed(code->studio, tic_key_return)) + else if (enterWasPressed(code)) newLine(code); else if (clear || shift) @@ -2995,14 +2999,14 @@ static void processKeyboard(Code* code) else if(keyWasPressed(code->studio, tic_key_pagedown)) pageDown(code); else if(keyWasPressed(code->studio, tic_key_delete)) deleteChar(code); else if(keyWasPressed(code->studio, tic_key_backspace)) backspaceChar(code); - else if(keyWasPressed(code->studio, tic_key_return)) newLine(code); + else if(enterWasPressed(code)) newLine(code); else if(keyWasPressed(code->studio, tic_key_tab)) doTab(code, shift, ctrl); else usedKeybinding = false; } if(!usedKeybinding) { - if(shift && keyWasPressed(code->studio, tic_key_return)) + if(shift && enterWasPressed(code)) { newLineAutoClose(code); usedKeybinding = true; @@ -3181,7 +3185,7 @@ static void textFindTick(Code* code) { - if(keyWasPressed(code->studio, tic_key_return)) setCodeMode(code, TEXT_EDIT_MODE); + if(enterWasPressed(code)) setCodeMode(code, TEXT_EDIT_MODE); else if(keyWasPressed(code->studio, tic_key_up) || keyWasPressed(code->studio, tic_key_down) || keyWasPressed(code->studio, tic_key_left) @@ -3226,7 +3230,7 @@ static void textFindTick(Code* code) static void textReplaceTick(Code* code) { - if(keyWasPressed(code->studio, tic_key_return)) { + if (enterWasPressed(code)) { if (*code->popup.text && code->popup.offset == NULL) //still in "find" mode { code->popup.offset = code->popup.text + strlen(code->popup.text); @@ -3317,7 +3321,7 @@ static void textGoToTick(Code* code) { tic_mem* tic = code->tic; - if(keyWasPressed(code->studio, tic_key_return)) + if(enterWasPressed(code)) { if(*code->popup.text) updateGotoCode(code); @@ -3462,7 +3466,7 @@ static void processSidebar(Code* code) else if(keyWasPressed(code->studio, tic_key_end)) updateSidebarIndex(code, code->sidebar.size - 1); - else if(keyWasPressed(code->studio, tic_key_return)) + else if(enterWasPressed(code)) { updateSidebarCode(code); setCodeMode(code, TEXT_EDIT_MODE); From ca8a32653319d24f3b9b7600aa7de5deddd8c7c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20Su=C3=A1rez?= Date: Tue, 12 Sep 2023 19:00:01 -0500 Subject: [PATCH 27/83] Support using numpad Enter key in code editor --- src/studio/editors/code.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/studio/editors/code.c b/src/studio/editors/code.c index 79e4070e8..2d92f3d49 100644 --- a/src/studio/editors/code.c +++ b/src/studio/editors/code.c @@ -2471,8 +2471,10 @@ static char toggleCase(char c) { return c; } -static bool enterWasPressed(Code* code) { - return keyWasPressed(code->studio, tic_key_return); +static bool enterWasPressed(Code* code) +{ + return keyWasPressed(code->studio, tic_key_return) || + keyWasPressed(code->studio, tic_key_numpadenter); } static void processViKeyboard(Code* code) From 9e0b4f145e10ac8db77e550a021ed96093b7749c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20Su=C3=A1rez?= Date: Tue, 12 Sep 2023 19:09:32 -0500 Subject: [PATCH 28/83] Extract Enter-checking funciton in studio.c --- src/studio/studio.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/studio/studio.c b/src/studio/studio.c index 4089b9dc2..faa413ba2 100644 --- a/src/studio/studio.c +++ b/src/studio/studio.c @@ -1695,6 +1695,11 @@ void gotoMenu(Studio* studio) studio->mainmenu = studio_mainmenu_init(studio->menu, studio->config); } +static bool enterWasPressedOnce(Studio* studio) +{ + return keyWasPressedOnce(studio, tic_key_return); +} + static void processShortcuts(Studio* studio) { tic_mem* tic = studio->tic; @@ -1716,7 +1721,7 @@ static void processShortcuts(Studio* studio) if(alt) { - if (keyWasPressedOnce(studio, tic_key_return)) gotoFullscreen(studio); + if (enterWasPressedOnce(studio)) gotoFullscreen(studio); #if defined(BUILD_EDITORS) else if(studio->mode != TIC_RUN_MODE) { @@ -1735,7 +1740,7 @@ static void processShortcuts(Studio* studio) #if defined(BUILD_EDITORS) else if(keyWasPressedOnce(studio, tic_key_pageup)) changeStudioMode(studio, -1); else if(keyWasPressedOnce(studio, tic_key_pagedown)) changeStudioMode(studio, +1); - else if(keyWasPressedOnce(studio, tic_key_return)) runGame(studio); + else if(enterWasPressedOnce(studio)) runGame(studio); else if(keyWasPressedOnce(studio, tic_key_r)) runGame(studio); else if(keyWasPressedOnce(studio, tic_key_s)) saveProject(studio); #endif From af7133b61366134f47f96cb267a0f29d0835c3d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20Su=C3=A1rez?= Date: Tue, 12 Sep 2023 19:11:22 -0500 Subject: [PATCH 29/83] Support using numpad Enter key for full-screen and run-game shortcuts --- src/studio/studio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/studio/studio.c b/src/studio/studio.c index faa413ba2..e630431b9 100644 --- a/src/studio/studio.c +++ b/src/studio/studio.c @@ -1697,7 +1697,8 @@ void gotoMenu(Studio* studio) static bool enterWasPressedOnce(Studio* studio) { - return keyWasPressedOnce(studio, tic_key_return); + return keyWasPressedOnce(studio, tic_key_return) || + keyWasPressedOnce(studio, tic_key_numpadenter); } static void processShortcuts(Studio* studio) From ebc4358894675114a53e9404ade03b5027d6b63c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20Su=C3=A1rez?= Date: Tue, 12 Sep 2023 19:18:10 -0500 Subject: [PATCH 30/83] Support using numpad Enter key in console --- src/studio/screens/console.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/studio/screens/console.c b/src/studio/screens/console.c index 72368e244..5c8d9ddfd 100644 --- a/src/studio/screens/console.c +++ b/src/studio/screens/console.c @@ -4028,6 +4028,12 @@ static void backspaceWord(Console* console) console->input.pos = pos; } +static bool enterWasPressed(Console* console) +{ + return keyWasPressed(console->studio, tic_key_return) || + keyWasPressed(console->studio, tic_key_numpadenter); +} + static void processKeyboard(Console* console) { tic_mem* tic = console->tic; @@ -4089,7 +4095,7 @@ static void processKeyboard(Console* console) if(console->input.pos > len) console->input.pos = len; } - else if(keyWasPressed(console->studio, tic_key_return)) processConsoleCommand(console); + else if(enterWasPressed(console)) processConsoleCommand(console); else if(keyWasPressed(console->studio, tic_key_backspace)) processConsoleBackspace(console); else if(keyWasPressed(console->studio, tic_key_delete)) processConsoleDel(console); else if(keyWasPressed(console->studio, tic_key_home)) processConsoleHome(console); From d765b7aa66dfe8a809d2864bba36b73190dbe2d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20Su=C3=A1rez?= Date: Tue, 12 Sep 2023 19:26:02 -0500 Subject: [PATCH 31/83] Support using numpad Enter key in menu --- src/studio/screens/menu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/studio/screens/menu.c b/src/studio/screens/menu.c index 8547c06ad..eeb13985d 100644 --- a/src/studio/screens/menu.c +++ b/src/studio/screens/menu.c @@ -215,6 +215,13 @@ static void drawOptionArrow(Menu* menu, MenuOption* option, s32 x, s32 y, s32 ic } } +static bool enterWasPressed(tic_mem* tic) +{ + + return tic_api_keyp(tic, tic_key_return, Hold, Period) || + tic_api_keyp(tic, tic_key_numpadenter, Hold, Period); +} + static void drawMenu(Menu* menu, s32 x, s32 y) { if (getStudioMode(menu->studio) != TIC_MENU_MODE) @@ -257,8 +264,7 @@ static void drawMenu(Menu* menu, s32 x, s32 y) } } - if(tic_api_btnp(menu->tic, A, -1, -1) - || tic_api_keyp(tic, tic_key_return, Hold, Period)) + if(tic_api_btnp(menu->tic, A, -1, -1) || enterWasPressed(tic)) { if(option) { From 3fcdf4d188aea95fda1c087bfd978ff0b842a5d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20Su=C3=A1rez?= Date: Tue, 12 Sep 2023 19:30:32 -0500 Subject: [PATCH 32/83] Support using numpad Enter key in surf menu --- src/studio/screens/surf.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/studio/screens/surf.c b/src/studio/screens/surf.c index b45cab3f6..d1ef1d824 100644 --- a/src/studio/screens/surf.c +++ b/src/studio/screens/surf.c @@ -612,6 +612,12 @@ static void move(Surf* surf, s32 dir) surf->anim.movie = resetMovie(&surf->anim.move); } +static bool enterWasPressed(tic_mem* tic) +{ + return tic_api_keyp(tic, tic_key_return, -1, -1) || + tic_api_keyp(tic, tic_key_numpadenter, -1, -1); +} + static void processGamepad(Surf* surf) { tic_mem* tic = surf->tic; @@ -661,8 +667,8 @@ static void processGamepad(Surf* surf) move(surf, dir); } - if(tic_api_btnp(tic, A, -1, -1) - || tic_api_keyp(tic, tic_key_return, -1, -1)) + if(tic_api_btnp(tic, A, -1, -1) + || enterWasPressed(tic)) { SurfItem* item = getMenuItem(surf); item->dir @@ -906,4 +912,4 @@ void freeSurf(Surf* surf) freeAnim(surf); resetMenu(surf); free(surf); -} \ No newline at end of file +} From 4b0f1c4aed97b0be3c80fc285bbe2e250187bbad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20Su=C3=A1rez?= Date: Tue, 12 Sep 2023 19:38:39 -0500 Subject: [PATCH 33/83] Extract Enter-checking funciton in music.c --- src/studio/editors/music.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/studio/editors/music.c b/src/studio/editors/music.c index 959cfb704..746ae89ba 100644 --- a/src/studio/editors/music.c +++ b/src/studio/editors/music.c @@ -1244,6 +1244,11 @@ static void processTrackerKeyboard(Music* music) } +static bool enterWasPressed(Music* music) +{ + return keyWasPressed(music->studio, tic_key_return); +} + static void processPatternKeyboard(Music* music) { tic_mem* tic = music->tic; @@ -1257,7 +1262,7 @@ static void processPatternKeyboard(Music* 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) - || keyWasPressed(music->studio, tic_key_return)) + || enterWasPressed(music)) music->tracker.edit.y = music->scroll.pos; else { @@ -1542,7 +1547,7 @@ static void processKeyboard(Music* music) ? playTrack(music) : stopTrack(music); } - else if(keyWasPressed(music->studio, tic_key_return)) + else if(enterWasPressed(music)) { stopped ? (shift From 2575de1fa1aad504c766246de8fbc2b47bbf111c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20Su=C3=A1rez?= Date: Tue, 12 Sep 2023 19:40:41 -0500 Subject: [PATCH 34/83] Support using numpad Enter key in music editor --- src/studio/editors/music.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/studio/editors/music.c b/src/studio/editors/music.c index 746ae89ba..a5f50bfd6 100644 --- a/src/studio/editors/music.c +++ b/src/studio/editors/music.c @@ -1246,7 +1246,8 @@ static void processTrackerKeyboard(Music* music) static bool enterWasPressed(Music* music) { - return keyWasPressed(music->studio, tic_key_return); + return keyWasPressed(music->studio, tic_key_return) || + keyWasPressed(music->studio, tic_key_numpadenter); } static void processPatternKeyboard(Music* music) From 0b741c776c09487e6840866bdbea567ff4df4d8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20Su=C3=A1rez?= Date: Wed, 13 Sep 2023 21:23:34 -0500 Subject: [PATCH 35/83] Create enterWasPressed in studio.h --- src/studio/editors/code.c | 20 +++++++------------- src/studio/editors/music.c | 10 ++-------- src/studio/screens/console.c | 8 +------- src/studio/screens/menu.c | 4 ++-- src/studio/screens/surf.c | 4 ++-- src/studio/studio.c | 7 +++++++ src/studio/studio.h | 1 + 7 files changed, 22 insertions(+), 32 deletions(-) diff --git a/src/studio/editors/code.c b/src/studio/editors/code.c index 2d92f3d49..2a434a418 100644 --- a/src/studio/editors/code.c +++ b/src/studio/editors/code.c @@ -2471,12 +2471,6 @@ static char toggleCase(char c) { return c; } -static bool enterWasPressed(Code* code) -{ - return keyWasPressed(code->studio, tic_key_return) || - keyWasPressed(code->studio, tic_key_numpadenter); -} - static void processViKeyboard(Code* code) { @@ -2520,7 +2514,7 @@ static void processViKeyboard(Code* code) else if (keyWasPressed(code->studio, tic_key_tab)) doTab(code, shift, ctrl); - else if (enterWasPressed(code)) + else if (enterWasPressed(code->studio)) newLine(code); else if (clear || shift) @@ -3001,14 +2995,14 @@ static void processKeyboard(Code* code) else if(keyWasPressed(code->studio, tic_key_pagedown)) pageDown(code); else if(keyWasPressed(code->studio, tic_key_delete)) deleteChar(code); else if(keyWasPressed(code->studio, tic_key_backspace)) backspaceChar(code); - else if(enterWasPressed(code)) newLine(code); + else if(enterWasPressed(code->studio)) newLine(code); else if(keyWasPressed(code->studio, tic_key_tab)) doTab(code, shift, ctrl); else usedKeybinding = false; } if(!usedKeybinding) { - if(shift && enterWasPressed(code)) + if(shift && enterWasPressed(code->studio)) { newLineAutoClose(code); usedKeybinding = true; @@ -3187,7 +3181,7 @@ static void textFindTick(Code* code) { - if(enterWasPressed(code)) setCodeMode(code, TEXT_EDIT_MODE); + if(enterWasPressed(code->studio)) setCodeMode(code, TEXT_EDIT_MODE); else if(keyWasPressed(code->studio, tic_key_up) || keyWasPressed(code->studio, tic_key_down) || keyWasPressed(code->studio, tic_key_left) @@ -3232,7 +3226,7 @@ static void textFindTick(Code* code) static void textReplaceTick(Code* code) { - if (enterWasPressed(code)) { + if (enterWasPressed(code->studio)) { if (*code->popup.text && code->popup.offset == NULL) //still in "find" mode { code->popup.offset = code->popup.text + strlen(code->popup.text); @@ -3323,7 +3317,7 @@ static void textGoToTick(Code* code) { tic_mem* tic = code->tic; - if(enterWasPressed(code)) + if(enterWasPressed(code->studio)) { if(*code->popup.text) updateGotoCode(code); @@ -3468,7 +3462,7 @@ static void processSidebar(Code* code) else if(keyWasPressed(code->studio, tic_key_end)) updateSidebarIndex(code, code->sidebar.size - 1); - else if(enterWasPressed(code)) + else if(enterWasPressed(code->studio)) { updateSidebarCode(code); setCodeMode(code, TEXT_EDIT_MODE); diff --git a/src/studio/editors/music.c b/src/studio/editors/music.c index a5f50bfd6..16a6a212e 100644 --- a/src/studio/editors/music.c +++ b/src/studio/editors/music.c @@ -1244,12 +1244,6 @@ static void processTrackerKeyboard(Music* music) } -static bool enterWasPressed(Music* music) -{ - return keyWasPressed(music->studio, tic_key_return) || - keyWasPressed(music->studio, tic_key_numpadenter); -} - static void processPatternKeyboard(Music* music) { tic_mem* tic = music->tic; @@ -1263,7 +1257,7 @@ static void processPatternKeyboard(Music* 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)) + || enterWasPressed(music->studio)) music->tracker.edit.y = music->scroll.pos; else { @@ -1548,7 +1542,7 @@ static void processKeyboard(Music* music) ? playTrack(music) : stopTrack(music); } - else if(enterWasPressed(music)) + else if(enterWasPressed(music->studio)) { stopped ? (shift diff --git a/src/studio/screens/console.c b/src/studio/screens/console.c index 5c8d9ddfd..feffc096a 100644 --- a/src/studio/screens/console.c +++ b/src/studio/screens/console.c @@ -4028,12 +4028,6 @@ static void backspaceWord(Console* console) console->input.pos = pos; } -static bool enterWasPressed(Console* console) -{ - return keyWasPressed(console->studio, tic_key_return) || - keyWasPressed(console->studio, tic_key_numpadenter); -} - static void processKeyboard(Console* console) { tic_mem* tic = console->tic; @@ -4095,7 +4089,7 @@ static void processKeyboard(Console* console) if(console->input.pos > len) console->input.pos = len; } - else if(enterWasPressed(console)) processConsoleCommand(console); + else if(enterWasPressed(console->studio)) processConsoleCommand(console); else if(keyWasPressed(console->studio, tic_key_backspace)) processConsoleBackspace(console); else if(keyWasPressed(console->studio, tic_key_delete)) processConsoleDel(console); else if(keyWasPressed(console->studio, tic_key_home)) processConsoleHome(console); diff --git a/src/studio/screens/menu.c b/src/studio/screens/menu.c index eeb13985d..34ebd8b07 100644 --- a/src/studio/screens/menu.c +++ b/src/studio/screens/menu.c @@ -215,7 +215,7 @@ static void drawOptionArrow(Menu* menu, MenuOption* option, s32 x, s32 y, s32 ic } } -static bool enterWasPressed(tic_mem* tic) +static bool ticEnterWasPressed(tic_mem* tic) { return tic_api_keyp(tic, tic_key_return, Hold, Period) || @@ -264,7 +264,7 @@ static void drawMenu(Menu* menu, s32 x, s32 y) } } - if(tic_api_btnp(menu->tic, A, -1, -1) || enterWasPressed(tic)) + if(tic_api_btnp(menu->tic, A, -1, -1) || ticEnterWasPressed(tic)) { if(option) { diff --git a/src/studio/screens/surf.c b/src/studio/screens/surf.c index d1ef1d824..fc99a5363 100644 --- a/src/studio/screens/surf.c +++ b/src/studio/screens/surf.c @@ -612,7 +612,7 @@ static void move(Surf* surf, s32 dir) surf->anim.movie = resetMovie(&surf->anim.move); } -static bool enterWasPressed(tic_mem* tic) +static bool ticEnterWasPressed(tic_mem* tic) { return tic_api_keyp(tic, tic_key_return, -1, -1) || tic_api_keyp(tic, tic_key_numpadenter, -1, -1); @@ -668,7 +668,7 @@ static void processGamepad(Surf* surf) } if(tic_api_btnp(tic, A, -1, -1) - || enterWasPressed(tic)) + || ticEnterWasPressed(tic)) { SurfItem* item = getMenuItem(surf); item->dir diff --git a/src/studio/studio.c b/src/studio/studio.c index e630431b9..3c8ddfb7e 100644 --- a/src/studio/studio.c +++ b/src/studio/studio.c @@ -436,6 +436,13 @@ bool keyWasPressed(Studio* studio, tic_key key) return tic_api_keyp(tic, key, KEYBOARD_HOLD, KEYBOARD_PERIOD); } +bool enterWasPressed(Studio* studio) +{ + tic_mem* tic = studio->tic; + return tic_api_keyp(tic, tic_key_return, KEYBOARD_HOLD, KEYBOARD_PERIOD) || + tic_api_keyp(tic, tic_key_numpadenter, KEYBOARD_HOLD, KEYBOARD_PERIOD); +} + bool anyKeyWasPressed(Studio* studio) { tic_mem* tic = studio->tic; diff --git a/src/studio/studio.h b/src/studio/studio.h index a9562d067..a5d900279 100644 --- a/src/studio/studio.h +++ b/src/studio/studio.h @@ -258,6 +258,7 @@ tic_map* getBankMap(Studio* studio); char getKeyboardText(Studio* studio); bool keyWasPressed(Studio* studio, tic_key key); +bool enterWasPressed(Studio* studio); bool anyKeyWasPressed(Studio* studio); const StudioConfig* getConfig(Studio* studio); From 5c006f23bb02d5d3afeb4f0bcf0b6a671536296a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20Su=C3=A1rez?= Date: Wed, 13 Sep 2023 21:36:04 -0500 Subject: [PATCH 36/83] Create tic_core_enterp in io.h --- src/api.h | 1 + src/core/io.c | 6 ++++++ src/studio/screens/menu.c | 9 +-------- src/studio/screens/surf.c | 8 +------- src/studio/studio.c | 3 +-- 5 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/api.h b/src/api.h index d3431176d..bb09ff8cd 100644 --- a/src/api.h +++ b/src/api.h @@ -877,6 +877,7 @@ void tic_core_synth_sound(tic_mem* tic); void tic_core_blit(tic_mem* tic); void tic_core_blit_ex(tic_mem* tic, tic_blit_callback clb); const tic_script_config* tic_core_script_config(tic_mem* memory); +bool tic_core_enterp(tic_mem* tic, s32 hold, s32 period); #define VBANK(tic, bank) \ bool MACROVAR(_bank_) = tic_api_vbank(tic, bank); \ diff --git a/src/core/io.c b/src/core/io.c index aedce6037..6e44c19fe 100644 --- a/src/core/io.c +++ b/src/core/io.c @@ -132,6 +132,12 @@ tic_point tic_api_mouse(tic_mem* memory) : (tic_point){memory->ram->input.mouse.x - TIC80_OFFSET_LEFT, memory->ram->input.mouse.y - TIC80_OFFSET_TOP}; } +bool tic_core_enterp(tic_mem* tic, s32 hold, s32 period) +{ + return tic_api_keyp(tic, tic_key_return, hold, period) || + tic_api_keyp(tic, tic_key_numpadenter, hold, period); +} + void tic_core_tick_io(tic_mem* tic) { tic_core* core = (tic_core*)tic; diff --git a/src/studio/screens/menu.c b/src/studio/screens/menu.c index 34ebd8b07..2d394279e 100644 --- a/src/studio/screens/menu.c +++ b/src/studio/screens/menu.c @@ -215,13 +215,6 @@ static void drawOptionArrow(Menu* menu, MenuOption* option, s32 x, s32 y, s32 ic } } -static bool ticEnterWasPressed(tic_mem* tic) -{ - - return tic_api_keyp(tic, tic_key_return, Hold, Period) || - tic_api_keyp(tic, tic_key_numpadenter, Hold, Period); -} - static void drawMenu(Menu* menu, s32 x, s32 y) { if (getStudioMode(menu->studio) != TIC_MENU_MODE) @@ -264,7 +257,7 @@ static void drawMenu(Menu* menu, s32 x, s32 y) } } - if(tic_api_btnp(menu->tic, A, -1, -1) || ticEnterWasPressed(tic)) + if(tic_api_btnp(menu->tic, A, -1, -1) || tic_core_enterp(tic, -1, -1)) { if(option) { diff --git a/src/studio/screens/surf.c b/src/studio/screens/surf.c index fc99a5363..396732b62 100644 --- a/src/studio/screens/surf.c +++ b/src/studio/screens/surf.c @@ -612,12 +612,6 @@ static void move(Surf* surf, s32 dir) surf->anim.movie = resetMovie(&surf->anim.move); } -static bool ticEnterWasPressed(tic_mem* tic) -{ - return tic_api_keyp(tic, tic_key_return, -1, -1) || - tic_api_keyp(tic, tic_key_numpadenter, -1, -1); -} - static void processGamepad(Surf* surf) { tic_mem* tic = surf->tic; @@ -668,7 +662,7 @@ static void processGamepad(Surf* surf) } if(tic_api_btnp(tic, A, -1, -1) - || ticEnterWasPressed(tic)) + || tic_core_enterp(tic, -1, -1)) { SurfItem* item = getMenuItem(surf); item->dir diff --git a/src/studio/studio.c b/src/studio/studio.c index 3c8ddfb7e..bd9551e74 100644 --- a/src/studio/studio.c +++ b/src/studio/studio.c @@ -439,8 +439,7 @@ bool keyWasPressed(Studio* studio, tic_key key) bool enterWasPressed(Studio* studio) { tic_mem* tic = studio->tic; - return tic_api_keyp(tic, tic_key_return, KEYBOARD_HOLD, KEYBOARD_PERIOD) || - tic_api_keyp(tic, tic_key_numpadenter, KEYBOARD_HOLD, KEYBOARD_PERIOD); + return tic_core_enterp(tic, KEYBOARD_HOLD, KEYBOARD_PERIOD); } bool anyKeyWasPressed(Studio* studio) From e05c985cd5d9279780a61eb6a16c09633585dcbe Mon Sep 17 00:00:00 2001 From: alectroemel Date: Mon, 18 Sep 2023 09:23:54 -0500 Subject: [PATCH 37/83] bump janet version to 1.31.0 --- vendor/janet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/janet b/vendor/janet index 3a4d56afc..4e5889ed5 160000 --- a/vendor/janet +++ b/vendor/janet @@ -1 +1 @@ -Subproject commit 3a4d56afca2eee0e4dbca9a6400757d198e6d6f3 +Subproject commit 4e5889ed59fd78d3912590af3277a3346a97e033 From 79da692489faa0f0112f68f0575840c156c56954 Mon Sep 17 00:00:00 2001 From: alectroemel Date: Tue, 19 Sep 2023 08:31:56 -0500 Subject: [PATCH 38/83] update janetconf.h to new version, include patches for windows build in janet --- build/janet/janetconf.h | 6 +++--- vendor/janet | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/janet/janetconf.h b/build/janet/janetconf.h index 647530125..6e0dee55b 100644 --- a/build/janet/janetconf.h +++ b/build/janet/janetconf.h @@ -4,10 +4,10 @@ #define JANETCONF_H #define JANET_VERSION_MAJOR 1 -#define JANET_VERSION_MINOR 29 -#define JANET_VERSION_PATCH 1 +#define JANET_VERSION_MINOR 31 +#define JANET_VERSION_PATCH 0 #define JANET_VERSION_EXTRA "" -#define JANET_VERSION "1.29.1" +#define JANET_VERSION "1.31.0" /* #define JANET_BUILD "local" */ diff --git a/vendor/janet b/vendor/janet index 4e5889ed5..169bd812c 160000 --- a/vendor/janet +++ b/vendor/janet @@ -1 +1 @@ -Subproject commit 4e5889ed59fd78d3912590af3277a3346a97e033 +Subproject commit 169bd812c9183865b2399a8eaeab6aad238856c5 From b95e2debe274b9d6c79843398df6fe4e049f6554 Mon Sep 17 00:00:00 2001 From: Tim Scherhaufer Date: Fri, 22 Sep 2023 00:39:02 +0200 Subject: [PATCH 39/83] JS API: Fix spr colorkey default parameter In case that no parameter or undefined is passed to the spr function in JS, the parameter would evaluate to 0 due to a wrong default value in the code path when colorkey is not an array. In case of an array the default value would be -1, which is also specified in the wiki. We now pass -1 in case the parameter is not an array. See: #2291 --- src/api/js.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/js.c b/src/api/js.c index 275311dc9..1d2a29824 100644 --- a/src/api/js.c +++ b/src/api/js.c @@ -237,7 +237,7 @@ static JSValue js_spr(JSContext *ctx, JSValueConst this_val, s32 argc, JSValueCo } else { - colors[0] = getInteger2(ctx, argv[3], 0); + colors[0] = getInteger2(ctx, argv[3], -1); count = 1; } From f1590a3d433fac0f86bdd88ac66070b6b5e3fea8 Mon Sep 17 00:00:00 2001 From: nesbox Date: Sat, 23 Sep 2023 12:09:05 +0200 Subject: [PATCH 40/83] #2300: added 32 bit Android --- build/android/app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/android/app/build.gradle b/build/android/app/build.gradle index 592e43d10..85cdba2d7 100644 --- a/build/android/app/build.gradle +++ b/build/android/app/build.gradle @@ -18,7 +18,7 @@ android { versionCode 10200 versionName "1.02.00" ndk { - abiFilters 'arm64-v8a' + abiFilters 'arm64-v8a', 'armeabi-v7a' } externalNativeBuild { ndkBuild { From c556efbfbdda69b464d4da725b9ebb94189678bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20Su=C3=A1rez?= Date: Sun, 24 Sep 2023 12:14:30 -0500 Subject: [PATCH 41/83] Move tic_core_enterp to studio --- src/api.h | 1 - src/core/io.c | 6 ------ src/studio/screens/menu.c | 2 +- src/studio/screens/surf.c | 2 +- src/studio/studio.c | 9 ++++++++- src/studio/studio.h | 1 + 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/api.h b/src/api.h index bb09ff8cd..d3431176d 100644 --- a/src/api.h +++ b/src/api.h @@ -877,7 +877,6 @@ void tic_core_synth_sound(tic_mem* tic); void tic_core_blit(tic_mem* tic); void tic_core_blit_ex(tic_mem* tic, tic_blit_callback clb); const tic_script_config* tic_core_script_config(tic_mem* memory); -bool tic_core_enterp(tic_mem* tic, s32 hold, s32 period); #define VBANK(tic, bank) \ bool MACROVAR(_bank_) = tic_api_vbank(tic, bank); \ diff --git a/src/core/io.c b/src/core/io.c index 6e44c19fe..aedce6037 100644 --- a/src/core/io.c +++ b/src/core/io.c @@ -132,12 +132,6 @@ tic_point tic_api_mouse(tic_mem* memory) : (tic_point){memory->ram->input.mouse.x - TIC80_OFFSET_LEFT, memory->ram->input.mouse.y - TIC80_OFFSET_TOP}; } -bool tic_core_enterp(tic_mem* tic, s32 hold, s32 period) -{ - return tic_api_keyp(tic, tic_key_return, hold, period) || - tic_api_keyp(tic, tic_key_numpadenter, hold, period); -} - void tic_core_tick_io(tic_mem* tic) { tic_core* core = (tic_core*)tic; diff --git a/src/studio/screens/menu.c b/src/studio/screens/menu.c index 2d394279e..5baf90e2e 100644 --- a/src/studio/screens/menu.c +++ b/src/studio/screens/menu.c @@ -257,7 +257,7 @@ static void drawMenu(Menu* menu, s32 x, s32 y) } } - if(tic_api_btnp(menu->tic, A, -1, -1) || tic_core_enterp(tic, -1, -1)) + if(tic_api_btnp(menu->tic, A, -1, -1) || ticEnterWasPressed(tic, -1, -1)) { if(option) { diff --git a/src/studio/screens/surf.c b/src/studio/screens/surf.c index 396732b62..17f43ddb3 100644 --- a/src/studio/screens/surf.c +++ b/src/studio/screens/surf.c @@ -662,7 +662,7 @@ static void processGamepad(Surf* surf) } if(tic_api_btnp(tic, A, -1, -1) - || tic_core_enterp(tic, -1, -1)) + || ticEnterWasPressed(tic, -1, -1)) { SurfItem* item = getMenuItem(surf); item->dir diff --git a/src/studio/studio.c b/src/studio/studio.c index bd9551e74..14a95aa89 100644 --- a/src/studio/studio.c +++ b/src/studio/studio.c @@ -439,9 +439,16 @@ bool keyWasPressed(Studio* studio, tic_key key) bool enterWasPressed(Studio* studio) { tic_mem* tic = studio->tic; - return tic_core_enterp(tic, KEYBOARD_HOLD, KEYBOARD_PERIOD); + return ticEnterWasPressed(tic, KEYBOARD_HOLD, KEYBOARD_PERIOD); } +bool ticEnterWasPressed(tic_mem* tic, s32 hold, s32 period) +{ + return tic_api_keyp(tic, tic_key_return, hold, period) || + tic_api_keyp(tic, tic_key_numpadenter, hold, period); +} + + bool anyKeyWasPressed(Studio* studio) { tic_mem* tic = studio->tic; diff --git a/src/studio/studio.h b/src/studio/studio.h index a5d900279..6f39dee7f 100644 --- a/src/studio/studio.h +++ b/src/studio/studio.h @@ -260,6 +260,7 @@ char getKeyboardText(Studio* studio); bool keyWasPressed(Studio* studio, tic_key key); bool enterWasPressed(Studio* studio); bool anyKeyWasPressed(Studio* studio); +bool ticEnterWasPressed(tic_mem* tic, s32 hold, s32 period); const StudioConfig* getConfig(Studio* studio); struct Start* getStartScreen(Studio* studio); From 726abf0572c89c004d2bab4cae04a2ca82a4e2c9 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 02:14:45 +0800 Subject: [PATCH 42/83] Update pocketpy --- vendor/pocketpy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/pocketpy b/vendor/pocketpy index 35910d32d..7046ab9b4 160000 --- a/vendor/pocketpy +++ b/vendor/pocketpy @@ -1 +1 @@ -Subproject commit 35910d32d67d0f81ade9fd3b6d8c512018a7da69 +Subproject commit 7046ab9b4a0d4e70e3e717ec48727ad44d0f7604 From db284e02f438352a3127f121e50e8af8d78a9310 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 03:23:39 +0800 Subject: [PATCH 43/83] some initial try --- compile_flags.txt | 12 +++++ src/api/python.c | 114 ++++++++++++++++++++++++++++++---------------- vendor/pocketpy | 2 +- 3 files changed, 87 insertions(+), 41 deletions(-) create mode 100644 compile_flags.txt diff --git a/compile_flags.txt b/compile_flags.txt new file mode 100644 index 000000000..0d47608e6 --- /dev/null +++ b/compile_flags.txt @@ -0,0 +1,12 @@ +-xc +-Wall +-W* +-Iinclude/ +-Isrc/ +-Isrc/api/ +-Isrc/core/ +-Isrc/ext/ +-Isrc/studio/ +-Isrc/system/ +-Ivendor/blip-buf/ +-Ivendor/pocketpy/include/ diff --git a/src/api/python.c b/src/api/python.c index 1a7ad2610..8d93763e6 100644 --- a/src/api/python.c +++ b/src/api/python.c @@ -1,4 +1,3 @@ - #include "core/core.h" #if defined(TIC_BUILD_WITH_PYTHON) @@ -7,16 +6,46 @@ #include #include +typedef struct CachedNames{ + bool initialized; + pkpy_CName _tic_core; + pkpy_CName len; + pkpy_CName __getitem__; +} CachedNames; + +CachedNames _cached_names; + +static CachedNames* N(){ + if(!_cached_names.initialized){ + _cached_names._tic_core = pkpy_name("_tic_core"); + _cached_names.len = pkpy_name("len"); + _cached_names.__getitem__ = pkpy_name("__getitem__"); + _cached_names.initialized = true; + } + return &_cached_names; +} + +static char* cstrdup(pkpy_CString cs){ + char* s = (char*)malloc(cs.size + 1); + memcpy(s, cs.data, cs.size); + s[cs.size] = '\0'; + return s; +} + +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) { - pkpy_get_global(vm, "_tic_core"); + pkpy_getglobal(vm, N()->_tic_core); return pkpy_to_voidp(vm, -1, (void**) core); } static bool setup_core(pkpy_vm* vm, tic_core* core) { if (!pkpy_push_voidp(vm, core)) return false; - if (!pkpy_set_global(vm, "_tic_core")) return false; + if (!pkpy_setglobal(vm, N()->_tic_core)) return false; return true; } @@ -38,25 +67,27 @@ static int prepare_colorindex(pkpy_vm* vm, int index, u8 * buffer) } else { //should be a list then - pkpy_get_global(vm, "len"); - pkpy_push(vm, index); //get the list - pkpy_call(vm, 1); + pkpy_getglobal(vm, N()->len); + pkpy_push_null(vm); + pkpy_dup(vm, index); //get the list + pkpy_vectorcall(vm, 1); int list_len; pkpy_to_int(vm, -1, &list_len); - pkpy_pop(vm, 1); + pkpy_pop_top(vm); list_len = (list_len < TIC_PALETTE_SIZE)?(list_len):(TIC_PALETTE_SIZE); for(int i = 0; i < list_len; i++) { int list_val; - pkpy_push(vm, index); + pkpy_dup(vm, index); //get the list + pkpy_get_unbound_method(vm, N()->__getitem__); pkpy_push_int(vm, i); - pkpy_call_method(vm, "__getitem__", 1); + pkpy_vectorcall(vm, 1); pkpy_to_int(vm, -1, &list_val); buffer[i] = list_val; - pkpy_pop(vm, 1); + pkpy_pop_top(vm); } return list_len; @@ -67,20 +98,21 @@ static int prepare_colorindex(pkpy_vm* vm, int index, u8 * buffer) static int py_trace(pkpy_vm* vm) { tic_mem* tic; - char* message = NULL; + pkpy_CString message; int color; + pkpy_py_str(vm); pkpy_to_string(vm, 0, &message); pkpy_to_int(vm, 1, &color); get_core(vm, (tic_core**) &tic); if (pkpy_check_error(vm)) { - if (message != NULL) free(message); return 0; } - tic_api_trace(tic, message, (u8) color); - free(message); + char* message_s = cstrdup(message); + tic_api_trace(tic, message_s, (u8) color); + free(message_s); return 0; } @@ -252,7 +284,7 @@ static int py_fget(pkpy_vm* vm) { tic_mem* tic; int sprite_id; - unsigned flag; + int flag; pkpy_to_int(vm, 0, &sprite_id); pkpy_to_int(vm, 1, &flag); @@ -260,7 +292,7 @@ static int py_fget(pkpy_vm* vm) if(pkpy_check_error(vm)) return 0; - bool set = tic_api_fget(tic, sprite_id, flag); + bool set = tic_api_fget(tic, sprite_id, (u8)flag); pkpy_push_bool(vm, set); return 1; } @@ -269,7 +301,7 @@ static int py_fset(pkpy_vm* vm) { tic_mem* tic; int sprite_id; - unsigned flag; + int flag; bool set_to; pkpy_to_int(vm, 0, &sprite_id); @@ -279,14 +311,14 @@ static int py_fset(pkpy_vm* vm) if(pkpy_check_error(vm)) return 0; - tic_api_fset(tic, sprite_id, flag, set_to); + tic_api_fset(tic, sprite_id, (u8)flag, set_to); return 0; } static int py_font(pkpy_vm* vm) { tic_mem* tic; - char* text = NULL; + pkpy_CString text; int x; int y; int width; @@ -307,7 +339,6 @@ static int py_font(pkpy_vm* vm) pkpy_to_bool(vm, 8, &alt); get_core(vm, (tic_core**) &tic); if(pkpy_check_error(vm)) { - if (text != NULL) free(text); return 0; } @@ -318,11 +349,12 @@ static int py_font(pkpy_vm* vm) else { u8 chromakey = (u8) chromakey_raw; - s32 size = tic_api_font(tic, text, x, y, &chromakey, 1, width, height, fixed, scale, alt); + char* text_s = cstrdup(text); + s32 size = tic_api_font(tic, text_s, x, y, &chromakey, 1, width, height, fixed, scale, alt); + free(text_s); pkpy_push_int(vm, size); } - free(text); return 1; } @@ -337,7 +369,7 @@ static int py_key(pkpy_vm* vm) return 0; if (key_id >= tic_keys_count) { - pkpy_error(vm, "tic80-panic!", "unknown keyboard code\n"); + pkpy_error(vm, "tic80-panic!", pkpy_string("unknown keyboard code\n")); return 0; } @@ -361,7 +393,7 @@ static int py_keyp(pkpy_vm* vm) return 0; if (key_id >= tic_keys_count) { - pkpy_error(vm, "tic80-panic!", "unknown keyboard code\n"); + pkpy_error(vm, "tic80-panic!", pkpy_string("unknown keyboard code\n")); return 0; } @@ -395,10 +427,11 @@ static int py_line(pkpy_vm* vm) static void remap_callback(void* data, s32 x, s32 y, RemapResult* result) { pkpy_vm* vm = data; - pkpy_push(vm, -1); //get copy of remap callable + pkpy_dup(vm, -1); //get copy of remap callable + pkpy_push_null(vm); pkpy_push_int(vm, x); pkpy_push_int(vm, y); - pkpy_call(vm, 2); + pkpy_vectorcall(vm, 2); int index, flip, rotate; @@ -570,7 +603,7 @@ static int py_music(pkpy_vm* vm) { return 0; if (track > MUSIC_TRACKS - 1 ) - pkpy_error(vm, "tic80-panic!", "invalid music track index\n"); + pkpy_error(vm, "tic80-panic!", pkpy_string("invalid music track index\n")); //stop the music first I guess tic_api_music(tic, -1, 0, 0, false, false, -1, -1); @@ -687,7 +720,7 @@ static int py_pmem(pkpy_vm* vm) { return 0; if (index >= TIC_PERSISTENT_SIZE) { - pkpy_error(vm, "tic80-panic!", "invalid persistent tic index\n"); + pkpy_error(vm, "tic80-panic!", pkpy_string("invalid persistent tic index\n")); return 0; } @@ -866,7 +899,9 @@ static int py_sfx(pkpy_vm* vm) if (pkpy_is_string(vm, 1)) { parse_note = true; - pkpy_to_string(vm, 1, &string_note); + pkpy_CString tmp; + pkpy_to_string(vm, 1, &tmp); + if(tmp.size) string_note = cstrdup(tmp); } else { pkpy_to_int(vm, 1, &int_note); } @@ -882,7 +917,7 @@ static int py_sfx(pkpy_vm* vm) if (parse_note) { if(!tic_tool_parse_note(string_note, ¬e, &octave)) { - pkpy_error(vm, "tic80-panic!", "invalid note, should like C#4\n"); + pkpy_error(vm, "tic80-panic!", pkpy_string("invalid note, should like C#4\n")); goto cleanup; //error in future; } @@ -892,12 +927,12 @@ static int py_sfx(pkpy_vm* vm) } if (channel < 0 || channel >= TIC_SOUND_CHANNELS) { - pkpy_error(vm, "tic80-panic!", "unknown channel\n"); + pkpy_error(vm, "tic80-panic!", pkpy_string("unknown channel\n")); goto cleanup; } if (sfx_id >= SFX_COUNT) { - pkpy_error(vm, "tic80-panic!", "unknown sfx index\n"); + pkpy_error(vm, "tic80-panic!", pkpy_string("unknown sfx index\n")); goto cleanup; } @@ -969,7 +1004,7 @@ static int py_sync(pkpy_vm* vm) return 0; if (bank < 0 || bank >= TIC_BANKS) { - pkpy_error(vm, "tic80-panic!", "sync() error, invalid bank\n"); + pkpy_error(vm, "tic80-panic!", pkpy_string("sync() error, invalid bank\n")); return 0; } @@ -1138,15 +1173,14 @@ static int py_vbank(pkpy_vm* vm) { } static bool setup_c_bindings(pkpy_vm* vm) { + pkpy_push_function(vm, "trace(message, color=15)", py_trace); + pkpy_setglobal_2(vm, "trace"); - pkpy_push_function(vm, py_trace, 2); - pkpy_set_global(vm, "_trace"); - - pkpy_push_function(vm, py_cls, 1); - pkpy_set_global(vm, "_cls"); + pkpy_push_function(vm, "cls(color=0)", py_cls); + pkpy_setglobal_2(vm, "cls"); - pkpy_push_function(vm, py_btn, 1); - pkpy_set_global(vm, "_btn"); + pkpy_push_function(vm, "btn(id: int)", py_btn); + pkpy_setglobal_2(vm, "btn"); pkpy_push_function(vm, py_btnp, 3); pkpy_set_global(vm, "_btnp"); diff --git a/vendor/pocketpy b/vendor/pocketpy index 7046ab9b4..b97e283fd 160000 --- a/vendor/pocketpy +++ b/vendor/pocketpy @@ -1 +1 @@ -Subproject commit 7046ab9b4a0d4e70e3e717ec48727ad44d0f7604 +Subproject commit b97e283fd84ae097d8593f8042c7c75f21da4d1f From 18bf625ad82a7f73591c3fb45fd59d5f40e5614e Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 04:18:01 +0800 Subject: [PATCH 44/83] some more update --- CMakeLists.txt | 69 +++++---- src/api/python.c | 383 +++++++++++++++++++---------------------------- 2 files changed, 195 insertions(+), 257 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c0ed2527..9cfdfa62c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -400,37 +400,44 @@ target_include_directories(squirrel PRIVATE ${SQUIRREL_DIR}/sqstdlib) # PocketPy (Python) ################################ -set(POCKETPY_DIR ${THIRDPARTY_DIR}/pocketpy) - -if (${CMAKE_VERSION} VERSION_LESS "3.12.0") - set(Python3_EXECUTABLE "python3") -else() - find_package(Python3 COMPONENTS Interpreter) -endif() - -add_custom_command( - OUTPUT ${POCKETPY_DIR}/src/_generated.h - COMMAND ${Python3_EXECUTABLE} preprocess.py - WORKING_DIRECTORY ${POCKETPY_DIR} - DEPENDS ${POCKETPY_DIR}/preprocess.py -) - -add_library(python STATIC - ${POCKETPY_DIR}/src/_generated.h - ${POCKETPY_DIR}/c_bindings/pocketpy_c.cpp -) - -set_target_properties(python PROPERTIES LINKER_LANGUAGE CXX) -target_compile_definitions(python PRIVATE PK_ENABLE_OS=0) -target_include_directories(python - PRIVATE ${POCKETPY_DIR}/src - PUBLIC ${POCKETPY_DIR}/c_bindings) - -if (${CMAKE_VERSION} VERSION_LESS "3.8.0") - set_target_properties(python PROPERTIES COMPILE_FLAGS "--std=c++17") -else() - target_compile_features(python PRIVATE cxx_std_17) -endif() +add_subdirectory(${THIRDPARTY_DIR}/pocketpy) + +set_target_properties(pocketpy PROPERTIES OUTPUT_NAME python) +set_target_properties(pocketpy PROPERTIES LINKER_LANGUAGE CXX) + +target_compile_definitions(pocketpy PRIVATE PK_ENABLE_OS=0) + +# set(POCKETPY_DIR ${THIRDPARTY_DIR}/pocketpy) + +# if (${CMAKE_VERSION} VERSION_LESS "3.12.0") +# set(Python3_EXECUTABLE "python3") +# else() +# find_package(Python3 COMPONENTS Interpreter) +# endif() + +# add_custom_command( +# OUTPUT ${POCKETPY_DIR}/src/_generated.h +# COMMAND ${Python3_EXECUTABLE} preprocess.py +# WORKING_DIRECTORY ${POCKETPY_DIR} +# DEPENDS ${POCKETPY_DIR}/preprocess.py +# ) + +# add_library(python STATIC +# ${POCKETPY_DIR}/src/_generated.h +# ${POCKETPY_DIR}/c_bindings/pocketpy_c.cpp +# ) + +# set_target_properties(python PROPERTIES LINKER_LANGUAGE CXX) +# target_compile_definitions(python PRIVATE PK_ENABLE_OS=0) +# target_include_directories(python +# PRIVATE ${POCKETPY_DIR}/src +# PUBLIC ${POCKETPY_DIR}/c_bindings) + +# if (${CMAKE_VERSION} VERSION_LESS "3.8.0") +# set_target_properties(python PROPERTIES COMPILE_FLAGS "--std=c++17") +# else() +# target_compile_features(python PRIVATE cxx_std_17) +# endif() ################################ # GIFLIB diff --git a/src/api/python.c b/src/api/python.c index 8d93763e6..a4deec2b9 100644 --- a/src/api/python.c +++ b/src/api/python.c @@ -11,6 +11,11 @@ typedef struct CachedNames{ pkpy_CName _tic_core; pkpy_CName len; pkpy_CName __getitem__; + pkpy_CName TIC; + pkpy_CName BOOT; + pkpy_CName SCN; + pkpy_CName BDR; + pkpy_CName MENU; } CachedNames; CachedNames _cached_names; @@ -20,6 +25,11 @@ static CachedNames* N(){ _cached_names._tic_core = pkpy_name("_tic_core"); _cached_names.len = pkpy_name("len"); _cached_names.__getitem__ = pkpy_name("__getitem__"); + _cached_names.TIC = pkpy_name("TIC"); + _cached_names.BOOT = pkpy_name("BOOT"); + _cached_names.SCN = pkpy_name("SCN"); + _cached_names.BDR = pkpy_name("BDR"); + _cached_names.MENU = pkpy_name("MENU"); _cached_names.initialized = true; } return &_cached_names; @@ -36,6 +46,10 @@ static void pkpy_setglobal_2(pkpy_vm* vm, const char* name){ pkpy_setglobal(vm, pkpy_name(name)); } +static bool pkpy_vm_run(pkpy_vm* vm, const char* src){ + return 0; +} + static bool get_core(pkpy_vm* vm, tic_core** core) { pkpy_getglobal(vm, N()->_tic_core); @@ -806,7 +820,7 @@ static int py_poke4(pkpy_vm* vm) { static int py_print(pkpy_vm* vm) { tic_mem* tic; - char* text = NULL; + pkpy_CString text; int x; int y; int color; @@ -825,15 +839,14 @@ static int py_print(pkpy_vm* vm) { pkpy_to_bool(vm, 7, &alt); get_core(vm, (tic_core**) &tic); if(pkpy_check_error(vm)) { - if (text != NULL) free(text); return 0; } - s32 size = tic_api_print(tic, text, x, y, color, fixed, scale, alt); + char* text_s = cstrdup(text); + s32 size = tic_api_print(tic, text_s, x, y, color, fixed, scale, alt); + free(text_s); pkpy_push_int(vm, size); - - free(text); return 1; } @@ -1179,137 +1192,138 @@ static bool setup_c_bindings(pkpy_vm* vm) { pkpy_push_function(vm, "cls(color=0)", py_cls); pkpy_setglobal_2(vm, "cls"); + //lua api does this for btn pkpy_push_function(vm, "btn(id: int)", py_btn); pkpy_setglobal_2(vm, "btn"); - pkpy_push_function(vm, py_btnp, 3); - pkpy_set_global(vm, "_btnp"); + pkpy_push_function(vm, "btnp(id: int, hold=-1, period=-1)", py_btnp); + pkpy_setglobal_2(vm, "btnp"); - pkpy_push_function(vm, py_circ, 4); - pkpy_set_global(vm, "_circ"); + pkpy_push_function(vm, "circ(x: int, y: int, radius: int, color: int)", py_circ); + pkpy_setglobal_2(vm, "circ"); - pkpy_push_function(vm, py_circb, 4); - pkpy_set_global(vm, "_circb"); + pkpy_push_function(vm, "circb(x: int, y: int, radius: int, color: int)", py_circb); + pkpy_setglobal_2(vm, "circb"); - pkpy_push_function(vm, py_clip, 4); - pkpy_set_global(vm, "_clip"); + pkpy_push_function(vm, "elli(x: int, y: int, a: int, b: int, color: int)", py_elli); + pkpy_setglobal_2(vm, "elli"); - pkpy_push_function(vm, py_elli, 5); - pkpy_set_global(vm, "_elli"); + pkpy_push_function(vm, "ellib(x: int, y: int, a: int, b: int, color: int)", py_ellib); + pkpy_setglobal_2(vm, "ellib"); - pkpy_push_function(vm, py_ellib, 5); - pkpy_set_global(vm, "_ellib"); + pkpy_push_function(vm, "clip(x: int, y: int, width: int, height: int)", py_clip); + pkpy_setglobal_2(vm, "clip"); - pkpy_push_function(vm, py_exit, 0); - pkpy_set_global(vm, "_exit"); + pkpy_push_function(vm, "exit()", py_exit); + pkpy_setglobal_2(vm, "exit"); - pkpy_push_function(vm, py_fget, 2); - pkpy_set_global(vm, "_fget"); + pkpy_push_function(vm, "fget(sprite_id: int, flag: int)", py_fget); + pkpy_setglobal_2(vm, "fget"); - pkpy_push_function(vm, py_fset, 3); - pkpy_set_global(vm, "_fset"); + pkpy_push_function(vm, "fset(sprite_id: int, flag: int, b: bool)", py_fset); + pkpy_setglobal_2(vm, "fset"); - pkpy_push_function(vm, py_font, 9); - pkpy_set_global(vm, "_font"); + pkpy_push_function(vm, "font(text: str, x: int, y: int, chromakey: int, char_width: int=8, char_height: int=8, fixed: bool=False, scale: int=1, alt: bool=False)", py_font); + pkpy_setglobal_2(vm, "font"); - pkpy_push_function(vm, py_key, 1); - pkpy_set_global(vm, "_key"); + pkpy_push_function(vm, "key(code=-1)", py_key); + pkpy_setglobal_2(vm, "key"); - pkpy_push_function(vm, py_keyp, 3); - pkpy_set_global(vm, "_keyp"); + pkpy_push_function(vm, "keyp(code=-1, hold=-1, period=-17)", py_keyp); + pkpy_setglobal_2(vm, "keyp"); - pkpy_push_function(vm, py_line, 5); - pkpy_set_global(vm, "_line"); + pkpy_push_function(vm, "line(x0: int, y0: int, x1: int, y1: int, color: int)", py_line); + pkpy_setglobal_2(vm, "line"); - pkpy_push_function(vm, py_map, 9); - pkpy_set_global(vm, "_map"); + pkpy_push_function(vm, "map(x: int=0, y: int=0, w: int=30, h: int=17, sx: int=0, sy: int=0, colorkey: int=-1, scale: int=1, remap: list=None)", py_map); + pkpy_setglobal_2(vm, "map"); - pkpy_push_function(vm, py_memcpy, 3); - pkpy_set_global(vm, "_memcpy"); + pkpy_push_function(vm, "memcpy(dest: int, source: int, size: int)", py_memcpy); + pkpy_setglobal_2(vm, "memcpy"); - pkpy_push_function(vm, py_memset, 3); - pkpy_set_global(vm, "_memset"); + pkpy_push_function(vm, "memset(dest: int, value: int, size: int)", py_memset); + pkpy_setglobal_2(vm, "memset"); - pkpy_push_function(vm, py_mget, 2); - pkpy_set_global(vm, "_mget"); + pkpy_push_function(vm, "mget(x: int, y: int)", py_mget); + pkpy_setglobal_2(vm, "mget"); - pkpy_push_function(vm, py_mouse, 0); - pkpy_set_global(vm, "_mouse"); + pkpy_push_function(vm, "mset(x: int, y: int, tile_id: int)", py_mset); + pkpy_setglobal_2(vm, "mset"); - pkpy_push_function(vm, py_mset, 3); - pkpy_set_global(vm, "_mset"); + pkpy_push_function(vm, "mouse()", py_mouse); + pkpy_setglobal_2(vm, "mouse"); - pkpy_push_function(vm, py_music, 7); - pkpy_set_global(vm, "_music"); + pkpy_push_function(vm, "music(track=-1, frame=-1, row=-1, loop=True, sustain=False, tempo=-1, speed=-1)", py_music); + pkpy_setglobal_2(vm, "music"); - pkpy_push_function(vm, py_peek, 2); - pkpy_set_global(vm, "_peek"); + pkpy_push_function(vm, "peek(addr: int, bits=8)", py_peek); + pkpy_setglobal_2(vm, "peek"); - pkpy_push_function(vm, py_peek1, 1); - pkpy_set_global(vm, "_peek1"); + pkpy_push_function(vm, "peek1(addr: int)", py_peek1); + pkpy_setglobal_2(vm, "peek1"); - pkpy_push_function(vm, py_peek2, 1); - pkpy_set_global(vm, "_peek2"); + pkpy_push_function(vm, "peek2(addr: int)", py_peek2); + pkpy_setglobal_2(vm, "peek2"); - pkpy_push_function(vm, py_peek4, 1); - pkpy_set_global(vm, "_peek4"); + pkpy_push_function(vm, "peek4(addr: int)", py_peek4); + pkpy_setglobal_2(vm, "peek4"); - pkpy_push_function(vm, py_pix, 3); - pkpy_set_global(vm, "_pix"); + pkpy_push_function(vm, "pix(x: int, y: int, color: int=None)", py_pix); + pkpy_setglobal_2(vm, "pix"); - pkpy_push_function(vm, py_pmem, 2); - pkpy_set_global(vm, "_pmem"); + pkpy_push_function(vm, "pmem(index: int, value: int=None)", py_pmem); + pkpy_setglobal_2(vm, "pmem"); - pkpy_push_function(vm, py_poke, 3); - pkpy_set_global(vm, "_poke"); + pkpy_push_function(vm, "poke(addr: int, value: int, bits=8)", py_poke); + pkpy_setglobal_2(vm, "poke"); - pkpy_push_function(vm, py_poke1, 2); - pkpy_set_global(vm, "_poke1"); + pkpy_push_function(vm, "poke1(addr: int, value: int)", py_poke1); + pkpy_setglobal_2(vm, "poke1"); - pkpy_push_function(vm, py_poke2, 2); - pkpy_set_global(vm, "_poke2"); + pkpy_push_function(vm, "poke2(addr: int, value: int)", py_poke2); + pkpy_setglobal_2(vm, "poke2"); - pkpy_push_function(vm, py_poke4, 2); - pkpy_set_global(vm, "_poke4"); + pkpy_push_function(vm, "poke4(addr: int, value: int)", py_poke4); + pkpy_setglobal_2(vm, "poke4"); - pkpy_push_function(vm, py_print, 8); - pkpy_set_global(vm, "_print"); + pkpy_push_function(vm, "print(text: str, x: int=0, y: int=0, color: int=15, fixed: bool=False, scale: int=1, smallfont: bool=False, alt: bool=False)", py_print); + pkpy_setglobal_2(vm, "print"); - pkpy_push_function(vm, py_rect, 5); - pkpy_set_global(vm, "_rect"); + pkpy_push_function(vm, "rect(x: int, y: int, w: int, h: int, color: int)", py_rect); + pkpy_setglobal_2(vm, "rect"); - pkpy_push_function(vm, py_rectb, 5); - pkpy_set_global(vm, "_rectb"); + pkpy_push_function(vm, "rectb(x: int, y: int, w: int, h: int, color: int)", py_rectb); + pkpy_setglobal_2(vm, "rectb"); - pkpy_push_function(vm, py_reset, 0); - pkpy_set_global(vm, "_reset"); - - pkpy_push_function(vm, py_sfx, 6); - pkpy_set_global(vm, "_sfx"); + pkpy_push_function(vm, "reset()", py_reset); + pkpy_setglobal_2(vm, "reset"); + + pkpy_push_function(vm, "sfx(id: int, note: int=-1, duration: int=-1, channel: int=0, volume: int=15, speed: int=0)", py_sfx); + pkpy_setglobal_2(vm, "sfx"); - pkpy_push_function(vm, py_spr, 9); - pkpy_set_global(vm, "_spr"); + pkpy_push_function(vm, "spr(id: int, x: int, y: int, colorkey: int=-1, scale: int=1, flip: int=0, rotate: int=0, w: int=1, h: int=1)", py_spr); + pkpy_setglobal_2(vm, "spr"); - pkpy_push_function(vm, py_sync, 3); - pkpy_set_global(vm, "_sync"); + pkpy_push_function(vm, "sync(mask: int=0, bank: int=0, tocart: bool=False)", py_sync); + pkpy_setglobal_2(vm, "sync"); - pkpy_push_function(vm, py_time, 0); - pkpy_set_global(vm, "_time"); + pkpy_push_function(vm, "time()", py_time); + pkpy_setglobal_2(vm, "time"); - pkpy_push_function(vm, py_tri, 7); - pkpy_set_global(vm, "_tri"); + pkpy_push_function(vm, "tstamp()", py_tstamp); + pkpy_setglobal_2(vm, "tstamp"); - pkpy_push_function(vm, py_trib, 7); - pkpy_set_global(vm, "_trib"); + pkpy_push_function(vm, "tri(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, color: int)", py_tri); + pkpy_setglobal_2(vm, "tri"); - pkpy_push_function(vm, py_tstamp, 0); - pkpy_set_global(vm, "_tstamp"); + pkpy_push_function(vm, "trib(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, color: int)", py_trib); + pkpy_setglobal_2(vm, "trib"); - pkpy_push_function(vm, py_ttri, 17); - pkpy_set_global(vm, "_ttri"); + pkpy_push_function(vm, "ttri(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, u1: float, v1: float, u2: float, v2: float, u3: float, v3: float, texsrc: int=0, chromakey: int=-1, z1: float=0, z2: float=0, z3: float=0)", py_ttri); + pkpy_setglobal_2(vm, "ttri"); - pkpy_push_function(vm, py_vbank, 1); - pkpy_set_global(vm, "_vbank"); + pkpy_push_function(vm, "vbank(bank: int=None)", py_vbank); + pkpy_setglobal_2(vm, "vbank"); if(pkpy_check_error(vm)) return false; @@ -1318,109 +1332,6 @@ static bool setup_c_bindings(pkpy_vm* vm) { } static bool setup_py_bindings(pkpy_vm* vm) { - pkpy_vm_run(vm, "def trace(message, color=15) : return _trace(str(message), int(color))"); - - pkpy_vm_run(vm, "def cls(color=0) : return _cls(int(color))"); - - //lua api does this for btn - pkpy_vm_run(vm, "def btn(id) : return _btn(id)"); - pkpy_vm_run(vm, "def btnp(id, hold=-1, period=-1) : return _btnp(int(id), int(hold), int(period))"); - - //even if there are no keyword args, this also gives us argument count checks - pkpy_vm_run(vm, "def circ(x, y, radius, color) : return _circ(int(x), int(y), int(radius), int(color))"); - pkpy_vm_run(vm, "def circb(x, y, radius, color) : return _circb(int(x), int(y), int(radius), int(color))\n"); - - pkpy_vm_run(vm, "def elli(x, y, a, b, color) : return _elli(int(x), int(y), int(radius), int(color))"); - pkpy_vm_run(vm, "def ellib(x, y, a, b, color) : return _ellib(int(x), int(y), int(radius), int(color))"); - - pkpy_vm_run(vm, "def clip(x, y, width, height) : return _clip(int(x), int(y), int(width), int(height))"); - pkpy_vm_run(vm, "def exit() : return _exit()\n"); - - pkpy_vm_run(vm, "def fget(sprite_id, flag) : return _fget(int(sprite_id), int(flag))"); - pkpy_vm_run(vm, "def fset(sprite_id, flag, b) : return _fset(int(sprite_id), int(flag), bool(b))"); - - pkpy_vm_run(vm, - "def font(text, x, y, chromakey, char_width=8, char_height=8, fixed=False, scale=1, alt=False) : " - "return _font(str(text), int(x), int(y), chromakey, int(char_width), int(char_height), bool(fixed), int(scale), bool(alt))" - ); - - pkpy_vm_run(vm, "def key(code=-1) : return _key(code)"); - pkpy_vm_run(vm, "def keyp(code=-1, hold=-1, period=-17) : return _keyp(int(code), int(hold), int(period))"); - - pkpy_vm_run(vm, "def line(x0, y0, x1, y1, color) : _line(int(x0), int(y0), int(x1), int(y1), int(color))"); - pkpy_vm_run(vm, - "def map(x=0, y=0, w=30, h=17, sx=0, sy=0, colorkey=-1, scale=1, remap=None) : " - " return _map(int(x),int(y),int(w),int(h),int(sx),int(sy),colorkey,int(scale),remap)" - ); - - pkpy_vm_run(vm, "def memcpy(dest, source, size) : return _memcpy(int(dest), int(source), int(size))"); - pkpy_vm_run(vm, "def memset(dest, value, size) : return _memset(int(dest), int(value), int(size))"); - - pkpy_vm_run(vm, "def mget(x, y) : return _mget(int(x), int(y))"); - pkpy_vm_run(vm, "def mset(x, y, tile_id) : return _mset(int(x), int(y), int(tile_id))"); - - pkpy_vm_run(vm, "def mouse() : return _mouse()"); - - pkpy_vm_run(vm, - "def music(track=-1, frame=-1, row=-1, loop=True, sustain=False, tempo=-1, speed=-1) :" - "return _music(int(track), int(frame), int(row), bool(loop), bool(sustain), int(tempo), int(speed))" - ); - - pkpy_vm_run(vm, "def peek(addr, bits=8) : return _peek(int(addr), int(bits)) "); - pkpy_vm_run(vm, "def peek1(addr) : return _peek1(int(addr)) "); - pkpy_vm_run(vm, "def peek2(addr) : return _peek2(int(addr)) "); - pkpy_vm_run(vm, "def peek4(addr) : return _peek4(int(addr)) "); - - pkpy_vm_run(vm, "def pix(x, y, color=None) : return _pix(int(x), int(y), color)"); - - pkpy_vm_run(vm, "def pmem(index, value=None) : return _pmem(int(index), value)"); - - pkpy_vm_run(vm, "def poke(addr, value, bits=8) : return _poke(int(addr), int(value), int(bits)) "); - pkpy_vm_run(vm, "def poke1(addr, value) : return _poke1(int(addr), int(value)) "); - pkpy_vm_run(vm, "def poke2(addr, value) : return _poke2(int(addr), int(value)) "); - pkpy_vm_run(vm, "def poke4(addr, value) : return _poke4(int(addr), int(value)) "); - - pkpy_vm_run(vm, - "def print(text, x=0, y=0, color=15, fixed=False, scale=1, smallfont=False, alt=False) :" - " return _print(str(text), int(x), int(y), int(color), bool(fixed), int(scale), bool(smallfont), bool(alt))" - ); - - pkpy_vm_run(vm, "def rect(x, y, w, h, color) : return _rect(int(x),int(y),int(w),int(h),int(color))"); - pkpy_vm_run(vm, "def rectb(x, y, w, h, color) : return _rectb(int(x),int(y),int(w),int(h),int(color))"); - - pkpy_vm_run(vm, "def reset() : return _reset()"); - - pkpy_vm_run(vm, - "def sfx(id, note=-1, duration=-1, channel=0, volume=15, speed=0) : " - "return _sfx(id, int(note), int(duration), int(channel), int(volume), int(speed))" - ); - - pkpy_vm_run(vm, - "def spr(id, x, y, colorkey=-1, scale=1, flip=0, rotate=0, w=1, h=1) : " - "return _spr(int(id), int(x), int(y), colorkey, int(scale), int(flip), int(rotate), int(w), int(h))" - ); - - pkpy_vm_run(vm, "def sync(mask=0, bank=0, tocart=False) : return _sync(int(mask), int(bank), bool(tocart))"); - - pkpy_vm_run(vm, "def time() : return _time()"); - pkpy_vm_run(vm, "def tstamp() : return _tstamp()"); - - pkpy_vm_run(vm, - "def tri(x1, y1, x2, y2, x3, y3, color) : " - "return _tri(float(x1), float(y1), float(x2), float(y2), float(x3), float(y3), int(color))" - ); - pkpy_vm_run(vm, - "def trib(x1, y1, x2, y2, x3, y3, color) : " - "return _trib(float(x1), float(y1), float(x2), float(y2), float(x3), float(y3), int(color))" - ); - - pkpy_vm_run(vm, - "def ttri(x1, y1, x2, y2, x3, y3, u1, v1, u2, v2, u3, v3, texsrc=0, chromakey=-1, z1=0, z2=0, z3=0) : " - "return _ttri(float(x1),float(y1),float(x2),float(y2),float(x3),float(y3),float(u1),float(v1),float(u2),float(v2),float(u3),float(v3),int(texsrc),chromakey,float(z1),float(z2),float(z3))" - ); - - pkpy_vm_run(vm, "def vbank(bank=None) : return _vbank(bank)"); - if(pkpy_check_error(vm)) return false; @@ -1433,7 +1344,7 @@ void closePython(tic_mem* tic) if (core->currentVM) { - pkpy_vm_destroy(core->currentVM); + pkpy_delete_vm(core->currentVM); core->currentVM = NULL; } } @@ -1453,7 +1364,7 @@ static bool initPython(tic_mem* tic, const char* code) closePython(tic); tic_core* core = (tic_core*)tic; - pkpy_vm* vm = pkpy_vm_create(false, false); + pkpy_vm* vm = pkpy_new_vm(false); core->currentVM = vm; @@ -1488,11 +1399,15 @@ void callPythonTick(tic_mem* tic) if (!core->currentVM) return; - if (pkpy_check_global(core->currentVM, TIC_FN)) - { - pkpy_get_global(core->currentVM, TIC_FN); - if(!pkpy_call(core->currentVM, 0)) - report_error(core, "error while running TIC\n"); + if(!pkpy_getglobal(core->currentVM, N()->TIC)){ + pkpy_clear_error(core->currentVM, NULL); + return; + } + pkpy_push_null(core->currentVM); + if(!pkpy_vectorcall(core->currentVM, 0)){ + report_error(core, "error while running TIC\n"); + }else{ + pkpy_pop_top(core->currentVM); } } void callPythonBoot(tic_mem* tic) { @@ -1500,11 +1415,15 @@ void callPythonBoot(tic_mem* tic) { if (!core->currentVM) return; - if (pkpy_check_global(core->currentVM, BOOT_FN)) - { - pkpy_get_global(core->currentVM, BOOT_FN); - if(!pkpy_call(core->currentVM, 0)) - report_error(core, "error while running BOOT\n"); + if(!pkpy_getglobal(core->currentVM, N()->BOOT)){ + pkpy_clear_error(core->currentVM, NULL); + return; + } + pkpy_push_null(core->currentVM); + if(!pkpy_vectorcall(core->currentVM, 0)){ + report_error(core, "error while running BOOT\n"); + }else{ + pkpy_pop_top(core->currentVM); } } @@ -1513,12 +1432,16 @@ void callPythonScanline(tic_mem* tic, s32 row, void* data) { if (!core->currentVM) return; - if (pkpy_check_global(core->currentVM, SCN_FN)) - { - pkpy_get_global(core->currentVM, SCN_FN); - pkpy_push_int(core->currentVM, row); - if(!pkpy_call(core->currentVM, 1)) - report_error(core, "error while running SCN\n"); + if(!pkpy_getglobal(core->currentVM, N()->SCN)){ + pkpy_clear_error(core->currentVM, NULL); + return; + } + pkpy_push_null(core->currentVM); + pkpy_push_int(core->currentVM, row); + if(!pkpy_vectorcall(core->currentVM, 1)){ + report_error(core, "error while running SCN\n"); + }else{ + pkpy_pop_top(core->currentVM); } } @@ -1527,12 +1450,16 @@ void callPythonBorder(tic_mem* tic, s32 row, void* data) { if (!core->currentVM) return; - if (pkpy_check_global(core->currentVM, BDR_FN)) - { - pkpy_get_global(core->currentVM, BDR_FN); - pkpy_push_int(core->currentVM, row); - if(!pkpy_call(core->currentVM, 1)) - report_error(core, "error while running BDR\n"); + if(!pkpy_getglobal(core->currentVM, N()->BDR)){ + pkpy_clear_error(core->currentVM, NULL); + return; + } + pkpy_push_null(core->currentVM); + pkpy_push_int(core->currentVM, row); + if(!pkpy_vectorcall(core->currentVM, 1)){ + report_error(core, "error while running BDR\n"); + }else{ + pkpy_pop_top(core->currentVM); } } @@ -1541,12 +1468,16 @@ void callPythonMenu(tic_mem* tic, s32 index, void* data) { if (!core->currentVM) return; - if (pkpy_check_global(core->currentVM, MENU_FN)) - { - pkpy_get_global(core->currentVM, MENU_FN); - pkpy_push_int(core->currentVM, index); - if(!pkpy_call(core->currentVM, 1)) - report_error(core, "error while running MENU\n"); + if(pkpy_getglobal(core->currentVM, N()->MENU)){ + pkpy_clear_error(core->currentVM, NULL); + return; + } + pkpy_push_null(core->currentVM); + pkpy_push_int(core->currentVM, index); + if(!pkpy_vectorcall(core->currentVM, 1)){ + report_error(core, "error while running MENU\n"); + }else{ + pkpy_pop_top(core->currentVM); } } @@ -1600,7 +1531,7 @@ next_word : comment : if (*code == 0) goto end; else if (*code == '\n') { code++; goto start; } - else { *code++; goto comment; } + else { code++; goto comment; } string : if (*code == 0) goto end; From 7da8523b81440f81fc71fb0a815b2953e43b85e2 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 04:25:48 +0800 Subject: [PATCH 45/83] fix a bug --- src/api/python.c | 4 ++-- vendor/pocketpy | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/python.c b/src/api/python.c index a4deec2b9..ae113ec18 100644 --- a/src/api/python.c +++ b/src/api/python.c @@ -826,7 +826,7 @@ static int py_print(pkpy_vm* vm) { int color; bool fixed; int scale; - bool small; + bool small_; bool alt; pkpy_to_string(vm, 0, &text); @@ -835,7 +835,7 @@ static int py_print(pkpy_vm* vm) { pkpy_to_int(vm, 3, &color); pkpy_to_bool(vm, 4, &fixed); pkpy_to_int(vm, 5, &scale); - pkpy_to_bool(vm, 6, &small); + pkpy_to_bool(vm, 6, &small_); pkpy_to_bool(vm, 7, &alt); get_core(vm, (tic_core**) &tic); if(pkpy_check_error(vm)) { diff --git a/vendor/pocketpy b/vendor/pocketpy index b97e283fd..a19a6b349 160000 --- a/vendor/pocketpy +++ b/vendor/pocketpy @@ -1 +1 @@ -Subproject commit b97e283fd84ae097d8593f8042c7c75f21da4d1f +Subproject commit a19a6b349bac66008779bde16dd8b312f220a2ca From 19126e6c5a725e67b80a0ef651d84eca6d960402 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 04:33:47 +0800 Subject: [PATCH 46/83] some more fix --- CMakeLists.txt | 1 + vendor/pocketpy | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9cfdfa62c..bb34269a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -406,6 +406,7 @@ set_target_properties(pocketpy PROPERTIES OUTPUT_NAME python) set_target_properties(pocketpy PROPERTIES LINKER_LANGUAGE CXX) target_compile_definitions(pocketpy PRIVATE PK_ENABLE_OS=0) +target_include_directories(pocketpy PRIVATE ${POCKETPY_DIR}/include) # set(POCKETPY_DIR ${THIRDPARTY_DIR}/pocketpy) diff --git a/vendor/pocketpy b/vendor/pocketpy index a19a6b349..405b8188f 160000 --- a/vendor/pocketpy +++ b/vendor/pocketpy @@ -1 +1 @@ -Subproject commit a19a6b349bac66008779bde16dd8b312f220a2ca +Subproject commit 405b8188ff743d59de6df2af39d3c4f85dd0df17 From dd162d56e57041718c4baea40a5e3127cbaadb21 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 04:44:47 +0800 Subject: [PATCH 47/83] some more fix --- CMakeLists.txt | 36 ++---------------------------------- src/api/python.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb34269a4..67dfdfa9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -397,7 +397,7 @@ target_include_directories(squirrel PRIVATE ${SQUIRREL_DIR}/squirrel) target_include_directories(squirrel PRIVATE ${SQUIRREL_DIR}/sqstdlib) ################################ -# PocketPy (Python) +# pocketpy (Python) ################################ add_subdirectory(${THIRDPARTY_DIR}/pocketpy) @@ -406,39 +406,7 @@ set_target_properties(pocketpy PROPERTIES OUTPUT_NAME python) set_target_properties(pocketpy PROPERTIES LINKER_LANGUAGE CXX) target_compile_definitions(pocketpy PRIVATE PK_ENABLE_OS=0) -target_include_directories(pocketpy PRIVATE ${POCKETPY_DIR}/include) - -# set(POCKETPY_DIR ${THIRDPARTY_DIR}/pocketpy) - -# if (${CMAKE_VERSION} VERSION_LESS "3.12.0") -# set(Python3_EXECUTABLE "python3") -# else() -# find_package(Python3 COMPONENTS Interpreter) -# endif() - -# add_custom_command( -# OUTPUT ${POCKETPY_DIR}/src/_generated.h -# COMMAND ${Python3_EXECUTABLE} preprocess.py -# WORKING_DIRECTORY ${POCKETPY_DIR} -# DEPENDS ${POCKETPY_DIR}/preprocess.py -# ) - -# add_library(python STATIC -# ${POCKETPY_DIR}/src/_generated.h -# ${POCKETPY_DIR}/c_bindings/pocketpy_c.cpp -# ) - -# set_target_properties(python PROPERTIES LINKER_LANGUAGE CXX) -# target_compile_definitions(python PRIVATE PK_ENABLE_OS=0) -# target_include_directories(python -# PRIVATE ${POCKETPY_DIR}/src -# PUBLIC ${POCKETPY_DIR}/c_bindings) - -# if (${CMAKE_VERSION} VERSION_LESS "3.8.0") -# set_target_properties(python PROPERTIES COMPILE_FLAGS "--std=c++17") -# else() -# target_compile_features(python PRIVATE cxx_std_17) -# endif() +target_include_directories(pocketpy PUBLIC ${POCKETPY_DIR}/include) ################################ # GIFLIB diff --git a/src/api/python.c b/src/api/python.c index ae113ec18..e5b801e55 100644 --- a/src/api/python.c +++ b/src/api/python.c @@ -115,8 +115,10 @@ static int py_trace(pkpy_vm* vm) pkpy_CString message; int color; + pkpy_dup(vm, 0); pkpy_py_str(vm); - pkpy_to_string(vm, 0, &message); + pkpy_to_string(vm, -1, &message); + pkpy_to_int(vm, 1, &color); get_core(vm, (tic_core**) &tic); if (pkpy_check_error(vm)) @@ -447,7 +449,7 @@ static void remap_callback(void* data, s32 x, s32 y, RemapResult* result) { pkpy_push_int(vm, y); pkpy_vectorcall(vm, 2); - + pkpy_unpack_sequence(vm, 3); int index, flip, rotate; pkpy_to_int(vm, -3, &index); pkpy_to_int(vm, -2, &flip); @@ -829,7 +831,10 @@ static int py_print(pkpy_vm* vm) { bool small_; bool alt; - pkpy_to_string(vm, 0, &text); + pkpy_dup(vm, 0); + pkpy_py_str(vm); + pkpy_to_string(vm, -1, &text); + pkpy_to_int(vm, 1, &x); pkpy_to_int(vm, 2, &y); pkpy_to_int(vm, 3, &color); From 61cb70550cc8fad4fb794d4e61cc4b0b3341c74f Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 04:47:00 +0800 Subject: [PATCH 48/83] a small fix --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 67dfdfa9f..4c09902c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -406,7 +406,7 @@ set_target_properties(pocketpy PROPERTIES OUTPUT_NAME python) set_target_properties(pocketpy PROPERTIES LINKER_LANGUAGE CXX) target_compile_definitions(pocketpy PRIVATE PK_ENABLE_OS=0) -target_include_directories(pocketpy PUBLIC ${POCKETPY_DIR}/include) +target_include_directories(pocketpy PUBLIC ${THIRDPARTY_DIR}/pocketpy/include) ################################ # GIFLIB From c5705e71c9fd86df773a9ee033d128383328fe91 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 04:57:37 +0800 Subject: [PATCH 49/83] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c09902c1..a224ca540 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -406,7 +406,7 @@ set_target_properties(pocketpy PROPERTIES OUTPUT_NAME python) set_target_properties(pocketpy PROPERTIES LINKER_LANGUAGE CXX) target_compile_definitions(pocketpy PRIVATE PK_ENABLE_OS=0) -target_include_directories(pocketpy PUBLIC ${THIRDPARTY_DIR}/pocketpy/include) +include_directories(${THIRDPARTY_DIR}/pocketpy/include) ################################ # GIFLIB From 23d87ab455e27b0e8bf6eb8f9f8af4ef785a8a54 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 10:33:39 +0800 Subject: [PATCH 50/83] Update CMakeLists.txt --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a224ca540..f02e88def 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -402,12 +402,13 @@ target_include_directories(squirrel PRIVATE ${SQUIRREL_DIR}/sqstdlib) add_subdirectory(${THIRDPARTY_DIR}/pocketpy) -set_target_properties(pocketpy PROPERTIES OUTPUT_NAME python) set_target_properties(pocketpy PROPERTIES LINKER_LANGUAGE CXX) - target_compile_definitions(pocketpy PRIVATE PK_ENABLE_OS=0) include_directories(${THIRDPARTY_DIR}/pocketpy/include) +# alias pocketpy to python for next steps +add_library(python ALIAS pocketpy) + ################################ # GIFLIB ################################ From 167384e724693a44031931e603afbfe17ac2ea82 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 10:44:46 +0800 Subject: [PATCH 51/83] ... --- CMakeLists.txt | 4 ++++ src/api/python.c | 6 +----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f02e88def..8fc6e3b9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -406,6 +406,10 @@ set_target_properties(pocketpy PROPERTIES LINKER_LANGUAGE CXX) target_compile_definitions(pocketpy PRIVATE PK_ENABLE_OS=0) include_directories(${THIRDPARTY_DIR}/pocketpy/include) +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(pocketpy PRIVATE -Wno-psabi) +endif() + # alias pocketpy to python for next steps add_library(python ALIAS pocketpy) diff --git a/src/api/python.c b/src/api/python.c index e5b801e55..25bfcdbd8 100644 --- a/src/api/python.c +++ b/src/api/python.c @@ -46,10 +46,6 @@ static void pkpy_setglobal_2(pkpy_vm* vm, const char* name){ pkpy_setglobal(vm, pkpy_name(name)); } -static bool pkpy_vm_run(pkpy_vm* vm, const char* src){ - return 0; -} - static bool get_core(pkpy_vm* vm, tic_core** core) { pkpy_getglobal(vm, N()->_tic_core); @@ -1388,7 +1384,7 @@ static bool initPython(tic_mem* tic, const char* code) return false; } - if(!pkpy_vm_run(vm, code)) + if(!pkpy_exec(vm, code)) { report_error(core, "error while processing the main code\n"); From a7305f3079bdd013f0943b65d2156ca8bbcd8388 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 10:56:17 +0800 Subject: [PATCH 52/83] small update --- src/api/python.c | 29 +++++++++-------------------- vendor/pocketpy | 2 +- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/api/python.c b/src/api/python.c index 25bfcdbd8..9614a575f 100644 --- a/src/api/python.c +++ b/src/api/python.c @@ -6,7 +6,7 @@ #include #include -typedef struct CachedNames{ +struct CachedNames{ bool initialized; pkpy_CName _tic_core; pkpy_CName len; @@ -16,11 +16,10 @@ typedef struct CachedNames{ pkpy_CName SCN; pkpy_CName BDR; pkpy_CName MENU; -} CachedNames; +}_cached_names; -CachedNames _cached_names; - -static CachedNames* N(){ +static struct CachedNames* N(){ + // use cached names to improve performance if(!_cached_names.initialized){ _cached_names._tic_core = pkpy_name("_tic_core"); _cached_names.len = pkpy_name("len"); @@ -35,6 +34,7 @@ static CachedNames* N(){ return &_cached_names; } +// duplicate a pkpy_CString to a null-terminated c string static char* cstrdup(pkpy_CString cs){ char* s = (char*)malloc(cs.size + 1); memcpy(s, cs.data, cs.size); @@ -49,14 +49,15 @@ static void pkpy_setglobal_2(pkpy_vm* vm, const char* name){ static bool get_core(pkpy_vm* vm, tic_core** core) { pkpy_getglobal(vm, N()->_tic_core); - return pkpy_to_voidp(vm, -1, (void**) core); + bool ok = pkpy_to_voidp(vm, -1, (void**) core); + if(ok) pkpy_pop_top(vm); + return ok; } static bool setup_core(pkpy_vm* vm, tic_core* core) { if (!pkpy_push_voidp(vm, core)) return false; - if (!pkpy_setglobal(vm, N()->_tic_core)) return false; - return true; + return pkpy_setglobal(vm, N()->_tic_core); } //index should be a positive index @@ -1332,13 +1333,6 @@ static bool setup_c_bindings(pkpy_vm* vm) { return true; } -static bool setup_py_bindings(pkpy_vm* vm) { - if(pkpy_check_error(vm)) - return false; - - return true; -} - void closePython(tic_mem* tic) { tic_core* core = (tic_core*)tic; @@ -1378,11 +1372,6 @@ static bool initPython(tic_mem* tic, const char* code) report_error(core, "problem setting up the c bindings (pocketpy c binding bug\n"); return false; } - if (!setup_py_bindings(vm)) - { - report_error(core, "problem setting up the py bindings (pocketpy c binding bug\n"); - return false; - } if(!pkpy_exec(vm, code)) { diff --git a/vendor/pocketpy b/vendor/pocketpy index 405b8188f..ea2e16c93 160000 --- a/vendor/pocketpy +++ b/vendor/pocketpy @@ -1 +1 @@ -Subproject commit 405b8188ff743d59de6df2af39d3c4f85dd0df17 +Subproject commit ea2e16c9316f47642453fa8b438e890287f50341 From 403859bc6188a3ba023af4093438e69034de8787 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 11:07:23 +0800 Subject: [PATCH 53/83] Update pocketpy --- vendor/pocketpy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/pocketpy b/vendor/pocketpy index ea2e16c93..dc692a383 160000 --- a/vendor/pocketpy +++ b/vendor/pocketpy @@ -1 +1 @@ -Subproject commit ea2e16c9316f47642453fa8b438e890287f50341 +Subproject commit dc692a3835c4a11dd135c78d62c2f2acad33614f From c0c605cb0bd5254f9ff63b5c86ea929a8ecd34e2 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 11:09:06 +0800 Subject: [PATCH 54/83] Update pocketpy --- vendor/pocketpy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/pocketpy b/vendor/pocketpy index dc692a383..a889df2c0 160000 --- a/vendor/pocketpy +++ b/vendor/pocketpy @@ -1 +1 @@ -Subproject commit dc692a3835c4a11dd135c78d62c2f2acad33614f +Subproject commit a889df2c09358b1ed7777a7775c18c0da0a24da4 From 38ee7f9180882a09a16a9fa62a3d56f8b4b44193 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 11:27:32 +0800 Subject: [PATCH 55/83] try fix cmake error --- CMakeLists.txt | 3 +++ src/api/python.c | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fc6e3b9b..ccc09849a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -403,7 +403,10 @@ target_include_directories(squirrel PRIVATE ${SQUIRREL_DIR}/sqstdlib) add_subdirectory(${THIRDPARTY_DIR}/pocketpy) set_target_properties(pocketpy PROPERTIES LINKER_LANGUAGE CXX) +set_target_properties(pocketpy PROPERTIES OUTPUT_NAME python) + target_compile_definitions(pocketpy PRIVATE PK_ENABLE_OS=0) + include_directories(${THIRDPARTY_DIR}/pocketpy/include) if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/src/api/python.c b/src/api/python.c index 9614a575f..cf9dc5bbe 100644 --- a/src/api/python.c +++ b/src/api/python.c @@ -1550,7 +1550,18 @@ multiline_string_escape : void evalPython(tic_mem* tic, const char* code) { - printf("TODO: python eval not yet implemented\n."); + tic_core* core = (tic_core*)tic; + pkpy_vm* vm = core->currentVM; + if (!vm) return; + + if(!pkpy_exec(vm, code)) + { + char* msg; + if(pkpy_clear_error(vm, &msg)){ + core->data->error(core->data->data, msg); + pkpy_free(msg); + } + } } From f3287c3146e2975f87b237beae092acd9edc5b93 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 11:31:15 +0800 Subject: [PATCH 56/83] ... --- CMakeLists.txt | 1 - src/api/python.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ccc09849a..7b598c54a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -403,7 +403,6 @@ target_include_directories(squirrel PRIVATE ${SQUIRREL_DIR}/sqstdlib) add_subdirectory(${THIRDPARTY_DIR}/pocketpy) set_target_properties(pocketpy PROPERTIES LINKER_LANGUAGE CXX) -set_target_properties(pocketpy PROPERTIES OUTPUT_NAME python) target_compile_definitions(pocketpy PRIVATE PK_ENABLE_OS=0) diff --git a/src/api/python.c b/src/api/python.c index cf9dc5bbe..ad3cd5f6a 100644 --- a/src/api/python.c +++ b/src/api/python.c @@ -928,7 +928,7 @@ static int py_sfx(pkpy_vm* vm) get_core(vm, (tic_core**) &tic); if(pkpy_check_error(vm)) goto cleanup; - int note, octave; + s32 note, octave; if (parse_note) { if(!tic_tool_parse_note(string_note, ¬e, &octave)) { From 7cf65f4ef1d25b6c8821f534e16f1f2157fe12d5 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 11:34:18 +0800 Subject: [PATCH 57/83] Update CMakeLists.txt --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b598c54a..ccc09849a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -403,6 +403,7 @@ target_include_directories(squirrel PRIVATE ${SQUIRREL_DIR}/sqstdlib) add_subdirectory(${THIRDPARTY_DIR}/pocketpy) set_target_properties(pocketpy PROPERTIES LINKER_LANGUAGE CXX) +set_target_properties(pocketpy PROPERTIES OUTPUT_NAME python) target_compile_definitions(pocketpy PRIVATE PK_ENABLE_OS=0) From c189a5d28c76ab6560d44360a613c9be5b6314cc Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 12:00:25 +0800 Subject: [PATCH 58/83] some update Update CMakeLists.txt Update CMakeLists.txt --- CMakeLists.txt | 11 +++++++++-- src/api/python.c | 14 +++++++------- vendor/pocketpy | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ccc09849a..b06cad4fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -403,8 +403,6 @@ target_include_directories(squirrel PRIVATE ${SQUIRREL_DIR}/sqstdlib) add_subdirectory(${THIRDPARTY_DIR}/pocketpy) set_target_properties(pocketpy PROPERTIES LINKER_LANGUAGE CXX) -set_target_properties(pocketpy PROPERTIES OUTPUT_NAME python) - target_compile_definitions(pocketpy PRIVATE PK_ENABLE_OS=0) include_directories(${THIRDPARTY_DIR}/pocketpy/include) @@ -414,7 +412,16 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") endif() # alias pocketpy to python for next steps +<<<<<<< HEAD +set_target_properties(pocketpy PROPERTIES OUTPUT_NAME python) add_library(python ALIAS pocketpy) +======= +if(BAREMETALPI) + set_target_properties(pocketpy PROPERTIES OUTPUT_NAME python) +else() + add_library(python ALIAS pocketpy) +endif() +>>>>>>> 57221aab8efd3e54eb975607b70414adf0a67469 ################################ # GIFLIB diff --git a/src/api/python.c b/src/api/python.c index ad3cd5f6a..49745d4e1 100644 --- a/src/api/python.c +++ b/src/api/python.c @@ -1225,7 +1225,7 @@ static bool setup_c_bindings(pkpy_vm* vm) { pkpy_push_function(vm, "fset(sprite_id: int, flag: int, b: bool)", py_fset); pkpy_setglobal_2(vm, "fset"); - pkpy_push_function(vm, "font(text: str, x: int, y: int, chromakey: int, char_width: int=8, char_height: int=8, fixed: bool=False, scale: int=1, alt: bool=False)", py_font); + pkpy_push_function(vm, "font(text: str, x: int, y: int, chromakey: int, char_width=8, char_height=8, fixed=False, scale=1, alt=False)", py_font); pkpy_setglobal_2(vm, "font"); pkpy_push_function(vm, "key(code=-1)", py_key); @@ -1237,7 +1237,7 @@ static bool setup_c_bindings(pkpy_vm* vm) { pkpy_push_function(vm, "line(x0: int, y0: int, x1: int, y1: int, color: int)", py_line); pkpy_setglobal_2(vm, "line"); - pkpy_push_function(vm, "map(x: int=0, y: int=0, w: int=30, h: int=17, sx: int=0, sy: int=0, colorkey: int=-1, scale: int=1, remap: list=None)", py_map); + pkpy_push_function(vm, "map(x=0, y=0, w=30, h=17, sx=0, sy=0, colorkey=-1, scale=1, remap: list=None)", py_map); pkpy_setglobal_2(vm, "map"); pkpy_push_function(vm, "memcpy(dest: int, source: int, size: int)", py_memcpy); @@ -1288,7 +1288,7 @@ static bool setup_c_bindings(pkpy_vm* vm) { pkpy_push_function(vm, "poke4(addr: int, value: int)", py_poke4); pkpy_setglobal_2(vm, "poke4"); - pkpy_push_function(vm, "print(text: str, x: int=0, y: int=0, color: int=15, fixed: bool=False, scale: int=1, smallfont: bool=False, alt: bool=False)", py_print); + pkpy_push_function(vm, "print(text: str, x=0, y=0, color=15, fixed=False, scale=1, smallfont=False, alt=False)", py_print); pkpy_setglobal_2(vm, "print"); pkpy_push_function(vm, "rect(x: int, y: int, w: int, h: int, color: int)", py_rect); @@ -1300,13 +1300,13 @@ static bool setup_c_bindings(pkpy_vm* vm) { pkpy_push_function(vm, "reset()", py_reset); pkpy_setglobal_2(vm, "reset"); - pkpy_push_function(vm, "sfx(id: int, note: int=-1, duration: int=-1, channel: int=0, volume: int=15, speed: int=0)", py_sfx); + pkpy_push_function(vm, "sfx(id: int, note=-1, duration=-1, channel=0, volume=15, speed=0)", py_sfx); pkpy_setglobal_2(vm, "sfx"); - pkpy_push_function(vm, "spr(id: int, x: int, y: int, colorkey: int=-1, scale: int=1, flip: int=0, rotate: int=0, w: int=1, h: int=1)", py_spr); + pkpy_push_function(vm, "spr(id: int, x: int, y: int, colorkey=-1, scale=1, flip=0, rotate=0, w=1, h=1)", py_spr); pkpy_setglobal_2(vm, "spr"); - pkpy_push_function(vm, "sync(mask: int=0, bank: int=0, tocart: bool=False)", py_sync); + pkpy_push_function(vm, "sync(mask=0, bank=0, tocart=False)", py_sync); pkpy_setglobal_2(vm, "sync"); pkpy_push_function(vm, "time()", py_time); @@ -1321,7 +1321,7 @@ static bool setup_c_bindings(pkpy_vm* vm) { pkpy_push_function(vm, "trib(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, color: int)", py_trib); pkpy_setglobal_2(vm, "trib"); - pkpy_push_function(vm, "ttri(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, u1: float, v1: float, u2: float, v2: float, u3: float, v3: float, texsrc: int=0, chromakey: int=-1, z1: float=0, z2: float=0, z3: float=0)", py_ttri); + pkpy_push_function(vm, "ttri(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, u1: float, v1: float, u2: float, v2: float, u3: float, v3: float, texsrc=0, chromakey=-1, z1: float=0, z2: float=0, z3: float=0)", py_ttri); pkpy_setglobal_2(vm, "ttri"); pkpy_push_function(vm, "vbank(bank: int=None)", py_vbank); diff --git a/vendor/pocketpy b/vendor/pocketpy index a889df2c0..a3d4e6695 160000 --- a/vendor/pocketpy +++ b/vendor/pocketpy @@ -1 +1 @@ -Subproject commit a889df2c09358b1ed7777a7775c18c0da0a24da4 +Subproject commit a3d4e6695850dd0c0114176a2be23635db6322a7 From 7392d9b13d112f6fa065292f5b1b79b054d01a4c Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 14:26:36 +0800 Subject: [PATCH 59/83] Update CMakeLists.txt --- CMakeLists.txt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b06cad4fd..ae55e4fd3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -412,16 +412,8 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") endif() # alias pocketpy to python for next steps -<<<<<<< HEAD set_target_properties(pocketpy PROPERTIES OUTPUT_NAME python) add_library(python ALIAS pocketpy) -======= -if(BAREMETALPI) - set_target_properties(pocketpy PROPERTIES OUTPUT_NAME python) -else() - add_library(python ALIAS pocketpy) -endif() ->>>>>>> 57221aab8efd3e54eb975607b70414adf0a67469 ################################ # GIFLIB From e72b2751c0fd56be9562f32a58cb40be93b65d34 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 14:29:11 +0800 Subject: [PATCH 60/83] Update build.yml --- .github/workflows/build.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 22b0d2be8..8de537f4a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -161,6 +161,14 @@ jobs: runs-on: windows-2019 steps: + # https://github.com/actions/runner-images/issues/2642#issuecomment-774988591 + - name: configure Pagefile + uses: al-cheb/configure-pagefile-action@v1.2 + with: + minimum-size: 16GB + maximum-size: 16GB + disk-root: "C:" + - uses: ruby/setup-ruby@v1 with: ruby-version: 2.6 From d4c18ab716e512cde6b18750a6b9a14c49515e94 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 15:13:09 +0800 Subject: [PATCH 61/83] Update python.c --- src/api/python.c | 88 ++++++++++++++++++------------------------------ 1 file changed, 32 insertions(+), 56 deletions(-) diff --git a/src/api/python.c b/src/api/python.c index 49745d4e1..76f16984f 100644 --- a/src/api/python.c +++ b/src/api/python.c @@ -7,7 +7,6 @@ #include struct CachedNames{ - bool initialized; pkpy_CName _tic_core; pkpy_CName len; pkpy_CName __getitem__; @@ -16,23 +15,7 @@ struct CachedNames{ pkpy_CName SCN; pkpy_CName BDR; pkpy_CName MENU; -}_cached_names; - -static struct CachedNames* N(){ - // use cached names to improve performance - if(!_cached_names.initialized){ - _cached_names._tic_core = pkpy_name("_tic_core"); - _cached_names.len = pkpy_name("len"); - _cached_names.__getitem__ = pkpy_name("__getitem__"); - _cached_names.TIC = pkpy_name("TIC"); - _cached_names.BOOT = pkpy_name("BOOT"); - _cached_names.SCN = pkpy_name("SCN"); - _cached_names.BDR = pkpy_name("BDR"); - _cached_names.MENU = pkpy_name("MENU"); - _cached_names.initialized = true; - } - return &_cached_names; -} +} N; // duplicate a pkpy_CString to a null-terminated c string static char* cstrdup(pkpy_CString cs){ @@ -48,7 +31,7 @@ static void pkpy_setglobal_2(pkpy_vm* vm, const char* name){ static bool get_core(pkpy_vm* vm, tic_core** core) { - pkpy_getglobal(vm, N()->_tic_core); + pkpy_getglobal(vm, N._tic_core); bool ok = pkpy_to_voidp(vm, -1, (void**) core); if(ok) pkpy_pop_top(vm); return ok; @@ -57,7 +40,7 @@ static bool get_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); + return pkpy_setglobal(vm, N._tic_core); } //index should be a positive index @@ -78,7 +61,7 @@ static int prepare_colorindex(pkpy_vm* vm, int index, u8 * buffer) } else { //should be a list then - pkpy_getglobal(vm, N()->len); + pkpy_getglobal(vm, N.len); pkpy_push_null(vm); pkpy_dup(vm, index); //get the list pkpy_vectorcall(vm, 1); @@ -93,7 +76,7 @@ static int prepare_colorindex(pkpy_vm* vm, int index, u8 * buffer) { int list_val; pkpy_dup(vm, index); //get the list - pkpy_get_unbound_method(vm, N()->__getitem__); + pkpy_get_unbound_method(vm, N.__getitem__); pkpy_push_int(vm, i); pkpy_vectorcall(vm, 1); pkpy_to_int(vm, -1, &list_val); @@ -1188,40 +1171,32 @@ static int py_vbank(pkpy_vm* vm) { } static bool setup_c_bindings(pkpy_vm* vm) { - pkpy_push_function(vm, "trace(message, color=15)", py_trace); - pkpy_setglobal_2(vm, "trace"); - - pkpy_push_function(vm, "cls(color=0)", py_cls); - pkpy_setglobal_2(vm, "cls"); - - //lua api does this for btn pkpy_push_function(vm, "btn(id: int)", py_btn); pkpy_setglobal_2(vm, "btn"); - pkpy_push_function(vm, "btnp(id: int, hold=-1, period=-1)", py_btnp); pkpy_setglobal_2(vm, "btnp"); pkpy_push_function(vm, "circ(x: int, y: int, radius: int, color: int)", py_circ); pkpy_setglobal_2(vm, "circ"); - pkpy_push_function(vm, "circb(x: int, y: int, radius: int, color: int)", py_circb); pkpy_setglobal_2(vm, "circb"); + pkpy_push_function(vm, "clip(x: int, y: int, width: int, height: int)", py_clip); + pkpy_setglobal_2(vm, "clip"); + + pkpy_push_function(vm, "cls(color=0)", py_cls); + pkpy_setglobal_2(vm, "cls"); + pkpy_push_function(vm, "elli(x: int, y: int, a: int, b: int, color: int)", py_elli); pkpy_setglobal_2(vm, "elli"); - pkpy_push_function(vm, "ellib(x: int, y: int, a: int, b: int, color: int)", py_ellib); pkpy_setglobal_2(vm, "ellib"); - pkpy_push_function(vm, "clip(x: int, y: int, width: int, height: int)", py_clip); - pkpy_setglobal_2(vm, "clip"); - pkpy_push_function(vm, "exit()", py_exit); pkpy_setglobal_2(vm, "exit"); pkpy_push_function(vm, "fget(sprite_id: int, flag: int)", py_fget); pkpy_setglobal_2(vm, "fget"); - pkpy_push_function(vm, "fset(sprite_id: int, flag: int, b: bool)", py_fset); pkpy_setglobal_2(vm, "fset"); @@ -1230,7 +1205,6 @@ static bool setup_c_bindings(pkpy_vm* vm) { pkpy_push_function(vm, "key(code=-1)", py_key); pkpy_setglobal_2(vm, "key"); - pkpy_push_function(vm, "keyp(code=-1, hold=-1, period=-17)", py_keyp); pkpy_setglobal_2(vm, "keyp"); @@ -1242,13 +1216,11 @@ static bool setup_c_bindings(pkpy_vm* vm) { pkpy_push_function(vm, "memcpy(dest: int, source: int, size: int)", py_memcpy); pkpy_setglobal_2(vm, "memcpy"); - pkpy_push_function(vm, "memset(dest: int, value: int, size: int)", py_memset); pkpy_setglobal_2(vm, "memset"); pkpy_push_function(vm, "mget(x: int, y: int)", py_mget); pkpy_setglobal_2(vm, "mget"); - pkpy_push_function(vm, "mset(x: int, y: int, tile_id: int)", py_mset); pkpy_setglobal_2(vm, "mset"); @@ -1260,13 +1232,10 @@ static bool setup_c_bindings(pkpy_vm* vm) { pkpy_push_function(vm, "peek(addr: int, bits=8)", py_peek); pkpy_setglobal_2(vm, "peek"); - pkpy_push_function(vm, "peek1(addr: int)", py_peek1); pkpy_setglobal_2(vm, "peek1"); - pkpy_push_function(vm, "peek2(addr: int)", py_peek2); pkpy_setglobal_2(vm, "peek2"); - pkpy_push_function(vm, "peek4(addr: int)", py_peek4); pkpy_setglobal_2(vm, "peek4"); @@ -1278,13 +1247,10 @@ static bool setup_c_bindings(pkpy_vm* vm) { pkpy_push_function(vm, "poke(addr: int, value: int, bits=8)", py_poke); pkpy_setglobal_2(vm, "poke"); - pkpy_push_function(vm, "poke1(addr: int, value: int)", py_poke1); pkpy_setglobal_2(vm, "poke1"); - pkpy_push_function(vm, "poke2(addr: int, value: int)", py_poke2); pkpy_setglobal_2(vm, "poke2"); - pkpy_push_function(vm, "poke4(addr: int, value: int)", py_poke4); pkpy_setglobal_2(vm, "poke4"); @@ -1293,7 +1259,6 @@ static bool setup_c_bindings(pkpy_vm* vm) { pkpy_push_function(vm, "rect(x: int, y: int, w: int, h: int, color: int)", py_rect); pkpy_setglobal_2(vm, "rect"); - pkpy_push_function(vm, "rectb(x: int, y: int, w: int, h: int, color: int)", py_rectb); pkpy_setglobal_2(vm, "rectb"); @@ -1309,20 +1274,22 @@ static bool setup_c_bindings(pkpy_vm* vm) { pkpy_push_function(vm, "sync(mask=0, bank=0, tocart=False)", py_sync); pkpy_setglobal_2(vm, "sync"); + pkpy_push_function(vm, "ttri(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, u1: float, v1: float, u2: float, v2: float, u3: float, v3: float, texsrc=0, chromakey=-1, z1: float=0, z2: float=0, z3: float=0)", py_ttri); + pkpy_setglobal_2(vm, "ttri"); + pkpy_push_function(vm, "time()", py_time); pkpy_setglobal_2(vm, "time"); - pkpy_push_function(vm, "tstamp()", py_tstamp); - pkpy_setglobal_2(vm, "tstamp"); + pkpy_push_function(vm, "trace(message, color=15)", py_trace); + pkpy_setglobal_2(vm, "trace"); pkpy_push_function(vm, "tri(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, color: int)", py_tri); pkpy_setglobal_2(vm, "tri"); - pkpy_push_function(vm, "trib(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, color: int)", py_trib); pkpy_setglobal_2(vm, "trib"); - pkpy_push_function(vm, "ttri(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, u1: float, v1: float, u2: float, v2: float, u3: float, v3: float, texsrc=0, chromakey=-1, z1: float=0, z2: float=0, z3: float=0)", py_ttri); - pkpy_setglobal_2(vm, "ttri"); + pkpy_push_function(vm, "tstamp()", py_tstamp); + pkpy_setglobal_2(vm, "tstamp"); pkpy_push_function(vm, "vbank(bank: int=None)", py_vbank); pkpy_setglobal_2(vm, "vbank"); @@ -1356,6 +1323,15 @@ static void report_error(tic_core* core, char* prefix) { static bool initPython(tic_mem* tic, const char* code) { + N._tic_core = pkpy_name("_tic_core"); + N.len = pkpy_name("len"); + N.__getitem__ = pkpy_name("__getitem__"); + N.TIC = pkpy_name("TIC"); + N.BOOT = pkpy_name("BOOT"); + N.SCN = pkpy_name("SCN"); + N.BDR = pkpy_name("BDR"); + N.MENU = pkpy_name("MENU"); + closePython(tic); tic_core* core = (tic_core*)tic; @@ -1389,7 +1365,7 @@ void callPythonTick(tic_mem* tic) if (!core->currentVM) return; - if(!pkpy_getglobal(core->currentVM, N()->TIC)){ + if(!pkpy_getglobal(core->currentVM, N.TIC)){ pkpy_clear_error(core->currentVM, NULL); return; } @@ -1405,7 +1381,7 @@ void callPythonBoot(tic_mem* tic) { if (!core->currentVM) return; - if(!pkpy_getglobal(core->currentVM, N()->BOOT)){ + if(!pkpy_getglobal(core->currentVM, N.BOOT)){ pkpy_clear_error(core->currentVM, NULL); return; } @@ -1422,7 +1398,7 @@ void callPythonScanline(tic_mem* tic, s32 row, void* data) { if (!core->currentVM) return; - if(!pkpy_getglobal(core->currentVM, N()->SCN)){ + if(!pkpy_getglobal(core->currentVM, N.SCN)){ pkpy_clear_error(core->currentVM, NULL); return; } @@ -1440,7 +1416,7 @@ void callPythonBorder(tic_mem* tic, s32 row, void* data) { if (!core->currentVM) return; - if(!pkpy_getglobal(core->currentVM, N()->BDR)){ + if(!pkpy_getglobal(core->currentVM, N.BDR)){ pkpy_clear_error(core->currentVM, NULL); return; } @@ -1458,7 +1434,7 @@ void callPythonMenu(tic_mem* tic, s32 index, void* data) { if (!core->currentVM) return; - if(pkpy_getglobal(core->currentVM, N()->MENU)){ + if(pkpy_getglobal(core->currentVM, N.MENU)){ pkpy_clear_error(core->currentVM, NULL); return; } From 039a7c61803de7e8eeabbf014c95cdabe096e91f Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 15:27:48 +0800 Subject: [PATCH 62/83] Update python.c --- src/api/python.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/api/python.c b/src/api/python.c index 76f16984f..254187951 100644 --- a/src/api/python.c +++ b/src/api/python.c @@ -1171,9 +1171,9 @@ static int py_vbank(pkpy_vm* vm) { } static bool setup_c_bindings(pkpy_vm* vm) { - pkpy_push_function(vm, "btn(id: int)", py_btn); + pkpy_push_function(vm, "btn(id: int) -> bool", py_btn); pkpy_setglobal_2(vm, "btn"); - pkpy_push_function(vm, "btnp(id: int, hold=-1, period=-1)", py_btnp); + pkpy_push_function(vm, "btnp(id: int, hold=-1, period=-1) -> bool", py_btnp); pkpy_setglobal_2(vm, "btnp"); pkpy_push_function(vm, "circ(x: int, y: int, radius: int, color: int)", py_circ); @@ -1195,23 +1195,23 @@ static bool setup_c_bindings(pkpy_vm* vm) { pkpy_push_function(vm, "exit()", py_exit); pkpy_setglobal_2(vm, "exit"); - pkpy_push_function(vm, "fget(sprite_id: int, flag: int)", py_fget); + pkpy_push_function(vm, "fget(sprite_id: int, flag: int) -> bool", py_fget); pkpy_setglobal_2(vm, "fget"); pkpy_push_function(vm, "fset(sprite_id: int, flag: int, b: bool)", py_fset); pkpy_setglobal_2(vm, "fset"); - pkpy_push_function(vm, "font(text: str, x: int, y: int, chromakey: int, char_width=8, char_height=8, fixed=False, scale=1, alt=False)", py_font); + pkpy_push_function(vm, "font(text: str, x: int, y: int, chromakey: int, char_width=8, char_height=8, fixed=False, scale=1, alt=False) -> int", py_font); pkpy_setglobal_2(vm, "font"); - pkpy_push_function(vm, "key(code=-1)", py_key); + pkpy_push_function(vm, "key(code=-1) -> bool", py_key); pkpy_setglobal_2(vm, "key"); - pkpy_push_function(vm, "keyp(code=-1, hold=-1, period=-17)", py_keyp); + pkpy_push_function(vm, "keyp(code=-1, hold=-1, period=-17) -> int", py_keyp); pkpy_setglobal_2(vm, "keyp"); pkpy_push_function(vm, "line(x0: int, y0: int, x1: int, y1: int, color: int)", py_line); pkpy_setglobal_2(vm, "line"); - pkpy_push_function(vm, "map(x=0, y=0, w=30, h=17, sx=0, sy=0, colorkey=-1, scale=1, remap: list=None)", py_map); + pkpy_push_function(vm, "map(x=0, y=0, w=30, h=17, sx=0, sy=0, colorkey=-1, scale=1, remap=None)", py_map); pkpy_setglobal_2(vm, "map"); pkpy_push_function(vm, "memcpy(dest: int, source: int, size: int)", py_memcpy); @@ -1219,30 +1219,30 @@ static bool setup_c_bindings(pkpy_vm* vm) { pkpy_push_function(vm, "memset(dest: int, value: int, size: int)", py_memset); pkpy_setglobal_2(vm, "memset"); - pkpy_push_function(vm, "mget(x: int, y: int)", py_mget); + pkpy_push_function(vm, "mget(x: int, y: int) -> int", py_mget); pkpy_setglobal_2(vm, "mget"); pkpy_push_function(vm, "mset(x: int, y: int, tile_id: int)", py_mset); pkpy_setglobal_2(vm, "mset"); - pkpy_push_function(vm, "mouse()", py_mouse); + pkpy_push_function(vm, "mouse() -> tuple[int, int, bool, bool, bool, int, int]", py_mouse); pkpy_setglobal_2(vm, "mouse"); pkpy_push_function(vm, "music(track=-1, frame=-1, row=-1, loop=True, sustain=False, tempo=-1, speed=-1)", py_music); pkpy_setglobal_2(vm, "music"); - pkpy_push_function(vm, "peek(addr: int, bits=8)", py_peek); + pkpy_push_function(vm, "peek(addr: int, bits=8) -> int", py_peek); pkpy_setglobal_2(vm, "peek"); - pkpy_push_function(vm, "peek1(addr: int)", py_peek1); + pkpy_push_function(vm, "peek1(addr: int) -> int", py_peek1); pkpy_setglobal_2(vm, "peek1"); - pkpy_push_function(vm, "peek2(addr: int)", py_peek2); + pkpy_push_function(vm, "peek2(addr: int) -> int", py_peek2); pkpy_setglobal_2(vm, "peek2"); - pkpy_push_function(vm, "peek4(addr: int)", py_peek4); + pkpy_push_function(vm, "peek4(addr: int) -> int", py_peek4); pkpy_setglobal_2(vm, "peek4"); - pkpy_push_function(vm, "pix(x: int, y: int, color: int=None)", py_pix); + pkpy_push_function(vm, "pix(x: int, y: int, color: int=None) -> int | None", py_pix); pkpy_setglobal_2(vm, "pix"); - pkpy_push_function(vm, "pmem(index: int, value: int=None)", py_pmem); + pkpy_push_function(vm, "pmem(index: int, value: int=None) -> int", py_pmem); pkpy_setglobal_2(vm, "pmem"); pkpy_push_function(vm, "poke(addr: int, value: int, bits=8)", py_poke); @@ -1254,7 +1254,7 @@ static bool setup_c_bindings(pkpy_vm* vm) { pkpy_push_function(vm, "poke4(addr: int, value: int)", py_poke4); pkpy_setglobal_2(vm, "poke4"); - pkpy_push_function(vm, "print(text: str, x=0, y=0, color=15, fixed=False, scale=1, smallfont=False, alt=False)", py_print); + pkpy_push_function(vm, "print(text, x=0, y=0, color=15, fixed=False, scale=1, smallfont=False, alt=False)", py_print); pkpy_setglobal_2(vm, "print"); pkpy_push_function(vm, "rect(x: int, y: int, w: int, h: int, color: int)", py_rect); @@ -1274,10 +1274,10 @@ static bool setup_c_bindings(pkpy_vm* vm) { pkpy_push_function(vm, "sync(mask=0, bank=0, tocart=False)", py_sync); pkpy_setglobal_2(vm, "sync"); - pkpy_push_function(vm, "ttri(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, u1: float, v1: float, u2: float, v2: float, u3: float, v3: float, texsrc=0, chromakey=-1, z1: float=0, z2: float=0, z3: float=0)", py_ttri); + pkpy_push_function(vm, "ttri(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, u1: float, v1: float, u2: float, v2: float, u3: float, v3: float, texsrc=0, chromakey=-1, z1=0.0, z2=0.0, z3=0.0)", py_ttri); pkpy_setglobal_2(vm, "ttri"); - pkpy_push_function(vm, "time()", py_time); + pkpy_push_function(vm, "time() -> int", py_time); pkpy_setglobal_2(vm, "time"); pkpy_push_function(vm, "trace(message, color=15)", py_trace); @@ -1288,10 +1288,10 @@ static bool setup_c_bindings(pkpy_vm* vm) { pkpy_push_function(vm, "trib(x1: float, y1: float, x2: float, y2: float, x3: float, y3: float, color: int)", py_trib); pkpy_setglobal_2(vm, "trib"); - pkpy_push_function(vm, "tstamp()", py_tstamp); + pkpy_push_function(vm, "tstamp() -> int", py_tstamp); pkpy_setglobal_2(vm, "tstamp"); - pkpy_push_function(vm, "vbank(bank: int=None)", py_vbank); + pkpy_push_function(vm, "vbank(bank: int=None) -> int", py_vbank); pkpy_setglobal_2(vm, "vbank"); if(pkpy_check_error(vm)) From 1133bf79e65ba87d933e30ccf5f0113c67f348a0 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 16:32:31 +0800 Subject: [PATCH 63/83] ... ... --- build_web.sh | 6 ++++++ vendor/pocketpy | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 build_web.sh diff --git a/build_web.sh b/build_web.sh new file mode 100644 index 000000000..dac7f4edf --- /dev/null +++ b/build_web.sh @@ -0,0 +1,6 @@ +cd build +emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=Debug .. +cmake --build . --config Debug --parallel +cp bin/tic80.js webapp/tic80.js +cp bin/tic80.wasm webapp/tic80.wasm +python -m http.server 8000 --directory webapp \ No newline at end of file diff --git a/vendor/pocketpy b/vendor/pocketpy index a3d4e6695..366ff866d 160000 --- a/vendor/pocketpy +++ b/vendor/pocketpy @@ -1 +1 @@ -Subproject commit a3d4e6695850dd0c0114176a2be23635db6322a7 +Subproject commit 366ff866d4816af28429d53e2fd1f4aba42a8d97 From 851a4aa2c18bbf5f2fda6c40db8725e32dced61b Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 20:06:30 +0800 Subject: [PATCH 64/83] ... --- CMakeLists.txt | 7 ++++++- build_web.sh | 5 ++++- src/api/python.c | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae55e4fd3..da0b1da2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -415,6 +415,11 @@ endif() set_target_properties(pocketpy PROPERTIES OUTPUT_NAME python) add_library(python ALIAS pocketpy) +if(EMSCRIPTEN) + # remove fno-rtti and fno-exceptions in wasm library + target_compile_options(wasm PRIVATE -fexceptions -frtti) +endif() + ################################ # GIFLIB ################################ @@ -1191,7 +1196,7 @@ if(BUILD_SDL) endif() if(EMSCRIPTEN) - set_target_properties(tic80 PROPERTIES LINK_FLAGS "-s WASM=1 -s USE_SDL=2 -s ALLOW_MEMORY_GROWTH=1 -s FETCH=1 -s EXPORT_ES6=1 -s MODULARIZE=1 -s ENVIRONMENT=web -s EXPORT_NAME=createModule -s EXPORTED_RUNTIME_METHODS=['ENV'] -lidbfs.js") + set_target_properties(tic80 PROPERTIES LINK_FLAGS "-fexceptions -s WASM=1 -s USE_SDL=2 -s ALLOW_MEMORY_GROWTH=1 -s FETCH=1 -s EXPORT_ES6=1 -s MODULARIZE=1 -s ENVIRONMENT=web -s EXPORT_NAME=createModule -s EXPORTED_RUNTIME_METHODS=['ENV'] -lidbfs.js") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s USE_SDL=2") if(CMAKE_BUILD_TYPE STREQUAL "Debug") diff --git a/build_web.sh b/build_web.sh index dac7f4edf..56baab535 100644 --- a/build_web.sh +++ b/build_web.sh @@ -1,6 +1,9 @@ cd build +rm CMakeCache.txt +rm cmake_install.cmake +rm Makefile emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=Debug .. -cmake --build . --config Debug --parallel +cmake --build . --config Debug cp bin/tic80.js webapp/tic80.js cp bin/tic80.wasm webapp/tic80.wasm python -m http.server 8000 --directory webapp \ No newline at end of file diff --git a/src/api/python.c b/src/api/python.c index 254187951..eec8baf54 100644 --- a/src/api/python.c +++ b/src/api/python.c @@ -98,6 +98,7 @@ static int py_trace(pkpy_vm* vm) pkpy_dup(vm, 0); pkpy_py_str(vm); pkpy_to_string(vm, -1, &message); + pkpy_pop_top(vm); pkpy_to_int(vm, 1, &color); get_core(vm, (tic_core**) &tic); @@ -814,6 +815,7 @@ static int py_print(pkpy_vm* vm) { pkpy_dup(vm, 0); pkpy_py_str(vm); pkpy_to_string(vm, -1, &text); + pkpy_pop_top(vm); pkpy_to_int(vm, 1, &x); pkpy_to_int(vm, 2, &y); @@ -1371,6 +1373,7 @@ void callPythonTick(tic_mem* tic) } pkpy_push_null(core->currentVM); if(!pkpy_vectorcall(core->currentVM, 0)){ + pkpy_clear_error(core->currentVM, NULL); report_error(core, "error while running TIC\n"); }else{ pkpy_pop_top(core->currentVM); From 552fee4eedaaa84508af1f5f9f75da907059c63e Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 21:23:15 +0800 Subject: [PATCH 65/83] ... --- CMakeLists.txt | 8 -------- build_web.sh | 5 +---- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index da0b1da2a..d852d426f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -401,10 +401,7 @@ target_include_directories(squirrel PRIVATE ${SQUIRREL_DIR}/sqstdlib) ################################ add_subdirectory(${THIRDPARTY_DIR}/pocketpy) - -set_target_properties(pocketpy PROPERTIES LINKER_LANGUAGE CXX) target_compile_definitions(pocketpy PRIVATE PK_ENABLE_OS=0) - include_directories(${THIRDPARTY_DIR}/pocketpy/include) if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") @@ -415,11 +412,6 @@ endif() set_target_properties(pocketpy PROPERTIES OUTPUT_NAME python) add_library(python ALIAS pocketpy) -if(EMSCRIPTEN) - # remove fno-rtti and fno-exceptions in wasm library - target_compile_options(wasm PRIVATE -fexceptions -frtti) -endif() - ################################ # GIFLIB ################################ diff --git a/build_web.sh b/build_web.sh index 56baab535..f05792f36 100644 --- a/build_web.sh +++ b/build_web.sh @@ -1,9 +1,6 @@ cd build -rm CMakeCache.txt -rm cmake_install.cmake -rm Makefile emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=Debug .. cmake --build . --config Debug cp bin/tic80.js webapp/tic80.js cp bin/tic80.wasm webapp/tic80.wasm -python -m http.server 8000 --directory webapp \ No newline at end of file +python -m http.server 8001 --directory webapp \ No newline at end of file From 7fec01d94dc15f979c64ceae6b02129038174261 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 21:34:10 +0800 Subject: [PATCH 66/83] ... --- CMakeLists.txt | 7 ++++++- build_web.sh | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d852d426f..f38d477ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -412,6 +412,11 @@ endif() set_target_properties(pocketpy PROPERTIES OUTPUT_NAME python) add_library(python ALIAS pocketpy) +if(EMSCRIPTEN) + # exceptions must be enabled for emscripten + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fexceptions") +endif() + ################################ # GIFLIB ################################ @@ -1188,7 +1193,7 @@ if(BUILD_SDL) endif() if(EMSCRIPTEN) - set_target_properties(tic80 PROPERTIES LINK_FLAGS "-fexceptions -s WASM=1 -s USE_SDL=2 -s ALLOW_MEMORY_GROWTH=1 -s FETCH=1 -s EXPORT_ES6=1 -s MODULARIZE=1 -s ENVIRONMENT=web -s EXPORT_NAME=createModule -s EXPORTED_RUNTIME_METHODS=['ENV'] -lidbfs.js") + set_target_properties(tic80 PROPERTIES LINK_FLAGS "-s WASM=1 -s USE_SDL=2 -s ALLOW_MEMORY_GROWTH=1 -s FETCH=1 -s EXPORT_ES6=1 -s MODULARIZE=1 -s ENVIRONMENT=web -s EXPORT_NAME=createModule -s EXPORTED_RUNTIME_METHODS=['ENV'] -lidbfs.js") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s USE_SDL=2") if(CMAKE_BUILD_TYPE STREQUAL "Debug") diff --git a/build_web.sh b/build_web.sh index f05792f36..81b001bb2 100644 --- a/build_web.sh +++ b/build_web.sh @@ -3,4 +3,4 @@ emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=Debug .. cmake --build . --config Debug cp bin/tic80.js webapp/tic80.js cp bin/tic80.wasm webapp/tic80.wasm -python -m http.server 8001 --directory webapp \ No newline at end of file +python -m http.server 8002 --directory webapp \ No newline at end of file From b17928c54d973e9c0d88c7e452320611cb3c14d1 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 21:52:02 +0800 Subject: [PATCH 67/83] ... --- build_web.sh | 2 +- src/api/python.c | 44 +++++++++++++++----------------------------- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/build_web.sh b/build_web.sh index 81b001bb2..baa88adf6 100644 --- a/build_web.sh +++ b/build_web.sh @@ -3,4 +3,4 @@ emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=Debug .. cmake --build . --config Debug cp bin/tic80.js webapp/tic80.js cp bin/tic80.wasm webapp/tic80.wasm -python -m http.server 8002 --directory webapp \ No newline at end of file +python -m http.server 8008 --directory webapp \ No newline at end of file diff --git a/src/api/python.c b/src/api/python.c index eec8baf54..b83e65ce7 100644 --- a/src/api/python.c +++ b/src/api/python.c @@ -31,9 +31,10 @@ static void pkpy_setglobal_2(pkpy_vm* vm, const char* name){ static bool get_core(pkpy_vm* vm, tic_core** core) { - pkpy_getglobal(vm, N._tic_core); - bool ok = pkpy_to_voidp(vm, -1, (void**) core); - if(ok) pkpy_pop_top(vm); + bool ok = pkpy_getglobal(vm, N._tic_core); + if(!ok) return false; + ok = pkpy_to_voidp(vm, -1, (void**) core); + pkpy_pop_top(vm); return ok; } @@ -1367,13 +1368,10 @@ void callPythonTick(tic_mem* tic) if (!core->currentVM) return; - if(!pkpy_getglobal(core->currentVM, N.TIC)){ - pkpy_clear_error(core->currentVM, NULL); - return; - } + if(!pkpy_getglobal(core->currentVM, N.TIC)) return; + pkpy_push_null(core->currentVM); if(!pkpy_vectorcall(core->currentVM, 0)){ - pkpy_clear_error(core->currentVM, NULL); report_error(core, "error while running TIC\n"); }else{ pkpy_pop_top(core->currentVM); @@ -1384,10 +1382,8 @@ void callPythonBoot(tic_mem* tic) { if (!core->currentVM) return; - if(!pkpy_getglobal(core->currentVM, N.BOOT)){ - pkpy_clear_error(core->currentVM, NULL); - 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"); @@ -1401,10 +1397,8 @@ void callPythonScanline(tic_mem* tic, s32 row, void* data) { if (!core->currentVM) return; - if(!pkpy_getglobal(core->currentVM, N.SCN)){ - pkpy_clear_error(core->currentVM, NULL); - return; - } + if(!pkpy_getglobal(core->currentVM, N.SCN)) return; + pkpy_push_null(core->currentVM); pkpy_push_int(core->currentVM, row); if(!pkpy_vectorcall(core->currentVM, 1)){ @@ -1419,10 +1413,8 @@ void callPythonBorder(tic_mem* tic, s32 row, void* data) { if (!core->currentVM) return; - if(!pkpy_getglobal(core->currentVM, N.BDR)){ - pkpy_clear_error(core->currentVM, NULL); - return; - } + if(!pkpy_getglobal(core->currentVM, N.BDR)) return; + pkpy_push_null(core->currentVM); pkpy_push_int(core->currentVM, row); if(!pkpy_vectorcall(core->currentVM, 1)){ @@ -1437,10 +1429,8 @@ void callPythonMenu(tic_mem* tic, s32 index, void* data) { if (!core->currentVM) return; - if(pkpy_getglobal(core->currentVM, N.MENU)){ - pkpy_clear_error(core->currentVM, NULL); - return; - } + if(pkpy_getglobal(core->currentVM, N.MENU)) return; + pkpy_push_null(core->currentVM); pkpy_push_int(core->currentVM, index); if(!pkpy_vectorcall(core->currentVM, 1)){ @@ -1535,11 +1525,7 @@ void evalPython(tic_mem* tic, const char* code) if(!pkpy_exec(vm, code)) { - char* msg; - if(pkpy_clear_error(vm, &msg)){ - core->data->error(core->data->data, msg); - pkpy_free(msg); - } + report_error(core, "error while evaluating the code\n"); } } From 8071889ad496bb7ce1723ae0e7853d1ec9c59415 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 21:53:20 +0800 Subject: [PATCH 68/83] Update pocketpy --- vendor/pocketpy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/pocketpy b/vendor/pocketpy index 366ff866d..e1b2bda6a 160000 --- a/vendor/pocketpy +++ b/vendor/pocketpy @@ -1 +1 @@ -Subproject commit 366ff866d4816af28429d53e2fd1f4aba42a8d97 +Subproject commit e1b2bda6aaa8e731fdd025f158ac9d5657033139 From 559d4ad5f7225c9e2ce30ed03316d89bd1789a03 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 22:15:49 +0800 Subject: [PATCH 69/83] some clean --- .gitignore | 1 + build_web.sh | 6 ------ compile_flags.txt | 12 ------------ vendor/pocketpy | 2 +- 4 files changed, 2 insertions(+), 19 deletions(-) delete mode 100644 build_web.sh delete mode 100644 compile_flags.txt diff --git a/.gitignore b/.gitignore index bd138dc16..57a77ed31 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *.opendb *.suo compile_commands.json +compile_flags.txt sexit .vscode/ build/install_manifest.txt diff --git a/build_web.sh b/build_web.sh deleted file mode 100644 index baa88adf6..000000000 --- a/build_web.sh +++ /dev/null @@ -1,6 +0,0 @@ -cd build -emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=Debug .. -cmake --build . --config Debug -cp bin/tic80.js webapp/tic80.js -cp bin/tic80.wasm webapp/tic80.wasm -python -m http.server 8008 --directory webapp \ No newline at end of file diff --git a/compile_flags.txt b/compile_flags.txt deleted file mode 100644 index 0d47608e6..000000000 --- a/compile_flags.txt +++ /dev/null @@ -1,12 +0,0 @@ --xc --Wall --W* --Iinclude/ --Isrc/ --Isrc/api/ --Isrc/core/ --Isrc/ext/ --Isrc/studio/ --Isrc/system/ --Ivendor/blip-buf/ --Ivendor/pocketpy/include/ diff --git a/vendor/pocketpy b/vendor/pocketpy index e1b2bda6a..a810973f6 160000 --- a/vendor/pocketpy +++ b/vendor/pocketpy @@ -1 +1 @@ -Subproject commit e1b2bda6aaa8e731fdd025f158ac9d5657033139 +Subproject commit a810973f6567c09909b75ce865ce5761599fe397 From 8d07e7021394796b0cfb2f633d7da70a4b2ca9e8 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 23:09:18 +0800 Subject: [PATCH 70/83] fix https://github.com/nesbox/TIC-80/issues/2317 --- vendor/pocketpy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/pocketpy b/vendor/pocketpy index a810973f6..bb1d38f8f 160000 --- a/vendor/pocketpy +++ b/vendor/pocketpy @@ -1 +1 @@ -Subproject commit a810973f6567c09909b75ce865ce5761599fe397 +Subproject commit bb1d38f8fa5a28db9d516f89b6930dab7b53c017 From 06ba51c542c7f05ff6bf8f4590aac4797bf2f0a2 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sat, 30 Sep 2023 00:01:35 +0800 Subject: [PATCH 71/83] Update pocketpy --- vendor/pocketpy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/pocketpy b/vendor/pocketpy index bb1d38f8f..44d158e2f 160000 --- a/vendor/pocketpy +++ b/vendor/pocketpy @@ -1 +1 @@ -Subproject commit bb1d38f8fa5a28db9d516f89b6930dab7b53c017 +Subproject commit 44d158e2fb22b7a9edc61ac116842843d4766c54 From 23191645c1255d1d025a976f78b039d1c4aa7150 Mon Sep 17 00:00:00 2001 From: d_m Date: Fri, 29 Sep 2023 13:56:28 -0400 Subject: [PATCH 72/83] Add a few more emacs bindings This commit adds the following key bindings: - Ctrl + '_': undo - Ctrl + '<': beginning of document - Ctrl + '>': end of document These are all standard Emacs key bindings. --- src/studio/editors/code.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/studio/editors/code.c b/src/studio/editors/code.c index 2a434a418..8fb475dee 100644 --- a/src/studio/editors/code.c +++ b/src/studio/editors/code.c @@ -2949,6 +2949,7 @@ static void processKeyboard(Code* code) else if(keyWasPressed(code->studio, tic_key_space)) emacsMode ? toggleMark(code) : noop; else if(keyWasPressed(code->studio, tic_key_l)) recenterScroll(code, emacsMode); else if(keyWasPressed(code->studio, tic_key_v)) emacsMode ? pageDown(code) : noop; + else if(shift && keyWasPressed(code->studio, tic_key_minus)) emacsMode ? undo(code) : noop; else ctrlHandled = false; } @@ -2968,6 +2969,8 @@ static void processKeyboard(Code* code) else if(keyWasPressed(code->studio, tic_key_w)) emacsMode ? copyToClipboard(code, true) : noop; else if(keyWasPressed(code->studio, tic_key_g)) emacsMode ? setCodeMode(code, TEXT_GOTO_MODE) : noop; else if(keyWasPressed(code->studio, tic_key_s)) emacsMode ? setCodeMode(code, TEXT_FIND_MODE) : noop; + else if(shift && sym && sym == '<') emacsMode ? goCodeHome(code) : noop; + else if(shift && sym && sym == '>') emacsMode ? goCodeEnd(code) : noop; else if(shift && sym && sym == '(') emacsMode? sexpify(code) : noop; else if(keyWasPressed(code->studio, tic_key_slash)) emacsMode ? redo(code) : noop; else if(keyWasPressed(code->studio, tic_key_semicolon)) emacsMode ? commentLine(code) : noop; From 45977f1691be7badfc35a495f3bd526752185470 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Fri, 6 Oct 2023 02:19:26 +0800 Subject: [PATCH 73/83] Update pocketpy --- vendor/pocketpy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/pocketpy b/vendor/pocketpy index 44d158e2f..59b1c13f3 160000 --- a/vendor/pocketpy +++ b/vendor/pocketpy @@ -1 +1 @@ -Subproject commit 44d158e2fb22b7a9edc61ac116842843d4766c54 +Subproject commit 59b1c13f354b7b819a16b2f94b9bda8b428fd710 From 5d2bffe7783284a68c49b8241f71c4235920cacc Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sat, 7 Oct 2023 13:40:26 +0800 Subject: [PATCH 74/83] Update pocketpy --- vendor/pocketpy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/pocketpy b/vendor/pocketpy index 366ff866d..7312afdad 160000 --- a/vendor/pocketpy +++ b/vendor/pocketpy @@ -1 +1 @@ -Subproject commit 366ff866d4816af28429d53e2fd1f4aba42a8d97 +Subproject commit 7312afdad24bb308037088d34b32ed0078fed7d2 From f5eb79d7e8464bbcdc78d14e6b1fb3d43272787a Mon Sep 17 00:00:00 2001 From: alectroemel Date: Sat, 7 Oct 2023 08:58:43 -0500 Subject: [PATCH 75/83] Janet language bindings for ttri fn, texsrc arg can be int or bool --- src/api/janet.c | 317 +++++++++++++++++++++++++----------------------- 1 file changed, 164 insertions(+), 153 deletions(-) diff --git a/src/api/janet.c b/src/api/janet.c index e46dc8016..53e30e418 100644 --- a/src/api/janet.c +++ b/src/api/janet.c @@ -181,25 +181,25 @@ static SFXNote tic_optsfxnote(Janet *argv, int32_t argc, int32_t n, SFXNote sfxN { if (argc <= n) { - return sfxNote; + return sfxNote; } else if (janet_checktype(argv[n], JANET_STRING)) { - const char *noteStr = janet_getcstring(argv, n); + const char *noteStr = janet_getcstring(argv, n); - if (!tic_tool_parse_note(noteStr, &sfxNote.note, &sfxNote.octave)) - { - janet_panicf("invalid note, should be like C#4, got %s\n", noteStr); - } + if (!tic_tool_parse_note(noteStr, &sfxNote.note, &sfxNote.octave)) + { + janet_panicf("invalid note, should be like C#4, got %s\n", noteStr); + } - return sfxNote; + return sfxNote; } else { - s32 id = janet_getinteger(argv, n); - sfxNote.note = id % NOTES; - sfxNote.octave = id / NOTES; - return sfxNote; + s32 id = janet_getinteger(argv, n); + sfxNote.note = id % NOTES; + sfxNote.octave = id / NOTES; + return sfxNote; } } @@ -216,33 +216,33 @@ static ColorKey tic_optcolorkey(Janet *argv, int32_t argc, int32_t n) if (argc > n) { - if (janet_checktypes(argv[n], JANET_TFLAG_INDEXED)) - { - JanetView keys = janet_getindexed(argv, n); - s32 list_count = keys.len; - - for(s32 i = 0; i < TIC_PALETTE_SIZE; i++) - { - if (i < list_count) - { - colorkey.colors[i] = (s32)janet_getinteger(keys.items, i);; - colorkey.count++; - } - else - { - break; - } - } - } - else if (janet_checkint(argv[n])) - { - colorkey.colors[0] = (s32)janet_getnumber(argv, n); - colorkey.count = 1; - } - else - { - janet_panic("Error: colorkeys must be either int or list of int"); - } + if (janet_checktypes(argv[n], JANET_TFLAG_INDEXED)) + { + JanetView keys = janet_getindexed(argv, n); + s32 list_count = keys.len; + + for(s32 i = 0; i < TIC_PALETTE_SIZE; i++) + { + if (i < list_count) + { + colorkey.colors[i] = (s32)janet_getinteger(keys.items, i);; + colorkey.count++; + } + else + { + break; + } + } + } + else if (janet_checkint(argv[n])) + { + colorkey.colors[0] = (s32)janet_getnumber(argv, n); + colorkey.count = 1; + } + else + { + janet_panic("Error: colorkeys must be either int or list of int"); + } } return colorkey; @@ -261,11 +261,11 @@ static TriDepth tic_opttridepth(Janet* argv, int32_t argc, int32_t n) if (argc > n) { - depth.on = true; + depth.on = true; - depth.z[0] = janet_getnumber(argv, n); - depth.z[1] = janet_getnumber(argv, n+1); - depth.z[2] = janet_getnumber(argv, n+2); + depth.z[0] = janet_getnumber(argv, n); + depth.z[1] = janet_getnumber(argv, n+1); + depth.z[2] = janet_getnumber(argv, n+2); } return depth; @@ -317,10 +317,10 @@ static Janet janet_pix(int32_t argc, Janet* argv) s32 y = (s32)janet_getinteger(argv, 1); if (argc == 2) { - get = true; + get = true; } else { - color = (u8)janet_getinteger(argv, 2); - get = false; + color = (u8)janet_getinteger(argv, 2); + get = false; } tic_mem* memory = (tic_mem*)getJanetMachine(); @@ -390,8 +390,8 @@ static Janet janet_spr(int32_t argc, Janet* argv) tic_mem* memory = (tic_mem*)getJanetMachine(); tic_api_spr(memory, index, x, y, w, h, - colorkey.colors, colorkey.count, - scale, flip, rotate); + colorkey.colors, colorkey.count, + scale, flip, rotate); return janet_wrap_nil(); } @@ -426,7 +426,7 @@ static Janet janet_sfx(int32_t argc, Janet* argv) s32 index = (s32)janet_getinteger(argv, 0); if (index >= SFX_COUNT) { - janet_panicf("unknown sfx index, got %s\n", index); + janet_panicf("unknown sfx index, got %s\n", index); } // possibly get default values from sfx @@ -435,16 +435,16 @@ static Janet janet_sfx(int32_t argc, Janet* argv) s32 defaultSpeed = SFX_DEF_SPEED; if (index >= 0) { - defaultSfxNote.note = effect->note; - defaultSfxNote.octave = effect->octave; - defaultSpeed = effect->speed; + defaultSfxNote.note = effect->note; + defaultSfxNote.octave = effect->octave; + defaultSpeed = effect->speed; } SFXNote sfxNote = tic_optsfxnote(argv, argc, 1, defaultSfxNote); s32 duration = (s32)janet_optinteger(argv, argc, 2, -1); s32 channel = (s32)janet_optinteger(argv, argc, 3, 0); if (channel < 0 || channel > TIC_SOUND_CHANNELS) { - janet_panicf("unknown channel, got %s\n", channel); + janet_panicf("unknown channel, got %s\n", channel); } s32 volumes[TIC80_SAMPLE_CHANNELS] = {MAX_VOLUME, MAX_VOLUME}; @@ -454,10 +454,10 @@ static Janet janet_sfx(int32_t argc, Janet* argv) s32 speed = (s32)janet_optinteger(argv, argc, 5, defaultSpeed); tic_api_sfx(memory, index, - sfxNote.note, sfxNote.octave, - duration, channel, - volumes[0] & 0xf, volumes[1] & 0xf, - speed); + sfxNote.note, sfxNote.octave, + duration, channel, + volumes[0] & 0xf, volumes[1] & 0xf, + speed); return janet_wrap_nil(); } @@ -475,15 +475,15 @@ static void remapCallback(void* data, s32 x, s32 y, RemapResult* result) if (janet_checktypes(jresult, JANET_TFLAG_INDEXED)) { - const Janet *jresult_tuple = janet_unwrap_tuple(jresult); - u8 retc = janet_tuple_length(jresult_tuple); - result->index = janet_getinteger(jresult_tuple, 0); - result->flip = janet_optinteger(jresult_tuple, retc, 1, 0); - result->rotate = janet_optinteger(jresult_tuple, retc, 2, 0); + const Janet *jresult_tuple = janet_unwrap_tuple(jresult); + u8 retc = janet_tuple_length(jresult_tuple); + result->index = janet_getinteger(jresult_tuple, 0); + result->flip = janet_optinteger(jresult_tuple, retc, 1, 0); + result->rotate = janet_optinteger(jresult_tuple, retc, 2, 0); } else if (janet_checkint(jresult)) { - result->index = janet_unwrap_integer(jresult); + result->index = janet_unwrap_integer(jresult); } } @@ -508,17 +508,17 @@ static Janet janet_map(int32_t argc, Janet* argv) if (argc < 9) { - tic_api_map(memory, x, y, w, h, sx, sy, - colorkey.colors, colorkey.count, - scale, NULL, NULL); + tic_api_map(memory, x, y, w, h, sx, sy, + colorkey.colors, colorkey.count, + scale, NULL, NULL); } else { - JanetFunction *remap = janet_getfunction(argv, 8); - tic_api_map(memory, x, y, w, h, sx, sy, - colorkey.colors, colorkey.count, - scale, - remapCallback, remap); + JanetFunction *remap = janet_getfunction(argv, 8); + tic_api_map(memory, x, y, w, h, sx, sy, + colorkey.colors, colorkey.count, + scale, + remapCallback, remap); } return janet_wrap_nil(); @@ -671,7 +671,7 @@ static Janet janet_trace(int32_t argc, Janet* argv) const char *message = janet_getcstring(argv, 0); if (argc > 1) { - color = janet_getinteger(argv, 1); + color = janet_getinteger(argv, 1); } tic_mem* memory = (tic_mem*)getJanetMachine(); @@ -686,20 +686,20 @@ static Janet janet_pmem(int32_t argc, Janet* argv) if(index < TIC_PERSISTENT_SIZE) { - tic_mem* memory = (tic_mem*)getJanetMachine(); - u32 val = tic_api_pmem(memory, index, 0, false); + tic_mem* memory = (tic_mem*)getJanetMachine(); + u32 val = tic_api_pmem(memory, index, 0, false); - if (argc >= 2) - { - u32 value = janet_getinteger(argv, 1); - tic_api_pmem(memory, index, value, true); - } + if (argc >= 2) + { + u32 value = janet_getinteger(argv, 1); + tic_api_pmem(memory, index, value, true); + } - return janet_wrap_integer(val); + return janet_wrap_integer(val); } else { - janet_panic("Error: invalid persistent tic index"); + janet_panic("Error: invalid persistent tic index"); } } @@ -742,8 +742,8 @@ static Janet janet_font(int32_t argc, Janet* argv) tic_mem* memory = (tic_mem*)getJanetMachine(); int32_t width = tic_api_font(memory, - text, x, y, &chromakey, 1, - w, h, fixed, scale, alt); + text, x, y, &chromakey, 1, + w, h, fixed, scale, alt); return janet_wrap_integer(width); } @@ -755,9 +755,9 @@ static Janet janet_mouse(int32_t argc, Janet* argv) Janet result[7]; { - tic_point point = tic_api_mouse(memory); - result[0] = janet_wrap_integer(point.x); - result[1] = janet_wrap_integer(point.y); + tic_point point = tic_api_mouse(memory); + result[0] = janet_wrap_integer(point.x); + result[1] = janet_wrap_integer(point.y); } tic_core* core = getJanetMachine(); @@ -882,8 +882,19 @@ static Janet janet_ttri(int32_t argc, Janet* argv) float v3 = janet_getnumber(argv, 11); tic_texture_src src = tic_tiles_texture; - if (janet_optboolean(argv, argc, 12, false)) { - src = tic_map_texture; + + if (argc > 12) + { + if (janet_checktypes(argv[12], JANET_TFLAG_BOOLEAN)) + { + if (janet_getboolean(argv, 12)) { + src = tic_map_texture; + } + } + else if (janet_checktypes(argv[12], JANET_TFLAG_NUMBER)) + { + src = janet_getinteger(argv, 12); + } } ColorKey trans = tic_optcolorkey(argv, argc, 13); @@ -891,15 +902,15 @@ static Janet janet_ttri(int32_t argc, Janet* argv) tic_mem* memory = (tic_mem*)getJanetMachine(); tic_api_ttri(memory, - x1, y1, - x2, y2, - x3, y3, - u1, v1, - u2, v2, - u3, v3, - src, - trans.colors, trans.count, - depth.z[0], depth.z[1], depth.z[2], depth.on); + x1, y1, + x2, y2, + x3, y3, + u1, v1, + u2, v2, + u3, v3, + src, + trans.colors, trans.count, + depth.z[0], depth.z[1], depth.z[2], depth.on); return janet_wrap_nil(); } @@ -911,15 +922,15 @@ static Janet janet_clip(int32_t argc, Janet* argv) tic_mem* memory = (tic_mem*)getJanetMachine(); if (argc == 0) { - tic_api_clip(memory, 0, 0, TIC80_WIDTH, TIC80_HEIGHT); + tic_api_clip(memory, 0, 0, TIC80_WIDTH, TIC80_HEIGHT); } else if (argc == 4) { - s32 x = janet_getinteger(argv, 0); - s32 y = janet_getinteger(argv, 1); - s32 w = janet_getinteger(argv, 2); - s32 h = janet_getinteger(argv, 3); - tic_api_clip(memory, x, y, w, h); + s32 x = janet_getinteger(argv, 0); + s32 y = janet_getinteger(argv, 1); + s32 w = janet_getinteger(argv, 2); + s32 h = janet_getinteger(argv, 3); + tic_api_clip(memory, x, y, w, h); } else { - janet_panic("Error: must provide exactly 0 or 4 args."); + janet_panic("Error: must provide exactly 0 or 4 args."); } return janet_wrap_nil(); @@ -1039,11 +1050,11 @@ static void closeJanet(tic_mem* tic) tic_core* core = (tic_core*)tic; if (core->currentVM) { - janet_deinit(); - core->currentVM = NULL; - CurrentMachine = NULL; - errBuffer = NULL; - GameFiber = NULL; + janet_deinit(); + core->currentVM = NULL; + CurrentMachine = NULL; + errBuffer = NULL; + GameFiber = NULL; } } @@ -1074,8 +1085,8 @@ static bool initJanet(tic_mem* tic, const char* code) // Load the game source code if (janet_dostring(core->currentVM, code, "main", &result)) { - reportError(core, result); - return false; + reportError(core, result); + return false; } return true; @@ -1106,8 +1117,8 @@ static void callJanetTick(tic_mem* tic) (void)janet_resolve(core->currentVM, janet_csymbol(TIC_FN), &pre_fn); if (janet_type(pre_fn) != JANET_FUNCTION) { - core->data->error(core->data->data, "(TIC) isn't found :("); - return; + core->data->error(core->data->data, "(TIC) isn't found :("); + return; } JanetFunction *tic_fn = janet_unwrap_function(pre_fn); @@ -1115,19 +1126,19 @@ static void callJanetTick(tic_mem* tic) JanetSignal status = janet_pcall(tic_fn, 0, NULL, &result, &GameFiber); if (status != JANET_SIGNAL_OK) { - reportError(core, result); + reportError(core, result); } #if defined(BUILD_DEPRECATED) // call OVR() callback for backward compatibility (void)janet_resolve(core->currentVM, janet_csymbol(OVR_FN), &pre_fn); if (janet_type(pre_fn) == JANET_FUNCTION) { - JanetFunction *ovr_fn = janet_unwrap_function(pre_fn); - JanetSignal status = janet_pcall(ovr_fn, 0, NULL, &result, &GameFiber); + JanetFunction *ovr_fn = janet_unwrap_function(pre_fn); + JanetSignal status = janet_pcall(ovr_fn, 0, NULL, &result, &GameFiber); - if (status != JANET_SIGNAL_OK) { - reportError(core, result); - } + if (status != JANET_SIGNAL_OK) { + reportError(core, result); + } } #endif } @@ -1144,7 +1155,7 @@ static void callJanetBoot(tic_mem* tic) (void)janet_resolve(core->currentVM, janet_csymbol(BOOT_FN), &pre_fn); if (janet_type(pre_fn) != JANET_FUNCTION) { - return; + return; } Janet result = janet_wrap_nil(); @@ -1152,7 +1163,7 @@ static void callJanetBoot(tic_mem* tic) JanetSignal status = janet_pcall(boot_fn, 0, NULL, &result, &GameFiber); if (status != JANET_SIGNAL_OK) { - reportError(core, result); + reportError(core, result); } } @@ -1168,7 +1179,7 @@ static void callJanetIntCallback(tic_mem* tic, s32 value, void* data, const char (void)janet_resolve(core->currentVM, janet_csymbol(name), &pre_fn); if (janet_type(pre_fn) != JANET_FUNCTION) { - return; + return; } Janet result = janet_wrap_nil(); @@ -1177,7 +1188,7 @@ static void callJanetIntCallback(tic_mem* tic, s32 value, void* data, const char JanetSignal status = janet_pcall(fn, 1, argv, &result, &GameFiber); if (status != JANET_SIGNAL_OK) { - reportError(core, result); + reportError(core, result); } } @@ -1207,49 +1218,49 @@ static const tic_outline_item* getJanetOutline(const char* code, s32* size) if(items) { - free(items); - items = NULL; + free(items); + items = NULL; } const char* ptr = code; while(true) { - static const char FuncString[] = "(defn "; + static const char FuncString[] = "(defn "; - ptr = strstr(ptr, FuncString); + ptr = strstr(ptr, FuncString); - if(ptr) - { - ptr += sizeof FuncString - 1; + if(ptr) + { + ptr += sizeof FuncString - 1; - const char* start = ptr; - const char* end = start; + const char* start = ptr; + const char* end = start; - while(*ptr) - { - char c = *ptr; + while(*ptr) + { + char c = *ptr; - if(c == ' ' || c == '\t' || c == '\n' || c == '[') - { - end = ptr; - break; - } + if(c == ' ' || c == '\t' || c == '\n' || c == '[') + { + end = ptr; + break; + } - ptr++; - } + ptr++; + } - if(end > start) - { - items = realloc(items, (*size + 1) * Size); + if(end > start) + { + items = realloc(items, (*size + 1) * Size); - items[*size].pos = start; - items[*size].size = (s32)(end - start); + items[*size].pos = start; + items[*size].size = (s32)(end - start); - (*size)++; - } - } - else break; + (*size)++; + } + } + else break; } return items; @@ -1270,9 +1281,9 @@ const tic_script_config JanetSyntaxConfig = .callback = { - .scanline = callJanetScanline, - .border = callJanetBorder, - .menu = callJanetMenu, + .scanline = callJanetScanline, + .border = callJanetBorder, + .menu = callJanetMenu, }, .getOutline = getJanetOutline, From a4c595fd64ea96e3f68fde951ee6d091e6014a35 Mon Sep 17 00:00:00 2001 From: alectroemel Date: Sat, 7 Oct 2023 09:01:21 -0500 Subject: [PATCH 76/83] fix tabs mode --- src/api/janet.c | 310 ++++++++++++++++++++++++------------------------ 1 file changed, 155 insertions(+), 155 deletions(-) diff --git a/src/api/janet.c b/src/api/janet.c index 53e30e418..b986023da 100644 --- a/src/api/janet.c +++ b/src/api/janet.c @@ -181,25 +181,25 @@ static SFXNote tic_optsfxnote(Janet *argv, int32_t argc, int32_t n, SFXNote sfxN { if (argc <= n) { - return sfxNote; + return sfxNote; } else if (janet_checktype(argv[n], JANET_STRING)) { - const char *noteStr = janet_getcstring(argv, n); + const char *noteStr = janet_getcstring(argv, n); - if (!tic_tool_parse_note(noteStr, &sfxNote.note, &sfxNote.octave)) - { - janet_panicf("invalid note, should be like C#4, got %s\n", noteStr); - } + if (!tic_tool_parse_note(noteStr, &sfxNote.note, &sfxNote.octave)) + { + janet_panicf("invalid note, should be like C#4, got %s\n", noteStr); + } - return sfxNote; + return sfxNote; } else { - s32 id = janet_getinteger(argv, n); - sfxNote.note = id % NOTES; - sfxNote.octave = id / NOTES; - return sfxNote; + s32 id = janet_getinteger(argv, n); + sfxNote.note = id % NOTES; + sfxNote.octave = id / NOTES; + return sfxNote; } } @@ -216,33 +216,33 @@ static ColorKey tic_optcolorkey(Janet *argv, int32_t argc, int32_t n) if (argc > n) { - if (janet_checktypes(argv[n], JANET_TFLAG_INDEXED)) - { - JanetView keys = janet_getindexed(argv, n); - s32 list_count = keys.len; - - for(s32 i = 0; i < TIC_PALETTE_SIZE; i++) - { - if (i < list_count) - { - colorkey.colors[i] = (s32)janet_getinteger(keys.items, i);; - colorkey.count++; - } - else - { - break; - } - } - } - else if (janet_checkint(argv[n])) - { - colorkey.colors[0] = (s32)janet_getnumber(argv, n); - colorkey.count = 1; - } - else - { - janet_panic("Error: colorkeys must be either int or list of int"); - } + if (janet_checktypes(argv[n], JANET_TFLAG_INDEXED)) + { + JanetView keys = janet_getindexed(argv, n); + s32 list_count = keys.len; + + for(s32 i = 0; i < TIC_PALETTE_SIZE; i++) + { + if (i < list_count) + { + colorkey.colors[i] = (s32)janet_getinteger(keys.items, i);; + colorkey.count++; + } + else + { + break; + } + } + } + else if (janet_checkint(argv[n])) + { + colorkey.colors[0] = (s32)janet_getnumber(argv, n); + colorkey.count = 1; + } + else + { + janet_panic("Error: colorkeys must be either int or list of int"); + } } return colorkey; @@ -261,11 +261,11 @@ static TriDepth tic_opttridepth(Janet* argv, int32_t argc, int32_t n) if (argc > n) { - depth.on = true; + depth.on = true; - depth.z[0] = janet_getnumber(argv, n); - depth.z[1] = janet_getnumber(argv, n+1); - depth.z[2] = janet_getnumber(argv, n+2); + depth.z[0] = janet_getnumber(argv, n); + depth.z[1] = janet_getnumber(argv, n+1); + depth.z[2] = janet_getnumber(argv, n+2); } return depth; @@ -317,10 +317,10 @@ static Janet janet_pix(int32_t argc, Janet* argv) s32 y = (s32)janet_getinteger(argv, 1); if (argc == 2) { - get = true; + get = true; } else { - color = (u8)janet_getinteger(argv, 2); - get = false; + color = (u8)janet_getinteger(argv, 2); + get = false; } tic_mem* memory = (tic_mem*)getJanetMachine(); @@ -390,8 +390,8 @@ static Janet janet_spr(int32_t argc, Janet* argv) tic_mem* memory = (tic_mem*)getJanetMachine(); tic_api_spr(memory, index, x, y, w, h, - colorkey.colors, colorkey.count, - scale, flip, rotate); + colorkey.colors, colorkey.count, + scale, flip, rotate); return janet_wrap_nil(); } @@ -426,7 +426,7 @@ static Janet janet_sfx(int32_t argc, Janet* argv) s32 index = (s32)janet_getinteger(argv, 0); if (index >= SFX_COUNT) { - janet_panicf("unknown sfx index, got %s\n", index); + janet_panicf("unknown sfx index, got %s\n", index); } // possibly get default values from sfx @@ -435,16 +435,16 @@ static Janet janet_sfx(int32_t argc, Janet* argv) s32 defaultSpeed = SFX_DEF_SPEED; if (index >= 0) { - defaultSfxNote.note = effect->note; - defaultSfxNote.octave = effect->octave; - defaultSpeed = effect->speed; + defaultSfxNote.note = effect->note; + defaultSfxNote.octave = effect->octave; + defaultSpeed = effect->speed; } SFXNote sfxNote = tic_optsfxnote(argv, argc, 1, defaultSfxNote); s32 duration = (s32)janet_optinteger(argv, argc, 2, -1); s32 channel = (s32)janet_optinteger(argv, argc, 3, 0); if (channel < 0 || channel > TIC_SOUND_CHANNELS) { - janet_panicf("unknown channel, got %s\n", channel); + janet_panicf("unknown channel, got %s\n", channel); } s32 volumes[TIC80_SAMPLE_CHANNELS] = {MAX_VOLUME, MAX_VOLUME}; @@ -454,10 +454,10 @@ static Janet janet_sfx(int32_t argc, Janet* argv) s32 speed = (s32)janet_optinteger(argv, argc, 5, defaultSpeed); tic_api_sfx(memory, index, - sfxNote.note, sfxNote.octave, - duration, channel, - volumes[0] & 0xf, volumes[1] & 0xf, - speed); + sfxNote.note, sfxNote.octave, + duration, channel, + volumes[0] & 0xf, volumes[1] & 0xf, + speed); return janet_wrap_nil(); } @@ -475,15 +475,15 @@ static void remapCallback(void* data, s32 x, s32 y, RemapResult* result) if (janet_checktypes(jresult, JANET_TFLAG_INDEXED)) { - const Janet *jresult_tuple = janet_unwrap_tuple(jresult); - u8 retc = janet_tuple_length(jresult_tuple); - result->index = janet_getinteger(jresult_tuple, 0); - result->flip = janet_optinteger(jresult_tuple, retc, 1, 0); - result->rotate = janet_optinteger(jresult_tuple, retc, 2, 0); + const Janet *jresult_tuple = janet_unwrap_tuple(jresult); + u8 retc = janet_tuple_length(jresult_tuple); + result->index = janet_getinteger(jresult_tuple, 0); + result->flip = janet_optinteger(jresult_tuple, retc, 1, 0); + result->rotate = janet_optinteger(jresult_tuple, retc, 2, 0); } else if (janet_checkint(jresult)) { - result->index = janet_unwrap_integer(jresult); + result->index = janet_unwrap_integer(jresult); } } @@ -508,17 +508,17 @@ static Janet janet_map(int32_t argc, Janet* argv) if (argc < 9) { - tic_api_map(memory, x, y, w, h, sx, sy, - colorkey.colors, colorkey.count, - scale, NULL, NULL); + tic_api_map(memory, x, y, w, h, sx, sy, + colorkey.colors, colorkey.count, + scale, NULL, NULL); } else { - JanetFunction *remap = janet_getfunction(argv, 8); - tic_api_map(memory, x, y, w, h, sx, sy, - colorkey.colors, colorkey.count, - scale, - remapCallback, remap); + JanetFunction *remap = janet_getfunction(argv, 8); + tic_api_map(memory, x, y, w, h, sx, sy, + colorkey.colors, colorkey.count, + scale, + remapCallback, remap); } return janet_wrap_nil(); @@ -671,7 +671,7 @@ static Janet janet_trace(int32_t argc, Janet* argv) const char *message = janet_getcstring(argv, 0); if (argc > 1) { - color = janet_getinteger(argv, 1); + color = janet_getinteger(argv, 1); } tic_mem* memory = (tic_mem*)getJanetMachine(); @@ -686,20 +686,20 @@ static Janet janet_pmem(int32_t argc, Janet* argv) if(index < TIC_PERSISTENT_SIZE) { - tic_mem* memory = (tic_mem*)getJanetMachine(); - u32 val = tic_api_pmem(memory, index, 0, false); + tic_mem* memory = (tic_mem*)getJanetMachine(); + u32 val = tic_api_pmem(memory, index, 0, false); - if (argc >= 2) - { - u32 value = janet_getinteger(argv, 1); - tic_api_pmem(memory, index, value, true); - } + if (argc >= 2) + { + u32 value = janet_getinteger(argv, 1); + tic_api_pmem(memory, index, value, true); + } - return janet_wrap_integer(val); + return janet_wrap_integer(val); } else { - janet_panic("Error: invalid persistent tic index"); + janet_panic("Error: invalid persistent tic index"); } } @@ -742,8 +742,8 @@ static Janet janet_font(int32_t argc, Janet* argv) tic_mem* memory = (tic_mem*)getJanetMachine(); int32_t width = tic_api_font(memory, - text, x, y, &chromakey, 1, - w, h, fixed, scale, alt); + text, x, y, &chromakey, 1, + w, h, fixed, scale, alt); return janet_wrap_integer(width); } @@ -755,9 +755,9 @@ static Janet janet_mouse(int32_t argc, Janet* argv) Janet result[7]; { - tic_point point = tic_api_mouse(memory); - result[0] = janet_wrap_integer(point.x); - result[1] = janet_wrap_integer(point.y); + tic_point point = tic_api_mouse(memory); + result[0] = janet_wrap_integer(point.x); + result[1] = janet_wrap_integer(point.y); } tic_core* core = getJanetMachine(); @@ -887,13 +887,13 @@ static Janet janet_ttri(int32_t argc, Janet* argv) { if (janet_checktypes(argv[12], JANET_TFLAG_BOOLEAN)) { - if (janet_getboolean(argv, 12)) { - src = tic_map_texture; - } + if (janet_getboolean(argv, 12)) { + src = tic_map_texture; + } } else if (janet_checktypes(argv[12], JANET_TFLAG_NUMBER)) { - src = janet_getinteger(argv, 12); + src = janet_getinteger(argv, 12); } } @@ -902,15 +902,15 @@ static Janet janet_ttri(int32_t argc, Janet* argv) tic_mem* memory = (tic_mem*)getJanetMachine(); tic_api_ttri(memory, - x1, y1, - x2, y2, - x3, y3, - u1, v1, - u2, v2, - u3, v3, - src, - trans.colors, trans.count, - depth.z[0], depth.z[1], depth.z[2], depth.on); + x1, y1, + x2, y2, + x3, y3, + u1, v1, + u2, v2, + u3, v3, + src, + trans.colors, trans.count, + depth.z[0], depth.z[1], depth.z[2], depth.on); return janet_wrap_nil(); } @@ -922,15 +922,15 @@ static Janet janet_clip(int32_t argc, Janet* argv) tic_mem* memory = (tic_mem*)getJanetMachine(); if (argc == 0) { - tic_api_clip(memory, 0, 0, TIC80_WIDTH, TIC80_HEIGHT); + tic_api_clip(memory, 0, 0, TIC80_WIDTH, TIC80_HEIGHT); } else if (argc == 4) { - s32 x = janet_getinteger(argv, 0); - s32 y = janet_getinteger(argv, 1); - s32 w = janet_getinteger(argv, 2); - s32 h = janet_getinteger(argv, 3); - tic_api_clip(memory, x, y, w, h); + s32 x = janet_getinteger(argv, 0); + s32 y = janet_getinteger(argv, 1); + s32 w = janet_getinteger(argv, 2); + s32 h = janet_getinteger(argv, 3); + tic_api_clip(memory, x, y, w, h); } else { - janet_panic("Error: must provide exactly 0 or 4 args."); + janet_panic("Error: must provide exactly 0 or 4 args."); } return janet_wrap_nil(); @@ -1050,11 +1050,11 @@ static void closeJanet(tic_mem* tic) tic_core* core = (tic_core*)tic; if (core->currentVM) { - janet_deinit(); - core->currentVM = NULL; - CurrentMachine = NULL; - errBuffer = NULL; - GameFiber = NULL; + janet_deinit(); + core->currentVM = NULL; + CurrentMachine = NULL; + errBuffer = NULL; + GameFiber = NULL; } } @@ -1085,8 +1085,8 @@ static bool initJanet(tic_mem* tic, const char* code) // Load the game source code if (janet_dostring(core->currentVM, code, "main", &result)) { - reportError(core, result); - return false; + reportError(core, result); + return false; } return true; @@ -1117,8 +1117,8 @@ static void callJanetTick(tic_mem* tic) (void)janet_resolve(core->currentVM, janet_csymbol(TIC_FN), &pre_fn); if (janet_type(pre_fn) != JANET_FUNCTION) { - core->data->error(core->data->data, "(TIC) isn't found :("); - return; + core->data->error(core->data->data, "(TIC) isn't found :("); + return; } JanetFunction *tic_fn = janet_unwrap_function(pre_fn); @@ -1126,19 +1126,19 @@ static void callJanetTick(tic_mem* tic) JanetSignal status = janet_pcall(tic_fn, 0, NULL, &result, &GameFiber); if (status != JANET_SIGNAL_OK) { - reportError(core, result); + reportError(core, result); } #if defined(BUILD_DEPRECATED) // call OVR() callback for backward compatibility (void)janet_resolve(core->currentVM, janet_csymbol(OVR_FN), &pre_fn); if (janet_type(pre_fn) == JANET_FUNCTION) { - JanetFunction *ovr_fn = janet_unwrap_function(pre_fn); - JanetSignal status = janet_pcall(ovr_fn, 0, NULL, &result, &GameFiber); + JanetFunction *ovr_fn = janet_unwrap_function(pre_fn); + JanetSignal status = janet_pcall(ovr_fn, 0, NULL, &result, &GameFiber); - if (status != JANET_SIGNAL_OK) { - reportError(core, result); - } + if (status != JANET_SIGNAL_OK) { + reportError(core, result); + } } #endif } @@ -1155,7 +1155,7 @@ static void callJanetBoot(tic_mem* tic) (void)janet_resolve(core->currentVM, janet_csymbol(BOOT_FN), &pre_fn); if (janet_type(pre_fn) != JANET_FUNCTION) { - return; + return; } Janet result = janet_wrap_nil(); @@ -1163,7 +1163,7 @@ static void callJanetBoot(tic_mem* tic) JanetSignal status = janet_pcall(boot_fn, 0, NULL, &result, &GameFiber); if (status != JANET_SIGNAL_OK) { - reportError(core, result); + reportError(core, result); } } @@ -1179,7 +1179,7 @@ static void callJanetIntCallback(tic_mem* tic, s32 value, void* data, const char (void)janet_resolve(core->currentVM, janet_csymbol(name), &pre_fn); if (janet_type(pre_fn) != JANET_FUNCTION) { - return; + return; } Janet result = janet_wrap_nil(); @@ -1188,7 +1188,7 @@ static void callJanetIntCallback(tic_mem* tic, s32 value, void* data, const char JanetSignal status = janet_pcall(fn, 1, argv, &result, &GameFiber); if (status != JANET_SIGNAL_OK) { - reportError(core, result); + reportError(core, result); } } @@ -1218,49 +1218,49 @@ static const tic_outline_item* getJanetOutline(const char* code, s32* size) if(items) { - free(items); - items = NULL; + free(items); + items = NULL; } const char* ptr = code; while(true) { - static const char FuncString[] = "(defn "; + static const char FuncString[] = "(defn "; - ptr = strstr(ptr, FuncString); + ptr = strstr(ptr, FuncString); - if(ptr) - { - ptr += sizeof FuncString - 1; + if(ptr) + { + ptr += sizeof FuncString - 1; - const char* start = ptr; - const char* end = start; + const char* start = ptr; + const char* end = start; - while(*ptr) - { - char c = *ptr; + while(*ptr) + { + char c = *ptr; - if(c == ' ' || c == '\t' || c == '\n' || c == '[') - { - end = ptr; - break; - } + if(c == ' ' || c == '\t' || c == '\n' || c == '[') + { + end = ptr; + break; + } - ptr++; - } + ptr++; + } - if(end > start) - { - items = realloc(items, (*size + 1) * Size); + if(end > start) + { + items = realloc(items, (*size + 1) * Size); - items[*size].pos = start; - items[*size].size = (s32)(end - start); + items[*size].pos = start; + items[*size].size = (s32)(end - start); - (*size)++; - } - } - else break; + (*size)++; + } + } + else break; } return items; @@ -1281,9 +1281,9 @@ const tic_script_config JanetSyntaxConfig = .callback = { - .scanline = callJanetScanline, - .border = callJanetBorder, - .menu = callJanetMenu, + .scanline = callJanetScanline, + .border = callJanetBorder, + .menu = callJanetMenu, }, .getOutline = getJanetOutline, From 324d04d3d1f8ae6655a220690a9e0370bd9862e3 Mon Sep 17 00:00:00 2001 From: nesbox Date: Sun, 8 Oct 2023 12:51:05 +0200 Subject: [PATCH 77/83] #2311: fixed crash when steganography code reads out of bounds --- src/ext/png.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/ext/png.c b/src/ext/png.c index ec07fa941..84c1a7765 100644 --- a/src/ext/png.c +++ b/src/ext/png.c @@ -230,16 +230,20 @@ png_buffer png_encode(png_buffer cover, png_buffer cart) const s32 coverSize = png.width * png.height * RGBA_SIZE - HEADER_SIZE; Header header = {CLAMP(ceildiv(cartBits, coverSize), 1, BITS_IN_BYTE), cart.size}; - for (s32 i = 0; i < HEADER_SIZE; i++) - bitcpy(png.data, i << 3, header.data, i * HEADER_BITS, HEADER_BITS); + // only save with steganography if there are enough pixels for the size of the cartidge + if (coverSize >= cartBits) + { + for (s32 i = 0; i < HEADER_SIZE; i++) + bitcpy(png.data, i << 3, header.data, i * HEADER_BITS, HEADER_BITS); - u8* dst = png.data + HEADER_SIZE; - s32 end = ceildiv(cartBits, header.bits); - for (s32 i = 0; i < end; i++) - bitcpy(dst, i << 3, cart.data, i * header.bits, header.bits); + u8* dst = png.data + HEADER_SIZE; + s32 end = ceildiv(cartBits, header.bits); + for (s32 i = 0; i < end; i++) + bitcpy(dst, i << 3, cart.data, i * header.bits, header.bits); - for (s32 i = end; i < coverSize; i++) - bitcpy(dst, i << 3, (const u8[]){rand()}, 0, header.bits); + for (s32 i = end; i < coverSize; i++) + bitcpy(dst, i << 3, (const u8[]){rand()}, 0, header.bits); + } png_buffer out = png_write(png, cart); From 59ff33bb14d0654c157c012da996fafff5317028 Mon Sep 17 00:00:00 2001 From: nesbox Date: Sun, 8 Oct 2023 13:36:06 +0200 Subject: [PATCH 78/83] #2313: fixed cart addition in wasm --- CMakeLists.txt | 2 +- build/html/export.html | 133 +++++++++++--------------------- build/html/index.html | 143 +++++++++++++---------------------- build/html/prejs.js | 32 ++++++++ src/studio/screens/console.c | 8 +- 5 files changed, 134 insertions(+), 184 deletions(-) create mode 100644 build/html/prejs.js diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c0ed2527..5436036b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1208,7 +1208,7 @@ if(BUILD_SDL) endif() if(EMSCRIPTEN) - set_target_properties(tic80 PROPERTIES LINK_FLAGS "-s WASM=1 -s USE_SDL=2 -s ALLOW_MEMORY_GROWTH=1 -s FETCH=1 -s EXPORT_ES6=1 -s MODULARIZE=1 -s ENVIRONMENT=web -s EXPORT_NAME=createModule -s EXPORTED_RUNTIME_METHODS=['ENV'] -lidbfs.js") + set_target_properties(tic80 PROPERTIES LINK_FLAGS "-s WASM=1 -s USE_SDL=2 -s ALLOW_MEMORY_GROWTH=1 -s FETCH=1 --pre-js ${CMAKE_SOURCE_DIR}/build/html/prejs.js -lidbfs.js") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s USE_SDL=2") if(CMAKE_BUILD_TYPE STREQUAL "Debug") diff --git a/build/html/export.html b/build/html/export.html index 1791e40ce..527603a47 100644 --- a/build/html/export.html +++ b/build/html/export.html @@ -1,100 +1,57 @@ - - - - - TIC-80 tiny computer - - - -
- -
- Play -
-
- - - + + diff --git a/build/html/index.html b/build/html/index.html index 3f8496187..fa4c77659 100644 --- a/build/html/index.html +++ b/build/html/index.html @@ -1,98 +1,59 @@ - - - - - TIC-80 tiny computer - - - -
- -
- Play + + + + + + TIC-80 tiny computer + + + + + +
+ +
+
+

- CLICK TO PLAY -

-
- - - + + + + diff --git a/build/html/prejs.js b/build/html/prejs.js new file mode 100644 index 000000000..e206e1837 --- /dev/null +++ b/build/html/prejs.js @@ -0,0 +1,32 @@ +Module.saveAs = Module.saveAs||function(e){"use strict";if(typeof e==="undefined"||typeof navigator!=="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent)){return}var t=e.document,n=function(){return e.URL||e.webkitURL||e},r=t.createElementNS("http://www.w3.org/1999/xhtml","a"),o="download"in r,i=function(e){var t=new MouseEvent("click");e.dispatchEvent(t)},a=/constructor/i.test(e.HTMLElement),f=/CriOS\/[\d]+/.test(navigator.userAgent),u=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},d="application/octet-stream",s=1e3*40,c=function(e){var t=function(){if(typeof e==="string"){n().revokeObjectURL(e)}else{e.remove()}};setTimeout(t,s)},l=function(e,t,n){t=[].concat(t);var r=t.length;while(r--){var o=e["on"+t[r]];if(typeof o==="function"){try{o.call(e,n||e)}catch(i){u(i)}}}},p=function(e){if(/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)){return new Blob([String.fromCharCode(65279),e],{type:e.type})}return e},v=function(t,u,s){if(!s){t=p(t)}var v=this,w=t.type,m=w===d,y,h=function(){l(v,"writestart progress write writeend".split(" "))},S=function(){if((f||m&&a)&&e.FileReader){var r=new FileReader;r.onloadend=function(){var t=f?r.result:r.result.replace(/^data:[^;]*;/,"data:attachment/file;");var n=e.open(t,"_blank");if(!n)e.location.href=t;t=undefined;v.readyState=v.DONE;h()};r.readAsDataURL(t);v.readyState=v.INIT;return}if(!y){y=n().createObjectURL(t)}if(m){e.location.href=y}else{var o=e.open(y,"_blank");if(!o){e.location.href=y}}v.readyState=v.DONE;h();c(y)};v.readyState=v.INIT;if(o){y=n().createObjectURL(t);setTimeout(function(){r.href=y;r.download=u;i(r);h();c(y);v.readyState=v.DONE});return}S()},w=v.prototype,m=function(e,t,n){return new v(e,t||e.name||"download",n)};if(typeof navigator!=="undefined"&&navigator.msSaveOrOpenBlob){return function(e,t,n){t=t||e.name||"download";if(!n){e=p(e)}return navigator.msSaveOrOpenBlob(e,t)}}w.abort=function(){};w.readyState=w.INIT=0;w.WRITING=1;w.DONE=2;w.error=w.onwritestart=w.onprogress=w.onwrite=w.onabort=w.onerror=w.onwriteend=null;return m}(typeof self!=="undefined"&&self||typeof window!=="undefined"&&window||this.content);if(typeof module!=="undefined"&&module.exports){module.exports.saveAs=saveAs}else if(typeof define!=="undefined"&&define!==null&&define.amd!==null){define([],function(){return saveAs})}; +Module.showAddPopup = function(callback) +{ + var modal = document.getElementById('add-modal'); + var span = document.getElementsByClassName("close")[0]; + modal.style.display = "block"; + function cancel(){modal.style.display = "none"; callback(null, null);} + span.onclick = cancel; + window.onclick = function(event) {if (event.target == modal) cancel();} + + var uploadInput = document.getElementById('upload-input'); + uploadInput.onchange = function() + { + var file = uploadInput.files[0]; + + if(!file) return; + + var reader = new FileReader(); + + reader.onload = function(event) + { + var rom = new Uint8Array(event.target.result); + + callback(file.name, rom); + + uploadInput.value = ""; + modal.style.display = "none"; + }; + + reader.readAsArrayBuffer(file); + }; +}; \ No newline at end of file diff --git a/src/studio/screens/console.c b/src/studio/screens/console.c index feffc096a..36e2de084 100644 --- a/src/studio/screens/console.c +++ b/src/studio/screens/console.c @@ -2669,16 +2669,16 @@ static void onAddCommand(Console* console) } else { - var filePtr = Module._malloc(filename.length + 1); + var filePtr = _malloc(filename.length + 1); stringToUTF8(filename, filePtr, filename.length + 1); - var dataPtr = Module._malloc(rom.length); + var dataPtr = _malloc(rom.length); writeArrayToMemory(rom, dataPtr); dynCall('viiii', $0, [$1, filePtr, dataPtr, rom.length]); - Module._free(filePtr); - Module._free(dataPtr); + _free(filePtr); + _free(dataPtr); } }); }, onAddFile, console); From a24f206d61d5f7fa1608a67a5d466972a4bcb397 Mon Sep 17 00:00:00 2001 From: nesbox Date: Sun, 8 Oct 2023 14:47:41 +0200 Subject: [PATCH 79/83] #2322: fixed btn/btnp in ruby --- src/api/mruby.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/api/mruby.c b/src/api/mruby.c index ddd8c41d7..dc49c77cd 100644 --- a/src/api/mruby.c +++ b/src/api/mruby.c @@ -370,19 +370,17 @@ static mrb_value mrb_btnp(mrb_state* mrb, mrb_value self) mrb_int index, hold, period; mrb_int argc = mrb_get_args(mrb, "|iii", &index, &hold, &period); - index &= 0x1f; - if (argc == 0) { return mrb_fixnum_value(tic_api_btnp(memory, -1, -1, -1)); } else if(argc == 1) { - return mrb_bool_value(tic_api_btnp(memory, index, -1, -1)); + return mrb_bool_value(tic_api_btnp(memory, index & 0x1f, -1, -1) != 0); } else if (argc == 3) { - return mrb_bool_value(tic_api_btnp(memory, index, hold, period)); + return mrb_bool_value(tic_api_btnp(memory, index & 0x1f, hold, period) != 0); } else { @@ -394,19 +392,18 @@ static mrb_value mrb_btnp(mrb_state* mrb, mrb_value self) static mrb_value mrb_btn(mrb_state* mrb, mrb_value self) { tic_core* machine = getMRubyMachine(mrb); + tic_mem* memory = (tic_mem*)machine; mrb_int index, hold, period; mrb_int argc = mrb_get_args(mrb, "|i", &index, &hold, &period); - index &= 0x1f; - if (argc == 0) { - return mrb_fixnum_value(machine->memory.ram->input.gamepads.data); + return mrb_bool_value(tic_api_btn(memory, -1) != 0); } else if (argc == 1) { - return mrb_bool_value(machine->memory.ram->input.gamepads.data & (1 << index)); + return mrb_bool_value(tic_api_btn(memory, index & 0x1f) != 0); } else { From 8e1978b014f1cb15ca01364b35af4876c1b3509d Mon Sep 17 00:00:00 2001 From: ladace Date: Sun, 15 Oct 2023 19:45:33 +0800 Subject: [PATCH 80/83] fixed eval command in ruby fixed issue: eval causing the program to crash when no cart is running; vm being mistakenly reset when calling eval so resuming is impossible; potential memory leak --- src/api/mruby.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/api/mruby.c b/src/api/mruby.c index dc49c77cd..6c4842838 100644 --- a/src/api/mruby.c +++ b/src/api/mruby.c @@ -1053,17 +1053,19 @@ static bool initMRuby(tic_mem* tic, const char* code) static void evalMRuby(tic_mem* tic, const char* code) { tic_core* machine = (tic_core*)tic; - mrb_state* mrb = ((mrbVm*)machine->currentVM)->mrb = mrb_open(); - - if (!mrb) + mrbVm* vm=(mrbVm*)machine->currentVM; + if(!vm) return; + mrb_state* mrb = vm->mrb; + if (((mrbVm*)machine->currentVM)->mrb_cxt) { mrbc_context_free(mrb, ((mrbVm*)machine->currentVM)->mrb_cxt); } mrbc_context* mrb_cxt = ((mrbVm*)machine->currentVM)->mrb_cxt = mrbc_context_new(mrb); + mrbc_filename(mrb, mrb_cxt, "eval"); mrb_load_string_cxt(mrb, code, mrb_cxt); catcherr(machine); } From 1fb36a4184792555f8a7b69213f0a8c73bbbaf19 Mon Sep 17 00:00:00 2001 From: ladace Date: Sun, 15 Oct 2023 20:40:03 +0800 Subject: [PATCH 81/83] fixed crashing when running eval command in ruby eval crashes after first running a cart of a different language and switching to a ruby cart --- src/api/mruby.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/mruby.c b/src/api/mruby.c index 6c4842838..c642c2896 100644 --- a/src/api/mruby.c +++ b/src/api/mruby.c @@ -1054,7 +1054,7 @@ static void evalMRuby(tic_mem* tic, const char* code) { tic_core* machine = (tic_core*)tic; mrbVm* vm=(mrbVm*)machine->currentVM; - if(!vm) + if(!vm || !vm->mrb) return; mrb_state* mrb = vm->mrb; From 1e7ad346b600ac2338d2f01141e839ed0b1aa51c Mon Sep 17 00:00:00 2001 From: ladace Date: Sun, 15 Oct 2023 22:05:37 +0800 Subject: [PATCH 82/83] trace can log object in ruby --- src/api/mruby.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/mruby.c b/src/api/mruby.c index c642c2896..98e64cd53 100644 --- a/src/api/mruby.c +++ b/src/api/mruby.c @@ -900,7 +900,7 @@ static mrb_value mrb_trace(mrb_state *mrb, mrb_value self) { mrb_value text_obj; mrb_int color = TIC_DEFAULT_COLOR; - mrb_get_args(mrb, "S|i", &text_obj, &color); + mrb_get_args(mrb, "o|i", &text_obj, &color); tic_core* machine = getMRubyMachine(mrb); From 4212d28ef7791f64a05dbba4fdb193edea8a6b28 Mon Sep 17 00:00:00 2001 From: nesbox Date: Sun, 15 Oct 2023 17:39:01 +0200 Subject: [PATCH 83/83] #2310: fixed foreign keyboard keys --- src/studio/editors/code.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/studio/editors/code.c b/src/studio/editors/code.c index 8fb475dee..af15b8c39 100644 --- a/src/studio/editors/code.c +++ b/src/studio/editors/code.c @@ -2845,8 +2845,6 @@ static void processKeyboard(Code* code) { tic_mem* tic = code->tic; - if(tic->ram->input.keyboard.data == 0) return; - enum KeybindMode keymode = getKeybindMode(code); if (keymode == KEYBIND_VI)