Loader:DemulWine

From Wah!ki
Jump to navigation Jump to search

Demul Loader

About

This script loads roms passed from the commandline in Demul. The demul emulator does not currently (v0.5.6) have commanline options for game loading. The autohotkey script somewhat provides this functionality.

For this script to function it requires an ini be present in the emulator directory, this emulator can be built using the script by passing the build option.

An example bash script is included, this provides the full generic commandline.

Installation

  1. Save the AHK script
  2. Setup the AHK script
    • Change Configuration Options a required, refer script comments

Usage

To build the required ini file:

<path to script> build

To launch a title:

<path to script> launch rom_name

Autohotkey Script

; Demul Launcher
; Launch Demul with romname param
; ::Written by sairuk
;
; 20100113.2, 
;	Added warning at runtime
;	Added copy batchfile generation
; 20100113, Added ini modifier
; 20100112, Initial Release
;
;
; Configuration options
executable := "demul.exe" ;Executable to use
emupath := "C:\emulators\demul\" ;Location of the demul executable
;
; LAUNCH
fullscreen := "0" ;Push the emulator into fullscreen
fsmode := "AE" ;Fullscreen mode, AE:ALT+ENTER or F8:F8 key
;
; BUILD
inifile := "demul_launcher" ;INI file for launcher
modifier := "1" ;Set INI compatibility (1:ckergald,-2:Demul55/AWDEMUL)
;
; ADVANCED
filemenu_x := "15" ; file menu X position
filemenu_y := "30" ; file menu Y position
;
;================== Start Script ===================
;
; BuildSystemList(system)
;
; Read through control and write files
;
;
BuildSystemList(system, emupath, inifile, modifier){
	Sleep, 200
	ControlGet, List, List, , SysListView321, Select ROM
	If Errorlevel
		MsgBox, ERROR, Couldn't read list
	Loop, Parse, List, `n
	{
		RowNumber := A_Index
		Loop, Parse, A_LoopField, %A_Tab%
		{	
			if ( A_Index = 1 ) {
				RomName = %A_LoopField%
			} Else if ( A_Index = 5 ) {
				SysDest = %A_LoopField%
			}
		DownCount :=  RowNumber - modifier 		
		}
		;
		; Write INI Files
		IniWrite, %DownCount%, %emupath%%inifile%.ini, %RomName%, Down_Count
		IniWrite, %system%, %emupath%%inifile%.ini, %RomName%, System
		;
		; Make rom copy list
		FileAppend, mkdir roms\%SysDest%\`n, %emupath%%inifile%.bat
		FileAppend, move roms\%RomName%.* roms\%SysDest%\`n, %emupath%%inifile%.bat

	 }
	Send, {ESCAPE}
}
;
; Click on the File Menu (no shortcut keys are available)
;
clickFileMenu(x,y,num,period) {
	Click %x%,%y% ; Click File menu
	Sleep, %period%
	Send, {DOWN %num%}{ENTER}
}
;
;
;
chkSystem(system, emupath, inifile) {
	;==================== Available ====================
	;
	; Naomi
	if (system = "Naomi") { 
		down_keys := "2" 
	}
	;
	; Atomiswave
	Else if (system = "Atomiswave") { 
		down_keys := "3" 
	}
	;
	;xxxxxxxxxxxxxxxxxx Not Available xxxxxxxxxxxxxxxxxx
	;
	; Hikaru
	;Else if (system = "Hikari") { 
	;	down_keys := "4" 
	;}
	;
	; Model 3
	;Else if (system = "Model 3") {
	;	down_keys := "5" 
	;}
	;
	; Saturn
	;Else if (system = "Saturn") { 
	;	down_keys := "6" 
	;}
	Else {
		MsgBox, Could not find romname, you ini may be out of date
		ExitApp	
	}
	;===================================================
	if ( down_keys > 0 ) {
		return down_keys
	}	
}	
;
;
;
buildMe(system, emupath, inifile,filemenu_x,filemenu_y,down_keys,modifier) {
	down_keys := chkSystem(system, emupath, inifile)
	clickFileMenu(filemenu_x,filemenu_y,down_keys,500)
	BuildSystemList(system, emupath, inifile,modifier)
}
;
; Check for params
;
if 0 < 1
{
    MsgBox This script requires a mode be passed to it, options build/launch.
    ExitApp
}
mode = %1%

; Need to check for valid mode
If ( mode = "launch" ) {
	romname = %2%
} Else if ( mode = "build" ) {
	; Delete old support files
	FileDelete, %emupath%%inifile%.ini
	FileDelete, %emupath%%inifile%.bat
	;
	; Create File Headers
	; INI
	FileAppend, ;Demu Launcher INI, %emupath%%inifile%.ini
	; BAT
	FileAppend, @echo off`n, %emupath%%inifile%.bat
} Else {
	MsgBox, ERROR: No ROMNAME specified in launch mode, exiting
	ExitApp
}
;
; Check for the inifile
;
if ( mode = "launch" ) {
	ifNotExist, %emupath%%inifile% 
	{
		MsgBox, Could not find %emupath%%inifile%, Run this script with the build option.
		ExitApp
	} Else {
		;
		; Read Ini settings for current rom
		;
		IniRead, num_down, %emupath%%inifile%, %romname%, Down_Count, 0
		IniRead, system, %emupath%%inifile%, %romname%, System, Atomiswave
	}
}
;
; Start the emulator
;
if (mode = "build") {
	MsgBox, The emulator will close when finished, press OK to continue
}
Run, "%emupath%%executable%", Hide UseErrorLevel
WinActivate %executable%
Sleep, 1000

if (mode = "launch") {
	down_keys := chkSystem(system, emupath, inifile)
	clickFileMenu(filemenu_x,filemenu_y,down_keys,500)
}
If (mode = "build") {
	;==================== Available ====================
	;
	system := "Naomi"
	buildMe(system, emupath, inifile,filemenu_x,filemenu_y,down_keys,modifier)
	system := "Atomiswave"
	buildMe(system, emupath, inifile,filemenu_x,filemenu_y,down_keys,modifier)
	;
	;xxxxxxxxxxxxxxxxxx Not Available xxxxxxxxxxxxxxxxxx
	;
	;system := "Hikaru"
	;buildMe(system, emupath, inifile,filemenu_x,filemenu_y,down_keys,modifier)
	;system := "Model 3"
	;buildMe(system, emupath, inifile,filemenu_x,filemenu_y,down_keys,modifier)
	;system := "Saturn"
	;buildMe(system, emupath, inifile,filemenu_x,filemenu_y,down_keys,modifier)
}
;
; Select Rom
;
Send, {DOWN 3} ; Move into the list
Send, {DOWN %num_down%} ; Send down keystroke to select rom
Send, {ENTER}
;
;
Sleep, 9000 ; Sleep for 9 seconds before going into fullscreen
;
; Fullscreen
;
If ( fullscreen = "1" ) {
	if ( fsmode = "AE" ) {
		Send, {ALTDOWN}{ENTER}{ALTUP}
	}
	Else {
		Send, {F8} ; Go full Screen
	}
}
;
; Exit App
;
If (mode = "Build") {	
	Send, {ALTDOWN}{F4}{ALTUP}
}
Process, WaitClose, %executable%

Bash Script

#!/bin/sh
wine "C:\\Program Files\\AutoHotkey\\AutoHotkey.exe" "C:\\emulators\\demul\\demul_launcher.ahk" $@