foxygit / fake-08-xbox360 Log in
commit 2b64211670ecc302772298ea9442a6d76c534164
Author:     jtothebell <j.to.the.bell@gmail.com>
AuthorDate: Mon Aug 9 18:11:20 2021 -0600
Commit:     jtothebell <j.to.the.bell@gmail.com>
CommitDate: Mon Aug 9 18:11:20 2021 -0600

    tweak bittboy blit. Maybe slightly faster
---
 platform/bittboy/source/BittBoyHost.cpp | 58 ++++++++++++++++++++++++---------
 1 file changed, 42 insertions(+), 16 deletions(-)

diff --git a/platform/bittboy/source/BittBoyHost.cpp b/platform/bittboy/source/BittBoyHost.cpp
index 5b70d15..eabc85f 100644
--- a/platform/bittboy/source/BittBoyHost.cpp
+++ b/platform/bittboy/source/BittBoyHost.cpp
@@ -263,6 +263,7 @@ void Host::waitForTargetFps(){
 	}
 }

+/*
 void set_pixel(SDL_Surface *surface, int x, int y, uint16_t pixel)
 {
   uint16_t * const target_pixel = (uint16_t *) ((Uint8 *) surface->pixels
@@ -270,43 +271,68 @@ void set_pixel(SDL_Surface *surface, int x, int y, uint16_t pixel)
                                              + x * surface->format->BytesPerPixel);
   *target_pixel = pixel;
 }
+*/

 void Host::drawFrame(uint8_t* picoFb, uint8_t* screenPaletteMap, uint8_t drawMode){
-    /*
-    pixels = texture->pixels;
+
+    //pixels = window->pixels;

+    /*
+    1x scale
     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;
+            uint16_t * const target_pixel = (uint16_t *) ((Uint8 *) window->pixels
+                                             + y * window->pitch
+                                             + x * window->format->BytesPerPixel);
+            *target_pixel = col;
         }
     }
     */
-    for (int y = 0; y < (PicoScreenHeight - 4); y ++){
+
+   //2x scale, last 8 pico pixels (16 screen pixels) cut off
+    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]];

-            set_pixel(window, 32 + (x*2), (y*2), col);
-            set_pixel(window, 32 + (x*2)+1, (y*2), col);
-            set_pixel(window, 32 + (x*2), (y*2)+1, col);
-            set_pixel(window, 32 + (x*2)+1, (y*2)+1, col);
-
-            /*
-            uint16_t * const target_pixel = (uint16_t *) ((Uint8 *) window->pixels
-                                             + y * pitch
-                                             + x * bpp);
-            *target_pixel = col;
-            */
+            uint16_t * const target_pixel0 = (uint16_t *) ((Uint8 *) window->pixels
+                                             + y*2 * window->pitch
+                                             + (x*2 + 32) * window->format->BytesPerPixel);
+            uint16_t * const target_pixel1 = (uint16_t *) ((Uint8 *) window->pixels
+                                             + (y*2 + 1) * window->pitch
+                                             + (x*2 + 32) * window->format->BytesPerPixel);
+            uint16_t * const target_pixel2 = (uint16_t *) ((Uint8 *) window->pixels
+                                             + y*2 * window->pitch
+                                             + (x*2 + 33) * window->format->BytesPerPixel);
+            uint16_t * const target_pixel3 = (uint16_t *) ((Uint8 *) window->pixels
+                                             + (y*2 + 1) * window->pitch
+                                             + (x*2 + 33)* window->format->BytesPerPixel);
+            *target_pixel0 = col;
+            *target_pixel1 = col;
+            *target_pixel2 = col;
+            *target_pixel3 = col;
+
+            //set_pixel(window, 32 + (x*2), (y*2), col);
+            //set_pixel(window, 32 + (x*2)+1, (y*2), col);
+            //set_pixel(window, 32 + (x*2), (y*2)+1, col);
+            //set_pixel(window, 32 + (x*2)+1, (y*2)+1, col);
+
+
+            //uint16_t * const target_pixel = (uint16_t *) ((Uint8 *) window->pixels
+            //                                 + y * pitch
+            //                                 + x * bpp);
+            //target_pixel = col;
+

             //base = ((uint16_t *)pixels) + (y * window->pitch + x);
             //base[0] = col;
         }
     }

+


     postFlipFunction();