mirror of
https://github.com/SourMesen/Mesen2.git
synced 2025-04-02 10:21:44 -04:00
NSF - Fixed issues with playback, fixed flickering in UI
This commit is contained in:
parent
ca531837e3
commit
262cd83c6a
6 changed files with 33 additions and 38 deletions
|
@ -79,6 +79,15 @@ void NsfMapper::InitMapper(RomData& romData)
|
|||
if(_nsfHeader.SoundChips & NsfSoundChips::FDS) {
|
||||
AddRegisterRange(0x4040, 0x4092, MemoryOperation::Any);
|
||||
}
|
||||
|
||||
//Reset/IRQ vector
|
||||
AddRegisterRange(0xFFFC, 0xFFFF, MemoryOperation::Read);
|
||||
|
||||
//Set PLAY/INIT addresses in NSF code
|
||||
_nsfBios[0x02] = _nsfHeader.InitAddress & 0xFF;
|
||||
_nsfBios[0x03] = (_nsfHeader.InitAddress >> 8) & 0xFF;
|
||||
_nsfBios[0x14] = _nsfHeader.PlayAddress & 0xFF;
|
||||
_nsfBios[0x15] = (_nsfHeader.PlayAddress >> 8) & 0xFF;
|
||||
}
|
||||
|
||||
void NsfMapper::Reset(bool softReset)
|
||||
|
@ -87,28 +96,12 @@ void NsfMapper::Reset(bool softReset)
|
|||
_songNumber = _nsfHeader.StartingSong - 1;
|
||||
}
|
||||
|
||||
//INIT logic
|
||||
NesMemoryManager* mm = _console->GetMemoryManager();
|
||||
|
||||
//INIT logic
|
||||
|
||||
//Set PLAY/INIT addresses in NSF code
|
||||
_nsfBios[0x02] = _nsfHeader.InitAddress & 0xFF;
|
||||
_nsfBios[0x03] = (_nsfHeader.InitAddress >> 8) & 0xFF;
|
||||
|
||||
_nsfBios[0x05] = _nsfHeader.PlayAddress & 0xFF;
|
||||
_nsfBios[0x06] = (_nsfHeader.PlayAddress >> 8) & 0xFF;
|
||||
_nsfBios[0x14] = _nsfHeader.PlayAddress & 0xFF;
|
||||
_nsfBios[0x15] = (_nsfHeader.PlayAddress >> 8) & 0xFF;
|
||||
|
||||
//Clear internal RAM
|
||||
for(uint16_t i = 0; i < 0x800; i++) {
|
||||
mm->Write(i, 0, MemoryOperationType::Write);
|
||||
}
|
||||
|
||||
//Clear work ram
|
||||
for(uint16_t i = 0x6000; i < 0x7FFF; i++) {
|
||||
mm->Write(i, 0, MemoryOperationType::Write);
|
||||
}
|
||||
//Clear internal + work RAM
|
||||
memset(mm->GetInternalRAM(), 0, NesMemoryManager::InternalRAMSize);
|
||||
memset(GetWorkRam(), 0, GetWorkRamSize());
|
||||
|
||||
//Reset APU
|
||||
for(uint16_t i = 0x4000; i < 0x4013; i++) {
|
||||
|
@ -153,7 +146,7 @@ void NsfMapper::Reset(bool softReset)
|
|||
state.Y = 0;
|
||||
|
||||
_console->GetCpu()->SetIrqMask((uint8_t)IRQSource::External);
|
||||
_irqCounter = GetIrqReloadValue();
|
||||
_irqCounter = 0;
|
||||
|
||||
_allowSilenceDetection = false;
|
||||
_trackEndCounter = -1;
|
||||
|
@ -168,9 +161,6 @@ void NsfMapper::Reset(bool softReset)
|
|||
_sunsoftAudio.reset(new Sunsoft5bAudio(_console));
|
||||
|
||||
InternalSelectTrack(_songNumber);
|
||||
|
||||
//Reset/IRQ vector
|
||||
AddRegisterRange(0xFFFC, 0xFFFF, MemoryOperation::Read);
|
||||
}
|
||||
|
||||
void NsfMapper::GetMemoryRanges(MemoryRanges& ranges)
|
||||
|
@ -285,10 +275,12 @@ void NsfMapper::ProcessCpuClock()
|
|||
}
|
||||
*/
|
||||
|
||||
_irqCounter--;
|
||||
if(_irqCounter == 0) {
|
||||
_irqCounter = GetIrqReloadValue();
|
||||
TriggerIrq();
|
||||
if(_irqCounter > 0) {
|
||||
_irqCounter--;
|
||||
if(_irqCounter == 0) {
|
||||
_irqCounter = GetIrqReloadValue();
|
||||
TriggerIrq();
|
||||
}
|
||||
}
|
||||
|
||||
ClockLengthAndFadeCounters();
|
||||
|
@ -354,7 +346,10 @@ void NsfMapper::WriteRegister(uint16_t addr, uint8_t value)
|
|||
_sunsoftAudio->WriteRegister(addr, value);
|
||||
} else {
|
||||
switch(addr) {
|
||||
case 0x3F00: ClearIrq(); break;
|
||||
case 0x3F00:
|
||||
_irqCounter = GetIrqReloadValue();
|
||||
ClearIrq();
|
||||
break;
|
||||
|
||||
//MMC5 multiplication
|
||||
case 0x5205: _mmc5MultiplierValues[0] = value; break;
|
||||
|
|
|
@ -51,8 +51,8 @@ private:
|
|||
.org $3F00
|
||||
reset:
|
||||
CLI
|
||||
JSR [INIT] ; set at load time
|
||||
JSR [PLAY] ; set at load time
|
||||
JSR [INIT] ;set at load time
|
||||
STA $3F00 ;clear irq
|
||||
loop:
|
||||
JMP loop ;loop forever
|
||||
|
||||
|
@ -64,7 +64,7 @@ private:
|
|||
*/
|
||||
|
||||
uint8_t _nsfBios[0x20] = {
|
||||
0x58,0x20,0x00,0x00,0x20,0x00,0x00,0x4C,0x07,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x58,0x20,0x00,0x00,0x8D,0x00,0x3F,0x4C,0x07,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x8D,0x00,0x3F,0x20,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||
};
|
||||
|
||||
|
|
|
@ -236,7 +236,6 @@ void NesConsole::RunFrame()
|
|||
RunVsSubConsole();
|
||||
}
|
||||
}
|
||||
_emu->ProcessEndOfFrame();
|
||||
}
|
||||
|
||||
void NesConsole::RunVsSubConsole()
|
||||
|
|
|
@ -92,9 +92,6 @@ void NesCpu::Reset(bool softReset, ConsoleRegion region)
|
|||
_dmcDmaRunning = false;
|
||||
_lastCrashWarning = 0;
|
||||
|
||||
//Used by NSF code to disable Frame Counter & DMC interrupts
|
||||
_irqMask = 0xFF;
|
||||
|
||||
//Use _memoryManager->Read() directly to prevent clocking the PPU/APU when setting PC at reset
|
||||
_state.PC = _memoryManager->Read(NesCpu::ResetVector) | _memoryManager->Read(NesCpu::ResetVector+1) << 8;
|
||||
|
||||
|
@ -102,6 +99,9 @@ void NesCpu::Reset(bool softReset, ConsoleRegion region)
|
|||
SetFlags(PSFlags::Interrupt);
|
||||
_state.SP -= 0x03;
|
||||
} else {
|
||||
//Used by NSF code to disable Frame Counter & DMC interrupts
|
||||
_irqMask = 0xFF;
|
||||
|
||||
_state.A = 0;
|
||||
_state.SP = 0xFD;
|
||||
_state.X = 0;
|
||||
|
|
|
@ -1198,6 +1198,7 @@ void NesPpu::SendFrame()
|
|||
UpdateGrayscaleAndIntensifyBits();
|
||||
|
||||
if(_console->IsVsMainConsole()) {
|
||||
_emu->ProcessEndOfFrame();
|
||||
_emu->GetNotificationManager()->SendNotification(ConsoleNotificationType::PpuFrameDone, _currentOutputBuffer);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,10 +56,10 @@ void AudioPlayerHud::Draw()
|
|||
_hud->DrawString(15, 218, std::to_string(trackInfo.TrackNumber) + " / " + std::to_string(trackInfo.TrackCount), 0xFFFFFF, 0, 1);
|
||||
|
||||
if(trackInfo.Length <= 0) {
|
||||
_hud->DrawString(220, 208, position, 0xFFFFFF, 0, 1);
|
||||
_hud->DrawString(215, 208, " " + position + " ", 0xFFFFFF, 0, 1);
|
||||
} else {
|
||||
position += " / " + FormatSeconds(trackInfo.Length);
|
||||
_hud->DrawString(182, 208, position, 0xFFFFFF, 0, 1);
|
||||
_hud->DrawString(177, 208, " " + position + " ", 0xFFFFFF, 0, 1);
|
||||
|
||||
constexpr int barWidth = 222;
|
||||
_hud->DrawRectangle(15, 199, barWidth + 4, 6, 0xBBBBBB, false, 1);
|
||||
|
|
Loading…
Add table
Reference in a new issue