Merge pull request #17 from NovaSquirrel/master

Update to latest
This commit is contained in:
mkwong98 2021-11-02 00:16:06 +08:00 committed by GitHub
commit 1b1e7be6ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 79 additions and 63 deletions

View file

@ -901,7 +901,7 @@ bool Debugger::ProcessRamOperation(MemoryOperationType type, uint16_t &addr, uin
_currentReadValue = nullptr; _currentReadValue = nullptr;
if(type == MemoryOperationType::Write) { if(type == MemoryOperationType::Write) {
if(_runToCycle == -1 && !CheckFlag(DebuggerFlags::IgnoreRedundantWrites) || _memoryManager->DebugRead(addr) != value) { if((_runToCycle == -1 && !CheckFlag(DebuggerFlags::IgnoreRedundantWrites)) || (_memoryManager->DebugRead(addr) != value)) {
_memoryAccessCounter->ProcessMemoryWrite(addressInfo, _cpu->GetCycleCount()); _memoryAccessCounter->ProcessMemoryWrite(addressInfo, _cpu->GetCycleCount());
} }
@ -916,7 +916,7 @@ bool Debugger::ProcessRamOperation(MemoryOperationType type, uint16_t &addr, uin
} }
} else if(addr >= 0x4018 && _mapper->IsWriteRegister(addr)) { } else if(addr >= 0x4018 && _mapper->IsWriteRegister(addr)) {
_eventManager->AddDebugEvent(DebugEventType::MapperRegisterWrite, addr, value); _eventManager->AddDebugEvent(DebugEventType::MapperRegisterWrite, addr, value);
} else if(addr >= 0x4000 && addr <= 0x4015 || addr == 0x4017) { } else if((addr >= 0x4000 && addr <= 0x4015) || addr == 0x4017) {
_eventManager->AddDebugEvent(DebugEventType::ApuRegisterWrite, addr, value); _eventManager->AddDebugEvent(DebugEventType::ApuRegisterWrite, addr, value);
} else if(addr == 0x4016) { } else if(addr == 0x4016) {
_eventManager->AddDebugEvent(DebugEventType::ControlRegisterWrite, addr, value); _eventManager->AddDebugEvent(DebugEventType::ControlRegisterWrite, addr, value);

View file

@ -30,6 +30,7 @@ private:
uint8_t irqAHighValue; uint8_t irqAHighValue;
uint8_t irqALowValue; uint8_t irqALowValue;
uint8_t irqBValue; uint8_t irqBValue;
uint8_t irqEnable;
uint16_t currentRegister; uint16_t currentRegister;
@ -92,47 +93,59 @@ private:
break; break;
case 0x1: case 0x1:
if (currentRegister == 0x24) { if (irqEnable) {
//Timer A High 8 bits if (currentRegister == 0x24) {
//std::cout << "Timer A High 8 bits" << std::endl; //Timer A High 8 bits
irqAHighValue = value; irqAHighValue = value;
}
if (currentRegister == 0x25) {
//Timer A Low 2 bits
//std::cout << "Timer A Low 2 bits" << std::endl;
irqALowValue = (value & 0x3);
}
if (currentRegister == 0x26) {
//Timer B 8 bits
//std::cout << "Timer B 8 bits" << std::endl;
irqBValue = value;
}
if ((currentRegister == 0x27) && ((value & 0x5)|(value & 0xA))) {
//Load+Enable IRQ (0xA = TimerB, 0x5 = TimerA)
//std::cout << "Load+Enable IRQ" << std::endl;
if ((currentRegister == 0x27) && (value & 0x5)) {
irqATimer = (uint16_t(irqAHighValue) << 2) | irqALowValue;
irqACurrentTimer = 72 * (1024 - irqATimer) * 2;
irqATimerEnable = 1;
//std::cout << "Load+Enable IRQ A" << std::endl;
} }
if ((currentRegister == 0x27) && (value & 0xA)) { if (currentRegister == 0x25) {
irqBTimer = 1152 * (256 - irqBValue) * 2; //Timer A Low 2 bits
irqBCurrentTimer = irqBTimer; irqALowValue = (value & 0x3);
irqBTimerEnable = 1; }
//std::cout << "Load+Enable IRQ B " << irqBCurrentTimer << std::endl; if (currentRegister == 0x26) {
//Timer B 8 bits
irqBValue = value;
}
if (currentRegister == 0x27) {
//Load+Enable IRQ (0xA = TimerB, 0x5 = TimerA)
if ((value & 0x5)) {
irqATimer = (uint16_t(irqAHighValue) << 2) | irqALowValue;
irqACurrentTimer = 72 * (1024 - irqATimer) * 2;
irqATimerEnable = 1;
}
if ((value & 0xA)) {
irqBTimer = 1152 * (256 - irqBValue) * 2;
irqBCurrentTimer = irqBTimer;
irqBTimerEnable = 1;
}
if ((value & 0x10)) {
//Enable/Reset IRQ
_console->GetCpu()->ClearIrqSource(IRQSource::EPSM);
irqATimerEnable = 0;
}
if ((value & 0x20)) {
//Enable/Reset IRQ
_console->GetCpu()->ClearIrqSource(IRQSource::EPSM);
irqBTimerEnable = 0;
}
} }
} }
if ((currentRegister == 0x27) && (value & 0x30)) { if (currentRegister == 0x29) {
//Enable/Reset IRQ //std::cout << std::hex << "value: " << value << std::endl;
//std::cout << std::hex << uint16_t(value) << "Reset IRQ" << std::endl; if ((value & 0x3 && (value & 0x80))) {
_console->GetCpu()->ClearIrqSource(IRQSource::EPSM); //if ((value & 0x3 )) {
irqATimerEnable = 0; //enable IRQ's
irqBTimerEnable = 0; //std::cout << "enable IRQ's" << std::endl;
} irqEnable = 1;
if ((currentRegister == 0x29) && (value & 0x3)) { }
//enable IRQ's if (!(value & 0x83)) {
//std::cout << "enable IRQ's" << std::endl; //enable IRQ's
//std::cout << "enable IRQ's" << std::endl;
irqEnable = 0;
_console->GetCpu()->ClearIrqSource(IRQSource::EPSM);
irqATimerEnable = 0;
irqBTimerEnable = 0;
}
} }
break; break;
case 0x3: case 0x3:
@ -141,10 +154,6 @@ private:
}*/ }*/
break; break;
} }
//irqBValue = value;
//std::cout << std::hex << irqBValue << std::endl;
} }
uint32_t getClockFrequency() uint32_t getClockFrequency()
@ -170,13 +179,13 @@ protected:
EPSMSSGAudio::ClockAudio(); EPSMSSGAudio::ClockAudio();
_clock += getClockFrequency() / (double)_console->GetCpu()->GetClockRate(_console->GetModel()); _clock += getClockFrequency() / (double)_console->GetCpu()->GetClockRate(_console->GetModel());
_clockIRQ += (getClockFrequency()*6) / (double)_console->GetCpu()->GetClockRate(_console->GetModel()); _clockIRQ += _console->GetSettings()->GetEPSMClockFrequency() / (double)_console->GetCpu()->GetClockRate(_console->GetModel());
while (_clockIRQ >= _cycleCountIRQ) { while (_clockIRQ >= _cycleCountIRQ) {
_cycleCountIRQ++; _cycleCountIRQ++;
if (irqATimerEnable) { if (irqATimerEnable) {
irqACurrentTimer--; irqACurrentTimer--;
if (!irqACurrentTimer) { if (!irqACurrentTimer) {
irqATimerEnable = 0; irqACurrentTimer++;
_console->GetCpu()->SetIrqSource(IRQSource::EPSM); _console->GetCpu()->SetIrqSource(IRQSource::EPSM);
} }
@ -184,7 +193,7 @@ protected:
if (irqBTimerEnable) { if (irqBTimerEnable) {
irqBCurrentTimer--; irqBCurrentTimer--;
if (!irqBCurrentTimer) { if (!irqBCurrentTimer) {
irqBTimerEnable = 0; irqBCurrentTimer++;
_console->GetCpu()->SetIrqSource(IRQSource::EPSM); _console->GetCpu()->SetIrqSource(IRQSource::EPSM);
} }
@ -202,7 +211,7 @@ protected:
{ {
_clock--; _clock--;
int16_t samples[2]; int16_t samples[4];
OPN2_Clock(&_chip, samples); OPN2_Clock(&_chip, samples);
for (uint8_t x = 0; x < 2; x++) for (uint8_t x = 0; x < 2; x++)
@ -242,6 +251,7 @@ public:
_clock = 0; _clock = 0;
_clockIRQ = 0; _clockIRQ = 0;
irqEnable = 0;
irqATimerEnable = 0; irqATimerEnable = 0;
irqBTimerEnable = 0; irqBTimerEnable = 0;
@ -266,9 +276,9 @@ public:
const uint8_t a1 = !!(writeAddr & 0x2); const uint8_t a1 = !!(writeAddr & 0x2);
if (a0 == 0x0) { writeAddr = 0xC000; } if (a0 == 0x0) { writeAddr = 0xC000; }
if (a0 == 0x1) { writeAddr = 0xE000; } if (a0 == 0x1) { writeAddr = 0xE000; }
if (a1 == 0x0) { EPSMSSGAudio::WriteRegister(writeAddr, value); } if (a1 == 0x0) { EPSMSSGAudio::WriteRegister(writeAddr, writeValue); }
WriteToChip(a0 | (a1 << 1), writeValue); WriteToChip(a0 | (a1 << 1), writeValue);
WriteToChipIRQ(a0 | (a1 << 1), value); WriteToChipIRQ(a0 | (a1 << 1), writeValue);
} }
break; break;
case 0x401c: //0xC000 A0 = 0, A1 = 0 case 0x401c: //0xC000 A0 = 0, A1 = 0

View file

@ -826,6 +826,8 @@ int LuaApi::GetAccessCounters(lua_State *lua)
lua_rawseti(lua, -2, i); lua_rawseti(lua, -2, i);
} }
break; break;
default:
break;
} }
return 1; return 1;

View file

@ -133,7 +133,7 @@ void MemoryManager::Write(uint16_t addr, uint8_t value, MemoryOperationType oper
{ {
if(_console->DebugProcessRamOperation(operationType, addr, value)) { if(_console->DebugProcessRamOperation(operationType, addr, value)) {
_ramWriteHandlers[addr]->WriteRAM(addr, value); _ramWriteHandlers[addr]->WriteRAM(addr, value);
if ((addr == 0x4016) /*| (addr >= 0x401c && addr <= 0x401f)*/) { if (addr == 0x4016) {
_ramWriteHandlers[0xE000]->WriteRAM(addr, value); _ramWriteHandlers[0xE000]->WriteRAM(addr, value);
} }
} }
@ -165,6 +165,7 @@ uint32_t MemoryManager::ToAbsolutePrgAddress(uint16_t ramAddr)
void MemoryManager::StreamState(bool saving) void MemoryManager::StreamState(bool saving)
{ {
(void)saving;
ArrayInfo<uint8_t> internalRam = { _internalRAM, MemoryManager::InternalRAMSize }; ArrayInfo<uint8_t> internalRam = { _internalRAM, MemoryManager::InternalRAMSize };
Stream(internalRam); Stream(internalRam);
} }

View file

@ -58,16 +58,17 @@ public:
{ {
_readCount = 0; _readCount = 0;
_stateBuffer = _stateBuffer =
IsPressed(PartyTap::Buttons::B1) ? 1 : 0 | (IsPressed(PartyTap::Buttons::B1) ? 1 : 0) |
IsPressed(PartyTap::Buttons::B2) ? 2 : 0 | (IsPressed(PartyTap::Buttons::B2) ? 2 : 0) |
IsPressed(PartyTap::Buttons::B3) ? 4 : 0 | (IsPressed(PartyTap::Buttons::B3) ? 4 : 0) |
IsPressed(PartyTap::Buttons::B4) ? 8 : 0 | (IsPressed(PartyTap::Buttons::B4) ? 8 : 0) |
IsPressed(PartyTap::Buttons::B5) ? 16 : 0 | (IsPressed(PartyTap::Buttons::B5) ? 16 : 0) |
IsPressed(PartyTap::Buttons::B6) ? 32 : 0; (IsPressed(PartyTap::Buttons::B6) ? 32 : 0);
} }
void WriteRAM(uint16_t addr, uint8_t value) override void WriteRAM(uint16_t addr, uint8_t value) override
{ {
(void)addr;
StrobeProcessWrite(value); StrobeProcessWrite(value);
} }
}; };

View file

@ -63,7 +63,6 @@ protected:
void UpdateState() void UpdateState()
{ {
MemoryAccessType access = _prgRamEnabled ? MemoryAccessType::ReadWrite : MemoryAccessType::NoAccess;
SetCpuMemoryMapping(0x6000, 0x7FFF, 0, HasBattery() ? PrgMemoryType::SaveRam : PrgMemoryType::WorkRam); SetCpuMemoryMapping(0x6000, 0x7FFF, 0, HasBattery() ? PrgMemoryType::SaveRam : PrgMemoryType::WorkRam);
if(_usingExternalRom) { if(_usingExternalRom) {

View file

@ -533,6 +533,7 @@ namespace Mesen.GUI.Debugger
new List<string> {"func","emu.getState","emu.getState()","","* Table* Current emulation state","Return a table containing information about the state of the CPU, PPU, APU and cartridge."}, new List<string> {"func","emu.getState","emu.getState()","","* Table* Current emulation state","Return a table containing information about the state of the CPU, PPU, APU and cartridge."},
new List<string> {"func","emu.setState","emu.setState(state)","state - *Table* A table containing the state of the emulation to apply.","","Updates the CPU and PPU's state.\nThe* state* parameter must be a table in the same format as the one returned by getState()\nNote: the state of the APU or cartridge cannot be modified by using setState()." }, new List<string> {"func","emu.setState","emu.setState(state)","state - *Table* A table containing the state of the emulation to apply.","","Updates the CPU and PPU's state.\nThe* state* parameter must be a table in the same format as the one returned by getState()\nNote: the state of the APU or cartridge cannot be modified by using setState()." },
new List<string> {"func","emu.breakExecution","emu.breakExecution()","","","Breaks the execution of the game and displays the debugger window."}, new List<string> {"func","emu.breakExecution","emu.breakExecution()","","","Breaks the execution of the game and displays the debugger window."},
new List<string> {"func","emu.stop","emu.stop()","","","Stops execution of the game."},
new List<string> {"func","emu.execute","emu.execute(count, type)","count - *Integer* The number of cycles or instructions to run before breaking\ntype - *Enum* See executeCountType","","Runs the emulator for the specified number of cycles/instructions and then breaks the execution."}, new List<string> {"func","emu.execute","emu.execute(count, type)","count - *Integer* The number of cycles or instructions to run before breaking\ntype - *Enum* See executeCountType","","Runs the emulator for the specified number of cycles/instructions and then breaks the execution."},
new List<string> {"func","emu.reset","emu.reset()","","","Resets the current game."}, new List<string> {"func","emu.reset","emu.reset()","","","Resets the current game."},
new List<string> {"func","emu.resume","emu.resume()","","","Resumes execution after breaking."}, new List<string> {"func","emu.resume","emu.resume()","","","Resumes execution after breaking."},

View file

@ -148,11 +148,13 @@ namespace Mesen.GUI.Forms
private void btnOK_Click(object sender, EventArgs e) private void btnOK_Click(object sender, EventArgs e)
{ {
this.DialogResult = ((Button)sender).DialogResult;
this.Close(); this.Close();
} }
private void btnCancel_Click(object sender, EventArgs e) private void btnCancel_Click(object sender, EventArgs e)
{ {
this.DialogResult = ((Button)sender).DialogResult;
this.Close(); this.Close();
} }
} }

View file

@ -234,7 +234,7 @@ static void fchecksize (LoadState *S, size_t size, const char *tname) {
#define checksize(S,t) fchecksize(S,sizeof(t),#t) #define checksize(S,t) fchecksize(S,sizeof(t),#t)
static void checkHeader (LoadState *S) { static void checkHeader (LoadState *S) {
checkliteral(S, LUA_SIGNATURE + 1, "not a"); /* 1st char already checked */ checkliteral(S, &LUA_SIGNATURE[1], "not a"); /* 1st char already checked */
if (LoadByte(S) != LUAC_VERSION) if (LoadByte(S) != LUAC_VERSION)
error(S, "version mismatch in"); error(S, "version mismatch in");
if (LoadByte(S) != LUAC_FORMAT) if (LoadByte(S) != LUAC_FORMAT)