foxygit / fake-08-xbox360 Log in
commit f55b6c4817420fdab84e17cd1f0b2ef4456d50dd
Author:     jtothebell <j.to.the.bell@gmail.com>
AuthorDate: Fri Sep 3 19:23:24 2021 -0600
Commit:     jtothebell <j.to.the.bell@gmail.com>
CommitDate: Fri Sep 3 19:23:24 2021 -0600

    WIP attempint to optimize screen buf to texture
---
 platform/bittboy/source/BittBoyHost.cpp | 54 +++++++++++----------------------
 1 file changed, 18 insertions(+), 36 deletions(-)

diff --git a/platform/bittboy/source/BittBoyHost.cpp b/platform/bittboy/source/BittBoyHost.cpp
index 63a3fee..5b448fe 100644
--- a/platform/bittboy/source/BittBoyHost.cpp
+++ b/platform/bittboy/source/BittBoyHost.cpp
@@ -40,6 +40,7 @@ int _maxNoStretchHeight = 128;

 const int PicoScreenWidth = 128;
 const int PicoScreenHeight = 128;
+const int pixelBlocksPerLine = PicoScreenWidth / 8;


 StretchOption stretch;
@@ -491,18 +492,6 @@ void Host::drawFrame(uint8_t* picoFb, uint8_t* screenPaletteMap, uint8_t drawMod
         }
     }
     else { //default
-        /*
-        for (int y = 0; y < PicoScreenHeight; y ++){
-            for (int x = 0; x < PicoScreenWidth; x ++){
-                uint8_t c = getPixelNibble(x, y, picoFb);
-                uint16_t col = _mapped16BitColors[screenPaletteMap[c]];
-
-                base = ((uint16_t *)pixels) + ( y * PicoScreenHeight + x);
-                base[0] = col;
-            }
-        }
-        */
-       const int pixelBlocksPerLine = PicoScreenWidth / 8;
         for (int y = 0; y < PicoScreenHeight; y ++){
             for (int x = 0; x < pixelBlocksPerLine; x ++){
                 int32_t eightPix = ((int32_t*)picoFb)[y * pixelBlocksPerLine + x];
@@ -516,28 +505,17 @@ void Host::drawFrame(uint8_t* picoFb, uint8_t* screenPaletteMap, uint8_t drawMod
                 int b = (eightPix >>  4) & 0x0f;
                 int a = (eightPix)       & 0x0f;

-                /*
-                //old way to check
-                uint8_t ca = getPixelNibble(x    , y, picoFb);
-                uint8_t cb = getPixelNibble(x + 1, y, picoFb);
-                uint8_t cc = getPixelNibble(x + 2, y, picoFb);
-                uint8_t cd = getPixelNibble(x + 3, y, picoFb);
-                uint8_t ce = getPixelNibble(x + 4, y, picoFb);
-                uint8_t cf = getPixelNibble(x + 5, y, picoFb);
-                uint8_t cg = getPixelNibble(x + 6, y, picoFb);
-                uint8_t ch = getPixelNibble(x + 7, y, picoFb);
-                */
-
-                uint16_t cola = _mapped16BitColors[screenPaletteMap[a]];
-                uint16_t colb = _mapped16BitColors[screenPaletteMap[b]];
-                uint16_t colc = _mapped16BitColors[screenPaletteMap[c]];
-                uint16_t cold = _mapped16BitColors[screenPaletteMap[d]];
-                uint16_t cole = _mapped16BitColors[screenPaletteMap[e]];
-                uint16_t colf = _mapped16BitColors[screenPaletteMap[f]];
-                uint16_t colg = _mapped16BitColors[screenPaletteMap[g]];
-                uint16_t colh = _mapped16BitColors[screenPaletteMap[h]];
-
-                base = ((uint16_t *)pixels) + ( y * PicoScreenHeight + x * 8);
+                int32_t cola = _mapped16BitColors[screenPaletteMap[a]];
+                int32_t colb = _mapped16BitColors[screenPaletteMap[b]];
+                int32_t colc = _mapped16BitColors[screenPaletteMap[c]];
+                int32_t cold = _mapped16BitColors[screenPaletteMap[d]];
+                int32_t cole = _mapped16BitColors[screenPaletteMap[e]];
+                int32_t colf = _mapped16BitColors[screenPaletteMap[f]];
+                int32_t colg = _mapped16BitColors[screenPaletteMap[g]];
+                int32_t colh = _mapped16BitColors[screenPaletteMap[h]];
+
+
+                base = ((uint16_t *)pixels + (y * PicoScreenHeight + x * 8));
                 base[0] = cola;
                 base[1] = colb;
                 base[2] = colc;
@@ -546,15 +524,19 @@ void Host::drawFrame(uint8_t* picoFb, uint8_t* screenPaletteMap, uint8_t drawMod
                 base[5] = colf;
                 base[6] = colg;
                 base[7] = colh;
+

-                //----OR----
+                //----OR something like this for further optimization?
+                //not exactly this. its broken
                 /*
-                int32_t* base32 = ((int32_t *)pixels) + ( y * PicoScreenHeight + x * 4);
+                int32_t* base32 = ((int32_t *)pixels + (y * PicoScreenHeight + x * 8));
                 base32[0] = cola << 16 & colb;
                 base32[1] = colc << 16 & cold;
                 base32[2] = cole << 16 & colf;
                 base32[3] = colg << 16 & colh;
                 */
+
+
             }
         }
     }