- [FIX] Corregits un cabàs de warnings
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
*.exe
|
||||
ascii
|
||||
ascii_debug
|
||||
.vscode/*
|
||||
*.dll
|
||||
wiki/*
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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();
|
||||
|
||||
+1
-111
@@ -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);
|
||||
|
||||
@@ -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<std::string>::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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user