mirror of
https://github.com/dingusdev/dingusppc.git
synced 2024-12-23 06:29:38 +00:00
videoctrl: add framebuffer conversion callback.
This commit is contained in:
parent
fff597075d
commit
476d893094
@ -525,6 +525,11 @@ void ATIRage::crtc_enable() {
|
||||
|
||||
this->refresh_rate = pixel_clock / hori_total / vert_total;
|
||||
|
||||
// specify framebuffer converter (hardcoded for now)
|
||||
this->convert_fb_cb = [this](uint8_t *dst_buf, int dst_pitch) {
|
||||
this->convert_frame_8bpp(dst_buf, dst_pitch);
|
||||
};
|
||||
|
||||
LOG_F(INFO, "ATI Rage: primary CRT controller enabled:");
|
||||
LOG_F(INFO, "Video mode: %s",
|
||||
(this->mm_regs[ATI_CRTC_GEN_CNTL+3] & 1) ? "extended" : "VGA");
|
||||
|
@ -28,17 +28,20 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include <chrono>
|
||||
#include <cinttypes>
|
||||
|
||||
VideoCtrlBase::VideoCtrlBase()
|
||||
VideoCtrlBase::VideoCtrlBase(int width, int height)
|
||||
{
|
||||
LOG_F(INFO, "Create display window...");
|
||||
|
||||
this->active_width = width;
|
||||
this->active_height = height;
|
||||
|
||||
// Create display window
|
||||
this->display_wnd = SDL_CreateWindow(
|
||||
"DingusPPC Display",
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
640,
|
||||
480,
|
||||
this->active_width,
|
||||
this->active_height,
|
||||
SDL_WINDOW_OPENGL
|
||||
);
|
||||
|
||||
@ -98,9 +101,8 @@ void VideoCtrlBase::update_screen()
|
||||
|
||||
SDL_LockTexture(this->disp_texture, NULL, (void **)&dst_buf, &dst_pitch);
|
||||
|
||||
// call texture update method (hardcoded for now)
|
||||
// TODO: convert it to a callback
|
||||
this->convert_frame_8bpp(dst_buf, dst_pitch);
|
||||
// texture update callback to get ARGB data from guest framebuffer
|
||||
this->convert_fb_cb(dst_buf, dst_pitch);
|
||||
|
||||
SDL_UnlockTexture(this->disp_texture);
|
||||
SDL_RenderClear(this->renderer);
|
||||
@ -121,6 +123,11 @@ void VideoCtrlBase::update_screen()
|
||||
SDL_Delay(15);
|
||||
}
|
||||
|
||||
void VideoCtrlBase::convert_frame_1bpp(uint8_t *dst_buf, int dst_pitch)
|
||||
{
|
||||
// TODO: implement me!
|
||||
}
|
||||
|
||||
void VideoCtrlBase::convert_frame_8bpp(uint8_t *dst_buf, int dst_pitch)
|
||||
{
|
||||
uint8_t *src_buf, *src_row, *dst_row, pix;
|
||||
|
@ -27,15 +27,18 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include <SDL.h>
|
||||
|
||||
#include <cinttypes>
|
||||
#include <functional>
|
||||
|
||||
class VideoCtrlBase {
|
||||
public:
|
||||
VideoCtrlBase();
|
||||
VideoCtrlBase(int width = 640, int height = 480);
|
||||
~VideoCtrlBase();
|
||||
|
||||
void update_screen(void);
|
||||
|
||||
void convert_frame_8bpp(uint8_t *dst_buf, int dst_pitch);
|
||||
// converters for various framebuffer pixel depths
|
||||
virtual void convert_frame_1bpp(uint8_t *dst_buf, int dst_pitch);
|
||||
virtual void convert_frame_8bpp(uint8_t *dst_buf, int dst_pitch);
|
||||
|
||||
protected:
|
||||
/* CRT controller parameters */
|
||||
@ -51,6 +54,8 @@ protected:
|
||||
uint8_t* fb_ptr;
|
||||
int fb_pitch;
|
||||
|
||||
std::function<void(uint8_t *dst_buf, int dst_pitch)> convert_fb_cb;
|
||||
|
||||
private:
|
||||
SDL_Window *display_wnd;
|
||||
SDL_Renderer *renderer;
|
||||
|
Loading…
Reference in New Issue
Block a user