@@ -72,6 +72,7 @@ public struct programSettings
7272 public int backupMemcards ; //Backup Memory Card settings
7373 public int warningMessage ; //Warning message settings
7474 public int restoreWindowPosition ; //Restore window position
75+ public int fixCorruptedCards ; //Try to fix corrupted memory cards
7576 public int glassStatusBar ; //Vista glass status bar
7677 public int formatType ; //Type of formatting for hardware interfaces
7778 public string listFont ; //List font
@@ -207,6 +208,9 @@ private void loadProgramSettings()
207208 //Load format type
208209 mainSettings . formatType = xmlAppSettings . readXmlEntryInt ( "HardwareFormatType" , 0 , 1 ) ;
209210
211+ //Load fix corrupted cards value
212+ mainSettings . fixCorruptedCards = xmlAppSettings . readXmlEntryInt ( "FixCorruptedCards" , 0 , 1 ) ;
213+
210214 //Check if window position should be read
211215 if ( mainSettings . restoreWindowPosition == 1 )
212216 {
@@ -266,6 +270,9 @@ private void saveProgramSettings()
266270 //Set format type
267271 xmlAppSettings . writeXmlEntry ( "HardwareFormatType" , mainSettings . formatType . ToString ( ) ) ;
268272
273+ //Set fix corrupted cards value
274+ xmlAppSettings . writeXmlEntry ( "FixCorruptedCards" , mainSettings . fixCorruptedCards . ToString ( ) ) ;
275+
269276 //Set window X coordinate
270277 xmlAppSettings . writeXmlEntry ( "WindowX" , this . Location . X . ToString ( ) ) ;
271278
@@ -276,6 +283,12 @@ private void saveProgramSettings()
276283 xmlAppSettings . closeXmlWriter ( ) ;
277284 }
278285
286+ //Quick and dirty settings bool converter
287+ private bool getSettingsBool ( int intValue )
288+ {
289+ return ( intValue == 1 ) ? true : false ;
290+ }
291+
279292 //Backup a Memory Card
280293 private void backupMemcard ( string fileName )
281294 {
@@ -356,7 +369,7 @@ private void openCard(string fileName)
356369 PScard . Add ( new ps1card ( ) ) ;
357370
358371 //Try to open card
359- errorMsg = PScard [ PScard . Count - 1 ] . openMemoryCard ( fileName ) ;
372+ errorMsg = PScard [ PScard . Count - 1 ] . openMemoryCard ( fileName , getSettingsBool ( mainSettings . fixCorruptedCards ) ) ;
360373
361374 //If card is sucesfully opened proceed further, else destroy it
362375 if ( errorMsg == null )
@@ -449,7 +462,7 @@ private void saveCardDialog(int listIndex)
449462 //Save a Memory Card to a given filename
450463 private void saveMemoryCard ( int listIndex , string fileName , byte memoryCardType )
451464 {
452- if ( PScard [ listIndex ] . saveMemoryCard ( fileName , memoryCardType ) )
465+ if ( PScard [ listIndex ] . saveMemoryCard ( fileName , memoryCardType , getSettingsBool ( mainSettings . fixCorruptedCards ) ) )
453466 {
454467 refreshListView ( listIndex , cardList [ listIndex ] . SelectedIndices [ 0 ] ) ;
455468 refreshStatusStrip ( ) ;
@@ -1660,7 +1673,7 @@ private void cardReaderRead(byte[] readData)
16601673 PScard . Add ( new ps1card ( ) ) ;
16611674
16621675 //Fill the card with the new data
1663- PScard [ PScard . Count - 1 ] . openMemoryCardStream ( readData ) ;
1676+ PScard [ PScard . Count - 1 ] . openMemoryCardStream ( readData , getSettingsBool ( mainSettings . fixCorruptedCards ) ) ;
16641677
16651678 //Temporary set a bogus file location (to fool filterNullCard function)
16661679 PScard [ PScard . Count - 1 ] . cardLocation = "\0 " ;
@@ -2054,7 +2067,7 @@ private void dexDriveMenuWrite_Click(object sender, EventArgs e)
20542067 if ( PScard . Count > 0 )
20552068 {
20562069 //Open a DexDrive communication window
2057- new cardReaderWindow ( ) . writeMemoryCardDexDrive ( this , appName , mainSettings . communicationPort , PScard [ listIndex ] . saveMemoryCardStream ( ) , 1024 ) ;
2070+ new cardReaderWindow ( ) . writeMemoryCardDexDrive ( this , appName , mainSettings . communicationPort , PScard [ listIndex ] . saveMemoryCardStream ( getSettingsBool ( mainSettings . fixCorruptedCards ) ) , 1024 ) ;
20582071 }
20592072 }
20602073
@@ -2087,7 +2100,7 @@ private void memCARDuinoMenuWrite_Click(object sender, EventArgs e)
20872100 if ( PScard . Count > 0 )
20882101 {
20892102 //Open a DexDrive communication window
2090- new cardReaderWindow ( ) . writeMemoryCardCARDuino ( this , appName , mainSettings . communicationPort , PScard [ listIndex ] . saveMemoryCardStream ( ) , 1024 ) ;
2103+ new cardReaderWindow ( ) . writeMemoryCardCARDuino ( this , appName , mainSettings . communicationPort , PScard [ listIndex ] . saveMemoryCardStream ( getSettingsBool ( mainSettings . fixCorruptedCards ) ) , 1024 ) ;
20912104 }
20922105 }
20932106
@@ -2108,7 +2121,7 @@ private void pS1CardLinkMenuWrite_Click(object sender, EventArgs e)
21082121 if ( PScard . Count > 0 )
21092122 {
21102123 //Open a DexDrive communication window
2111- new cardReaderWindow ( ) . writeMemoryCardPS1CLnk ( this , appName , mainSettings . communicationPort , PScard [ listIndex ] . saveMemoryCardStream ( ) , 1024 ) ;
2124+ new cardReaderWindow ( ) . writeMemoryCardPS1CLnk ( this , appName , mainSettings . communicationPort , PScard [ listIndex ] . saveMemoryCardStream ( getSettingsBool ( mainSettings . fixCorruptedCards ) ) , 1024 ) ;
21122125 }
21132126 }
21142127
@@ -2143,21 +2156,21 @@ private void formatHardwareCard(int hardDevice)
21432156 if ( mainSettings . formatType == 0 ) frameNumber = 64 ;
21442157
21452158 //Create a new card by giving a null path
2146- blankCard . openMemoryCard ( null ) ;
2159+ blankCard . openMemoryCard ( null , true ) ;
21472160
21482161 //Check what device to use
21492162 switch ( hardDevice )
21502163 {
21512164 case 0 : //DexDrive
2152- new cardReaderWindow ( ) . writeMemoryCardDexDrive ( this , appName , mainSettings . communicationPort , blankCard . saveMemoryCardStream ( ) , frameNumber ) ;
2165+ new cardReaderWindow ( ) . writeMemoryCardDexDrive ( this , appName , mainSettings . communicationPort , blankCard . saveMemoryCardStream ( true ) , frameNumber ) ;
21532166 break ;
21542167
21552168 case 1 : //MemCARDuino
2156- new cardReaderWindow ( ) . writeMemoryCardCARDuino ( this , appName , mainSettings . communicationPort , blankCard . saveMemoryCardStream ( ) , frameNumber ) ;
2169+ new cardReaderWindow ( ) . writeMemoryCardCARDuino ( this , appName , mainSettings . communicationPort , blankCard . saveMemoryCardStream ( true ) , frameNumber ) ;
21572170 break ;
21582171
21592172 case 2 : //PS1CardLink
2160- new cardReaderWindow ( ) . writeMemoryCardPS1CLnk ( this , appName , mainSettings . communicationPort , blankCard . saveMemoryCardStream ( ) , frameNumber ) ;
2173+ new cardReaderWindow ( ) . writeMemoryCardPS1CLnk ( this , appName , mainSettings . communicationPort , blankCard . saveMemoryCardStream ( true ) , frameNumber ) ;
21612174 break ;
21622175 }
21632176 }
0 commit comments