It is currently Fri May 24, 2013 10:44 pm

All times are UTC




Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Tue May 08, 2012 7:16 am 
Offline
Snes9x White Belt

Joined: Tue May 08, 2012 6:14 am
Posts: 2
I ran into a very similar issue with .cht files that I've been generating and I tracked down the issue to the "saved bit" (bit 3) in the first byte of the cht file. If this bit is cleared and the cheat is enabled (bit 2 cleared also) then when the rom loads it will get stuck in what appears to be an infinite loop.

Using the 1.53 Windows port, I found that the first byte of a cheat will be set this way when I generate a cht file with an initial value of 0x04 (disabled and no saved value), load the rom, open the cheat dialog, enable the cheat, then close the dialog by clicking ok. The saved value is not saved to the cht file and the byte is set to 0x00 (enabled and no saved value). Now I close snes9x, reopen it and load the rom. At this point the infinite loop is encountered and snes9x has to to be force closed (I didn't spend anytime trying to debug the actual location of the infinite loop (or whatever is causing the hang), but it must occur somewhere after S9xGetByteFree() is called in S9xApplyCheat() during rom loading).

The cht file should have been saved with the first byte of the cheat set to 0x08 in the use case above, but the Windows port (only tested 1.53) does not do this. If the cht file was saved properly, this infinite loop issue would have been avoided. It appears this issue I'm seeing with saving the cht file is caused in the "ID_CHEAT_ENTER" switch case starting at line 2166 in wsnes9x.cpp:
Code:
      case ID_CHEAT_ENTER:
         RestoreGUIDisplay ();
         S9xRemoveCheats ();
         DialogBox(g_hInst, MAKEINTRESOURCE(IDD_CHEATER), hWnd, DlgCheater);
         S9xSaveCheatFile (S9xGetFilename (".cht", CHEAT_DIR));
         S9xApplyCheats ();
         RestoreSNESDisplay ();
         break;

In this code S9xSaveCheatFile() is called before S9xApplyCheats(). I think these two lines should be swapped because S9xApplyCheats() is what sets the saved value and the saved bit properly, which we definitely want done before saving. I don't have a development environment setup to allow me to compile snes9x so I haven't been able to test this fix, but it should do the trick hopefully.

Looking at this code, it also becomes apparent that a simple workaround is to re-open the cheat dialog and click ok again (so everytime you want to enable a cheat, open the dialog, enable the cheat, click ok, then reopen the dialog and click ok again). If you do this then the cht file will be saved properly and the next time you open snes9x with cheats enabled it will not get stuck.

It would be awesome if this could be fixed in the next release :) Thanks!


Top
 Profile  
 
PostPosted: Tue May 08, 2012 12:52 pm 
Offline
Official Win32 Porter/Dev
User avatar

Joined: Thu Aug 30, 2007 10:15 pm
Posts: 450
I've already fixed the infinite loop (as stated on the previous page), it should be in this testbuild: snes9x_testbuild_29032012.zip.

It still makes sense to change the order of those calls - will be in the next version/testbuild.


Top
 Profile  
 
PostPosted: Wed May 09, 2012 6:47 am 
Offline
Snes9x White Belt

Joined: Tue May 08, 2012 6:14 am
Posts: 2
OV2 wrote:
I've already fixed the infinite loop (as stated on the previous page), it should be in this testbuild: snes9x_testbuild_29032012.zip.

It still makes sense to change the order of those calls - will be in the next version/testbuild.


Thanks! :D


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: Google [Bot], Google Adsense [Bot] and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group