mirror of
https://github.com/NeoFlock/neonucleus.git
synced 2025-09-24 09:03:32 +02:00
changes
This commit is contained in:
parent
be89f6a960
commit
d1ad9d0be3
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
nn_screen *nn_newScreen(nn_Context *context, int maxWidth, int maxHeight, int maxDepth, int editableColors, int paletteColors) {
|
nn_screen *nn_newScreen(nn_Context *context, int maxWidth, int maxHeight, int maxDepth, int editableColors, int paletteColors) {
|
||||||
nn_Alloc *alloc = &context->allocator;
|
nn_Alloc *alloc = &context->allocator;
|
||||||
|
// TODO: handle OOMs
|
||||||
nn_screen *screen = nn_alloc(alloc, sizeof(nn_screen));
|
nn_screen *screen = nn_alloc(alloc, sizeof(nn_screen));
|
||||||
screen->ctx = *context;
|
screen->ctx = *context;
|
||||||
screen->buffer = nn_alloc(alloc, sizeof(nn_scrchr_t) * maxWidth * maxHeight);
|
screen->buffer = nn_alloc(alloc, sizeof(nn_scrchr_t) * maxWidth * maxHeight);
|
||||||
@ -65,6 +66,20 @@ void nn_setResolution(nn_screen *screen, int width, int height) {
|
|||||||
screen->height = height;
|
screen->height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nn_bool_t nn_unsafeReallocateScreenBuffer(nn_screen *screen, int maxWidth, int maxHeight) {
|
||||||
|
nn_Alloc *alloc = &screen->ctx.allocator;
|
||||||
|
|
||||||
|
nn_scrchr_t *newBuffer = nn_alloc(alloc, sizeof(nn_scrchr_t) * maxWidth * maxHeight);
|
||||||
|
if(newBuffer == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
screen->buffer = newBuffer;
|
||||||
|
screen->maxWidth = maxWidth;
|
||||||
|
screen->maxHeight = maxHeight;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void nn_getViewport(nn_screen *screen, int *width, int *height) {
|
void nn_getViewport(nn_screen *screen, int *width, int *height) {
|
||||||
*width = screen->viewportWidth;
|
*width = screen->viewportWidth;
|
||||||
*height = screen->viewportHeight;
|
*height = screen->viewportHeight;
|
||||||
|
@ -111,7 +111,7 @@ nn_size_t nn_vf_spaceUsedByNode(nn_vfnode *node) {
|
|||||||
if(node->isDirectory) {
|
if(node->isDirectory) {
|
||||||
nn_size_t sum = 0;
|
nn_size_t sum = 0;
|
||||||
for(nn_size_t i = 0; i < node->len; i++) {
|
for(nn_size_t i = 0; i < node->len; i++) {
|
||||||
sum = nn_vf_spaceUsedByNode(node->entries[i]);
|
sum += nn_vf_spaceUsedByNode(node->entries[i]);
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
} else {
|
} else {
|
||||||
|
@ -914,6 +914,9 @@ void nn_unlockScreen(nn_screen *screen);
|
|||||||
void nn_getResolution(nn_screen *screen, int *width, int *height);
|
void nn_getResolution(nn_screen *screen, int *width, int *height);
|
||||||
void nn_maxResolution(nn_screen *screen, int *width, int *height);
|
void nn_maxResolution(nn_screen *screen, int *width, int *height);
|
||||||
void nn_setResolution(nn_screen *screen, int width, int height);
|
void nn_setResolution(nn_screen *screen, int width, int height);
|
||||||
|
// changes the maximum resolution
|
||||||
|
// DOES NOT USE THE LOCK AND THUS MAY CAUSE RACE CONDITIONS AND SEGFAULTS!!!!!
|
||||||
|
nn_bool_t nn_unsafeReallocateScreenBuffer(nn_screen *screen, int maxWidth, int maxHeight);
|
||||||
|
|
||||||
void nn_getViewport(nn_screen *screen, int *width, int *height);
|
void nn_getViewport(nn_screen *screen, int *width, int *height);
|
||||||
void nn_setViewport(nn_screen *screen, int width, int height);
|
void nn_setViewport(nn_screen *screen, int width, int height);
|
||||||
|
@ -228,6 +228,7 @@ local libcomputer = {
|
|||||||
local deadline = computer.uptime() + (type(timeout) == "number" and timeout or math.huge)
|
local deadline = computer.uptime() + (type(timeout) == "number" and timeout or math.huge)
|
||||||
|
|
||||||
repeat
|
repeat
|
||||||
|
print("waiting for signal", computer.uptime())
|
||||||
yield() -- give executor a chance to give us stuff
|
yield() -- give executor a chance to give us stuff
|
||||||
local s = table.pack(computer.popSignal())
|
local s = table.pack(computer.popSignal())
|
||||||
if s.n > 0 then
|
if s.n > 0 then
|
||||||
@ -437,7 +438,6 @@ local lastGC = computer.uptime()
|
|||||||
while true do
|
while true do
|
||||||
timeout = nextDeadline()
|
timeout = nextDeadline()
|
||||||
bubbleYield = false
|
bubbleYield = false
|
||||||
collectgarbage()
|
|
||||||
|
|
||||||
if computer.uptime() - lastGC >= gcInterval then
|
if computer.uptime() - lastGC >= gcInterval then
|
||||||
collectgarbage("collect")
|
collectgarbage("collect")
|
||||||
|
@ -69,7 +69,7 @@ void *testLuaArch_alloc(testLuaArch *arch, void *ptr, size_t osize, size_t nsize
|
|||||||
nn_Alloc *alloc = nn_getAllocator(nn_getUniverse(arch->computer));
|
nn_Alloc *alloc = nn_getAllocator(nn_getUniverse(arch->computer));
|
||||||
if(nsize == 0) {
|
if(nsize == 0) {
|
||||||
arch->memoryUsed -= osize;
|
arch->memoryUsed -= osize;
|
||||||
free(ptr);
|
nn_dealloc(alloc, ptr, osize);
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
size_t actualOldSize = osize;
|
size_t actualOldSize = osize;
|
||||||
@ -79,7 +79,7 @@ void *testLuaArch_alloc(testLuaArch *arch, void *ptr, size_t osize, size_t nsize
|
|||||||
}
|
}
|
||||||
arch->memoryUsed -= actualOldSize;
|
arch->memoryUsed -= actualOldSize;
|
||||||
arch->memoryUsed += nsize;
|
arch->memoryUsed += nsize;
|
||||||
return realloc(ptr, nsize);
|
return nn_resize(alloc, ptr, actualOldSize, nsize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user