Skip to content

Commit

Permalink
WIP- untested attempt to wire up RA options to screen buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
jtothebell committed Sep 2, 2024
1 parent 8399fe8 commit 7265281
Showing 1 changed file with 33 additions and 27 deletions.
60 changes: 33 additions & 27 deletions platform/libretro/libretro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ int16_t audioBuffer[audioBufferSize];
const int PicoScreenWidth = 128;
const int PicoScreenHeight = 128;

const int BytesPerPixel = 2;

static int scale = 1;
static int crop_h_left = 0;
static int crop_h_right = 0;
Expand Down Expand Up @@ -72,7 +70,6 @@ static void frame_time_cb(retro_usec_t usec)
static void check_variables(bool startup)
{
struct retro_variable var = {0};
char key[256];
int video_updated = 0;

var.key = "fake08_video_scale";
Expand Down Expand Up @@ -468,37 +465,46 @@ EXPORT void retro_run()
flip = 0;
break;
}
//TODO: handle rotation/flip/mirroring

#ifdef TWO_X_SCALE

for(int scry = 0; scry < PicoScreenHeight; scry++) {
for (int scrx = 0; scrx < PicoScreenWidth; scrx++) {
int picox = scrx / drawModeScaleX;
int picoy = scry / drawModeScaleY;
uint16_t color = _rgb565Colors[screenPaletteMap[getPixelNibble(picox, picoy, picoFb)]];

for (int y = 0; y < SCALE; y++) {
for (int x = 0; x < SCALE; x++) {
screenBuffer[(scry*SCALE+y)*PicoScreenWidthScaled+scrx*SCALE+x] = color;
//unsigned incr = 0;
unsigned width = PicoScreenWidth;
unsigned height = PicoScreenHeight;
unsigned pitch = width * sizeof(uint16_t);

//incr += (crop_h_left + crop_h_right);
width -= (crop_h_left + crop_h_right);
height -= (crop_v_top + crop_v_bottom);
pitch -= (crop_h_left + crop_h_right) * sizeof(uint16_t);

if (scale > 1) {
for(unsigned scry = 0; scry < height; scry++) {
for (unsigned scrx = 0; scrx < width; scrx++) {
int picox = scrx / drawModeScaleX;
int picoy = scry / drawModeScaleY;
uint16_t color = _rgb565Colors[screenPaletteMap[getPixelNibble(picox, picoy, picoFb)]];

for (int y = 0; y < scale; y++) {
for (int x = 0; x < scale; x++) {
screenBuffer2x[(scry*scale+y)*PicoScreenWidth*scale+scrx*scale+x] = color;
}
}
}
}
}


#else
//TODO: handle rotation/flip/mirroring
for(int scry = 0; scry < PicoScreenHeight; scry++) {
for (int scrx = 0; scrx < PicoScreenWidth; scrx++) {
int picox = scrx / drawModeScaleX;
int picoy = scry / drawModeScaleY;
screenBuffer[scry*128+scrx] = _rgb565Colors[screenPaletteMap[getPixelNibble(picox, picoy, picoFb)]];
}
video_cb(&screenBuffer2x, width * scale, height * scale, pitch * scale);
}
else {
for(unsigned scry = 0; scry < height; scry++) {
for (unsigned scrx = 0; scrx < width; scrx++) {
int picox = scrx / drawModeScaleX;
int picoy = scry / drawModeScaleY;
screenBuffer[scry*width+scrx] = _rgb565Colors[screenPaletteMap[getPixelNibble(picox, picoy, picoFb)]];
}
}

video_cb(&screenBuffer, PicoScreenWidth, PicoScreenHeight, PicoScreenWidth * BytesPerPixel);

#endif
video_cb(&screenBuffer, width, height, pitch);
}

frame++;
}
Expand Down

0 comments on commit 7265281

Please sign in to comment.