From 9c1062c076fd63fb8a5c5293838cc38c381e4be5 Mon Sep 17 00:00:00 2001 From: IonutParau Date: Sun, 15 Mar 2026 22:32:35 +0100 Subject: [PATCH] bugfixes and a temporary optimization indirect is way too aggressive. It needs to be reworked --- data/OpenOS/bin/tree.lua | 3 +++ src/machine.lua | 2 ++ src/main.c | 5 ++++ src/neonucleus.c | 57 ++++++++++++++++++++++++++++++++++++++-- src/neonucleus.h | 1 + 5 files changed, 66 insertions(+), 2 deletions(-) diff --git a/data/OpenOS/bin/tree.lua b/data/OpenOS/bin/tree.lua index 6198b81..0f6dcb6 100644 --- a/data/OpenOS/bin/tree.lua +++ b/data/OpenOS/bin/tree.lua @@ -269,6 +269,9 @@ local function writeEntry(entry, levelStack) if opts.Q then io.write('"') end if opts.color == "always" then + if not entry.extension then + print("entry:", entry) + end io.write("\27[" .. colorize(entry) .. "m") end diff --git a/src/machine.lua b/src/machine.lua index 445994b..a0b3a83 100644 --- a/src/machine.lua +++ b/src/machine.lua @@ -5,6 +5,7 @@ local sysyieldobj = {} +local coroutine = coroutine local function sysyield() coroutine.yield(sysyieldobj) @@ -26,6 +27,7 @@ end function coroutine.wrap(f) local co = coroutine.create(f) return function(...) + if coroutine.status(co) ~= "suspended" then return end local t = {coroutine.resume(co, ...)} if t[1] then return table.unpack(t, 2) diff --git a/src/main.c b/src/main.c index d563b6d..49b3397 100644 --- a/src/main.c +++ b/src/main.c @@ -428,6 +428,10 @@ nn_Exit ne_screen_handler(nn_ScreenRequest *req) { req->keyboard = NULL; return NN_OK; } + if(req->h != 0) { + req->keyboard = NULL; + return NN_OK; + } size_t keylen = strlen(buf->keyboard); if(keylen > req->w) keylen = req->w; memcpy(req->keyboard, buf->keyboard, keylen); @@ -1204,6 +1208,7 @@ int main(int argc, char **argv) { tickClock = tickDelay; nn_clearstack(c); + if(getenv("NN_NOIDLE") != NULL) nn_resetIdleTime(c); nn_Exit e = nn_tick(c); if(e != NN_OK) { nn_setErrorFromExit(c, e); diff --git a/src/neonucleus.c b/src/neonucleus.c index eb04bec..e2bd0f7 100644 --- a/src/neonucleus.c +++ b/src/neonucleus.c @@ -1127,7 +1127,11 @@ bool nn_isComputerIdle(nn_Computer *computer) { } void nn_addIdleTime(nn_Computer *computer, double time) { - computer->idleTimestamp += time; + //computer->idleTimestamp += time; +} + +void nn_resetIdleTime(nn_Computer *computer) { + computer->idleTimestamp = -1; } nn_Exit nn_tick(nn_Computer *computer) { @@ -1430,7 +1434,7 @@ nn_Exit nn_call(nn_Computer *computer, const char *address, const char *method) nn_Method m = c.cstate->methods[j]; if(nn_strcmp(m.name, method) != 0) continue; // indirect calls consume the entire call budget - if((m.flags & NN_DIRECT) == NN_INDIRECT) computer->callBudget = 0; + //if((m.flags & NN_DIRECT) == NN_INDIRECT) computer->callBudget = 0; } nn_ComponentRequest req; @@ -3094,6 +3098,7 @@ static nn_Exit nn_screen_handler(nn_ComponentRequest *req) { scrreq.instance = req->compUserdata; const char *method = req->methodCalled; + nn_Exit e; switch(req->action) { case NN_COMP_FREETYPE: @@ -3110,6 +3115,54 @@ static nn_Exit nn_screen_handler(nn_ComponentRequest *req) { req->methodEnabled = true; return NN_OK; case NN_COMP_CALL: + if(nn_strcmp(method, "isOn") == 0) { + scrreq.action = NN_SCR_ISON; + e = state->handler(&scrreq); + if(e) return e; + req->returnCount = 1; + return nn_pushbool(C, scrreq.w != 0); + } + if(nn_strcmp(method, "isPrecise") == 0) { + scrreq.action = NN_SCR_ISPRECISE; + e = state->handler(&scrreq); + if(e) return e; + req->returnCount = 1; + return nn_pushbool(C, scrreq.w != 0); + } + if(nn_strcmp(method, "isTouchModeInverted") == 0) { + scrreq.action = NN_SCR_ISTOUCHINVERTED; + e = state->handler(&scrreq); + if(e) return e; + req->returnCount = 1; + return nn_pushbool(C, scrreq.w != 0); + } + if(nn_strcmp(method, "getAspectRatio") == 0) { + scrreq.action = NN_SCR_GETASPECTRATIO; + e = state->handler(&scrreq); + if(e) return e; + req->returnCount = 2; + e = nn_pushinteger(C, scrreq.w); + if(e) return e; + return nn_pushinteger(C, scrreq.h); + } + if(nn_strcmp(method, "getKeyboards") == 0) { + char buf[NN_MAX_ADDRESS]; + size_t kbCount = 0; + while(true) { + scrreq.action = NN_SCR_GETKEYBOARD; + scrreq.keyboard = buf; + scrreq.w = sizeof(buf); + scrreq.h = kbCount; + e = state->handler(&scrreq); + if(e) return e; + if(scrreq.keyboard == NULL) break; + e = nn_pushlstring(C, buf, scrreq.w); + if(e) return e; + kbCount++; + } + req->returnCount = 1; + return nn_pusharraytable(C, kbCount); + } nn_setError(C, "method not implemented yet"); return NN_EBADCALL; } diff --git a/src/neonucleus.h b/src/neonucleus.h index ddb31ec..487f4ab 100644 --- a/src/neonucleus.h +++ b/src/neonucleus.h @@ -467,6 +467,7 @@ nn_ComputerState nn_getComputerState(nn_Computer *computer); bool nn_isComputerIdle(nn_Computer *computer); // Shifts over the idle timestamp. void nn_addIdleTime(nn_Computer *computer, double time); +void nn_resetIdleTime(nn_Computer *computer); // runs a tick of the computer. Make sure to check the state as well! // This automatically resets the component budgets and call budget. // It also sets the idle timestamp to the current uptime.