From 38764943e5fc61c424c018068dc7f6790dddf147 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Thu, 29 Feb 2024 02:29:14 +0100 Subject: Format repass. --- src/render.c | 53 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 23 deletions(-) (limited to 'src/render.c') diff --git a/src/render.c b/src/render.c index a4ed262..66db0c4 100644 --- a/src/render.c +++ b/src/render.c @@ -9,28 +9,31 @@ #define BLOCK_FLAG 0x40 #define IP_FLAG 0x80 -static void apply_flag(uint32 origin, uint32 max_pos, uint32 cell_size, - uint32 address, uint32 flag, uint8_p buffer) -{ +static void apply_flag( + uint32 origin, uint32 max_pos, uint32 cell_size, uint32 address, + uint32 flag, uint8_p buffer +) { if (address >= origin && address < max_pos) { - /* Flag falls inside rendered image. We can 'and' the bit to the - corresponding pixel. + /* + * Flag falls inside rendered image. We can 'and' the bit to the + * corresponding pixel. */ uint32 pixel = (address - origin) / cell_size; buffer[pixel] |= flag; } } -void sal_ren_get_image(uint32 origin, uint32 cell_size, uint32 buff_size, - uint8_p buffer) -{ - /* Render a 1D image of a given section of memory, at a given resolution - (zoom) and store it in a pre-allocated 'buffer'. - - On the Salis python handler we draw memory as a 1D 'image' on the WORLD - page. If we were to render this image directly on python, it would be - excruciatingly slow, as we have to iterate over large areas of memory! - Therefore, this memory module comes with a built-in, super fast renderer. +void sal_ren_get_image( + uint32 origin, uint32 cell_size, uint32 buff_size, uint8_p buffer +) { + /* + * Render a 1D image of a given section of memory, at a given resolution + * (zoom) and store it in a pre-allocated 'buffer'. + * + * On the Salis python handler we draw memory as a 1D 'image' on the WORLD + * page. If we were to render this image directly on python, it would be + * excruciatingly slow, as we have to iterate over large areas of memory! + * Therefore, this memory module comes with a built-in, super fast renderer. */ uint32 i; uint32 max_pos; @@ -40,8 +43,9 @@ void sal_ren_get_image(uint32 origin, uint32 cell_size, uint32 buff_size, assert(buff_size); assert(buffer); - /* We make use of openmp for multi-threaded looping. This allows even - faster render times, wherever openmp is supported. + /* + * We make use of openmp for multi-threaded looping. This allows even faster + * render times, wherever openmp is supported. */ #pragma omp parallel for for (i = 0; i < buff_size; i++) { @@ -68,8 +72,9 @@ void sal_ren_get_image(uint32 origin, uint32 cell_size, uint32 buff_size, buffer[i] |= (uint8)(alloc_flag); } - /* We also iterate through all processes and append extra bit flags to the - rendered image signaling process IP position and memory block limits. + /* + * We also iterate through all processes and append extra bit flags to the + * rendered image signaling process IP position and memory block limits. */ max_pos = origin + (cell_size * buff_size); @@ -78,12 +83,14 @@ void sal_ren_get_image(uint32 origin, uint32 cell_size, uint32 buff_size, if (!sal_proc_is_free(i)) { Process proc = sal_proc_get_proc(i); apply_flag(origin, max_pos, cell_size, proc.ip, IP_FLAG, buffer); - apply_flag(origin, max_pos, cell_size, proc.mb1a, BLOCK_FLAG, - buffer); + apply_flag( + origin, max_pos, cell_size, proc.mb1a, BLOCK_FLAG, buffer + ); if (proc.mb2s) { - apply_flag(origin, max_pos, cell_size, proc.mb2a, BLOCK_FLAG, - buffer); + apply_flag( + origin, max_pos, cell_size, proc.mb2a, BLOCK_FLAG, buffer + ); } } } -- cgit v1.2.1