]> Shamusworld >> Repos - apple2/blobdiff - src/applevideo.cpp
Initial stab at fixing the GUI classes so that they work properly.
[apple2] / src / applevideo.cpp
index 25420524fb0f202cef42b1b526c9927132e59abb..86eeeda3899919cc47c2fb9e947036f340ad1c2b 100755 (executable)
@@ -72,7 +72,7 @@ bool alternateCharset;
 // Local variables
 
 // We set up the colors this way so that they'll be endian safe
-// when we cast them to a uint32.
+// when we cast them to a uint32. Note that the format is RGBA.
 
 // "Master Color Values" palette
 
@@ -225,7 +225,8 @@ uint16 appleHiresToMono[0x200] = {
        0x207F, 0x387F, 0x267F, 0x3E7F, 0x21FF, 0x39FF, 0x27FF, 0x3FFF  // $Fx
 };
 
-static uint8 blurTable[0x800][8];                              // Color TV blur table
+//static uint8 blurTable[0x800][8];                            // Color TV blur table
+static uint8 blurTable[0x80][8];                               // Color TV blur table
 static uint32 * palette = (uint32 *)altColors;
 enum { ST_FIRST_ENTRY = 0, ST_COLOR_TV = 0, ST_WHITE_MONO, ST_GREEN_MONO, ST_LAST_ENTRY };
 static uint8 screenType = ST_COLOR_TV;
@@ -242,13 +243,21 @@ void SetupBlurTable(void)
 {
        // NOTE: This table only needs to be 7 bits wide instead of 11, since the
        //       last four bits are copies of the previous four...
-
-       for(uint16 bitPat=0; bitPat<0x800; bitPat++)
+       //       Odd. Doing the bit patterns from 0-$7F doesn't work, but going
+       //       from 0-$7FF stepping by 16 does. Hm.
+       //       Well, it seems that going from 0-$7F doesn't have enough precision to do the job.
+#if 0
+//     for(uint16 bitPat=0; bitPat<0x800; bitPat++)
+       for(uint16 bitPat=0; bitPat<0x80; bitPat++)
        {
-               uint16 w3 = bitPat & 0x888;
+/*             uint16 w3 = bitPat & 0x888;
                uint16 w2 = bitPat & 0x444;
                uint16 w1 = bitPat & 0x222;
-               uint16 w0 = bitPat & 0x111;
+               uint16 w0 = bitPat & 0x111;*/
+               uint16 w3 = bitPat & 0x88;
+               uint16 w2 = bitPat & 0x44;
+               uint16 w1 = bitPat & 0x22;
+               uint16 w0 = bitPat & 0x11;
 
                uint16 blurred3 = (w3 | (w3 >> 1) | (w3 >> 2) | (w3 >> 3)) & 0x00FF;
                uint16 blurred2 = (w2 | (w2 >> 1) | (w2 >> 2) | (w2 >> 3)) & 0x00FF;
@@ -264,6 +273,26 @@ void SetupBlurTable(void)
                        blurTable[bitPat][7 - i] = color;
                }
        }
+#else
+       for(uint16 bitPat=0; bitPat<0x800; bitPat+=0x10)
+       {
+               uint16 w0 = bitPat & 0x111, w1 = bitPat & 0x222, w2 = bitPat & 0x444, w3 = bitPat & 0x888;
+
+               uint16 blurred0 = (w0 | (w0 >> 1) | (w0 >> 2) | (w0 >> 3)) & 0x00FF;
+               uint16 blurred1 = (w1 | (w1 >> 1) | (w1 >> 2) | (w1 >> 3)) & 0x00FF;
+               uint16 blurred2 = (w2 | (w2 >> 1) | (w2 >> 2) | (w2 >> 3)) & 0x00FF;
+               uint16 blurred3 = (w3 | (w3 >> 1) | (w3 >> 2) | (w3 >> 3)) & 0x00FF;
+
+               for(int8 i=7; i>=0; i--)
+               {
+                       uint8 color = (((blurred0 >> i) & 0x01) << 3)
+                               | (((blurred1 >> i) & 0x01) << 2)
+                               | (((blurred2 >> i) & 0x01) << 1)
+                               | ((blurred3 >> i) & 0x01);
+                       blurTable[bitPat >> 4][7 - i] = color;
+               }
+       }
+#endif
 }
 
 void TogglePalette(void)
@@ -413,6 +442,7 @@ static void Render40ColumnTextLine(uint8 line)
                                scrBuffer[(x * 7 * 2) + (line * VIRTUAL_SCREEN_WIDTH * 8 * 2) + (cx * 2) + 0 + (cy * VIRTUAL_SCREEN_WIDTH * 2)] = pixel;
                                scrBuffer[(x * 7 * 2) + (line * VIRTUAL_SCREEN_WIDTH * 8 * 2) + (cx * 2) + 1 + (cy * VIRTUAL_SCREEN_WIDTH * 2)] = pixel;
 
+                               // QnD method to get blank alternate lines in text mode
                                if (screenType == ST_GREEN_MONO)
                                        pixel = 0xFF000000;
 
@@ -434,6 +464,9 @@ static void Render40ColumnText(void)
 static void RenderLoRes(uint16 toLine/*= 24*/)
 {
 // NOTE: The green mono rendering doesn't skip every other line... !!! FIX !!!
+//       Also, we could set up three different Render functions depending on which
+//       render type was set and call it with a function pointer. Would be faster
+//       then the nested ifs we have now.
 /*
 Note that these colors correspond to the bit patterns generated by the numbers 0-F in order:
 Color #s correspond to the bit patterns in reverse... Interesting!
@@ -509,7 +542,7 @@ fb fb fb -> 15 [1111] -> 15         WHITE
                        {
                                for(uint8 i=0; i<7; i++)
                                {
-                                       uint16 bitPat = (pixels & 0x7F000000) >> 20;
+                                       uint8 bitPat = (pixels & 0x7F000000) >> 24;
                                        pixels <<= 4;
 
                                        for(uint8 j=0; j<4; j++)
@@ -564,7 +597,7 @@ fb fb fb -> 15 [1111] -> 15         WHITE
                        {
                                for(uint8 i=0; i<7; i++)
                                {
-                                       uint16 bitPat = (pixels & 0x7F000000) >> 20;
+                                       uint8 bitPat = (pixels & 0x7F000000) >> 24;
                                        pixels <<= 4;
 
                                        for(uint8 j=0; j<4; j++)
@@ -600,7 +633,16 @@ fb fb fb -> 15 [1111] -> 15                WHITE
 
 static void RenderHiRes(uint16 toLine/*= 192*/)
 {
+// NOTE: Not endian safe. !!! FIX !!!
+#if 0
        uint32 pixelOn = (screenType == ST_WHITE_MONO ? 0xFFFFFFFF : 0xFF61FF61);
+#else
+// Now it is. Now roll this fix into all the other places... !!! FIX !!!
+// The colors are set in the 8-bit array as R G B A
+       uint8 monoColors[8] = { 0xFF, 0xFF, 0xFF, 0xFF, 0x61, 0xFF, 0x61, 0xFF };
+       uint32 * colorPtr = (uint32 *)monoColors;
+       uint32 pixelOn = (screenType == ST_WHITE_MONO ? colorPtr[0] : colorPtr[1]);
+#endif
 
        for(uint16 y=0; y<toLine; y++)
        {
@@ -627,7 +669,7 @@ static void RenderHiRes(uint16 toLine/*= 192*/)
                        {
                                for(uint8 i=0; i<7; i++)
                                {
-                                       uint16 bitPat = (pixels & 0x7F000000) >> 20;
+                                       uint8 bitPat = (pixels & 0x7F000000) >> 24;
                                        pixels <<= 4;
 
                                        for(uint8 j=0; j<4; j++)