Skip to content

Commit

Permalink
Merge branch 'OptimizeLine'
Browse files Browse the repository at this point in the history
  • Loading branch information
jtothebell committed Sep 5, 2021
2 parents 5f8b0c1 + f55b6c4 commit dc8bacd
Show file tree
Hide file tree
Showing 6 changed files with 459 additions and 156 deletions.
7 changes: 6 additions & 1 deletion platform/SDL1_2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ INCLUDES := ${INCLUDES}
#---------------------------------------------------------------------------------
CC = $(CXX)

CFLAGS := -g -Wall -ffunction-sections -DVER_STR=\"$(APP_VERSION)\" \
CFLAGS := -g -Wall -Ofast -ffunction-sections -DVER_STR=\"$(APP_VERSION)\" \
$(DEFINES)

CFLAGS += $(INCLUDE)

CXXFLAGS := $(CFLAGS) -fno-rtti -std=gnu++17

#to profile, link to gperftools profiler
#LIBS := -Wl,--no-as-needed -lprofiler -Wl,--as-needed -lSDL
#alternatively, use operf
#sudo operf ./platform/SDL1_2/FAKE08 ~/p8carts/png-x-zero.p8.png
#opreport --demangle=smart --symbols > fake08-x-zero-master-preoptim2.txt
LIBS := -lSDL

LDFLAGS := $(LIBS)
Expand Down
51 changes: 45 additions & 6 deletions platform/bittboy/source/BittBoyHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ int _maxNoStretchHeight = 128;

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


StretchOption stretch;
Expand Down Expand Up @@ -493,12 +494,50 @@ 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;
for (int x = 0; x < pixelBlocksPerLine; x ++){
int32_t eightPix = ((int32_t*)picoFb)[y * pixelBlocksPerLine + x];

int h = (eightPix >> 28) & 0x0f;
int g = (eightPix >> 24) & 0x0f;
int f = (eightPix >> 20) & 0x0f;
int e = (eightPix >> 16) & 0x0f;
int d = (eightPix >> 12) & 0x0f;
int c = (eightPix >> 8) & 0x0f;
int b = (eightPix >> 4) & 0x0f;
int a = (eightPix) & 0x0f;

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;
base[3] = cold;
base[4] = cole;
base[5] = colf;
base[6] = colg;
base[7] = colh;


//----OR something like this for further optimization?
//not exactly this. its broken
/*
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;
*/


}
}
}
Expand Down
Loading

0 comments on commit dc8bacd

Please sign in to comment.