From: Shamus Hammons Date: Wed, 19 Jan 2011 14:15:15 +0000 (+0000) Subject: Incremental changes to get Jaguar engine to work in QT environment. X-Git-Tag: 2.0.0~34^2~27 X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=438d3a52ef0af04ac3279c0839fe6ffd7333b776;p=virtualjaguar Incremental changes to get Jaguar engine to work in QT environment. --- diff --git a/Makefile b/Makefile index 87489b9..c191bf4 100644 --- a/Makefile +++ b/Makefile @@ -205,7 +205,7 @@ QT_CFLAGS = -MMD `pkg-config --cflags QtGui` QT_DEFINES = -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED #QT_INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I./src/gui -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I./obj QT_INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I./src -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtOpenGL -I/usr/include/qt4 -I/usr/X11R6/include -I./obj -QT_CXXFLAGS = -MMD -pipe -O2 -march=pentium-m -pipe -D_REENTRANT -Wall -W $(QT_DEFINES) -D$(SYSTYPE) +QT_CXXFLAGS = -MMD -pipe -O2 -march=pentium-m -pipe -D_REENTRANT -Wall -W $(QT_DEFINES) -D$(SYSTYPE) -g obj/moc_%.cpp: src/gui/%.h @echo -e "\033[01;33m***\033[00;32m Creating $@...\033[00m" diff --git a/src/gui/glwidget.cpp b/src/gui/glwidget.cpp index e32dde3..9788bc3 100644 --- a/src/gui/glwidget.cpp +++ b/src/gui/glwidget.cpp @@ -14,14 +14,27 @@ #include "glwidget.h" #include "settings.h" +#include "tom.h" +#include "video.h" GLWidget::GLWidget(QWidget * parent/*= 0*/): QGLWidget(parent), texture(0), textureWidth(0), textureHeight(0), buffer(0), rasterWidth(320), rasterHeight(240) { +// tomDeviceWidth = rasterWidth; + tomDeviceWidth = 1024; // It has to be the texture width... + + // Set up the backbuffer + // To be safe, this should be 1280 * 625 * 2... + backbuffer = (uint32_t *)malloc(1280 * 625 * sizeof(uint32_t)); +// memset(backbuffer, 0x44, rasterWidth * + memset(backbuffer, 0xFF, 1024 * + (vjs.hardwareTypeNTSC ? rasterHeight : VIRTUAL_SCREEN_HEIGHT_PAL) + * sizeof(uint32_t)); } GLWidget::~GLWidget() { + delete[] backbuffer; } void GLWidget::initializeGL() diff --git a/src/gui/mainwin.cpp b/src/gui/mainwin.cpp index 24c3dc4..90f192a 100644 --- a/src/gui/mainwin.cpp +++ b/src/gui/mainwin.cpp @@ -245,7 +245,8 @@ void MainWin::Timer(void) } #else JaguarExecuteNew(); - memcpy(videoWidget->buffer, backbuffer, videoWidget->rasterHeight * videoWidget->rasterWidth); +// memcpy(videoWidget->buffer, backbuffer, videoWidget->rasterHeight * videoWidget->rasterWidth); + memcpy(videoWidget->buffer, backbuffer, videoWidget->rasterHeight * videoWidget->textureWidth); // memcpy(surface->pixels, backbuffer, TOMGetVideoModeWidth() * TOMGetVideoModeHeight() * 4); #endif @@ -372,20 +373,23 @@ void MainWin::ToggleRunState(void) for(uint32_t y=0; yrasterHeight; y++) videoWidget->buffer[(y * videoWidget->textureWidth) + x] = 0x00000000; #else - for(uint32_t i=0; itextureWidth * 256; i++) { uint32_t pixel = backbuffer[i]; - uint8_t b = (pixel >> 16) & 0xFF, g = (pixel >> 8) & 0xFF, r = pixel & 0xFF; +// uint8_t b = (pixel >> 16) & 0xFF, g = (pixel >> 8) & 0xFF, r = pixel & 0xFF; + uint8_t r = (pixel >> 24) & 0xFF, g = (pixel >> 16) & 0xFF, b = (pixel >> 8) & 0xFF; pixel = ((r + g + b) / 3) & 0x00FF; - backbuffer[i] = 0xFF000000 | (pixel << 16) | (pixel << 8); +// backbuffer[i] = 0xFF000000 | (pixel << 16) | (pixel << 8); + backbuffer[i] = 0x000000FF | (pixel << 16) | (pixel << 8); } - memcpy(videoWidget->buffer, backbuffer, videoWidget->rasterHeight * videoWidget->rasterWidth); +// memcpy(videoWidget->buffer, backbuffer, videoWidget->rasterHeight * videoWidget->rasterWidth); + memcpy(videoWidget->buffer, backbuffer, videoWidget->rasterHeight * videoWidget->textureWidth); #endif videoWidget->updateGL(); } - } void MainWin::SetZoom100(void) diff --git a/src/tom.cpp b/src/tom.cpp index b3882a0..2986068 100644 --- a/src/tom.cpp +++ b/src/tom.cpp @@ -336,6 +336,8 @@ uint16 tom_jerry_int_pending, tom_timer_int_pending, tom_object_int_pending, //int16 * TOMBackbuffer; uint32 * TOMBackbuffer; +uint32 tomDeviceWidth; + static const char * videoMode_to_str[8] = { "16 BPP CRY", "24 BPP RGB", "16 BPP DIRECT", "16 BPP RGB", "Mixed mode", "24 BPP RGB", "16 BPP DIRECT", "16 BPP RGB" }; @@ -1020,7 +1022,9 @@ void tom_render_24bpp_scanline(uint32 * backbuffer) *currentLineBuffer++ = pixel; } - TOMBackbuffer += GetSDLScreenWidthInPixels(); +#warning "!!! Need to move this to an interface file !!! FIX !!!" +// TOMBackbuffer += GetSDLScreenWidthInPixels(); + TOMBackbuffer += tomDeviceWidth; } } @@ -1499,8 +1503,10 @@ if (offset == VMODE) { tomWidth = width, tomHeight = height; - if (vjs.renderType == RT_NORMAL) - ResizeScreen(tomWidth, tomHeight); +#warning "!!! TOM: ResizeScreen commented out !!!" +// No need to resize anything, since we're prepared for this... +// if (vjs.renderType == RT_NORMAL) +// ResizeScreen(tomWidth, tomHeight); } } } diff --git a/src/tom.h b/src/tom.h index 03bd830..a484d78 100644 --- a/src/tom.h +++ b/src/tom.h @@ -61,4 +61,6 @@ extern uint32 tomTimerPrescaler; extern uint32 tomTimerDivider; extern int32 tomTimerCounter; +extern uint32 tomDeviceWidth; + #endif // __TOM_H__ diff --git a/src/video.cpp b/src/video.cpp index 1d86f18..9177380 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -240,6 +240,8 @@ void RenderBackbuffer(void) // void ResizeScreen(uint32 width, uint32 height) { +// For now, we don't do anything here... +#if 0 SDL_FreeSurface(surface); surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, RMASK, GMASK, BMASK, AMASK); @@ -277,6 +279,7 @@ void ResizeScreen(uint32 width, uint32 height) sprintf(window_title, "Virtual Jaguar (%i x %i)", (int)width, (int)height); SDL_WM_SetCaption((vjs.useOpenGL ? "Virtual Jaguar (OpenGL)" : window_title), "Virtual Jaguar"); +#endif } //