From 28ef8faaa1faa7cb727e8496c3a7bf2996559e10 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 24 Aug 2025 07:08:07 +1000 Subject: [PATCH] Atari ST: Launcher graphics render --- src/atari_st/Window_Atari.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/atari_st/Window_Atari.c b/src/atari_st/Window_Atari.c index 7209e8bcb..70f10c919 100644 --- a/src/atari_st/Window_Atari.c +++ b/src/atari_st/Window_Atari.c @@ -109,17 +109,16 @@ void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) { bmp->height = height; } +// Each group of 16 pixels is interleaved across 4 bitplanes +struct GRWORD { UWORD plane1, plane2, plane3, plane4; }; + // TODO should be done in assembly.. search up 'chunky to planar atari ST' void Window_DrawFramebuffer(Rect2D r, struct Bitmap* bmp) { // TODO UWORD* ptr = Physbase(); Mem_Set(ptr, 0, 32000); int idx = 0; - - UWORD* plane1 = ptr + 0; - UWORD* plane2 = ptr + 4000; - UWORD* plane3 = ptr + 8000; - UWORD* plane4 = ptr + 12000; + struct GRWORD* planes = (struct GRWORD*)ptr; for (int y = 0; y < r.height; y++) { @@ -136,10 +135,12 @@ void Window_DrawFramebuffer(Rect2D r, struct Bitmap* bmp) { //int pal = R | (G << 1) | (B << 2); int b1 = B & 0x01, b2 = (B >> 1); - plane1[idx >> 4] |= R << (idx & 0x0F); - plane2[idx >> 4] |= G << (idx & 0x0F); - plane3[idx >> 4] |= b1<< (idx & 0x0F); - plane4[idx >> 4] |= b2<< (idx & 0x0F); + int word = idx >> 4, bit = 15 - (idx & 0x0F); + + planes[word].plane1 |= R << bit; + planes[word].plane2 |= G << bit; + planes[word].plane3 |= b1<< bit; + planes[word].plane4 |= b2<< bit; } } }