many bugfixes

OpenOS is now almost fully usable
This commit is contained in:
2025-06-29 18:11:29 +02:00
parent 4c9851f847
commit e9d3826f0f
3 changed files with 50 additions and 4 deletions

View File

@@ -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);