From 11e82599e6f5754101a15b21bf2c3b752d5a16db Mon Sep 17 00:00:00 2001 From: feos-tas Date: Sun, 13 Jul 2014 12:22:22 +0000 Subject: [PATCH] Show some values for registers $4000-$4017 (memview, disassembly). --- trunk/src/debug.cpp | 22 ++++++++++++-- trunk/src/debug.h | 10 +++++++ trunk/src/drivers/win/memview.cpp | 50 +++++++++++++++---------------- trunk/src/input.cpp | 2 ++ trunk/src/ppu.cpp | 2 ++ trunk/src/sound.cpp | 27 +++++++---------- trunk/vc/vc10_fceux.vcxproj | 1 + 7 files changed, 70 insertions(+), 44 deletions(-) diff --git a/trunk/src/debug.cpp b/trunk/src/debug.cpp index 2f85dbb7..9c8f1365 100644 --- a/trunk/src/debug.cpp +++ b/trunk/src/debug.cpp @@ -263,7 +263,7 @@ uint8 *GetNesCHRPointer(int A){ } uint8 GetMem(uint16 A) { - if ((A >= 0x2000) && (A < 0x4000)) { + if ((A >= 0x2000) && (A < 0x4000)) // PPU regs and their mirrors switch (A&7) { case 0: return PPU[0]; case 1: return PPU[1]; @@ -274,8 +274,24 @@ uint8 GetMem(uint16 A) { case 6: return RefreshAddr&0xFF; case 7: return VRAMBuffer; } - } else if ((A >= 0x4000) && (A < 0x5000)) return 0xFF; // AnS: changed the range, so MMC5 ExRAM can be watched in the Hexeditor - if (GameInfo) return ARead[A](A); //adelikat: 11/17/09: Prevent crash if this is called with no game loaded. + // feos: added more registers + else if ((A >= 0x4000) && (A < 0x4010)) + return PSG[A&15]; + else if ((A >= 0x4010) && (A < 0x4018)) + switch(A&7) { + case 0: return DMCFormat; + case 1: return RawDALatch; + case 2: return DMCAddressLatch; + case 3: return DMCSizeLatch; + case 4: return SpriteDMA; + case 5: return EnabledChannels; + case 6: return RawReg4016; + case 7: return IRQFrameMode; + } + else if ((A >= 0x4018) && (A < 0x5000)) // AnS: changed the range, so MMC5 ExRAM can be watched in the Hexeditor + return 0xFF; + if (GameInfo) //adelikat: 11/17/09: Prevent crash if this is called with no game loaded. + return ARead[A](A); else return 0; } diff --git a/trunk/src/debug.h b/trunk/src/debug.h index 09c10177..435f250c 100644 --- a/trunk/src/debug.h +++ b/trunk/src/debug.h @@ -148,6 +148,16 @@ public: extern NSF_HEADER NSFHeader; +extern uint8 PSG[0x10]; +extern uint8 DMCFormat; +extern uint8 RawDALatch; +extern uint8 DMCAddressLatch; +extern uint8 DMCSizeLatch; +extern uint8 EnabledChannels; +extern uint8 SpriteDMA; +extern uint8 RawReg4016; +extern uint8 IRQFrameMode; + ///retrieves the core's DebuggerState DebuggerState &FCEUI_Debugger(); diff --git a/trunk/src/drivers/win/memview.cpp b/trunk/src/drivers/win/memview.cpp index a82acf83..538dfc2a 100644 --- a/trunk/src/drivers/win/memview.cpp +++ b/trunk/src/drivers/win/memview.cpp @@ -107,17 +107,17 @@ struct } popupmenu[] = { - {0x0000,0xFFFF, MODE_NES_MEMORY, ID_ADDRESS_SYMBOLIC_NAME, "Add symbolic debug name"}, - {0x0000,0x2000, MODE_NES_MEMORY,ID_ADDRESS_FRZ_SUBMENU,"Freeze/Unfreeze This Address"}, - {0x6000,0x7FFF, MODE_NES_MEMORY,ID_ADDRESS_FRZ_SUBMENU,"Freeze/Unfreeze This Address"}, - {0x0000,0xFFFF, MODE_NES_MEMORY,ID_ADDRESS_ADDBP_R,"Add Debugger Read Breakpoint"}, - {0x0000,0x3FFF, MODE_NES_PPU,ID_ADDRESS_ADDBP_R,"Add Debugger Read Breakpoint"}, - {0x0000,0xFFFF, MODE_NES_MEMORY,ID_ADDRESS_ADDBP_W,"Add Debugger Write Breakpoint"}, - {0x0000,0x3FFF, MODE_NES_PPU,ID_ADDRESS_ADDBP_W,"Add Debugger Write Breakpoint"}, - {0x0000,0xFFFF, MODE_NES_MEMORY,ID_ADDRESS_ADDBP_X,"Add Debugger Execute Breakpoint"}, - {0x8000,0xFFFF, MODE_NES_MEMORY,ID_ADDRESS_SEEK_IN_ROM,"Go Here In ROM File"}, - {0x8000,0xFFFF, MODE_NES_MEMORY,ID_ADDRESS_CREATE_GG_CODE,"Create Game Genie Code At This Address"}, - {0x0000,0xFFFF, MODE_NES_MEMORY, ID_ADDRESS_BOOKMARK, "Add / Remove bookmark"}, + {0x0000,0xFFFF, MODE_NES_MEMORY, ID_ADDRESS_SYMBOLIC_NAME, "Add symbolic debug name"}, + {0x0000,0x2000, MODE_NES_MEMORY, ID_ADDRESS_FRZ_SUBMENU, "Freeze/Unfreeze This Address"}, + {0x6000,0x7FFF, MODE_NES_MEMORY, ID_ADDRESS_FRZ_SUBMENU, "Freeze/Unfreeze This Address"}, + {0x0000,0xFFFF, MODE_NES_MEMORY, ID_ADDRESS_ADDBP_R, "Add Debugger Read Breakpoint"}, + {0x0000,0x3FFF, MODE_NES_PPU, ID_ADDRESS_ADDBP_R, "Add Debugger Read Breakpoint"}, + {0x0000,0xFFFF, MODE_NES_MEMORY, ID_ADDRESS_ADDBP_W, "Add Debugger Write Breakpoint"}, + {0x0000,0x3FFF, MODE_NES_PPU, ID_ADDRESS_ADDBP_W, "Add Debugger Write Breakpoint"}, + {0x0000,0xFFFF, MODE_NES_MEMORY, ID_ADDRESS_ADDBP_X, "Add Debugger Execute Breakpoint"}, + {0x8000,0xFFFF, MODE_NES_MEMORY, ID_ADDRESS_SEEK_IN_ROM, "Go Here In ROM File"}, + {0x8000,0xFFFF, MODE_NES_MEMORY, ID_ADDRESS_CREATE_GG_CODE, "Create Game Genie Code At This Address"}, + {0x0000,0xFFFF, MODE_NES_MEMORY, ID_ADDRESS_BOOKMARK, "Add / Remove bookmark"}, } ; #define POPUPNUM (sizeof popupmenu / sizeof popupmenu[0]) @@ -1311,20 +1311,20 @@ LRESULT CALLBACK MemViewCallB(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa // ################################## End of SP CODE ########################### switch(wParam){ - case 0x43: //Ctrl+C - MemViewCallB(hMemView,WM_COMMAND,MENU_MV_EDIT_COPY,0); //recursion at work - return 0; - case 0x56: //Ctrl+V - MemViewCallB(hMemView,WM_COMMAND,MENU_MV_EDIT_PASTE,0); - return 0; - case 0x5a: //Ctrl+Z - UndoLastPatch(); break; - case 0x41: //Ctrl+A - // Fall through to Ctrl+G - case 0x47: //Ctrl+G - GotoAddress(hwnd); break; - case 0x46: //Ctrl+F - OpenFindDialog(); break; + case 0x43: //Ctrl+C + MemViewCallB(hMemView,WM_COMMAND,MENU_MV_EDIT_COPY,0); //recursion at work + return 0; + case 0x56: //Ctrl+V + MemViewCallB(hMemView,WM_COMMAND,MENU_MV_EDIT_PASTE,0); + return 0; + case 0x5a: //Ctrl+Z + UndoLastPatch(); break; + case 0x41: //Ctrl+A + // Fall through to Ctrl+G + case 0x47: //Ctrl+G + GotoAddress(hwnd); break; + case 0x46: //Ctrl+F + OpenFindDialog(); break; } } diff --git a/trunk/src/input.cpp b/trunk/src/input.cpp index 02a1a546..22bc725d 100644 --- a/trunk/src/input.cpp +++ b/trunk/src/input.cpp @@ -93,6 +93,7 @@ static int CommandMapping[EMUCMD_NUM]; static uint8 joy_readbit[2]; uint8 joy[4]={0,0,0,0}; //HACK - should be static but movie needs it static uint8 LastStrobe; +uint8 RawReg4016 = 0; // Joystick strobe (W) static bool replaceP2StartWithMicrophone = false; @@ -172,6 +173,7 @@ static DECLFW(B4016) portFC.driver->Strobe(); } LastStrobe=V&0x1; + RawReg4016 = V; } //a main joystick port driver representing the case where nothing is plugged in diff --git a/trunk/src/ppu.cpp b/trunk/src/ppu.cpp index 06225c84..168e26fd 100644 --- a/trunk/src/ppu.cpp +++ b/trunk/src/ppu.cpp @@ -335,6 +335,7 @@ void (*PPU_hook)(uint32 A); uint8 vtoggle = 0; uint8 XOffset = 0; +uint8 SpriteDMA = 0; // $4014 / Writing $xx copies 256 bytes by reading from $xx00-$xxFF and writing to $2004 (OAM data) uint32 TempAddr = 0, RefreshAddr = 0, DummyRead = 0; @@ -918,6 +919,7 @@ static DECLFW(B4014) { for (x = 0; x < 256; x++) X6502_DMW(0x2004, X6502_DMR(t + x)); + SpriteDMA = V; } #define PAL(c) ((c) + cc) diff --git a/trunk/src/sound.cpp b/trunk/src/sound.cpp index 4cb74eb1..4bb710d7 100644 --- a/trunk/src/sound.cpp +++ b/trunk/src/sound.cpp @@ -46,16 +46,19 @@ static uint8 TriMode=0; static int32 tristep=0; -static int32 wlcount[4]={0,0,0,0}; /* Wave length counters. */ +static int32 wlcount[4]={0,0,0,0}; // Wave length counters. -static uint8 IRQFrameMode=0; /* $4017 / xx000000 */ -/*static*/ uint8 PSG[0x10]; -static uint8 RawDALatch=0; /* $4011 0xxxxxxx */ -/*static*/ uint8 InitialRawDALatch=0; // used only for lua +// APU registers: +uint8 PSG[0x10]; // $4000-$400F / Channels 1-4 +uint8 DMCFormat=0; // $4010 / Play mode and frequency +uint8 RawDALatch=0; // $4011 / 7-bit DAC / 0xxxxxxx +uint8 DMCAddressLatch=0; // $4012 / Start of DMC waveform is at address $C000 + $40*$xx +uint8 DMCSizeLatch=0; // $4013 / Length of DMC waveform is $10*$xx + 1 bytes (128*$xx + 8 samples) +uint8 EnabledChannels=0; // $4015 / Sound channels enable and status +uint8 IRQFrameMode=0; // $4017 / Frame counter control / xx000000 -uint8 EnabledChannels=0; /* Byte written to $4015 */ - -/*static*/ ENVUNIT EnvUnits[3]; +uint8 InitialRawDALatch=0; // used only for lua +ENVUNIT EnvUnits[3]; static const int RectDuties[4]={1,2,4,6}; @@ -119,18 +122,10 @@ static const uint32 PALDMCTable[0x10]= 176, 148, 132, 118, 98, 78, 66, 50 }; -// $4010 - Frequency -// $4011 - Actual data outputted -// $4012 - Address register: $c000 + V*64 -// $4013 - Size register: Size in bytes = (V+1)*64 - /*static*/ int32 DMCacc=1; /*static*/ int32 DMCPeriod=0; /*static*/ uint8 DMCBitCount=0; -/*static*/ uint8 DMCAddressLatch=0,DMCSizeLatch=0; /* writes to 4012 and 4013 */ -/*static*/ uint8 DMCFormat=0; /* Write to $4010 */ - static uint32 DMCAddress=0; static int32 DMCSize=0; static uint8 DMCShift=0; diff --git a/trunk/vc/vc10_fceux.vcxproj b/trunk/vc/vc10_fceux.vcxproj index 78dde635..74325286 100644 --- a/trunk/vc/vc10_fceux.vcxproj +++ b/trunk/vc/vc10_fceux.vcxproj @@ -84,6 +84,7 @@ AllRules.ruleset + true