If Control = JoyPort1
	Set_CFG_Value(%dbpath%\GameBase Amiga.uae||joyport0||kbd4)
	Set_CFG_Value(%dbpath%\GameBase Amiga.uae||joyport1||kbd5)
	Set_CFG_Value(%dbpath%\WHDLoad.uae||joyport0||kbd4)
	Set_CFG_Value(%dbpath%\WHDLoad.uae||joyport1||kbd5)

Else
	Set_CFG_Value(%dbpath%\GameBase Amiga.uae||joyport0||mouse1)
	Set_CFG_Value(%dbpath%\GameBase Amiga.uae||joyport1||kbd4)
	Set_CFG_Value(%dbpath%\WHDLoad.uae||joyport0||mouse1)
	Set_CFG_Value(%dbpath%\WHDLoad.uae||joyport1||kbd4)

End If

Set_CFG_Value(%dbpath%\GameBase Amiga.uae||kickstart_rom||%kickstart_rom_value%)
Set_CFG_Value(%dbpath%\GameBase Amiga.uae||nr_floppies||%nr_floppies_value%)
Set_CFG_Value(%dbpath%\GameBase Amiga.uae||floppy0type||%floppy0type_value%)
Set_CFG_Value(%dbpath%\GameBase Amiga.uae||floppy1type||%floppy1type_value%)
Set_CFG_Value(%dbpath%\GameBase Amiga.uae||floppy2type||%floppy2type_value%)
Set_CFG_Value(%dbpath%\GameBase Amiga.uae||floppy3type||%floppy3type_value%)
Set_CFG_Value(%dbpath%\GameBase Amiga.uae||immediate_blits||%immediate_blits_value%)
Set_CFG_Value(%dbpath%\GameBase Amiga.uae||ntsc||%ntsc_value%)
Set_CFG_Value(%dbpath%\GameBase Amiga.uae||chipset||%chipset_value%)
Set_CFG_Value(%dbpath%\GameBase Amiga.uae||collision_level||%collision_level_value%)
Set_CFG_Value(%dbpath%\GameBase Amiga.uae||fastmem_size||%fastmem_size_value%)
Set_CFG_Value(%dbpath%\GameBase Amiga.uae||bogomem_size||%bogomem_size_value%)
Set_CFG_Value(%dbpath%\GameBase Amiga.uae||chipmem_size||%chipmem_size_value%)
Set_CFG_Value(%dbpath%\GameBase Amiga.uae||cpu_speed||%cpu_speed_value%)
Set_CFG_Value(%dbpath%\GameBase Amiga.uae||cpu_model||%cpu_model_value%)
Set_CFG_Value(%dbpath%\GameBase Amiga.uae||cpu_compatible||%cpu_compatible_value%)
Set_CFG_Value(%dbpath%\GameBase Amiga.uae||cycle_exact||%cycle_exact_value%)
Set_CFG_Value(%dbpath%\GameBase Amiga.uae||chipset_compatible||%chipset_compatible_value%)
Set_CFG_Value(%dbpath%\GameBase Amiga.uae||cpu_24bit_addressing||%cpu_24bit_addressing_value%)
Set_CFG_Value(%dbpath%\GameBase Amiga.uae||statefile||%statefile_value%)

If VersionComment CONTAINS(WHD)
	Set_CFG_Item(%dbpath%\WHDLoad.uae||filesystem2=rw,DH0:DH0||:||%dbpath%\whd,0)
	Set_CFG_Item(%dbpath%\WHDLoad.uae||filesystem=rw,DH0||:||%dbpath\whd)
	Set_CFG_Item(%dbpath%\WHDLoad.uae||filesystem2=rw,DH1:DH1||:||%gbgamepath%\rezip\%gamefilenoext%,0)
	Set_CFG_Item(%dbpath%\WHDLoad.uae||filesystem=rw,DH1||:||%gbgamepath%\rezip\%gamefilenoext%)
	Set_CFG_Item(%dbpath%\WHD\s\user-startup||cd||||%cd_value%)
	Set_CFG_Item(%dbpath%\WHD\s\user-startup||whdload||||%whdload_value%)
	Set_CFG_Value(%dbpath%\WHDLoad.uae||immediate_blits||%immediate_blits_value%)
	Set_CFG_Value(%dbpath%\WHDLoad.uae||chipset_compatible||%chipset_compatible_value%)
	Set_CFG_Value(%dbpath%\WHDLoad.uae||collision_level||%collision_level_value%)
	Set_CFG_Value(%dbpath%\WHDLoad.uae||z3mem_size||%z3mem_size_value%)
	Set_CFG_Value(%dbpath%\WHDLoad.uae||cpu_speed||%cpu_speed_value%)
	Set_CFG_Value(%dbpath%\WHDLoad.uae||finegrain_cpu_speed||%finegrain_cpu_speed_value%)
	Set_CFG_Value(%dbpath%\WHDLoad.uae||cpu_type||%cpu_type_value%)
	Set_CFG_Value(%dbpath%\WHDLoad.uae||fpu_model||%fpu_model_value%)
	Set_CFG_Value(%dbpath%\WHDLoad.uae||cpu_compatible||%cpu_compatible_value%)
	Set_CFG_Value(%dbpath%\WHDLoad.uae||fpu_strict||%fpu_strict_value%)
	Set_CFG_Value(%dbpath%\WHDLoad.uae||cpu_24bit_addressing||%cpu_24bit_addressing_value%)
	Set_CFG_Value(%dbpath%\WHDLoad.uae||cpu_cycle_exact||%cpu_cycle_exact_value%)
	Set_CFG_Value(%dbpath%\WHDLoad.uae||blitter_cycle_exact||%blitter_cycle_exact_value%)
	Run_Program(%dbpath%\whdrun.exe||%gamepathfile% %gbgamepath%\rezip\%gamefilenoext%/ "%emupath%\winuae.exe" "%dbpath%\WHDLoad.uae" "%dbpath%\WHD\s\user-startup||nowait)


	If PalNTSC = NTSC
		Set_CFG_Value(%dbpath%\WHDLoad.uae||ntsc||true)
	Else

		Set_CFG_Value(%dbpath%\WHDLoad.uae||ntsc||false)

	End If

Else

	Add_CLP(-f "%dbpath%\GameBase Amiga.uae" -0%gamepathfile% -1%gamepathfile(1)% -2%gamepathfile(2)% -3%gamepathfile(3)% -s diskimage0=%gamepathfile% -s diskimage1=%gamepathfile(1)% -s diskimage2=%gamepathfile(2)% -s diskimage3=%gamepathfile(3)% -s diskimage4=%gamepathfile(4)% -s diskimage5=%gamepathfile(5)% -s diskimage6=%gamepathfile(6)% -s diskimage7=%gamepathfile(7)% -s diskimage8=%gamepathfile(8)% -s diskimage9=%gamepathfile(9)% -s diskimage10=%gamepathfile(10)% -s diskimage11=%gamepathfile(11)% -s diskimage12=%gamepathfile(12)% -s diskimage13=%gamepathfile(13)% -s diskimage14=%gamepathfile(14)% -s diskimage15=%gamepathfile(15)% -s diskimage16=%gamepathfile(16)% -s diskimage17=%gamepathfile(17)% -s diskimage18=%gamepathfile(18)% -s diskimage19=%gamepathfile(19)%)

	Run_Emulator()

End If