diff --git a/devices/video/atirage.cpp b/devices/video/atirage.cpp
index 89d2891..b3953a0 100644
--- a/devices/video/atirage.cpp
+++ b/devices/video/atirage.cpp
@@ -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");
diff --git a/devices/video/videoctrl.cpp b/devices/video/videoctrl.cpp
index 0c78446..d8db848 100644
--- a/devices/video/videoctrl.cpp
+++ b/devices/video/videoctrl.cpp
@@ -28,17 +28,20 @@ along with this program. If not, see .
#include
#include
-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;
diff --git a/devices/video/videoctrl.h b/devices/video/videoctrl.h
index 8c8804b..66aa560 100644
--- a/devices/video/videoctrl.h
+++ b/devices/video/videoctrl.h
@@ -27,15 +27,18 @@ along with this program. If not, see .
#include
#include
+#include
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 convert_fb_cb;
+
private:
SDL_Window *display_wnd;
SDL_Renderer *renderer;