]> git.0x19.co - doomgeneric-snom360/commitdiff
Fixes to 256-color mode
authorTuro Lamminen <turol@iki.fi>
Tue, 23 Apr 2024 17:23:03 +0000 (20:23 +0300)
committerTuro Lamminen <turol@iki.fi>
Tue, 23 Apr 2024 17:23:03 +0000 (20:23 +0300)
doomgeneric/doomgeneric.c
doomgeneric/doomgeneric.h
doomgeneric/i_video.c
doomgeneric/i_video.h

index 782a7e716cebca14f3c65a4a43737045a4763192..881d700776dfc9fdc2e69943ed45767e72c7660b 100644 (file)
@@ -4,7 +4,7 @@
 
 #include "doomgeneric.h"
 
-uint32_t* DG_ScreenBuffer = 0;
+pixel_t* DG_ScreenBuffer = NULL;
 
 void M_FindResponseFile(void);
 void D_DoomMain (void);
index 9ba1457074e72ff4ba41eb0cc069cd8fe9e7bc85..0fbbd2b76834a5093138cedb2ee0332132e424ee 100644 (file)
 #endif  // DOOMGENERIC_RESY
 
 
-extern uint32_t* DG_ScreenBuffer;
+#ifdef CMAP256
+
+typedef uint8_t pixel_t;
+
+#else  // CMAP256
+
+typedef uint32_t pixel_t;
+
+#endif  // CMAP256
+
+
+extern pixel_t* DG_ScreenBuffer;
 
 void doomgeneric_Create(int argc, char **argv);
 void doomgeneric_Tick();
index 34b661505a7905d01a5fc96f574edc829269df58..8a9aac60a0e644560a05edee1de7b1d92630a494 100644 (file)
@@ -75,15 +75,20 @@ static struct FB_ScreenInfo s_Fb;
 int fb_scaling = 1;
 int usemouse = 0;
 
-struct color {
-    uint32_t b:8;
-    uint32_t g:8;
-    uint32_t r:8;
-    uint32_t a:8;
-};
+
+#ifdef CMAP256
+
+boolean palette_changed;
+struct color colors[256];
+
+#else  // CMAP256
 
 static struct color colors[256];
 
+
+#endif  // CMAP256
+
+
 void I_GetEvent(void);
 
 // The screen buffer; this is modified to draw things to the screen
@@ -183,6 +188,13 @@ void I_InitGraphics (void)
        s_Fb.yres = DOOMGENERIC_RESY;
        s_Fb.xres_virtual = s_Fb.xres;
        s_Fb.yres_virtual = s_Fb.yres;
+
+#ifdef CMAP256
+
+       s_Fb.bits_per_pixel = 8;
+
+#else  // CMAP256
+
        s_Fb.bits_per_pixel = 32;
 
        s_Fb.blue.length = 8;
@@ -195,6 +207,7 @@ void I_InitGraphics (void)
        s_Fb.red.offset = 16;
        s_Fb.transp.offset = 24;
        
+#endif  // CMAP256
 
     printf("I_InitGraphics: framebuffer: x_res: %d, y_res: %d, x_virtual: %d, y_virtual: %d, bpp: %d\n",
             s_Fb.xres, s_Fb.yres, s_Fb.xres_virtual, s_Fb.yres_virtual, s_Fb.bits_per_pixel);
@@ -277,10 +290,17 @@ void I_FinishUpdate (void)
         for (i = 0; i < fb_scaling; i++) {
             line_out += x_offset;
 #ifdef CMAP256
-            for (fb_scaling == 1) {
+            if (fb_scaling == 1) {
                 memcpy(line_out, line_in, SCREENWIDTH); /* fb_width is bigger than Doom SCREENWIDTH... */
             } else {
-                //XXX FIXME fb_scaling support!
+                int j;
+
+                for (j = 0; j < SCREENWIDTH; j++) {
+                    int k;
+                    for (k = 0; k < fb_scaling; k++) {
+                        line_out[j * fb_scaling + k] = line_in[j];
+                    }
+                }
             }
 #else
             //cmap_to_rgb565((void*)line_out, (void*)line_in, SCREENWIDTH);
@@ -336,6 +356,12 @@ void I_SetPalette (byte* palette)
         colors[i].g = gammatable[usegamma][*palette++];
         colors[i].b = gammatable[usegamma][*palette++];
     }
+
+#ifdef CMAP256
+
+    palette_changed = true;
+
+#endif  // CMAP256
 }
 
 // Given an RGB value, find the closest matching palette index.
index 85d1fea419f43f50016b64bafd9fb046e4cfd789..c8565f419d3066b13d53f829d0e2dfeb32cf35f6 100644 (file)
@@ -138,6 +138,14 @@ void I_EnableLoadingDisk(void);
 
 void I_EndRead (void);
 
+struct color {
+    uint32_t b:8;
+    uint32_t g:8;
+    uint32_t r:8;
+    uint32_t a:8;
+};
+
+
 extern char *video_driver;
 extern boolean screenvisible;
 
@@ -157,4 +165,11 @@ extern int aspect_ratio_correct;
 extern int show_diskicon;
 extern int diskicon_readbytes;
 
+#ifdef CMAP256
+
+extern boolean palette_changed;
+extern struct color colors[256];
+
+#endif  // CMAP256
+
 #endif