console: fix writing out of bounds and writing unused memory#229
Conversation
introduces helper functions to avoid the repetition and mistakes logic was verified equivalent or better by hand but not runtime-tested fixes various issues having to do with out of bounds writes misc changes to extraneous whitespace noticed during the refactor
|
Oh hell yeah this fixes the problems I've been having with my app! Thank you!! |
|
For the record: - while( cur_row++ < (con->windowY + con->windowHeight) )
+ while( cur_row++ < con->windowHeight )in - while( cur_row-- )
+ while( --cur_row )in TODO: during testing and comparison, @DacoTaco noticed a graphical issue in certain cases, with passing
This was already the case before this PR, but isn't addressed yet, no decision reached on how to handle it (truncating the intended console dimensions in the init to at least have parity between both, maybe forcing the extra pixels to a certain color, or resetting them when fully clearing the console, or other ideas) |
avoids an unwritten right/bottom edge that's not part of a complete tile this caused graphical issues and inconsistencies between Init and InitEx document in the function doxygen comment make values in __console_vipostcb only computed once ptr directly from the global equal to destbuffer, less indirection
|
Update: decision reached, implemented and documented in the latest commit, is to force con_xres/con_yres to be multiples of font size inside CON_Init/Ex Note: the change done for a bit of extra "speed" in the fairly hot (display) loop of __console_vipostcb made me notice this entire part is kind of flimsy when working with multiple PrintConsole instances at once, but that's a new thing so most probably not really used by anyone yet? |
The intent of multiple PrintConsole instances is separate windows to the same underlying framebuffer. See for instance https://github.com/devkitPro/3ds-examples/blob/master/graphics/printing/multiple-windows-text/source/main.c . Each window could also have different fonts. The intent of CON_InitEx is to overwrite part of the framebuffer for the current frame with a small console that could, for example, be used for debug output. I'm not sure if it makes sense for the PrintConsole API to be mixed with that but we can mull that over later. Thanks for all your work on this @LiquidFenrir. These changes lgtm |
Adds precision to the expected values of various arguments/results of the console API
New internal helper functions for commonly repeated (tedious and prone to mistakes) pattern
More comments for non-intuitive/non-obvious implementation decisions that had to be done due to the mixing of "units"
NOT TESTED ON HARDWARE (or in any use), but logically sound (more than the previous mixed results, at least)