2017-07-03 21:00:42 +01:00
|
|
|
#include "emulator.h"
|
2019-11-30 15:48:48 +00:00
|
|
|
#include "ui_emulator.h"
|
2017-07-03 21:00:42 +01:00
|
|
|
|
2017-07-04 12:14:04 +01:00
|
|
|
#include <QMdiSubWindow>
|
2019-11-25 21:08:01 +00:00
|
|
|
#include "StdAfx.h"
|
|
|
|
#include "Common.h"
|
|
|
|
#include "Video.h"
|
|
|
|
#include "NTSC.h"
|
2020-12-28 19:42:04 +00:00
|
|
|
#include "Interface.h"
|
2017-07-04 12:14:04 +01:00
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
|
2017-07-03 21:00:42 +01:00
|
|
|
Emulator::Emulator(QWidget *parent) :
|
2019-11-30 15:48:48 +00:00
|
|
|
QFrame(parent),
|
|
|
|
ui(new Ui::Emulator)
|
2017-07-03 21:00:42 +01:00
|
|
|
{
|
2019-11-30 15:48:48 +00:00
|
|
|
ui->setupUi(this);
|
2017-07-03 21:00:42 +01:00
|
|
|
}
|
|
|
|
|
2019-12-06 20:00:16 +00:00
|
|
|
Emulator::~Emulator()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2017-10-15 21:08:08 +01:00
|
|
|
void Emulator::updateVideo()
|
2017-07-03 21:00:42 +01:00
|
|
|
{
|
2019-11-30 15:48:48 +00:00
|
|
|
ui->video->update();
|
2017-07-03 21:00:42 +01:00
|
|
|
}
|
2017-07-04 12:14:04 +01:00
|
|
|
|
2019-11-25 21:08:01 +00:00
|
|
|
void Emulator::redrawScreen()
|
|
|
|
{
|
2020-12-28 19:42:04 +00:00
|
|
|
NTSC_SetVideoMode( GetVideo().GetVideoMode() );
|
2019-11-25 21:08:01 +00:00
|
|
|
NTSC_VideoRedrawWholeScreen();
|
|
|
|
refreshScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Emulator::refreshScreen()
|
2017-10-15 21:08:08 +01:00
|
|
|
{
|
2019-11-30 15:48:48 +00:00
|
|
|
ui->video->repaint();
|
2017-10-15 21:08:08 +01:00
|
|
|
}
|
|
|
|
|
2019-11-16 11:59:37 +00:00
|
|
|
bool Emulator::saveScreen(const QString & filename) const
|
2017-10-17 21:14:36 +01:00
|
|
|
{
|
2019-11-30 15:48:48 +00:00
|
|
|
return ui->video->getScreen().save(filename);
|
2017-10-17 21:14:36 +01:00
|
|
|
}
|
|
|
|
|
2020-12-28 20:00:16 +00:00
|
|
|
void Emulator::loadVideoSettings()
|
|
|
|
{
|
|
|
|
ui->video->loadVideoSettings();
|
|
|
|
}
|
|
|
|
|
2019-11-22 20:32:32 +00:00
|
|
|
void Emulator::displayLogo()
|
|
|
|
{
|
2019-11-30 15:48:48 +00:00
|
|
|
ui->video->displayLogo();
|
2019-11-22 20:32:32 +00:00
|
|
|
}
|
|
|
|
|
2017-07-04 12:14:04 +01:00
|
|
|
void Emulator::setVideoSize(QMdiSubWindow * window, const QSize & size)
|
|
|
|
{
|
|
|
|
window->showNormal();
|
|
|
|
|
|
|
|
// assume the extra space between widget and border is not affected by a resize
|
2019-11-30 15:48:48 +00:00
|
|
|
const QSize gap = window->size() - ui->video->size();
|
2017-07-04 12:14:04 +01:00
|
|
|
window->resize(size + gap);
|
|
|
|
}
|
|
|
|
|
2017-07-04 19:24:26 +01:00
|
|
|
void Emulator::setZoom(QMdiSubWindow * window, const int x)
|
2017-07-04 12:14:04 +01:00
|
|
|
{
|
2019-11-30 15:48:48 +00:00
|
|
|
const QSize target = ui->video->minimumSize() * x;
|
2017-07-04 12:14:04 +01:00
|
|
|
setVideoSize(window, target);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Emulator::set43AspectRatio(QMdiSubWindow * window)
|
|
|
|
{
|
|
|
|
// keep the same surface with 4:3 aspect ratio
|
2019-11-30 15:48:48 +00:00
|
|
|
const QSize & size = ui->video->size();
|
2017-07-04 12:14:04 +01:00
|
|
|
const double area = size.height() * size.width();
|
|
|
|
|
2017-07-09 16:49:40 +01:00
|
|
|
const int numerator = 35; // 7 * 40
|
|
|
|
const int denominator = 24; // 8 * 24
|
2017-07-04 12:14:04 +01:00
|
|
|
|
|
|
|
const int x = sqrt(area / (numerator * denominator));
|
|
|
|
const QSize target(numerator * x, denominator * x);
|
|
|
|
setVideoSize(window, target);
|
|
|
|
}
|