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
games/NXDoom: RGB565 support, loadable-module conversion, and crash fixes
Add RGB565 framebuffer support to blit_screen() - it previously assumed
a 32-bit ARGB framebuffer unconditionally, a real limitation for any
board whose framebuffer is FB_FMT_RGB16_565. Branches on pinfo.bpp:
16bpp uses RGBTO16(), 32bpp keeps the existing ARGBTO32() path, and
anything else fails loudly via i_error() rather than reading/writing
past the intended pixel bounds silently. Also centers the scaled
viewport within the framebuffer instead of pinning it to the top-left
corner, and adds CONFIG_GAMES_NXDOOM_PREFDIR to the IWAD search path
(previously only used for the config/save file location). Builds as a
standalone loadable module (MODULE = m) unconditionally so it can be
installed/launched via nxpkg/nxstore.
Fix three real hardware crashes found while bringing this up as a
loadable module:
- A truncated/corrupted config line was silently overriding a
variable's compiled-in default with an empty/unparsable value
instead of being skipped - this let a corrupted "screenblocks" line
through as screenblocks=0, and the renderer's view-size math divides
by a value derived from screenblocks, reaching a divide-by-zero
hardware exception. Also clamps screenblocks to its own valid range
[3, 11] as an independent second layer of defense.
- r_map_plane()'s bounds check was gated behind the debug-only
CONFIG_GAMES_NXDOOM_RANGECHECK and, when tripped, called the fatal
i_error() - both wrong: the check guards a real out-of-bounds array
write (observed with values far past even viewheight), so it cannot
be optional, and killing the whole process over one glitched plane
span is worse than vanilla DOOM's own behavior of rendering the
glitch. Now unconditional, checks against the true array bound
(SCREENHEIGHT), and skips the draw instead of touching memory or
aborting. Also converts visplanes/openings/drawsegs/vissprites from
static arrays to heap allocation (freed via i_at_exit so cleanup also
runs on the i_error() fatal path) to relieve DRAM pressure once a
full application is linked into the same image.
- myargv was under-allocated: sized for argc pointers, but this
codebase's own argument handling assumes argv is NULL-terminated at
argv[argc] (standard C/exec convention). Root-caused via a real crash
dump and symbol resolution against the built ELF; now allocates
argc + 1 pointers and explicitly NULL-terminates.
Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
0 commit comments