You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
console: fix writing out of bounds and writing unused memory (#229)
* consolidate console documentation and offset usage
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
* remove somehow broken character
* forgot a word
* remove false doc (mindless copy-paste), extra punctuation
* reword comment for readability
* remove spurious commas
* remove more spurious commas
* ensure con_xres,con_yres multiples of font size
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
* make new functions inline, making them faster in the callback
---------
Co-authored-by: Dave Murphy <[email protected]>
Co-authored-by: DacoTaco <[email protected]>
* \brief retrieve the columns and rows of the current console
82
82
*
83
-
* \param[out] cols,rows number of columns and rows of the current console
83
+
* \param[out] cols,rows number of columns and rows of the current console in tiles
84
84
*
85
85
* \return none
86
86
*/
@@ -90,7 +90,7 @@ void CON_GetMetrics(int *cols, int *rows);
90
90
* \fn CON_GetPosition(int *col, int *row)
91
91
* \brief retrieve the current cursor position of the current console
92
92
*
93
-
* \param[out] col,row current cursor position
93
+
* \param[out] col,row current cursor position in tiles, 1-indexed
94
94
*
95
95
* \return none
96
96
*/
@@ -100,7 +100,7 @@ void CON_GetPosition(int *cols, int *rows);
100
100
* \fn CON_EnableGecko(int channel, int safe)
101
101
* \brief Enable or disable the USB gecko console.
102
102
*
103
-
* \param[in] channel EXI channel, or -1 ¨to disable the gecko console
103
+
* \param[in] channel EXI channel, or -1 to disable the gecko console
104
104
* \param[in] safe If true, use safe mode (wait for peer)
105
105
*
106
106
* \return none
@@ -152,22 +152,24 @@ typedef struct PrintConsole
152
152
ConsoleFontfont; ///< Font of the console
153
153
154
154
void*destbuffer; ///< Framebuffer address
155
-
intcon_xres,con_yres,con_stride;
156
-
inttarget_x,target_y, tgt_stride;
155
+
intcon_xres, con_yres; ///< Console buffer width/height in pixels
156
+
intcon_stride; ///< Size of one row in the console buffer in bytes
157
+
inttarget_x, target_y; ///< Target buffer x/y offset to start the console in pixels
158
+
inttgt_stride; ///< Size of one row in the target buffer in bytes
157
159
158
-
intcursorX; ///< Current X location of the cursor (as a tile offset by default)
159
-
intcursorY; ///< Current Y location of the cursor (as a tile offset by default)
160
+
intcursorX; ///< Current X location of the cursor in the window in tiles, 1-indexed: 1 <= cursorX <= windowWidth, cursorX > windowWidth wraps to the next line and resets to cursorX = 1
161
+
intcursorY; ///< Current Y location of the cursor in the window in tiles, 1-indexed
160
162
161
163
intprevCursorX; ///< Internal state
162
164
intprevCursorY; ///< Internal state
163
165
164
-
intcon_cols; ///< Width of the console hardware layer in characters
165
-
intcon_rows; ///< Height of the console hardware layer in characters
166
+
intcon_cols; ///< Width of the console hardware layer in characters (aka tiles)
167
+
intcon_rows; ///< Height of the console hardware layer in characters (aka tiles)
166
168
167
-
intwindowX; ///< Window X location in characters (not implemented)
168
-
intwindowY; ///< Window Y location in characters (not implemented)
169
-
intwindowWidth; ///< Window width in characters (not implemented)
170
-
intwindowHeight; ///< Window height in characters (not implemented)
169
+
intwindowX; ///< Window X location in tiles, 1-indexed, 1 <= windowX < con_cols
170
+
intwindowY; ///< Window Y location in tiles, 1-indexed
0 commit comments