From bb00507733f2ed1123a00c7f57b6569a75a8ee18 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Sat, 16 May 2026 09:06:34 +0200 Subject: [PATCH] =?UTF-8?q?-=20[FIX]=20Corregits=20un=20cab=C3=A0s=20de=20?= =?UTF-8?q?warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + ascii.cpp | 4 +- lua.cpp | 2 +- lua/loadlib.c | 112 +------------------------------------------------- main.cpp | 6 +-- play.cpp | 4 +- 6 files changed, 10 insertions(+), 119 deletions(-) diff --git a/.gitignore b/.gitignore index fe3525b..9f14995 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.exe ascii +ascii_debug .vscode/* *.dll wiki/* diff --git a/ascii.cpp b/ascii.cpp index 2731773..2faac17 100644 --- a/ascii.cpp +++ b/ascii.cpp @@ -311,7 +311,7 @@ int main(int argc,char*argv[]) { debug_cursor_blink--; if (debug_cursor_blink == 0) { debug_cursor_blink = 60; - const int pos = cursor_x+cursor_y*screen_width; + //const int pos = cursor_x+cursor_y*screen_width; //char_screen[pos] = char_screen[pos]==32 ? 95 : 32; } loop(); @@ -600,7 +600,7 @@ void pdebug() { } } */ -int cmd_index = 0; +unsigned int cmd_index = 0; void debug_get_cmd() { char_screen[cursor_x+cursor_y*screen_width] = 0; //char *tmp = (char*)&char_screen[1+cursor_y*screen_width]; diff --git a/lua.cpp b/lua.cpp index 4e256f9..2b40022 100644 --- a/lua.cpp +++ b/lua.cpp @@ -420,7 +420,7 @@ bool lua_is_playing() { return lua_state == STATE_PLAYING; } -const char boot[] = "function init()mode(1)cls()play('o5l0v5cegv4cegv3cegv2cegv1ceg')memcpy(360,4608,240)memcpy(1560,4848,240)ink(1)print('G A M E',8,16)ink(4)print('S Y S T E M',20,16)ink(7)print('mini',9,8)ink(8)print('v0.7.2',34,29)w=0 end function update()w=w+1 if w>90 then cls()load()end end"; +const char boot[] = "function init()mode(1)cls()play('o5l0v5cegv4cegv3cegv2cegv1ceg')memcpy(360,4608,240)memcpy(1560,4848,240)ink(1)print('G A M E',8,16)ink(4)print('S Y S T E M',20,16)ink(7)print('mini',9,8)ink(8)print('v0.7.3',34,29)w=0 end function update()w=w+1 if w>90 then cls()load()end end"; void lua_init(const char* filename, const bool start_playing) { if (lua_state != STATE_STOPPED) lua_quit(); diff --git a/lua/loadlib.c b/lua/loadlib.c index 3fd26c5..6bbae7b 100644 --- a/lua/loadlib.c +++ b/lua/loadlib.c @@ -646,118 +646,8 @@ static void findloader (lua_State *L, const char *name) { } } -// [RZC 12/03/2026] ================================== -// Soport per a rutes relatives i absolutes -// -static void resolve_module_name(lua_State *L, char *out, size_t outsz) { - const char *req = luaL_checkstring(L, 1); - - // 1. RUTA ABSOLUTA: empieza por ':' - if (req[0] == ':') { - strncpy(out, req + 1, outsz - 1); - out[outsz - 1] = '\0'; - return; - } - - // 2. Obtener módulo llamador - lua_Debug ar; - if (!lua_getstack(L, 1, &ar)) { - // No hay llamador → usar nombre tal cual - strncpy(out, req, outsz - 1); - out[outsz - 1] = '\0'; - return; - } - - lua_getinfo(L, "S", &ar); - - // ar.source contiene algo como "@ia.test" o "@main" - const char *src = ar.source; - if (!src) { - // No viene de archivo → usar nombre tal cual - strncpy(out, req, outsz - 1); - out[outsz - 1] = '\0'; - return; - } - - // Quitar '@' - //src++; - - // 3. Extraer directorio del módulo llamador - // Ej: "ia.tools.other" → "ia.tools" - char caller[256]; - strncpy(caller, src, sizeof(caller) - 1); - caller[sizeof(caller) - 1] = '\0'; - - char *lastdot = strrchr(caller, '.'); - if (lastdot) - *lastdot = '\0'; // dejar solo el directorio - else - caller[0] = '\0'; // está en la raíz - - // 4. RUTA RELATIVA HACIA ARRIBA: empieza por ".." - if (req[0] == '.' && req[1] == '.') { - // Contar cuántos '.' consecutivos hay - int up = 0; - while (req[up] == '.') - up++; - - // up = número de puntos → niveles a subir - // Ej: "..test" → up=2 → subir 1 nivel - // "...main" → up=3 → subir 2 niveles - - int levels = up - 1; - - // Copiar caller a buffer temporal - char temp[256]; - strncpy(temp, caller, sizeof(temp) - 1); - temp[sizeof(temp) - 1] = '\0'; - - // Subir niveles - for (int i = 0; i < levels; i++) { - char *p = strrchr(temp, '.'); - if (p) - *p = '\0'; - else { - temp[0] = '\0'; - break; - } - } - - // Concatenar lo que queda después de los puntos - const char *rest = req + up; - - if (temp[0] == '\0') { - // Hemos llegado a la raíz - strncpy(out, rest, outsz - 1); - } else { - snprintf(out, outsz, "%s.%s", temp, rest); - } - - out[outsz - 1] = '\0'; - return; - } - - // 5. RUTA RELATIVA NORMAL (no empieza por ':' ni por '..') - if (caller[0] == '\0') { - // Estamos en la raíz - strncpy(out, req, outsz - 1); - } else { - snprintf(out, outsz, "%s.%s", caller, req); - } - - out[outsz - 1] = '\0'; -} -// =================================================== - static int ll_require (lua_State *L) { - // [RZC 12/03/2026] ================================== - // Soport per a rutes relatives i absolutes - // - //const char *name = luaL_checkstring(L, 1); - char resolved[256]; - resolve_module_name(L, resolved, sizeof(resolved)); - const char *name = resolved; - // =================================================== + const char *name = luaL_checkstring(L, 1); lua_settop(L, 1); /* LOADED table will be at index 2 */ lua_getfield(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE); diff --git a/main.cpp b/main.cpp index ac12501..f24cf4e 100644 --- a/main.cpp +++ b/main.cpp @@ -17,7 +17,7 @@ void save_code(); void loop() { if (btnp(KEY_TAB)) { - current_editor = (++current_editor)%2; + current_editor = (current_editor+1)%2; switch(current_editor) { case 0: init_terminal(); @@ -137,8 +137,8 @@ void load_code() { } std::list::iterator ls[28]; -static int col = 0; -static int line = 0; +static unsigned int col = 0; +static unsigned int line = 0; void refresh_code_editor() { color(COLOR_WHITE, COLOR_BLUE); diff --git a/play.cpp b/play.cpp index 03e9dbd..cefc184 100644 --- a/play.cpp +++ b/play.cpp @@ -14,11 +14,11 @@ static char* song_ptr = NULL; static char* song = NULL; uint32_t interpret_note(uint8_t* buffer, const char note, const char param ) { - const uint32_t length = ( param == -1 ? default_length : ((float)lengths[param])/10000.0f ) * tempo; + const uint32_t length = ( param == -1 ? default_length : ((float)lengths[uint8_t(param)])/10000.0f ) * tempo; if( note == 100 ) { memset( buffer, 0, length ); return length; } const uint16_t period = periods[note + octave*12]; - for( int i = 0; i < length; i++ ) buffer[i] = ( (i % period) < (period >> 1) ? volume : -volume ); + for( unsigned int i = 0; i < length; i++ ) buffer[i] = ( (i % period) < (period >> 1) ? volume : -volume ); return length; }