rfancella

OpenMSX.ahk

Dec 8th, 2014
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.39 KB | None | 0 0
  1. MEmu = OpenMSX
  2. MEmuV = v0.11.0
  3. MURL = http://openmsx.sourceforge.net/
  4. MAuthor = brolly
  5. MVersion = 2.0.1
  6. MCRC = BBF4E5C8
  7. iCRC = C92EFB88
  8. mId = 635403946322405220
  9. MSystem = "Microsoft MSX","Microsoft MSX2","Microsoft MSX2+","Microsoft MSX Turbo-R","Pioneer Palcom LaserDisc"
  10. ;----------------------------------------------------------------------------
  11. ; Notes:
  12. ; Make sure you have the bios for the system/model you are trying to emulate inside share/machines.
  13. ; You can find roms for several systems here: http://www.msxarchive.nl/pub/msx/emulator/
  14. ;
  15. ; For emulating the Pioneer Palcom LaserDisc system you must have the PX-7 bios inside share/machines/Pioneer_PX-7/roms
  16. ;
  17. ; A file named boot_script.txt will be created in your emulator path every time you start a game. If you have any file with the
  18. ; same name there make sure you rename it to something Else or it will get overwritten.
  19. ;
  20. ; About C-BIOS Machines:
  21. ; C-BIOS is a minimal implementation of the MSX BIOS, allowing some games to be played without an original MSX BIOS ROM image.
  22. ; It only supports cart games. It's highly suggested that you use a real machine instead of one of the C-BIOS implementations.
  23. ;
  24. ; Key remapping:
  25. ; If you want to remap any keys you can do it directly on OpenMSX just create a folder named remaps in the emulator folder. Inside
  26. ; that folder create SYSTEMNAME.txt files depending on the system and you can also create a GLOBAL.txt file with remaps that you want
  27. ; to use for any system of this module. Read the emulator docs for details on how to create remaps, for example:
  28. ; bind PAGEUP "set pause on"
  29. ; bind ESCAPE "quit"
  30. ;
  31. ; MSX Turbo-R Machines : Panasonic_FS-A1GT & Panasonic_FS-A1ST
  32. ; MSX2+ Machines : Sony_HB-F1XDJ, Sanyo_PHC-70FD, Sanyo_PHC-70FD2, Sanyo_PHC-35J, Panasonic_FS-A1FX, Panasonic_FS-A1WSX, Panasonic_FS-A1WX
  33. ; MSX Machines with Disk Drives : National_CF-3300 & Gradiente_Expert_DDPlus
  34. ;----------------------------------------------------------------------------
  35. StartModule()
  36. BezelGUI()
  37. FadeInStart()
  38.  
  39. sysTypes := Object("Pioneer Palcom LaserDisc","palcom","Microsoft MSX","msx","Microsoft MSX2","msx2","Microsoft MSX2+","msx2+","Microsoft MSX Turbo-R","turbor")
  40. sysIdent := sysTypes[systemName]
  41. If !sysIdent
  42. ScriptError("Your systemName is: " . systemName . "`nIt is not one of the known supported systems for this OpenMSX module: " . moduleName)
  43.  
  44. defaultMachines := Object("palcom","Pioneer_PX-7","msx","Sony_HB-501P","msx2","Sony_HB-F900","msx2+","Panasonic_FS-A1WSX","turbor","Panasonic_FS-A1GT")
  45. defaultmach := defaultMachines[sysIdent]
  46.  
  47. If (sysIdent = "msx") ;For Disk games in MSX1 we will need a specific model with disk drives
  48. If romExtension in .dsk,.dmk
  49. defaultmach = Gradiente_Expert_DDPlus
  50.  
  51. settingsFile := modulePath . "\" . (If FileExist(modulePath . "\" . systemName . ".ini") ? systemName : moduleName) . ".ini" ; use a custom systemName ini If it exists
  52. Log("SettingsFile is " . settingsFile)
  53.  
  54. Fullscreen := IniReadCheck(settingsFile, "Settings", "Fullscreen","true",,1)
  55. HideConsole := IniReadCheck(settingsFile, "Settings", "HideConsole","true",,1)
  56. FullSpeedWhenLoading := IniReadCheck(settingsFile, "Settings", "FullSpeedWhenLoading","true",,1)
  57. DefaultMachine := IniReadCheck(settingsFile, "Settings", "DefaultMachine",defaultmach,,1)
  58. ScalerAlgorithm := IniReadCheck(settingsFile, "Settings", "ScalerAlgorithm","simple",,1)
  59. ScaleFactor := IniReadCheck(settingsFile, "Settings", "ScaleFactor","2",,1)
  60. ApplyScalerOnFullscreen := IniReadCheck(settingsFile, "Settings", "ApplyScalerOnFullscreen","false",,1)
  61.  
  62. If (sysIdent = "msx") ;For Disk games in MSX1 we will need a specific model with disk drives
  63. {
  64. DefaultMachine := IniReadCheck(settingsFile, romName, "Machine",DefaultMachine,,1)
  65. RomType := IniReadCheck(settingsFile, romName, "RomType","",,1)
  66. ExtensionCart := IniReadCheck(settingsFile, romName, "ExtensionCart","",,1)
  67. DualDiskLoad := IniReadCheck(settingsFile, romName, "DualDiskLoad","false",,1)
  68. DiskSwapDrive := IniReadCheck(settingsFile, romName, "DiskSwapDrive","A",,1)
  69. }
  70.  
  71. GlobalJoystick1 := IniReadCheck(settingsFile, "Settings", "Joystick1","keyjoystick1",,1)
  72. GlobalJoystick2 := IniReadCheck(settingsFile, "Settings", "Joystick2","keyjoystick2",,1)
  73. Joystick1 := IniReadCheck(settingsFile, romName, "Joystick1",GlobalJoystick1,,1)
  74. Joystick2 := IniReadCheck(settingsFile, romName, "Joystick2",GlobalJoystick2,,1)
  75.  
  76. ;Generate a boot_script file
  77. scriptName = boot_script.txt
  78.  
  79. ;Create the user-startup file to launch the game
  80. BootScriptFile := emuPath . "\" . scriptName
  81. FileDelete, %BootScriptFile%
  82.  
  83. BezelStart("fixResMode")
  84.  
  85. If (Fullscreen = "true")
  86. FileAppend, set fullscreen on`n, %BootScriptFile%
  87. Else
  88. FileAppend, set fullscreen off`n, %BootScriptFile%
  89.  
  90. If (FullSpeedWhenLoading = "true")
  91. FileAppend, set fullspeedwhenloading on`n, %BootScriptFile%
  92. Else
  93. FileAppend, set fullspeedwhenloading off`n, %BootScriptFile%
  94.  
  95. If (Fullscreen = "false" OR ApplyScalerOnFullscreen = "true")
  96. {
  97. FileAppend, set scale_algorithm %ScalerAlgorithm%`n, %BootScriptFile%
  98. FileAppend, set scale_factor %ScaleFactor%`n, %BootScriptFile%
  99. }
  100.  
  101. ;hideEmuObj := Object("ahk_class ConsoleWindowClass",0,"openmsx ahk_class ConsoleWindowClass",1) ; Hide_Emu will hide these windows. 0 = will never unhide, 1 = will unhide later
  102. hideEmuObj := Object("ahk_class ConsoleWindowClass",0,"ahk_class SDL_app",1) ; Hide_Emu will hide these windows. 0 = will never unhide, 1 = will unhide later
  103. 7z(romPath, romName, romExtension, 7zExtractPath)
  104.  
  105. If romExtension in .cas,.wav
  106. {
  107. FileAppend, set autoruncassettes on`n, %BootScriptFile%
  108. ;StringReplace, newRompath, rompath, \, /, All ;\ characters are not accepted in the script and must be replaced by /
  109. ;FileAppend, cassetteplayer insert "%newRompath%/%romname%%romextension%"`n, %BootScriptFile%
  110. }
  111.  
  112. If (Joystick1 != none)
  113. FileAppend, plug joyporta %Joystick1%`n, %BootScriptFile%
  114. If (Joystick2 != none)
  115. FileAppend, plug joyportb %Joystick2%`n, %BootScriptFile%
  116.  
  117. If (Joystick1 = "mouse" || Joystick2 = "mouse" || Joystick1 = "trackball" || Joystick2 = "trackball" || Joystick1 = "touchpad" || Joystick2 = "touchpad") {
  118. FileAppend, set grabinput on`n, %BootScriptFile%
  119. FileAppend, escape_grab`n, %BootScriptFile%
  120. }
  121.  
  122. If ExtensionCart ;We should append it to the boot script because using the -ext CLI it will always try to add it to cart slot a unless the config XML specifically says slot 2
  123. If romExtension in .rom,.bin
  124. If (ExtensionCart != "64KBexRAM")
  125. FileAppend, ext %ExtensionCart%`n, %BootScriptFile%
  126.  
  127. ;Read remaps from remaps text files
  128. If FileExist(emuPath . "\remaps\GLOBAL.txt")
  129. Loop, read, %emuPath%\remaps\GLOBAL.txt
  130. FileAppend, %A_LoopReadLine%`n, %BootScriptFile%
  131. If FileExist(emuPath . "\remaps\" . SystemName . ".txt")
  132. Loop, read, %emuPath%\remaps\%SystemName%.txt
  133. FileAppend, %A_LoopReadLine%`n, %BootScriptFile%
  134.  
  135. If (sysIdent = "palcom") {
  136. machinetype = Pioneer_PX-7
  137. mediatype1 = laserdisc
  138. }
  139.  
  140. If (!DefaultMachine)
  141. ScriptError("Machine Type not defined for " . sysIdent)
  142.  
  143. params := " -machine " . DefaultMachine . " -script " . scriptName
  144. If romExtension in .rom,.bin
  145. params := params . " -carta """ . romPath . "\" . romName . romExtension . """"
  146. Else If romExtension in .dsk,.dmk
  147. {
  148. params := params . " -diska """ . romPath . "\" . romName . romExtension . """"
  149. If (DualDiskLoad = "true")
  150. {
  151. If romName contains (Disk 1
  152. {
  153. RomTableCheck() ; make sure romTable is created already so the next line can calculate correctly
  154. If (romtable.MaxIndex() > 1)
  155. {
  156. romName2 := romtable[2,1] ;This should be disk 2
  157. params := params . " -diskb """ . romName2 . """"
  158. }
  159. }
  160. }
  161. If ExtensionCart
  162. params := params . " -ext " . ExtensionCart
  163. } Else If romExtension in .cas,.wav
  164. {
  165. params := params . " -cassetteplayer """ . romPath . "\" . romName . romExtension . """"
  166. If ExtensionCart
  167. params := params . " -ext " . ExtensionCart
  168. }
  169. Else If romExtension = .ogv
  170. params := params . " -laserdisc """ . romPath . "\" . romName . romExtension . """"
  171.  
  172. If RomType
  173. params := params . " -romtype " . RomType
  174.  
  175. HideEmuStart()
  176. Run(executable . params, emuPath)
  177.  
  178. ;WinWait("openmsx ahk_class ConsoleWindowClass")
  179. ;WinWaitActive("openmsx ahk_class ConsoleWindowClass")
  180. WinWait("ahk_class SDL_app")
  181. WinWaitActive("ahk_class SDL_app")
  182.  
  183. If HideConsole = true
  184. WinSet, Transparent, On, ahk_class ConsoleWindowClass ; makes the console window transparent so you don't see it on exit
  185.  
  186. Sleep, 2000 ;Needs this otherwise BezelDraw won't be able to get the correct window dimension
  187. BezelDraw()
  188. HideEmuEnd()
  189. FadeInExit()
  190.  
  191. Process("WaitClose", executable)
  192.  
  193. 7zCleanUp()
  194. BezelExit()
  195. FadeOutExit()
  196. ExitModule()
  197.  
  198. MultiGame:
  199. If romExtension in .cas,.wav
  200. {
  201. StringReplace, newRompath, selectedRom, \, /, All ;\ characters are not accepted in the script and must be replaced by /
  202. Send, {F10} ;Open the console
  203. Send, cassetteplayer insert "%newRompath%" ;Change tape
  204. Send, {Enter}
  205. Send, {F10} ;Close the console
  206. }
  207. Else If romExtension in .dsk,.dmk
  208. {
  209. DriveToUse := If DiskSwapDrive = "A" ? "diska" : "diskb"
  210. StringReplace, newRompath, selectedRom, \, /, All ;\ characters are not accepted in the script and must be replaced by /
  211. Send, {F10} ;Open the console
  212. Send, %DriveToUse% "%newRompath%" ;Change disk
  213. Send, {Enter}
  214. Send, {F10} ;Close the console
  215. }
  216. Return
  217.  
  218. CloseProcess:
  219. FadeOutStart()
  220. ;WinClose("openmsx ahk_class ConsoleWindowClass")
  221. WinClose("ahk_class SDL_app")
  222. Return
Advertisement
Add Comment
Please, Sign In to add comment