Advertisement
djvj

nestopia class rewrite

Jul 5th, 2016
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.47 KB | None | 0 0
  1. MEmu = Nestopia
  2. MEmuV = v1.42
  3. MURL = http://www.emucr.com/2011/09/nestopia-unofficial-v1420.html
  4. MAuthor = djvj
  5. MVersion = 2.0.5
  6. MCRC = 6F80AA06
  7. iCRC = F9662CA1
  8. MID = 635038268908287546
  9. MSystem = "Nintendo Entertainment System","Nintendo Famicom","Nintendo Famicom Disk System"
  10. ;----------------------------------------------------------------------------
  11. ; Notes:
  12. ; If using this for Nintendo Famicom Disk System, make sure you place an FDS bios in your bios subfolder for your emu. You will have to select it on first launch of any FDS game.
  13. ; Set your fullscreen key to Alt+Enter if it is not already for Pause support
  14. ;----------------------------------------------------------------------------
  15. StartModule()
  16. BezelGUI()
  17. FadeInStart()
  18.  
  19. primaryExe := new Emulator(emuPath . "\" . executable) ; instantiate emulator executable object
  20. emuPrimaryWindow := new Window(new WindowTitle("Nestopia","Nestopia")) ; instantiate primary emulator window object
  21.  
  22. Fullscreen := moduleIni.Read("Settings", "Fullscreen","true","",1)
  23. ExitKey := moduleIni.Read("Settings", "ExitKey","Esc","",1)
  24. ToggleMenuKey := moduleIni.Read("Settings", "ToggleMenuKey","Alt+M","",1)
  25. bezelTopOffset := moduleIni.Read("Settings", "bezelTopOffset",16,"",1)
  26. bezelBottomOffset := moduleIni.Read("Settings", "bezelBottomOffset",26,"",1)
  27. bezelLeftOffset := moduleIni.Read("Settings", "bezelLeftOffset",7,"",1)
  28. bezelRightOffset := moduleIni.Read("Settings", "bezelRightOffset",7,"",1)
  29.  
  30. forceControls := moduleIni.Read(dbName . "|Settings", "forceControls","False","",1)
  31. port1 := moduleIni.Read(dbName . "|Settings", "port1","unconnected","",1)
  32. port2 := moduleIni.Read(dbName . "|Settings", "port2","unconnected","",1)
  33. port3 := moduleIni.Read(dbName . "|Settings", "port3","unconnected","",1)
  34. port4 := moduleIni.Read(dbName . "|Settings", "port4","unconnected","",1)
  35. port5 := moduleIni.Read(dbName . "|Settings", "port5","unconnected","",1)
  36.  
  37. BezelStart()
  38.  
  39. emuSettingsFile := new File(emuPath . "\nestopia.xml")
  40. emuSettingsFile.Read()
  41.  
  42. If StringUtils.InStr(emuSettingsFile.Text,"<confirm-exit>yes</confirm-exit>") ; find if this setting is not the desired value
  43. emuSettingsFile.Text := StringUtils.Replace(emuSettingsFile.Text,"<confirm-exit>yes</confirm-exit>", "<confirm-exit>no</confirm-exit>") ; turning off confirmation on exit
  44. If !StringUtils.InStr(emuSettingsFile.Text,"<exit>" . ExitKey . "</exit>") ; find if this setting is not the desired value
  45. { currentExitKey := StrX(emuSettingsFile.Text,"<exit>" ,0,0,"</exit>",0,0) ; trim confirm-exit to what it's current setting is
  46. emuSettingsFile.Text := StringUtils.Replace(emuSettingsFile.Text,currentExitKey,"<exit>" . ExitKey . "</exit>") ; replacing the current exit key to the desired one from above
  47. }
  48. If !StringUtils.InStr(emuSettingsFile.Text,"<toggle-menu>" . ToggleMenuKey . "</toggle-menu>") ; find if this setting is not the desired value
  49. { currentMenuKey := StrX(emuSettingsFile.Text,"<toggle-menu>" ,0,0,"</toggle-menu>",0,0) ; trim toggle-menu to what it's current setting is
  50. emuSettingsFile.Text := StringUtils.Replace(emuSettingsFile.Text,currentMenuKey,"<toggle-menu>" . ToggleMenuKey . "</toggle-menu>") ; replacing the current toggle-menu key to the desired one from above
  51. }
  52.  
  53. If (forceControls = "true")
  54. {
  55. If StringUtils.InStr(emuSettingsFile.Text,"<auto-select-controllers>yes</auto-select-controllers>") ; find if this setting is not the desired value
  56. emuSettingsFile.Text := StringUtils.Replace(emuSettingsFile.Text,"<auto-select-controllers>yes</auto-select-controllers>","<auto-select-controllers>no</auto-select-controllers>") ; replacing the current toggle-menu key to the desired one from above
  57.  
  58. Loop, 5
  59. {
  60. currentTemp := StrX(emuSettingsFile.Text,"<port-" . A_Index . ">" ,0,0,"</port-" . A_Index . ">",0,0)
  61. port := port%A_Index%
  62.  
  63. If (port = "pad")
  64. port := "pad" . A_Index
  65.  
  66. ;MsgBox,,,% port . " - " . currentTemp
  67.  
  68. emuSettingsFile.Text := StringUtils.Replace(emuSettingsFile.Text,currentTemp,"<port-" . A_Index . ">" . port . "</port-" . A_Index . ">")
  69. }
  70. } Else {
  71. If StringUtils.InStr(emuSettingsFile.Text,"<auto-select-controllers>no</auto-select-controllers>") ; find if this setting is not the desired value
  72. emuSettingsFile.Text := StringUtils.Replace(emuSettingsFile.Text,"<auto-select-controllers>no</auto-select-controllers>","<auto-select-controllers>yes</auto-select-controllers>")
  73. }
  74.  
  75. ; Enable Fullscreen
  76. currentFS := StrX(emuSettingsFile.Text,"<start-fullscreen>" ,0,0,"</start-fullscreen>",0,0) ; trim start-fullscreen to what it's current setting is
  77. emuSettingsFile.Text := StringUtils.Replace(emuSettingsFile.Text,currentFS,"<start-fullscreen>" . ((If Fullscreen = "true")?"yes":"no") . "</start-fullscreen>") ; setting start-fullscreen to the desired setting from above
  78.  
  79. ; Update and save emuSettingsFile
  80. emuSettingsFile.Delete()
  81. emuSettingsFile.Append(emuSettingsFile.Text,"UTF-8")
  82.  
  83. hideEmuObj := Object(emuPrimaryWindow,1)
  84. 7z(romPath, romName, romExtension, sevenZExtractPath)
  85.  
  86. HideAppStart(hideEmuObj,hideEmu)
  87. primaryExe.Run(" """ . romPath . "\" . romName . romExtension . """")
  88. emuPrimaryWindow.Wait()
  89. emuPrimaryWindow.WaitActive()
  90.  
  91. BezelDraw()
  92. HideAppEnd(hideEmuObj,hideEmu)
  93. FadeInExit()
  94. Process("WaitClose", executable)
  95. 7zCleanUp()
  96. BezelExit()
  97. FadeOutExit()
  98. ExitModule()
  99.  
  100.  
  101. HaltEmu:
  102. ; KeyUtils.Send("!{Enter}")
  103. TimerUtils.Sleep(200)
  104. Return
  105. RestoreEmu:
  106. WinActivate, ahk_id %emulatorID%
  107. ; KeyUtils.Send("!{Enter}")
  108. Return
  109.  
  110. CloseProcess:
  111. FadeOutStart()
  112. emuPrimaryWindow.Close()
  113. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement