Retro Render Path
Purpose
Section titled “Purpose”The retro path owns the bonus output image and the minimap image used during
bonus rendering. In the current code, world-space content is redirected into
app->bonus.retro.out, which is window-sized, then the HUD is drawn last so it
stays readable.
Retro render path
Bonus world output with sharp final HUD overlay
The bonus retro path redirects world drawing into the window-sized bonus output image, keeps a dedicated minimap buffer, then draws the HUD after the world pass so UI remains readable.
app->bonus.retro Retro mode owns three MLX images and lightweight control state.
fb win_w x win_h allocated retro framebuffer / helper source out win_w x win_h active bonus world output image minimap radius/tile derived dedicated minimap image buffer retro_begin(app, &saved_frame) World code stays unchanged because only the active frame target changes.
saved_frame = app->frame;
app->frame = app->bonus.retro.out;
// background, DDA walls, sprites, minimap
// now write into the bonus output image retro_upscale_to_out(app) Nearest-neighbor mapping exists as a helper; the normal frame path currently renders directly into out.
src_x = x * fb.width / out.width;
src_y = y * fb.height / out.height;
color = retro_get_pixel(fb, src_x, src_y);
put_pixel(out, x, y, color); resolution visualizer Compare the optional helper framebuffer with the window-sized output and final HUD overlay.
HUD is drawn after the world pass.
safety and degradation Retro mode is optional: failed allocations disable it instead of crashing runtime.
advantages strong retro visual identity, lower world render cost, sharp HUD separation
tradeoffs intentional pixelation, reduced world detail, extra image buffers
Data Model
Section titled “Data Model”Retro state is stored in app->bonus.retro and contains:
fb, an allocated framebuffer kept by the retro contextout, the active window-sized bonus output imageminimap, the dedicated minimap image bufferenabled, the runtime flag that activates or disables the pathminimap_zoom, the runtime zoom value used by minimap rendering
Initialization
Section titled “Initialization”retro_init(app) resets retro images, allocates fb, allocates out,
allocates the minimap image, and enables the path only when every required
buffer is valid. Both fb and out are currently allocated with the active
window dimensions.
If allocation fails, retro mode is disabled and the application continues on the normal frame path. This keeps the feature optional and safe under partial resource failure.
Frame Integration
Section titled “Frame Integration”retro_begin(app, &saved_frame) saves the current window-sized frame descriptor
and replaces app->frame with app->bonus.retro.out. The existing world
pipeline then writes into the bonus output image without needing separate
raycasting logic.
retro_render(app, &saved_frame) restores the original frame descriptor. The
frame end then presents app->bonus.retro.out through mlx_put_image_to_window
when retro mode is active.
HUD drawing happens after retro world handling so UI stays readable and is not mixed into the world pass.
Upscale Helper
Section titled “Upscale Helper”retro_upscale_to_out(app) still exists in srcs_bonus/retro/display.c as a
nearest-neighbor helper:
src_x = x * fb.width / out.widthsrc_y = y * fb.height / out.height- read the source color from
fb - write it into
out
The normal draw_frame() path does not currently call this helper, because the
active bonus output already uses the window dimensions.
Safety and Cleanup
Section titled “Safety and Cleanup”Retro rendering is guarded by readiness checks: image pointers, addresses,
dimensions, and the enabled flag must be valid. On shutdown,
retro_shutdown(app) destroys fb, out, and the minimap image, resets image
state, and disables the path.
Code References
Section titled “Code References”srcs_bonus/retro/api.csrcs_bonus/retro/image.csrcs_bonus/retro/display.csrcs_bonus/retro/minimap.csrcs_bonus/retro/minimap_pixels.csrcs/render/render_frame.cinclude/defines_bonus.h