SGDK icon indicating copy to clipboard operation
SGDK copied to clipboard

Add TTY console support

Open a-dietrich opened this issue 1 year ago • 2 comments

  • Add console functions to inc/ext and src/ext
  • Add stb_printf
  • Add console sample
  • Update doxyfile
  • Update libmd.a and libmd_debug.a

a-dietrich avatar Jul 10 '22 17:07 a-dietrich

Thanks for having a look. stb_sprintf is a more complete alternative to the standard printf. It supports more formats and types (e.g., float, which can be useful for displaying percentage values).

Regarding the code check, it only reports minor warnings. Moreover, it seems that Codacy shows false positives. The code uses some macros to modify values, which is not recognized. The stb library is widely used and I have tried it for quite a while now. It is unlikely that there are any major errors.

a-dietrich avatar Jul 13 '22 20:07 a-dietrich

Actually, there is one more thing I forgot: stb_sprintf.h also provides vsnprintf(), which checks the buffer size. At the moment SGDK only provides vsprintf() which could result in buffer overflows, so we would need a large string buffer to minimize the risk.

I realize that stb_sprintf.h is quite big, but it would only be linked if the console is used. For final game builds (if no console functions are called) the linker would take care that it is not added to the binary.

a-dietrich avatar Jul 24 '22 19:07 a-dietrich