mirror of
https://github.com/NeoFlock/neonucleus.git
synced 2025-09-24 09:03:32 +02:00
many bugfixes
OpenOS is now almost fully usable
This commit is contained in:
parent
4c9851f847
commit
e9d3826f0f
@ -359,12 +359,20 @@ void nni_gpu_copy(nni_gpu *gpu, void *_, nn_component *component, nn_computer *c
|
||||
|
||||
int changes = 0, clears = 0;
|
||||
|
||||
nn_scrchr_t *tmpBuffer = nn_malloc(sizeof(nn_scrchr_t) * w * h);
|
||||
if(tmpBuffer == NULL) {
|
||||
nn_setCError(computer, "out of memory");
|
||||
return;
|
||||
}
|
||||
|
||||
for(int cx = x; cx < x + w; cx++) {
|
||||
for(int cy = y; cy < y + h; cy++) {
|
||||
int ox = cx - x;
|
||||
int oy = cy - y;
|
||||
nn_scrchr_t src = nn_getPixel(gpu->currentScreen, cx, cy);
|
||||
nn_scrchr_t old = nn_getPixel(gpu->currentScreen, cx + tx, cy + ty);
|
||||
tmpBuffer[ox + oy * w] = src;
|
||||
if(!nni_samePixel(old, src)) {
|
||||
nn_setPixel(gpu->currentScreen, cx + tx, cy + ty, src);
|
||||
if(src.codepoint == ' ')
|
||||
clears++;
|
||||
else changes++;
|
||||
@ -372,6 +380,15 @@ void nni_gpu_copy(nni_gpu *gpu, void *_, nn_component *component, nn_computer *c
|
||||
}
|
||||
}
|
||||
|
||||
for(int ox = 0; ox < w; ox++) {
|
||||
for(int oy = 0; oy < h; oy++) {
|
||||
nn_scrchr_t p = tmpBuffer[ox + oy * w];
|
||||
nn_setPixel(gpu->currentScreen, ox + x + tx, oy + y + ty, p);
|
||||
}
|
||||
}
|
||||
|
||||
nn_free(tmpBuffer);
|
||||
|
||||
nn_addHeat(computer, gpu->ctrl.pixelChangeHeat * changes);
|
||||
nn_callCost(computer, gpu->ctrl.pixelChangeCost * changes);
|
||||
nn_removeEnergy(computer, gpu->ctrl.pixelChangeEnergy * changes);
|
||||
|
@ -394,10 +394,38 @@ sandbox = {
|
||||
|
||||
utf8 = copy(utf8),
|
||||
unicode = copy(unicode, {
|
||||
wtrunc = function(s, count)
|
||||
return unicode.sub(s, 1, count)
|
||||
end,
|
||||
wtrunc = function (str,space)
|
||||
space = space - 1
|
||||
return str:sub(1,(space >= utf8.len(str)) and (#str) or (utf8.offset(str,space+1)-1))
|
||||
end,
|
||||
isWide = function(s) return unicode.wlen(s) > unicode.len(s) end,
|
||||
upper = string.upper,
|
||||
lower = string.lower,
|
||||
sub = function (str,a,b)
|
||||
if not b then b = utf8.len(str) end
|
||||
if not a then a = 1 end
|
||||
-- a = math.max(a,1)
|
||||
|
||||
if a < 0 then
|
||||
-- negative
|
||||
|
||||
a = utf8.len(str) + a + 1
|
||||
end
|
||||
|
||||
if b < 0 then
|
||||
b = utf8.len(str) + b + 1
|
||||
end
|
||||
|
||||
if a > b then return "" end
|
||||
|
||||
if b >= utf8.len(str) then b = #str else b = utf8.offset(str,b+1)-1 end
|
||||
|
||||
if a > utf8.len(str) then return "" end
|
||||
a = utf8.offset(str,a)
|
||||
|
||||
return str:sub(a,b)
|
||||
-- return str:sub(a, b)
|
||||
end,
|
||||
}),
|
||||
checkArg = checkArg,
|
||||
component = libcomponent,
|
||||
|
@ -61,6 +61,7 @@ double nn_realTimeClock(void *_) {
|
||||
}
|
||||
|
||||
void nn_busySleep(double t) {
|
||||
return; // fuck sleep
|
||||
double deadline = nn_realTime() + t;
|
||||
while(nn_realTime() < deadline) {}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user