Skip to content

Instantly share code, notes, and snippets.

@ToadKing
Created July 18, 2012 22:39
Show Gist options
  • Save ToadKing/3139434 to your computer and use it in GitHub Desktop.
Save ToadKing/3139434 to your computer and use it in GitHub Desktop.
From cb52028cab6d98aaa10e88e13fdcc1fddc0f6737 Mon Sep 17 00:00:00 2001
From: Toad King <toadking@toadking.com>
Date: Wed, 18 Jul 2012 18:38:31 -0400
Subject: [PATCH] video fixes
---
libretro.cpp | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/libretro.cpp b/libretro.cpp
index c5cfbd8..2ec96b1 100644
--- a/libretro.cpp
+++ b/libretro.cpp
@@ -45,6 +45,8 @@ struct Stella
};
Stella* stella;
+static uint16_t frame_buffer[256*160];
+
//Set the palette for the current stella instance
void stellaMDFNSetPalette (const uInt32* palette)
{
@@ -103,7 +105,7 @@ void retro_get_system_av_info(struct retro_system_av_info *info)
info->geometry.base_width = 160;
info->geometry.base_height = 210;
info->geometry.max_width = 160;
- info->geometry.max_height = 210;
+ info->geometry.max_height = 256;
info->geometry.aspect_ratio = 4.0 / 3.0;
}
@@ -261,25 +263,29 @@ void retro_reset(void)
void retro_run(void)
{
- /*
- Int32 frameWidth = stella->GameConsole->tia().width();
- Int32 frameHeight = stella->GameConsole->tia().height();
-
- for(int i = 0; i != frameHeight; i ++)
- {
- for(int j = 0; j != frameWidth; j ++)
- {
- espec->surface->pixels[i * espec->surface->pitchinpix + j] = stella->Palette[stella->GameConsole->tia().currentFrameBuffer()[i * frameWidth + j] & 0xFF];
- }
- }*/
stella->GameConsole->tia().update();
-
- video_cb(stella->GameConsole->tia().currentFrameBuffer(), 160, 210, 320);
+
+ Int32 frameWidth = stella->GameConsole->tia().width();
+ Int32 frameHeight = stella->GameConsole->tia().height();
+
+ for(int i = 0; i != frameHeight; i ++)
+ {
+ for(int j = 0; j != frameWidth; j ++)
+ {
+ Int32 pixel = stella->Palette[stella->GameConsole->tia().currentFrameBuffer()[i * frameWidth + j]];
+ uint16_t color = (pixel & 0x0000F8) >> 3; // B
+ color |= (pixel & 0x00F800) >> 6; // G
+ color |= (pixel & 0xF80000) >> 9; // R
+ frame_buffer[i * frameWidth + j] = color;
+ }
+ }
+
+ video_cb(frame_buffer, frameWidth, frameHeight, frameWidth * 2);
//AUDIO
//Get the number of samples in a frame
- uint32_t soundFrameSize = 34100.0f / stella->GameConsole->getFramerate();
+ uint32_t soundFrameSize = 44100.0f / stella->GameConsole->getFramerate();
//Process one frame of audio from stella
uint8_t samplebuffer[2048];
--
1.7.10.msysgit.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment