From 72c7c2ffd1bc34b016dc3644919d7cfad0ae9c0d Mon Sep 17 00:00:00 2001 From: Frank-74 Date: Fri, 29 Sep 2017 00:52:28 +0100 Subject: [PATCH 1/9] Fix Volume --- Source/Project64-audio/Driver/DirectSound.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Source/Project64-audio/Driver/DirectSound.cpp b/Source/Project64-audio/Driver/DirectSound.cpp index 19d2df018..d57464af1 100644 --- a/Source/Project64-audio/Driver/DirectSound.cpp +++ b/Source/Project64-audio/Driver/DirectSound.cpp @@ -132,10 +132,16 @@ void DirectSoundDriver::SetFrequency(uint32_t Frequency) void DirectSoundDriver::SetVolume(uint32_t Volume) { - /*DWORD dsVolume = ((DWORD)Volume * -25); - if (Volume == 100) dsVolume = (DWORD)DSBVOLUME_MIN; - if (Volume == 0) dsVolume = DSBVOLUME_MAX; - if (lpdsb != NULL) lpdsb->SetVolume(dsVolume);*/ + LPDIRECTSOUNDBUFFER & lpdsb = (LPDIRECTSOUNDBUFFER &)m_lpdsb; + int32_t dsVolume = - 10 ^ ((100 - Volume) * 33); + if (Volume == 0) + { + dsVolume = DSBVOLUME_MIN; + } + if (lpdsb != NULL) + { + lpdsb->SetVolume(dsVolume); + } } void DirectSoundDriver::SetSegmentSize(uint32_t length, uint32_t SampleRate) @@ -278,4 +284,4 @@ void DirectSoundDriver::AudioThreadProc() lpdsbuf->Stop(); } WriteTrace(TraceAudioDriver, TraceDebug, "Audio Thread Terminated..."); -} \ No newline at end of file +} From b5c8a0f4c546b0f0660f6ce504493611d7128931 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sun, 1 Oct 2017 07:09:17 +1100 Subject: [PATCH 2/9] [Cheats] Clear extra code --- Source/Project64-core/N64System/CheatClass.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Project64-core/N64System/CheatClass.cpp b/Source/Project64-core/N64System/CheatClass.cpp index 7d4e5d933..61d433a9f 100644 --- a/Source/Project64-core/N64System/CheatClass.cpp +++ b/Source/Project64-core/N64System/CheatClass.cpp @@ -354,7 +354,7 @@ void CCheats::ModifyMemory8(uint32_t Address, uint8_t Value) m_MMU.SB_VAddr(Address, OriginalValue.Changed); if (g_Recompiler) { - g_Recompiler->ClearRecompCode_Virt(Address, 1, CRecompiler::Remove_Cheats); + g_Recompiler->ClearRecompCode_Virt(Address & ~0xFFF, 0x1000, CRecompiler::Remove_Cheats); } } @@ -374,7 +374,7 @@ void CCheats::ModifyMemory16(uint32_t Address, uint16_t Value) m_MMU.SH_VAddr(Address, OriginalValue.Changed); if (g_Recompiler) { - g_Recompiler->ClearRecompCode_Virt(Address, 2, CRecompiler::Remove_Cheats); + g_Recompiler->ClearRecompCode_Virt(Address & ~0xFFF, 0x1000, CRecompiler::Remove_Cheats); } } From 1a13c877618a64216d8fbaa904c11e38e2cd14af Mon Sep 17 00:00:00 2001 From: Enker Date: Sat, 14 Oct 2017 14:30:36 -0400 Subject: [PATCH 3/9] [RDB] Add CF=1 to Pokemon Snap --- Config/Project64.rdb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Config/Project64.rdb b/Config/Project64.rdb index c3140380c..37f75c2bb 100644 --- a/Config/Project64.rdb +++ b/Config/Project64.rdb @@ -2478,6 +2478,7 @@ Status=Compatible Good Name=Ide Yousuke no Mahjong Juku (J) Internal Name=²ÃÞÖ³½¹ÉÏ°¼Þ¬Ý¼Þ­¸ Status=Compatible +Save Type=16kbit Eeprom [D692CC5E-EC58D072-C:50] Good Name=Iggy's Reckin' Balls (E) @@ -3134,7 +3135,6 @@ Internal Name=Madden NFL 2002 Status=Compatible Counter Factor=1 RDRAM Size=8 -Save Type=16kbit Eeprom [3925D625-8C83C75E-C:50] Good Name=Madden NFL 99 (E) @@ -4311,6 +4311,7 @@ Good Name=Pokemon Snap (A) Internal Name=POKEMON SNAP Status=Issues (plugin) Plugin Note= broken; needs accurate FB emu +Counter Factor=1 Cheat0=D1382D1C 802C,80382D0F 0000 //Pass 1st Level and Controller Fix Cheat1=D11E3C44 2881,811E3C44 2001,D11E3C46 0098,811E3C46 0001 //Make Picture selectable CheatPlugin0=Jabo's Direct3D8,Glide64 For PJ64 @@ -4321,6 +4322,7 @@ Good Name=Pokemon Snap (E) Internal Name=POKEMON SNAP Status=Issues (plugin) Plugin Note= broken; needs accurate FB emu +Counter Factor=1 Cheat0=D1381BFC 802C,80381BEF 0000 //Pass 1st Level and Controller Fix Cheat1=D11E3824 2881,811E3824 2001,D11E3826 0098,811E3826 0001 //Make Picture selectable CheatPlugin0=Jabo's Direct3D8,Glide64 For PJ64 @@ -4331,6 +4333,7 @@ Good Name=Pokemon Snap (F) Internal Name=POKEMON SNAP Status=Issues (plugin) Plugin Note= broken; needs accurate FB emu +Counter Factor=1 Cheat0=D1381BFC 802C,80381BEF 0000 //Pass 1st Level and Controller Fix Cheat1=D11E3744 2881,811E3744 2001,D11E3746 0098,811E3746 0001 //Make Picture selectable CheatPlugin0=Jabo's Direct3D8,Glide64 For PJ64 @@ -4341,6 +4344,7 @@ Good Name=Pokemon Snap (G) Internal Name=POKEMON SNAP Status=Issues (plugin) Plugin Note= broken; needs accurate FB emu +Counter Factor=1 Cheat0=D1381BDC 802C,80381BCF 0000 //Pass 1st Level and Controller Fix Cheat1=D11E3744 2881,811E3744 2001,D11E3746 0098,811E3746 0001 //Make Picture selectable CheatPlugin0=Jabo's Direct3D8,Glide64 For PJ64 @@ -4351,6 +4355,7 @@ Good Name=Pokemon Snap (I) Internal Name=POKEMON SNAP Status=Issues (plugin) Plugin Note= broken; needs accurate FB emu +Counter Factor=1 Cheat0=D1381BFC 802C,80381BEF 0000 //Pass 1st Level and Controller Fix Cheat1=D11E3994 2881,811E3994 2001,D11E3996 0098,811E3996 0001 //Make Picture selectable CheatPlugin0=Jabo's Direct3D8,Glide64 For PJ64 @@ -4361,6 +4366,7 @@ Good Name=Pokemon Snap (J) (V1.0) Internal Name=POKEMON SNAP Status=Issues (plugin) Plugin Note= broken; needs accurate FB emu +Counter Factor=1 Cheat0=D136D22C 802A,8036D21F 0000 //Pass 1st Level and Controller Fix Cheat1=D11E1EC4 2881,811E1EC4 2001,D11E1EC6 0098,811E1EC6 0001 //Make Picture selectable CheatPlugin0=Jabo's Direct3D8,Glide64 For PJ64 @@ -4371,6 +4377,7 @@ Good Name=Pokemon Snap (J) (V1.1) Internal Name=POKEMON SNAP Status=Issues (plugin) Plugin Note= broken; needs accurate FB emu +Counter Factor=1 Cheat0=D136D22C 802A,8036D21F 0000 //Pass 1st Level and Controller Fix Cheat1=D11E1EC4 2881,811E1EC4 2001,D11E1EC6 0098,811E1EC6 0001 //Make Picture selectable CheatPlugin0=Jabo's Direct3D8,Glide64 For PJ64 @@ -4381,6 +4388,7 @@ Good Name=Pokemon Snap (S) Internal Name=POKEMON SNAP Status=Issues (plugin) Plugin Note= broken; needs accurate FB emu +Counter Factor=1 Cheat0=D1381BFC 802C,80381BEF 0000 //Pass 1st Level and Controller Fix Cheat1=D11E38C4 2881,811E38C4 2001,D11E38C6 0098,811E38C6 0001 //Make Picture selectable CheatPlugin0=Jabo's Direct3D8,Glide64 For PJ64 @@ -4391,6 +4399,7 @@ Good Name=Pokemon Snap (U) Internal Name=POKEMON SNAP Status=Issues (plugin) Plugin Note= broken; needs accurate FB emu +Counter Factor=1 Cheat0=D1382D1C 802C,80382D0F 0000 //Pass 1st Level and Controller Fix Cheat1=D11E3184 2881,811E3184 2001,D11E3186 0098,811E3186 0001 //Make Picture selectable CheatPlugin0=Jabo's Direct3D8,Glide64 For PJ64 @@ -4401,6 +4410,7 @@ Good Name=Pokemon Snap Station (U) Internal Name=POKEMON SNAP Status=Issues (plugin) Plugin Note= broken; needs accurate FB emu +Counter Factor=1 Cheat0=D1382D1C 802C,80382D0F 0000 //Pass 1st Level and Controller Fix Cheat1=D11E30F4 2881,811E30F4 2001,D11E30F6 0098,811E30F6 0001 //Make Picture selectable CheatPlugin0=Jabo's Direct3D8,Glide64 For PJ64 From 23c1007aa04322def05cf80a37e8c2ff0b98d0d9 Mon Sep 17 00:00:00 2001 From: Azimer Date: Tue, 17 Oct 2017 21:38:38 -0500 Subject: [PATCH 4/9] Randomize PI and SI DMA timing This should help with randomization while FAT is on. --- Source/Project64-core/3rdParty/Random.cpp | 48 +++++++++++++++++++ Source/Project64-core/3rdParty/Random.h | 31 ++++++++++++ Source/Project64-core/N64System/Mips/Dma.cpp | 8 ++-- .../Project64-core/N64System/Mips/PifRam.cpp | 9 ++-- Source/Project64-core/N64System/N64Class.cpp | 3 ++ Source/Project64-core/N64System/N64Class.h | 2 + .../Project64-core/N64System/SystemGlobals.h | 5 +- Source/Project64-core/Project64-core.vcxproj | 2 + .../Project64-core.vcxproj.filters | 6 +++ 9 files changed, 106 insertions(+), 8 deletions(-) create mode 100644 Source/Project64-core/3rdParty/Random.cpp create mode 100644 Source/Project64-core/3rdParty/Random.h diff --git a/Source/Project64-core/3rdParty/Random.cpp b/Source/Project64-core/3rdParty/Random.cpp new file mode 100644 index 000000000..3209cf6db --- /dev/null +++ b/Source/Project64-core/3rdParty/Random.cpp @@ -0,0 +1,48 @@ +/**************************************************************************** +* * +* Project64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +/* + * Implements the CRandom class. + * + * This class implements the Lehmer Random Number Generator. + * + */ + +#include "Random.h" +#include + +CRandom::CRandom() +{ + state = (uint32_t)time(NULL); +} + +CRandom::CRandom(uint32_t seed_value) +{ + state = seed_value; +} + +uint32_t randomizer(uint32_t val) +{ + return ((uint64_t)val * 279470273UL) % 4294967291UL; +} + +uint32_t CRandom::next() +{ + state = randomizer(state); + return state; +} + +void CRandom::seed(uint32_t seed_value) +{ + if (seed_value == 0) + state == 1; + else + state = seed_value; +} diff --git a/Source/Project64-core/3rdParty/Random.h b/Source/Project64-core/3rdParty/Random.h new file mode 100644 index 000000000..439f06a7f --- /dev/null +++ b/Source/Project64-core/3rdParty/Random.h @@ -0,0 +1,31 @@ +/**************************************************************************** +* * +* Project64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +/* + * Defines the CRandom class. + * + * This class implements the Lehmer Random Number Generator. + * + */ + +#include + +class CRandom +{ +public: + CRandom(); + CRandom(uint32_t seed_value); + uint32_t next(); + void seed(uint32_t seed_value); + +protected: + uint32_t randomizer(uint32_t val); + uint32_t state; +}; diff --git a/Source/Project64-core/N64System/Mips/Dma.cpp b/Source/Project64-core/N64System/Mips/Dma.cpp index abfa03ab3..b5eb0ad54 100644 --- a/Source/Project64-core/N64System/Mips/Dma.cpp +++ b/Source/Project64-core/N64System/Mips/Dma.cpp @@ -458,9 +458,11 @@ void CDMA::PI_DMA_WRITE() { g_Recompiler->ClearRecompCode_Phys(g_Reg->PI_DRAM_ADDR_REG, g_Reg->PI_WR_LEN_REG, CRecompiler::Remove_DMA); } - g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; - g_Reg->MI_INTR_REG |= MI_INTR_PI; - g_Reg->CheckInterrupts(); + g_SystemTimer->SetTimer(g_SystemTimer->PiTimer, PI_WR_LEN_REG/8 + (g_Random->next() % 0x40), false); + + //g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; + //g_Reg->MI_INTR_REG |= MI_INTR_PI; + //g_Reg->CheckInterrupts(); //ChangeTimer(PiTimer,(int32_t)(PI_WR_LEN_REG * 8.9) + 50); //ChangeTimer(PiTimer,(int32_t)(PI_WR_LEN_REG * 8.9)); return; diff --git a/Source/Project64-core/N64System/Mips/PifRam.cpp b/Source/Project64-core/N64System/Mips/PifRam.cpp index 8b4ba49d7..9583070f4 100644 --- a/Source/Project64-core/N64System/Mips/PifRam.cpp +++ b/Source/Project64-core/N64System/Mips/PifRam.cpp @@ -358,13 +358,14 @@ void CPifRam::SI_DMA_READ() if (g_System->bDelaySI()) { - g_SystemTimer->SetTimer(CSystemTimer::SiTimer, 0x900, false); + g_SystemTimer->SetTimer(CSystemTimer::SiTimer, 0x900 + (g_Random->next() % 0x40), false); } else { - g_Reg->MI_INTR_REG |= MI_INTR_SI; - g_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT; - g_Reg->CheckInterrupts(); + g_SystemTimer->SetTimer(CSystemTimer::SiTimer, g_Random->next() % 0x40, false); + //g_Reg->MI_INTR_REG |= MI_INTR_SI; + //g_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT; + //g_Reg->CheckInterrupts(); } } diff --git a/Source/Project64-core/N64System/N64Class.cpp b/Source/Project64-core/N64System/N64Class.cpp index 2f56f5221..ac275402d 100644 --- a/Source/Project64-core/N64System/N64Class.cpp +++ b/Source/Project64-core/N64System/N64Class.cpp @@ -716,6 +716,7 @@ void CN64System::Reset(bool bInitReg, bool ClearMenory) m_SyncCPU->Reset(bInitReg, ClearMenory); } g_Settings->SaveBool(GameRunning_InReset, true); + WriteTrace(TraceN64System, TraceDebug, "Done"); } @@ -763,6 +764,7 @@ bool CN64System::SetActiveSystem(bool bActive) R4300iOp::m_TestTimer = m_TestTimer; R4300iOp::m_NextInstruction = m_NextInstruction; R4300iOp::m_JumpToLocation = m_JumpToLocation; + g_Random = &m_Random; } else { @@ -782,6 +784,7 @@ bool CN64System::SetActiveSystem(bool bActive) g_Plugins = m_Plugins; g_TLBLoadAddress = NULL; g_TLBStoreAddress = NULL; + g_Random = NULL; } } diff --git a/Source/Project64-core/N64System/N64Class.h b/Source/Project64-core/N64System/N64Class.h index 63d04d1b7..c4326b01c 100644 --- a/Source/Project64-core/N64System/N64Class.h +++ b/Source/Project64-core/N64System/N64Class.h @@ -23,6 +23,7 @@ #include #include #include +#include #include "Mips/TLBClass.h" #include "CheatClass.h" @@ -164,6 +165,7 @@ private: uint32_t m_SyncCount; bool m_SyncCpu; bool m_CheatsSlectionChanged; + CRandom m_Random; //When Syncing cores this is the PC where it last Sync'ed correctly uint32_t m_LastSuccessSyncPC[10]; diff --git a/Source/Project64-core/N64System/SystemGlobals.h b/Source/Project64-core/N64System/SystemGlobals.h index 3ebbff683..b1bfd0521 100644 --- a/Source/Project64-core/N64System/SystemGlobals.h +++ b/Source/Project64-core/N64System/SystemGlobals.h @@ -62,4 +62,7 @@ extern CDebugger * g_Debugger; extern uint8_t ** g_RecompPos; class CMempak; -extern CMempak * g_Mempak; \ No newline at end of file +extern CMempak * g_Mempak; + +class CRandom; +extern CRandom * g_Random; diff --git a/Source/Project64-core/Project64-core.vcxproj b/Source/Project64-core/Project64-core.vcxproj index 412d6fedc..9cbfef092 100644 --- a/Source/Project64-core/Project64-core.vcxproj +++ b/Source/Project64-core/Project64-core.vcxproj @@ -35,6 +35,7 @@ NotUsing + @@ -126,6 +127,7 @@ + diff --git a/Source/Project64-core/Project64-core.vcxproj.filters b/Source/Project64-core/Project64-core.vcxproj.filters index f3f9f6b9b..44f537ba3 100644 --- a/Source/Project64-core/Project64-core.vcxproj.filters +++ b/Source/Project64-core/Project64-core.vcxproj.filters @@ -339,6 +339,9 @@ Source Files\N64 System\Recompiler\Arm + + Source Files\3rd Party + @@ -659,6 +662,9 @@ Header Files + + Header Files\3rd Party + From 1b8d0324175a2e7a4ab17655c7771c8f82c6b069 Mon Sep 17 00:00:00 2001 From: Azimer Date: Tue, 17 Oct 2017 22:52:07 -0500 Subject: [PATCH 5/9] Bug fixes and requests * Moved to CRandom to Common lib * Initialized CRandom with a time seed in CN64System constructor * Added CRandom::state getters and setters to support saved states --- Source/Common/Common.vcxproj | 2 ++ Source/Common/Common.vcxproj.filters | 6 ++++++ .../3rdParty => Common}/Random.cpp | 20 ++++++++++++------- .../3rdParty => Common}/Random.h | 5 +++-- Source/Project64-core/N64System/N64Class.cpp | 3 ++- Source/Project64-core/N64System/N64Class.h | 2 +- .../N64System/SystemGlobals.cpp | 1 + Source/Project64-core/Project64-core.vcxproj | 2 -- .../Project64-core.vcxproj.filters | 6 ------ 9 files changed, 28 insertions(+), 19 deletions(-) rename Source/{Project64-core/3rdParty => Common}/Random.cpp (79%) rename Source/{Project64-core/3rdParty => Common}/Random.h (93%) diff --git a/Source/Common/Common.vcxproj b/Source/Common/Common.vcxproj index 4ce014430..e8ba6cbe8 100644 --- a/Source/Common/Common.vcxproj +++ b/Source/Common/Common.vcxproj @@ -43,6 +43,7 @@ + Create @@ -64,6 +65,7 @@ + diff --git a/Source/Common/Common.vcxproj.filters b/Source/Common/Common.vcxproj.filters index 437d0328f..69caab164 100644 --- a/Source/Common/Common.vcxproj.filters +++ b/Source/Common/Common.vcxproj.filters @@ -62,6 +62,9 @@ Source Files + + Source Files + @@ -124,5 +127,8 @@ Header Files + + Header Files + \ No newline at end of file diff --git a/Source/Project64-core/3rdParty/Random.cpp b/Source/Common/Random.cpp similarity index 79% rename from Source/Project64-core/3rdParty/Random.cpp rename to Source/Common/Random.cpp index 3209cf6db..a46f8887c 100644 --- a/Source/Project64-core/3rdParty/Random.cpp +++ b/Source/Common/Random.cpp @@ -15,6 +15,7 @@ * */ +#include "stdafx.h" #include "Random.h" #include @@ -23,12 +24,12 @@ CRandom::CRandom() state = (uint32_t)time(NULL); } -CRandom::CRandom(uint32_t seed_value) +CRandom::CRandom(uint32_t state_value) { - state = seed_value; + state = state_value; } -uint32_t randomizer(uint32_t val) +uint32_t CRandom::randomizer(uint32_t val) { return ((uint64_t)val * 279470273UL) % 4294967291UL; } @@ -39,10 +40,15 @@ uint32_t CRandom::next() return state; } -void CRandom::seed(uint32_t seed_value) +void CRandom::set_state(uint32_t state_value) { - if (seed_value == 0) - state == 1; + if (state_value == 0) + state = 1; else - state = seed_value; + state = state_value; +} + +uint32_t CRandom::get_state() +{ + return state; } diff --git a/Source/Project64-core/3rdParty/Random.h b/Source/Common/Random.h similarity index 93% rename from Source/Project64-core/3rdParty/Random.h rename to Source/Common/Random.h index 439f06a7f..1a599a47c 100644 --- a/Source/Project64-core/3rdParty/Random.h +++ b/Source/Common/Random.h @@ -14,7 +14,7 @@ * This class implements the Lehmer Random Number Generator. * */ - +#pragma once #include class CRandom @@ -23,7 +23,8 @@ public: CRandom(); CRandom(uint32_t seed_value); uint32_t next(); - void seed(uint32_t seed_value); + uint32_t get_state(); + void set_state(uint32_t state_value); protected: uint32_t randomizer(uint32_t val); diff --git a/Source/Project64-core/N64System/N64Class.cpp b/Source/Project64-core/N64System/N64Class.cpp index ac275402d..c2d649ee9 100644 --- a/Source/Project64-core/N64System/N64Class.cpp +++ b/Source/Project64-core/N64System/N64Class.cpp @@ -57,7 +57,8 @@ CN64System::CN64System(CPlugins * Plugins, bool SavesReadOnly, bool SyncSystem) m_thread(NULL), m_hPauseEvent(true), m_CheatsSlectionChanged(false), - m_SyncCpu(SyncSystem) + m_SyncCpu(SyncSystem), + m_Random((uint32_t)time(NULL)) { WriteTrace(TraceN64System, TraceDebug, "Start"); memset(m_LastSuccessSyncPC, 0, sizeof(m_LastSuccessSyncPC)); diff --git a/Source/Project64-core/N64System/N64Class.h b/Source/Project64-core/N64System/N64Class.h index c4326b01c..85ae9796c 100644 --- a/Source/Project64-core/N64System/N64Class.h +++ b/Source/Project64-core/N64System/N64Class.h @@ -10,6 +10,7 @@ ****************************************************************************/ #pragma once +#include #include #include #include @@ -23,7 +24,6 @@ #include #include #include -#include #include "Mips/TLBClass.h" #include "CheatClass.h" diff --git a/Source/Project64-core/N64System/SystemGlobals.cpp b/Source/Project64-core/N64System/SystemGlobals.cpp index d6e058b1c..84552337b 100644 --- a/Source/Project64-core/N64System/SystemGlobals.cpp +++ b/Source/Project64-core/N64System/SystemGlobals.cpp @@ -32,5 +32,6 @@ uint32_t * g_TLBStoreAddress = NULL; CDebugger * g_Debugger = NULL; uint8_t ** g_RecompPos = NULL; CMempak * g_Mempak = NULL; +CRandom * g_Random = NULL; int * g_NextTimer; \ No newline at end of file diff --git a/Source/Project64-core/Project64-core.vcxproj b/Source/Project64-core/Project64-core.vcxproj index 9cbfef092..412d6fedc 100644 --- a/Source/Project64-core/Project64-core.vcxproj +++ b/Source/Project64-core/Project64-core.vcxproj @@ -35,7 +35,6 @@ NotUsing - @@ -127,7 +126,6 @@ - diff --git a/Source/Project64-core/Project64-core.vcxproj.filters b/Source/Project64-core/Project64-core.vcxproj.filters index 44f537ba3..f3f9f6b9b 100644 --- a/Source/Project64-core/Project64-core.vcxproj.filters +++ b/Source/Project64-core/Project64-core.vcxproj.filters @@ -339,9 +339,6 @@ Source Files\N64 System\Recompiler\Arm - - Source Files\3rd Party - @@ -662,9 +659,6 @@ Header Files - - Header Files\3rd Party - From 958f11cc6dbc66fc49182b86c24b9649eef21ce4 Mon Sep 17 00:00:00 2001 From: Azimer Date: Wed, 18 Oct 2017 00:05:38 -0500 Subject: [PATCH 6/9] Fixed random state with SyncCPU --- Source/Project64-core/N64System/N64Class.cpp | 8 ++++---- Source/Project64-core/N64System/N64Class.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/Project64-core/N64System/N64Class.cpp b/Source/Project64-core/N64System/N64Class.cpp index c2d649ee9..d3190edfc 100644 --- a/Source/Project64-core/N64System/N64Class.cpp +++ b/Source/Project64-core/N64System/N64Class.cpp @@ -30,7 +30,7 @@ #pragma warning(disable:4355) // Disable 'this' : used in base member initializer list -CN64System::CN64System(CPlugins * Plugins, bool SavesReadOnly, bool SyncSystem) : +CN64System::CN64System(CPlugins * Plugins, uint32_t randomizer_seed, bool SavesReadOnly, bool SyncSystem) : CSystemEvents(this, Plugins), m_EndEmulation(false), m_SaveUsing((SAVE_CHIP_TYPE)g_Settings->LoadDword(Game_SaveChip)), @@ -58,7 +58,7 @@ CN64System::CN64System(CPlugins * Plugins, bool SavesReadOnly, bool SyncSystem) m_hPauseEvent(true), m_CheatsSlectionChanged(false), m_SyncCpu(SyncSystem), - m_Random((uint32_t)time(NULL)) + m_Random(randomizer_seed) { WriteTrace(TraceN64System, TraceDebug, "Start"); memset(m_LastSuccessSyncPC, 0, sizeof(m_LastSuccessSyncPC)); @@ -111,7 +111,7 @@ CN64System::CN64System(CPlugins * Plugins, bool SavesReadOnly, bool SyncSystem) g_Plugins->CopyPlugins(g_Settings->LoadStringVal(Directory_PluginSync)); m_SyncPlugins = new CPlugins(Directory_PluginSync, true); m_SyncPlugins->SetRenderWindows(g_Plugins->SyncWindow(), NULL); - m_SyncCPU = new CN64System(m_SyncPlugins, true, true); + m_SyncCPU = new CN64System(m_SyncPlugins, randomizer_seed, true, true); } Reset(true, true); @@ -360,7 +360,7 @@ bool CN64System::RunFileImage(const char * FileLoc) void CN64System::RunLoadedImage(void) { WriteTrace(TraceN64System, TraceDebug, "Start"); - g_BaseSystem = new CN64System(g_Plugins, false, false); + g_BaseSystem = new CN64System(g_Plugins, (uint32_t)time(NULL), false, false); if (g_BaseSystem) { g_BaseSystem->StartEmulation(true); diff --git a/Source/Project64-core/N64System/N64Class.h b/Source/Project64-core/N64System/N64Class.h index 85ae9796c..909cc0732 100644 --- a/Source/Project64-core/N64System/N64Class.h +++ b/Source/Project64-core/N64System/N64Class.h @@ -49,7 +49,7 @@ class CN64System : protected CDebugSettings { public: - CN64System(CPlugins * Plugins, bool SavesReadOnly, bool SyncSystem); + CN64System(CPlugins * Plugins, uint32_t randomizer_seed, bool SavesReadOnly, bool SyncSystem); virtual ~CN64System(void); CCheats m_Cheats; From 44f8a82c875246656364c1b40c25816bf19578bb Mon Sep 17 00:00:00 2001 From: Azimer Date: Wed, 18 Oct 2017 00:16:30 -0500 Subject: [PATCH 7/9] Prefix m_ in CRandom class --- Source/Common/Random.cpp | 14 +++++++------- Source/Common/Random.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Common/Random.cpp b/Source/Common/Random.cpp index a46f8887c..54bc07126 100644 --- a/Source/Common/Random.cpp +++ b/Source/Common/Random.cpp @@ -21,12 +21,12 @@ CRandom::CRandom() { - state = (uint32_t)time(NULL); + m_state = (uint32_t)time(NULL); } CRandom::CRandom(uint32_t state_value) { - state = state_value; + m_state = state_value; } uint32_t CRandom::randomizer(uint32_t val) @@ -36,19 +36,19 @@ uint32_t CRandom::randomizer(uint32_t val) uint32_t CRandom::next() { - state = randomizer(state); - return state; + m_state = randomizer(m_state); + return m_state; } void CRandom::set_state(uint32_t state_value) { if (state_value == 0) - state = 1; + m_state = 1; else - state = state_value; + m_state = state_value; } uint32_t CRandom::get_state() { - return state; + return m_state; } diff --git a/Source/Common/Random.h b/Source/Common/Random.h index 1a599a47c..aeb33536a 100644 --- a/Source/Common/Random.h +++ b/Source/Common/Random.h @@ -28,5 +28,5 @@ public: protected: uint32_t randomizer(uint32_t val); - uint32_t state; + uint32_t m_state; }; From 74cf9908f6ef3937db7800435d8545978d269d4d Mon Sep 17 00:00:00 2001 From: Azimer Date: Wed, 18 Oct 2017 01:07:52 -0500 Subject: [PATCH 8/9] Add Random.cpp to Common.mk for android --- Android/jni/Common/common.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Android/jni/Common/common.mk b/Android/jni/Common/common.mk index 5c14725b2..ef9424e6e 100644 --- a/Android/jni/Common/common.mk +++ b/Android/jni/Common/common.mk @@ -21,6 +21,7 @@ LOCAL_SRC_FILES := \ $(SRCDIR)/MemoryManagement.cpp \ $(SRCDIR)/path.cpp \ $(SRCDIR)/Platform.cpp \ + $(SRCDIR)/Random.cpp \ $(SRCDIR)/StdString.cpp \ $(SRCDIR)/SyncEvent.cpp \ $(SRCDIR)/Thread.cpp \ @@ -30,4 +31,4 @@ LOCAL_SRC_FILES := \ LOCAL_CFLAGS := $(COMMON_CFLAGS) LOCAL_CPPFLAGS := $(COMMON_CPPFLAGS) -include $(BUILD_STATIC_LIBRARY) \ No newline at end of file +include $(BUILD_STATIC_LIBRARY) From a47d5c329823c5a2fb1c24525201b032c0cc1efc Mon Sep 17 00:00:00 2001 From: zilmar Date: Fri, 20 Oct 2017 19:57:21 +1100 Subject: [PATCH 9/9] [Debugger] Change how font work --- .../N64System/Debugger/Debugger-Commands.cpp | 24 ++++++-- .../N64System/Debugger/Debugger-Commands.h | 5 +- .../Debugger/Debugger-RegisterTabs.cpp | 56 ++++++++----------- .../Debugger/Debugger-RegisterTabs.h | 8 +-- 4 files changed, 46 insertions(+), 47 deletions(-) diff --git a/Source/Project64/N64System/Debugger/Debugger-Commands.cpp b/Source/Project64/N64System/Debugger/Debugger-Commands.cpp index 31631422c..afd781213 100644 --- a/Source/Project64/N64System/Debugger/Debugger-Commands.cpp +++ b/Source/Project64/N64System/Debugger/Debugger-Commands.cpp @@ -31,6 +31,8 @@ CToolTipDialog() m_StartAddress = 0x80000000; m_Breakpoints = m_Debugger->Breakpoints(); m_bEditing = false; + m_CommandListRows = 39; + m_RowHeight = 13; } CDebugCommandsView::~CDebugCommandsView(void) @@ -57,8 +59,6 @@ LRESULT CDebugCommandsView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARA DlgResize_Init(false, true); DlgToolTip_Init(); - m_CommandListRows = 39; - CheckCPUType(); GetWindowRect(&m_DefaultWindowRect); @@ -871,7 +871,19 @@ LRESULT CDebugCommandsView::OnMeasureItem(UINT uMsg, WPARAM wParam, LPARAM lPara if (wParam == IDC_CMD_LIST) { MEASUREITEMSTRUCT* lpMeasureItem = (MEASUREITEMSTRUCT*)lParam; - lpMeasureItem->itemHeight = CCommandList::ROW_HEIGHT; + HWND hCmdList = GetDlgItem(IDC_CMD_LIST); + HWND hHeader = ListView_GetHeader(hCmdList); + RECT header_rc = { 0 }, control_rc = { 0 }; + if (::GetClientRect(hHeader, &header_rc) && GetClientRect(&control_rc)) + { + int height = (control_rc.bottom - control_rc.top) - (header_rc.bottom - header_rc.top); + m_RowHeight = height / m_CommandListRows; + } + else + { + m_RowHeight = 13; + } + lpMeasureItem->itemHeight = m_RowHeight; } return FALSE; } @@ -928,8 +940,8 @@ void CDebugCommandsView::DrawBranchArrows(HDC listDC) int begX = baseX - arrow.startMargin * 3; int endX = baseX - arrow.endMargin * 3; - int begY = baseY + arrow.startPos * CCommandList::ROW_HEIGHT; - int endY = baseY + arrow.endPos * CCommandList::ROW_HEIGHT; + int begY = baseY + arrow.startPos * m_RowHeight; + int endY = baseY + arrow.endPos * m_RowHeight; bool bEndVisible = true; @@ -1405,7 +1417,7 @@ LRESULT CDebugCommandsView::OnSizing(UINT uMsg, WPARAM wParam, LPARAM lParam, BO int rowsHeight = listRect.Height() - headRect.Height(); - int nRows = (rowsHeight / CCommandList::ROW_HEIGHT); + int nRows = (rowsHeight / m_RowHeight); if (m_CommandListRows != nRows) { diff --git a/Source/Project64/N64System/Debugger/Debugger-Commands.h b/Source/Project64/N64System/Debugger/Debugger-Commands.h index fc8b4112f..d90473285 100644 --- a/Source/Project64/N64System/Debugger/Debugger-Commands.h +++ b/Source/Project64/N64System/Debugger/Debugger-Commands.h @@ -29,10 +29,6 @@ public: COL_SYMBOL }; - enum { - ROW_HEIGHT = 13, - }; - void Attach(HWND hWndNew) { CListViewCtrl::Attach(hWndNew); @@ -143,6 +139,7 @@ private: OPCODE& m_SelectedOpCode = m_SelectedOpInfo.m_OpCode; uint32_t m_FollowAddress; + uint32_t m_RowHeight; typedef struct { uint32_t address; diff --git a/Source/Project64/N64System/Debugger/Debugger-RegisterTabs.cpp b/Source/Project64/N64System/Debugger/Debugger-RegisterTabs.cpp index 61bf302e5..59b673b92 100644 --- a/Source/Project64/N64System/Debugger/Debugger-RegisterTabs.cpp +++ b/Source/Project64/N64System/Debugger/Debugger-RegisterTabs.cpp @@ -19,14 +19,6 @@ bool CRegisterTabs::m_bColorsEnabled = false; void CRegisterTabs::Attach(HWND hWndNew) { CTabCtrl::Attach(hWndNew); - LOGFONT lf; - GetObject((HFONT)GetCurrentObject(GetDC(), OBJ_FONT), sizeof(LOGFONT), &lf); - - HFONT monoFont = CreateFont(lf.lfHeight * -1, 0, 0, 0, - FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, - OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, - CLEARTYPE_QUALITY, FF_DONTCARE, "Consolas" - ); m_GPRTab = AddTab("GPR", IDD_Debugger_RegGPR, TabProcGPR); m_FPRTab = AddTab("FPR", IDD_Debugger_RegFPR, TabProcFPR); @@ -42,36 +34,36 @@ void CRegisterTabs::Attach(HWND hWndNew) m_SITab = AddTab("SI", IDD_Debugger_RegSI, TabProcDefault); m_DDTab = AddTab("DD", IDD_Debugger_RegDD, TabProcDefault); - InitRegisterEdits64(m_GPRTab, m_GPREdits, GPREditIds, monoFont); - InitRegisterEdit64(m_GPRTab, m_HIEdit, IDC_HI_EDIT, monoFont); - InitRegisterEdit64(m_GPRTab, m_LOEdit, IDC_LO_EDIT, monoFont); + InitRegisterEdits64(m_GPRTab, m_GPREdits, GPREditIds); + InitRegisterEdit64(m_GPRTab, m_HIEdit, IDC_HI_EDIT); + InitRegisterEdit64(m_GPRTab, m_LOEdit, IDC_LO_EDIT); - InitRegisterEdits(m_FPRTab, m_FPREdits, FPREditIds, monoFont); - InitRegisterEdit(m_FPRTab, m_FCSREdit, IDC_FCSR_EDIT, monoFont); + InitRegisterEdits(m_FPRTab, m_FPREdits, FPREditIds); + InitRegisterEdit(m_FPRTab, m_FCSREdit, IDC_FCSR_EDIT); - InitRegisterEdits(m_COP0Tab, m_COP0Edits, COP0EditIds, monoFont); + InitRegisterEdits(m_COP0Tab, m_COP0Edits, COP0EditIds); m_CauseTip.Attach(m_COP0Tab.GetDlgItem(IDC_CAUSE_TIP)); - InitRegisterEdits(m_RDRAMTab, m_RDRAMEdits, RDRAMEditIds, monoFont); + InitRegisterEdits(m_RDRAMTab, m_RDRAMEdits, RDRAMEditIds); - InitRegisterEdits(m_SPTab, m_SPEdits, SPEditIds, monoFont); - InitRegisterEdit(m_SPTab, m_SPPCEdit, IDC_SP_PC_EDIT, monoFont); + InitRegisterEdits(m_SPTab, m_SPEdits, SPEditIds); + InitRegisterEdit(m_SPTab, m_SPPCEdit, IDC_SP_PC_EDIT); - InitRegisterEdits(m_DPCTab, m_DPCEdits, DPCEditIds, monoFont); + InitRegisterEdits(m_DPCTab, m_DPCEdits, DPCEditIds); - InitRegisterEdits(m_MITab, m_MIEdits, MIEditIds, monoFont); + InitRegisterEdits(m_MITab, m_MIEdits, MIEditIds); - InitRegisterEdits(m_VITab, m_VIEdits, VIEditIds, monoFont); + InitRegisterEdits(m_VITab, m_VIEdits, VIEditIds); - InitRegisterEdits(m_AITab, m_AIEdits, AIEditIds, monoFont); + InitRegisterEdits(m_AITab, m_AIEdits, AIEditIds); - InitRegisterEdits(m_PITab, m_PIEdits, PIEditIds, monoFont); + InitRegisterEdits(m_PITab, m_PIEdits, PIEditIds); - InitRegisterEdits(m_RITab, m_RIEdits, RIEditIds, monoFont); + InitRegisterEdits(m_RITab, m_RIEdits, RIEditIds); - InitRegisterEdits(m_SITab, m_SIEdits, SIEditIds, monoFont); + InitRegisterEdits(m_SITab, m_SIEdits, SIEditIds); - InitRegisterEdits(m_DDTab, m_DDEdits, DDEditIds, monoFont); + InitRegisterEdits(m_DDTab, m_DDEdits, DDEditIds); SetColorsEnabled(false); RefreshEdits(); @@ -668,32 +660,30 @@ void CRegisterTabs::SetColorsEnabled(bool bColorsEnabled) m_bColorsEnabled = bColorsEnabled; } -void CRegisterTabs::InitRegisterEdit(CWindow& tab, CEditNumber& edit, WORD ctrlId, HFONT font) +void CRegisterTabs::InitRegisterEdit(CWindow& tab, CEditNumber& edit, WORD ctrlId) { edit.Attach(tab.GetDlgItem(ctrlId)); edit.SetDisplayType(CEditNumber::DisplayHex); - edit.SetFont(font); } -void CRegisterTabs::InitRegisterEdits(CWindow& tab, CEditNumber* edits, const DWORD* ctrlIds, HFONT font) +void CRegisterTabs::InitRegisterEdits(CWindow& tab, CEditNumber* edits, const DWORD* ctrlIds) { for (int i = 0; i < ctrlIds[i] != 0; i++) { - InitRegisterEdit(tab, edits[i], ctrlIds[i], font); + InitRegisterEdit(tab, edits[i], ctrlIds[i]); } } -void CRegisterTabs::InitRegisterEdit64(CWindow& tab, CEditReg64& edit, WORD ctrlId, HFONT font) +void CRegisterTabs::InitRegisterEdit64(CWindow& tab, CEditReg64& edit, WORD ctrlId) { edit.Attach(tab.GetDlgItem(ctrlId)); - edit.SetFont(font); } -void CRegisterTabs::InitRegisterEdits64(CWindow& tab, CEditReg64* edits, const DWORD* ctrlIds, HFONT font) +void CRegisterTabs::InitRegisterEdits64(CWindow& tab, CEditReg64* edits, const DWORD* ctrlIds) { for (int i = 0; i < ctrlIds[i] != 0; i++) { - InitRegisterEdit64(tab, edits[i], ctrlIds[i], font); + InitRegisterEdit64(tab, edits[i], ctrlIds[i]); } } diff --git a/Source/Project64/N64System/Debugger/Debugger-RegisterTabs.h b/Source/Project64/N64System/Debugger/Debugger-RegisterTabs.h index cf8e48c7a..f9cd5a68c 100644 --- a/Source/Project64/N64System/Debugger/Debugger-RegisterTabs.h +++ b/Source/Project64/N64System/Debugger/Debugger-RegisterTabs.h @@ -261,10 +261,10 @@ private: static INT_PTR CALLBACK TabProcGPR(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); static INT_PTR CALLBACK TabProcFPR(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); - static void InitRegisterEdit(CWindow& tab, CEditNumber& edit, WORD ctrlId, HFONT font); - static void InitRegisterEdits(CWindow& tab, CEditNumber* edits, const DWORD* ctrlIds, HFONT font); - static void InitRegisterEdit64(CWindow& tab, CEditReg64& edit, WORD ctrlId, HFONT font); - static void InitRegisterEdits64(CWindow& tab, CEditReg64* edits, const DWORD* ctrlIds, HFONT font); + static void InitRegisterEdit(CWindow& tab, CEditNumber& edit, WORD ctrlId); + static void InitRegisterEdits(CWindow& tab, CEditNumber* edits, const DWORD* ctrlIds); + static void InitRegisterEdit64(CWindow& tab, CEditReg64& edit, WORD ctrlId); + static void InitRegisterEdits64(CWindow& tab, CEditReg64* edits, const DWORD* ctrlIds); static void ZeroRegisterEdit(CEditNumber& edit); static void ZeroRegisterEdits(CEditNumber* edits, const DWORD* ctrlIds); static void ZeroRegisterEdit64(CEditReg64& edit);