mirror of
https://github.com/libretro/gambatte-libretro.git
synced 2024-11-27 01:40:23 +00:00
Add "force DMG mode" option.
git-svn-id: https://gambatte.svn.sourceforge.net/svnroot/gambatte@188 9dfb2916-2d38-0410-aef4-c5fe6c9ffc24
This commit is contained in:
parent
f834c0a646
commit
b061b5db6c
@ -139,6 +139,9 @@ mw(mw), source(source), frameTime(4389, 262144) {
|
||||
|
||||
settingsm->addSeparator();
|
||||
|
||||
forceDmgAction = settingsm->addAction(tr("Force &DMG Mode"));
|
||||
forceDmgAction->setCheckable(true);
|
||||
|
||||
{
|
||||
QMenu *const palm = settingsm->addMenu(tr("DMG &Palette"));
|
||||
|
||||
@ -237,7 +240,7 @@ void GambatteMenuHandler::loadFile(const QString &fileName) {
|
||||
pauseAction->setChecked(false);
|
||||
pauseChange();
|
||||
|
||||
if (source->load((fileName.toAscii()).data())) {
|
||||
if (source->load((fileName.toAscii()).data(), forceDmgAction->isChecked())) {
|
||||
mw->stop();
|
||||
|
||||
QMessageBox::critical(
|
||||
|
@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2007 by Sindre Aamås *
|
||||
* Copyright (C) 2007 by Sindre Aam<EFBFBD>s *
|
||||
* aamas@stud.ntnu.no *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
@ -80,6 +80,7 @@ class GambatteMenuHandler : public QObject {
|
||||
QAction *pauseAction;
|
||||
QAction *decFrameRateAction;
|
||||
QAction *incFrameRateAction;
|
||||
QAction *forceDmgAction;
|
||||
QMenu *recentMenu;
|
||||
QMenu *stateSlotMenu;
|
||||
PaletteDialog *globalPaletteDialog;
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
|
||||
void emitBlit() { emit blit(); }
|
||||
|
||||
bool load(const char* romfile) { return gb.load(romfile); }
|
||||
bool load(const char* romfile, const bool forceDmg) { return gb.load(romfile, forceDmg); }
|
||||
void reset() { gb.reset(); }
|
||||
void setDmgPaletteColor(unsigned palNum, unsigned colorNum, unsigned rgb32) { gb.setDmgPaletteColor(palNum, colorNum, rgb32); }
|
||||
void setSavedir(const std::string &sdir) { gb.set_savedir(sdir.c_str()); }
|
||||
|
@ -60,6 +60,15 @@ public:
|
||||
bool isExeced() const { return execed; }
|
||||
};
|
||||
|
||||
class ForceDmgOption : public DescOption {
|
||||
bool forceDmg_;
|
||||
public:
|
||||
ForceDmgOption() : DescOption("force-dmg"), forceDmg_(false) {}
|
||||
void exec(const char *const */*argv*/, int /*index*/) { forceDmg_ = true; }
|
||||
const char* getDesc() const { return "\t\tForce DMG mode\n"; }
|
||||
bool forceDmg() const { return forceDmg_; }
|
||||
};
|
||||
|
||||
class RateOption : public DescOption {
|
||||
unsigned rate;
|
||||
public:
|
||||
@ -426,6 +435,8 @@ bool GambatteSdl::init(int argc, char **argv) {
|
||||
Parser parser;
|
||||
|
||||
std::vector<DescOption*> v;
|
||||
ForceDmgOption forceDmgOption;
|
||||
v.push_back(&forceDmgOption);
|
||||
FsOption fsOption;
|
||||
v.push_back(&fsOption);
|
||||
InputOption inputOption;
|
||||
@ -487,7 +498,7 @@ bool GambatteSdl::init(int argc, char **argv) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (gambatte.load(argv[loadIndex])) {
|
||||
if (gambatte.load(argv[loadIndex], forceDmgOption.forceDmg())) {
|
||||
std::printf("failed to load ROM %s\n", argv[loadIndex]);
|
||||
return 1;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class GB {
|
||||
public:
|
||||
GB();
|
||||
~GB();
|
||||
bool load(const char* romfile);
|
||||
bool load(const char* romfile, bool forceDmg = false);
|
||||
|
||||
/** Emulates until at least 'samples' stereo sound samples are produced in the supplied buffer.
|
||||
* There are 35112 stereo sound samples in a video frame.
|
||||
|
@ -47,8 +47,8 @@ void CPU::runFor(const unsigned long cycles) {
|
||||
cycleCounter_ = memory.resetCounters(cycleCounter_);
|
||||
}
|
||||
|
||||
bool CPU::load(const char* romfile) {
|
||||
bool tmp = memory.loadROM(romfile);
|
||||
bool CPU::load(const char* romfile, const bool forceDmg) {
|
||||
bool tmp = memory.loadROM(romfile, forceDmg);
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ public:
|
||||
memory.setOsdElement(osdElement);
|
||||
}
|
||||
|
||||
bool load(const char* romfile);
|
||||
bool load(const char* romfile, bool forceDmg);
|
||||
|
||||
void setSoundBuffer(Gambatte::uint_least32_t *const buf) { memory.setSoundBuffer(buf); }
|
||||
unsigned fillSoundBuffer() { return memory.fillSoundBuffer(cycleCounter_); }
|
||||
|
@ -99,10 +99,10 @@ void GB::set_savedir(const char *sdir) {
|
||||
z80->set_savedir(sdir);
|
||||
}
|
||||
|
||||
bool GB::load(const char* romfile) {
|
||||
bool GB::load(const char* romfile, const bool forceDmg) {
|
||||
z80->saveSavedata();
|
||||
|
||||
const bool failed = z80->load(romfile);
|
||||
const bool failed = z80->load(romfile, forceDmg);
|
||||
|
||||
if (!failed) {
|
||||
SaveState state;
|
||||
|
@ -1547,7 +1547,7 @@ static void enforce8bit(unsigned char *data, unsigned long sz) {
|
||||
*data++ &= 0xFF;
|
||||
}
|
||||
|
||||
bool Memory::loadROM(const char *romfile) {
|
||||
bool Memory::loadROM(const char *romfile, const bool forceDmg) {
|
||||
romFilePath = romfile;
|
||||
|
||||
File rom(romfile);
|
||||
@ -1560,7 +1560,7 @@ bool Memory::loadROM(const char *romfile) {
|
||||
unsigned char header[0x150];
|
||||
rom.read(reinterpret_cast<char*>(header), sizeof(header));
|
||||
|
||||
cgb = header[0x0143] >> 7;
|
||||
cgb = ~forceDmg & (header[0x0143] >> 7) & 1;
|
||||
|
||||
switch (header[0x0147]) {
|
||||
case 0x00: std::printf("Plain ROM loaded.\n");
|
||||
|
@ -199,7 +199,7 @@ public:
|
||||
unsigned long event(unsigned long cycleCounter);
|
||||
unsigned long resetCounters(unsigned long cycleCounter);
|
||||
|
||||
bool loadROM(const char* romfile);
|
||||
bool loadROM(const char* romfile, bool forceDmg);
|
||||
void set_savedir(const char *dir);
|
||||
|
||||
void setInputStateGetter(Gambatte::InputStateGetter *getInput) {
|
||||
|
Loading…
Reference in New Issue
Block a user