From edcaea006b18b9d048625d8cded3fa4b8ec34a44 Mon Sep 17 00:00:00 2001 From: zilmar Date: Wed, 30 Jun 2010 21:35:44 +0000 Subject: [PATCH] git-svn-id: https://localhost/svn/Project64/trunk@41 111125ac-702d-7242-af9c-5ba8ae61c1ef --- .../Interpreter/Interpreter Ops.cpp | 38 +------------------ Source/Project64/N64 System/Mips/Audio.cpp | 24 ++++++++---- Source/Project64/N64 System/Mips/Audio.h | 2 +- Source/Project64/N64 System/Mips/Dma.cpp | 8 ++-- Source/Project64/N64 System/Mips/FlashRam.cpp | 17 +-------- Source/Project64/N64 System/Mips/FlashRam.h | 1 - .../N64 System/Mips/Memory Virtual Mem.cpp | 6 ++- .../N64 System/Mips/Register Class.cpp | 6 +++ .../N64 System/Mips/Register Class.h | 2 + .../N64 System/Mips/System Timing.cpp | 2 - Source/Project64/Plugins/GFX plugin.cpp | 2 +- Source/Project64/Plugins/RSP Plugin.cpp | 2 +- 12 files changed, 40 insertions(+), 70 deletions(-) diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp index 69daf68f7..0391d9122 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp @@ -722,7 +722,7 @@ void TestInterpreterJump (DWORD PC, DWORD TargetPC, int Reg1, int Reg2) R4300iOp::m_TestTimer = TRUE; } -/************************* m_Opcode functions *************************/ +/************************* Opcode functions *************************/ void R4300iOp::J (void) { m_NextInstruction = DELAY_SLOT; m_JumpToLocation = ((*_PROGRAM_COUNTER) & 0xF0000000) + (m_Opcode.target << 2); @@ -1052,24 +1052,6 @@ void R4300iOp::LW (void) { #endif if (m_Opcode.rt == 0) { return; } -#ifdef toremove - if (Address >= 0xA3F00000 && Address < 0xC0000000) - { - if (Address < 0xA4000000 || Address >= 0xA4002000) - { - Address &= 0x1FFFFFFF; - if (!r4300i_LW_NonMemory(Address,&_GPR[m_Opcode.rt].UW[0])) - { - if (ShowUnhandledMemory) - { - DisplayError("Failed to load word\n\nIn LW",Address); - } - } - _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rt].W[0]; - return; - } - } -#endif if (!_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) { if (g_ShowTLBMisses) { @@ -1189,24 +1171,6 @@ void R4300iOp::SW (void) { #if (!defined(EXTERNAL_RELEASE)) Log_SW((*_PROGRAM_COUNTER),Address,_GPR[m_Opcode.rt].UW[0]); #endif -#ifdef toremove - if (Address >= 0xA3F00000 && Address < 0xC0000000) - { - if (Address < 0xA4000000 || Address >= 0xA4002000) - { - Address &= 0x1FFFFFFF; - if (!r4300i_SW_NonMemory(Address,_GPR[m_Opcode.rt].UW[0])) - { - if (ShowUnhandledMemory) - { - DisplayError("Failed to load word\n\nIn SW",Address); - } - } - return; - } - } -#endif - if (!_MMU->SW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) { if (g_ShowTLBMisses) diff --git a/Source/Project64/N64 System/Mips/Audio.cpp b/Source/Project64/N64 System/Mips/Audio.cpp index 2b6be7441..57c3d25c1 100644 --- a/Source/Project64/N64 System/Mips/Audio.cpp +++ b/Source/Project64/N64 System/Mips/Audio.cpp @@ -14,6 +14,7 @@ void CAudio::Reset ( void ) m_CurrentLength = 0; m_SecondBuff = 0; m_Status = 0; + m_BytesPerSecond = 0; m_CountsPerByte = 500; // should be calculated ... see below m_FramesPerSecond = 60; } @@ -21,6 +22,7 @@ void CAudio::Reset ( void ) DWORD CAudio::GetLength ( void ) { DWORD TimeLeft = _SystemTimer->GetTimer(CSystemTimer::AiTimer); + WriteTraceF(TraceError,"CAudio::GetLength: TimeLeft = %d m_CountsPerByte = %d BytesLeft = %d",TimeLeft,(int)m_CountsPerByte, (int)(TimeLeft / m_CountsPerByte)); if (TimeLeft > 0) { return TimeLeft / m_CountsPerByte; @@ -40,6 +42,7 @@ void CAudio::LenChanged ( void ) return; } + WriteTraceF(TraceError,"CAudio::LenChanged: m_CurrentLength = %d AI_LEN_REG = %d m_CountsPerByte = %d",m_CurrentLength,_Reg->AI_LEN_REG,(int)m_CountsPerByte); if (m_CurrentLength == 0) { m_CurrentLength = _Reg->AI_LEN_REG; _SystemTimer->SetTimer(CSystemTimer::AiTimer,m_CurrentLength * m_CountsPerByte,false); @@ -55,8 +58,13 @@ void CAudio::LenChanged ( void ) void CAudio::TimerDone ( void ) { + WriteTraceF(TraceError,"CAudio::TimerDone: m_SecondBuff = %d",m_SecondBuff); + + _Reg->MI_INTR_REG |= MI_INTR_AI; + _Reg->CheckInterrupts(); + if (m_SecondBuff != 0) { - _SystemTimer->SetTimer(CSystemTimer::AiTimer,m_SecondBuff * m_CountsPerByte,true); + _SystemTimer->SetTimer(CSystemTimer::AiTimer,m_SecondBuff * m_CountsPerByte,false); } m_CurrentLength = m_SecondBuff; m_SecondBuff = 0; @@ -65,18 +73,20 @@ void CAudio::TimerDone ( void ) void CAudio::SetViIntr ( DWORD VI_INTR_TIME ) { + WriteTraceF(TraceError,"CAudio::SetViIntr: VI_INTR_TIME = %d",VI_INTR_TIME); + double CountsPerSecond = (DWORD)((double)VI_INTR_TIME * m_FramesPerSecond); - m_CountsPerByte = (double)CountsPerSecond / (double)m_BytesPerSecond; - //m_CountsPerByte = 490; // donkey kong - //m_CountsPerByte = 100; // Paper mario - //m_CountsPerByte = 490; // Paper mario - + if (m_BytesPerSecond != 0) + { + //m_CountsPerByte = (double)CountsPerSecond / (double)m_BytesPerSecond; + } } void CAudio::SetFrequency (DWORD Dacrate, DWORD System) { - + WriteTraceF(TraceError,"CAudio::SetFrequency: Dacrate = %d System = %d",Dacrate,System); + DWORD Frequency; switch (System) { diff --git a/Source/Project64/N64 System/Mips/Audio.h b/Source/Project64/N64 System/Mips/Audio.h index 12a3956c2..dca317c5c 100644 --- a/Source/Project64/N64 System/Mips/Audio.h +++ b/Source/Project64/N64 System/Mips/Audio.h @@ -20,7 +20,7 @@ private: DWORD m_SecondBuff; DWORD m_Status; DWORD m_BytesPerSecond; - double m_CountsPerByte; + int m_CountsPerByte; int m_FramesPerSecond; /* float m_VSyncTiming; diff --git a/Source/Project64/N64 System/Mips/Dma.cpp b/Source/Project64/N64 System/Mips/Dma.cpp index 552b5ddf5..5dbc29e47 100644 --- a/Source/Project64/N64 System/Mips/Dma.cpp +++ b/Source/Project64/N64 System/Mips/Dma.cpp @@ -55,10 +55,9 @@ void CDMA::PI_DMA_READ (void) { return; } } - if (g_SaveUsing == SaveChip_FlashRam) { -#ifndef EXTERNAL_RELEASE + if (g_SaveUsing == SaveChip_FlashRam) + { DisplayError("**** FLashRam DMA Read address %X *****",_Reg->PI_CART_ADDR_REG); -#endif _Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; _Reg->MI_INTR_REG |= MI_INTR_PI; _Reg->CheckInterrupts(); @@ -111,7 +110,8 @@ void CDMA::PI_DMA_WRITE (void) { return; } - if ( _Reg->PI_CART_ADDR_REG >= 0x10000000 && _Reg->PI_CART_ADDR_REG <= 0x1FBFFFFF) { + if ( _Reg->PI_CART_ADDR_REG >= 0x10000000 && _Reg->PI_CART_ADDR_REG <= 0x1FBFFFFF) + { DWORD i; #ifdef tofix #ifdef ROM_IN_MAPSPACE diff --git a/Source/Project64/N64 System/Mips/FlashRam.cpp b/Source/Project64/N64 System/Mips/FlashRam.cpp index 87c8d20d1..d2a0edfda 100644 --- a/Source/Project64/N64 System/Mips/FlashRam.cpp +++ b/Source/Project64/N64 System/Mips/FlashRam.cpp @@ -89,7 +89,8 @@ void CFlashram::DmaToFlashram(BYTE * Source, int StartOffset, int len) { } } -DWORD CFlashram::ReadFlashStatus (DWORD PAddr) + +DWORD CFlashram::ReadFromFlashStatus (DWORD PAddr) { switch (PAddr) { case 0x08000000: return (DWORD)(m_FlashStatus >> 32); @@ -205,17 +206,3 @@ void CFlashram::WriteToFlashCommand(DWORD FlashRAM_Command) { #endif } } - -DWORD CFlashram::ReadFromFlashStatus (DWORD PAddr) -{ - switch (PAddr) { - case 0x08000000: return (DWORD)(m_FlashStatus >> 32); - default: -#ifndef EXTERNAL_RELEASE - DisplayError("Reading from flash ram status (%X)",PAddr); -#endif - break; - } - return (DWORD)(m_FlashStatus >> 32); -} - diff --git a/Source/Project64/N64 System/Mips/FlashRam.h b/Source/Project64/N64 System/Mips/FlashRam.h index 2c3d94732..1d4e37466 100644 --- a/Source/Project64/N64 System/Mips/FlashRam.h +++ b/Source/Project64/N64 System/Mips/FlashRam.h @@ -18,7 +18,6 @@ public: void WriteToFlashCommand ( DWORD Value ); private: - DWORD ReadFlashStatus ( DWORD PAddr ); bool LoadFlashram ( void ); BYTE * m_FlashRamPointer; diff --git a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp index c342a417b..e41ef2902 100644 --- a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp +++ b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp @@ -764,6 +764,7 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) { } if ( ( Value & MI_CLR_DP_INTR ) != 0 ) { AndConstToVariable(~MI_INTR_DP,&_Reg->MI_INTR_REG,"MI_INTR_REG"); + AndConstToVariable(~MI_INTR_DP,&_Reg->m_GfxIntrReg,"m_GfxIntrReg"); } } break; @@ -1978,6 +1979,7 @@ int CMipsMemoryVM::SW_NonMemory ( DWORD PAddr, DWORD Value ) { if ( ( Value & SP_CLR_BROKE ) != 0) { _Reg->SP_STATUS_REG &= ~SP_STATUS_BROKE; } if ( ( Value & SP_CLR_INTR ) != 0) { _Reg->MI_INTR_REG &= ~MI_INTR_SP; + _Reg->m_RspIntrReg &= ~MI_INTR_SP; _Reg->CheckInterrupts(); } #ifndef EXTERNAL_RELEASE @@ -2076,6 +2078,7 @@ int CMipsMemoryVM::SW_NonMemory ( DWORD PAddr, DWORD Value ) { if ( ( Value & MI_SET_EBUS ) != 0 ) { _Reg->MI_MODE_REG |= MI_MODE_EBUS; } if ( ( Value & MI_CLR_DP_INTR ) != 0 ) { _Reg->MI_INTR_REG &= ~MI_INTR_DP; + _Reg->m_GfxIntrReg &= ~MI_INTR_DP; _Reg->CheckInterrupts(); } if ( ( Value & MI_CLR_RDRAM ) != 0 ) { _Reg->MI_MODE_REG &= ~MI_MODE_RDRAM; } @@ -2238,7 +2241,7 @@ int CMipsMemoryVM::SW_NonMemory ( DWORD PAddr, DWORD Value ) { if (g_SaveUsing == SaveChip_Auto) { g_SaveUsing = SaveChip_FlashRam; } if (g_SaveUsing != SaveChip_FlashRam) { return TRUE; } WriteToFlashCommand(Value); - return FALSE; + return TRUE; break; case 0x1FC00000: if (PAddr < 0x1FC007C0) { @@ -3776,6 +3779,7 @@ void CMipsMemoryVM::ChangeSpStatus (void) if ( ( RegModValue & SP_CLR_BROKE ) != 0) { _Reg->SP_STATUS_REG &= ~SP_STATUS_BROKE; } if ( ( RegModValue & SP_CLR_INTR ) != 0) { _Reg->MI_INTR_REG &= ~MI_INTR_SP; + _Reg->m_RspIntrReg &= ~MI_INTR_SP; _Reg->CheckInterrupts(); } #ifndef EXTERNAL_RELEASE diff --git a/Source/Project64/N64 System/Mips/Register Class.cpp b/Source/Project64/N64 System/Mips/Register Class.cpp index 424c58877..d14a8bc65 100644 --- a/Source/Project64/N64 System/Mips/Register Class.cpp +++ b/Source/Project64/N64 System/Mips/Register Class.cpp @@ -240,6 +240,10 @@ void CRegisters::Reset() memset(m_Peripheral_Interface,0,sizeof(m_Peripheral_Interface)); memset(m_SerialInterface,0,sizeof(m_SerialInterface)); + m_AudioIntrReg = 0; + m_GfxIntrReg = 0; + m_RspIntrReg = 0; + FixFpuLocations(); } @@ -264,6 +268,8 @@ void CRegisters::CheckInterrupts ( void ) MI_INTR_REG &= ~MI_INTR_AI; MI_INTR_REG |= (m_AudioIntrReg & MI_INTR_AI); } + MI_INTR_REG |= (m_RspIntrReg & MI_INTR_SP); + MI_INTR_REG |= (m_GfxIntrReg & MI_INTR_DP); if ((MI_INTR_MASK_REG & MI_INTR_REG) != 0) { FAKE_CAUSE_REGISTER |= CAUSE_IP2; } else { diff --git a/Source/Project64/N64 System/Mips/Register Class.h b/Source/Project64/N64 System/Mips/Register Class.h index 112e043f6..cc1737872 100644 --- a/Source/Project64/N64 System/Mips/Register Class.h +++ b/Source/Project64/N64 System/Mips/Register Class.h @@ -502,6 +502,8 @@ public: DWORD m_RDRAM_Interface[8]; DWORD m_SerialInterface[4]; DWORD m_AudioIntrReg; + DWORD m_GfxIntrReg; + DWORD m_RspIntrReg; void CheckInterrupts ( void ); diff --git a/Source/Project64/N64 System/Mips/System Timing.cpp b/Source/Project64/N64 System/Mips/System Timing.cpp index 378b16e53..81df53aea 100644 --- a/Source/Project64/N64 System/Mips/System Timing.cpp +++ b/Source/Project64/N64 System/Mips/System Timing.cpp @@ -184,8 +184,6 @@ void CSystemTimer::TimerDone (void) break; case CSystemTimer::AiTimer: _SystemTimer->StopTimer(CSystemTimer::AiTimer); - _Reg->MI_INTR_REG |= MI_INTR_AI; - _Reg->CheckInterrupts(); _Audio->TimerDone(); break; default: diff --git a/Source/Project64/Plugins/GFX plugin.cpp b/Source/Project64/Plugins/GFX plugin.cpp index 527bdc51e..e07b0e02f 100644 --- a/Source/Project64/Plugins/GFX plugin.cpp +++ b/Source/Project64/Plugins/GFX plugin.cpp @@ -226,7 +226,7 @@ bool CGfxPlugin::Initiate ( CN64System * System, CMainGui * RenderWindow ) { Info.RDRAM = _MMU->Rdram(); Info.DMEM = _MMU->Dmem(); Info.IMEM = _MMU->Imem(); - Info.MI__INTR_REG = &_Reg->MI_INTR_REG; + Info.MI__INTR_REG = &_Reg->m_GfxIntrReg; Info.DPC__START_REG = &_Reg->DPC_START_REG; Info.DPC__END_REG = &_Reg->DPC_END_REG; Info.DPC__CURRENT_REG = &_Reg->DPC_CURRENT_REG; diff --git a/Source/Project64/Plugins/RSP Plugin.cpp b/Source/Project64/Plugins/RSP Plugin.cpp index 648f0b4e5..c22c91fee 100644 --- a/Source/Project64/Plugins/RSP Plugin.cpp +++ b/Source/Project64/Plugins/RSP Plugin.cpp @@ -240,7 +240,7 @@ bool CRSP_Plugin::Initiate ( CPlugins * Plugins, CN64System * System ) Info.IMEM = _MMU->Imem(); Info.MemoryBswaped = FALSE; - Info.MI__INTR_REG = &_Reg->MI_INTR_REG; + Info.MI__INTR_REG = &_Reg->m_RspIntrReg; Info.SP__MEM_ADDR_REG = &_Reg->SP_MEM_ADDR_REG; Info.SP__DRAM_ADDR_REG = &_Reg->SP_DRAM_ADDR_REG;