From 5c1418c27eac455e38028b7d8bf327d87b00e774 Mon Sep 17 00:00:00 2001 From: Zack Buhman Date: Fri, 28 Apr 2023 05:23:33 -0700 Subject: [PATCH] raytracing: switch pixel format from 24 bpp to 15 bpp The Sega Saturn does not have enough video RAM to store an entire 24-bit framebuffer. Attempting this causes the "bottom" half of the scene to be clipped, as video RAM addresses that do not exist are written to. --- raytracing/main-saturn.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/raytracing/main-saturn.cpp b/raytracing/main-saturn.cpp index b7b4e0f..6698f5e 100644 --- a/raytracing/main-saturn.cpp +++ b/raytracing/main-saturn.cpp @@ -43,7 +43,7 @@ void put_pixel(int32_t x, int32_t y, const vec3& color) if (sx >= 320 || sx < 0 || sy >= 240 || sy < 0) return; - vdp2.vram.u32[512 * sy + sx] = rgb24(color); + vdp2.vram.u16[512 * sy + sx] = rgb15(color); } template @@ -101,8 +101,8 @@ void main_asdf() vdp2.reg.BGON = BGON__N0ON; vdp2.reg.CHCTLA = ( - // CHCTLA__N0CHCN__32K_COLOR // 15 bits per pixel, RGB - CHCTLA__N0CHCN__16M_COLOR // 24 bits per pixel + CHCTLA__N0CHCN__32K_COLOR // 15 bits per pixel, RGB + // CHCTLA__N0CHCN__16M_COLOR // 24 bits per pixel | CHCTLA__N0BMSZ__512x256_DOT | CHCTLA__N0BMEN__BITMAP_FORMAT );