]> Shamusworld >> Repos - virtualjaguar/commitdiff
Incremental changes to get Jaguar engine to work in QT environment.
authorShamus Hammons <jlhamm@acm.org>
Wed, 19 Jan 2011 14:15:15 +0000 (14:15 +0000)
committerShamus Hammons <jlhamm@acm.org>
Wed, 19 Jan 2011 14:15:15 +0000 (14:15 +0000)
Makefile
src/gui/glwidget.cpp
src/gui/mainwin.cpp
src/tom.cpp
src/tom.h
src/video.cpp

index 87489b9fc7a6fd979ed1960d331984d66c40f3b3..c191bf480cdfa01ba3dc98ae025c1fd4e30bb00d 100644 (file)
--- 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"
index e32dde3682aa65c4b6d842e6d960313803e669ae..9788bc3b4f65e53cc6cd5fb039e01f3ee827b59d 100644 (file)
 #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()
index 24c3dc457a5476d8bc30999b0f28d9d03f91775b..90f192a464a69932108fe592b28bab75c3e0e971 100644 (file)
@@ -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; y<videoWidget->rasterHeight; y++)
                                videoWidget->buffer[(y * videoWidget->textureWidth) + x] = 0x00000000;
 #else
-               for(uint32_t i=0; i<TOMGetVideoModeWidth() * 256; i++)
+//             for(uint32_t i=0; i<TOMGetVideoModeWidth() * 256; i++)
+               for(uint32_t i=0; i<videoWidget->textureWidth * 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)
index b3882a09f3fbe645e4b1b17ba6d6c2aaf21f9483..29860682832fcb655c33c67ce0711c31de8dff51 100644 (file)
@@ -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);
                }
        }
 }
index 03bd830d8a3ab698a7e34de82e624775cd9b492a..a484d78775ab9e3dc1306e2c89effbcd67e533de 100644 (file)
--- 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__
index 1d86f18b83e61dfa725cfd4b5806a0400c7fc4d1..917738071ec29bf8c290fd6ee8ef7298cee849ea 100644 (file)
@@ -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
 }
 
 //