mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-23 14:19:55 -06:00
147 lines
5.0 KiB
C++
147 lines
5.0 KiB
C++
/*
|
|
Copyright 2016-2023 melonDS team
|
|
|
|
This file is part of melonDS.
|
|
|
|
melonDS is free software: you can redistribute it and/or modify it under
|
|
the terms of the GNU General Public License as published by the Free
|
|
Software Foundation, either version 3 of the License, or (at your option)
|
|
any later version.
|
|
|
|
melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
with melonDS. If not, see http://www.gnu.org/licenses/.
|
|
*/
|
|
|
|
#ifndef EMUINSTANCE_H
|
|
#define EMUINSTANCE_H
|
|
|
|
#include "NDS.h"
|
|
#include "EmuThread.h"
|
|
#include "Window.h"
|
|
#include "Config.h"
|
|
#include "SaveManager.h"
|
|
|
|
const int kMaxWindows = 16;
|
|
|
|
class EmuInstance
|
|
{
|
|
public:
|
|
EmuInstance(int inst);
|
|
~EmuInstance();
|
|
|
|
int getInstanceID() { return instanceID; }
|
|
EmuThread* getEmuThread() { return emuThread; }
|
|
melonDS::NDS* getNDS() { return nds; }
|
|
|
|
void createWindow();
|
|
|
|
// return: empty string = setup OK, non-empty = error message
|
|
QString verifySetup();
|
|
|
|
bool updateConsole(UpdateConsoleNDSArgs&& ndsargs, UpdateConsoleGBAArgs&& gbaargs) noexcept;
|
|
|
|
void enableCheats(bool enable);
|
|
melonDS::ARCodeFile* getCheatFile();
|
|
|
|
void romIcon(const melonDS::u8 (&data)[512],
|
|
const melonDS::u16 (&palette)[16],
|
|
melonDS::u32 (&iconRef)[32*32]);
|
|
void animatedROMIcon(const melonDS::u8 (&data)[8][512],
|
|
const melonDS::u16 (&palette)[8][16],
|
|
const melonDS::u16 (&sequence)[64],
|
|
melonDS::u32 (&animatedIconRef)[64][32*32],
|
|
std::vector<int> &animatedSequenceRef);
|
|
|
|
private:
|
|
static int lastSep(const std::string& path);
|
|
std::string getAssetPath(bool gba, const std::string& configpath, const std::string& ext, const std::string& file);
|
|
|
|
QString verifyDSBIOS();
|
|
QString verifyDSiBIOS();
|
|
QString verifyDSFirmware();
|
|
QString verifyDSiFirmware();
|
|
QString verifyDSiNAND();
|
|
|
|
std::string getEffectiveFirmwareSavePath();
|
|
void initFirmwareSaveManager() noexcept;
|
|
std::string getSavestateName(int slot);
|
|
bool savestateExists(int slot);
|
|
bool loadState(const std::string& filename);
|
|
bool saveState(const std::string& filename);
|
|
void undoStateLoad();
|
|
void unloadCheats();
|
|
void loadCheats();
|
|
std::optional<std::array<melonDS::u8, melonDS::ARM9BIOSSize>> loadARM9BIOS() noexcept;
|
|
std::optional<std::array<melonDS::u8, melonDS::ARM7BIOSSize>> loadARM7BIOS() noexcept;
|
|
std::optional<std::array<melonDS::u8, melonDS::DSiBIOSSize>> loadDSiARM9BIOS() noexcept;
|
|
std::optional<std::array<melonDS::u8, melonDS::DSiBIOSSize>> loadDSiARM7BIOS() noexcept;
|
|
melonDS::Firmware generateFirmware(int type) noexcept;
|
|
std::optional<melonDS::Firmware> loadFirmware(int type) noexcept;
|
|
std::optional<melonDS::DSi_NAND::NANDImage> loadNAND(const std::array<melonDS::u8, melonDS::DSiBIOSSize>& arm7ibios) noexcept;
|
|
std::optional<melonDS::FATStorageArgs> getSDCardArgs(const std::string& key) noexcept;
|
|
std::optional<melonDS::FATStorage> loadSDCard(const std::string& key) noexcept;
|
|
void setBatteryLevels();
|
|
void setDateTime();
|
|
void reset();
|
|
bool bootToMenu();
|
|
melonDS::u32 decompressROM(const melonDS::u8* inContent, const melonDS::u32 inSize, std::unique_ptr<melonDS::u8[]>& outContent);
|
|
void clearBackupState();
|
|
std::pair<std::unique_ptr<melonDS::Firmware>, std::string> generateDefaultFirmware();
|
|
bool parseMacAddress(void* data);
|
|
void customizeFirmware(melonDS::Firmware& firmware) noexcept;
|
|
bool loadROMData(const QStringList& filepath, std::unique_ptr<melonDS::u8[]>& filedata, melonDS::u32& filelen, std::string& basepath, std::string& romname) noexcept;
|
|
QString getSavErrorString(std::string& filepath, bool gba);
|
|
bool loadROM(QStringList filepath, bool reset);
|
|
void ejectCart();
|
|
bool cartInserted();
|
|
QString cartLabel();
|
|
bool loadGBAROM(QStringList filepath);
|
|
void loadGBAAddon(int type);
|
|
void ejectGBACart();
|
|
bool gbaCartInserted();
|
|
QString gbaCartLabel();
|
|
|
|
int instanceID;
|
|
|
|
EmuThread* emuThread;
|
|
|
|
MainWindow* mainWindow;
|
|
MainWindow* windowList[kMaxWindows];
|
|
int numWindows;
|
|
|
|
Config::Table globalCfg;
|
|
Config::Table localCfg;
|
|
|
|
melonDS::NDS* nds;
|
|
|
|
int cartType;
|
|
std::string baseROMDir;
|
|
std::string baseROMName;
|
|
std::string baseAssetName;
|
|
|
|
int gbaCartType;
|
|
std::string baseGBAROMDir;
|
|
std::string baseGBAROMName;
|
|
std::string baseGBAAssetName;
|
|
|
|
std::unique_ptr<SaveManager> ndsSave;
|
|
std::unique_ptr<SaveManager> gbaSave;
|
|
std::unique_ptr<SaveManager> firmwareSave;
|
|
|
|
std::unique_ptr<melonDS::Savestate> backupState;
|
|
bool savestateLoaded;
|
|
std::string previousSaveFile;
|
|
|
|
melonDS::ARCodeFile* cheatFile;
|
|
bool cheatsOn;
|
|
|
|
friend class EmuThread;
|
|
friend class MainWindow;
|
|
};
|
|
|
|
#endif //EMUINSTANCE_H
|