mirror of
https://github.com/libretro/Mu.git
synced 2026-11-16 17:11:10 +00:00
Qt version now loads to digitizer like RetroArch version
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <new>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <cstdint>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -23,9 +24,10 @@ uint32_t screenHeight;
|
||||
static QImage video;
|
||||
static QTimer* refreshDisplay;
|
||||
static QSettings settings;
|
||||
std::mutex emuMutex;
|
||||
static std::atomic<bool> emuOn;
|
||||
static std::atomic<bool> emuLock;
|
||||
static bool emuInited;
|
||||
static std::atomic<bool> emuInited;
|
||||
static uint8_t romBuffer[ROM_SIZE];
|
||||
|
||||
|
||||
void popupErrorDialog(std::string error){
|
||||
@@ -84,13 +86,14 @@ MainWindow::MainWindow(QWidget* parent) :
|
||||
ui(new Ui::MainWindow){
|
||||
ui->setupUi(this);
|
||||
emuOn = false;
|
||||
emuLock = false;
|
||||
emuInited = false;
|
||||
screenWidth = 160;
|
||||
screenHeight = 160;
|
||||
screenHeight = 160 + 60;
|
||||
|
||||
loadRom();
|
||||
|
||||
ui->ctrlBtn->setText("Start");
|
||||
|
||||
refreshDisplay = new QTimer(this);
|
||||
connect(refreshDisplay, SIGNAL(timeout()), this, SLOT(updateDisplay()));
|
||||
//update display every 16.67 miliseconds = 60*second
|
||||
@@ -98,8 +101,9 @@ MainWindow::MainWindow(QWidget* parent) :
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow(){
|
||||
while(emuLock)usleep(10);
|
||||
emuMutex.lock();
|
||||
emulatorExit();
|
||||
emuMutex.unlock();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@@ -117,7 +121,7 @@ void MainWindow::loadRom(){
|
||||
uint8_t* romData = getFileBuffer(rom, size, error);
|
||||
if(romData){
|
||||
size_t romSize = size < ROM_SIZE ? size : ROM_SIZE;
|
||||
memcpy(palmRom, romData, romSize);
|
||||
memcpy(romBuffer, romData, romSize);
|
||||
delete[] romData;
|
||||
}
|
||||
|
||||
@@ -160,13 +164,14 @@ void MainWindow::on_install_pressed(){
|
||||
|
||||
//display
|
||||
void MainWindow::updateDisplay(){
|
||||
if(emuOn && !emuLock){
|
||||
emuLock = true;
|
||||
emulateFrame();
|
||||
video = QImage((unsigned char*)palmFramebuffer, screenWidth, screenHeight, QImage::Format_RGB16);//16 bit
|
||||
ui->display->setPixmap(QPixmap::fromImage(video).scaled(ui->display->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||
ui->display->update();
|
||||
emuLock = false;
|
||||
if(emuOn){
|
||||
if(emuMutex.try_lock()){
|
||||
emulateFrame();
|
||||
video = QImage((unsigned char*)palmFramebuffer, screenWidth, screenHeight, QImage::Format_RGB16);//16 bit
|
||||
ui->display->setPixmap(QPixmap::fromImage(video).scaled(ui->display->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||
ui->display->update();
|
||||
emuMutex.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,3 +248,25 @@ void MainWindow::on_joyRight_clicked(){
|
||||
void MainWindow::on_settings_clicked(){
|
||||
//setprocess(SETUP);
|
||||
}
|
||||
|
||||
//emu control
|
||||
void MainWindow::on_ctrlBtn_clicked()
|
||||
{
|
||||
emuMutex.lock();
|
||||
if(!emuOn && !emuInited){
|
||||
//start emu
|
||||
emulatorInit(romBuffer, ACCURATE);
|
||||
emuInited = true;
|
||||
emuOn = true;
|
||||
ui->ctrlBtn->setText("Pause");
|
||||
}
|
||||
else if(emuOn){
|
||||
emuOn = false;
|
||||
ui->ctrlBtn->setText("Resume");
|
||||
}
|
||||
else if(!emuOn){
|
||||
emuOn = true;
|
||||
ui->ctrlBtn->setText("Pause");
|
||||
}
|
||||
emuMutex.unlock();
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@ private slots:
|
||||
void on_joyRight_clicked();
|
||||
void on_settings_clicked();
|
||||
|
||||
void on_ctrlBtn_clicked();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
};
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="buttons">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
@@ -277,7 +277,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="9">
|
||||
<item row="0" column="8">
|
||||
<widget class="QPushButton" name="power">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
@@ -290,6 +290,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="9">
|
||||
<widget class="QPushButton" name="ctrlBtn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ctrl_btn</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="misc">
|
||||
|
||||
@@ -321,5 +321,5 @@ void emulateFrame(){
|
||||
}
|
||||
palmCycleCounter -= CPU_FREQUENCY / EMU_FPS;
|
||||
|
||||
printf("Ran frame, executed %f cycles.\n", palmCycleCounter + CPU_FREQUENCY / EMU_FPS);
|
||||
//printf("Ran frame, executed %f cycles.\n", palmCycleCounter + CPU_FREQUENCY / EMU_FPS);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
//The LCD power-off sequence is activated by programming the Power Save Mode Enable bit (REG[A0h] bit 0) to 1.
|
||||
|
||||
uint8_t sed1376Registers[SED1376_REG_SIZE];
|
||||
uint8_t sed1376Framebuffer[SED1376_FB_SIZE];
|
||||
uint8_t sed1376Framebuffer[SED1376_FB_SIZE + 3];//+ 3 to prevent 32 bit writes on last byte from corrupting memory
|
||||
|
||||
|
||||
unsigned int sed1376GetRegister(unsigned int address){
|
||||
@@ -49,6 +49,6 @@ void sed1376Render(){
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
//black screen
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user