[crabemu-svn-commits] SF.net SVN: crabemu:[248] trunk/CrabEmu/src/qt
Status: Beta
Brought to you by:
ljsebald
From: <los...@us...> - 2014-11-02 22:15:29
|
Revision: 248 http://sourceforge.net/p/crabemu/code/248 Author: lostgeneration Date: 2014-11-02 22:15:20 +0000 (Sun, 02 Nov 2014) Log Message: ----------- Updates to Qt port * Fix compilation errors. * Added VIM modelines to sources. Modified Paths: -------------- trunk/CrabEmu/src/qt/CrabEmuThread.cpp trunk/CrabEmu/src/qt/CrabEmuThread.h trunk/CrabEmu/src/qt/EmuWidget.cpp trunk/CrabEmu/src/qt/EmuWidget.h trunk/CrabEmu/src/qt/glext.h trunk/CrabEmu/src/qt/gui/UIAboutDialog.cpp trunk/CrabEmu/src/qt/gui/UIAboutDialog.h trunk/CrabEmu/src/qt/gui/UICrabEmu.cpp trunk/CrabEmu/src/qt/gui/UICrabEmu.h trunk/CrabEmu/src/qt/gui/UIDebugWindow.cpp trunk/CrabEmu/src/qt/gui/UIDebugWindow.h trunk/CrabEmu/src/qt/gui/UIKeyInputDialog.cpp trunk/CrabEmu/src/qt/gui/UIKeyInputDialog.h trunk/CrabEmu/src/qt/gui/UIPreferences.cpp trunk/CrabEmu/src/qt/gui/UIPreferences.h trunk/CrabEmu/src/qt/main.cpp Modified: trunk/CrabEmu/src/qt/CrabEmuThread.cpp =================================================================== --- trunk/CrabEmu/src/qt/CrabEmuThread.cpp 2014-11-02 22:13:08 UTC (rev 247) +++ trunk/CrabEmu/src/qt/CrabEmuThread.cpp 2014-11-02 22:15:20 UTC (rev 248) @@ -19,16 +19,15 @@ #include <QMutex> #include "CrabEmuThread.h" +#include "console.h" #include "sound.h" extern QMutex memoryLock; -extern int emu_frame(int run); extern void render_scene(void); extern double GetAbsoluteTime(void); -extern "C" int sms_initialized; -extern "C" int coleco_initialized; -extern "C" int nes_initialized; +extern "C" console_t *console; + CrabEmuThread::CrabEmuThread(QObject *parent) : QThread(parent) { finished = false; fps = 60.0; @@ -49,15 +48,14 @@ while(!finished) { memoryLock.lock(); - if(!sms_initialized && !coleco_initialized && !nes_initialized) { + if(!console->initialized) { emit frameRendered(); memoryLock.unlock(); sleep(1); continue; } - run = emu_frame(run); - + console->frame(0); render_scene(); emit frameRendered(); memoryLock.unlock(); @@ -73,3 +71,6 @@ void CrabEmuThread::setFps(float f) { fps = f; } + +// vim: ts=4 sts=4 sw=4 et sta + Modified: trunk/CrabEmu/src/qt/CrabEmuThread.h =================================================================== --- trunk/CrabEmu/src/qt/CrabEmuThread.h 2014-11-02 22:13:08 UTC (rev 247) +++ trunk/CrabEmu/src/qt/CrabEmuThread.h 2014-11-02 22:15:20 UTC (rev 248) @@ -45,3 +45,6 @@ }; #endif /* !CRABEMUTHREAD_H */ + +// vim: ts=4 sts=4 sw=4 et sta + Modified: trunk/CrabEmu/src/qt/EmuWidget.cpp =================================================================== --- trunk/CrabEmu/src/qt/EmuWidget.cpp 2014-11-02 22:13:08 UTC (rev 247) +++ trunk/CrabEmu/src/qt/EmuWidget.cpp 2014-11-02 22:15:20 UTC (rev 248) @@ -23,22 +23,20 @@ #include "EmuWidget.h" #include "CrabEmuThread.h" #include "CrabEmu.h" +#include "nesppu.h" +#include "smsvdp.h" +#include "console.h" -#include "sms.h" -#include "smsvdp.h" -#include "nes.h" -#include "nesppu.h" #include "terebi.h" -#include "pastlib.h" #include "scale2x.h" +#include "hqx.h" #if defined(_WIN32) && defined(ENABLE_OPENGL) #include "glext.h" #endif -extern "C" int sms_console; extern "C" sms_vdp_t smsvdp; -extern "C" int sms_initialized, coleco_initialized, nes_initialized; +extern "C" console_t *console; #if defined(ENABLE_OPENGL) && defined(CRABEMU_32BIT_COLOR) #define PXTYPE GL_BGRA @@ -60,22 +58,6 @@ renderer = Render_Normal; } -#else - -EmuWidget::EmuWidget(CrabEmuThread *thd, QWidget *parent) : QGLWidget(parent) { - connect(thd, SIGNAL(frameRendered()), this, SLOT(updateGL())); - txrChanged = true; - txrCreated = false; - txrWidth = 256; - txrHeight = 256; - fbTrans = NULL; - renderer = Render_Normal; -} - -#endif - -#ifndef ENABLE_OPENGL - QImage *EmuWidget::retainImage() { mutex.lock(); return &img; @@ -85,37 +67,15 @@ mutex.unlock(); } -#else - -QImage *EmuWidget::retainImage() { - mutex.lock(); - img = grabFrameBuffer(); - return &img; -} - -void EmuWidget::releaseImage() { - mutex.unlock(); -} - -#endif - -#ifndef ENABLE_OPENGL - void EmuWidget::paintEvent(QPaintEvent *event __UNUSED__) { QMutexLocker locker(&mutex); QPainter painter(this); QRect r; - if(sms_initialized || coleco_initialized || nes_initialized) { - if(sms_console == CONSOLE_GG) { - r.setRect(48, 24, 160, 144); - } - else if(sms_console == CONSOLE_NES) { - r.setRect(0, 0, 256, 240); - } - else { - r.setRect(0, 0, 256, smsvdp.lines); - } + if(console && console->initialized) { + uint32_t x, y, w, h; + console->active_size(&x, &y, &w, &h); + r.setRect(x, y, w, h); painter.drawImage(rect(), img, r); } @@ -127,11 +87,31 @@ #else +EmuWidget::EmuWidget(CrabEmuThread *thd, QWidget *parent) : QGLWidget(parent) { + connect(thd, SIGNAL(frameRendered()), this, SLOT(updateGL())); + txrChanged = true; + txrCreated = false; + txrWidth = 256; + txrHeight = 256; + fbTrans = NULL; + renderer = Render_Normal; +} + +QImage *EmuWidget::retainImage() { + mutex.lock(); + img = grabFrameBuffer(); + return &img; +} + +void EmuWidget::releaseImage() { + mutex.unlock(); +} + void EmuWidget::resizeGL(int width, int height) { cxtWidth = width; cxtHeight = height; - if(!sms_initialized && !coleco_initialized && !nes_initialized) + if(!console || !console->initialized) return; glShadeModel(GL_SMOOTH); @@ -143,22 +123,27 @@ glMatrixMode(GL_PROJECTION); glLoadIdentity(); - if(sms_console == CONSOLE_NES) + if(console->console_type == CONSOLE_NES) glOrtho(0.0f, 255.0f, 239.0f, 0.0f, 1.0f, 0.0f); - else if(sms_console != CONSOLE_GG) + else if(console->console_type != CONSOLE_GG) glOrtho(0.0f, 255.0f, smsvdp.lines - 1, 0.0f, 1.0f, 0.0f); else glOrtho(0.0f, 159.0f, 143.0f, 0.0f, 1.0f, 0.0f); + //uint32_t x, y; + //console->frame_size(&x, &y); + //glOrtho(0.0f, x, y, 0.0f, 1.0f, 0.0f); + glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } -void EmuWidget::paintGL() { - if(!sms_initialized && !coleco_initialized && !nes_initialized) { +void EmuWidget::paintGL() { + if(!console || !console->initialized) { glClear(GL_COLOR_BUFFER_BIT); return; } + printf("initialized\n"); if(txrChanged) { if(txrCreated) { @@ -185,8 +170,7 @@ glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, glTexture); - - if(sms_console != CONSOLE_NES) { + if(console->console_type != CONSOLE_NES) { switch(renderer) { case Render_Normal: glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, txrWidth, txrHeight, @@ -200,14 +184,14 @@ break; case Render_HQ2x: - ProcessHQ2x((pixel *)smsvdp.framebuffer, (pixel *)fbTrans, + hq2x((pixel_t *)smsvdp.framebuffer, (pixel_t *)fbTrans, 256, smsvdp.lines); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, txrWidth, txrHeight, PXTYPE, DTTYPE, fbTrans); break; case Render_HQ4x: - ProcessHQ4x((pixel *)smsvdp.framebuffer, (pixel *)fbTrans, + hq4x((pixel_t *)smsvdp.framebuffer, (pixel_t *)fbTrans, 256, smsvdp.lines); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, txrWidth, txrHeight, PXTYPE, DTTYPE, fbTrans); @@ -229,14 +213,14 @@ break; case Render_HQ2x: - ProcessHQ2x((pixel *)nes_ppu_framebuffer(), (pixel *)fbTrans, + hq2x((pixel_t *)nes_ppu_framebuffer(), (pixel_t *)fbTrans, 256, 240); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, txrWidth, txrHeight, PXTYPE, DTTYPE, fbTrans); break; case Render_HQ4x: - ProcessHQ4x((pixel *)nes_ppu_framebuffer(), (pixel *)fbTrans, + hq4x((pixel_t *)nes_ppu_framebuffer(), (pixel_t *)fbTrans, 256, 240); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, txrWidth, txrHeight, PXTYPE, DTTYPE, fbTrans); @@ -244,7 +228,7 @@ } } - if(sms_console == CONSOLE_NES) { + if(console->console_type == CONSOLE_NES) { glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 240.0f / 256.0f); glVertex2f(0.0f, 239.0f); @@ -256,7 +240,7 @@ glVertex2f(255.0f, 0.0f); glEnd(); } - else if(sms_console != CONSOLE_GG) { + else if(console->console_type != CONSOLE_GG) { glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, smsvdp.lines / 256.0f); glVertex2f(0.0f, smsvdp.lines - 1); @@ -343,3 +327,6 @@ renderer = r; #endif } + +// vim: ts=4 sts=4 sw=4 et sta + Modified: trunk/CrabEmu/src/qt/EmuWidget.h =================================================================== --- trunk/CrabEmu/src/qt/EmuWidget.h 2014-11-02 22:13:08 UTC (rev 247) +++ trunk/CrabEmu/src/qt/EmuWidget.h 2014-11-02 22:15:20 UTC (rev 248) @@ -102,3 +102,6 @@ #endif /* ENABLE_OPENGL */ #endif /* EMUWIDGET_H */ + +// vim: ts=4 sts=4 sw=4 et sta + Modified: trunk/CrabEmu/src/qt/glext.h =================================================================== --- trunk/CrabEmu/src/qt/glext.h 2014-11-02 22:13:08 UTC (rev 247) +++ trunk/CrabEmu/src/qt/glext.h 2014-11-02 22:15:20 UTC (rev 248) @@ -13140,3 +13140,6 @@ #endif #endif + +// vim: ts=4 sts=4 sw=4 et sta + Modified: trunk/CrabEmu/src/qt/gui/UIAboutDialog.cpp =================================================================== --- trunk/CrabEmu/src/qt/gui/UIAboutDialog.cpp 2014-11-02 22:13:08 UTC (rev 247) +++ trunk/CrabEmu/src/qt/gui/UIAboutDialog.cpp 2014-11-02 22:15:20 UTC (rev 248) @@ -27,3 +27,6 @@ labelAbout->setText(labelAbout->text().arg(VERSION)); layout()->setSizeConstraint(QLayout::SetFixedSize); } + +// vim: ts=4 sts=4 sw=4 et sta + Modified: trunk/CrabEmu/src/qt/gui/UIAboutDialog.h =================================================================== --- trunk/CrabEmu/src/qt/gui/UIAboutDialog.h 2014-11-02 22:13:08 UTC (rev 247) +++ trunk/CrabEmu/src/qt/gui/UIAboutDialog.h 2014-11-02 22:15:20 UTC (rev 248) @@ -30,3 +30,6 @@ }; #endif /* !UIABOUTDIALOG_H */ + +// vim: ts=4 sts=4 sw=4 et sta + Modified: trunk/CrabEmu/src/qt/gui/UICrabEmu.cpp =================================================================== --- trunk/CrabEmu/src/qt/gui/UICrabEmu.cpp 2014-11-02 22:13:08 UTC (rev 247) +++ trunk/CrabEmu/src/qt/gui/UICrabEmu.cpp 2014-11-02 22:15:20 UTC (rev 248) @@ -29,6 +29,7 @@ #include "UIPreferences.h" #include "UIDebugWindow.h" #include "../EmuWidget.h" +#include "console.h" #include "sms.h" #include "colecovision.h" #include "nes.h" @@ -39,18 +40,17 @@ #include "rom.h" #include "smsvdp.h" #include "sn76489.h" -#include "smsz80.h" +//#include "smsz80.h" #include "sound.h" #include "cheats.h" -extern "C" int sms_initialized; -extern "C" int coleco_initialized; -extern "C" int nes_initialized; extern "C" int sms_psg_enabled; extern "C" int sms_ym2413_enabled; extern "C" sn76489_t psg; -extern "C" int sms_console; -extern "C" int sms_region; +//extern "C" int console->console_type; +//extern "C" int sms_region; +extern "C" console_t *console; + extern QMutex memoryLock; UICrabEmu::UICrabEmu(QWidget *parent) : QMainWindow(parent), videoMultiple(1) { @@ -120,17 +120,10 @@ delete thd; - if(sms_initialized) { + if(console->initialized) { saveSRAM(); - sms_shutdown(); + console->shutdown(); } - else if(coleco_initialized) { - coleco_shutdown(); - } - else if(nes_initialized) { - saveSRAM(); - nes_shutdown(); - } } void UICrabEmu::restoreSettings() { @@ -162,17 +155,12 @@ unpause(); - if(sms_initialized) { + if(console && console->initialized) { saveSRAM(); - if(sms_shutdown()) { + if(console->shutdown()) { return -1; } } - else if(nes_initialized) { - saveSRAM(); - if(nes_shutdown()) - return -1; - } if(debugger) on_actionDebugger_triggered(); @@ -187,24 +175,10 @@ menuPSG_Channels->setEnabled(true); menuVideo_System->setEnabled(true); - if(coleco_initialized) { - if(sms_region & videoSystem) { - if(coleco_reset()) { - return -1; - } - } - else { - coleco_shutdown(); - coleco_init(videoSystem); - updateFps(); - } + if(coleco_init(videoSystem)) { + return -1; } - else { - if(coleco_init(videoSystem)) { - return -1; - } - updateFps(); - } + updateFps(); biosfn = settings.value("ColecoVision BIOS ROM").toString(); @@ -236,45 +210,25 @@ return 0; } -int UICrabEmu::initializeSMS(QString filename, int console) { +int UICrabEmu::initializeSMS(QString filename, int console_type) { QString biosfn; QSettings settings; unpause(); - if(coleco_initialized) { + if(console && console->initialized) { saveSRAM(); - if(coleco_shutdown()) { + if(console->shutdown()) { return -1; } } - else if(nes_initialized) { - saveSRAM(); - if(nes_shutdown()) - return -1; + + if(sms_init(videoSystem, region, 0)) { + return -1; } - if(sms_initialized) { - saveSRAM(); + updateFps(); - if(sms_region & region && sms_region & videoSystem) { - if(sms_reset()) { - return -1; - } - } - else { - sms_shutdown(); - sms_init(videoSystem, region); - updateFps(); - } - } - else { - if(sms_init(videoSystem, region)) { - return -1; - } - updateFps(); - } - // Enable available features actionEnableYM2413->setEnabled(true); actionEnablePSG->setEnabled(true); @@ -285,7 +239,7 @@ menuVideo_System->setEnabled(true); sms_ym2413_enabled = actionEnableYM2413->isChecked(); - if(console == CONSOLE_SMS) { + if(console_type == CONSOLE_SMS) { biosfn = settings.value("SMS BIOS ROM").toString(); if(settings.value("SMS BIOS Enabled", false).toBool() && @@ -303,7 +257,7 @@ resizeEmu(256, smsvdp.lines); } - else if(console == CONSOLE_GG) { + else if(console_type == CONSOLE_GG) { biosfn = settings.value("Game Gear BIOS ROM").toString(); if(settings.value("GG BIOS Enabled", false).toBool() && @@ -322,7 +276,7 @@ resizeEmu(160, 144); } - if(sms_mem_load_rom(filename.toUtf8().data(), console)) { + if(sms_mem_load_rom(filename.toUtf8().data(), console_type)) { QMessageBox::warning(QApplication::activeWindow(), "Cannot open " "ROM file", "CrabEmu cannot open " + filename + "\n" "Please check that the file exists and is accessible."); @@ -340,13 +294,9 @@ unpause(); - if(coleco_initialized) { - if(coleco_shutdown()) - return -1; - } - else if(sms_initialized) { + if(console && console->initialized) { saveSRAM(); - if(sms_shutdown()) + if(console->shutdown()) return -1; } @@ -359,19 +309,10 @@ menuPSG_Channels->setDisabled(true); menuVideo_System->setDisabled(true); - if(nes_initialized) { - saveSRAM(); + if(nes_init(videoSystem)) + return -1; + updateFps(); - nes_shutdown(); - nes_init(videoSystem); - updateFps(); - } - else { - if(nes_init(videoSystem)) - return -1; - updateFps(); - } - nes_mem_load_rom(filename.toUtf8().data()); resizeEmu(256, 240); loadSRAM(); @@ -382,7 +323,7 @@ QStringList romPath; QStringList romExts; QFile file(filename); - int console; + int console_type; /* Kill off the emulation thread... we'll restart it as needed. */ thd->finish(); @@ -391,25 +332,25 @@ QMutexLocker locker(&memoryLock); - console = rom_detect_console(filename.toUtf8().data()); + console_type = rom_detect_console(filename.toUtf8().data()); - if(console < 0) { + if(console_type < 0) { QMessageBox::warning(QApplication::activeWindow(), "Cannot open " "ROM file", "CrabEmu cannot open " + filename + "\n" "Unrecognized file type."); return; } - if(console == CONSOLE_COLECOVISION) { + if(console_type == CONSOLE_COLECOVISION) { if(initializeCV(filename)) return; } - else if(console == CONSOLE_NES) { + else if(console_type == CONSOLE_NES) { if(initializeNES(filename)) return; } else { - if(initializeSMS(filename, console)) + if(initializeSMS(filename, console_type)) return; } @@ -447,72 +388,44 @@ void UICrabEmu::loadSRAM() { QSettings settings; + int (*read_sram)(const char *fn); - if(sms_initialized) { + if(console->console_type == CONSOLE_NES) { + read_sram = nes_mem_read_sram; + } else if(console->console_family == CONSOLE_SMS) { + read_sram = sms_read_cartram_from_file; + } + + if(console->initialized) { if(settings.value("Save Directory Enabled").toBool()) - sms_read_cartram_from_file( + read_sram( (settings.value("Save Directory").toString() + "/" + romName + ".ces").toUtf8().data()); else - sms_read_cartram_from_file((openRom + ".ces").toUtf8().data()); + read_sram((openRom + ".ces").toUtf8().data()); } - else if(nes_initialized) { - if(settings.value("Save Directory Enabled").toBool()) - nes_mem_read_sram( - (settings.value("Save Directory").toString() + "/" + - romName + ".ces").toUtf8().data()); - else - nes_mem_read_sram((openRom + ".ces").toUtf8().data()); - } } void UICrabEmu::saveSRAM() { QSettings settings; - if(sms_initialized) { + if(console->initialized) { if(settings.value("Save Directory Enabled").toBool()) - sms_write_cartram_to_file( + console->save_sram( (settings.value("Save Directory").toString() + "/" + romName + ".ces").toUtf8().data()); else - sms_write_cartram_to_file((openRom + ".ces").toUtf8().data()); + console->save_sram((openRom + ".ces").toUtf8().data()); } - else if(nes_initialized) { - if(settings.value("Save Directory Enabled").toBool()) - nes_mem_write_sram( - (settings.value("Save Directory").toString() + "/" + - romName + ".ces").toUtf8().data()); - else - nes_mem_write_sram((openRom + ".ces").toUtf8().data()); - } } void UICrabEmu::saveLoad(QString state, bool load) { QString filename; QSettings settings; - int (*save_func)(const char *); - int (*load_func)(const char *); - if(!sms_initialized && !coleco_initialized && !nes_initialized) + if(!console->initialized) return; - if(sms_initialized) { - save_func = &sms_save_state; - load_func = &sms_load_state; - } - else if(coleco_initialized) { - save_func = &coleco_save_state; - load_func = &coleco_load_state; - } - else if(nes_initialized) { - save_func = &nes_save_state; - load_func = &nes_load_state; - } - else { - // huh? - return; - } - if(settings.value("State Directory Enabled").toBool()) filename = settings.value("State Directory").toString() + "/" + romName + "." + state + ".cestate"; @@ -522,7 +435,7 @@ QMutexLocker locker(&memoryLock); if(load) { - if(load_func(filename.toUtf8().data())) { + if(console->load_state(filename.toUtf8().data())) { QMessageBox::warning(QApplication::activeWindow(), "Cannot open " "state file", "CrabEmu cannot open " + filename + " for " "reading. Verify that you have the permissions to " @@ -530,7 +443,7 @@ } } else { - if(save_func(filename.toUtf8().data())) { + if(console->save_state(filename.toUtf8().data())) { QMessageBox::warning(QApplication::activeWindow(), "Cannot open " "state file", "CrabEmu cannot open " + filename +" for " "writing. Verify that you have the permissions to " @@ -591,7 +504,7 @@ void UICrabEmu::on_actionTakeScreenshot_triggered() { QMutexLocker locker(&memoryLock); - if(!sms_initialized && !coleco_initialized && !nes_initialized) { + if(!console->initialized) { return; } @@ -613,10 +526,10 @@ data = emuwidget->retainImage(); - if(sms_console == CONSOLE_GG) { + if(console->console_type == CONSOLE_GG) { img = data->copy(48, 24, 160, 144); } - else if(sms_console == CONSOLE_NES) { + else if(console->console_type == CONSOLE_NES) { img = data->copy(0, 0, 256, 240); } else { @@ -746,7 +659,7 @@ } void UICrabEmu::on_actionEnableCheats_triggered() { - if(!sms_initialized) { + if(!console->initialized) { actionEnableCheats->setChecked(false); return; } @@ -779,48 +692,8 @@ emuwidget->setRenderer(Render_HQ4x); } -#if 0 -void UICrabEmu::on_action1X_triggered() -{ - videoMultiple = 1; - - if(!sms_initialized && !coleco_initialized && !nes_initialized) { - return; - } - - if (sms_console == CONSOLE_GG) { - resizeEmu(160, 144); - } - else if(sms_console == CONSOLE_NES) { - resizeEmu(256, 240); - } - else { - resizeEmu(256, smsvdp.lines); - } -} - -void UICrabEmu::on_action2X_triggered() -{ - videoMultiple = 2; - - if(!sms_initialized && !coleco_initialized && !nes_initialized) { - return; - } - - if (sms_console == CONSOLE_GG) { - resizeEmu(160, 144); - } - else if(sms_console == CONSOLE_NES) { - resizeEmu(256, 240); - } - else { - resizeEmu(256, smsvdp.lines); - } -} -#endif - void UICrabEmu::on_actionPause_triggered() { - if(!sms_initialized && !coleco_initialized && !nes_initialized) { + if(!console->initialized) { actionPause->setChecked(false); return; } @@ -845,37 +718,19 @@ } void UICrabEmu::on_actionReset_triggered() { - if(!sms_initialized && !coleco_initialized && !nes_initialized) + if(!console->initialized) return; if(paused) { on_actionPause_triggered(); } - if(sms_console == CONSOLE_COLECOVISION) { - if(sms_region & videoSystem) { - coleco_soft_reset(); - } - else { - on_actionReloadRom_triggered(); - } - } - else if(sms_console == CONSOLE_NES) { - nes_soft_reset(); - } - else { - if(sms_region & region && sms_region & videoSystem) { - sms_soft_reset(); - } - else { - // We've changed the region or video system, so do a full reset - on_actionReloadRom_triggered(); - } - } + // TODO: if the region or video system changes, a full reset may be needed + console->soft_reset(); } void UICrabEmu::on_actionShutdown_triggered() { - if(!sms_initialized && !coleco_initialized && !nes_initialized) + if(!console->initialized) return; unpause(); @@ -883,15 +738,7 @@ thd->finish(); thd->wait(); - if(sms_console == CONSOLE_COLECOVISION) { - coleco_shutdown(); - } - else if(sms_console == CONSOLE_NES) { - nes_shutdown(); - } - else { - sms_shutdown(); - } + console->shutdown(); } void UICrabEmu::on_actionReloadRom_triggered() { @@ -928,7 +775,7 @@ } void UICrabEmu::on_actionDebugger_triggered() { - if(coleco_initialized) { + if(console->console_family != CONSOLE_SMS) { return; } @@ -969,10 +816,10 @@ if(e->isAutoRepeat()) return; - if(sms_console == CONSOLE_COLECOVISION) { + if(console->console_type == CONSOLE_COLECOVISION) { colecoKeyPressEvent(e); } - else if(sms_console == CONSOLE_NES) { + else if(console->console_type == CONSOLE_NES) { nesKeyPressEvent(e); } else { @@ -1015,7 +862,7 @@ } if(button != -1) { - sms_button_pressed(1, button); + console->button_pressed(1, button); return; } @@ -1041,7 +888,7 @@ } if(button != -1) { - sms_button_pressed(2, button); + console->button_pressed(2, button); } } @@ -1113,7 +960,7 @@ } if(button != -1) { - coleco_button_pressed(1, button); + console->button_pressed(1, button); return; } @@ -1175,7 +1022,7 @@ } if(button != -1) { - coleco_button_pressed(2, button); + console->button_pressed(2, button); } } @@ -1209,7 +1056,7 @@ button = NES_SELECT; if(button != -1) { - nes_button_pressed(1, button); + console->button_pressed(1, button); return; } @@ -1233,7 +1080,7 @@ button = NES_SELECT; if(button != -1) - nes_button_pressed(2, button); + console->button_pressed(2, button); } void UICrabEmu::keyReleaseEvent(QKeyEvent *e) { @@ -1241,10 +1088,10 @@ if(e->isAutoRepeat()) return; - if(sms_console == CONSOLE_COLECOVISION) { + if(console->console_type == CONSOLE_COLECOVISION) { colecoKeyReleaseEvent(e); } - else if(sms_console == CONSOLE_NES) { + else if(console->console_type == CONSOLE_NES) { nesKeyReleaseEvent(e); } else { @@ -1629,3 +1476,6 @@ thd->setFps(50.0); } } + +// vim: ts=4 sts=4 sw=4 et sta + Modified: trunk/CrabEmu/src/qt/gui/UICrabEmu.h =================================================================== --- trunk/CrabEmu/src/qt/gui/UICrabEmu.h 2014-11-02 22:13:08 UTC (rev 247) +++ trunk/CrabEmu/src/qt/gui/UICrabEmu.h 2014-11-02 22:15:20 UTC (rev 248) @@ -133,3 +133,6 @@ }; #endif /* !UICRABEMU_H */ + +// vim: ts=4 sts=4 sw=4 et sta + Modified: trunk/CrabEmu/src/qt/gui/UIDebugWindow.cpp =================================================================== --- trunk/CrabEmu/src/qt/gui/UIDebugWindow.cpp 2014-11-02 22:13:08 UTC (rev 247) +++ trunk/CrabEmu/src/qt/gui/UIDebugWindow.cpp 2014-11-02 22:15:20 UTC (rev 248) @@ -22,18 +22,15 @@ #include "UICrabEmu.h" #include "CrabZ80.h" #include "CrabZ80d.h" -#include "sms.h" -#include "smsz80.h" +#include "console.h" #include "smsvdp.h" #include "sn76489.h" #include <cstdio> #include <QSettings> -extern "C" int sms_initialized, coleco_initialized; extern "C" CrabZ80_t *cpuz80; extern "C" sn76489_t psg; -extern int emu_frame(int run); -extern void render_scene(void); +extern "C" console_t *console; UIDebugWindow::UIDebugWindow(CrabEmuThread *thd, UICrabEmu* parent, bool paused): QMainWindow(parent) { this->paused = paused; @@ -288,8 +285,8 @@ SNDTONE(2) #undef SNDTONE - sprintf(tmp, "%03x", psg.noise); - sndNoise->setText(tmp); + sprintf(tmp, "%03x", psg.noise); + sndNoise->setText(tmp); } void UIDebugWindow::disassemble() { @@ -304,7 +301,7 @@ // When we press pause, we call our signal which is connected to the main // window's pause slot to do the work void UIDebugWindow::on_actionPause_triggered() { - if(!sms_initialized && !coleco_initialized) { + if(!console->initialized) { actionPause->setChecked(false); return; } @@ -321,19 +318,18 @@ void UIDebugWindow::on_actionCPUStep_triggered() { // don't allow if we're not paused - if((!sms_initialized && !coleco_initialized)|| !paused) + if((!console->initialized) || !paused) return; - sms_z80_run(1); + console->step(); setCpuInfo(); update(); } void UIDebugWindow::on_actionFrameStep_triggered() { - if((!sms_initialized && !coleco_initialized) || !paused) + if((!console->initialized) || !paused) return; - sms_frame(1, 0); - render_scene(); + console->frame(0); parent->emuwidget->update(); setCpuInfo(); update(); @@ -419,7 +415,7 @@ } void UIDebugWindow::update() { - if(sms_initialized || coleco_initialized) { + if(console->initialized) { updatePalette(); setSDSC(); setSndInfo(); @@ -428,3 +424,6 @@ setVdpTiles(); } } + +// vim: ts=4 sts=4 sw=4 et sta + Modified: trunk/CrabEmu/src/qt/gui/UIDebugWindow.h =================================================================== --- trunk/CrabEmu/src/qt/gui/UIDebugWindow.h 2014-11-02 22:13:08 UTC (rev 247) +++ trunk/CrabEmu/src/qt/gui/UIDebugWindow.h 2014-11-02 22:15:20 UTC (rev 248) @@ -68,3 +68,6 @@ }; #endif // UIDEBUGWINDOW_H + +// vim: ts=4 sts=4 sw=4 et sta + Modified: trunk/CrabEmu/src/qt/gui/UIKeyInputDialog.cpp =================================================================== --- trunk/CrabEmu/src/qt/gui/UIKeyInputDialog.cpp 2014-11-02 22:13:08 UTC (rev 247) +++ trunk/CrabEmu/src/qt/gui/UIKeyInputDialog.cpp 2014-11-02 22:15:20 UTC (rev 248) @@ -32,3 +32,6 @@ m_keyPressed = e->key(); accept(); } + +// vim: ts=4 sts=4 sw=4 et sta + Modified: trunk/CrabEmu/src/qt/gui/UIKeyInputDialog.h =================================================================== --- trunk/CrabEmu/src/qt/gui/UIKeyInputDialog.h 2014-11-02 22:13:08 UTC (rev 247) +++ trunk/CrabEmu/src/qt/gui/UIKeyInputDialog.h 2014-11-02 22:15:20 UTC (rev 248) @@ -39,3 +39,6 @@ }; #endif /* !UIKEYINPUTDIALOG_H */ + +// vim: ts=4 sts=4 sw=4 et sta + Modified: trunk/CrabEmu/src/qt/gui/UIPreferences.cpp =================================================================== --- trunk/CrabEmu/src/qt/gui/UIPreferences.cpp 2014-11-02 22:13:08 UTC (rev 247) +++ trunk/CrabEmu/src/qt/gui/UIPreferences.cpp 2014-11-02 22:15:20 UTC (rev 248) @@ -418,3 +418,6 @@ map[button] = key; (*bm)[buttonmap] = map; } + +// vim: ts=4 sts=4 sw=4 et sta + Modified: trunk/CrabEmu/src/qt/gui/UIPreferences.h =================================================================== --- trunk/CrabEmu/src/qt/gui/UIPreferences.h 2014-11-02 22:13:08 UTC (rev 247) +++ trunk/CrabEmu/src/qt/gui/UIPreferences.h 2014-11-02 22:15:20 UTC (rev 248) @@ -127,3 +127,6 @@ }; #endif /* !UIPREFERENCES_H */ + +// vim: ts=4 sts=4 sw=4 et sta + Modified: trunk/CrabEmu/src/qt/main.cpp =================================================================== --- trunk/CrabEmu/src/qt/main.cpp 2014-11-02 22:13:08 UTC (rev 247) +++ trunk/CrabEmu/src/qt/main.cpp 2014-11-02 22:15:20 UTC (rev 248) @@ -26,18 +26,11 @@ #include "gui/UICrabEmu.h" #include "gui/UIDebugWindow.h" #include "EmuWidget.h" +#include "console.h" -#include "sms.h" -#include "colecovision.h" -#include "nes.h" -#include "smsvdp.h" -#include "nesppu.h" - static bool resized = false; -extern "C" sms_vdp_t smsvdp; -extern "C" int sms_initialized; -extern "C" int sms_console; static UICrabEmu *mainWindow; +console_t *console; QMutex memoryLock; @@ -48,47 +41,17 @@ QImage *img = mainWindow->emuwidget->retainImage(); uchar *bits = img->bits(); - if(sms_console != CONSOLE_NES) { - /* Simple, but effective. */ + /* Simple, but effective. */ #ifdef CRABEMU_32BIT_COLOR - memcpy(bits, smsvdp.framebuffer, 256 * 256 * 4); + memcpy(bits, console->framebuffer(), 256 * 256 * 4); #else - memcpy(bits, smsvdp.framebuffer, 256 * 256 * 2); + memcpy(bits, console->framebuffer(), 256 * 256 * 2); #endif - } - else { -#ifdef CRABEMU_32BIT_COLOR - memcpy(bits, nes_ppu_framebuffer(), 256 * 256 * 4); -#else - memcpy(bits, nes_ppu_framebuffer(), 256 * 256 * 2); -#endif - } mainWindow->emuwidget->releaseImage(); #endif } -int emu_frame(int run) { - switch(sms_console) { - case CONSOLE_COLECOVISION: - run = coleco_frame(run, 0); - break; - - case CONSOLE_NES: - run = nes_frame(run, 0); - break; - - case CONSOLE_SMS: - case CONSOLE_GG: - case CONSOLE_SG1000: - case CONSOLE_SC3000: - run = sms_frame(run, 0); - break; - } - - return run; -} - extern "C" void gui_set_aspect(float x __UNUSED__, float y __UNUSED__) { /* XXXX: Do something about this function sometime. */ resized = true; @@ -98,6 +61,10 @@ mainWindow->setWindowTitle(QString::fromUtf8(str)); } +extern "C" void gui_set_console(console_t *c) { + console = c; +} + #ifdef ENABLE_SDSC_TERMINAL extern "C" void gui_update_sdsc_terminal(char console[25][80 * 2]) { @@ -131,3 +98,6 @@ return app.exec(); } + +// vim: ts=4 sts=4 sw=4 et sta + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |