From 83e343b593a5324014b3a4f2d93649faed115ca1 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Tue, 14 Dec 2010 07:18:09 +0000 Subject: [PATCH 01/33] * Bugfix for Recent Iso List (it stopped remembering stuff a couple revs ago). * Doing some configuration panel additions and cleanups (UI/theme-related) -- WIP. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4090 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/gui/App.h | 11 ++-- pcsx2/gui/AppConfig.cpp | 4 +- pcsx2/gui/AppConfig.h | 1 + pcsx2/gui/AppRes.cpp | 2 + pcsx2/gui/Dialogs/ConfigurationDialog.h | 19 +++---- pcsx2/gui/Dialogs/SysConfigDialog.cpp | 17 ++++-- pcsx2/gui/MSWstuff.cpp | 9 ++- pcsx2/gui/MainFrame.cpp | 2 +- pcsx2/gui/MainMenuClicks.cpp | 4 +- pcsx2/gui/RecentIsoList.cpp | 52 +++++++++++------- pcsx2/gui/RecentIsoList.h | 1 + pcsx2/gui/Resources/ConfigIcon_Appearance.png | Bin 0 -> 7569 bytes pcsx2/windows/VCprojects/pcsx2_2008.vcproj | 34 ++++++++++++ 13 files changed, 108 insertions(+), 48 deletions(-) create mode 100644 pcsx2/gui/Resources/ConfigIcon_Appearance.png diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index d92e35e947..73e81419a2 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -190,14 +190,15 @@ struct AppImageIds Gamefixes, MemoryCard, Video, - Cpu; + Cpu, + Appearance; ConfigIds() { - Paths = Plugins = - Speedhacks = Gamefixes = - Video = Cpu = - MemoryCard = -1; + Paths = Plugins = + Speedhacks = Gamefixes = + Video = Cpu = + MemoryCard = Appearance = -1; } } Config; diff --git a/pcsx2/gui/AppConfig.cpp b/pcsx2/gui/AppConfig.cpp index 4467e73218..d14a9aba72 100644 --- a/pcsx2/gui/AppConfig.cpp +++ b/pcsx2/gui/AppConfig.cpp @@ -360,7 +360,8 @@ AppConfig::AppConfig() : MainGuiPosition( wxDefaultPosition ) , SysSettingsTabName( L"Cpu" ) , McdSettingsTabName( L"none" ) - , AppSettingsTabName( L"Plugins" ) + , ComponentsTabName( L"Plugins" ) + , AppSettingsTabName( L"Appearance" ) , GameDatabaseTabName( L"none" ) , DeskTheme( L"default" ) { @@ -466,6 +467,7 @@ void AppConfig::LoadSaveRootItems( IniInterface& ini ) IniEntry( MainGuiPosition ); IniEntry( SysSettingsTabName ); IniEntry( McdSettingsTabName ); + IniEntry( ComponentsTabName ); IniEntry( AppSettingsTabName ); IniEntry( GameDatabaseTabName ); ini.EnumEntry( L"LanguageId", LanguageId, NULL, defaults.LanguageId ); diff --git a/pcsx2/gui/AppConfig.h b/pcsx2/gui/AppConfig.h index 7430b6371b..af54483714 100644 --- a/pcsx2/gui/AppConfig.h +++ b/pcsx2/gui/AppConfig.h @@ -192,6 +192,7 @@ public: // by it's UTF/ASCII name). wxString SysSettingsTabName; wxString McdSettingsTabName; + wxString ComponentsTabName; wxString AppSettingsTabName; wxString GameDatabaseTabName; diff --git a/pcsx2/gui/AppRes.cpp b/pcsx2/gui/AppRes.cpp index 2ecc32f317..52db60fc93 100644 --- a/pcsx2/gui/AppRes.cpp +++ b/pcsx2/gui/AppRes.cpp @@ -31,6 +31,7 @@ #include "Resources/ConfigIcon_Paths.h" #include "Resources/ConfigIcon_Plugins.h" #include "Resources/ConfigIcon_MemoryCard.h" +#include "Resources/ConfigIcon_Appearance.h" #include "Resources/AppIcon16.h" #include "Resources/AppIcon32.h" @@ -184,6 +185,7 @@ wxImageList& Pcsx2App::GetImgList_Config() FancyLoadMacro( MemoryCard ); FancyLoadMacro( Video ); FancyLoadMacro( Cpu ); + FancyLoadMacro( Appearance ); } return *images; } diff --git a/pcsx2/gui/Dialogs/ConfigurationDialog.h b/pcsx2/gui/Dialogs/ConfigurationDialog.h index 09e652cdf8..a04c0678b7 100644 --- a/pcsx2/gui/Dialogs/ConfigurationDialog.h +++ b/pcsx2/gui/Dialogs/ConfigurationDialog.h @@ -90,23 +90,18 @@ namespace Dialogs }; // -------------------------------------------------------------------------------------- - // LanguageSelectionDialog + // InterfaceConfigDialog // -------------------------------------------------------------------------------------- - class LanguageSelectionDialog : public BaseConfigurationDialog + class InterfaceConfigDialog : public BaseConfigurationDialog { public: - virtual ~LanguageSelectionDialog() throw() {} - LanguageSelectionDialog(wxWindow* parent=NULL); - static wxString GetNameStatic() { return L"LanguageSelector"; } + virtual ~InterfaceConfigDialog() throw() {} + InterfaceConfigDialog(wxWindow* parent=NULL); + static wxString GetNameStatic() { return L"InterfaceConfig"; } wxString GetDialogName() const { return GetNameStatic(); } protected: - virtual wxString& GetConfSettingsTabName() const - { - pxFailDev("Language selector does not have a listbook or settings tab."); - static wxString fail; - return fail; - } + virtual wxString& GetConfSettingsTabName() const { return g_Conf->AppSettingsTabName; } }; // -------------------------------------------------------------------------------------- @@ -162,7 +157,7 @@ namespace Dialogs wxString GetDialogName() const { return GetNameStatic(); } protected: - virtual wxString& GetConfSettingsTabName() const { return g_Conf->AppSettingsTabName; } + virtual wxString& GetConfSettingsTabName() const { return g_Conf->ComponentsTabName; } }; // -------------------------------------------------------------------------------------- diff --git a/pcsx2/gui/Dialogs/SysConfigDialog.cpp b/pcsx2/gui/Dialogs/SysConfigDialog.cpp index a1979995db..b6148d2984 100644 --- a/pcsx2/gui/Dialogs/SysConfigDialog.cpp +++ b/pcsx2/gui/Dialogs/SysConfigDialog.cpp @@ -98,7 +98,6 @@ Dialogs::ComponentsConfigDialog::ComponentsConfigDialog(wxWindow* parent) AddPage ( wxLt("Plugins"), cfgid.Plugins ); AddPage ( wxLt("BIOS"), cfgid.Cpu ); - AddPage ( wxLt("Folders"), cfgid.Paths ); AddListbook(); AddOkCancel(); @@ -107,12 +106,20 @@ Dialogs::ComponentsConfigDialog::ComponentsConfigDialog(wxWindow* parent) wxGetApp().PostMethod( CheckPluginsOverrides ); } -Dialogs::LanguageSelectionDialog::LanguageSelectionDialog(wxWindow *parent) +Dialogs::InterfaceConfigDialog::InterfaceConfigDialog(wxWindow *parent) : BaseConfigurationDialog( parent, AddAppName(_("Language Selector - %s")), 400 ) { ScopedBusyCursor busy( Cursor_ReallyBusy ); - *this += new Panels::LanguageSelectionPanel( this ) | pxCenter; + CreateListbook( wxGetApp().GetImgList_Config() ); + const AppImageIds::ConfigIds& cfgid( wxGetApp().GetImgId().Config ); - wxDialogWithHelpers::AddOkCancel( NULL, false ); -} \ No newline at end of file + AddPage ( wxLt("Appearance"), cfgid.Appearance ); + AddPage ( wxLt("Folders"), cfgid.Paths ); + + AddListbook(); + AddOkCancel(); + + //*this += new Panels::LanguageSelectionPanel( this ) | pxCenter; + //wxDialogWithHelpers::AddOkCancel( NULL, false ); +} diff --git a/pcsx2/gui/MSWstuff.cpp b/pcsx2/gui/MSWstuff.cpp index 59b0f6fa77..70d22cb570 100644 --- a/pcsx2/gui/MSWstuff.cpp +++ b/pcsx2/gui/MSWstuff.cpp @@ -39,9 +39,12 @@ void MSW_ListView_SetIconSpacing( wxListbook& listbook, int width ) // way over generous. This little bit of Win32-specific code ensures proper icon spacing, scaled // to the size of the frame's ideal width. - ListView_SetIconSpacing( (HWND)listbook.GetListView()->GetHWND(), - (width / listbook.GetPageCount()) - 4, g_Conf->Listbook_ImageSize+32 // y component appears to be ignored - ); + if (listbook.GetPageCount()) + { + ListView_SetIconSpacing( (HWND)listbook.GetListView()->GetHWND(), + (width / listbook.GetPageCount()) - 4, g_Conf->Listbook_ImageSize+32 // y component appears to be ignored + ); + } #endif } diff --git a/pcsx2/gui/MainFrame.cpp b/pcsx2/gui/MainFrame.cpp index bc52eca23b..0219f62709 100644 --- a/pcsx2/gui/MainFrame.cpp +++ b/pcsx2/gui/MainFrame.cpp @@ -450,7 +450,7 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title) if (IsDebugBuild) { m_menuConfig.Append(MenuId_Config_GameDatabase, _("Game Database Editor") ); - m_menuConfig.Append(MenuId_Config_Language, _("Language...") ); + m_menuConfig.Append(MenuId_Config_Language, _("Appearance...") ); } m_menuConfig.AppendSeparator(); diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp index eb398ce339..fde9628bb2 100644 --- a/pcsx2/gui/MainMenuClicks.cpp +++ b/pcsx2/gui/MainMenuClicks.cpp @@ -74,8 +74,8 @@ void MainEmuFrame::Menu_SelectPluginsBios_Click(wxCommandEvent &event) void MainEmuFrame::Menu_Language_Click(wxCommandEvent &event) { - //AppOpenDialog( this ); - LanguageSelectionDialog(this).ShowModal(); + //AppOpenDialog( this ); + InterfaceConfigDialog(this).ShowModal(); } static void WipeSettings() diff --git a/pcsx2/gui/RecentIsoList.cpp b/pcsx2/gui/RecentIsoList.cpp index 64d64fb8bb..2ad512a072 100644 --- a/pcsx2/gui/RecentIsoList.cpp +++ b/pcsx2/gui/RecentIsoList.cpp @@ -34,6 +34,10 @@ RecentIsoManager::RecentIsoManager( wxMenu* menu ) { m_cursel = 0; m_Separator = NULL; + + IniLoader loader; + LoadListFrom(loader); + Connect( wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(RecentIsoManager::OnChangedSelection) ); } @@ -59,10 +63,8 @@ void RecentIsoManager::OnChangedSelection( wxCommandEvent& evt ) m_cursel = i; - // TODO: Dialog asking for hotswap or reset!!!! - ScopedCoreThreadPopup stopped_core; - //SysUpdateIsoSrcFile( m_Items[i].Filename ); + #ifdef __LINUX__ // Likely not what was intended, but it compiles for the moment... SwapOrReset_Iso( NULL, stopped_core, m_Items[i].Filename, GetMsg_IsoImageChanged()); @@ -70,6 +72,7 @@ void RecentIsoManager::OnChangedSelection( wxCommandEvent& evt ) // Getting a window from the menu? SwapOrReset_Iso( m_Menu->GetWindow(), stopped_core, m_Items[i].Filename, GetMsg_IsoImageChanged()); #endif + stopped_core.AllowResume(); } @@ -157,6 +160,27 @@ void RecentIsoManager::InsertIntoMenu( int id ) curitem.ItemPtr->Check(); } +void RecentIsoManager::LoadListFrom( IniInterface& ini ) +{ + if (!ini.IsOk()) return; + + ini.GetConfig().SetRecordDefaults( false ); + + RemoveAllFromMenu(); + + m_MaxLength = g_Conf->RecentIsoCount; + ScopedIniGroup groupie( ini, L"RecentIso" ); + for( uint i=0; iCurrentIso ); + + ini.GetConfig().SetRecordDefaults( true ); +} + void RecentIsoManager::AppStatusEvent_OnSettingsApplied() { // TODO : Implement application of Recent Iso List "maximum" history option @@ -166,36 +190,26 @@ void RecentIsoManager::AppStatusEvent_OnSettingsLoadSave( const AppSettingsEvent { IniInterface& ini( evt.GetIni() ); - ini.GetConfig().SetRecordDefaults( false ); - if( ini.IsSaving() ) { // Wipe existing recent iso list if we're saving, because our size might have changed // and that could leave some residual entries in the config. + ini.GetConfig().SetRecordDefaults( false ); + ini.GetConfig().DeleteGroup( L"RecentIso" ); ScopedIniGroup groupie( ini, L"RecentIso" ); int cnt = m_Items.size(); for( int i=0; iRecentIsoCount; - ScopedIniGroup groupie( ini, L"RecentIso" ); - for( uint i=0; iCurrentIso ); + LoadListFrom(ini); } - - ini.GetConfig().SetRecordDefaults( true ); } diff --git a/pcsx2/gui/RecentIsoList.h b/pcsx2/gui/RecentIsoList.h index 54e2423560..9e99b40bae 100644 --- a/pcsx2/gui/RecentIsoList.h +++ b/pcsx2/gui/RecentIsoList.h @@ -58,6 +58,7 @@ public: protected: void InsertIntoMenu( int id ); void OnChangedSelection( wxCommandEvent& evt ); + void LoadListFrom( IniInterface& ini ); void AppStatusEvent_OnSettingsLoadSave( const AppSettingsEventInfo& ini ); void AppStatusEvent_OnSettingsApplied(); diff --git a/pcsx2/gui/Resources/ConfigIcon_Appearance.png b/pcsx2/gui/Resources/ConfigIcon_Appearance.png new file mode 100644 index 0000000000000000000000000000000000000000..048809cf7f1e568f417fad9de2f5ed1d05ccc25f GIT binary patch literal 7569 zcmdUU=T{S7xb=ht2)(HE-W3oCy$1q;(0lJvr8ns$6sdwBy%#BpAc!DMx=2-;6hR<} z3My5QqL94#E$@22+`r)NHRn0!?6c>Yne*)VGLvd#phZQ_LJj}`6-ryfgwSLDYfvyD zo?x>t2pu?B9c2cELRU8pv4k05q-Umy$K&rf*gD#nSeqG`8tEy>%ScK}!fxMWVrC*J z2`3R4!c_RC5DzyOHwzPiXQHDa@B}?d1O89{Pf1|Z)l}4#6bKmz`hO%X9UVdZFB0+- z#)SB9>3>H;a)Oe;6Vm=0|2Kg`|GOVLntx09i{rEX?fq}-+Z&4;3-6ZSzy0vG@7+l6 z+um0Lovpp?ja$zx+8XQH>&lyI%05*n&sFNyRF+K@8`qWPF666}Ri&A=rR_{%eX^q#-NRBT{xVIXtl%5b(iLvR4kRJORvd9xM~C>7`0DlEQEzvJqy3_Cy|td-QLFS+P4F`h^7rqzQERtB z1$f_Sw^nbm(SL3OPjL!La51m4GOMyyb9Z-tZmQj8qS0ico@(QkW)H75(aEz?^SWaf z=b&9{tX^uOpKE4**FG}VPEFlC-PSSD)jlf3#^-^lMUJs{hN%{zcEv{O5f-kACRWDw zDW!VqQZ6M3`^*q?>pVRTLRn)>P&QWgd`#VAj1fK-x({@lG&a9hA@QI|RFRMQ}X(2C3FbpFil2JW~S=~!XQAb}MMyNisqK!68j8VZ=Ko&)? zld*^(qpTU7tUFvxfDxw02s0sALRN&6OH74Q%!)xoo8ULbTZkJ%as-#ku`%D^5xdFB z%ET=~&7(vx?R8czf}Lns{>MevsG6x0ETKf(Ery!b8E4e1d=mE z(<;Q&-#sMEImivrcfJ$k@9XC3<;;cj3UUkc5AqJ?l56*z3kLwEBb0`kS$OGQNeuj& z<>K3zje8wE_k4Ty?^$-VTg)y_+pOMhYUE5YdE-*LSocEOx8bcm|4{_Ereu2aB1_#LI#ECg>8&dTtJ!{#%fQC{B21qvYhbRJS&vl0iS-In}C}yfbUXjxlS=W{uxIA8 z!X@{4e>rN+plGe+sngTb@~>rEj<8|oQ*p#cNkjk)H$9 z4l|&KXUE62!Ph*%1_kSsaIxX!0f`-uO8f}VGFv%(VEZ`Y6Um%P4H_`)p|uT&P?9qN zJ|Bml6H_P0QjK4LgY^!a*#^Eiy*LuXKKy(d%fqR>*}^*35j(GnDX@nRM9@QGUE@+> z6ZJaT-a^ZV)pm>+O6&UZN__nhID@WO@)8Tt@6RdgLersrm{CNhoL#154gYJy6SZj2 zHHLCirYsI=DDl;^9j7<|*;2%IK!T-$C9Op!&#wLba95&OL;z7Y?%IlJlx1x+Uu15wYXoz>RdLq@1UuS-jb!WR%0#Y^TA>?`5>ImN9 z>@PtPeBp}MNvFSV2Fgc0Kt8^yl>>Gjg7g}Dy3rB!Tm{MkV%hKBEQPHy#l;MA7>&1Q zW*&SV=H=xbzeaOM3OHq=WsbQ?u)f;I(Pu>6JYq z84b?AjzS-|fX=EsVGvLe!9@ky009rd)Sxd!`m~G%ZS^$`cMUUO1kLG=qT4o#^g26oE;)&-V&l3@+~ysY~A&B>;Fp(^q5#RH`MFsY4R9 zL*uGg5O$2DnEOia`$#~7#~@Rf7Ag+lMx}Un#mEr;TQ&eb{*7FC2w;b-*!qk<_TwLX z&kn_Q%=<*2N<)BtDnw;k!RY;YQ8-T(FRey`cIgl>Q@mxi(w3VWo@epwiu#%pMg`Ov zQD5j(K+|@MLu!ON6bckHW8Uw@0U9SD_~K4fvnr(;6N$D?;!SQIgOW$p%E|MGFm@u# z#GbqH^D}#WGWDFkXX(^<)Og~i|1bTjRbcOV^0h>)OaV45 z6c+(tw#S0h*8-X8q&P%HZlXY#(hox8aDcv>+Zl-HM%GWxGJIH=1w>;I0aOiHK4G#q zxUY(Q+|$M3TQ?7<4QD-d3P^Hz6`Af zHV70e4hr7H00|BUbo7k0@U>dgi~ASE_v>$$Y3I@a7#4(?l=jovu^etd zoISr(A+WJ7i7Z}{#=mXNKAj1;acduf=V$EW$=Pxx5= z)=%)71kJ$s1pBXteBQNIAbBDP8xF`p9PZfq*!P>onurpSYkIUjm7cQU9nkwD= zae&?S6knHHr1X4F-g^0$_Hb)wp zoh=yrI(T1D-qwDc^7f}3aM5=6RBP-nI7R)%Lzm0EEbwMvst|EH8{onI7_-U)L??e6 za=_39?0;DRKPzb7=Wz^p4b6a$DclETDgeJ`iYqH#YT=;pTX{ls7$pvd7sb((M#1@X zrWs6J2~M&nav)^5u`=UQvsHiecs1DU!0+gtpTtjZ%76yizl>$~kz5a7i%}STt^%|- zRmsvY^!X#=H)^@@cRU9ELUc6k9)v!j^$SUHzTKv{GLYl&frizx@kw8|>uh|6*#XmQ zWCJs>qoGYZbt(7ycF-a_BCEmmJtwH<)>lumr>TZhlaq?~eoYnS2pUPxtzn~ii9ELu zH&zN|4&OZc&>@^JX638e;xzd8uXgibFVOYI1_D5|C@7AN#UJtyRdY#8ODnX6d1X$o z6va<`Fyl`H8d0A+zU-;SUh@5#o)oUWI^t@x+p4_fx-xM6$LiN-7NRTRPP2*!mx{y0 z01L?WgF3iWIqs(y+95Vp4V8&3c>ab09C@2oD>)_h?s7n%dZrNXsP;utd)(W)MCKxk7KR!TCq(S=@m&Z~90uLZ2? z7O4Z6W@{f|D)BctN-gAI5xbLvDJx-31GZhRbH~Cg>w2-Wu*KQ;qEEOP7|Mk}7&D(` zThiGOX`ZB=v6cWxB?|SiHNy5ZoA={bKkWk8K26lyddlvcahl`MF_Wkzdi3owyUZgt z=?~2Dvd$_>k>i`_Z&n;cGeiSqWw(`;nM(^#NmFS>1Bo=Yu234$JdI=>d_JqM&ag6v zTHgbH@u@%Ye$DNEh@5yGCd`(g?XGK>Wlu&;cmI{ocaO>&x(vOXJvdAmPp?3Hzb;Toxl8nU zD3kApH5$UxwNe8QEq0k+V{4C#I8T}bpRBY2lcIFsAGs`kj5Pkie5ZhYP|3nPm{*t=yul3Uo7w~ zY{?I9IiTBAPw>>h`%(znQ%L(G&?2cAwX`Uj8fXCI{=q&>2Z{s*>u>S$sBE-3|6J6! z?NEo%4#|2P7@5WR>_#3sf=;RN_wjy2_@`U@XIg&|_-3)H9bU9XfGgwaM!WY?UFgrx zTZdd+RdE>g9V!fcdwfbLD;Eh9c5J+umG;|#7hYP}=v;Lu(jU~O+HCpfIQeQ*1>ar} za4s>BozP{l4fCkNw7x&o72Nn}Vr`VNt4}gKwgT9`C?2Jh7 zpnhD7s?rp_ef=osCmN1Rfv9bn6|{%Cj*E+niCrmpaKRB32G(d{zSOPytWaVLs#K6+ z_{)o_UFHBR;1|CoaoP`usf#wkztzm6&nyXE)WkXZuEYcMIRTW93YjXkFvc(>vSXfWz>=YEmw3`5y=do zM&GAYUMf-m)`~Q-gXvHtawkLi{FVbUTNfB8; zPONnLNxlL%Gv5|VY>zvT01l+Gx3qpAsCuTA9iUI9Lgx=_7aBt#WOje>+}|?Hk&E4qnD5oUKRsbI+~b`0z%BYDTl! z*ahF*yd{$Yr3GrZGg`b5L;0d!Honw4#8m5K&flfFLo4QO7>y0H_blkrc^Lw`n7fF| zF?(BK?b|(~u@P96kA$+qWxf~@j z&1>cP`G@kav$I;NT2guTWJ>nLOR!{JyM=ai$$}@xA7^8{uShwgF<0BuXu((ICoEq{ zob(KDZ^|x-aRF<;i?>y$r_mgJqDcoS7cXa;#LxJSu5eD_O`~e zw1^iBxR;9x4o;cA^**mwD7nRWd66R6RLR6ffLdb7QMB}@814=)q${6 zwm}t;E??mm@9W=tmmM3^X;;-#>tWoBmi=gFshtrxyTrL=)HcNF!<>5pB)U-FBnc8jGANwUoY&eazt)~@z>vnXjVW%h7@k}Z;qUq1x)6zqd3+E##EUG>Eztz#L zlZtmPp_f~n{g=bpsQVlKD3Lf`$5N7Kw(wYv-nw=axh?t`9{w-u?J z9%XJ`yo`=nX71u4Dozb|EUG{kb>;8~K4g^x{G2dOQe8C2>uXQW5a<)Ypx@z9#ixbSJu(DElat-(SlUg-M-#%8w$F+(%GkbR6#AV>jq02 z0bwG}r+MMQ+vnRWPs{%_hGfk8$hf-Sf=NnF5&~7nlSOo^`!NLcnW->)nOUNdSu!x) zAVTQ<%=2Oh6u-n9JaiPWx_EY?rb%hMrV{Jo%%Cm?wo)jE3e zLRD+*ni}=g(Wb{aof|W=ORT*7Cg@56Q~dQI5hr{acx|zxoNN|wifl0?0`h9tv-lF8 z!shLw(i?GwP88wMbji{lkq_FHkU~j*@*js|X#NCZbV8F%lYLvhbqKkNe=Cx|Wo^<8 zvv%}19H#W#LPMelBleK9yQwv@7U&g9zLat1iYI6x2f z07rNlepZaq}RA=}}FSE8j`WlEDv*3~3af985-MVGs{&bOFP*Awl?0a|Pk9`AA zGL0971*;+|KF2I)SP&dCjLc;Dy16Nl$yXv}lG4XfP4xRNmcP3|81(^g2?-ZJPu+%ro$1*e3EeRW0%n*7ce5Q>gzkmA#*GtzdowkF4>q&*_a zS0@)62ek4V=f0n~EB=lt7JA&6%;U%|dv5@>BgoAaVZs=yefjLVW>FEuMf5IAzpZnGC0297-DLY`48 zsv1@E%prdw8ze=Oj>2BDUKnm+QK3bm?Kgh6=8exex#qPyu<(B_YwQ&goChy#H+FM0*89HG?R)J6w1W_Hg8h!LW_av=uie9mgc(I5A#llCY z`ojfGvhzdw!Gs@vO;Wbrljd`VD#m6%^NDrTYq$ri4xtJ3Z6a0zRMc@5*b`BO7{Qf# z!z-G4Y#b;_ACnQ*)HP&NXZ3Wh$&T$hJv}`e(=DoOodk6vRSg`>+Np)3PH3U(_Qd35 z@Z56p_QOAeV@D2IDO7d8bgm{wDj+1pq@?P!@rd|@C6R>V0?2qxMWY#$zCd1I`ma(c zzg>h5nsfl`{8%9Tk(r@eQP&*NW7^Ij>nun$ZQ>O-%N%wj9q|CktAO@Yxuc9!#!~K5 zJME0UxKL#-C5dG`j^nZ10(T?#|yvlF&f5mGC)m!^NZCM=JXZpc8 zinlxrqa3bzN(<3O>T2Gft?bv1)c@0dDFG^GayTkQh7O%ByGqH-;`-0e&v<5r#Xsh> z%9?vH7Y}lZ;n1S!$RJ3(rIK@h$P2O!@(c4T_EhoByr&L3c(>w{fz^Ww6js7-NZ6rf z8$HbFZ{@Tkb8okkEPU_c* + + + + + + + + + + + From 0f772de2ec710ad2fac9593bc61da20d928a4bd8 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut@gmail.com" Date: Tue, 14 Dec 2010 19:08:15 +0000 Subject: [PATCH 02/33] cmake: Add ressource file git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4093 96395faa-99c1-11dd-bbfe-3dabce05a288 --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c4e5d4c6f0..d5540dee45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,6 +77,7 @@ set(resourceList AppIcon16.png AppIcon32.png AppIcon64.png BackgroundLogo.png + ConfigIcon_Appearance.png ButtonIcon_Camera.png ConfigIcon_Cpu.png ConfigIcon_Gamefixes.png From b39546fe81c583c95c5f28ed1a6105f14927c9f0 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut@gmail.com" Date: Tue, 14 Dec 2010 21:44:12 +0000 Subject: [PATCH 03/33] cmake: rework the resource stuff. Avoid rebuild and files are clear by cmake. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4095 96395faa-99c1-11dd-bbfe-3dabce05a288 --- CMakeLists.txt | 26 -------------------------- cmake/Pcsx2Utils.cmake | 25 ------------------------- pcsx2/CMakeLists.txt | 36 ++++++++++++++++++++++++++++++++++-- 3 files changed, 34 insertions(+), 53 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d5540dee45..482ab2e0ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,29 +65,3 @@ endif(EXISTS "${PROJECT_SOURCE_DIR}/pcsx2" AND pcsx2_core) if(EXISTS "${PROJECT_SOURCE_DIR}/plugins") add_subdirectory(plugins) endif(EXISTS "${PROJECT_SOURCE_DIR}/plugins") - -#------------------------------------------------------------------------------- -# Resources -#------------------------------------------------------------------------------- -# Specify all binary images to convert them into c/c++ header files. -# -#------------------------------------------------------------------------------- -# add resources here -set(resourceList AppIcon16.png - AppIcon32.png - AppIcon64.png - BackgroundLogo.png - ConfigIcon_Appearance.png - ButtonIcon_Camera.png - ConfigIcon_Cpu.png - ConfigIcon_Gamefixes.png - ConfigIcon_MemoryCard.png - ConfigIcon_Paths.png - ConfigIcon_Plugins.png - ConfigIcon_Speedhacks.png - ConfigIcon_Video.png - Dualshock.jpg) - -createResourceTarget(${resourceList}) -#------------------------------------------------------------------------------- - diff --git a/cmake/Pcsx2Utils.cmake b/cmake/Pcsx2Utils.cmake index 38097cea46..28223536dd 100644 --- a/cmake/Pcsx2Utils.cmake +++ b/cmake/Pcsx2Utils.cmake @@ -1,30 +1,5 @@ # additonal cmake macros and functions -#------------------------------------------------------------------------------- -# createResourceTarget -#------------------------------------------------------------------------------- -# This function is used to generate header files, used as resources. -# A list of Resources taken as input parameter. -#------------------------------------------------------------------------------- -function(createResourceTarget) - # working directory - set(workdir ${PROJECT_SOURCE_DIR}/pcsx2/gui/Resources) - - # create dummy target depending on bin2cpp - add_custom_target(Resources - DEPENDS bin2cpp) - - # create a custom command for every resource file - foreach(entry IN LISTS ARGV) - # create custom command and assign to target Resources - add_custom_command(TARGET Resources POST_BUILD - COMMAND bin2cpp ${entry} - WORKING_DIRECTORY ${workdir}) - endforeach(entry) -endfunction(createResourceTarget) -#------------------------------------------------------------------------------- - - #------------------------------------------------------------------------------- # detectOperatingSystem #------------------------------------------------------------------------------- diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index dd636f6de1..a4cc5f4124 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -363,6 +363,24 @@ set(pcsx2GuiHeaders gui/RecentIsoList.h ) +# Gui resources headers +set(pcsx2GuiResources + gui/Resources/AppIcon16.h + gui/Resources/AppIcon32.h + gui/Resources/AppIcon64.h + gui/Resources/BackgroundLogo.h + gui/Resources/ConfigIcon_Appearance.h + gui/Resources/ButtonIcon_Camera.h + gui/Resources/ConfigIcon_Cpu.h + gui/Resources/ConfigIcon_Gamefixes.h + gui/Resources/ConfigIcon_MemoryCard.h + gui/Resources/ConfigIcon_Paths.h + gui/Resources/ConfigIcon_Plugins.h + gui/Resources/ConfigIcon_Speedhacks.h + gui/Resources/ConfigIcon_Video.h + gui/Resources/Dualshock.h + ) + # IPU sources set(pcsx2IPUSources IPU/IPU.cpp @@ -568,6 +586,7 @@ set(Common ${pcsx2DebugToolsSources} ${pcsx2DebugToolsSources} ${pcsx2GuiSources} + ${pcsx2GuiResources} ${pcsx2GuiHeaders} ${pcsx2IPUSources} ${pcsx2IPUHeaders} @@ -618,8 +637,21 @@ add_executable(${Output} ${Common} ${Platform}) -# add dependencies -add_dependencies(${Output} Resources) +# Generate the resources files +add_custom_command(OUTPUT "gui/Resources/AppIcon16.h" COMMAND bin2cpp "gui/Resources/AppIcon16.png") +add_custom_command(OUTPUT "gui/Resources/AppIcon32.h" COMMAND bin2cpp "gui/Resources/AppIcon32.png") +add_custom_command(OUTPUT "gui/Resources/AppIcon64.h" COMMAND bin2cpp "gui/Resources/AppIcon64.png") +add_custom_command(OUTPUT "gui/Resources/BackgroundLogo.h" COMMAND bin2cpp "gui/Resources/BackgroundLogo.png") +add_custom_command(OUTPUT "gui/Resources/ButtonIcon_Camera.h" COMMAND bin2cpp "gui/Resources/ButtonIcon_Camera.png") +add_custom_command(OUTPUT "gui/Resources/ConfigIcon_Appearance.h" COMMAND bin2cpp "gui/Resources/ConfigIcon_Appearance.png") +add_custom_command(OUTPUT "gui/Resources/ConfigIcon_Cpu.h" COMMAND bin2cpp "gui/Resources/ConfigIcon_Cpu.png") +add_custom_command(OUTPUT "gui/Resources/ConfigIcon_Gamefixes.h" COMMAND bin2cpp "gui/Resources/ConfigIcon_Gamefixes.png") +add_custom_command(OUTPUT "gui/Resources/ConfigIcon_MemoryCard.h" COMMAND bin2cpp "gui/Resources/ConfigIcon_MemoryCard.png") +add_custom_command(OUTPUT "gui/Resources/ConfigIcon_Paths.h" COMMAND bin2cpp "gui/Resources/ConfigIcon_Paths.png") +add_custom_command(OUTPUT "gui/Resources/ConfigIcon_Plugins.h" COMMAND bin2cpp "gui/Resources/ConfigIcon_Plugins.png") +add_custom_command(OUTPUT "gui/Resources/ConfigIcon_Speedhacks.h" COMMAND bin2cpp "gui/Resources/ConfigIcon_Speedhacks.png") +add_custom_command(OUTPUT "gui/Resources/ConfigIcon_Video.h" COMMAND bin2cpp "gui/Resources/ConfigIcon_Video.png") +add_custom_command(OUTPUT "gui/Resources/Dualshock.h" COMMAND bin2cpp "gui/Resources/Dualshock.jpg") # link target with project internal libraries target_link_libraries(${Output} Utilities x86emitter) From 375a766cf12a6e84aa890841d40a3774090ff743 Mon Sep 17 00:00:00 2001 From: sudonim1 Date: Fri, 17 Dec 2010 01:32:40 +0000 Subject: [PATCH 04/33] GSDx: Disable MSAA if all checks failed. Also, prefer normal 32 bit depth to lockable 32 bit depth on D3D9. I was anticipating a use for locking but further examination of the code revealed that to be impractical. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4099 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDevice11.cpp | 3 +++ plugins/GSdx/GSDevice9.cpp | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/GSdx/GSDevice11.cpp b/plugins/GSdx/GSDevice11.cpp index dca96bfe34..196569e410 100644 --- a/plugins/GSdx/GSDevice11.cpp +++ b/plugins/GSdx/GSDevice11.cpp @@ -229,6 +229,9 @@ bool GSDevice11::Create(GSWnd* wnd) } } + if (m_msaa_desc.Count == 1) + m_msaa = 0; + // convert D3D11_INPUT_ELEMENT_DESC il_convert[] = diff --git a/plugins/GSdx/GSDevice9.cpp b/plugins/GSdx/GSDevice9.cpp index 27a43e0a4e..1d80539f32 100644 --- a/plugins/GSdx/GSDevice9.cpp +++ b/plugins/GSdx/GSDevice9.cpp @@ -91,10 +91,10 @@ bool GSDevice9::Create(GSWnd* wnd) if(!m_d3d) return false; - if (TestDepthFormat(m_d3d, D3DFMT_D32F_LOCKABLE)) - m_depth_format = D3DFMT_D32F_LOCKABLE; - else if (TestDepthFormat(m_d3d, D3DFMT_D32)) + if (TestDepthFormat(m_d3d, D3DFMT_D32)) m_depth_format = D3DFMT_D32; + else if (TestDepthFormat(m_d3d, D3DFMT_D32F_LOCKABLE)) + m_depth_format = D3DFMT_D32F_LOCKABLE; else if (TestDepthFormat(m_d3d, D3DFMT_D24S8)) m_depth_format = D3DFMT_D24S8; else @@ -155,6 +155,9 @@ bool GSDevice9::Create(GSWnd* wnd) } } + if (m_msaa_desc.Count == 1) + m_msaa = 0; + // if(!Reset(1, 1)) From 4ebbe65c4f554dee5050c0b470259524d87f4b97 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Sun, 19 Dec 2010 08:31:35 +0000 Subject: [PATCH 05/33] w32pthreads: maintenance work; applied patches inspired by the VLC guys that make the code a little more sensible where pointer types are concerned. Removed some obsolete ancient compiler crap regarding interlocked exchanges. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4100 96395faa-99c1-11dd-bbfe-3dabce05a288 --- 3rdparty/w32pthreads/include/implement.h | 64 +++++++++---------- 3rdparty/w32pthreads/include/pthread.h | 3 +- 3rdparty/w32pthreads/pthread_barrier_wait.c | 9 +-- 3rdparty/w32pthreads/pthread_mutex_lock.c | 17 ++--- .../w32pthreads/pthread_mutex_timedlock.c | 17 ++--- 3rdparty/w32pthreads/pthread_mutex_trylock.c | 5 +- 3rdparty/w32pthreads/pthread_mutex_unlock.c | 6 +- 3rdparty/w32pthreads/pthread_spin_destroy.c | 9 +-- 3rdparty/w32pthreads/pthread_spin_lock.c | 9 +-- 3rdparty/w32pthreads/pthread_spin_trylock.c | 7 +- 3rdparty/w32pthreads/pthread_spin_unlock.c | 7 +- 3rdparty/w32pthreads/ptw32_MCS_lock.c | 38 +++++------ 3rdparty/w32pthreads/ptw32_cancel.c | 2 +- 3rdparty/w32pthreads/ptw32_processTerminate.c | 3 + 3rdparty/w32pthreads/ptw32_throw.c | 8 +-- 15 files changed, 74 insertions(+), 130 deletions(-) diff --git a/3rdparty/w32pthreads/include/implement.h b/3rdparty/w32pthreads/include/implement.h index b908436bb1..17fc2311ce 100644 --- a/3rdparty/w32pthreads/include/implement.h +++ b/3rdparty/w32pthreads/include/implement.h @@ -45,6 +45,9 @@ #include #include +#include +#include +#include /* * In case windows.h doesn't define it (e.g. WinCE perhaps) @@ -54,23 +57,10 @@ typedef VOID (APIENTRY *PAPCFUNC)(DWORD dwParam); #endif /* - * note: ETIMEDOUT is correctly defined in winsock.h - */ -#include - -/* - * In case ETIMEDOUT hasn't been defined above somehow. + * In case ETIMEDOUT hasn't been defined in winsock.h somehow. */ #ifndef ETIMEDOUT -# define ETIMEDOUT 10060 /* This is the value in winsock.h. */ -#endif - -#if !defined(malloc) -#include -#endif - -#if !defined(INT_MAX) -#include +# define ETIMEDOUT 10060 /* This is the value in winsock.h. */ #endif /* use local include files during development */ @@ -83,14 +73,6 @@ typedef VOID (APIENTRY *PAPCFUNC)(DWORD dwParam); #define INLINE #endif -#if defined (__MINGW32__) || (_MSC_VER >= 1300) -#define PTW32_INTERLOCKED_LONG long -#define PTW32_INTERLOCKED_LPLONG long* -#else -#define PTW32_INTERLOCKED_LONG PVOID -#define PTW32_INTERLOCKED_LPLONG PVOID* -#endif - #if defined(__MINGW32__) #include #elif defined(__BORLANDC__) @@ -338,9 +320,9 @@ struct ptw32_mcs_node_t_ { struct ptw32_mcs_node_t_ **lock; /* ptr to tail of queue */ struct ptw32_mcs_node_t_ *next; /* ptr to successor in queue */ - LONG readyFlag; /* set after lock is released by + HANDLE readyFlag; /* set after lock is released by predecessor */ - LONG nextFlag; /* set after 'next' ptr is set by + HANDLE nextFlag; /* set after 'next' ptr is set by successor */ }; @@ -668,18 +650,32 @@ extern "C" #endif -/* - * Defaults. Could be overridden when building the inlined version of the dll. - * See ptw32_InterlockedCompareExchange.c - */ -// Default to inlining the pthreads versions... (air) -#ifndef PTW32_INTERLOCKED_COMPARE_EXCHANGE -#define PTW32_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange +static INLINE void* _InterlockedExchangePointer( void* volatile* target, void* value ) +{ +#ifdef _M_AMD64 // high-level atomic ops, please leave these 64 bit checks in place. + return (void*)_InterlockedExchange64( (LONG_PTR*)target, value ); +#else + return (void*)_InterlockedExchange( (LONG_PTR*)target, (LONG_PTR)value ); #endif +} -#ifndef PTW32_INTERLOCKED_EXCHANGE -#define PTW32_INTERLOCKED_EXCHANGE _InterlockedExchange +static INLINE void* _InterlockedCompareExchangePointer( void* volatile* target, void* value, void* comparand ) +{ +#ifdef _M_AMD64 // high-level atomic ops, please leave these 64 bit checks in place. + return (void*)_InterlockedCompareExchange64( (LONG_PTR*)target, value, comparand ); +#else + return (void*)_InterlockedCompareExchange( (LONG_PTR*)target, (LONG_PTR)value, (LONG_PTR)comparand ); #endif +} + +static INLINE void* _InterlockedExchangeAddPointer( void* volatile* target, void* value ) +{ +#ifdef _M_AMD64 // high-level atomic ops, please leave these 64 bit checks in place. + return (void*)_InterlockedExchangeAdd64( (LONG_PTR*)target, (LONG_PTR)value ); +#else + return (void*)_InterlockedExchangeAdd( (LONG_PTR*)target, (LONG_PTR)value ); +#endif +} /* diff --git a/3rdparty/w32pthreads/include/pthread.h b/3rdparty/w32pthreads/include/pthread.h index e19765e179..4c22939488 100644 --- a/3rdparty/w32pthreads/include/pthread.h +++ b/3rdparty/w32pthreads/include/pthread.h @@ -306,8 +306,9 @@ enum { #endif #endif -#ifndef HAVE_STRUCT_TIMESPEC +#if !defined( HAVE_STRUCT_TIMESPEC ) && !defined( _TIMESPEC_DEFINED ) #define HAVE_STRUCT_TIMESPEC 1 +#define _TIMESPEC_DEFINED 1 struct timespec { long tv_sec; long tv_nsec; diff --git a/3rdparty/w32pthreads/pthread_barrier_wait.c b/3rdparty/w32pthreads/pthread_barrier_wait.c index 520b1e3063..70b0e5cf0f 100644 --- a/3rdparty/w32pthreads/pthread_barrier_wait.c +++ b/3rdparty/w32pthreads/pthread_barrier_wait.c @@ -84,13 +84,8 @@ pthread_barrier_wait (pthread_barrier_t * barrier) */ if (0 == result) { - result = ((PTW32_INTERLOCKED_LONG) step == - PTW32_INTERLOCKED_COMPARE_EXCHANGE ((PTW32_INTERLOCKED_LPLONG) - & (b->iStep), - (PTW32_INTERLOCKED_LONG) - (1L - step), - (PTW32_INTERLOCKED_LONG) - step) ? + result = ( step == + _InterlockedCompareExchange ( &(b->iStep), (1L - step), step) ? PTHREAD_BARRIER_SERIAL_THREAD : 0); } diff --git a/3rdparty/w32pthreads/pthread_mutex_lock.c b/3rdparty/w32pthreads/pthread_mutex_lock.c index 3765331fcf..301e62fec4 100644 --- a/3rdparty/w32pthreads/pthread_mutex_lock.c +++ b/3rdparty/w32pthreads/pthread_mutex_lock.c @@ -68,13 +68,9 @@ pthread_mutex_lock (pthread_mutex_t * mutex) if (mx->kind == PTHREAD_MUTEX_NORMAL) { - if ((LONG) PTW32_INTERLOCKED_EXCHANGE( - (LPLONG) &mx->lock_idx, - (LONG) 1) != 0) + if (_InterlockedExchange( &mx->lock_idx, 1) != 0) { - while ((LONG) PTW32_INTERLOCKED_EXCHANGE( - (LPLONG) &mx->lock_idx, - (LONG) -1) != 0) + while (_InterlockedExchange( &mx->lock_idx, -1) != 0) { if (WAIT_OBJECT_0 != WaitForSingleObject (mx->event, INFINITE)) { @@ -88,10 +84,7 @@ pthread_mutex_lock (pthread_mutex_t * mutex) { pthread_t self = pthread_self(); - if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE( - (PTW32_INTERLOCKED_LPLONG) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1, - (PTW32_INTERLOCKED_LONG) 0) == 0) + if (_InterlockedCompareExchange(&mx->lock_idx, 1, 0) == 0) { mx->recursive_count = 1; mx->ownerThread = self; @@ -111,9 +104,7 @@ pthread_mutex_lock (pthread_mutex_t * mutex) } else { - while ((LONG) PTW32_INTERLOCKED_EXCHANGE( - (LPLONG) &mx->lock_idx, - (LONG) -1) != 0) + while (_InterlockedExchange(&mx->lock_idx, -1) != 0) { if (WAIT_OBJECT_0 != WaitForSingleObject (mx->event, INFINITE)) { diff --git a/3rdparty/w32pthreads/pthread_mutex_timedlock.c b/3rdparty/w32pthreads/pthread_mutex_timedlock.c index 54af13fdbf..30505d87ec 100644 --- a/3rdparty/w32pthreads/pthread_mutex_timedlock.c +++ b/3rdparty/w32pthreads/pthread_mutex_timedlock.c @@ -133,13 +133,9 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex, if (mx->kind == PTHREAD_MUTEX_NORMAL) { - if ((LONG) PTW32_INTERLOCKED_EXCHANGE( - (LPLONG) &mx->lock_idx, - (LONG) 1) != 0) + if (_InterlockedExchange(&mx->lock_idx, 1) != 0) { - while ((LONG) PTW32_INTERLOCKED_EXCHANGE( - (LPLONG) &mx->lock_idx, - (LONG) -1) != 0) + while (_InterlockedExchange(&mx->lock_idx, -1) != 0) { if (0 != (result = ptw32_timed_eventwait (mx->event, abstime))) { @@ -152,10 +148,7 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex, { pthread_t self = pthread_self(); - if ((PTW32_INTERLOCKED_LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE( - (PTW32_INTERLOCKED_LPLONG) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1, - (PTW32_INTERLOCKED_LONG) 0) == 0) + if (_InterlockedCompareExchange(&mx->lock_idx, 1, 0) == 0) { mx->recursive_count = 1; mx->ownerThread = self; @@ -175,9 +168,7 @@ pthread_mutex_timedlock (pthread_mutex_t * mutex, } else { - while ((LONG) PTW32_INTERLOCKED_EXCHANGE( - (LPLONG) &mx->lock_idx, - (LONG) -1) != 0) + while (_InterlockedExchange(&mx->lock_idx, -1) != 0) { if (0 != (result = ptw32_timed_eventwait (mx->event, abstime))) { diff --git a/3rdparty/w32pthreads/pthread_mutex_trylock.c b/3rdparty/w32pthreads/pthread_mutex_trylock.c index b1ad7e62b3..61e95611d5 100644 --- a/3rdparty/w32pthreads/pthread_mutex_trylock.c +++ b/3rdparty/w32pthreads/pthread_mutex_trylock.c @@ -63,10 +63,7 @@ pthread_mutex_trylock (pthread_mutex_t * mutex) mx = *mutex; - if (0 == (LONG) PTW32_INTERLOCKED_COMPARE_EXCHANGE ( - (PTW32_INTERLOCKED_LPLONG) &mx->lock_idx, - (PTW32_INTERLOCKED_LONG) 1, - (PTW32_INTERLOCKED_LONG) 0)) + if (0 == (LONG) _InterlockedCompareExchange(&mx->lock_idx, 1, 0)) { if (mx->kind != PTHREAD_MUTEX_NORMAL) { diff --git a/3rdparty/w32pthreads/pthread_mutex_unlock.c b/3rdparty/w32pthreads/pthread_mutex_unlock.c index 293f5b86af..d148d34de6 100644 --- a/3rdparty/w32pthreads/pthread_mutex_unlock.c +++ b/3rdparty/w32pthreads/pthread_mutex_unlock.c @@ -60,8 +60,7 @@ pthread_mutex_unlock (pthread_mutex_t * mutex) { LONG idx; - idx = (LONG) PTW32_INTERLOCKED_EXCHANGE ((LPLONG) &mx->lock_idx, - (LONG) 0); + idx = _InterlockedExchange (&mx->lock_idx, 0); if (idx != 0) { if (idx < 0) @@ -92,8 +91,7 @@ pthread_mutex_unlock (pthread_mutex_t * mutex) { mx->ownerThread.p = NULL; - if ((LONG) PTW32_INTERLOCKED_EXCHANGE ((LPLONG) &mx->lock_idx, - (LONG) 0) < 0) + if (_InterlockedExchange (&mx->lock_idx, 0) < 0) { /* Someone may be waiting on that mutex */ if (SetEvent (mx->event) == 0) diff --git a/3rdparty/w32pthreads/pthread_spin_destroy.c b/3rdparty/w32pthreads/pthread_spin_destroy.c index d6bbc32f72..fe8b13056f 100644 --- a/3rdparty/w32pthreads/pthread_spin_destroy.c +++ b/3rdparty/w32pthreads/pthread_spin_destroy.c @@ -54,13 +54,8 @@ pthread_spin_destroy (pthread_spinlock_t * lock) { result = pthread_mutex_destroy (&(s->u.mutex)); } - else if ((PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED != - PTW32_INTERLOCKED_COMPARE_EXCHANGE ((PTW32_INTERLOCKED_LPLONG) - & (s->interlock), - (PTW32_INTERLOCKED_LONG) - PTW32_OBJECT_INVALID, - (PTW32_INTERLOCKED_LONG) - PTW32_SPIN_UNLOCKED)) + else if (PTW32_SPIN_UNLOCKED != + _InterlockedCompareExchange(&(s->interlock), PTW32_OBJECT_INVALID, PTW32_SPIN_UNLOCKED)) { result = EINVAL; } diff --git a/3rdparty/w32pthreads/pthread_spin_lock.c b/3rdparty/w32pthreads/pthread_spin_lock.c index f6fa3e48de..5b6de30522 100644 --- a/3rdparty/w32pthreads/pthread_spin_lock.c +++ b/3rdparty/w32pthreads/pthread_spin_lock.c @@ -59,13 +59,8 @@ pthread_spin_lock (pthread_spinlock_t * lock) s = *lock; - while ((PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED == - PTW32_INTERLOCKED_COMPARE_EXCHANGE ((PTW32_INTERLOCKED_LPLONG) & - (s->interlock), - (PTW32_INTERLOCKED_LONG) - PTW32_SPIN_LOCKED, - (PTW32_INTERLOCKED_LONG) - PTW32_SPIN_UNLOCKED)) + while (PTW32_SPIN_LOCKED == + _InterlockedCompareExchange(&(s->interlock), PTW32_SPIN_LOCKED, PTW32_SPIN_UNLOCKED)) { } diff --git a/3rdparty/w32pthreads/pthread_spin_trylock.c b/3rdparty/w32pthreads/pthread_spin_trylock.c index ce44287463..5fb55f8ccd 100644 --- a/3rdparty/w32pthreads/pthread_spin_trylock.c +++ b/3rdparty/w32pthreads/pthread_spin_trylock.c @@ -60,12 +60,7 @@ pthread_spin_trylock (pthread_spinlock_t * lock) s = *lock; switch ((long) - PTW32_INTERLOCKED_COMPARE_EXCHANGE ((PTW32_INTERLOCKED_LPLONG) & - (s->interlock), - (PTW32_INTERLOCKED_LONG) - PTW32_SPIN_LOCKED, - (PTW32_INTERLOCKED_LONG) - PTW32_SPIN_UNLOCKED)) + _InterlockedCompareExchange(&(s->interlock), PTW32_SPIN_LOCKED, PTW32_SPIN_UNLOCKED)) { case PTW32_SPIN_UNLOCKED: return 0; diff --git a/3rdparty/w32pthreads/pthread_spin_unlock.c b/3rdparty/w32pthreads/pthread_spin_unlock.c index dc214ddb34..d9f3c3fdb6 100644 --- a/3rdparty/w32pthreads/pthread_spin_unlock.c +++ b/3rdparty/w32pthreads/pthread_spin_unlock.c @@ -55,12 +55,7 @@ pthread_spin_unlock (pthread_spinlock_t * lock) } switch ((long) - PTW32_INTERLOCKED_COMPARE_EXCHANGE ((PTW32_INTERLOCKED_LPLONG) & - (s->interlock), - (PTW32_INTERLOCKED_LONG) - PTW32_SPIN_UNLOCKED, - (PTW32_INTERLOCKED_LONG) - PTW32_SPIN_LOCKED)) + _InterlockedCompareExchange (&(s->interlock), PTW32_SPIN_UNLOCKED, PTW32_SPIN_LOCKED)) { case PTW32_SPIN_LOCKED: return 0; diff --git a/3rdparty/w32pthreads/ptw32_MCS_lock.c b/3rdparty/w32pthreads/ptw32_MCS_lock.c index be70b7ebb7..a350114cdb 100644 --- a/3rdparty/w32pthreads/ptw32_MCS_lock.c +++ b/3rdparty/w32pthreads/ptw32_MCS_lock.c @@ -98,13 +98,11 @@ * set flag to -1 otherwise. Note that -1 cannot be a valid handle value. */ INLINE void -ptw32_mcs_flag_set (LONG * flag) +ptw32_mcs_flag_set (HANDLE * flag) { - HANDLE e = (HANDLE)PTW32_INTERLOCKED_COMPARE_EXCHANGE( - (PTW32_INTERLOCKED_LPLONG)flag, - (PTW32_INTERLOCKED_LONG)-1, - (PTW32_INTERLOCKED_LONG)0); - if ((HANDLE)0 != e) + HANDLE e = (HANDLE)_InterlockedCompareExchangePointer(flag, (HANDLE)-1, (HANDLE)0); + + if (e) { /* another thread has already stored an event handle in the flag */ SetEvent(e); @@ -118,24 +116,21 @@ ptw32_mcs_flag_set (LONG * flag) * set, and proceed without creating an event otherwise. */ INLINE void -ptw32_mcs_flag_wait (LONG * flag) +ptw32_mcs_flag_wait (HANDLE * flag) { - if (0 == InterlockedExchangeAdd((LPLONG)flag, 0)) /* MBR fence */ + if (0 == _InterlockedExchangeAddPointer(flag, NULL)) /* MBR fence */ { /* the flag is not set. create event. */ HANDLE e = CreateEvent(NULL, PTW32_FALSE, PTW32_FALSE, NULL); - if (0 == PTW32_INTERLOCKED_COMPARE_EXCHANGE( - (PTW32_INTERLOCKED_LPLONG)flag, - (PTW32_INTERLOCKED_LONG)e, - (PTW32_INTERLOCKED_LONG)0)) - { - /* stored handle in the flag. wait on it now. */ - WaitForSingleObject(e, INFINITE); - } + if (0 == _InterlockedCompareExchangePointer(flag, e, 0)) + { + /* stored handle in the flag. wait on it now. */ + WaitForSingleObject(e, INFINITE); + } - CloseHandle(e); + CloseHandle(e); } } @@ -158,8 +153,7 @@ ptw32_mcs_lock_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node) node->next = 0; /* initially, no successor */ /* queue for the lock */ - pred = (ptw32_mcs_local_node_t *)PTW32_INTERLOCKED_EXCHANGE((LPLONG)lock, - (LONG)node); + pred = (ptw32_mcs_local_node_t *)_InterlockedExchangePointer(lock, node); if (0 != pred) { @@ -190,9 +184,7 @@ ptw32_mcs_lock_release (ptw32_mcs_local_node_t * node) /* no known successor */ if (node == (ptw32_mcs_local_node_t *) - PTW32_INTERLOCKED_COMPARE_EXCHANGE((PTW32_INTERLOCKED_LPLONG)lock, - (PTW32_INTERLOCKED_LONG)0, - (PTW32_INTERLOCKED_LONG)node)) + _InterlockedCompareExchangePointer(lock, 0, node)) { /* no successor, lock is free now */ return; @@ -201,7 +193,7 @@ ptw32_mcs_lock_release (ptw32_mcs_local_node_t * node) /* wait for successor */ ptw32_mcs_flag_wait(&node->nextFlag); next = (ptw32_mcs_local_node_t *) - InterlockedExchangeAdd((LPLONG)&node->next, 0); /* MBR fence */ + _InterlockedExchangeAddPointer(&node->next, NULL); /* MBR fence */ } /* pass the lock */ diff --git a/3rdparty/w32pthreads/ptw32_cancel.c b/3rdparty/w32pthreads/ptw32_cancel.c index 540bcbe1bf..33252c97d3 100644 --- a/3rdparty/w32pthreads/ptw32_cancel.c +++ b/3rdparty/w32pthreads/ptw32_cancel.c @@ -73,7 +73,7 @@ ptw32_cancel_self (void) } static void CALLBACK -ptw32_cancel_callback (DWORD unused) +ptw32_cancel_callback (DWORD_PTR unused) { ptw32_throw (PTW32_EPS_CANCEL); diff --git a/3rdparty/w32pthreads/ptw32_processTerminate.c b/3rdparty/w32pthreads/ptw32_processTerminate.c index 25da104477..0282dbe7fa 100644 --- a/3rdparty/w32pthreads/ptw32_processTerminate.c +++ b/3rdparty/w32pthreads/ptw32_processTerminate.c @@ -94,6 +94,9 @@ ptw32_processTerminate (void) tp = tpNext; } + ptw32_threadReuseTop = PTW32_THREAD_REUSE_EMPTY; + ptw32_threadReuseBottom = PTW32_THREAD_REUSE_EMPTY; + LeaveCriticalSection (&ptw32_thread_reuse_lock); /* diff --git a/3rdparty/w32pthreads/ptw32_throw.c b/3rdparty/w32pthreads/ptw32_throw.c index b85d8aa721..5b7eb96f4d 100644 --- a/3rdparty/w32pthreads/ptw32_throw.c +++ b/3rdparty/w32pthreads/ptw32_throw.c @@ -72,15 +72,15 @@ ptw32_throw (DWORD exception) * explicit thread exit here after cleaning up POSIX * residue (i.e. cleanup handlers, POSIX thread handle etc). */ - unsigned exitCode = 0; + void* exitCode = 0; switch (exception) { case PTW32_EPS_CANCEL: - exitCode = (unsigned) PTHREAD_CANCELED; + exitCode = PTHREAD_CANCELED; break; case PTW32_EPS_EXIT: - exitCode = (unsigned) sp->exitStatus;; + exitCode = sp->exitStatus; break; } @@ -91,7 +91,7 @@ ptw32_throw (DWORD exception) #endif #if ! defined (__MINGW32__) || defined (__MSVCRT__) || defined (__DMC__) - _endthreadex (exitCode); + _endthreadex ((unsigned)exitCode); #else _endthread (); #endif From 40f6aef1d3cf5c6e658baf6dfc54cb36268f72a7 Mon Sep 17 00:00:00 2001 From: "feal87@gmail.com" Date: Sun, 19 Dec 2010 10:48:09 +0000 Subject: [PATCH 06/33] Fixing some stuff on the GSDumpGUI (more update to come) to allow me to test decently Gsdx while waiting for DirectX SDK to complete download 1) Change log to "log.txt" 2) Fix a crash when an invalid directory is specified in the textbox. 3) Fix working folder for loading library. Now it searches for dependencies in the same folder as the plugin dll. 4) Fix configuration save/loading git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4102 96395faa-99c1-11dd-bbfe-3dabce05a288 --- tools/GSDumpGUI/Core/Program.cs | 2 ++ tools/GSDumpGUI/Forms/frmMain.cs | 15 +++++++++++++-- tools/GSDumpGUI/GSDumpGUI.sln | 20 ++++++++++++++++++++ tools/GSDumpGUI/Library/GSDXWrapper.cs | 9 +++++++-- 4 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 tools/GSDumpGUI/GSDumpGUI.sln diff --git a/tools/GSDumpGUI/Core/Program.cs b/tools/GSDumpGUI/Core/Program.cs index 51534124a8..ee7698911f 100644 --- a/tools/GSDumpGUI/Core/Program.cs +++ b/tools/GSDumpGUI/Core/Program.cs @@ -7,6 +7,7 @@ using System.Runtime.InteropServices; using System.Threading; using System.Diagnostics; using GSDumpGUI.Properties; +using System.IO; namespace GSDumpGUI { @@ -51,6 +52,7 @@ namespace GSDumpGUI GSDXWrapper wrap = new GSDXWrapper(); wrap.Load(DLLPath); + Directory.SetCurrentDirectory(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + Path.GetFileName(DLLPath) + "\\")); if (Operation == "GSReplay") { ChangeIcon = true; diff --git a/tools/GSDumpGUI/Forms/frmMain.cs b/tools/GSDumpGUI/Forms/frmMain.cs index 103785e130..afff9cf2da 100644 --- a/tools/GSDumpGUI/Forms/frmMain.cs +++ b/tools/GSDumpGUI/Forms/frmMain.cs @@ -124,18 +124,29 @@ namespace GSDumpGUI private void cmdSave_Click(object sender, EventArgs e) { + Boolean Err = false; + if (System.IO.Directory.Exists(txtDumpsDirectory.Text)) Properties.Settings.Default.DumpDir = txtDumpsDirectory.Text; else + { + Err = true; MessageBox.Show("Select a correct directory for dumps", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } if (System.IO.Directory.Exists(txtGSDXDirectory.Text)) Properties.Settings.Default.GSDXDir = txtGSDXDirectory.Text; else + { + Err = true; MessageBox.Show("Select a correct directory for GSDX", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } - Properties.Settings.Default.Save(); - ReloadGSDXs(); + if (!Err) + { + Properties.Settings.Default.Save(); + ReloadGSDXs(); + } } private void cmdStart_Click(object sender, EventArgs e) diff --git a/tools/GSDumpGUI/GSDumpGUI.sln b/tools/GSDumpGUI/GSDumpGUI.sln new file mode 100644 index 0000000000..bed0a4844e --- /dev/null +++ b/tools/GSDumpGUI/GSDumpGUI.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GSDumpGUI", "GSDumpGUI.csproj", "{825E4311-652D-4A1E-8AA1-F6D81B186E33}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {825E4311-652D-4A1E-8AA1-F6D81B186E33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {825E4311-652D-4A1E-8AA1-F6D81B186E33}.Debug|Any CPU.Build.0 = Debug|Any CPU + {825E4311-652D-4A1E-8AA1-F6D81B186E33}.Release|Any CPU.ActiveCfg = Release|Any CPU + {825E4311-652D-4A1E-8AA1-F6D81B186E33}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/tools/GSDumpGUI/Library/GSDXWrapper.cs b/tools/GSDumpGUI/Library/GSDXWrapper.cs index d1305916c9..a470d8de84 100644 --- a/tools/GSDumpGUI/Library/GSDXWrapper.cs +++ b/tools/GSDumpGUI/Library/GSDXWrapper.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; +using System.IO; namespace GSDumpGUI { @@ -24,6 +25,8 @@ namespace GSDumpGUI { NativeMethods.SetErrorMode(0x8007); Boolean Ris = true; + + Directory.SetCurrentDirectory(Path.GetDirectoryName(DLL)); IntPtr hmod = NativeMethods.LoadLibrary(DLL); if (hmod.ToInt64() > 0) { @@ -35,16 +38,17 @@ namespace GSDumpGUI if (!((funcaddrConfig.ToInt64() > 0) && (funcaddrLibName.ToInt64() > 0) && (funcaddrReplay.ToInt64() > 0))) { Int32 id = NativeMethods.GetLastError(); - System.IO.File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "test.txt", DLL + " failed to load. Error " + id); + System.IO.File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "log.txt", DLL + " failed to load. Error " + id + Environment.NewLine); Ris = false; } } else { Int32 id = NativeMethods.GetLastError(); - System.IO.File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "test.txt", DLL + " failed to load. Error " + id + Environment.NewLine); + System.IO.File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "log.txt", DLL + " failed to load. Error " + id + Environment.NewLine); Ris = false; } + NativeMethods.SetErrorMode(0x0000); return Ris; } @@ -60,6 +64,7 @@ namespace GSDumpGUI Unload(); Loaded = true; + Directory.SetCurrentDirectory(Path.GetDirectoryName(DLL)); IntPtr hmod = NativeMethods.LoadLibrary(DLL); if (hmod.ToInt64() > 0) { From 8a696815050d51af92c4be4bdd6166561c3e9358 Mon Sep 17 00:00:00 2001 From: "feal87@gmail.com" Date: Sun, 19 Dec 2010 11:28:38 +0000 Subject: [PATCH 07/33] Added some more verbose logs to GSDumpGUI (I'll start now to make a native loader for the dumps file inside the app) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4103 96395faa-99c1-11dd-bbfe-3dabce05a288 --- tools/GSDumpGUI/Forms/frmMain.Designer.cs | 94 +++++++++++++---------- tools/GSDumpGUI/Forms/frmMain.cs | 71 ++++++++++------- tools/GSDumpGUI/Library/GSDXWrapper.cs | 1 + 3 files changed, 98 insertions(+), 68 deletions(-) diff --git a/tools/GSDumpGUI/Forms/frmMain.Designer.cs b/tools/GSDumpGUI/Forms/frmMain.Designer.cs index e727864086..250241ae02 100644 --- a/tools/GSDumpGUI/Forms/frmMain.Designer.cs +++ b/tools/GSDumpGUI/Forms/frmMain.Designer.cs @@ -35,7 +35,6 @@ this.cmdBrowseDumps = new System.Windows.Forms.Button(); this.lblDumpDirectory = new System.Windows.Forms.Label(); this.txtDumpsDirectory = new System.Windows.Forms.TextBox(); - this.cmdSaveAndReload = new System.Windows.Forms.Button(); this.lstGSDX = new System.Windows.Forms.ListBox(); this.lstDumps = new System.Windows.Forms.ListBox(); this.lblDumps = new System.Windows.Forms.Label(); @@ -52,21 +51,24 @@ this.rdaDX10SW = new System.Windows.Forms.RadioButton(); this.lblOverride = new System.Windows.Forms.Label(); this.rdaNone = new System.Windows.Forms.RadioButton(); + this.lblInternalLog = new System.Windows.Forms.Label(); + this.txtIntLog = new System.Windows.Forms.TextBox(); ((System.ComponentModel.ISupportInitialize)(this.pctBox)).BeginInit(); this.SuspendLayout(); // // txtGSDXDirectory // - this.txtGSDXDirectory.Location = new System.Drawing.Point(624, 26); + this.txtGSDXDirectory.Location = new System.Drawing.Point(703, 25); this.txtGSDXDirectory.Name = "txtGSDXDirectory"; this.txtGSDXDirectory.Size = new System.Drawing.Size(243, 20); this.txtGSDXDirectory.TabIndex = 0; this.txtGSDXDirectory.TabStop = false; + this.txtGSDXDirectory.Leave += new System.EventHandler(this.txtGSDXDirectory_Leave); // // lblDirectory // this.lblDirectory.AutoSize = true; - this.lblDirectory.Location = new System.Drawing.Point(627, 10); + this.lblDirectory.Location = new System.Drawing.Point(706, 9); this.lblDirectory.Name = "lblDirectory"; this.lblDirectory.Size = new System.Drawing.Size(82, 13); this.lblDirectory.TabIndex = 1; @@ -74,7 +76,7 @@ // // cmdBrowseGSDX // - this.cmdBrowseGSDX.Location = new System.Drawing.Point(873, 24); + this.cmdBrowseGSDX.Location = new System.Drawing.Point(952, 23); this.cmdBrowseGSDX.Name = "cmdBrowseGSDX"; this.cmdBrowseGSDX.Size = new System.Drawing.Size(29, 23); this.cmdBrowseGSDX.TabIndex = 2; @@ -85,7 +87,7 @@ // // cmdBrowseDumps // - this.cmdBrowseDumps.Location = new System.Drawing.Point(873, 67); + this.cmdBrowseDumps.Location = new System.Drawing.Point(952, 66); this.cmdBrowseDumps.Name = "cmdBrowseDumps"; this.cmdBrowseDumps.Size = new System.Drawing.Size(29, 23); this.cmdBrowseDumps.TabIndex = 5; @@ -97,7 +99,7 @@ // lblDumpDirectory // this.lblDumpDirectory.AutoSize = true; - this.lblDumpDirectory.Location = new System.Drawing.Point(624, 54); + this.lblDumpDirectory.Location = new System.Drawing.Point(703, 53); this.lblDumpDirectory.Name = "lblDumpDirectory"; this.lblDumpDirectory.Size = new System.Drawing.Size(85, 13); this.lblDumpDirectory.TabIndex = 4; @@ -105,29 +107,19 @@ // // txtDumpsDirectory // - this.txtDumpsDirectory.Location = new System.Drawing.Point(624, 70); + this.txtDumpsDirectory.Location = new System.Drawing.Point(703, 69); this.txtDumpsDirectory.Name = "txtDumpsDirectory"; this.txtDumpsDirectory.Size = new System.Drawing.Size(243, 20); this.txtDumpsDirectory.TabIndex = 3; this.txtDumpsDirectory.TabStop = false; - // - // cmdSaveAndReload - // - this.cmdSaveAndReload.Location = new System.Drawing.Point(626, 97); - this.cmdSaveAndReload.Name = "cmdSaveAndReload"; - this.cmdSaveAndReload.Size = new System.Drawing.Size(276, 23); - this.cmdSaveAndReload.TabIndex = 6; - this.cmdSaveAndReload.TabStop = false; - this.cmdSaveAndReload.Text = "Save And Reload"; - this.cmdSaveAndReload.UseVisualStyleBackColor = true; - this.cmdSaveAndReload.Click += new System.EventHandler(this.cmdSave_Click); + this.txtDumpsDirectory.Leave += new System.EventHandler(this.txtDumpsDirectory_Leave); // // lstGSDX // this.lstGSDX.FormattingEnabled = true; - this.lstGSDX.Location = new System.Drawing.Point(319, 24); + this.lstGSDX.Location = new System.Drawing.Point(367, 24); this.lstGSDX.Name = "lstGSDX"; - this.lstGSDX.Size = new System.Drawing.Size(301, 225); + this.lstGSDX.Size = new System.Drawing.Size(330, 199); this.lstGSDX.TabIndex = 1; // // lstDumps @@ -135,7 +127,7 @@ this.lstDumps.FormattingEnabled = true; this.lstDumps.Location = new System.Drawing.Point(12, 24); this.lstDumps.Name = "lstDumps"; - this.lstDumps.Size = new System.Drawing.Size(301, 225); + this.lstDumps.Size = new System.Drawing.Size(349, 199); this.lstDumps.TabIndex = 0; this.lstDumps.SelectedIndexChanged += new System.EventHandler(this.lstDumps_SelectedIndexChanged); // @@ -151,7 +143,7 @@ // GsdxList // this.GsdxList.AutoSize = true; - this.GsdxList.Location = new System.Drawing.Point(316, 9); + this.GsdxList.Location = new System.Drawing.Point(364, 9); this.GsdxList.Name = "GsdxList"; this.GsdxList.Size = new System.Drawing.Size(56, 13); this.GsdxList.TabIndex = 10; @@ -159,7 +151,7 @@ // // cmdStart // - this.cmdStart.Location = new System.Drawing.Point(720, 192); + this.cmdStart.Location = new System.Drawing.Point(802, 164); this.cmdStart.Name = "cmdStart"; this.cmdStart.Size = new System.Drawing.Size(182, 58); this.cmdStart.TabIndex = 11; @@ -170,7 +162,7 @@ // // cmdConfigGSDX // - this.cmdConfigGSDX.Location = new System.Drawing.Point(720, 130); + this.cmdConfigGSDX.Location = new System.Drawing.Point(802, 102); this.cmdConfigGSDX.Name = "cmdConfigGSDX"; this.cmdConfigGSDX.Size = new System.Drawing.Size(88, 56); this.cmdConfigGSDX.TabIndex = 12; @@ -181,27 +173,27 @@ // // txtLog // - this.txtLog.Location = new System.Drawing.Point(269, 275); + this.txtLog.Location = new System.Drawing.Point(269, 249); this.txtLog.Multiline = true; this.txtLog.Name = "txtLog"; this.txtLog.ReadOnly = true; this.txtLog.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.txtLog.Size = new System.Drawing.Size(633, 208); + this.txtLog.Size = new System.Drawing.Size(351, 208); this.txtLog.TabIndex = 13; this.txtLog.TabStop = false; // // lblLog // this.lblLog.AutoSize = true; - this.lblLog.Location = new System.Drawing.Point(266, 259); + this.lblLog.Location = new System.Drawing.Point(266, 233); this.lblLog.Name = "lblLog"; - this.lblLog.Size = new System.Drawing.Size(25, 13); + this.lblLog.Size = new System.Drawing.Size(58, 13); this.lblLog.TabIndex = 14; - this.lblLog.Text = "Log"; + this.lblLog.Text = "Log GSDX"; // // cmdOpenIni // - this.cmdOpenIni.Location = new System.Drawing.Point(814, 130); + this.cmdOpenIni.Location = new System.Drawing.Point(896, 102); this.cmdOpenIni.Name = "cmdOpenIni"; this.cmdOpenIni.Size = new System.Drawing.Size(88, 56); this.cmdOpenIni.TabIndex = 15; @@ -212,7 +204,7 @@ // // pctBox // - this.pctBox.Location = new System.Drawing.Point(12, 262); + this.pctBox.Location = new System.Drawing.Point(12, 236); this.pctBox.Name = "pctBox"; this.pctBox.Size = new System.Drawing.Size(248, 221); this.pctBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; @@ -223,7 +215,7 @@ // rdaDX9HW // this.rdaDX9HW.AutoSize = true; - this.rdaDX9HW.Location = new System.Drawing.Point(626, 165); + this.rdaDX9HW.Location = new System.Drawing.Point(708, 137); this.rdaDX9HW.Name = "rdaDX9HW"; this.rdaDX9HW.Size = new System.Drawing.Size(68, 17); this.rdaDX9HW.TabIndex = 18; @@ -235,7 +227,7 @@ // rdaDX10HW // this.rdaDX10HW.AutoSize = true; - this.rdaDX10HW.Location = new System.Drawing.Point(626, 188); + this.rdaDX10HW.Location = new System.Drawing.Point(708, 160); this.rdaDX10HW.Name = "rdaDX10HW"; this.rdaDX10HW.Size = new System.Drawing.Size(74, 17); this.rdaDX10HW.TabIndex = 19; @@ -247,7 +239,7 @@ // rdaDX9SW // this.rdaDX9SW.AutoSize = true; - this.rdaDX9SW.Location = new System.Drawing.Point(626, 211); + this.rdaDX9SW.Location = new System.Drawing.Point(708, 183); this.rdaDX9SW.Name = "rdaDX9SW"; this.rdaDX9SW.Size = new System.Drawing.Size(67, 17); this.rdaDX9SW.TabIndex = 20; @@ -259,7 +251,7 @@ // rdaDX10SW // this.rdaDX10SW.AutoSize = true; - this.rdaDX10SW.Location = new System.Drawing.Point(626, 234); + this.rdaDX10SW.Location = new System.Drawing.Point(708, 206); this.rdaDX10SW.Name = "rdaDX10SW"; this.rdaDX10SW.Size = new System.Drawing.Size(73, 17); this.rdaDX10SW.TabIndex = 21; @@ -271,7 +263,7 @@ // lblOverride // this.lblOverride.AutoSize = true; - this.lblOverride.Location = new System.Drawing.Point(621, 130); + this.lblOverride.Location = new System.Drawing.Point(703, 102); this.lblOverride.Name = "lblOverride"; this.lblOverride.Size = new System.Drawing.Size(94, 13); this.lblOverride.TabIndex = 22; @@ -281,7 +273,7 @@ // this.rdaNone.AutoSize = true; this.rdaNone.Checked = true; - this.rdaNone.Location = new System.Drawing.Point(625, 146); + this.rdaNone.Location = new System.Drawing.Point(707, 118); this.rdaNone.Name = "rdaNone"; this.rdaNone.Size = new System.Drawing.Size(51, 17); this.rdaNone.TabIndex = 23; @@ -291,11 +283,33 @@ this.rdaNone.UseVisualStyleBackColor = true; this.rdaNone.CheckedChanged += new System.EventHandler(this.rda_CheckedChanged); // + // lblInternalLog + // + this.lblInternalLog.AutoSize = true; + this.lblInternalLog.Location = new System.Drawing.Point(626, 233); + this.lblInternalLog.Name = "lblInternalLog"; + this.lblInternalLog.Size = new System.Drawing.Size(63, 13); + this.lblInternalLog.TabIndex = 25; + this.lblInternalLog.Text = "Log Internal"; + // + // txtIntLog + // + this.txtIntLog.Location = new System.Drawing.Point(629, 249); + this.txtIntLog.Multiline = true; + this.txtIntLog.Name = "txtIntLog"; + this.txtIntLog.ReadOnly = true; + this.txtIntLog.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.txtIntLog.Size = new System.Drawing.Size(351, 208); + this.txtIntLog.TabIndex = 24; + this.txtIntLog.TabStop = false; + // // GSDumpGUI // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(906, 495); + this.ClientSize = new System.Drawing.Size(988, 467); + this.Controls.Add(this.lblInternalLog); + this.Controls.Add(this.txtIntLog); this.Controls.Add(this.rdaNone); this.Controls.Add(this.lblOverride); this.Controls.Add(this.rdaDX10SW); @@ -312,7 +326,6 @@ this.Controls.Add(this.GsdxList); this.Controls.Add(this.lblDumps); this.Controls.Add(this.lstDumps); - this.Controls.Add(this.cmdSaveAndReload); this.Controls.Add(this.cmdBrowseDumps); this.Controls.Add(this.lblDumpDirectory); this.Controls.Add(this.txtDumpsDirectory); @@ -341,7 +354,6 @@ private System.Windows.Forms.Button cmdBrowseDumps; private System.Windows.Forms.Label lblDumpDirectory; private System.Windows.Forms.TextBox txtDumpsDirectory; - private System.Windows.Forms.Button cmdSaveAndReload; private System.Windows.Forms.ListBox lstGSDX; private System.Windows.Forms.ListBox lstDumps; private System.Windows.Forms.Label lblDumps; @@ -358,6 +370,8 @@ private System.Windows.Forms.RadioButton rdaDX10SW; private System.Windows.Forms.Label lblOverride; private System.Windows.Forms.RadioButton rdaNone; + private System.Windows.Forms.Label lblInternalLog; + private System.Windows.Forms.TextBox txtIntLog; } } diff --git a/tools/GSDumpGUI/Forms/frmMain.cs b/tools/GSDumpGUI/Forms/frmMain.cs index afff9cf2da..fab8df8856 100644 --- a/tools/GSDumpGUI/Forms/frmMain.cs +++ b/tools/GSDumpGUI/Forms/frmMain.cs @@ -63,6 +63,8 @@ namespace GSDumpGUI public void ReloadGSDXs() { + txtIntLog.Text += "Starting GSDX Loading Procedures" + Environment.NewLine + Environment.NewLine; + txtGSDXDirectory.Text = Properties.Settings.Default.GSDXDir; txtDumpsDirectory.Text = Properties.Settings.Default.DumpDir; @@ -79,11 +81,24 @@ namespace GSDumpGUI if (GSDXWrapper.IsValidGSDX(itm)) { wrap.Load(itm); + lstGSDX.Items.Add(Path.GetFileName(itm) + " | " + wrap.PSEGetLibName()); + txtIntLog.Text += "\"" + itm + "\" correctly identified as " + wrap.PSEGetLibName() + Environment.NewLine; + wrap.Unload(); } + else + { + txtIntLog.Text += "Failed to load \"" + itm + "\". Is it really a GSDX DLL?" + Environment.NewLine; + } } + } + txtIntLog.Text += Environment.NewLine + "Completed GSDX Loading Procedures" + Environment.NewLine + Environment.NewLine; + + txtIntLog.Text += "Starting GSDX Dumps Loading Procedures : " + Environment.NewLine + Environment.NewLine; + if (Directory.Exists(txtDumpsDirectory.Text)) + { String[] Dumps = Directory.GetFiles(txtDumpsDirectory.Text, "*.gs", SearchOption.TopDirectoryOnly); foreach (var itm in Dumps) @@ -91,9 +106,13 @@ namespace GSDumpGUI BinaryReader br = new BinaryReader(System.IO.File.Open(itm, FileMode.Open)); Int32 CRC = br.ReadInt32(); br.Close(); - lstDumps.Items.Add(Path.GetFileName(itm) + " | CRC : " + CRC.ToString("X")); + lstDumps.Items.Add(Path.GetFileName(itm) + " | CRC : " + CRC.ToString("X")); + txtIntLog.Text += "Identified Dump for game (" + CRC.ToString("X") + ") with filename \"" + itm + "\"" + Environment.NewLine; } } + txtIntLog.Text += Environment.NewLine + "Completed GSDX Dumps Loading Procedures : " + Environment.NewLine + Environment.NewLine; + txtIntLog.SelectionStart = txtIntLog.TextLength; + txtIntLog.ScrollToCaret(); } private void GSDumpGUI_Load(object sender, EventArgs e) @@ -111,6 +130,8 @@ namespace GSDumpGUI fbd.SelectedPath = AppDomain.CurrentDomain.BaseDirectory; if (fbd.ShowDialog() == DialogResult.OK) txtGSDXDirectory.Text = fbd.SelectedPath; + SaveConfig(); + ReloadGSDXs(); } private void cmdBrowseDumps_Click(object sender, EventArgs e) @@ -120,33 +141,8 @@ namespace GSDumpGUI fbd.SelectedPath = AppDomain.CurrentDomain.BaseDirectory; if (fbd.ShowDialog() == DialogResult.OK) txtDumpsDirectory.Text = fbd.SelectedPath; - } - - private void cmdSave_Click(object sender, EventArgs e) - { - Boolean Err = false; - - if (System.IO.Directory.Exists(txtDumpsDirectory.Text)) - Properties.Settings.Default.DumpDir = txtDumpsDirectory.Text; - else - { - Err = true; - MessageBox.Show("Select a correct directory for dumps", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - if (System.IO.Directory.Exists(txtGSDXDirectory.Text)) - Properties.Settings.Default.GSDXDir = txtGSDXDirectory.Text; - else - { - Err = true; - MessageBox.Show("Select a correct directory for GSDX", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - if (!Err) - { - Properties.Settings.Default.Save(); - ReloadGSDXs(); - } + SaveConfig(); + ReloadGSDXs(); } private void cmdStart_Click(object sender, EventArgs e) @@ -336,5 +332,24 @@ namespace GSDumpGUI if (itm.Checked == true) SelectedRad = Convert.ToInt32(itm.Tag); } + + private void txtGSDXDirectory_Leave(object sender, EventArgs e) + { + SaveConfig(); + ReloadGSDXs(); + } + + private void txtDumpsDirectory_Leave(object sender, EventArgs e) + { + SaveConfig(); + ReloadGSDXs(); + } + + private void SaveConfig() + { + Properties.Settings.Default.GSDXDir = txtGSDXDirectory.Text; + Properties.Settings.Default.DumpDir = txtDumpsDirectory.Text; + Properties.Settings.Default.Save(); + } } } diff --git a/tools/GSDumpGUI/Library/GSDXWrapper.cs b/tools/GSDumpGUI/Library/GSDXWrapper.cs index a470d8de84..79b430cb1b 100644 --- a/tools/GSDumpGUI/Library/GSDXWrapper.cs +++ b/tools/GSDumpGUI/Library/GSDXWrapper.cs @@ -57,6 +57,7 @@ namespace GSDumpGUI { this.DLL = DLL; NativeMethods.SetErrorMode(0x8007); + if (!IsValidGSDX(DLL)) throw new Exception("Invalid GSDX DLL"); From 5ef3d80f47d0729e2fbbe2363da40f57cf8c8723 Mon Sep 17 00:00:00 2001 From: "feal87@gmail.com" Date: Sun, 19 Dec 2010 14:41:11 +0000 Subject: [PATCH 08/33] Rewritten all the dump functionality to be completely managed by my application and not relying anymore on gsdx REPLAY function. This is the first of a series of commit. The plan is to have a decent debug tool to understand problems with gsdx. Plan to do some other commit to clear up the code not used anymore git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4104 96395faa-99c1-11dd-bbfe-3dabce05a288 --- tools/GSDumpGUI/Core/Program.cs | 6 +- tools/GSDumpGUI/GSDumpGUI.csproj | 4 +- tools/GSDumpGUI/Library/GSDXWrapper.cs | 157 ++++++++++++++++++++++- tools/GSDumpGUI/Library/GSDump/GSData.cs | 20 +++ tools/GSDumpGUI/Library/GSDump/GSDump.cs | 84 ++++++++++++ tools/GSDumpGUI/Library/NativeMethods.cs | 4 + 6 files changed, 267 insertions(+), 8 deletions(-) create mode 100644 tools/GSDumpGUI/Library/GSDump/GSData.cs create mode 100644 tools/GSDumpGUI/Library/GSDump/GSDump.cs diff --git a/tools/GSDumpGUI/Core/Program.cs b/tools/GSDumpGUI/Core/Program.cs index ee7698911f..3e50e15798 100644 --- a/tools/GSDumpGUI/Core/Program.cs +++ b/tools/GSDumpGUI/Core/Program.cs @@ -55,11 +55,9 @@ namespace GSDumpGUI Directory.SetCurrentDirectory(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + Path.GetFileName(DLLPath) + "\\")); if (Operation == "GSReplay") { + GSDump dump = GSDump.LoadDump(DumpPath); + wrap.Run(dump, Renderer); ChangeIcon = true; - if (Renderer != -1) - wrap.GSReplayDump(Renderer + " " + DumpPath); - else - wrap.GSReplayDump(DumpPath); } else wrap.GSConfig(); diff --git a/tools/GSDumpGUI/GSDumpGUI.csproj b/tools/GSDumpGUI/GSDumpGUI.csproj index 1631d2bd9a..b3f957acfd 100644 --- a/tools/GSDumpGUI/GSDumpGUI.csproj +++ b/tools/GSDumpGUI/GSDumpGUI.csproj @@ -36,7 +36,7 @@ TRACE prompt 4 - false + true x86 @@ -54,6 +54,8 @@ frmMain.cs + + diff --git a/tools/GSDumpGUI/Library/GSDXWrapper.cs b/tools/GSDumpGUI/Library/GSDXWrapper.cs index 79b430cb1b..21f208f7f0 100644 --- a/tools/GSDumpGUI/Library/GSDXWrapper.cs +++ b/tools/GSDumpGUI/Library/GSDXWrapper.cs @@ -6,21 +6,48 @@ using System.IO; namespace GSDumpGUI { + public delegate void GSReplay(IntPtr HWND, IntPtr HInstance, String File, Boolean Show); + public delegate void GSgifTransfer1(IntPtr data, int size); + public delegate void GSgifTransfer2(IntPtr data, int size); + public delegate void GSgifTransfer3(IntPtr data, int size); + public delegate void GSVSync(byte field); + public delegate void GSreadFIFO2(IntPtr data, int size); + public delegate void GSsetGameCRC(int crc, int options); + public delegate void GSfreeze(int mode, IntPtr data); + public delegate void GSopen(IntPtr hwnd, String Title, int renderer); + public delegate void GSclose(); + public delegate void GSshutdown(); + public delegate void GSConfigure(); + public delegate void GSsetBaseMem(IntPtr data); + public delegate IntPtr PSEgetLibName(); + public delegate void GSinit(); + public class GSDXWrapper { - private delegate void GSReplay(IntPtr HWND, IntPtr HInstance, String File, Boolean Show); - private delegate void GSConfigure(); - private delegate IntPtr PSEgetLibName(); private GSReplay gsReplay; private GSConfigure gsConfigure; private PSEgetLibName PsegetLibName; + private GSgifTransfer1 GSgifTransfer1; + private GSgifTransfer2 GSgifTransfer2; + private GSgifTransfer3 GSgifTransfer3; + private GSVSync GSVSync; + private GSreadFIFO2 GSreadFIFO2; + private GSsetGameCRC GSsetGameCRC; + private GSfreeze GSfreeze; + private GSopen GSopen; + private GSclose GSclose; + private GSshutdown GSshutdown; + private GSsetBaseMem GSsetBaseMem; + private GSinit GSinit; private Boolean Loaded; private String DLL; private IntPtr DLLAddr; + private Boolean Running; + static public Boolean IsValidGSDX(String DLL) { NativeMethods.SetErrorMode(0x8007); @@ -34,6 +61,19 @@ namespace GSDumpGUI IntPtr funcaddrLibName = NativeMethods.GetProcAddress(hmod, "PS2EgetLibName"); IntPtr funcaddrConfig = NativeMethods.GetProcAddress(hmod, "GSconfigure"); + IntPtr funcaddrGIF1 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer1"); + IntPtr funcaddrGIF2 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer2"); + IntPtr funcaddrGIF3 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer3"); + IntPtr funcaddrVSync = NativeMethods.GetProcAddress(hmod, "GSvsync"); + IntPtr funcaddrSetBaseMem = NativeMethods.GetProcAddress(hmod, "GSsetBaseMem"); + IntPtr funcaddrOpen = NativeMethods.GetProcAddress(hmod, "GSopen"); + IntPtr funcaddrSetCRC = NativeMethods.GetProcAddress(hmod, "GSsetGameCRC"); + IntPtr funcaddrClose = NativeMethods.GetProcAddress(hmod, "GSclose"); + IntPtr funcaddrShutdown = NativeMethods.GetProcAddress(hmod, "GSshutdown"); + IntPtr funcaddrFreeze = NativeMethods.GetProcAddress(hmod, "GSfreeze"); + IntPtr funcaddrGSreadFIFO2 = NativeMethods.GetProcAddress(hmod, "GSreadFIFO2"); + IntPtr funcaddrinit = NativeMethods.GetProcAddress(hmod, "GSinit"); + NativeMethods.FreeLibrary(hmod); if (!((funcaddrConfig.ToInt64() > 0) && (funcaddrLibName.ToInt64() > 0) && (funcaddrReplay.ToInt64() > 0))) { @@ -73,9 +113,36 @@ namespace GSDumpGUI IntPtr funcaddrLibName = NativeMethods.GetProcAddress(hmod, "PS2EgetLibName"); IntPtr funcaddrConfig = NativeMethods.GetProcAddress(hmod, "GSconfigure"); + IntPtr funcaddrGIF1 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer1"); + IntPtr funcaddrGIF2 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer2"); + IntPtr funcaddrGIF3 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer3"); + IntPtr funcaddrVSync = NativeMethods.GetProcAddress(hmod, "GSvsync"); + IntPtr funcaddrSetBaseMem = NativeMethods.GetProcAddress(hmod, "GSsetBaseMem"); + IntPtr funcaddrOpen = NativeMethods.GetProcAddress(hmod, "GSopen"); + IntPtr funcaddrSetCRC = NativeMethods.GetProcAddress(hmod, "GSsetGameCRC"); + IntPtr funcaddrClose = NativeMethods.GetProcAddress(hmod, "GSclose"); + IntPtr funcaddrShutdown = NativeMethods.GetProcAddress(hmod, "GSshutdown"); + IntPtr funcaddrFreeze = NativeMethods.GetProcAddress(hmod, "GSfreeze"); + IntPtr funcaddrGSreadFIFO2 = NativeMethods.GetProcAddress(hmod, "GSreadFIFO2"); + IntPtr funcaddrinit = NativeMethods.GetProcAddress(hmod, "GSinit"); + gsReplay = (GSReplay)Marshal.GetDelegateForFunctionPointer(funcaddrReplay, typeof(GSReplay)); gsConfigure = (GSConfigure)Marshal.GetDelegateForFunctionPointer(funcaddrConfig, typeof(GSConfigure)); PsegetLibName = (PSEgetLibName)Marshal.GetDelegateForFunctionPointer(funcaddrLibName, typeof(PSEgetLibName)); + + this.GSgifTransfer1 = (GSgifTransfer1)Marshal.GetDelegateForFunctionPointer(funcaddrGIF1, typeof(GSgifTransfer1)); + this.GSgifTransfer2 = (GSgifTransfer2)Marshal.GetDelegateForFunctionPointer(funcaddrGIF2, typeof(GSgifTransfer2)); + this.GSgifTransfer3 = (GSgifTransfer3)Marshal.GetDelegateForFunctionPointer(funcaddrGIF3, typeof(GSgifTransfer3)); + this.GSVSync = (GSVSync)Marshal.GetDelegateForFunctionPointer(funcaddrVSync, typeof(GSVSync)); + this.GSsetBaseMem = (GSsetBaseMem)Marshal.GetDelegateForFunctionPointer(funcaddrSetBaseMem, typeof(GSsetBaseMem)); + this.GSopen = (GSopen)Marshal.GetDelegateForFunctionPointer(funcaddrOpen, typeof(GSopen)); + this.GSsetGameCRC = (GSsetGameCRC)Marshal.GetDelegateForFunctionPointer(funcaddrSetCRC, typeof(GSsetGameCRC)); + this.GSclose = (GSclose)Marshal.GetDelegateForFunctionPointer(funcaddrClose, typeof(GSclose)); + this.GSshutdown = (GSshutdown)Marshal.GetDelegateForFunctionPointer(funcaddrShutdown, typeof(GSshutdown)); + this.GSfreeze = (GSfreeze)Marshal.GetDelegateForFunctionPointer(funcaddrFreeze, typeof(GSfreeze)); + this.GSreadFIFO2 = (GSreadFIFO2)Marshal.GetDelegateForFunctionPointer(funcaddrGSreadFIFO2, typeof(GSreadFIFO2)); + this.GSinit = (GSinit)Marshal.GetDelegateForFunctionPointer(funcaddrinit, typeof(GSinit)); + DLLAddr = hmod; } NativeMethods.SetErrorMode(0x0000); @@ -107,5 +174,89 @@ namespace GSDumpGUI throw new Exception("GSDX is not loaded"); return Marshal.PtrToStringAnsi(PsegetLibName.Invoke()); } + + public unsafe void Run(GSDump dump, int rendererOverride) + { + Running = true; + GSinit(); + fixed (byte* pointer = dump.Registers) + { + GSsetBaseMem(new IntPtr(pointer)); + Int32 HWND = 0; + GSopen(new IntPtr(&HWND), "", rendererOverride); + GSsetGameCRC(dump.CRC, 0); + fixed (byte* freeze = dump.StateData) + { + GSfreeze(0, new IntPtr(freeze)); + GSVSync(1); + + while (Running) + { /*"C:\Users\Alessio\Desktop\Plugins\Dll\gsdx-sse4-r3878.dll" "C:\Users\Alessio\Desktop\Plugins\Dumps\gsdx_20100603052628.gs" "GSReplay" 0*/ + if (!NativeMethods.IsWindowVisible(new IntPtr(HWND))) + { + Running = false; + break; + } + foreach (var itm in dump.Data) + { + switch (itm.id) + { + case GSType.Transfer: + switch (itm.data[0]) + { + case 0: + fixed (byte* gifdata = itm.data) + { + byte[] data = new byte[4]; + data[0]=*(gifdata+1); + data[1]=*(gifdata+2); + data[2]=*(gifdata+3); + data[3]=*(gifdata+4); + Int32 size = BitConverter.ToInt32(data, 0); + GSgifTransfer1(new IntPtr(gifdata + 5), 16384 - size); + } + break; + case 1: + fixed (byte* gifdata = itm.data) + { + GSgifTransfer2(new IntPtr(gifdata + 1), (itm.data.Length - 1) / 16); + } + break; + case 2: + fixed (byte* gifdata = itm.data) + { + GSgifTransfer3(new IntPtr(gifdata + 1), (itm.data.Length - 1) / 16); + } + break; + } + break; + case GSType.VSync: + GSVSync(itm.data[0]); + break; + case GSType.ReadFIFO2: + fixed (byte* FIFO = itm.data) + { + GSreadFIFO2(new IntPtr(FIFO), itm.data.Length / 16); + } + break; + case GSType.Registers: + Marshal.Copy(itm.data, 0, new IntPtr(pointer), 8192); + break; + default: + break; + } + } + } + + GSclose(); + GSshutdown(); + } + } + } + + public void Stop() + { + Running = false; + } } } diff --git a/tools/GSDumpGUI/Library/GSDump/GSData.cs b/tools/GSDumpGUI/Library/GSDump/GSData.cs new file mode 100644 index 0000000000..cd06622db6 --- /dev/null +++ b/tools/GSDumpGUI/Library/GSDump/GSData.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace GSDumpGUI +{ + public class GSData + { + public GSType id; + public byte[] data; + } + + public enum GSType + { + Transfer = 0, + VSync = 1, + ReadFIFO2 = 2, + Registers = 3 + } +} diff --git a/tools/GSDumpGUI/Library/GSDump/GSDump.cs b/tools/GSDumpGUI/Library/GSDump/GSDump.cs new file mode 100644 index 0000000000..c1303141c3 --- /dev/null +++ b/tools/GSDumpGUI/Library/GSDump/GSDump.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; + +namespace GSDumpGUI +{ + public class GSDump + { + public Int32 CRC; + public byte[] StateData; + public byte[] Registers; // 8192 bytes + + public List Data; + + public GSDump() + { + Data = new List(); + } + + static public GSDump LoadDump(String FileName) + { + GSDump dmp = new GSDump(); + + BinaryReader br = new BinaryReader(System.IO.File.Open(FileName, FileMode.Open)); + dmp.CRC = br.ReadInt32(); + Int32 ss = br.ReadInt32(); + dmp.StateData = br.ReadBytes(ss); + dmp.Registers = br.ReadBytes(8192); + + while (br.PeekChar() != -1) + { + GSData data = new GSData(); + data.id = (GSType)br.ReadByte(); + + switch (data.id) + { + case GSType.Transfer: + byte index = br.ReadByte(); + if (index == 0) + { + Int32 size = br.ReadInt32(); + + byte[] dat = new byte[16384]; + List Data = new List(); + Data.Add(index); + Data.AddRange(BitConverter.GetBytes(size)); + Data.AddRange(dat); + + int startaddr = 16389 - size; + + for (int i = 0; i < size; i++) + Data[startaddr + i] = br.ReadByte(); + data.data = Data.ToArray(); + } + else + { + Int32 size = br.ReadInt32(); + + List Data = new List(); + Data.Add(index); + Data.AddRange(br.ReadBytes(size)); + data.data = Data.ToArray(); + } + break; + case GSType.VSync: + data.data = br.ReadBytes(1); + break; + case GSType.ReadFIFO2: + Int32 sF = br.ReadInt32(); + data.data = br.ReadBytes(sF); + break; + case GSType.Registers: + data.data = br.ReadBytes(8192); + break; + } + dmp.Data.Add(data); + } + br.Close(); + + return dmp; + } + } +} diff --git a/tools/GSDumpGUI/Library/NativeMethods.cs b/tools/GSDumpGUI/Library/NativeMethods.cs index b24b39df46..192d7dc52d 100644 --- a/tools/GSDumpGUI/Library/NativeMethods.cs +++ b/tools/GSDumpGUI/Library/NativeMethods.cs @@ -35,5 +35,9 @@ namespace GSDumpGUI [SuppressUnmanagedCodeSecurityAttribute] [DllImport("user32", CharSet = CharSet.Ansi)] public extern static int SetClassLong(IntPtr HWND, int index, long newlong); + + [SuppressUnmanagedCodeSecurityAttribute] + [DllImport("user32", CharSet = CharSet.Ansi)] + public extern static bool IsWindowVisible(IntPtr HWND); } } From b3c90f21a6005f08ff6227e4572f4b9bc28158ec Mon Sep 17 00:00:00 2001 From: "feal87@gmail.com" Date: Sun, 19 Dec 2010 14:44:09 +0000 Subject: [PATCH 09/33] Clearing up everything was using the old replay code. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4105 96395faa-99c1-11dd-bbfe-3dabce05a288 --- tools/GSDumpGUI/Library/GSDXWrapper.cs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/tools/GSDumpGUI/Library/GSDXWrapper.cs b/tools/GSDumpGUI/Library/GSDXWrapper.cs index 21f208f7f0..03a740a138 100644 --- a/tools/GSDumpGUI/Library/GSDXWrapper.cs +++ b/tools/GSDumpGUI/Library/GSDXWrapper.cs @@ -6,7 +6,6 @@ using System.IO; namespace GSDumpGUI { - public delegate void GSReplay(IntPtr HWND, IntPtr HInstance, String File, Boolean Show); public delegate void GSgifTransfer1(IntPtr data, int size); public delegate void GSgifTransfer2(IntPtr data, int size); public delegate void GSgifTransfer3(IntPtr data, int size); @@ -24,8 +23,6 @@ namespace GSDumpGUI public class GSDXWrapper { - - private GSReplay gsReplay; private GSConfigure gsConfigure; private PSEgetLibName PsegetLibName; private GSgifTransfer1 GSgifTransfer1; @@ -57,7 +54,6 @@ namespace GSDumpGUI IntPtr hmod = NativeMethods.LoadLibrary(DLL); if (hmod.ToInt64() > 0) { - IntPtr funcaddrReplay = NativeMethods.GetProcAddress(hmod, "GSReplay"); IntPtr funcaddrLibName = NativeMethods.GetProcAddress(hmod, "PS2EgetLibName"); IntPtr funcaddrConfig = NativeMethods.GetProcAddress(hmod, "GSconfigure"); @@ -75,7 +71,7 @@ namespace GSDumpGUI IntPtr funcaddrinit = NativeMethods.GetProcAddress(hmod, "GSinit"); NativeMethods.FreeLibrary(hmod); - if (!((funcaddrConfig.ToInt64() > 0) && (funcaddrLibName.ToInt64() > 0) && (funcaddrReplay.ToInt64() > 0))) + if (!((funcaddrConfig.ToInt64() > 0) && (funcaddrLibName.ToInt64() > 0))) { Int32 id = NativeMethods.GetLastError(); System.IO.File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "log.txt", DLL + " failed to load. Error " + id + Environment.NewLine); @@ -109,7 +105,6 @@ namespace GSDumpGUI IntPtr hmod = NativeMethods.LoadLibrary(DLL); if (hmod.ToInt64() > 0) { - IntPtr funcaddrReplay = NativeMethods.GetProcAddress(hmod, "GSReplay"); IntPtr funcaddrLibName = NativeMethods.GetProcAddress(hmod, "PS2EgetLibName"); IntPtr funcaddrConfig = NativeMethods.GetProcAddress(hmod, "GSconfigure"); @@ -126,7 +121,6 @@ namespace GSDumpGUI IntPtr funcaddrGSreadFIFO2 = NativeMethods.GetProcAddress(hmod, "GSreadFIFO2"); IntPtr funcaddrinit = NativeMethods.GetProcAddress(hmod, "GSinit"); - gsReplay = (GSReplay)Marshal.GetDelegateForFunctionPointer(funcaddrReplay, typeof(GSReplay)); gsConfigure = (GSConfigure)Marshal.GetDelegateForFunctionPointer(funcaddrConfig, typeof(GSConfigure)); PsegetLibName = (PSEgetLibName)Marshal.GetDelegateForFunctionPointer(funcaddrLibName, typeof(PSEgetLibName)); @@ -161,13 +155,6 @@ namespace GSDumpGUI gsConfigure.Invoke(); } - public void GSReplayDump(String DumpFilename) - { - if (!Loaded) - throw new Exception("GSDX is not loaded"); - gsReplay.Invoke(new IntPtr(0), new IntPtr(0), DumpFilename, false); - } - public String PSEGetLibName() { if (!Loaded) @@ -191,7 +178,7 @@ namespace GSDumpGUI GSVSync(1); while (Running) - { /*"C:\Users\Alessio\Desktop\Plugins\Dll\gsdx-sse4-r3878.dll" "C:\Users\Alessio\Desktop\Plugins\Dumps\gsdx_20100603052628.gs" "GSReplay" 0*/ + { if (!NativeMethods.IsWindowVisible(new IntPtr(HWND))) { Running = false; From 0d0778a5dd8e9b73d4a99f921bac2f3d31f41e8d Mon Sep 17 00:00:00 2001 From: "feal87@gmail.com" Date: Sun, 19 Dec 2010 15:55:52 +0000 Subject: [PATCH 10/33] Started working on the debugger. Prepared only the link between master and client app. Have to investigate on the changes in the PATH1 done by Jake. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4106 96395faa-99c1-11dd-bbfe-3dabce05a288 --- tools/GSDumpGUI/Core/Program.cs | 98 ++++- tools/GSDumpGUI/Forms/frmMain.Designer.cs | 75 +++- tools/GSDumpGUI/Forms/frmMain.cs | 11 + tools/GSDumpGUI/GSDumpGUI.csproj | 9 + tools/GSDumpGUI/Library/GSDXWrapper.cs | 98 ++--- tools/GSDumpGUI/Library/GSDump/GSDump.cs | 45 +-- .../Library/TCPLibrary/Base/CancelArgs.cs | 56 +++ .../Library/TCPLibrary/Base/Client.cs | 323 ++++++++++++++++ .../Library/TCPLibrary/Base/ClientS.cs | 226 +++++++++++ .../GSDumpGUI/Library/TCPLibrary/Base/Data.cs | 57 +++ .../Library/TCPLibrary/Base/Server.cs | 365 ++++++++++++++++++ .../TCPLibrary/Message/BaseMessageClient.cs | 137 +++++++ .../TCPLibrary/Message/BaseMessageClientS.cs | 59 +++ .../TCPLibrary/Message/BaseMessageServer.cs | 186 +++++++++ .../Library/TCPLibrary/Message/TCPMessage.cs | 114 ++++++ 15 files changed, 1787 insertions(+), 72 deletions(-) create mode 100644 tools/GSDumpGUI/Library/TCPLibrary/Base/CancelArgs.cs create mode 100644 tools/GSDumpGUI/Library/TCPLibrary/Base/Client.cs create mode 100644 tools/GSDumpGUI/Library/TCPLibrary/Base/ClientS.cs create mode 100644 tools/GSDumpGUI/Library/TCPLibrary/Base/Data.cs create mode 100644 tools/GSDumpGUI/Library/TCPLibrary/Base/Server.cs create mode 100644 tools/GSDumpGUI/Library/TCPLibrary/Message/BaseMessageClient.cs create mode 100644 tools/GSDumpGUI/Library/TCPLibrary/Message/BaseMessageClientS.cs create mode 100644 tools/GSDumpGUI/Library/TCPLibrary/Message/BaseMessageServer.cs create mode 100644 tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs diff --git a/tools/GSDumpGUI/Core/Program.cs b/tools/GSDumpGUI/Core/Program.cs index 3e50e15798..9e83a3f448 100644 --- a/tools/GSDumpGUI/Core/Program.cs +++ b/tools/GSDumpGUI/Core/Program.cs @@ -8,20 +8,36 @@ using System.Threading; using System.Diagnostics; using GSDumpGUI.Properties; using System.IO; +using TCPLibrary.MessageBased.Core; namespace GSDumpGUI { static class Program { static public GSDumpGUI frmMain; + static public TCPLibrary.MessageBased.Core.BaseMessageServer Server; + static public List Clients; + static public TCPLibrary.MessageBased.Core.BaseMessageClient Client; static private Boolean ChangeIcon; + static private GSDump dump; [STAThread] static void Main(String[] args) { if (args.Length == 4) { + try + { + Client = new TCPLibrary.MessageBased.Core.BaseMessageClient(); + Client.OnMessageReceived += new TCPLibrary.MessageBased.Core.BaseMessageClient.MessageReceivedHandler(Client_OnMessageReceived); + Client.Connect("localhost", 9999); + } + catch (Exception) + { + Client = null; + } + Thread thd = new Thread(new ThreadStart(delegate { while (true) @@ -55,21 +71,101 @@ namespace GSDumpGUI Directory.SetCurrentDirectory(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + Path.GetFileName(DLLPath) + "\\")); if (Operation == "GSReplay") { - GSDump dump = GSDump.LoadDump(DumpPath); + dump = GSDump.LoadDump(DumpPath); wrap.Run(dump, Renderer); ChangeIcon = true; } else wrap.GSConfig(); wrap.Unload(); + + if (Client != null) + Client.Disconnect(); } else { + Clients = new List(); + + Server = new TCPLibrary.MessageBased.Core.BaseMessageServer(); + Server.OnClientMessageReceived += new BaseMessageServer.MessageReceivedHandler(Server_OnClientMessageReceived); + Server.OnClientAfterConnect += new TCPLibrary.Core.Server.ConnectedHandler(Server_OnClientAfterConnect); + Server.OnClientAfterDisconnected += new TCPLibrary.Core.Server.DisconnectedHandler(Server_OnClientAfterDisconnected); + Server.Port = 9999; + Server.Enabled = true; + Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); frmMain = new GSDumpGUI(); Application.Run(frmMain); + + Server.Enabled = false; } } + + static void Server_OnClientAfterDisconnected(TCPLibrary.Core.Server server, TCPLibrary.Core.ClientS sender) + { + Clients.Remove((TCPLibrary.MessageBased.Core.BaseMessageClientS)sender); + RefreshList(); + } + + static void Server_OnClientMessageReceived(BaseMessageServer server, BaseMessageClientS sender, TCPMessage Mess) + { + switch (Mess.MessageType) + { + case MessageType.Connect: + break; + case MessageType.MaxUsers: + break; + case MessageType.SizeDump: + frmMain.Invoke(new Action(delegate(object e) + { + frmMain.txtDumpSize.Text = (((int)Mess.Parameters[0]) / 1024f / 1024f).ToString("F2"); + }), new object[] { null }); + break; + default: + break; + } + } + + static void Client_OnMessageReceived(TCPLibrary.Core.Client sender, TCPLibrary.MessageBased.Core.TCPMessage Mess) + { + switch (Mess.MessageType) + { + case TCPLibrary.MessageBased.Core.MessageType.Connect: + break; + case TCPLibrary.MessageBased.Core.MessageType.MaxUsers: + break; + case TCPLibrary.MessageBased.Core.MessageType.SizeDump: + TCPMessage msg = new TCPMessage(); + msg.MessageType = MessageType.SizeDump; + if (dump != null) + msg.Parameters.Add(dump.Size); + else + msg.Parameters.Add(0); + Client.Send(msg); + break; + default: + break; + } + } + + static void Server_OnClientAfterConnect(TCPLibrary.Core.Server server, TCPLibrary.Core.ClientS sender) + { + Clients.Add((TCPLibrary.MessageBased.Core.BaseMessageClientS)sender); + RefreshList(); + } + + private static void RefreshList() + { + frmMain.Invoke(new Action( delegate(object e) + { + frmMain.lstProcesses.Items.Clear(); + + foreach (var itm in Clients) + { + frmMain.lstProcesses.Items.Add(itm.IPAddress); + } + }), new object[] { null}); + } } } diff --git a/tools/GSDumpGUI/Forms/frmMain.Designer.cs b/tools/GSDumpGUI/Forms/frmMain.Designer.cs index 250241ae02..9f4045a6b2 100644 --- a/tools/GSDumpGUI/Forms/frmMain.Designer.cs +++ b/tools/GSDumpGUI/Forms/frmMain.Designer.cs @@ -53,6 +53,12 @@ this.rdaNone = new System.Windows.Forms.RadioButton(); this.lblInternalLog = new System.Windows.Forms.Label(); this.txtIntLog = new System.Windows.Forms.TextBox(); + this.lblDebugger = new System.Windows.Forms.Label(); + this.lstProcesses = new System.Windows.Forms.ListBox(); + this.lblChild = new System.Windows.Forms.Label(); + this.lblDumpSize = new System.Windows.Forms.Label(); + this.txtDumpSize = new System.Windows.Forms.Label(); + this.lblWIP = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.pctBox)).BeginInit(); this.SuspendLayout(); // @@ -303,11 +309,72 @@ this.txtIntLog.TabIndex = 24; this.txtIntLog.TabStop = false; // + // lblDebugger + // + this.lblDebugger.AutoSize = true; + this.lblDebugger.Location = new System.Drawing.Point(417, 470); + this.lblDebugger.Name = "lblDebugger"; + this.lblDebugger.Size = new System.Drawing.Size(54, 13); + this.lblDebugger.TabIndex = 26; + this.lblDebugger.Text = "Debugger"; + // + // lstProcesses + // + this.lstProcesses.FormattingEnabled = true; + this.lstProcesses.Location = new System.Drawing.Point(12, 502); + this.lstProcesses.Name = "lstProcesses"; + this.lstProcesses.Size = new System.Drawing.Size(248, 251); + this.lstProcesses.TabIndex = 27; + this.lstProcesses.SelectedIndexChanged += new System.EventHandler(this.lstProcesses_SelectedIndexChanged); + // + // lblChild + // + this.lblChild.AutoSize = true; + this.lblChild.Location = new System.Drawing.Point(9, 487); + this.lblChild.Name = "lblChild"; + this.lblChild.Size = new System.Drawing.Size(82, 13); + this.lblChild.TabIndex = 28; + this.lblChild.Text = "Child Processes"; + // + // lblDumpSize + // + this.lblDumpSize.AutoSize = true; + this.lblDumpSize.Location = new System.Drawing.Point(279, 487); + this.lblDumpSize.Name = "lblDumpSize"; + this.lblDumpSize.Size = new System.Drawing.Size(58, 13); + this.lblDumpSize.TabIndex = 29; + this.lblDumpSize.Text = "Dump Size"; + // + // txtDumpSize + // + this.txtDumpSize.AutoSize = true; + this.txtDumpSize.Location = new System.Drawing.Point(279, 502); + this.txtDumpSize.Name = "txtDumpSize"; + this.txtDumpSize.Size = new System.Drawing.Size(0, 13); + this.txtDumpSize.TabIndex = 30; + // + // lblWIP + // + this.lblWIP.AutoSize = true; + this.lblWIP.Font = new System.Drawing.Font("Times New Roman", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblWIP.ForeColor = System.Drawing.Color.Red; + this.lblWIP.Location = new System.Drawing.Point(407, 589); + this.lblWIP.Name = "lblWIP"; + this.lblWIP.Size = new System.Drawing.Size(508, 73); + this.lblWIP.TabIndex = 31; + this.lblWIP.Text = "Work in Progress"; + // // GSDumpGUI // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(988, 467); + this.ClientSize = new System.Drawing.Size(988, 766); + this.Controls.Add(this.lblWIP); + this.Controls.Add(this.txtDumpSize); + this.Controls.Add(this.lblDumpSize); + this.Controls.Add(this.lstProcesses); + this.Controls.Add(this.lblChild); + this.Controls.Add(this.lblDebugger); this.Controls.Add(this.lblInternalLog); this.Controls.Add(this.txtIntLog); this.Controls.Add(this.rdaNone); @@ -372,6 +439,12 @@ private System.Windows.Forms.RadioButton rdaNone; private System.Windows.Forms.Label lblInternalLog; private System.Windows.Forms.TextBox txtIntLog; + private System.Windows.Forms.Label lblDebugger; + private System.Windows.Forms.Label lblChild; + public System.Windows.Forms.ListBox lstProcesses; + private System.Windows.Forms.Label lblDumpSize; + public System.Windows.Forms.Label txtDumpSize; + private System.Windows.Forms.Label lblWIP; } } diff --git a/tools/GSDumpGUI/Forms/frmMain.cs b/tools/GSDumpGUI/Forms/frmMain.cs index fab8df8856..143d882bcb 100644 --- a/tools/GSDumpGUI/Forms/frmMain.cs +++ b/tools/GSDumpGUI/Forms/frmMain.cs @@ -10,6 +10,7 @@ using System.Runtime.InteropServices; using System.Threading; using System.Diagnostics; using System.Security; +using TCPLibrary.MessageBased.Core; namespace GSDumpGUI { @@ -351,5 +352,15 @@ namespace GSDumpGUI Properties.Settings.Default.DumpDir = txtDumpsDirectory.Text; Properties.Settings.Default.Save(); } + + private void lstProcesses_SelectedIndexChanged(object sender, EventArgs e) + { + if (lstProcesses.SelectedIndex != -1) + { + TCPMessage msg = new TCPMessage(); + msg.MessageType = MessageType.SizeDump; + Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg); + } + } } } diff --git a/tools/GSDumpGUI/GSDumpGUI.csproj b/tools/GSDumpGUI/GSDumpGUI.csproj index b3f957acfd..0ccdfd4657 100644 --- a/tools/GSDumpGUI/GSDumpGUI.csproj +++ b/tools/GSDumpGUI/GSDumpGUI.csproj @@ -59,6 +59,15 @@ + + + + + + + + + frmMain.cs diff --git a/tools/GSDumpGUI/Library/GSDXWrapper.cs b/tools/GSDumpGUI/Library/GSDXWrapper.cs index 03a740a138..c82aac18d0 100644 --- a/tools/GSDumpGUI/Library/GSDXWrapper.cs +++ b/tools/GSDumpGUI/Library/GSDXWrapper.cs @@ -186,52 +186,7 @@ namespace GSDumpGUI } foreach (var itm in dump.Data) { - switch (itm.id) - { - case GSType.Transfer: - switch (itm.data[0]) - { - case 0: - fixed (byte* gifdata = itm.data) - { - byte[] data = new byte[4]; - data[0]=*(gifdata+1); - data[1]=*(gifdata+2); - data[2]=*(gifdata+3); - data[3]=*(gifdata+4); - Int32 size = BitConverter.ToInt32(data, 0); - GSgifTransfer1(new IntPtr(gifdata + 5), 16384 - size); - } - break; - case 1: - fixed (byte* gifdata = itm.data) - { - GSgifTransfer2(new IntPtr(gifdata + 1), (itm.data.Length - 1) / 16); - } - break; - case 2: - fixed (byte* gifdata = itm.data) - { - GSgifTransfer3(new IntPtr(gifdata + 1), (itm.data.Length - 1) / 16); - } - break; - } - break; - case GSType.VSync: - GSVSync(itm.data[0]); - break; - case GSType.ReadFIFO2: - fixed (byte* FIFO = itm.data) - { - GSreadFIFO2(new IntPtr(FIFO), itm.data.Length / 16); - } - break; - case GSType.Registers: - Marshal.Copy(itm.data, 0, new IntPtr(pointer), 8192); - break; - default: - break; - } + Step(itm, pointer); } } @@ -241,6 +196,57 @@ namespace GSDumpGUI } } + private unsafe void Step(GSData itm, byte* registers) + { + switch (itm.id) + { + case GSType.Transfer: + switch (itm.data[0]) + {/* + case 0: + byte[] data = new byte[16384]; + for (int i = 0; i < itm.data; i++) + { + + } + fixed (byte* gifdata = data) + { + GSgifTransfer1(new IntPtr(gifdata + 5), 16384 - size); + } + break;*/ + case 0: + case 1: + case 2: + fixed (byte* gifdata = itm.data) + { + GSgifTransfer2(new IntPtr(gifdata + 1), (itm.data.Length - 1) / 16); + } + break;/* + case 2: + fixed (byte* gifdata = itm.data) + { + GSgifTransfer3(new IntPtr(gifdata + 1), (itm.data.Length - 1) / 16); + } + break;*/ + } + break; + case GSType.VSync: + GSVSync(itm.data[0]); + break; + case GSType.ReadFIFO2: + fixed (byte* FIFO = itm.data) + { + GSreadFIFO2(new IntPtr(FIFO), itm.data.Length / 16); + } + break; + case GSType.Registers: + Marshal.Copy(itm.data, 0, new IntPtr(registers), 8192); + break; + default: + break; + } + } + public void Stop() { Running = false; diff --git a/tools/GSDumpGUI/Library/GSDump/GSDump.cs b/tools/GSDumpGUI/Library/GSDump/GSDump.cs index c1303141c3..0fc7b8b101 100644 --- a/tools/GSDumpGUI/Library/GSDump/GSDump.cs +++ b/tools/GSDumpGUI/Library/GSDump/GSDump.cs @@ -11,6 +11,22 @@ namespace GSDumpGUI public byte[] StateData; public byte[] Registers; // 8192 bytes + public int Size + { + get + { + int size = 0; + size = 4; + size += StateData.Length; + size += Registers.Length; + foreach (var itm in Data) + { + size += itm.data.Length; + } + return size; + } + } + public List Data; public GSDump() @@ -37,31 +53,12 @@ namespace GSDumpGUI { case GSType.Transfer: byte index = br.ReadByte(); - if (index == 0) - { - Int32 size = br.ReadInt32(); + Int32 size = br.ReadInt32(); - byte[] dat = new byte[16384]; - List Data = new List(); - Data.Add(index); - Data.AddRange(BitConverter.GetBytes(size)); - Data.AddRange(dat); - - int startaddr = 16389 - size; - - for (int i = 0; i < size; i++) - Data[startaddr + i] = br.ReadByte(); - data.data = Data.ToArray(); - } - else - { - Int32 size = br.ReadInt32(); - - List Data = new List(); - Data.Add(index); - Data.AddRange(br.ReadBytes(size)); - data.data = Data.ToArray(); - } + List Data = new List(); + Data.Add(index); + Data.AddRange(br.ReadBytes(size)); + data.data = Data.ToArray(); break; case GSType.VSync: data.data = br.ReadBytes(1); diff --git a/tools/GSDumpGUI/Library/TCPLibrary/Base/CancelArgs.cs b/tools/GSDumpGUI/Library/TCPLibrary/Base/CancelArgs.cs new file mode 100644 index 0000000000..981dd56a07 --- /dev/null +++ b/tools/GSDumpGUI/Library/TCPLibrary/Base/CancelArgs.cs @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2009 Ferreri Alessio +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +using System; +using System.Collections.Generic; +using System.Text; + +namespace TCPLibrary.Core +{ + /// + /// Class for containing information regarding the acceptance of a determinate situation. + /// + public class CancelArgs + { + /// + /// Whether the operation should be cancelled. + /// + private Boolean _cancel; + /// + /// Get/set the flag that determines if the operation should be cancelled. + /// + public Boolean Cancel + { + get { return _cancel; } + set { _cancel = value; } + } + + /// + /// Base constructor of the class. + /// + /// Whether the operation should be cancelled. + public CancelArgs(Boolean cancel) + { + this._cancel = cancel; + } + } +} diff --git a/tools/GSDumpGUI/Library/TCPLibrary/Base/Client.cs b/tools/GSDumpGUI/Library/TCPLibrary/Base/Client.cs new file mode 100644 index 0000000000..07bd8f8cfe --- /dev/null +++ b/tools/GSDumpGUI/Library/TCPLibrary/Base/Client.cs @@ -0,0 +1,323 @@ +/* +* Copyright (c) 2009 Ferreri Alessio +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +using System; +using System.Net.Sockets; +using System.Net; +using System.Threading; +using System.IO; +using System.ComponentModel; +using System.Text; +using System.Diagnostics; + +namespace TCPLibrary.Core +{ + /// + /// Base TCP client class wrapped around TcpClient. + /// + public class Client + { + /// + /// Lock object to assure that certain operation over the socket class are executed + /// in an exclusive way. + /// + private Object _lock; + + /// + /// Wrapper around the Network Stream of the socket. (Read-Only) + /// + private BinaryReader tr; + /// + /// Wrapper around the Network Stream of the socket. (Write-Only) + /// + private BinaryWriter tw; + /// + /// Address to which the client is connected. + /// + private IPEndPoint _address; + + /// + /// Flag to permit thread exit from the external. + /// + protected Boolean _active; + /// + /// Socket maintaining the connection. + /// + protected TcpClient _socket; + + /// + /// Get/set the address to which the client is connected. + /// + public IPEndPoint Address + { + get { return _address; } + } + + /// + /// Get the state of the connection. + /// + public Boolean Connected + { + get { return _socket != null; } + } + + /// + /// Delegate for the event of receiving/sending a line of data from/to the server. + /// + /// Sender of the event. + /// Line of data received. + public delegate void DataCommunicationHandler(Client sender, Data Data); + /// + /// Occurs when a line of data is received from the server. + /// + public event DataCommunicationHandler OnDataReceived; + /// + /// Occurs before the client send a line of data to the server. + /// + public event DataCommunicationHandler OnBeforeDataSent; + /// + /// Occurs after the client send a line of data to the server. + /// + public event DataCommunicationHandler OnAfterDataSent; + + /// + /// Delegate for the event of connection/disconnection to the server. + /// + /// Sender of the event. + public delegate void ConnectionStateHandler(Client sender); + /// + /// Occurs when the client successfully connect the server. + /// + public event ConnectionStateHandler OnConnected; + /// + /// Occurs when the client is disconnected from the server. + /// + public event ConnectionStateHandler OnDisconnected; + + /// + /// Delegate for the event of connection failed for rejection by the server. + /// + /// Sender of the event. + /// Message of fail sent by the server. + public delegate void ConnectionFailedHandler(Client sender, byte[] Message); + /// + /// Occurs when the client failed to connect to the server because the server rejected the connection. + /// + public event ConnectionFailedHandler OnConnectFailed; + + /// + /// Base constructor of the class. + /// + public Client() + { + _lock = new object(); + _address = null; + } + + /// + /// Try to connect to the server specified. + /// + /// Address of the server to connect. + /// Port of the server to connect. + /// True if the connection is successfull, false otherwise. + /// + /// + public virtual Boolean Connect(String Indirizzo, Int32 Port) + { + if (!Connected) + { + IPHostEntry addr = Dns.GetHostEntry(Indirizzo); + IPAddress ip = null; + + foreach (var itm in addr.AddressList) + { + if (itm.AddressFamily == AddressFamily.InterNetwork) + { + ip = itm; + break; + } + } + + if (ip != null) + { + _address = new IPEndPoint(ip, Port); + _socket = new TcpClient(); + + try + { + _socket.Connect(_address); + } + catch (SocketException) + { + _socket = null; + _address = null; + throw; + } + + tr = new BinaryReader(_socket.GetStream()); + tw = new BinaryWriter(_socket.GetStream()); + + // Receive the confirmation of the status of the connection to the server. + // Is CONNECTEDTCPSERVER if the connection is successfull, all other cases are wrong. + + Int32 Length = Convert.ToInt32(tr.ReadInt32()); + byte[] arr = new byte[Length]; + tr.Read(arr, 0, Length); + ASCIIEncoding ae = new ASCIIEncoding(); + String Accept = ae.GetString(arr, 0, arr.Length); + + if (Accept == "CONNECTEDTCPSERVER") + { + _active = true; + + Thread thd = new Thread(new ThreadStart(MainThread)); + thd.IsBackground = true; + thd.Name = "Client connected to " + Indirizzo + ":" + Port.ToString(); + thd.Start(); + + if (OnConnected != null) + OnConnected(this); + + return true; + } + else + { + Stop(); + if (OnConnectFailed != null) + OnConnectFailed(this, arr); + + return false; + } + } + else + return false; + } + else + throw new ArgumentException("The client is already connected!"); + } + + /// + /// Disconnect a Client if connected. + /// + public virtual void Disconnect() + { + lock (_lock) + { + _active = false; + tr.Close(); + tw.Close(); + } + } + + /// + /// Disconnect a Client if connected. + /// + protected virtual void Stop() + { + if (_socket != null) + { + tr.Close(); + tw.Close(); + _socket.Close(); + + _socket = null; + _address = null; + + if (OnDisconnected != null) + OnDisconnected(this); + } + } + + /// + /// Thread function that actually run the socket work. + /// + private void MainThread() + { + while (_active) + { + byte[] arr = null; + + try + { + int length = Convert.ToInt32(tr.ReadInt32()); + arr = new byte[length]; + int index = 0; + + while (length > 0) + { + + int receivedBytes = tr.Read(arr, index, length); + length -= receivedBytes; + index += receivedBytes; + } + } + catch (Exception) { } + + lock (_lock) + { + if (_active) + { + Boolean Stato = _socket.Client.Poll(100, SelectMode.SelectRead); + if ((arr == null) && (Stato == true)) + break; + else + if (OnDataReceived != null) + OnDataReceived(this, new Data(arr)); + } + else + break; + } + } + Stop(); + } + + /// + /// Send a line of data to the server. + /// + /// Data to send to the server. + /// + public void Send(Data msg) + { + if (_active) + { + if (OnBeforeDataSent != null) + OnBeforeDataSent(this, msg); + try + { + tw.Write(msg.Message.Length); + tw.Write(msg.Message); + tw.Flush(); + + if (OnAfterDataSent != null) + OnAfterDataSent(this, msg); + } + catch (IOException) + { + // Pensare a cosa fare quà. Questo è il caso in cui il server ha chiuso forzatamente + // la connessione mentre il client mandava roba. + } + } + else + throw new ArgumentException("The link is closed. Unable to send data."); + } + } +} diff --git a/tools/GSDumpGUI/Library/TCPLibrary/Base/ClientS.cs b/tools/GSDumpGUI/Library/TCPLibrary/Base/ClientS.cs new file mode 100644 index 0000000000..7b7443898f --- /dev/null +++ b/tools/GSDumpGUI/Library/TCPLibrary/Base/ClientS.cs @@ -0,0 +1,226 @@ +/* +* Copyright (c) 2009 Ferreri Alessio +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +using System; +using System.Net.Sockets; +using System.Threading; +using System.IO; +using System.Diagnostics; + +namespace TCPLibrary.Core +{ + /// + /// Base class that manages the single connection between a client and the server. + /// + public class ClientS + { + /// + /// Lock object to assure that certain operation over the socket class are executed + /// in an exclusive way. + /// + private Object _lock; + + /// + /// Wrapper around the Network Stream of the socket. (Read-Only) + /// + private BinaryReader tr; + /// + /// Wrapper around the Network Stream of the socket. (Write-Only) + /// + private BinaryWriter tw; + /// + /// Current IP address of the client. + /// + private String _ipaddress; + + /// + /// Flag to permit thread exit from the external. + /// + protected Boolean _active; + /// + /// Link to the server to which this client is connected. + /// + protected Server _server; + /// + /// Actual socket of the client. + /// + protected TcpClient _client; + + /// + /// Get the state of the connection. + /// + public Boolean Connected + { + get { return _client != null; } + } + + /// + /// IP Address of the client. + /// + public String IPAddress + { + get { return _ipaddress; } + } + + /// + /// Base class constructor. + /// + /// Server to which this client is linked to. + /// Socket of the client. + protected internal ClientS(Server server, TcpClient client) + { + _lock = new object(); + + _active = true; + _server = server; + _client = client; + _ipaddress = _client.Client.RemoteEndPoint.ToString(); + + NetworkStream ns = _client.GetStream(); + tr = new BinaryReader(ns); + tw = new BinaryWriter(ns); + } + + /// + /// Start up the thread managing this Client-Server connection. + /// + protected internal virtual void Start() + { + Thread _thread = new Thread(new ThreadStart(MainThread)); + _thread.IsBackground = true; + _thread.Name = "Thread Client " + _ipaddress; + _thread.Start(); + } + + /// + /// Thread function that actually run the socket work. + /// + private void MainThread() + { + while (_active) + { + byte[] arr = null; + + try + { + int length = Convert.ToInt32(tr.ReadInt32()); + arr = new byte[length]; + int index = 0; + + while (length > 0) + { + + int receivedBytes = tr.Read(arr, index, length); + length -= receivedBytes; + index += receivedBytes; + } + } + catch (Exception ex) + { + Debug.WriteLine(ex.ToString()); + } + + lock (_lock) + { + if (_active) + { + Boolean Stato = _client.Client.Poll(100, SelectMode.SelectRead); + if ((arr == null) && (Stato == true)) + break; + else + _server.RaiseDataReceivedEvent(this, new Data(arr)); + } + else + break; + } + } + Stop(); + } + + /// + /// Send a line of data to the client. + /// + /// Data to send to the client. + /// + public void Send(Data Data) + { + if (_active) + { + _server.RaiseBeforeDataSentEvent(this, Data); + + try + { + tw.Write(Data.Message.Length); + tw.Write(Data.Message); + tw.Flush(); + + _server.RaiseAfterDataSentEvent(this, Data); + } + catch (Exception ex) + { + Debug.Write(ex.ToString()); + // Pensare a cosa fare quà. Questo è il caso in cui il client ha chiuso forzatamente + // la connessione mentre il server mandava roba. + } + } + else + throw new ArgumentException("The link is closed. Unable to send data."); + } + + /// + /// Close the link between Client e Server. + /// + public void Disconnect() + { + lock (_lock) + { + _active = false; + tr.Close(); + tw.Close(); + } + } + + /// + /// Close the link between Client e Server. + /// + protected internal void Stop() + { + if (_client != null) + { + _server.RaiseClientBeforeDisconnectedEvent(this); + + tr.Close(); + tw.Close(); + + _client.Close(); + _client = null; + + lock (_server.Clients) + { + _server.Clients.Remove(this); + } + + _server.RaiseClientAfterDisconnectedEvent(this); + } + } + } +} diff --git a/tools/GSDumpGUI/Library/TCPLibrary/Base/Data.cs b/tools/GSDumpGUI/Library/TCPLibrary/Base/Data.cs new file mode 100644 index 0000000000..d946e09fed --- /dev/null +++ b/tools/GSDumpGUI/Library/TCPLibrary/Base/Data.cs @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2009 Ferreri Alessio +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +using System; +using System.Collections.Generic; +using System.Text; + +namespace TCPLibrary.Core +{ + /// + /// Structure for containing the data to be sent over a base client/server + /// + public class Data + { + /// + /// Data to be sent. + /// + private byte[] _message; + + /// + /// Get/set the data to be sent. + /// + public byte[] Message + { + get { return _message; } + set { _message = value; } + } + + /// + /// Base constructor of the class. + /// + /// Data to be sent. + public Data(byte[] msg) + { + this._message = msg; + } + } +} diff --git a/tools/GSDumpGUI/Library/TCPLibrary/Base/Server.cs b/tools/GSDumpGUI/Library/TCPLibrary/Base/Server.cs new file mode 100644 index 0000000000..4c7011639e --- /dev/null +++ b/tools/GSDumpGUI/Library/TCPLibrary/Base/Server.cs @@ -0,0 +1,365 @@ +/* +* Copyright (c) 2009 Ferreri Alessio +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Net.Sockets; +using System.Threading; +using System.IO; +using System.ComponentModel; +using System.Text; + +namespace TCPLibrary.Core +{ + /// + /// Base TCP server class wrapped around TcpListener. + /// + public class Server + { + /// + /// Socket maintaining the connection. + /// + private TcpListener _socket; + /// + /// Port to which the server will listen. + /// + private Int32 _port; + /// + /// Whether the server is enabled or not. + /// + private Boolean _enabled; + /// + /// List of the clients connected to the server. + /// + private List _clients; + /// + /// Number of connection permitted in the backlog of the server. + /// + private Int32 _connectionbacklog; + + /// + /// Delegate for the event of the Enabled property change. + /// + /// Sender of the event. + public delegate void EnabledChangedHandler(Server sender); + /// + /// Occurs when the Enabled property is changed. + /// + public event EnabledChangedHandler OnEnabledChanged; + + /// + /// Delegate for the event of receiving a line of data from a client. + /// + /// Server raising the event. + /// Client involved in the communication. + /// Line of data received. + public delegate void DataCommunicationHandler(Server server, ClientS client, Data Data); + /// + /// Occurs when a client send a line of data to the server. + /// + public event DataCommunicationHandler OnClientDataReceived; + /// + /// Occurs before the server send a line of data to a client. + /// + public event DataCommunicationHandler OnClientBeforeDataSent; + /// + /// Occurs after the server send a line of data to a client. + /// + public event DataCommunicationHandler OnClientAfterDataSent; + + /// + /// Delegate for the event of a connection of a client. + /// + /// Server raising the event. + /// The new client connected. + public delegate void ConnectedHandler(Server server, ClientS sender); + /// + /// Occurs after a client is connected to the server. + /// + public event ConnectedHandler OnClientAfterConnect; + + /// + /// Delegate for the event of a connection of a client. + /// + /// Server raising the event. + /// The new client to be connected. + /// Specify if the client should be accepted into the server. + public delegate void BeforeConnectedHandler(Server server, ClientS client, CancelArgs args); + /// + /// Occurs before a client is allowed to connect to the server. + /// + public event BeforeConnectedHandler OnClientBeforeConnect; + + /// + /// Delegate for the event of disconnection of a client. + /// + /// Server raising the event. + /// The client disconnected. + public delegate void DisconnectedHandler(Server server, ClientS sender); + /// + /// Occurs right after a client disconnect from the server. + /// + public event DisconnectedHandler OnClientAfterDisconnected; + /// + /// Occurs before a client disconnect from the server. + /// + public event DisconnectedHandler OnClientBeforeDisconnected; + + /// + /// Get/set the port number to which the server will listen. Cannot be set while the server is active. + /// + /// + public Int32 Port + { + get { return _port; } + set + { + if (Enabled == false) + _port = value; + else + throw new ArgumentException("Impossibile eseguire l'operazione a server attivo"); + } + } + + /// + /// Get/set the enabled state of the server. Setting this to true will actually activate the server. + /// + /// + public Boolean Enabled + { + get { return _enabled; } + set + { + if (value == true) + { + if (_enabled == false) + ActivateServer(); + } + else + { + if (_enabled == true) + DeactivateServer(); + } + } + } + + /// + /// Get/set the number of connection permitted in the backlog of the server. + /// + /// + public Int32 ConnectionBackLog + { + get { return _connectionbacklog; } + set + { + if (Enabled == false) + _connectionbacklog = value; + else + throw new ArgumentException("Impossibile eseguire l'operazione a server attivo"); + } + } + + /// + /// Get the list of the clients connected to the server. + /// + public List Clients + { + get { return _clients; } + } + + /// + /// Deactivate the server. + /// + protected virtual void DeactivateServer() + { + _enabled = false; + _socket.Stop(); + _socket = null; + + lock (_clients) + { + for (int i = 0; i < _clients.Count; i++) + _clients[i].Disconnect(); + } + + if (OnEnabledChanged != null) + OnEnabledChanged(this); + } + + /// + /// Activate the server. + /// + protected virtual void ActivateServer() + { + _socket = new TcpListener(IPAddress.Any, Port); + _socket.Start(ConnectionBackLog); + Thread thd = new Thread(new ThreadStart(MainThread)); + thd.Name = "Server on port " + Port.ToString(); + thd.IsBackground = true; + thd.Start(); + _enabled = true; + if (OnEnabledChanged != null) + OnEnabledChanged(this); + } + + /// + /// Broadcast a line of data to all the clients connected to the server. + /// + /// Line of data to be sent. + /// + public void Broadcast(Data Data) + { + if (Enabled) + { + lock (_clients) + { + foreach (var itm in _clients) + if (itm.Connected) + itm.Send(Data); + } + } + else + throw new ArgumentException("Unable to execute this operation when the server is inactive."); + } + + /// + /// Base constructor of the class. + /// + public Server() + { + _clients = new List(); + _port = 0; + _connectionbacklog = 0; + _enabled = false; + } + + /// + /// Thread function that actually run the server socket work. + /// + private void MainThread() + { + try + { + while (Enabled == true) + { + TcpClient client = _socket.AcceptTcpClient(); + + CancelArgs args = new CancelArgs(false); + ClientS cl = CreateClient(client); + if (OnClientBeforeConnect != null) + OnClientBeforeConnect(this, cl, args); + + if (args.Cancel != true) + { + lock (_clients) + { + _clients.Add(cl); + } + + ASCIIEncoding ae = new ASCIIEncoding(); + byte[] arr = ae.GetBytes("CONNECTEDTCPSERVER"); + + cl.Send(new Data(arr)); + + if (OnClientAfterConnect != null) + OnClientAfterConnect(this, cl); + cl.Start(); + } + else + { + client.GetStream().Close(); + client.Close(); + } + } + } + catch (SocketException) + { + Enabled = false; + } + } + + /// + /// Overridable function that create the structure to memorize the client data. + /// + /// Socket of the client. + /// The structure in which memorize all the information of the client. + protected virtual ClientS CreateClient(TcpClient socket) + { + ClientS cl = new ClientS(this, socket); + return cl; + } + + /// + /// Raise the OnClientAfterDataSent event. + /// + /// Client that raised the event. + /// Line of data sent. + internal void RaiseAfterDataSentEvent(ClientS cl, Data data) + { + if (OnClientAfterDataSent != null) + OnClientAfterDataSent(this, cl, data); + } + + /// + /// Raise the OnClientBeforeDataSent event. + /// + /// Client that raised the event. + /// Line of data sent. + internal void RaiseBeforeDataSentEvent(ClientS cl, Data data) + { + if (OnClientBeforeDataSent != null) + OnClientBeforeDataSent(this, cl, data); + } + + /// + /// Raise the OnDataReceived event. + /// + /// Client that raised the event. + /// Line of data received. + internal void RaiseDataReceivedEvent(ClientS cl, Data data) + { + if (OnClientDataReceived != null) + OnClientDataReceived(this, cl, data); + } + + /// + /// Raise the OnClientAfterDisconnected event. + /// + /// Client that raised the event. + internal void RaiseClientAfterDisconnectedEvent(ClientS cl) + { + if (OnClientAfterDisconnected != null) + OnClientAfterDisconnected(this, cl); + } + + /// + /// Raise the OnClientBeforeDisconnected event. + /// + /// Client that raised the event. + internal void RaiseClientBeforeDisconnectedEvent(ClientS cl) + { + if (OnClientBeforeDisconnected != null) + OnClientBeforeDisconnected(this, cl); + } + } +} diff --git a/tools/GSDumpGUI/Library/TCPLibrary/Message/BaseMessageClient.cs b/tools/GSDumpGUI/Library/TCPLibrary/Message/BaseMessageClient.cs new file mode 100644 index 0000000000..098cf1632a --- /dev/null +++ b/tools/GSDumpGUI/Library/TCPLibrary/Message/BaseMessageClient.cs @@ -0,0 +1,137 @@ +/* +The MIT License + +Copyright (c) 2008 Ferreri Alessio + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +using TCPLibrary.MessageBased.Core; +using TCPLibrary.Core; +using System; + +namespace TCPLibrary.MessageBased.Core +{ + /// + /// TCP Client Class that work with Message structures. + /// + public class BaseMessageClient : Client + { + /// + /// Delegate for the event of receiving a message structure from the server. + /// + /// Sender of the event. + /// Message received. + public delegate void MessageReceivedHandler(Client sender, TCPMessage Mess); + /// + /// Occurs when the client receive a message structure from the server. + /// + public event MessageReceivedHandler OnMessageReceived; + /// + /// Delegate for the event of sending a message structure to the server. + /// + /// Sender of the event. + /// Message sent. + public delegate void MessageSentHandler(Client sender, TCPMessage Mess); + /// + /// Occurs before the client send a message structure to the server. + /// + public event MessageSentHandler OnBeforeMessageSent; + /// + /// Occurs after the client send a message structure to the server. + /// + public event MessageSentHandler OnAfterMessageSent; + /// + /// Delegate for the event of connection fail for max users number reached. + /// + /// Sender of the event. + public delegate void MaxUsersReached(Client sender); + /// + /// Occurs when the connection fail as the server reached the maximum number of clients allowed. + /// + public event MaxUsersReached OnMaxUsersConnectionFail; + + /// + /// Base constructor of the class. + /// + public BaseMessageClient() + { + OnDataReceived += new DataCommunicationHandler(BaseMessageClient_OnDataReceived); + OnAfterDataSent += new DataCommunicationHandler(BaseMessageClient_OnDataSent); + OnConnectFailed += new ConnectionFailedHandler(BaseMessageClient_OnConnectFailed); + } + + /// + /// When the connection is rejected by the server raise the correct event. + /// + /// Sender of the event. + /// Message of the server. + void BaseMessageClient_OnConnectFailed(Client sender, byte[] Message) + { + if (TCPLibrary.MessageBased.Core.TCPMessage.FromByteArray(Message).MessageType == MessageType.MaxUsers) + if (OnMaxUsersConnectionFail != null) + OnMaxUsersConnectionFail(sender); + } + + /// + /// Parse the raw data sent to the server and create Message structures. + /// + /// Sender of the event. + /// Line of data sent. + void BaseMessageClient_OnDataSent(Client sender, Data Data) + { + TCPMessage msg = TCPMessage.FromByteArray(Data.Message); + if (OnAfterMessageSent != null) + OnAfterMessageSent(sender, msg); + } + + /// + /// Parse the raw data received from the server and create Message structures. + /// + /// Sender of the event. + /// Line of data received. + void BaseMessageClient_OnDataReceived(Client sender, Data Data) + { + TCPMessage msg = null; + try + { + msg = TCPMessage.FromByteArray(Data.Message); + } + catch (Exception) + { + + } + if (msg != null) + if (OnMessageReceived != null) + OnMessageReceived(sender, msg); + } + + /// + /// Send a message structure to the server. + /// + /// Message structure to be send. + /// + public void Send(TCPMessage msg) + { + if (OnBeforeMessageSent != null) + OnBeforeMessageSent(this, msg); + base.Send(new Data(msg.ToByteArray())); + } + } +} diff --git a/tools/GSDumpGUI/Library/TCPLibrary/Message/BaseMessageClientS.cs b/tools/GSDumpGUI/Library/TCPLibrary/Message/BaseMessageClientS.cs new file mode 100644 index 0000000000..d35d90fad4 --- /dev/null +++ b/tools/GSDumpGUI/Library/TCPLibrary/Message/BaseMessageClientS.cs @@ -0,0 +1,59 @@ +/* +The MIT License + +Copyright (c) 2008 Ferreri Alessio + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +using System.Net.Sockets; +using TCPLibrary.Core; +using TCPLibrary.MessageBased.Core; + +namespace TCPLibrary.MessageBased.Core +{ + /// + /// Class that manages the single connection between a client and the server based + /// on Message structures. + /// + public class BaseMessageClientS : ClientS + { + /// + /// Base constructor of the class. + /// + /// Server to which this client is linked to. + /// Socket of the client. + protected internal BaseMessageClientS(Server server, TcpClient client) + : base(server, client) + { + + } + + /// + /// Send a Message structure to the client. + /// + /// Message to be sent. + /// + public void Send(TCPMessage msg) + { + ((BaseMessageServer)_server).RaiseBeforeMessageSentEvent(this, msg); + base.Send(new Data(msg.ToByteArray())); + } + } +} diff --git a/tools/GSDumpGUI/Library/TCPLibrary/Message/BaseMessageServer.cs b/tools/GSDumpGUI/Library/TCPLibrary/Message/BaseMessageServer.cs new file mode 100644 index 0000000000..02aac1fe2e --- /dev/null +++ b/tools/GSDumpGUI/Library/TCPLibrary/Message/BaseMessageServer.cs @@ -0,0 +1,186 @@ +/* +The MIT License + +Copyright (c) 2008 Ferreri Alessio + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +using System; +using System.Collections.Generic; +using System.Text; +using TCPLibrary.MessageBased.Core; +using System.Net.Sockets; +using System.Threading; +using TCPLibrary.Core; + +namespace TCPLibrary.MessageBased.Core +{ + /// + /// TCP Server Class that work with Message structures. + /// + public class BaseMessageServer : Server + { + /// + /// Limit of user allowed inside the server. + /// + protected Int32 _userlimit; + + /// + /// Delegate for the event of receiving a Message from a client. + /// + /// Server raising the event. + /// Client sending the message. + /// Message received. + public delegate void MessageReceivedHandler(BaseMessageServer server, BaseMessageClientS sender, TCPMessage Mess); + /// + /// Occurs when a Message is received by the server. + /// + public event MessageReceivedHandler OnClientMessageReceived; + /// + /// Delegate for the event of sending a Message to a client. + /// + /// Server raising the event. + /// Client that will receive the message. + /// Message to be sent. + public delegate void MessageSentHandler(BaseMessageServer server, BaseMessageClientS receiver, TCPMessage Mess); + /// + /// Occurs when the server send a Message to a client. + /// + public event MessageSentHandler OnClientBeforeMessageSent; + /// + /// Occurs when the server send a Message to a client. + /// + public event MessageSentHandler OnClientAfterMessageSent; + + /// + /// Get/set the limit of users allowed inside the server. + /// + public Int32 UserLimit + { + get { return _userlimit; } + set { _userlimit = value; } + } + + /// + /// Base constructor of the class. + /// + public BaseMessageServer() : base() + { + OnClientBeforeConnect += new BeforeConnectedHandler(BaseMessageServer_OnClientBeforeConnect); + OnClientDataReceived += new DataCommunicationHandler(BaseMessageServer_OnDataReceived); + OnClientAfterDataSent += new DataCommunicationHandler(BaseMessageServer_OnDataSent); + _userlimit = 0; + } + + /// + /// Kick the client if the server reached the maximum allowed number of clients. + /// + /// Server raising the event. + /// Client connecting to the server. + /// Specify if the client should be accepted into the server. + void BaseMessageServer_OnClientBeforeConnect(Server server, ClientS client, CancelArgs args) + { + if ((Clients.Count >= UserLimit) && (UserLimit != 0)) + { + TCPMessage msg = new TCPMessage(); + msg.MessageType = MessageType.MaxUsers; + ((BaseMessageClientS)client).Send(msg); + + args.Cancel = true; + } + } + + /// + /// Trasform the line of data sent into a Message structure and raise + /// the event linked. + /// + /// Server raising the event. + /// Client that will receive the Message. + /// Line of data sent. + void BaseMessageServer_OnDataSent(Server server, ClientS receiver, Data Data) + { + TCPMessage msg = null; + try + { + msg = TCPMessage.FromByteArray(Data.Message); + } + catch (Exception) + { + + } + if (msg != null) + if (OnClientAfterMessageSent != null) + OnClientAfterMessageSent(this, (BaseMessageClientS)receiver, msg); + } + + /// + /// Raise the OnClientBeforeMessageSent event. + /// + /// Client that raised the event. + /// Message to be sent. + internal void RaiseBeforeMessageSentEvent(ClientS cl, TCPMessage msg) + { + if (OnClientBeforeMessageSent != null) + OnClientBeforeMessageSent(this, (BaseMessageClientS)cl, msg); + } + + /// + /// Trasform the line of data received into a Message structure and raise + /// the event linked. + /// + /// Server raising the event. + /// Client sending the data. + /// Line of data received. + void BaseMessageServer_OnDataReceived(Server server, ClientS sender, Data Data) + { + TCPMessage msg = null; + try + { + msg = TCPMessage.FromByteArray(Data.Message); + } + catch (Exception) + { + + } + if (msg != null) + if (OnClientMessageReceived != null) + OnClientMessageReceived(this, (BaseMessageClientS)sender, msg); + } + + /// + /// Function that create the structure to memorize the client data. + /// + /// Socket of the client. + /// The structure in which memorize all the information of the client. + protected override ClientS CreateClient(TcpClient socket) + { + return new BaseMessageClientS(this, socket); + } + + /// + /// Send a message to all clients in broadcast. + /// + /// Message to be sent. + public void Broadcast(TCPMessage Data) + { + base.Broadcast(new Data(Data.ToByteArray())); + } + } +} diff --git a/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs b/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs new file mode 100644 index 0000000000..0dc5d4facc --- /dev/null +++ b/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs @@ -0,0 +1,114 @@ +/* +The MIT License + +Copyright (c) 2008 Ferreri Alessio + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +using System; +using System.Collections.Generic; +using System.Xml.Serialization; +using System.IO; +using System.Runtime.Serialization.Formatters.Binary; + +namespace TCPLibrary.MessageBased.Core +{ + /// + /// Message structure that contains all the information of the message exchanged between + /// Message driven server/client. + /// + [Serializable] + public class TCPMessage + { + /// + /// Message Type. + /// + private MessageType _messageType; + /// + /// Messages parameters. + /// + private List _parameters; + + /// + /// Get/set the message type. + /// + public MessageType MessageType + { + get { return _messageType; } + set { _messageType = value; } + } + + /// + /// Get/set the message parameters. + /// + public List Parameters + { + get { return _parameters; } + } + + /// + /// Base constructor of the class. + /// + public TCPMessage() + { + _messageType = MessageType.Connect; + _parameters = new List(); + } + + /// + /// Parse a string and create a Message structure. + /// + /// Raw data. + /// Parsed message structure. + static public TCPMessage FromByteArray(byte[] data) + { + MemoryStream ms = new MemoryStream(); + BinaryWriter sw = new BinaryWriter(ms); + sw.Write(data, 0, data.Length); + sw.Flush(); + ms.Position = 0; + + BinaryFormatter formatter = new BinaryFormatter(); + TCPMessage msg = formatter.Deserialize(ms) as TCPMessage; + + return msg; + } + + /// + /// Trasform the structure into a String. + /// + /// The structure in a String format. + public byte[] ToByteArray() + { + MemoryStream ms = new MemoryStream(); + BinaryFormatter formatter = new BinaryFormatter(); + formatter.Serialize(ms, this); + ms.Position = 0; + return ms.ToArray(); + } + } + + public enum MessageType + { + Connect, + MaxUsers, + SizeDump + } +} From 58aa33b8bc69dbcbd45ae2f301b3e1e6364222ea Mon Sep 17 00:00:00 2001 From: "feal87@gmail.com" Date: Sun, 19 Dec 2010 16:03:21 +0000 Subject: [PATCH 11/33] git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4107 96395faa-99c1-11dd-bbfe-3dabce05a288 --- tools/GSDumpGUI/Library/GSDXWrapper.cs | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/tools/GSDumpGUI/Library/GSDXWrapper.cs b/tools/GSDumpGUI/Library/GSDXWrapper.cs index c82aac18d0..9044f8767b 100644 --- a/tools/GSDumpGUI/Library/GSDXWrapper.cs +++ b/tools/GSDumpGUI/Library/GSDXWrapper.cs @@ -6,9 +6,7 @@ using System.IO; namespace GSDumpGUI { - public delegate void GSgifTransfer1(IntPtr data, int size); - public delegate void GSgifTransfer2(IntPtr data, int size); - public delegate void GSgifTransfer3(IntPtr data, int size); + public delegate void GSgifTransfer(IntPtr data, int size); public delegate void GSVSync(byte field); public delegate void GSreadFIFO2(IntPtr data, int size); public delegate void GSsetGameCRC(int crc, int options); @@ -25,9 +23,7 @@ namespace GSDumpGUI { private GSConfigure gsConfigure; private PSEgetLibName PsegetLibName; - private GSgifTransfer1 GSgifTransfer1; - private GSgifTransfer2 GSgifTransfer2; - private GSgifTransfer3 GSgifTransfer3; + private GSgifTransfer GSgifTransfer; private GSVSync GSVSync; private GSreadFIFO2 GSreadFIFO2; private GSsetGameCRC GSsetGameCRC; @@ -57,9 +53,7 @@ namespace GSDumpGUI IntPtr funcaddrLibName = NativeMethods.GetProcAddress(hmod, "PS2EgetLibName"); IntPtr funcaddrConfig = NativeMethods.GetProcAddress(hmod, "GSconfigure"); - IntPtr funcaddrGIF1 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer1"); - IntPtr funcaddrGIF2 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer2"); - IntPtr funcaddrGIF3 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer3"); + IntPtr funcaddrGIF = NativeMethods.GetProcAddress(hmod, "GSgifTransfer"); IntPtr funcaddrVSync = NativeMethods.GetProcAddress(hmod, "GSvsync"); IntPtr funcaddrSetBaseMem = NativeMethods.GetProcAddress(hmod, "GSsetBaseMem"); IntPtr funcaddrOpen = NativeMethods.GetProcAddress(hmod, "GSopen"); @@ -108,9 +102,7 @@ namespace GSDumpGUI IntPtr funcaddrLibName = NativeMethods.GetProcAddress(hmod, "PS2EgetLibName"); IntPtr funcaddrConfig = NativeMethods.GetProcAddress(hmod, "GSconfigure"); - IntPtr funcaddrGIF1 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer1"); - IntPtr funcaddrGIF2 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer2"); - IntPtr funcaddrGIF3 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer3"); + IntPtr funcaddrGIF = NativeMethods.GetProcAddress(hmod, "GSgifTransfer"); IntPtr funcaddrVSync = NativeMethods.GetProcAddress(hmod, "GSvsync"); IntPtr funcaddrSetBaseMem = NativeMethods.GetProcAddress(hmod, "GSsetBaseMem"); IntPtr funcaddrOpen = NativeMethods.GetProcAddress(hmod, "GSopen"); @@ -124,9 +116,7 @@ namespace GSDumpGUI gsConfigure = (GSConfigure)Marshal.GetDelegateForFunctionPointer(funcaddrConfig, typeof(GSConfigure)); PsegetLibName = (PSEgetLibName)Marshal.GetDelegateForFunctionPointer(funcaddrLibName, typeof(PSEgetLibName)); - this.GSgifTransfer1 = (GSgifTransfer1)Marshal.GetDelegateForFunctionPointer(funcaddrGIF1, typeof(GSgifTransfer1)); - this.GSgifTransfer2 = (GSgifTransfer2)Marshal.GetDelegateForFunctionPointer(funcaddrGIF2, typeof(GSgifTransfer2)); - this.GSgifTransfer3 = (GSgifTransfer3)Marshal.GetDelegateForFunctionPointer(funcaddrGIF3, typeof(GSgifTransfer3)); + this.GSgifTransfer = (GSgifTransfer)Marshal.GetDelegateForFunctionPointer(funcaddrGIF, typeof(GSgifTransfer)); this.GSVSync = (GSVSync)Marshal.GetDelegateForFunctionPointer(funcaddrVSync, typeof(GSVSync)); this.GSsetBaseMem = (GSsetBaseMem)Marshal.GetDelegateForFunctionPointer(funcaddrSetBaseMem, typeof(GSsetBaseMem)); this.GSopen = (GSopen)Marshal.GetDelegateForFunctionPointer(funcaddrOpen, typeof(GSopen)); @@ -219,7 +209,7 @@ namespace GSDumpGUI case 2: fixed (byte* gifdata = itm.data) { - GSgifTransfer2(new IntPtr(gifdata + 1), (itm.data.Length - 1) / 16); + GSgifTransfer(new IntPtr(gifdata + 1), (itm.data.Length - 1) / 16); } break;/* case 2: From 36f9dcfcfadcf345712e34a09b22010eeb2d1d96 Mon Sep 17 00:00:00 2001 From: "feal87@gmail.com" Date: Sun, 19 Dec 2010 16:54:56 +0000 Subject: [PATCH 12/33] Little fixes. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4108 96395faa-99c1-11dd-bbfe-3dabce05a288 --- tools/GSDumpGUI/GSDumpGUI.csproj | 1 + tools/GSDumpGUI/Library/GSDXWrapper.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/GSDumpGUI/GSDumpGUI.csproj b/tools/GSDumpGUI/GSDumpGUI.csproj index 0ccdfd4657..6ff75d0ab1 100644 --- a/tools/GSDumpGUI/GSDumpGUI.csproj +++ b/tools/GSDumpGUI/GSDumpGUI.csproj @@ -28,6 +28,7 @@ prompt 4 x86 + true pdbonly diff --git a/tools/GSDumpGUI/Library/GSDXWrapper.cs b/tools/GSDumpGUI/Library/GSDXWrapper.cs index 9044f8767b..b33cf0de31 100644 --- a/tools/GSDumpGUI/Library/GSDXWrapper.cs +++ b/tools/GSDumpGUI/Library/GSDXWrapper.cs @@ -65,7 +65,7 @@ namespace GSDumpGUI IntPtr funcaddrinit = NativeMethods.GetProcAddress(hmod, "GSinit"); NativeMethods.FreeLibrary(hmod); - if (!((funcaddrConfig.ToInt64() > 0) && (funcaddrLibName.ToInt64() > 0))) + if (!((funcaddrConfig.ToInt64() > 0) && (funcaddrLibName.ToInt64() > 0) && (funcaddrGIF.ToInt64() > 0))) { Int32 id = NativeMethods.GetLastError(); System.IO.File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "log.txt", DLL + " failed to load. Error " + id + Environment.NewLine); From f1e5814c8b4b40abd2f8281df828e19dfcc1740d Mon Sep 17 00:00:00 2001 From: "feal87@gmail.com" Date: Sun, 19 Dec 2010 21:32:09 +0000 Subject: [PATCH 13/33] Added some statistics to better identify the type of dump you are using. Fixed some code to be coherent with actual pcsx2 state. (Still need to talk to Jake to understand the new changes) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4109 96395faa-99c1-11dd-bbfe-3dabce05a288 --- tools/GSDumpGUI/Core/Program.cs | 42 ++++- tools/GSDumpGUI/Forms/frmMain.Designer.cs | 177 +++++++++++++++++- tools/GSDumpGUI/Forms/frmMain.cs | 3 + tools/GSDumpGUI/Library/GSDXWrapper.cs | 48 +++-- tools/GSDumpGUI/Library/GSDump/GSDump.cs | 4 +- .../Library/TCPLibrary/Message/TCPMessage.cs | 3 +- 6 files changed, 251 insertions(+), 26 deletions(-) diff --git a/tools/GSDumpGUI/Core/Program.cs b/tools/GSDumpGUI/Core/Program.cs index 9e83a3f448..010502aafa 100644 --- a/tools/GSDumpGUI/Core/Program.cs +++ b/tools/GSDumpGUI/Core/Program.cs @@ -119,7 +119,19 @@ namespace GSDumpGUI case MessageType.SizeDump: frmMain.Invoke(new Action(delegate(object e) { - frmMain.txtDumpSize.Text = (((int)Mess.Parameters[0]) / 1024f / 1024f).ToString("F2"); + frmMain.txtDumpSize.Text = (((int)Mess.Parameters[0]) / 1024f / 1024f).ToString("F2") + " MB"; + }), new object[] { null }); + break; + case MessageType.Statistics: + frmMain.Invoke(new Action(delegate(object e) + { + frmMain.txtGIFPackets.Text = ((int)Mess.Parameters[0]).ToString(); + frmMain.txtPath1.Text = ((int)Mess.Parameters[1]).ToString(); + frmMain.txtPath2.Text = ((int)Mess.Parameters[2]).ToString(); + frmMain.txtPath3.Text = ((int)Mess.Parameters[3]).ToString(); + frmMain.txtReadFifo.Text = ((int)Mess.Parameters[5]).ToString(); + frmMain.txtVSync.Text = ((int)Mess.Parameters[4]).ToString(); + frmMain.txtRegisters.Text = ((int)Mess.Parameters[6]).ToString(); }), new object[] { null }); break; default: @@ -129,6 +141,7 @@ namespace GSDumpGUI static void Client_OnMessageReceived(TCPLibrary.Core.Client sender, TCPLibrary.MessageBased.Core.TCPMessage Mess) { + TCPMessage msg; switch (Mess.MessageType) { case TCPLibrary.MessageBased.Core.MessageType.Connect: @@ -136,7 +149,7 @@ namespace GSDumpGUI case TCPLibrary.MessageBased.Core.MessageType.MaxUsers: break; case TCPLibrary.MessageBased.Core.MessageType.SizeDump: - TCPMessage msg = new TCPMessage(); + msg = new TCPMessage(); msg.MessageType = MessageType.SizeDump; if (dump != null) msg.Parameters.Add(dump.Size); @@ -144,6 +157,31 @@ namespace GSDumpGUI msg.Parameters.Add(0); Client.Send(msg); break; + case MessageType.Statistics: + msg = new TCPMessage(); + msg.MessageType = MessageType.Statistics; + if (dump != null) + { + msg.Parameters.Add(dump.Data.Count); + msg.Parameters.Add(dump.Data.FindAll(a => (int)a.id == 0 && (a.data[0] == 3 || a.data[0] == 0)).Count); + msg.Parameters.Add(dump.Data.FindAll(a => (int)a.id == 0 && a.data[0] == 1).Count); + msg.Parameters.Add(dump.Data.FindAll(a => (int)a.id == 0 && a.data[0] == 2).Count); + msg.Parameters.Add(dump.Data.FindAll(a => (int)a.id == 1).Count); + msg.Parameters.Add(dump.Data.FindAll(a => (int)a.id == 2).Count); + msg.Parameters.Add(dump.Data.FindAll(a => (int)a.id == 3).Count); + } + else + { + msg.Parameters.Add(0); + msg.Parameters.Add(0); + msg.Parameters.Add(0); + msg.Parameters.Add(0); + msg.Parameters.Add(0); + msg.Parameters.Add(0); + msg.Parameters.Add(0); + } + Client.Send(msg); + break; default: break; } diff --git a/tools/GSDumpGUI/Forms/frmMain.Designer.cs b/tools/GSDumpGUI/Forms/frmMain.Designer.cs index 9f4045a6b2..b7f37384fd 100644 --- a/tools/GSDumpGUI/Forms/frmMain.Designer.cs +++ b/tools/GSDumpGUI/Forms/frmMain.Designer.cs @@ -59,6 +59,20 @@ this.lblDumpSize = new System.Windows.Forms.Label(); this.txtDumpSize = new System.Windows.Forms.Label(); this.lblWIP = new System.Windows.Forms.Label(); + this.txtGIFPackets = new System.Windows.Forms.Label(); + this.lblGIFPackets = new System.Windows.Forms.Label(); + this.txtPath1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.txtPath2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.txtPath3 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.txtVSync = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.txtReadFifo = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.txtRegisters = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.pctBox)).BeginInit(); this.SuspendLayout(); // @@ -323,7 +337,7 @@ this.lstProcesses.FormattingEnabled = true; this.lstProcesses.Location = new System.Drawing.Point(12, 502); this.lstProcesses.Name = "lstProcesses"; - this.lstProcesses.Size = new System.Drawing.Size(248, 251); + this.lstProcesses.Size = new System.Drawing.Size(248, 277); this.lstProcesses.TabIndex = 27; this.lstProcesses.SelectedIndexChanged += new System.EventHandler(this.lstProcesses_SelectedIndexChanged); // @@ -339,9 +353,10 @@ // lblDumpSize // this.lblDumpSize.AutoSize = true; + this.lblDumpSize.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblDumpSize.Location = new System.Drawing.Point(279, 487); this.lblDumpSize.Name = "lblDumpSize"; - this.lblDumpSize.Size = new System.Drawing.Size(58, 13); + this.lblDumpSize.Size = new System.Drawing.Size(67, 13); this.lblDumpSize.TabIndex = 29; this.lblDumpSize.Text = "Dump Size"; // @@ -358,17 +373,157 @@ this.lblWIP.AutoSize = true; this.lblWIP.Font = new System.Drawing.Font("Times New Roman", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblWIP.ForeColor = System.Drawing.Color.Red; - this.lblWIP.Location = new System.Drawing.Point(407, 589); + this.lblWIP.Location = new System.Drawing.Point(468, 587); this.lblWIP.Name = "lblWIP"; this.lblWIP.Size = new System.Drawing.Size(508, 73); this.lblWIP.TabIndex = 31; this.lblWIP.Text = "Work in Progress"; // + // txtGIFPackets + // + this.txtGIFPackets.AutoSize = true; + this.txtGIFPackets.Location = new System.Drawing.Point(279, 539); + this.txtGIFPackets.Name = "txtGIFPackets"; + this.txtGIFPackets.Size = new System.Drawing.Size(0, 13); + this.txtGIFPackets.TabIndex = 33; + // + // lblGIFPackets + // + this.lblGIFPackets.AutoSize = true; + this.lblGIFPackets.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblGIFPackets.Location = new System.Drawing.Point(279, 523); + this.lblGIFPackets.Name = "lblGIFPackets"; + this.lblGIFPackets.Size = new System.Drawing.Size(110, 13); + this.lblGIFPackets.TabIndex = 32; + this.lblGIFPackets.Text = "Total GIF Packets"; + // + // txtPath1 + // + this.txtPath1.AutoSize = true; + this.txtPath1.Location = new System.Drawing.Point(279, 578); + this.txtPath1.Name = "txtPath1"; + this.txtPath1.Size = new System.Drawing.Size(0, 13); + this.txtPath1.TabIndex = 35; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label2.Location = new System.Drawing.Point(279, 560); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(114, 13); + this.label2.TabIndex = 34; + this.label2.Text = "Path1 GIF Packets"; + // + // txtPath2 + // + this.txtPath2.AutoSize = true; + this.txtPath2.Location = new System.Drawing.Point(279, 618); + this.txtPath2.Name = "txtPath2"; + this.txtPath2.Size = new System.Drawing.Size(0, 13); + this.txtPath2.TabIndex = 37; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label3.Location = new System.Drawing.Point(279, 601); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(114, 13); + this.label3.TabIndex = 36; + this.label3.Text = "Path2 GIF Packets"; + // + // txtPath3 + // + this.txtPath3.AutoSize = true; + this.txtPath3.Location = new System.Drawing.Point(279, 653); + this.txtPath3.Name = "txtPath3"; + this.txtPath3.Size = new System.Drawing.Size(0, 13); + this.txtPath3.TabIndex = 39; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label5.Location = new System.Drawing.Point(279, 635); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(114, 13); + this.label5.TabIndex = 38; + this.label5.Text = "Path3 GIF Packets"; + // + // txtVSync + // + this.txtVSync.AutoSize = true; + this.txtVSync.Location = new System.Drawing.Point(279, 690); + this.txtVSync.Name = "txtVSync"; + this.txtVSync.Size = new System.Drawing.Size(0, 13); + this.txtVSync.TabIndex = 41; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label4.Location = new System.Drawing.Point(279, 671); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(91, 13); + this.label4.TabIndex = 40; + this.label4.Text = "Vsync Packets"; + // + // txtReadFifo + // + this.txtReadFifo.AutoSize = true; + this.txtReadFifo.Location = new System.Drawing.Point(279, 724); + this.txtReadFifo.Name = "txtReadFifo"; + this.txtReadFifo.Size = new System.Drawing.Size(0, 13); + this.txtReadFifo.TabIndex = 43; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label7.Location = new System.Drawing.Point(279, 709); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(114, 13); + this.label7.TabIndex = 42; + this.label7.Text = "ReadFIFO Packets"; + // + // txtRegisters + // + this.txtRegisters.AutoSize = true; + this.txtRegisters.Location = new System.Drawing.Point(279, 764); + this.txtRegisters.Name = "txtRegisters"; + this.txtRegisters.Size = new System.Drawing.Size(0, 13); + this.txtRegisters.TabIndex = 45; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label6.Location = new System.Drawing.Point(279, 744); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(110, 13); + this.label6.TabIndex = 44; + this.label6.Text = "Registers Packets"; + // // GSDumpGUI // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(988, 766); + this.ClientSize = new System.Drawing.Size(988, 790); + this.Controls.Add(this.txtRegisters); + this.Controls.Add(this.label6); + this.Controls.Add(this.txtReadFifo); + this.Controls.Add(this.label7); + this.Controls.Add(this.txtVSync); + this.Controls.Add(this.label4); + this.Controls.Add(this.txtPath3); + this.Controls.Add(this.label5); + this.Controls.Add(this.txtPath2); + this.Controls.Add(this.label3); + this.Controls.Add(this.txtPath1); + this.Controls.Add(this.label2); + this.Controls.Add(this.txtGIFPackets); + this.Controls.Add(this.lblGIFPackets); this.Controls.Add(this.lblWIP); this.Controls.Add(this.txtDumpSize); this.Controls.Add(this.lblDumpSize); @@ -445,6 +600,20 @@ private System.Windows.Forms.Label lblDumpSize; public System.Windows.Forms.Label txtDumpSize; private System.Windows.Forms.Label lblWIP; + public System.Windows.Forms.Label txtGIFPackets; + private System.Windows.Forms.Label lblGIFPackets; + public System.Windows.Forms.Label txtPath1; + private System.Windows.Forms.Label label2; + public System.Windows.Forms.Label txtPath2; + private System.Windows.Forms.Label label3; + public System.Windows.Forms.Label txtPath3; + private System.Windows.Forms.Label label5; + public System.Windows.Forms.Label txtVSync; + private System.Windows.Forms.Label label4; + public System.Windows.Forms.Label txtReadFifo; + private System.Windows.Forms.Label label7; + public System.Windows.Forms.Label txtRegisters; + private System.Windows.Forms.Label label6; } } diff --git a/tools/GSDumpGUI/Forms/frmMain.cs b/tools/GSDumpGUI/Forms/frmMain.cs index 143d882bcb..c3bd78f0ee 100644 --- a/tools/GSDumpGUI/Forms/frmMain.cs +++ b/tools/GSDumpGUI/Forms/frmMain.cs @@ -360,6 +360,9 @@ namespace GSDumpGUI TCPMessage msg = new TCPMessage(); msg.MessageType = MessageType.SizeDump; Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg); + msg = new TCPMessage(); + msg.MessageType = MessageType.Statistics; + Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg); } } } diff --git a/tools/GSDumpGUI/Library/GSDXWrapper.cs b/tools/GSDumpGUI/Library/GSDXWrapper.cs index b33cf0de31..9b4d16c731 100644 --- a/tools/GSDumpGUI/Library/GSDXWrapper.cs +++ b/tools/GSDumpGUI/Library/GSDXWrapper.cs @@ -7,6 +7,8 @@ using System.IO; namespace GSDumpGUI { public delegate void GSgifTransfer(IntPtr data, int size); + public delegate void GSgifTransfer2(IntPtr data, int size); + public delegate void GSgifTransfer3(IntPtr data, int size); public delegate void GSVSync(byte field); public delegate void GSreadFIFO2(IntPtr data, int size); public delegate void GSsetGameCRC(int crc, int options); @@ -24,6 +26,8 @@ namespace GSDumpGUI private GSConfigure gsConfigure; private PSEgetLibName PsegetLibName; private GSgifTransfer GSgifTransfer; + private GSgifTransfer2 GSgifTransfer2; + private GSgifTransfer3 GSgifTransfer3; private GSVSync GSVSync; private GSreadFIFO2 GSreadFIFO2; private GSsetGameCRC GSsetGameCRC; @@ -103,6 +107,8 @@ namespace GSDumpGUI IntPtr funcaddrConfig = NativeMethods.GetProcAddress(hmod, "GSconfigure"); IntPtr funcaddrGIF = NativeMethods.GetProcAddress(hmod, "GSgifTransfer"); + IntPtr funcaddrGIF2 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer2"); + IntPtr funcaddrGIF3 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer3"); IntPtr funcaddrVSync = NativeMethods.GetProcAddress(hmod, "GSvsync"); IntPtr funcaddrSetBaseMem = NativeMethods.GetProcAddress(hmod, "GSsetBaseMem"); IntPtr funcaddrOpen = NativeMethods.GetProcAddress(hmod, "GSopen"); @@ -117,6 +123,8 @@ namespace GSDumpGUI PsegetLibName = (PSEgetLibName)Marshal.GetDelegateForFunctionPointer(funcaddrLibName, typeof(PSEgetLibName)); this.GSgifTransfer = (GSgifTransfer)Marshal.GetDelegateForFunctionPointer(funcaddrGIF, typeof(GSgifTransfer)); + this.GSgifTransfer2 = (GSgifTransfer2)Marshal.GetDelegateForFunctionPointer(funcaddrGIF2, typeof(GSgifTransfer2)); + this.GSgifTransfer3 = (GSgifTransfer3)Marshal.GetDelegateForFunctionPointer(funcaddrGIF3, typeof(GSgifTransfer3)); this.GSVSync = (GSVSync)Marshal.GetDelegateForFunctionPointer(funcaddrVSync, typeof(GSVSync)); this.GSsetBaseMem = (GSsetBaseMem)Marshal.GetDelegateForFunctionPointer(funcaddrSetBaseMem, typeof(GSsetBaseMem)); this.GSopen = (GSopen)Marshal.GetDelegateForFunctionPointer(funcaddrOpen, typeof(GSopen)); @@ -188,36 +196,36 @@ namespace GSDumpGUI private unsafe void Step(GSData itm, byte* registers) { + /*"C:\Users\Alessio\Desktop\Plugins\Dll\gsdx-sse4-r3878.dll" "C:\Users\Alessio\Desktop\Plugins\Dumps\gsdx_20101219182059.gs" "GSReplay" 0*/ switch (itm.id) { case GSType.Transfer: switch (itm.data[0]) - {/* + { case 0: - byte[] data = new byte[16384]; - for (int i = 0; i < itm.data; i++) - { - - } - fixed (byte* gifdata = data) - { - GSgifTransfer1(new IntPtr(gifdata + 5), 16384 - size); - } - break;*/ - case 0: - case 1: - case 2: fixed (byte* gifdata = itm.data) { GSgifTransfer(new IntPtr(gifdata + 1), (itm.data.Length - 1) / 16); } - break;/* + break; + case 1: + fixed (byte* gifdata = itm.data) + { + GSgifTransfer(new IntPtr(gifdata + 1), (itm.data.Length - 1) /16); + } + break; case 2: fixed (byte* gifdata = itm.data) { - GSgifTransfer3(new IntPtr(gifdata + 1), (itm.data.Length - 1) / 16); + GSgifTransfer2(new IntPtr(gifdata + 1), (itm.data.Length - 1) /16); } - break;*/ + break; + case 3: + fixed (byte* gifdata = itm.data) + { + GSgifTransfer3(new IntPtr(gifdata + 1), (itm.data.Length - 1) /16); + } + break; } break; case GSType.VSync: @@ -226,7 +234,11 @@ namespace GSDumpGUI case GSType.ReadFIFO2: fixed (byte* FIFO = itm.data) { - GSreadFIFO2(new IntPtr(FIFO), itm.data.Length / 16); + byte[] arrnew = new byte[*((int*)FIFO)]; + fixed (byte* arrn = arrnew) + { + GSreadFIFO2(new IntPtr(arrn), *((int*)FIFO)); + } } break; case GSType.Registers: diff --git a/tools/GSDumpGUI/Library/GSDump/GSDump.cs b/tools/GSDumpGUI/Library/GSDump/GSDump.cs index 0fc7b8b101..81a4422362 100644 --- a/tools/GSDumpGUI/Library/GSDump/GSDump.cs +++ b/tools/GSDumpGUI/Library/GSDump/GSDump.cs @@ -65,11 +65,13 @@ namespace GSDumpGUI break; case GSType.ReadFIFO2: Int32 sF = br.ReadInt32(); - data.data = br.ReadBytes(sF); + data.data = BitConverter.GetBytes(sF); break; case GSType.Registers: data.data = br.ReadBytes(8192); break; + default: + break; } dmp.Data.Add(data); } diff --git a/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs b/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs index 0dc5d4facc..ce4c762b11 100644 --- a/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs +++ b/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs @@ -109,6 +109,7 @@ namespace TCPLibrary.MessageBased.Core { Connect, MaxUsers, - SizeDump + SizeDump, + Statistics } } From 02818b0304e8a63b6560b405af87658168f489ec Mon Sep 17 00:00:00 2001 From: sudonim1 Date: Mon, 20 Dec 2010 07:14:18 +0000 Subject: [PATCH 14/33] GSDx: fixed incorrect use of CComPtr that would leave a dangling reference in the settings dialog code (only affects old pcsx2 versions and wouldn't be a significant resource leak even there) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4110 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSSettingsDlg.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/GSdx/GSSettingsDlg.cpp b/plugins/GSdx/GSSettingsDlg.cpp index 5b8bafbc34..5ce3bda7f1 100644 --- a/plugins/GSdx/GSSettingsDlg.cpp +++ b/plugins/GSdx/GSSettingsDlg.cpp @@ -85,7 +85,9 @@ void GSSettingsDlg::OnInit() ComboBoxAppend(IDC_RESOLUTION, "Please select...", (LPARAM)&m_modes.back(), true); - if(CComPtr d3d = Direct3DCreate9(D3D_SDK_VERSION)) + CComPtr d3d; + d3d.Attach(Direct3DCreate9(D3D_SDK_VERSION)); + if(d3d) { uint32 w = theApp.GetConfig("ModeWidth", 0); uint32 h = theApp.GetConfig("ModeHeight", 0); From 9c9e2b8c51f0b9bb035cc9f2b551095d1f5066cf Mon Sep 17 00:00:00 2001 From: "feal87@gmail.com" Date: Mon, 20 Dec 2010 13:42:53 +0000 Subject: [PATCH 15/33] Little change to the function called. (Shouldn't do any kind of difference) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4111 96395faa-99c1-11dd-bbfe-3dabce05a288 --- tools/GSDumpGUI/Library/GSDXWrapper.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/GSDumpGUI/Library/GSDXWrapper.cs b/tools/GSDumpGUI/Library/GSDXWrapper.cs index 9b4d16c731..81816da485 100644 --- a/tools/GSDumpGUI/Library/GSDXWrapper.cs +++ b/tools/GSDumpGUI/Library/GSDXWrapper.cs @@ -211,19 +211,19 @@ namespace GSDumpGUI case 1: fixed (byte* gifdata = itm.data) { - GSgifTransfer(new IntPtr(gifdata + 1), (itm.data.Length - 1) /16); + GSgifTransfer2(new IntPtr(gifdata + 1), (itm.data.Length - 1) /16); } break; case 2: fixed (byte* gifdata = itm.data) { - GSgifTransfer2(new IntPtr(gifdata + 1), (itm.data.Length - 1) /16); + GSgifTransfer3(new IntPtr(gifdata + 1), (itm.data.Length - 1) /16); } break; case 3: fixed (byte* gifdata = itm.data) { - GSgifTransfer3(new IntPtr(gifdata + 1), (itm.data.Length - 1) /16); + GSgifTransfer(new IntPtr(gifdata + 1), (itm.data.Length - 1) /16); } break; } From 39780dcc10d370df78ccfe515f6f987ac27677f9 Mon Sep 17 00:00:00 2001 From: "feal87@gmail.com" Date: Mon, 20 Dec 2010 16:28:59 +0000 Subject: [PATCH 16/33] Modified a little the code to be more modular. Should not change the behaviour. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4112 96395faa-99c1-11dd-bbfe-3dabce05a288 --- tools/GSDumpGUI/GSDumpGUI.csproj | 3 +- tools/GSDumpGUI/Library/GSDXWrapper.cs | 18 +++++------ .../Library/GSDump/{ => GSData}/GSData.cs | 0 .../Library/GSDump/GSData/GSTransfer.cs | 19 ++++++++++++ tools/GSDumpGUI/Library/GSDump/GSDump.cs | 30 +++++++++++++------ 5 files changed, 51 insertions(+), 19 deletions(-) rename tools/GSDumpGUI/Library/GSDump/{ => GSData}/GSData.cs (100%) create mode 100644 tools/GSDumpGUI/Library/GSDump/GSData/GSTransfer.cs diff --git a/tools/GSDumpGUI/GSDumpGUI.csproj b/tools/GSDumpGUI/GSDumpGUI.csproj index 6ff75d0ab1..61dee5e6a7 100644 --- a/tools/GSDumpGUI/GSDumpGUI.csproj +++ b/tools/GSDumpGUI/GSDumpGUI.csproj @@ -55,8 +55,9 @@ frmMain.cs - + + diff --git a/tools/GSDumpGUI/Library/GSDXWrapper.cs b/tools/GSDumpGUI/Library/GSDXWrapper.cs index 81816da485..1778fb0e56 100644 --- a/tools/GSDumpGUI/Library/GSDXWrapper.cs +++ b/tools/GSDumpGUI/Library/GSDXWrapper.cs @@ -200,30 +200,30 @@ namespace GSDumpGUI switch (itm.id) { case GSType.Transfer: - switch (itm.data[0]) + switch (((GSTransfer)itm).Path) { - case 0: + case GSTransferPath.Path1Old: fixed (byte* gifdata = itm.data) { - GSgifTransfer(new IntPtr(gifdata + 1), (itm.data.Length - 1) / 16); + GSgifTransfer(new IntPtr(gifdata), (itm.data.Length) / 16); } break; - case 1: + case GSTransferPath.Path2: fixed (byte* gifdata = itm.data) { - GSgifTransfer2(new IntPtr(gifdata + 1), (itm.data.Length - 1) /16); + GSgifTransfer2(new IntPtr(gifdata), (itm.data.Length) /16); } break; - case 2: + case GSTransferPath.Path3: fixed (byte* gifdata = itm.data) { - GSgifTransfer3(new IntPtr(gifdata + 1), (itm.data.Length - 1) /16); + GSgifTransfer3(new IntPtr(gifdata), (itm.data.Length) /16); } break; - case 3: + case GSTransferPath.Path1New: fixed (byte* gifdata = itm.data) { - GSgifTransfer(new IntPtr(gifdata + 1), (itm.data.Length - 1) /16); + GSgifTransfer(new IntPtr(gifdata), (itm.data.Length) /16); } break; } diff --git a/tools/GSDumpGUI/Library/GSDump/GSData.cs b/tools/GSDumpGUI/Library/GSDump/GSData/GSData.cs similarity index 100% rename from tools/GSDumpGUI/Library/GSDump/GSData.cs rename to tools/GSDumpGUI/Library/GSDump/GSData/GSData.cs diff --git a/tools/GSDumpGUI/Library/GSDump/GSData/GSTransfer.cs b/tools/GSDumpGUI/Library/GSDump/GSData/GSTransfer.cs new file mode 100644 index 0000000000..3abc07d993 --- /dev/null +++ b/tools/GSDumpGUI/Library/GSDump/GSData/GSTransfer.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace GSDumpGUI +{ + public class GSTransfer : GSData + { + public GSTransferPath Path; + } + + public enum GSTransferPath + { + Path1Old = 0, + Path2 = 1, + Path3 = 2, + Path1New = 3 + } +} diff --git a/tools/GSDumpGUI/Library/GSDump/GSDump.cs b/tools/GSDumpGUI/Library/GSDump/GSDump.cs index 81a4422362..c5130e56c7 100644 --- a/tools/GSDumpGUI/Library/GSDump/GSDump.cs +++ b/tools/GSDumpGUI/Library/GSDump/GSDump.cs @@ -46,34 +46,46 @@ namespace GSDumpGUI while (br.PeekChar() != -1) { - GSData data = new GSData(); - data.id = (GSType)br.ReadByte(); - - switch (data.id) + GSType id = (GSType)br.ReadByte(); + switch (id) { case GSType.Transfer: + GSTransfer data = new GSTransfer(); + byte index = br.ReadByte(); + + data.id = id; + data.Path = (GSTransferPath)index; + Int32 size = br.ReadInt32(); List Data = new List(); - Data.Add(index); Data.AddRange(br.ReadBytes(size)); data.data = Data.ToArray(); + dmp.Data.Add(data); break; case GSType.VSync: - data.data = br.ReadBytes(1); + GSData dataV = new GSData(); + dataV.id = id; + dataV.data = br.ReadBytes(1); + dmp.Data.Add(dataV); break; case GSType.ReadFIFO2: + GSData dataR = new GSData(); + dataR.id = id; Int32 sF = br.ReadInt32(); - data.data = BitConverter.GetBytes(sF); + dataR.data = BitConverter.GetBytes(sF); + dmp.Data.Add(dataR); break; case GSType.Registers: - data.data = br.ReadBytes(8192); + GSData dataRR = new GSData(); + dataRR.id = id; + dataRR.data = br.ReadBytes(8192); + dmp.Data.Add(dataRR); break; default: break; } - dmp.Data.Add(data); } br.Close(); From 6a96e46920776e1697feb2f52c07320f835634a5 Mon Sep 17 00:00:00 2001 From: "gregory.hainaut@gmail.com" Date: Mon, 20 Dec 2010 19:57:50 +0000 Subject: [PATCH 17/33] zzogl: * increase a little the hack window (better for screenshot, not too big for small screen) * Use generic clut function in FlushDecodeClut * Various clean and comment git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4113 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/zzogl-pg/opengl/Linux/Linux.cpp | 3 +- plugins/zzogl-pg/opengl/ZZoglCreate.cpp | 2 +- plugins/zzogl-pg/opengl/ZZoglFlush.cpp | 57 ++------- plugins/zzogl-pg/opengl/ZZoglShoots.cpp | 10 +- plugins/zzogl-pg/opengl/targets.cpp | 149 ++++++++++++------------ 5 files changed, 93 insertions(+), 128 deletions(-) diff --git a/plugins/zzogl-pg/opengl/Linux/Linux.cpp b/plugins/zzogl-pg/opengl/Linux/Linux.cpp index df1e87f63c..cddd200b23 100644 --- a/plugins/zzogl-pg/opengl/Linux/Linux.cpp +++ b/plugins/zzogl-pg/opengl/Linux/Linux.cpp @@ -234,7 +234,8 @@ void DisplayAdvancedDialog() dialog = gtk_dialog_new(); gtk_window_set_title(GTK_WINDOW(dialog), "ZZOgl PG Advanced Config"); - gtk_window_set_default_size(GTK_WINDOW(dialog), 600, 600); + // A good value for the heigh will be 1000 instead of 800 but I'm afraid that some people still uses small screen... + gtk_window_set_default_size(GTK_WINDOW(dialog), 600, 800); gtk_window_set_modal(GTK_WINDOW(dialog), true); advanced_box = gtk_vbox_new(false, 5); diff --git a/plugins/zzogl-pg/opengl/ZZoglCreate.cpp b/plugins/zzogl-pg/opengl/ZZoglCreate.cpp index 2107c41b4b..279986e93f 100644 --- a/plugins/zzogl-pg/opengl/ZZoglCreate.cpp +++ b/plugins/zzogl-pg/opengl/ZZoglCreate.cpp @@ -188,7 +188,7 @@ inline bool CreateImportantCheck() if (!IsGLExt("GL_EXT_framebuffer_object")) { - ZZLog::Error_Log("*********\nZZogl: ERROR: Need GL_EXT_framebufer_object for multiple render targets\nZZogl: *********"); + ZZLog::Error_Log("*********\nZZogl: ERROR: Need GL_EXT_framebuffer_object for multiple render targets\nZZogl: *********"); bSuccess = false; } diff --git a/plugins/zzogl-pg/opengl/ZZoglFlush.cpp b/plugins/zzogl-pg/opengl/ZZoglFlush.cpp index 731f0fcadc..0c7b888a5f 100644 --- a/plugins/zzogl-pg/opengl/ZZoglFlush.cpp +++ b/plugins/zzogl-pg/opengl/ZZoglFlush.cpp @@ -26,6 +26,7 @@ #include "targets.h" #include "ZZoglFlushHack.h" #include "ZZoglShaders.h" +#include "ZZClut.h" #include //------------------ Defines @@ -337,14 +338,9 @@ inline void VisualBufferMessage(int context) curvb.tex0.th, curvb.tex0.tcc, curvb.tex0.tfx, curvb.tex0.cbp, curvb.tex0.cpsm, curvb.tex0.csm, curvb.tex0.csa, curvb.tex0.cld); char* Name; -// if (g_bSaveTex) { -// if (g_bSaveTex == 1) Name = NamedSaveTex(&curvb.tex0, 1); -// else -// Name = NamedSaveTex(&curvb.tex0, 0); ZZLog::Error_Log("TGA name '%s'.", Name); free(Name); -// } ZZLog::Debug_Log("buffer %ld.\n", BufferNumber); #endif } @@ -730,57 +726,19 @@ inline void FlushDecodeClut(VB& curvb, GLuint& ptexclut) if (ptexclut != 0) { - - int nClutOffset = 0, clutsize; + int clutsize; int entries = PSMT_IS8CLUT(curvb.tex0.psm) ? 256 : 16; if (curvb.tex0.csm && curvb.tex0.csa) ZZLog::Debug_Log("ERROR, csm1."); - if (PSMT_IS32BIT(curvb.tex0.cpsm)) // 32 bit - { - nClutOffset = 64 * curvb.tex0.csa; + if (PSMT_IS32BIT(curvb.tex0.cpsm)) { clutsize = min(entries, 256 - curvb.tex0.csa * 16) * 4; - } - else - { - nClutOffset = 64 * (curvb.tex0.csa & 15) + (curvb.tex0.csa >= 16 ? 2 : 0); + ClutBuffer_to_Array((u32*)&data[0], curvb.tex0.csa, clutsize); + } else { clutsize = min(entries, 512 - curvb.tex0.csa * 16) * 2; - } - - if (PSMT_IS32BIT(curvb.tex0.cpsm)) // 32 bit - { - memcpy_amd(&data[0], g_pbyGSClut + nClutOffset, clutsize); - } - else - { - u16* pClutBuffer = (u16*)(g_pbyGSClut + nClutOffset); - u16* pclut = (u16*) & data[0]; - int left = ((u32)nClutOffset & 2) ? 0 : ((nClutOffset & 0x3ff) / 2) + clutsize - 512; - - if (left > 0) clutsize -= left; - - while (clutsize > 0) - { - pclut[0] = pClutBuffer[0]; - pclut++; - pClutBuffer += 2; - clutsize -= 2; - } - - if (left > 0) - { - pClutBuffer = (u16*)(g_pbyGSClut + 2); - - while (left > 0) - { - pclut[0] = pClutBuffer[0]; - left -= 2; - pClutBuffer += 2; - pclut++; - } - } - } + ClutBuffer_to_Array((u16*)&data[0], curvb.tex0.csa, clutsize); + } GLenum tempType = PSMT_ISHALF_STORAGE(curvb.tex0) ? GL_UNSIGNED_SHORT_5_5_5_1 : GL_UNSIGNED_BYTE; Texture2D(4, 256, 1, GL_RGBA, tempType, &data[0]); @@ -987,6 +945,7 @@ inline FRAGMENTSHADER* FlushMadeNewTarget(VB& curvb, int exactcolor, int context // save the texture if (g_bSaveTex) { + // FIXME: I suspect one of g_bSaveTex test variable is wrong if (g_bSaveTex == 1) { SaveTex(&curvb.tex0, 1); diff --git a/plugins/zzogl-pg/opengl/ZZoglShoots.cpp b/plugins/zzogl-pg/opengl/ZZoglShoots.cpp index 7455f0fd6e..eb174e9ef0 100644 --- a/plugins/zzogl-pg/opengl/ZZoglShoots.cpp +++ b/plugins/zzogl-pg/opengl/ZZoglShoots.cpp @@ -395,6 +395,8 @@ SaveTex(tex0Info* ptex, int usevid) glBindTexture(GL_TEXTURE_RECTANGLE_NV, pmemtarg->ptex->tex); srcdata.resize(4 * pmemtarg->texW * pmemtarg->texH); + // FIXME strangely this function call seem to crash pcsx2 on atelier of iris 1 + // Note: fmt is GL_UNSIGNED_SHORT_1_5_5_5_REV glGetTexImage(GL_TEXTURE_RECTANGLE_NV, 0, GL_RGBA, pmemtarg->fmt, &srcdata[0]); u32 offset = MemorySize(pmemtarg->realy); @@ -613,6 +615,9 @@ SaveTex(tex0Info* ptex, int usevid) snprintf(Name, TGA_FILE_NAME_MAX_LENGTH, "Tex.%d.tga", TexNumber); SaveTGA(Name, ptex->tw, ptex->th, &data[0]); + + TexNumber++; + if (TexNumber > MAX_NUMBER_SAVED_TGA) TexNumber = 0; } @@ -621,13 +626,10 @@ SaveTex(tex0Info* ptex, int usevid) char* NamedSaveTex(tex0Info* ptex, int usevid) { SaveTex(ptex, usevid); + char* Name = (char*)malloc(TGA_FILE_NAME_MAX_LENGTH); snprintf(Name, TGA_FILE_NAME_MAX_LENGTH, "Tex.%d.tga", TexNumber); - TexNumber++; - - if (TexNumber > MAX_NUMBER_SAVED_TGA) TexNumber = 0; - return Name; } diff --git a/plugins/zzogl-pg/opengl/targets.cpp b/plugins/zzogl-pg/opengl/targets.cpp index b956b4cea5..8b134a72ef 100644 --- a/plugins/zzogl-pg/opengl/targets.cpp +++ b/plugins/zzogl-pg/opengl/targets.cpp @@ -475,6 +475,9 @@ void CRenderTarget::Update(int context, CRenderTarget* pdepth) texframe.tw = fbw; texframe.th = fbh; texframe.psm = psm; + // FIXME some field are not initialized... + // in particular the clut related one + assert(!PSMT_ISCLUT(psm)); // write color and zero out stencil buf, always 0 context! // force bilinear if using AA @@ -966,6 +969,9 @@ void CDepthTarget::Update(int context, CRenderTarget* prndr) texframe.tw = fbw; texframe.th = fbh; texframe.psm = psm; + // FIXME some field are not initialized... + // in particular the clut related one + assert(!PSMT_ISCLUT(psm)); DisableAllgl(); @@ -2017,96 +2023,93 @@ CMemoryTarget* CMemoryTargetMngr::GetMemoryTarget(const tex0Info& tex0, int forc assert(targ->clutsize > 0); } - else - { - if (tex0.psm == PSMT16Z || tex0.psm == PSMT16SZ) - { - ptexdata = (u8*)_aligned_malloc(4 * targ->texH * targ->texW, 16); - has_data = true; + else if (tex0.psm == PSMT16Z || tex0.psm == PSMT16SZ) + { + ptexdata = (u8*)_aligned_malloc(4 * targ->texH * targ->texW, 16); + has_data = true; - // needs to be 8 bit, use xmm for unpacking - u16* dst = (u16*)ptexdata; - u16* src = (u16*)(MemoryAddress(targ->realy)); + // needs to be 8 bit, use xmm for unpacking + u16* dst = (u16*)ptexdata; + u16* src = (u16*)(MemoryAddress(targ->realy)); #ifdef ZEROGS_SSE2 - assert(((u32)(uptr)dst) % 16 == 0); - // FIXME Uncomment to test intrinsic versions (instead of asm) - // perf improvement vs asm: - // 1/ gcc updates both pointer with 1 addition - // 2/ Bypass the cache for the store + assert(((u32)(uptr)dst) % 16 == 0); + // FIXME Uncomment to test intrinsic versions (instead of asm) + // perf improvement vs asm: + // 1/ gcc updates both pointer with 1 addition + // 2/ Bypass the cache for the store #define NEW_INTRINSIC_VERSION #ifdef NEW_INTRINSIC_VERSION - __m128i zero_128 = _mm_setzero_si128(); - // NOTE: future performance improvement - // SSE4.1 support uncacheable load 128bits. Maybe it can - // avoid some cache pollution - // NOTE2: I create multiple _n variable to mimic the previous ASM behavior - // but I'm not sure there are real gains. - for (int i = targ->height * GPU_TEXWIDTH/16 ; i > 0 ; --i) - { - // Convert 16 bits pixels to 32bits (zero extended) - // Batch 64 bytes (32 pixels) at once. - __m128i pixels_1 = _mm_load_si128((__m128i*)src); - __m128i pixels_2 = _mm_load_si128((__m128i*)(src+8)); - __m128i pixels_3 = _mm_load_si128((__m128i*)(src+16)); - __m128i pixels_4 = _mm_load_si128((__m128i*)(src+24)); + __m128i zero_128 = _mm_setzero_si128(); + // NOTE: future performance improvement + // SSE4.1 support uncacheable load 128bits. Maybe it can + // avoid some cache pollution + // NOTE2: I create multiple _n variable to mimic the previous ASM behavior + // but I'm not sure there are real gains. + for (int i = targ->height * GPU_TEXWIDTH/16 ; i > 0 ; --i) + { + // Convert 16 bits pixels to 32bits (zero extended) + // Batch 64 bytes (32 pixels) at once. + __m128i pixels_1 = _mm_load_si128((__m128i*)src); + __m128i pixels_2 = _mm_load_si128((__m128i*)(src+8)); + __m128i pixels_3 = _mm_load_si128((__m128i*)(src+16)); + __m128i pixels_4 = _mm_load_si128((__m128i*)(src+24)); - __m128i pix_low_1 = _mm_unpacklo_epi16(pixels_1, zero_128); - __m128i pix_high_1 = _mm_unpackhi_epi16(pixels_1, zero_128); - __m128i pix_low_2 = _mm_unpacklo_epi16(pixels_2, zero_128); - __m128i pix_high_2 = _mm_unpackhi_epi16(pixels_2, zero_128); + __m128i pix_low_1 = _mm_unpacklo_epi16(pixels_1, zero_128); + __m128i pix_high_1 = _mm_unpackhi_epi16(pixels_1, zero_128); + __m128i pix_low_2 = _mm_unpacklo_epi16(pixels_2, zero_128); + __m128i pix_high_2 = _mm_unpackhi_epi16(pixels_2, zero_128); - // Note: bypass cache - _mm_stream_si128((__m128i*)dst, pix_low_1); - _mm_stream_si128((__m128i*)(dst+8), pix_high_1); - _mm_stream_si128((__m128i*)(dst+16), pix_low_2); - _mm_stream_si128((__m128i*)(dst+24), pix_high_2); + // Note: bypass cache + _mm_stream_si128((__m128i*)dst, pix_low_1); + _mm_stream_si128((__m128i*)(dst+8), pix_high_1); + _mm_stream_si128((__m128i*)(dst+16), pix_low_2); + _mm_stream_si128((__m128i*)(dst+24), pix_high_2); - __m128i pix_low_3 = _mm_unpacklo_epi16(pixels_3, zero_128); - __m128i pix_high_3 = _mm_unpackhi_epi16(pixels_3, zero_128); - __m128i pix_low_4 = _mm_unpacklo_epi16(pixels_4, zero_128); - __m128i pix_high_4 = _mm_unpackhi_epi16(pixels_4, zero_128); + __m128i pix_low_3 = _mm_unpacklo_epi16(pixels_3, zero_128); + __m128i pix_high_3 = _mm_unpackhi_epi16(pixels_3, zero_128); + __m128i pix_low_4 = _mm_unpacklo_epi16(pixels_4, zero_128); + __m128i pix_high_4 = _mm_unpackhi_epi16(pixels_4, zero_128); - // Note: bypass cache - _mm_stream_si128((__m128i*)(dst+32), pix_low_3); - _mm_stream_si128((__m128i*)(dst+40), pix_high_3); - _mm_stream_si128((__m128i*)(dst+48), pix_low_4); - _mm_stream_si128((__m128i*)(dst+56), pix_high_4); + // Note: bypass cache + _mm_stream_si128((__m128i*)(dst+32), pix_low_3); + _mm_stream_si128((__m128i*)(dst+40), pix_high_3); + _mm_stream_si128((__m128i*)(dst+48), pix_low_4); + _mm_stream_si128((__m128i*)(dst+56), pix_high_4); - src += 32; - dst += 64; - } - // It is advise to use a fence instruction after non temporal move (mm_stream) instruction... - // store fence insures that previous store are finish before execute new one. - _mm_sfence(); + src += 32; + dst += 64; + } + // It is advise to use a fence instruction after non temporal move (mm_stream) instruction... + // store fence insures that previous store are finish before execute new one. + _mm_sfence(); #else - SSE2_UnswizzleZ16Target(dst, src, targ->height * GPU_TEXWIDTH / 16); + SSE2_UnswizzleZ16Target(dst, src, targ->height * GPU_TEXWIDTH / 16); #endif #else // ZEROGS_SSE2 - for (int i = 0; i < targ->height; ++i) - { - for (int j = 0; j < GPU_TEXWIDTH; ++j) - { - dst[0] = src[0]; - dst[1] = 0; - dst[2] = src[1]; - dst[3] = 0; - dst += 4; - src += 2; - } - } + for (int i = 0; i < targ->height; ++i) + { + for (int j = 0; j < GPU_TEXWIDTH; ++j) + { + dst[0] = src[0]; + dst[1] = 0; + dst[2] = src[1]; + dst[3] = 0; + dst += 4; + src += 2; + } + } #endif // ZEROGS_SSE2 - } - else - { - ptexdata = targ->ptex->memptr; - // We really don't want to deallocate memptr. As a reminder... - has_data = false; - } - } + } + else + { + ptexdata = targ->ptex->memptr; + // We really don't want to deallocate memptr. As a reminder... + has_data = false; + } // create the texture GL_REPORT_ERRORD(); From 402a52bbc6d87c14e69ab996ebd022dc6e41ff48 Mon Sep 17 00:00:00 2001 From: ramapcsx2 Date: Mon, 20 Dec 2010 21:36:06 +0000 Subject: [PATCH 18/33] Small fix to logging. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4114 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/IPU/mpeg2lib/Mpeg.cpp | 1 + pcsx2/ps2/eeHwTraceLog.inl | 1 + 2 files changed, 2 insertions(+) diff --git a/pcsx2/IPU/mpeg2lib/Mpeg.cpp b/pcsx2/IPU/mpeg2lib/Mpeg.cpp index 62d4805c7d..72ba1af9b6 100644 --- a/pcsx2/IPU/mpeg2lib/Mpeg.cpp +++ b/pcsx2/IPU/mpeg2lib/Mpeg.cpp @@ -161,6 +161,7 @@ intra: macroblock_modes = GETBITS(1); //I suspect (as this is actually a 2 bit command) that this should be getbits(2) //additionally, we arent dumping any bits here when i think we should be, need a game to test. (Refraction) + DevCon.Warning(" Rare MPEG command! "); if (macroblock_modes == 0) return 0; // error return (MACROBLOCK_INTRA | (1 << 16)); diff --git a/pcsx2/ps2/eeHwTraceLog.inl b/pcsx2/ps2/eeHwTraceLog.inl index 4ac1f14c5e..c4e904accd 100644 --- a/pcsx2/ps2/eeHwTraceLog.inl +++ b/pcsx2/ps2/eeHwTraceLog.inl @@ -166,6 +166,7 @@ static __ri const char* _eelog_GetHwName( u32 addr, T val ) EasyCase(SIF1_CHCR); EasyCase(SIF1_MADR); EasyCase(SIF1_QWC); + EasyCase(SIF1_TADR); EasyCase(SIF2_CHCR); EasyCase(SIF2_MADR); From 3038ccafb9e75c477ef26c07e57393aebe5c8dd2 Mon Sep 17 00:00:00 2001 From: "feal87@gmail.com" Date: Tue, 21 Dec 2010 07:29:33 +0000 Subject: [PATCH 19/33] 1) Resolved the problem with the GSFreeze. Now the states are loaded and reproduced correctly. 2) Put an error message when trying to load old savestates not compatible. 3) Added a clone function for dump. (may be useful later on) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4115 96395faa-99c1-11dd-bbfe-3dabce05a288 --- tools/GSDumpGUI/Core/Program.cs | 16 +++++ tools/GSDumpGUI/Library/GSDXWrapper.cs | 60 +++++++++++++------ tools/GSDumpGUI/Library/GSDump/GSDump.cs | 40 ++++++++++++- .../Library/TCPLibrary/Message/TCPMessage.cs | 3 +- 4 files changed, 98 insertions(+), 21 deletions(-) diff --git a/tools/GSDumpGUI/Core/Program.cs b/tools/GSDumpGUI/Core/Program.cs index 010502aafa..9d2063b366 100644 --- a/tools/GSDumpGUI/Core/Program.cs +++ b/tools/GSDumpGUI/Core/Program.cs @@ -79,6 +79,16 @@ namespace GSDumpGUI wrap.GSConfig(); wrap.Unload(); + if (GSDXWrapper.DumpTooOld) + { + if (Client != null) + { + TCPMessage msg = new TCPMessage(); + msg.MessageType = MessageType.StateOld; + Client.Send(msg); + } + } + if (Client != null) Client.Disconnect(); } @@ -134,6 +144,12 @@ namespace GSDumpGUI frmMain.txtRegisters.Text = ((int)Mess.Parameters[6]).ToString(); }), new object[] { null }); break; + case MessageType.StateOld: + frmMain.Invoke(new Action(delegate(object e) + { + MessageBox.Show("Savestate too old to be read. :(", "Warning"); + }), new object[] { null }); + break; default: break; } diff --git a/tools/GSDumpGUI/Library/GSDXWrapper.cs b/tools/GSDumpGUI/Library/GSDXWrapper.cs index 1778fb0e56..8976c9cc71 100644 --- a/tools/GSDumpGUI/Library/GSDXWrapper.cs +++ b/tools/GSDumpGUI/Library/GSDXWrapper.cs @@ -7,12 +7,13 @@ using System.IO; namespace GSDumpGUI { public delegate void GSgifTransfer(IntPtr data, int size); + public delegate void GSgifTransfer1(IntPtr data, int size); public delegate void GSgifTransfer2(IntPtr data, int size); public delegate void GSgifTransfer3(IntPtr data, int size); public delegate void GSVSync(byte field); public delegate void GSreadFIFO2(IntPtr data, int size); public delegate void GSsetGameCRC(int crc, int options); - public delegate void GSfreeze(int mode, IntPtr data); + public delegate int GSfreeze(int mode, IntPtr data); public delegate void GSopen(IntPtr hwnd, String Title, int renderer); public delegate void GSclose(); public delegate void GSshutdown(); @@ -23,9 +24,12 @@ namespace GSDumpGUI public class GSDXWrapper { + static public bool DumpTooOld = false; + private GSConfigure gsConfigure; private PSEgetLibName PsegetLibName; private GSgifTransfer GSgifTransfer; + private GSgifTransfer1 GSgifTransfer1; private GSgifTransfer2 GSgifTransfer2; private GSgifTransfer3 GSgifTransfer3; private GSVSync GSVSync; @@ -107,6 +111,7 @@ namespace GSDumpGUI IntPtr funcaddrConfig = NativeMethods.GetProcAddress(hmod, "GSconfigure"); IntPtr funcaddrGIF = NativeMethods.GetProcAddress(hmod, "GSgifTransfer"); + IntPtr funcaddrGIF1 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer1"); IntPtr funcaddrGIF2 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer2"); IntPtr funcaddrGIF3 = NativeMethods.GetProcAddress(hmod, "GSgifTransfer3"); IntPtr funcaddrVSync = NativeMethods.GetProcAddress(hmod, "GSvsync"); @@ -123,6 +128,7 @@ namespace GSDumpGUI PsegetLibName = (PSEgetLibName)Marshal.GetDelegateForFunctionPointer(funcaddrLibName, typeof(PSEgetLibName)); this.GSgifTransfer = (GSgifTransfer)Marshal.GetDelegateForFunctionPointer(funcaddrGIF, typeof(GSgifTransfer)); + this.GSgifTransfer1 = (GSgifTransfer1)Marshal.GetDelegateForFunctionPointer(funcaddrGIF1, typeof(GSgifTransfer1)); this.GSgifTransfer2 = (GSgifTransfer2)Marshal.GetDelegateForFunctionPointer(funcaddrGIF2, typeof(GSgifTransfer2)); this.GSgifTransfer3 = (GSgifTransfer3)Marshal.GetDelegateForFunctionPointer(funcaddrGIF3, typeof(GSgifTransfer3)); this.GSVSync = (GSVSync)Marshal.GetDelegateForFunctionPointer(funcaddrVSync, typeof(GSVSync)); @@ -172,24 +178,37 @@ namespace GSDumpGUI GSsetGameCRC(dump.CRC, 0); fixed (byte* freeze = dump.StateData) { - GSfreeze(0, new IntPtr(freeze)); - GSVSync(1); + byte[] GSFreez = new byte[8]; + Array.Copy(BitConverter.GetBytes(dump.StateData.Length), 0, GSFreez, 0, 4); + Array.Copy(BitConverter.GetBytes(new IntPtr(freeze).ToInt32()), 0, GSFreez, 4, 4); - while (Running) + fixed (byte* fr = GSFreez) { - if (!NativeMethods.IsWindowVisible(new IntPtr(HWND))) + int ris = GSfreeze(0, new IntPtr(fr)); + if (ris == -1) { - Running = false; - break; + DumpTooOld = true; + return; } - foreach (var itm in dump.Data) - { - Step(itm, pointer); - } - } + GSVSync(1); - GSclose(); - GSshutdown(); + while (Running) + { + if (!NativeMethods.IsWindowVisible(new IntPtr(HWND))) + { + Running = false; + break; + } + foreach (var itm in dump.Data) + { + Step(itm, pointer); + } + + } + + GSclose(); + GSshutdown(); + } } } } @@ -203,27 +222,30 @@ namespace GSDumpGUI switch (((GSTransfer)itm).Path) { case GSTransferPath.Path1Old: - fixed (byte* gifdata = itm.data) + byte[] data = new byte[16384]; + int addr = 16384 - itm.data.Length; + Array.Copy(itm.data, 0, data, addr, itm.data.Length); + fixed (byte* gifdata = data) { - GSgifTransfer(new IntPtr(gifdata), (itm.data.Length) / 16); + GSgifTransfer1(new IntPtr(gifdata), addr); } break; case GSTransferPath.Path2: fixed (byte* gifdata = itm.data) { - GSgifTransfer2(new IntPtr(gifdata), (itm.data.Length) /16); + GSgifTransfer2(new IntPtr(gifdata), (itm.data.Length) / 16); } break; case GSTransferPath.Path3: fixed (byte* gifdata = itm.data) { - GSgifTransfer3(new IntPtr(gifdata), (itm.data.Length) /16); + GSgifTransfer3(new IntPtr(gifdata), (itm.data.Length) / 16); } break; case GSTransferPath.Path1New: fixed (byte* gifdata = itm.data) { - GSgifTransfer(new IntPtr(gifdata), (itm.data.Length) /16); + GSgifTransfer(new IntPtr(gifdata), (itm.data.Length) / 16); } break; } diff --git a/tools/GSDumpGUI/Library/GSDump/GSDump.cs b/tools/GSDumpGUI/Library/GSDump/GSDump.cs index c5130e56c7..b1a4a064a6 100644 --- a/tools/GSDumpGUI/Library/GSDump/GSDump.cs +++ b/tools/GSDumpGUI/Library/GSDump/GSDump.cs @@ -8,6 +8,7 @@ namespace GSDumpGUI public class GSDump { public Int32 CRC; + public byte[] GSFreeze; public byte[] StateData; public byte[] Registers; // 8192 bytes @@ -34,14 +35,51 @@ namespace GSDumpGUI Data = new List(); } + public GSDump Clone() + { + GSDump newDump = new GSDump(); + newDump.CRC = this.CRC; + + byte[] state = new byte[StateData.Length]; + Array.Copy(StateData,state, StateData.Length); + newDump.StateData = state; + + newDump.Registers = new byte[8192]; + Array.Copy(this.Registers, newDump.Registers, 8192); + + foreach (var itm in this.Data) + { + if (itm.GetType().IsInstanceOfType(typeof(GSTransfer))) + { + GSTransfer gt = new GSTransfer(); + gt.id = itm.id; + gt.Path = ((GSTransfer)itm).Path; + gt.data = new byte[itm.data.Length]; + Array.Copy(itm.data, gt.data, itm.data.Length); + newDump.Data.Add(gt); + } + else + { + GSData gt = new GSData(); + gt.id = itm.id; + gt.data = new byte[itm.data.Length]; + Array.Copy(itm.data, gt.data, itm.data.Length); + newDump.Data.Add(gt); + } + } + return newDump; + } + static public GSDump LoadDump(String FileName) { GSDump dmp = new GSDump(); BinaryReader br = new BinaryReader(System.IO.File.Open(FileName, FileMode.Open)); dmp.CRC = br.ReadInt32(); + Int32 ss = br.ReadInt32(); - dmp.StateData = br.ReadBytes(ss); + dmp.StateData = br.ReadBytes(ss); + dmp.Registers = br.ReadBytes(8192); while (br.PeekChar() != -1) diff --git a/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs b/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs index ce4c762b11..dc0512e732 100644 --- a/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs +++ b/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs @@ -110,6 +110,7 @@ namespace TCPLibrary.MessageBased.Core Connect, MaxUsers, SizeDump, - Statistics + Statistics, + StateOld } } From 0c32038480b3a9513d8c1d94c6ce0de51d99e388 Mon Sep 17 00:00:00 2001 From: "feal87@gmail.com" Date: Tue, 21 Dec 2010 07:42:45 +0000 Subject: [PATCH 20/33] Reactivated the overrides modifying manually directly the inis. Now the app should be stable enough to allow base testing. I can now restart working on the debugger. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4116 96395faa-99c1-11dd-bbfe-3dabce05a288 --- tools/GSDumpGUI/Forms/frmMain.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/GSDumpGUI/Forms/frmMain.cs b/tools/GSDumpGUI/Forms/frmMain.cs index c3bd78f0ee..dcdaa20c2c 100644 --- a/tools/GSDumpGUI/Forms/frmMain.cs +++ b/tools/GSDumpGUI/Forms/frmMain.cs @@ -189,6 +189,18 @@ namespace GSDumpGUI SelectedRenderer = "4"; break; } + if (SelectedRenderer != "-1") + { + if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + GSDXName + "\\inis\\gsdx.ini")) + { + String ini = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + GSDXName + "\\inis\\gsdx.ini"); + int pos = ini.IndexOf("Renderer=", 0); + String newini = ini.Substring(0, pos + 9); + newini += SelectedRenderer; + newini += ini.Substring(pos + 10, ini.Length - pos - 10); + File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + GSDXName + "\\inis\\gsdx.ini", newini); + } + } if (lstDumps.SelectedItem != null) DumpPath = Properties.Settings.Default.DumpDir + "\\" + lstDumps.SelectedItem.ToString().Split(new char[] { '|' })[0]; From c1811e6903d971ada5a313afefdd0a63092cead7 Mon Sep 17 00:00:00 2001 From: "feal87@gmail.com" Date: Tue, 21 Dec 2010 08:07:43 +0000 Subject: [PATCH 21/33] Little fix to focus. Forgot to commit this one. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4117 96395faa-99c1-11dd-bbfe-3dabce05a288 --- tools/GSDumpGUI/Core/Program.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/GSDumpGUI/Core/Program.cs b/tools/GSDumpGUI/Core/Program.cs index 9d2063b366..7f15808c24 100644 --- a/tools/GSDumpGUI/Core/Program.cs +++ b/tools/GSDumpGUI/Core/Program.cs @@ -148,6 +148,7 @@ namespace GSDumpGUI frmMain.Invoke(new Action(delegate(object e) { MessageBox.Show("Savestate too old to be read. :(", "Warning"); + frmMain.Focus(); }), new object[] { null }); break; default: From 57dd103e0d9dd9443a9fc533a4979d6a6f05aaab Mon Sep 17 00:00:00 2001 From: ramapcsx2 Date: Wed, 22 Dec 2010 05:37:38 +0000 Subject: [PATCH 22/33] SPU2-X: Adapted the de-alias and frequency response filters from nenolod's "UPSE", a high quality PSF player. (http://nenolod.net/projects/upse/) These 2 filters are present on the real SPU(2) as well and are meant to increase the audio quality by fixing aliasing and then equalizing the final result. It currently mostly seems to accentuate the presence and highs. Thanks a ton for hinting at this and for letting us adapt your code for SPU2-X, nenolod! :) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4118 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/spu2-x/src/Config.h | 1 + plugins/spu2-x/src/Global.h | 3 + plugins/spu2-x/src/Linux/Config.cpp | 1 + plugins/spu2-x/src/Linux/Config.h | 1 + plugins/spu2-x/src/Mixer.cpp | 83 ++++++++++++++++++++++++++- plugins/spu2-x/src/Mixer.h | 42 ++++++++++++++ plugins/spu2-x/src/PS2E-spu2.cpp | 18 +++--- plugins/spu2-x/src/Windows/Config.cpp | 1 + 8 files changed, 142 insertions(+), 8 deletions(-) diff --git a/plugins/spu2-x/src/Config.h b/plugins/spu2-x/src/Config.h index 30956b11dc..04b8843fd4 100644 --- a/plugins/spu2-x/src/Config.h +++ b/plugins/spu2-x/src/Config.h @@ -63,6 +63,7 @@ extern int Interpolation; extern int ReverbBoost; extern int numSpeakers; extern bool EffectsDisabled; +extern bool postprocess_filter_enabled; extern u32 OutputModule; extern int SndOutLatencyMS; diff --git a/plugins/spu2-x/src/Global.h b/plugins/spu2-x/src/Global.h index 83400c6f6f..5e10d5498c 100644 --- a/plugins/spu2-x/src/Global.h +++ b/plugins/spu2-x/src/Global.h @@ -88,6 +88,9 @@ extern void SysMessage(const wchar_t *fmt, ...); # define SPU2_LOG #endif +// Uncomment to enable debug keys on numpad (0 to 5) +//#define DEBUG_KEYS + #include "Utilities/Exceptions.h" #include "Utilities/SafeArray.h" diff --git a/plugins/spu2-x/src/Linux/Config.cpp b/plugins/spu2-x/src/Linux/Config.cpp index 08d64505f0..a899f0c6c8 100644 --- a/plugins/spu2-x/src/Linux/Config.cpp +++ b/plugins/spu2-x/src/Linux/Config.cpp @@ -43,6 +43,7 @@ int Interpolation = 1; bool EffectsDisabled = false; int ReverbBoost = 0; +bool postprocess_filter_enabled = 1; // OUTPUT u32 OutputModule = 0; diff --git a/plugins/spu2-x/src/Linux/Config.h b/plugins/spu2-x/src/Linux/Config.h index ae5f42ded5..4c3c38c77d 100644 --- a/plugins/spu2-x/src/Linux/Config.h +++ b/plugins/spu2-x/src/Linux/Config.h @@ -69,6 +69,7 @@ static __forceinline bool RegDump() { return _RegDump & DebugEnabled; }*/ extern int Interpolation; extern int ReverbBoost; extern bool EffectsDisabled; +extern bool postprocess_filter_enabled = 1; extern int AutoDMAPlayRate[2]; diff --git a/plugins/spu2-x/src/Mixer.cpp b/plugins/spu2-x/src/Mixer.cpp index a39b1d70d1..a9db8593f3 100644 --- a/plugins/spu2-x/src/Mixer.cpp +++ b/plugins/spu2-x/src/Mixer.cpp @@ -723,6 +723,80 @@ StereoOut32 V_Core::Mix( const VoiceMixSet& inVoices, const StereoOut32& Input, return TD + ApplyVolume( RV*temp, FxVol ); } +// Filters that work on the final output to de-alias and equlize it. +// Taken from http://nenolod.net/projects/upse/ +#define OVERALL_SCALE (0.87f) + +StereoOut32 Apply_Frequency_Response_Filter(StereoOut32 &SoundStream) +{ + static FrequencyResponseFilter FRF = FrequencyResponseFilter(); + + s32 in, out; + s32 l, r; + s32 mid, side; + + l = SoundStream.Left; + r = SoundStream.Right; + + mid = l + r; + side = l - r; + + in = mid; + out = FRF.la0 * in + FRF.la1 * FRF.lx1 + FRF.la2 * FRF.lx2 - FRF.lb1 * FRF.ly1 - FRF.lb2 * FRF.ly2; + + FRF.lx2 = FRF.lx1; + FRF.lx1 = in; + + FRF.ly2 = FRF.ly1; + FRF.ly1 = out; + + mid = out; + + l = ((0.5) * (OVERALL_SCALE)) * (mid + side); + r = ((0.5) * (OVERALL_SCALE)) * (mid - side); + + in = l; + out = FRF.ha0 * in + FRF.ha1 * FRF.History_One_In.Left + FRF.ha2 * FRF.History_Two_In.Left - FRF.hb1 * FRF.History_One_Out.Left - FRF.hb2 * FRF.History_Two_Out.Left; + FRF.History_Two_In.Left = FRF.History_One_In.Left; FRF.History_One_In.Left = in; + FRF.History_Two_Out.Left = FRF.History_One_Out.Left; FRF.History_One_Out.Left = out; + l = out; + + in = r; + out = FRF.ha0 * in + FRF.ha1 * FRF.History_One_In.Right + FRF.ha2 * FRF.History_Two_In.Right - FRF.hb1 * FRF.History_One_Out.Right - FRF.hb2 * FRF.History_Two_Out.Right; + FRF.History_Two_In.Right = FRF.History_One_In.Right; FRF.History_One_In.Right = in; + FRF.History_Two_Out.Right = FRF.History_One_Out.Right; FRF.History_One_Out.Right = out; + r = out; + + //clamp_mix(l); + //clamp_mix(r); + + SoundStream.Left = l; + SoundStream.Right = r; + + return SoundStream; +} + +StereoOut32 Apply_Dealias_Filter(StereoOut32 &SoundStream) +{ + static StereoOut32 Old = StereoOut32::Empty; + + s32 l, r; + + l = SoundStream.Left; + r = SoundStream.Right; + + l += (l - Old.Left); + r += (r - Old.Right); + + Old.Left = SoundStream.Left; + Old.Right = SoundStream.Right; + + SoundStream.Left = l; + SoundStream.Right = r; + + return SoundStream; +} + // used to throttle the output rate of cache stat reports static int p_cachestat_counter=0; @@ -780,11 +854,18 @@ __forceinline void Mix() Out.Left = MulShr32( Out.Left<<(SndOutVolumeShift+1), Cores[1].MasterVol.Left.Value ); Out.Right = MulShr32( Out.Right<<(SndOutVolumeShift+1), Cores[1].MasterVol.Right.Value ); + #ifdef DEBUG_KEYS + if(postprocess_filter_enabled) + #endif + { + Out = Apply_Dealias_Filter ( Out ); + Out = Apply_Frequency_Response_Filter ( Out ); + } + // Final Clamp! // Like any good audio system, the PS2 pumps the volume and incurs some distortion in its // output, giving us a nice thumpy sound at times. So we add 1 above (2x volume pump) and // then clamp it all here. - Out = clamp_mix( Out, SndOutVolumeShift ); } diff --git a/plugins/spu2-x/src/Mixer.h b/plugins/spu2-x/src/Mixer.h index a643de2adb..4f790166c3 100644 --- a/plugins/spu2-x/src/Mixer.h +++ b/plugins/spu2-x/src/Mixer.h @@ -78,6 +78,48 @@ struct StereoOut32 }; +struct FrequencyResponseFilter +{ + static FrequencyResponseFilter Empty; + + StereoOut32 History_One_In; + StereoOut32 History_One_Out; + StereoOut32 History_Two_In; + StereoOut32 History_Two_Out; + + s32 lx1; + s32 lx2; + s32 ly1; + s32 ly2; + + float la0, la1, la2, lb1, lb2; + float ha0, ha1, ha2, hb1, hb2; + + FrequencyResponseFilter() : + History_One_In( 0, 0 ), + History_One_Out( 0, 0 ), + History_Two_In( 0, 0 ), + History_Two_Out( 0, 0 ), + lx1 ( 0 ), + lx2 ( 0 ), + ly1 ( 0 ), + ly2 ( 0 ), + + la0 ( 1.00320890889339290000 ), + la1 ( -1.97516434134506300000 ), + la2 ( 0.97243484967313087000 ), + lb1 ( -1.97525280404731810000 ), + lb2 ( 0.97555529586426892000 ), + + ha0 ( 1.52690772687271160000 ), + ha1 ( -1.62653918974914990000 ), + ha2 ( 0.57997976029249387000 ), + hb1 ( -0.80955590379048203000 ), + hb2 ( 0.28990420120653748000 ) + { + } + +}; extern void Mix(); extern s32 clamp_mix( s32 x, u8 bitshift=0 ); diff --git a/plugins/spu2-x/src/PS2E-spu2.cpp b/plugins/spu2-x/src/PS2E-spu2.cpp index 6449bf72ab..2f88f52d92 100644 --- a/plugins/spu2-x/src/PS2E-spu2.cpp +++ b/plugins/spu2-x/src/PS2E-spu2.cpp @@ -26,8 +26,6 @@ # include "svnrev.h" #endif -// Uncomment to enable debug keys -//#define DEBUG_KEYS // PCSX2 expects ASNI, not unicode, so this MUST always be char... static char libraryName[256]; @@ -511,7 +509,7 @@ static bool numpad_plus = false, numpad_plus_old = false; #ifdef DEBUG_KEYS static u32 lastTicks; -static bool lState[5]; +static bool lState[6]; #endif EXPORT_C_(void) SPU2async(u32 cycles) @@ -530,17 +528,23 @@ EXPORT_C_(void) SPU2async(u32 cycles) #ifdef DEBUG_KEYS u32 curTicks = GetTickCount(); - if((curTicks - lastTicks) >= 100) + if((curTicks - lastTicks) >= 50) { int oldI = Interpolation; - bool cState[5]; - for(int i=0;i<5;i++) + bool cState[6]; + for(int i=0;i<6;i++) { cState[i] = !!(GetAsyncKeyState(VK_NUMPAD0+i)&0x8000); - if(cState[i] && !lState[i]) + if((cState[i] && !lState[i]) && i != 5) Interpolation = i; + if((cState[i] && !lState[i]) && i == 5) + { + postprocess_filter_enabled = !postprocess_filter_enabled; + printf("Post process filters %s \n", postprocess_filter_enabled? "enabled" : "disabled"); + } + lState[i] = cState[i]; } diff --git a/plugins/spu2-x/src/Windows/Config.cpp b/plugins/spu2-x/src/Windows/Config.cpp index 7717666b17..f169d03c0f 100644 --- a/plugins/spu2-x/src/Windows/Config.cpp +++ b/plugins/spu2-x/src/Windows/Config.cpp @@ -37,6 +37,7 @@ int Interpolation = 1; */ int ReverbBoost = 0; bool EffectsDisabled = false; +bool postprocess_filter_enabled = 1; // OUTPUT int SndOutLatencyMS = 150; From 3be87bb2b04c7630af952eff67ac26d2e2d50248 Mon Sep 17 00:00:00 2001 From: "feal87@gmail.com" Date: Wed, 22 Dec 2010 06:59:53 +0000 Subject: [PATCH 23/33] 1) Fixed crash when no ini was created, but an override is attempted. 2) Started writting the debug mode. (a little gif browser grouped by VSync is created) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4119 96395faa-99c1-11dd-bbfe-3dabce05a288 --- tools/GSDumpGUI/Core/Program.cs | 81 +++++++++++++++++- tools/GSDumpGUI/Forms/frmMain.Designer.cs | 83 +++++++++++++++---- tools/GSDumpGUI/Forms/frmMain.cs | 45 +++++++++- tools/GSDumpGUI/Library/GSDXWrapper.cs | 34 +++++++- .../Library/TCPLibrary/Message/TCPMessage.cs | 6 +- 5 files changed, 228 insertions(+), 21 deletions(-) diff --git a/tools/GSDumpGUI/Core/Program.cs b/tools/GSDumpGUI/Core/Program.cs index 7f15808c24..b8ec038240 100644 --- a/tools/GSDumpGUI/Core/Program.cs +++ b/tools/GSDumpGUI/Core/Program.cs @@ -21,6 +21,7 @@ namespace GSDumpGUI static public TCPLibrary.MessageBased.Core.BaseMessageClient Client; static private Boolean ChangeIcon; static private GSDump dump; + static private GSDXWrapper wrap; [STAThread] static void Main(String[] args) @@ -66,7 +67,7 @@ namespace GSDumpGUI String Operation = args[2]; Int32 Renderer = Convert.ToInt32(args[3]); - GSDXWrapper wrap = new GSDXWrapper(); + wrap = new GSDXWrapper(); wrap.Load(DLLPath); Directory.SetCurrentDirectory(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + Path.GetFileName(DLLPath) + "\\")); if (Operation == "GSReplay") @@ -149,6 +150,53 @@ namespace GSDumpGUI { MessageBox.Show("Savestate too old to be read. :(", "Warning"); frmMain.Focus(); + }), new object[] { null }); + break; + case MessageType.GetDebugMode: + frmMain.Invoke(new Action(delegate(object e) + { + frmMain.chkDebugMode.Checked = (Boolean)Mess.Parameters[0]; + + frmMain.lblGif.Enabled = frmMain.chkDebugMode.Checked; + frmMain.btnRunToSelection.Enabled = frmMain.chkDebugMode.Checked; + frmMain.treTreeView.Enabled = frmMain.chkDebugMode.Checked; + frmMain.btnStep.Enabled = frmMain.chkDebugMode.Checked; + if (frmMain.chkDebugMode.Checked == false) + frmMain.treTreeView.Nodes.Clear(); + + }), new object[] { null }); + break; + case MessageType.DebugState: + frmMain.Invoke(new Action(delegate(object e) + { + frmMain.treTreeView.Nodes.Clear(); + List parents = new List(); + List nodes = new List(); + foreach (var itm in Mess.Parameters) + { + String[] parts = itm.ToString().Split(new char[] { '|' }); + switch (parts[1]) + { + case "Transfer": + nodes.Add(new TreeNode(parts[0] + " - " + parts[1] + " - " + parts[2])); + break; + case "ReadFIFO2": + nodes.Add(new TreeNode(parts[0] + " - " + parts[1])); + break; + case "VSync": + TreeNode tn = new TreeNode(); + tn.Text = parts[0] + " - " + parts[1]; + tn.Nodes.AddRange(nodes.ToArray()); + parents.Add(tn); + + nodes.Clear(); + break; + case "Registers": + nodes.Add(new TreeNode(parts[0] + " - " + parts[1])); + break; + } + } + frmMain.treTreeView.Nodes.AddRange(parents.ToArray()); }), new object[] { null }); break; default: @@ -199,6 +247,37 @@ namespace GSDumpGUI } Client.Send(msg); break; + case MessageType.SetDebugMode: + wrap.DebugMode = (Boolean)Mess.Parameters[0]; + + msg = new TCPMessage(); + msg.MessageType = MessageType.GetDebugMode; + msg.Parameters.Add(wrap.DebugMode); + Client.Send(msg); + + if (wrap.DebugMode) + { + msg = new TCPMessage(); + msg.MessageType = MessageType.DebugState; + msg.Parameters.AddRange(wrap.GetGifPackets(dump)); + Client.Send(msg); + } + break; + case MessageType.GetDebugMode: + msg = new TCPMessage(); + msg.MessageType = MessageType.GetDebugMode; + msg.Parameters.Add(wrap.DebugMode); + Client.Send(msg); + + if (wrap.DebugMode) + { + msg = new TCPMessage(); + msg.MessageType = MessageType.DebugState; + msg.Parameters.AddRange(wrap.GetGifPackets(dump)); + Client.Send(msg); + } + break; + default: break; } diff --git a/tools/GSDumpGUI/Forms/frmMain.Designer.cs b/tools/GSDumpGUI/Forms/frmMain.Designer.cs index b7f37384fd..9b0af7949b 100644 --- a/tools/GSDumpGUI/Forms/frmMain.Designer.cs +++ b/tools/GSDumpGUI/Forms/frmMain.Designer.cs @@ -58,7 +58,6 @@ this.lblChild = new System.Windows.Forms.Label(); this.lblDumpSize = new System.Windows.Forms.Label(); this.txtDumpSize = new System.Windows.Forms.Label(); - this.lblWIP = new System.Windows.Forms.Label(); this.txtGIFPackets = new System.Windows.Forms.Label(); this.lblGIFPackets = new System.Windows.Forms.Label(); this.txtPath1 = new System.Windows.Forms.Label(); @@ -73,6 +72,11 @@ this.label7 = new System.Windows.Forms.Label(); this.txtRegisters = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); + this.chkDebugMode = new System.Windows.Forms.CheckBox(); + this.lblGif = new System.Windows.Forms.Label(); + this.btnStep = new System.Windows.Forms.Button(); + this.btnRunToSelection = new System.Windows.Forms.Button(); + this.treTreeView = new System.Windows.Forms.TreeView(); ((System.ComponentModel.ISupportInitialize)(this.pctBox)).BeginInit(); this.SuspendLayout(); // @@ -368,17 +372,6 @@ this.txtDumpSize.Size = new System.Drawing.Size(0, 13); this.txtDumpSize.TabIndex = 30; // - // lblWIP - // - this.lblWIP.AutoSize = true; - this.lblWIP.Font = new System.Drawing.Font("Times New Roman", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblWIP.ForeColor = System.Drawing.Color.Red; - this.lblWIP.Location = new System.Drawing.Point(468, 587); - this.lblWIP.Name = "lblWIP"; - this.lblWIP.Size = new System.Drawing.Size(508, 73); - this.lblWIP.TabIndex = 31; - this.lblWIP.Text = "Work in Progress"; - // // txtGIFPackets // this.txtGIFPackets.AutoSize = true; @@ -505,11 +498,70 @@ this.label6.TabIndex = 44; this.label6.Text = "Registers Packets"; // + // chkDebugMode + // + this.chkDebugMode.AutoSize = true; + this.chkDebugMode.Enabled = false; + this.chkDebugMode.Location = new System.Drawing.Point(481, 487); + this.chkDebugMode.Name = "chkDebugMode"; + this.chkDebugMode.Size = new System.Drawing.Size(88, 17); + this.chkDebugMode.TabIndex = 46; + this.chkDebugMode.Text = "Debug Mode"; + this.chkDebugMode.UseVisualStyleBackColor = true; + this.chkDebugMode.CheckedChanged += new System.EventHandler(this.chkDebugMode_CheckedChanged); + // + // lblGif + // + this.lblGif.AutoSize = true; + this.lblGif.Enabled = false; + this.lblGif.Location = new System.Drawing.Point(427, 520); + this.lblGif.Name = "lblGif"; + this.lblGif.Size = new System.Drawing.Size(66, 13); + this.lblGif.TabIndex = 48; + this.lblGif.Text = "GIF Packets"; + // + // btnStep + // + this.btnStep.Enabled = false; + this.btnStep.Location = new System.Drawing.Point(629, 533); + this.btnStep.Name = "btnStep"; + this.btnStep.Size = new System.Drawing.Size(108, 40); + this.btnStep.TabIndex = 49; + this.btnStep.TabStop = false; + this.btnStep.Text = "Step"; + this.btnStep.UseVisualStyleBackColor = true; + this.btnStep.Click += new System.EventHandler(this.btnStep_Click); + // + // btnRunToSelection + // + this.btnRunToSelection.Enabled = false; + this.btnRunToSelection.Location = new System.Drawing.Point(629, 579); + this.btnRunToSelection.Name = "btnRunToSelection"; + this.btnRunToSelection.Size = new System.Drawing.Size(108, 40); + this.btnRunToSelection.TabIndex = 50; + this.btnRunToSelection.TabStop = false; + this.btnRunToSelection.Text = "Run To Selection"; + this.btnRunToSelection.UseVisualStyleBackColor = true; + this.btnRunToSelection.Click += new System.EventHandler(this.btnRunToSelection_Click); + // + // treTreeView + // + this.treTreeView.Enabled = false; + this.treTreeView.Location = new System.Drawing.Point(420, 539); + this.treTreeView.Name = "treTreeView"; + this.treTreeView.Size = new System.Drawing.Size(200, 240); + this.treTreeView.TabIndex = 51; + // // GSDumpGUI // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(988, 790); + this.Controls.Add(this.treTreeView); + this.Controls.Add(this.btnRunToSelection); + this.Controls.Add(this.btnStep); + this.Controls.Add(this.lblGif); + this.Controls.Add(this.chkDebugMode); this.Controls.Add(this.txtRegisters); this.Controls.Add(this.label6); this.Controls.Add(this.txtReadFifo); @@ -524,7 +576,6 @@ this.Controls.Add(this.label2); this.Controls.Add(this.txtGIFPackets); this.Controls.Add(this.lblGIFPackets); - this.Controls.Add(this.lblWIP); this.Controls.Add(this.txtDumpSize); this.Controls.Add(this.lblDumpSize); this.Controls.Add(this.lstProcesses); @@ -599,7 +650,6 @@ public System.Windows.Forms.ListBox lstProcesses; private System.Windows.Forms.Label lblDumpSize; public System.Windows.Forms.Label txtDumpSize; - private System.Windows.Forms.Label lblWIP; public System.Windows.Forms.Label txtGIFPackets; private System.Windows.Forms.Label lblGIFPackets; public System.Windows.Forms.Label txtPath1; @@ -614,6 +664,11 @@ private System.Windows.Forms.Label label7; public System.Windows.Forms.Label txtRegisters; private System.Windows.Forms.Label label6; + public System.Windows.Forms.CheckBox chkDebugMode; + public System.Windows.Forms.TreeView treTreeView; + public System.Windows.Forms.Label lblGif; + public System.Windows.Forms.Button btnStep; + public System.Windows.Forms.Button btnRunToSelection; } } diff --git a/tools/GSDumpGUI/Forms/frmMain.cs b/tools/GSDumpGUI/Forms/frmMain.cs index dcdaa20c2c..6a26822aca 100644 --- a/tools/GSDumpGUI/Forms/frmMain.cs +++ b/tools/GSDumpGUI/Forms/frmMain.cs @@ -195,10 +195,17 @@ namespace GSDumpGUI { String ini = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + GSDXName + "\\inis\\gsdx.ini"); int pos = ini.IndexOf("Renderer=", 0); - String newini = ini.Substring(0, pos + 9); - newini += SelectedRenderer; - newini += ini.Substring(pos + 10, ini.Length - pos - 10); - File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + GSDXName + "\\inis\\gsdx.ini", newini); + if (pos != -1) + { + String newini = ini.Substring(0, pos + 9); + newini += SelectedRenderer; + newini += ini.Substring(pos + 10, ini.Length - pos - 10); + File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + GSDXName + "\\inis\\gsdx.ini", newini); + } + else + { + File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "GSDumpGSDXConfigs\\" + GSDXName + "\\inis\\gsdx.ini", ini + Environment.NewLine + "Renderer=" + SelectedRenderer); + } } } if (lstDumps.SelectedItem != null) @@ -369,13 +376,43 @@ namespace GSDumpGUI { if (lstProcesses.SelectedIndex != -1) { + chkDebugMode.Enabled = true; + TCPMessage msg = new TCPMessage(); + msg.MessageType = MessageType.GetDebugMode; + msg.Parameters.Add(chkDebugMode.Checked); + Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg); + + msg = new TCPMessage(); msg.MessageType = MessageType.SizeDump; Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg); + msg = new TCPMessage(); msg.MessageType = MessageType.Statistics; Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg); } + else + { + chkDebugMode.Enabled = false; + } + } + + private void chkDebugMode_CheckedChanged(object sender, EventArgs e) + { + TCPMessage msg = new TCPMessage(); + msg.MessageType = MessageType.SetDebugMode; + msg.Parameters.Add(chkDebugMode.Checked); + Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg); + } + + private void btnStep_Click(object sender, EventArgs e) + { + MessageBox.Show("Not Implemented"); + } + + private void btnRunToSelection_Click(object sender, EventArgs e) + { + MessageBox.Show("Not Implemented"); } } } diff --git a/tools/GSDumpGUI/Library/GSDXWrapper.cs b/tools/GSDumpGUI/Library/GSDXWrapper.cs index 8976c9cc71..2fd7301b09 100644 --- a/tools/GSDumpGUI/Library/GSDXWrapper.cs +++ b/tools/GSDumpGUI/Library/GSDXWrapper.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using System.IO; +using TCPLibrary.MessageBased.Core; +using System.Threading; namespace GSDumpGUI { @@ -49,6 +51,11 @@ namespace GSDumpGUI private Boolean Running; + public List QueueMessage; + public Boolean DebugMode; + public GSData CurrentGIFPacket; + public AutoResetEvent Event; + static public Boolean IsValidGSDX(String DLL) { NativeMethods.SetErrorMode(0x8007); @@ -168,7 +175,10 @@ namespace GSDumpGUI public unsafe void Run(GSDump dump, int rendererOverride) { + QueueMessage = new List(); Running = true; + Event = new AutoResetEvent(true); + GSinit(); fixed (byte* pointer = dump.Registers) { @@ -199,11 +209,13 @@ namespace GSDumpGUI Running = false; break; } + foreach (var itm in dump.Data) { + CurrentGIFPacket = itm; + Step(itm, pointer); } - } GSclose(); @@ -275,5 +287,25 @@ namespace GSDumpGUI { Running = false; } + + internal List GetGifPackets(GSDump dump) + { + List Data = new List(); + for (int i = 0; i < dump.Data.Count; i++) + { + String act = i.ToString() + "|"; + act += dump.Data[i].id.ToString() + "|"; + if (dump.Data[i].GetType().IsSubclassOf(typeof(GSData))) + { + act += ((GSTransfer)dump.Data[i]).Path.ToString(); + } + else + { + + } + Data.Add(act); + } + return Data; + } } } diff --git a/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs b/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs index dc0512e732..dc6222e09a 100644 --- a/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs +++ b/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs @@ -111,6 +111,10 @@ namespace TCPLibrary.MessageBased.Core MaxUsers, SizeDump, Statistics, - StateOld + StateOld, + + GetDebugMode, + SetDebugMode, + DebugState } } From e085883e1cc20f0a7f467bac97f157fd0ba091c0 Mon Sep 17 00:00:00 2001 From: "feal87@gmail.com" Date: Wed, 22 Dec 2010 07:07:35 +0000 Subject: [PATCH 24/33] Forgot a little fix. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4120 96395faa-99c1-11dd-bbfe-3dabce05a288 --- tools/GSDumpGUI/Core/Program.cs | 9 +++++++++ tools/GSDumpGUI/Forms/frmMain.cs | 11 +++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tools/GSDumpGUI/Core/Program.cs b/tools/GSDumpGUI/Core/Program.cs index b8ec038240..11884c65e3 100644 --- a/tools/GSDumpGUI/Core/Program.cs +++ b/tools/GSDumpGUI/Core/Program.cs @@ -299,6 +299,15 @@ namespace GSDumpGUI { frmMain.lstProcesses.Items.Add(itm.IPAddress); } + if (frmMain.lstProcesses.SelectedIndex == -1) + { + frmMain.chkDebugMode.Checked = false; + frmMain.lblGif.Enabled = frmMain.chkDebugMode.Checked; + frmMain.btnRunToSelection.Enabled = frmMain.chkDebugMode.Checked; + frmMain.treTreeView.Enabled = frmMain.chkDebugMode.Checked; + frmMain.btnStep.Enabled = frmMain.chkDebugMode.Checked; + frmMain.treTreeView.Nodes.Clear(); + } }), new object[] { null}); } } diff --git a/tools/GSDumpGUI/Forms/frmMain.cs b/tools/GSDumpGUI/Forms/frmMain.cs index 6a26822aca..66ebc8d0c3 100644 --- a/tools/GSDumpGUI/Forms/frmMain.cs +++ b/tools/GSDumpGUI/Forms/frmMain.cs @@ -399,10 +399,13 @@ namespace GSDumpGUI private void chkDebugMode_CheckedChanged(object sender, EventArgs e) { - TCPMessage msg = new TCPMessage(); - msg.MessageType = MessageType.SetDebugMode; - msg.Parameters.Add(chkDebugMode.Checked); - Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg); + if (lstProcesses.SelectedIndex != -1) + { + TCPMessage msg = new TCPMessage(); + msg.MessageType = MessageType.SetDebugMode; + msg.Parameters.Add(chkDebugMode.Checked); + Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg); + } } private void btnStep_Click(object sender, EventArgs e) From 0962198a3b8cb13fef47e48ccfd695575f2bbb8e Mon Sep 17 00:00:00 2001 From: "feal87@gmail.com" Date: Wed, 22 Dec 2010 09:19:58 +0000 Subject: [PATCH 25/33] Implemented basic Step and RunTo functionality in the debug mode. Still very simple and probably bugged/incomplete. Just need to make some story in the svn, before doing some new big work. :D git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4121 96395faa-99c1-11dd-bbfe-3dabce05a288 --- tools/GSDumpGUI/Core/Program.cs | 61 +++++++++++++-- tools/GSDumpGUI/Forms/frmMain.cs | 14 +++- tools/GSDumpGUI/Library/GSDXWrapper.cs | 77 +++++++++++++++++-- tools/GSDumpGUI/Library/NativeMethods.cs | 28 +++++++ .../Library/TCPLibrary/Message/TCPMessage.cs | 5 +- 5 files changed, 171 insertions(+), 14 deletions(-) diff --git a/tools/GSDumpGUI/Core/Program.cs b/tools/GSDumpGUI/Core/Program.cs index 11884c65e3..0f118e7bd2 100644 --- a/tools/GSDumpGUI/Core/Program.cs +++ b/tools/GSDumpGUI/Core/Program.cs @@ -9,6 +9,7 @@ using System.Diagnostics; using GSDumpGUI.Properties; using System.IO; using TCPLibrary.MessageBased.Core; +using System.Drawing; namespace GSDumpGUI { @@ -23,6 +24,8 @@ namespace GSDumpGUI static private GSDump dump; static private GSDXWrapper wrap; + static private TreeNode CurrentNode; + [STAThread] static void Main(String[] args) { @@ -43,15 +46,16 @@ namespace GSDumpGUI { while (true) { + IntPtr pt = Process.GetCurrentProcess().MainWindowHandle; if (ChangeIcon) { - IntPtr pt = Process.GetCurrentProcess().MainWindowHandle; if (pt.ToInt64() != 0) { NativeMethods.SetClassLong(pt, -14, Resources.AppIcon.Handle.ToInt64()); ChangeIcon = false; } } + Int32 tmp = NativeMethods.GetAsyncKeyState(0x1b) & 0xf; if (tmp != 0) Process.GetCurrentProcess().Kill(); @@ -178,13 +182,20 @@ namespace GSDumpGUI switch (parts[1]) { case "Transfer": - nodes.Add(new TreeNode(parts[0] + " - " + parts[1] + " - " + parts[2])); + TreeNode tn2 = new TreeNode(); + tn2.Name = parts[0]; + tn2.Text = parts[0] + " - " + parts[1] + " - " + parts[2]; + nodes.Add(tn2); break; case "ReadFIFO2": - nodes.Add(new TreeNode(parts[0] + " - " + parts[1])); + TreeNode tn3 = new TreeNode(); + tn3.Name = parts[0]; + tn3.Text = parts[0] + " - " + parts[1]; + nodes.Add(tn3); break; case "VSync": TreeNode tn = new TreeNode(); + tn.Name = parts[0]; tn.Text = parts[0] + " - " + parts[1]; tn.Nodes.AddRange(nodes.ToArray()); parents.Add(tn); @@ -192,13 +203,32 @@ namespace GSDumpGUI nodes.Clear(); break; case "Registers": - nodes.Add(new TreeNode(parts[0] + " - " + parts[1])); + TreeNode tn4 = new TreeNode(); + tn4.Name = parts[0]; + tn4.Text = parts[0] + " - " + parts[1]; + nodes.Add(tn4); break; } } frmMain.treTreeView.Nodes.AddRange(parents.ToArray()); }), new object[] { null }); break; + case MessageType.Step: + case MessageType.RunToCursor: + frmMain.Invoke(new Action(delegate(object e) + { + int idtoselect = (int)Mess.Parameters[0]; + TreeNode[] noes = frmMain.treTreeView.Nodes.Find(idtoselect.ToString(), true); + if (noes.Length > 0) + { + if (CurrentNode != null) + CurrentNode.BackColor = Color.White; + noes[0].BackColor = Color.LightBlue; + CurrentNode = noes[0]; + frmMain.treTreeView.SelectedNode = noes[0]; + } + }), new object[] { null }); + break; default: break; } @@ -261,6 +291,11 @@ namespace GSDumpGUI msg.MessageType = MessageType.DebugState; msg.Parameters.AddRange(wrap.GetGifPackets(dump)); Client.Send(msg); + + msg = new TCPMessage(); + msg.MessageType = MessageType.Step; + msg.Parameters.Add(dump.Data.FindIndex(a => a == wrap.CurrentGIFPacket)); + Client.Send(msg); } break; case MessageType.GetDebugMode: @@ -275,9 +310,25 @@ namespace GSDumpGUI msg.MessageType = MessageType.DebugState; msg.Parameters.AddRange(wrap.GetGifPackets(dump)); Client.Send(msg); + + msg = new TCPMessage(); + msg.MessageType = MessageType.Step; + msg.Parameters.Add(dump.Data.FindIndex(a => a == wrap.CurrentGIFPacket)); + Client.Send(msg); } break; - + case MessageType.Step: + wrap.ExternalEvent.WaitOne(); + wrap.ExternalEvent.Reset(); + wrap.QueueMessage.Enqueue(Mess); + wrap.ThereIsWork = true; + break; + case MessageType.RunToCursor: + wrap.ExternalEvent.WaitOne(); + wrap.ExternalEvent.Reset(); + wrap.QueueMessage.Enqueue(Mess); + wrap.ThereIsWork = true; + break; default: break; } diff --git a/tools/GSDumpGUI/Forms/frmMain.cs b/tools/GSDumpGUI/Forms/frmMain.cs index 66ebc8d0c3..98570fdf0e 100644 --- a/tools/GSDumpGUI/Forms/frmMain.cs +++ b/tools/GSDumpGUI/Forms/frmMain.cs @@ -410,12 +410,22 @@ namespace GSDumpGUI private void btnStep_Click(object sender, EventArgs e) { - MessageBox.Show("Not Implemented"); + TCPMessage msg = new TCPMessage(); + msg.MessageType = MessageType.Step; + Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg); } private void btnRunToSelection_Click(object sender, EventArgs e) { - MessageBox.Show("Not Implemented"); + if (treTreeView.SelectedNode != null) + { + TCPMessage msg = new TCPMessage(); + msg.MessageType = MessageType.RunToCursor; + msg.Parameters.Add(Convert.ToInt32(treTreeView.SelectedNode.Text.Split(new string[]{" - "}, StringSplitOptions.None)[0])); + Program.Clients.Find(a => a.IPAddress == lstProcesses.SelectedItem.ToString()).Send(msg); + } + else + MessageBox.Show("You have not selected a node to jump to"); } } } diff --git a/tools/GSDumpGUI/Library/GSDXWrapper.cs b/tools/GSDumpGUI/Library/GSDXWrapper.cs index 2fd7301b09..167ef04c4d 100644 --- a/tools/GSDumpGUI/Library/GSDXWrapper.cs +++ b/tools/GSDumpGUI/Library/GSDXWrapper.cs @@ -51,10 +51,12 @@ namespace GSDumpGUI private Boolean Running; - public List QueueMessage; + public Queue QueueMessage; public Boolean DebugMode; public GSData CurrentGIFPacket; - public AutoResetEvent Event; + public bool ThereIsWork; + public AutoResetEvent ExternalEvent; + public int RunTo; static public Boolean IsValidGSDX(String DLL) { @@ -175,9 +177,9 @@ namespace GSDumpGUI public unsafe void Run(GSDump dump, int rendererOverride) { - QueueMessage = new List(); + QueueMessage = new Queue(); Running = true; - Event = new AutoResetEvent(true); + ExternalEvent = new AutoResetEvent(true); GSinit(); fixed (byte* pointer = dump.Registers) @@ -210,11 +212,74 @@ namespace GSDumpGUI break; } - foreach (var itm in dump.Data) + for (int i = 0; i < dump.Data.Count; i++) { + GSData itm = dump.Data[i]; CurrentGIFPacket = itm; - Step(itm, pointer); + if (DebugMode) + { + if (RunTo != -1) + { + if (i == RunTo) + { + RunTo = -1; + + TCPMessage Msg = new TCPMessage(); + Msg.MessageType = MessageType.RunToCursor; + Msg.Parameters.Add(i); + Program.Client.Send(Msg); + + ExternalEvent.Set(); + } + else + { + Step(itm, pointer); + } + } + else + { + while (!ThereIsWork && Running) + { + NativeMessage message; + while (NativeMethods.PeekMessage(out message, IntPtr.Zero, 0, 0, 1)) + { + if (!NativeMethods.IsWindowVisible(new IntPtr(HWND))) + { + Running = false; + } + NativeMethods.TranslateMessage(ref message); + NativeMethods.DispatchMessage(ref message); + } + } + + ThereIsWork = false; + if (QueueMessage.Count > 0) + { + TCPMessage Mess = QueueMessage.Dequeue(); + if (Mess.MessageType == MessageType.Step) + { + Step(itm, pointer); + + TCPMessage Msg = new TCPMessage(); + Msg.MessageType = MessageType.Step; + Msg.Parameters.Add(i); + Program.Client.Send(Msg); + + ExternalEvent.Set(); + } + else + if (Mess.MessageType == MessageType.RunToCursor) + { + RunTo = (int)Mess.Parameters[0]; + } + } + } + } + else + { + Step(itm, pointer); + } } } diff --git a/tools/GSDumpGUI/Library/NativeMethods.cs b/tools/GSDumpGUI/Library/NativeMethods.cs index 192d7dc52d..f2ed304901 100644 --- a/tools/GSDumpGUI/Library/NativeMethods.cs +++ b/tools/GSDumpGUI/Library/NativeMethods.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Text; using System.Security; using System.Runtime.InteropServices; +using System.Drawing; namespace GSDumpGUI { @@ -39,5 +40,32 @@ namespace GSDumpGUI [SuppressUnmanagedCodeSecurityAttribute] [DllImport("user32", CharSet = CharSet.Ansi)] public extern static bool IsWindowVisible(IntPtr HWND); + + [SuppressUnmanagedCodeSecurityAttribute] + [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool PeekMessage(out NativeMessage message, IntPtr hwnd, uint messageFilterMin, uint messageFilterMax, uint flags); + + [SuppressUnmanagedCodeSecurityAttribute] + [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool TranslateMessage(ref NativeMessage message); + + [SuppressUnmanagedCodeSecurityAttribute] + [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool DispatchMessage(ref NativeMessage message); } + + [StructLayout(LayoutKind.Sequential)] + public struct NativeMessage + { + public IntPtr hWnd; + public uint msg; + public IntPtr wParam; + public IntPtr lParam; + public uint time; + public Point p; + } + } diff --git a/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs b/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs index dc6222e09a..4d9f3b50d8 100644 --- a/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs +++ b/tools/GSDumpGUI/Library/TCPLibrary/Message/TCPMessage.cs @@ -115,6 +115,9 @@ namespace TCPLibrary.MessageBased.Core GetDebugMode, SetDebugMode, - DebugState + DebugState, + + Step, + RunToCursor } } From def52f300eff5ae126bb7722f58cae61f51d41c1 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Wed, 22 Dec 2010 10:43:20 +0000 Subject: [PATCH 26/33] spu2-x: compilation fix; pcsx2: fix the codeblock project; zzogl-pg: Add some comments and debugging code. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4122 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/Linux/pcsx2.cbp | 5 +++ plugins/spu2-x/src/Linux/Config.h | 2 +- plugins/zzogl-pg/opengl/Regs.cpp | 64 +++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/pcsx2/Linux/pcsx2.cbp b/pcsx2/Linux/pcsx2.cbp index e80f4e6a89..17fa299597 100644 --- a/pcsx2/Linux/pcsx2.cbp +++ b/pcsx2/Linux/pcsx2.cbp @@ -510,6 +510,11 @@