Key-Value example

I want to show you what I'm doing some evenings in my spare time.
At first I want to say that this is ONLY A PRIVATE HOBBY PROJECT, I don't want to "kill" eCC, But eventually wake up Andreas a bit ;-)

Moderator: DerMicha75

User avatar
DerMicha75
ECC2 (java) Developer
Posts: 521
Joined: 05 Feb 2007, 22:14
Location: Germany
Contact:

Key-Value example

Unread post by DerMicha75 » 27 Jan 2013, 23:26

Hi,

with this post I'll try to explain how to use the key/value feature. I tested this with the ScummVM platform. The given keywords are working, but maybe you want to add more...

In the platform configuration I added these lines:

Code: Select all

fullscreen=false
gfxmode=3x
subtitles=false
In every game you now can overwrite the settings by simple add a line to the configuration. I love Monkey Island and I want to show this in fullscreen. So I entered in meta of Monkey Island this:

Code: Select all

fullscreen=true
I configured the emulator to use a script. This means, a file called eccScriptRom.dat is written with all configuration. There you will find a section like this:

Code: Select all

[KEY_VALUE]
key_fullscreen = "false"
key_subtitles = "false"
key_gfxmode = "3x"
The keys start with key_ to avoid conflics with other variables. For Monkey Island it looks like

Code: Select all

[KEY_VALUE]
key_fullscreen = "true"
key_subtitles = "false"
key_gfxmode = "3x"
So now we need a script to recognize these variables and do some things. Inside the script there is the following code:

Code: Select all

$command = "--no-console -p" & $folder & "\unpacked\svm\" & $crc32
$fullscreen = IniRead($folder & "\scripts\eccScriptRom.dat", "KEY_VALUE", "key_fullscreen", "")
If $fullscreen = "true" Then
	$command = $command & " --fullscreen"
Else
	$command = $command & " --no-fullscreen"
EndIf
This code builds up a commandline. When the variable $fullscreen is true, it adds a --fullscreen to the commandline. Thats all...

Here is the complete script for ScummVM:

Code: Select all

; Platform        : ScummVM
; Script for      : ScummVM 1.5.0
; Script version  : v2.0.0.0
; Last changed    : 2013.01.27
;
; Authors: S. Ebeltjes (aka Phoenix), DerMicha75
;
; NOTES: 
; - This script needs packed ScummVM games.
; - The ScummVM GameID has to be placed in the metadata field ID.
; - In options you have to activate all 4 checkboxes in "Archive handling"
;
; ==============================================================================
#include "..\eccScriptSystem.au3"
; ==============================================================================

; ------------------------------------------------------------------------------
; Check if the 'Info-Id' field is filled
; ------------------------------------------------------------------------------

If $info_id = "" Then
	MsgBox(64, "ECC ScummVM", "This script only works if the 'Info-Id' field is filled in with the gamename to start. You can find the correct names in readme.txt inside ScummVM dir.")
	Exit
EndIf

;-------------------------------------------------------------------------------
; Build the commandline
;-------------------------------------------------------------------------------

$command = "--no-console -p" & $folder & "\unpacked\svm\" & $crc32
$fullscreen = IniRead($folder & "\scripts\eccScriptRom.dat", "KEY_VALUE", "key_fullscreen", "")
If $fullscreen = "true" Then
	$command = $command & " --fullscreen"
Else
	$command = $command & " --no-fullscreen"
EndIf

$subtitles = IniRead($folder & "\scripts\eccScriptRom.dat", "KEY_VALUE", "key_subtitles", "")
If $subtitles = "true" Then
	$command = $command & " --subtitles"
Else
	$command = $command & " --no-subtitles"
EndIf

$gfxmode = IniRead($folder & "\scripts\eccScriptRom.dat", "KEY_VALUE", "key_gfxmode", "")
$command = $command & " --gfx-mode=" & $gfxmode

; ------------------------------------------------------------------------------
; Run the emulator.
; ------------------------------------------------------------------------------

ShellExecute($emulator, $command & " " & $info_id, "", "")

; ------------------------------------------------------------------------------
; END OF SCRIPT
; ------------------------------------------------------------------------------

Exit
Micha

User avatar
Phoenix
ECC Developer 2006-2016
Posts: 9057
Joined: 27 Aug 2006, 01:17
Location: Deventer, The Netherlands
Contact:

Re: Key-Value example

Unread post by Phoenix » 28 Jan 2013, 20:26

Nice feature! :thumb:

I've "compressed" the script further (does the same, but a bit shorter)

Code: Select all

; Platform        : ScummVM
; Script for      : ScummVM 1.5.0
; Script version  : v2.0.0.0b
; Last changed    : 2013.01.27
;
; Authors: S. Ebeltjes (aka Phoenix), DerMicha75
;
; NOTES: 
; - This script needs packed ScummVM games.
; - The ScummVM GameID has to be placed in the metadata field ID.
; - In options you have to activate all 4 checkboxes in "Archive handling"
;
#include "..\eccScriptSystem.au3"

If $info_id = "" Then
   MsgBox(64, "ECC ScummVM", "This script only works if the 'Info-Id' field is filled in with the gamename to start. You can find the correct names in readme.txt inside ScummVM dir.")
   Exit
EndIf

$scriptromfile = $folder & "\scripts\eccScriptRom.dat"
$command = "--no-console -p" & $folder & "\unpacked\svm\" & $crc32

$fullscreen = IniRead($scriptromfile, "KEY_VALUE", "key_fullscreen", "")
If $fullscreen = "true" Then $command = $command & " --fullscreen"
If $fullscreen <> "true" Then $command = $command & " --no-fullscreen"

$subtitles = IniRead($scriptromfile, "KEY_VALUE", "key_subtitles", "")
If $subtitles = "true" Then $command = $command & " --subtitles"
If $subtitles <> "true" Then $command = $command & " --no-subtitles"

$gfxmode = IniRead($scriptromfile, "KEY_VALUE", "key_gfxmode", "")
$command = $command & " --gfx-mode=" & $gfxmode

ShellExecute($emulator, $command & " " & $info_id, "", "")
Exit
Sebastiaan Ebeltjes | ECC Developer 2006-2016 | ECC Forum Admin | Phoenix Interactive WebMaster
[- ECC programs -]
eccUpdate, eccScriptSystem, GtkThemeSelect, DatFileUpdater (DFU), ImagePackCenter (IPC), eccDiagnostics, 3dGallery, iccImageInject
eccKameleonCode, eccCreateStartmenuShotcut, eccThirdPartyConfig (TPC), EmuMoviesDownloader (EMD), eccVideoPlayer
MobyGamesImporter (MGI), ECC Amiga GetGemusConfig.

User avatar
Vicman
PLATINUM member
Posts: 1233
Joined: 17 Jun 2007, 16:12
Location: Germany,Bochum

Re: Key-Value example

Unread post by Vicman » 31 Mar 2013, 12:29

can you give me an example how to write / rewrite the script for the vic20 ? :surrender:

or maybe you can write the script for me ?
imagepacks:
Done: Vic20, N64, Philips VG-5000 G7000 G7400, SordM5, Amstrad GX4000, Enterprise 64/128
Progress: Atari 8bit, Dosbox, Exelvision EXL 100
Vicman's eCC-Clips on You Tube

User avatar
Vicman
PLATINUM member
Posts: 1233
Joined: 17 Jun 2007, 16:12
Location: Germany,Bochum

Re: Key-Value example

Unread post by Vicman » 07 Dec 2013, 10:37

*push*....

Any chance to get a script for the Vic-20 with key_values ?

here's the old vic-20 script :
Spoiler: show
; Platform : Commodore VIC-20
; Script for : VICE emulator (xvic.exe) (tested with v2.3.x)
; Script version : v2.2.0.1
; Last changed : 2012.11.06
;
; Author : Sebastiaan Ebeltjes (aka Phoenix)
;
; NOTES:
;
; Nothing yet!
;
; ==============================================================================
; You need to implent this block in every script, this changes the workfolder to
; the folder where this script is executed, and loads the 'eccScriptSystem' script.
FileChangeDir(@ScriptDir)
#include "..\eccScriptSystem.au3"
; ==============================================================================

; ------------------------------------------------------------------------------
; BEGIN OF SCRIPT
; ------------------------------------------------------------------------------
; SET additional variables for script
Global $VicIni = $eccEmuEmulatorPath & "vice.ini"
Global $VicCommandline = " "

; Check if the 'Meta-Info ID' field is filled in.
If $eccMetaInfoId = "" Then ; META INFO ID is not present
; Check if 'PrgInfo.exe' exists in the script folder
If FileExists($eccSystemEccFolder & "\ecc-script\vic20\PrgInfo.exe") <> 1 Then
MsgBox(0, $eccSystemName, "PRG Info '" & $eccSystemEccFolder & "\ecc-script\vic20\PrgInfo.exe' not found!")
Exit
EndIf

;First we need to 'catch' the right setting from 'PRGInfo'
Run(@ScriptDir & "\PrgInfo.exe " & $RomFile) ; start 'PRGInfo' (using chr34 to put rom in quotes)
WinWait("PRGInfo ", "", 10) ; wait until 'PRGInfo' is loaded
$prg_info = WinGetText("PRGInfo ", "") ; Get the text from the PRG info windows and put it in a variable
WinClose("PRGInfo ", "") ; close 'PRGinfo'

; Get the 'cpu settings' string from 'PRGinfo'
For $search_cpu = 1 to StringLen($prg_info)
If StringMid($prg_info, $search_cpu, 14) = "--------------" Then ; Check if string is found
$search_cpu_found = $search_cpu + 16 ; go 2 bytes further to get the good 'cpu string'
EndIf
Next

; ROM files
If StringMid($prg_info, $search_cpu_found, 8) = "Vic20 4K" Then $VicCommandline = $VicCommandline & "-memory 3k "
If StringMid($prg_info, $search_cpu_found, 8) = "Vic20 8K" Then $VicCommandline = $VicCommandline & "-memory 8k "
; BASIC files
If StringMid($prg_info, $search_cpu_found, 16) = "Unexpanded Vic20" Then $VicCommandline = $VicCommandline & "-memory none "
If StringMid($prg_info, $search_cpu_found, 13) = "Vic20 with 3K" Then $VicCommandline = $VicCommandline & "-memory 3k "
If StringMid($prg_info, $search_cpu_found, 13) = "Vic20 with 8K" Then $VicCommandline = $VicCommandline & "-memory 8k "
If StringMid($prg_info, $search_cpu_found, 14) = "Vic20 with 16K" Then $VicCommandline = $VicCommandline & "-memory 16k "
If StringMid($prg_info, $search_cpu_found, 14) = "Vic20 with 24K" Then $VicCommandline = $VicCommandline & "-memory 24k "
; Other
If StringMid($prg_info, $search_cpu_found, 26) = "Vic20 With Super Expander" Then $VicCommandline = $VicCommandline & "-memory 8k "
If StringMid($prg_info, $search_cpu_found, 46) = "Vic20 graphics memory (standard 5K) or C64/128" Then $VicCommandline = $VicCommandline & "-memory 8k "
If StringMid($prg_info, $search_cpu_found, 42) = "Commodore64/128 or Vic20 with 3K expansion" Then $VicCommandline = $VicCommandline & "-memory 3k "
; Not supported
If StringMid($prg_info, $search_cpu_found, 13) = "Commodore 128" Then
MsgBox(0, $eccSystemName, "No setting found for 'Commodore 128 (Or expanded Vic20 with altered basic memory address)'")
Exit
EndIf
If StringMid($prg_info, $search_cpu_found, 64) = "Expanded Vic20, saved from manually altered basic memory address" Then
MsgBox(0, $eccSystemName, "No setting found for 'Expanded Vic20, saved from manually altered basic memory address'")
Exit
EndIf
If StringMid($prg_info, $search_cpu_found, 12) = "Commodore 64" Then
MsgBox(0, $eccSystemName, "No setting found for 'Commodore 64 (Or Expanded Vic20, saved from manually altered basic memory address)'")
Exit
Endif
If StringMid($prg_info, $search_cpu_found, 30) = "Cassette buffer or sprite data" Then
MsgBox(0, $eccSystemName, "No setting found for 'Cassette buffer or sprite data'")
Exit
EndIf
If StringMid($prg_info, $search_cpu_found, 16) = "Commodore 64/128" Then
MsgBox(0, $eccSystemName, "No setting found for 'Commodore 64/128'")
Exit
EndIf
Else
; META INFO ID is present
; Get information to run in NTSC or PAL.
If StringInStr($eccMetaInfoId, "[ntsc]") Then $VicCommandline = $VicCommandline & "-ntsc "
If StringInStr($eccMetaInfoId, "[pal]") Then $VicCommandline = $VicCommandline & "-pal "

; Set memorybanks for VIC-20
If StringInStr($eccMetaInfoId, "[unexp]") Then $VicCommandline = $VicCommandline & "-memory none "
If StringInStr($eccMetaInfoId, "[all]") Then $VicCommandline = $VicCommandline & "-memory all "
If StringInStr($eccMetaInfoId, "[3k]") Then $VicCommandline = $VicCommandline & "-memory 3k "
If StringInStr($eccMetaInfoId, "[8k]") Then $VicCommandline = $VicCommandline & "-memory 8k "
If StringInStr($eccMetaInfoId, "[16k]") Then $VicCommandline = $VicCommandline & "-memory 16k "
If StringInStr($eccMetaInfoId, "[24k]") Then $VicCommandline = $VicCommandline & "-memory 24k "
If StringInStr($eccMetaInfoId, "[Block1,5]") Then $VicCommandline = $VicCommandline & "-memory 1,5 "

If StringInStr($eccMetaInfoId, "[multi]") Then
; Settings for MULTI catridges
If StringInStr($eccFileEccUnpackedFile, "[A000]") Then $MultiStringAvailable = "[A000]"
If StringInStr($eccFileEccUnpackedFile, "[B000]") Then $MultiStringAvailable = "[B000]"
If StringInStr($eccFileEccUnpackedFile, "[2000]") Then $MultiStringAvailable = "[2000]"
If StringInStr($eccFileEccUnpackedFile, "[4000]") Then $MultiStringAvailable = "[4000]"
If StringInStr($eccFileEccUnpackedFile, "[6000]") Then $MultiStringAvailable = "[6000]"

If StringInStr($eccMetaInfoId, "[a0]") Then
Global $RomFile_a0 = StringReplace($eccFileEccUnpackedFile, $MultiStringAvailable, "[A000]")
$VicCommandline = $VicCommandline & "-cartA " & Chr(34) & $eccFileEccUnpackedPath & $RomFile_a0 & Chr(34) & " "
EndIf

If StringInStr($eccMetaInfoId, "[b0]") Then
Global $RomFile_b0 = StringReplace($eccFileEccUnpackedFile, $MultiStringAvailable, "[B000]")
$VicCommandline = $VicCommandline & "-cartB " & Chr(34) & $eccFileEccUnpackedPath & $RomFile_b0 & Chr(34) & " "
EndIf

If StringInStr($eccMetaInfoId, "[20]") Then
Global $RomFile_20 = StringReplace($eccFileEccUnpackedFile, $MultiStringAvailable, "[2000]")
$VicCommandline = $VicCommandline & "-cart2 " & Chr(34) & $eccFileEccUnpackedPath & $RomFile_20 & Chr(34) & " "
EndIf

If StringInStr($eccMetaInfoId, "[40]") Then
Global $RomFile_40 = StringReplace($eccFileEccUnpackedFile, $MultiStringAvailable, "[4000]")
$VicCommandline = $VicCommandline & "-cart4 " & Chr(34) & $eccFileEccUnpackedPath & $RomFile_40 & Chr(34) & " "
EndIf

If StringInStr($eccMetaInfoId, "[60]") Then
Global $RomFile_60 = StringReplace($eccFileEccUnpackedFile, $MultiStringAvailable, "[6000]")
$VicCommandline = $VicCommandline & "-cart6 " & Chr(34) & $eccFileEccUnpackedPath & $RomFile_60 & Chr(34) & " "
EndIf

Else
; Settings for SINGLE catridges
If StringInStr($eccMetaInfoId, "[a0]") Then $VicCommandline = $VicCommandline & "-cartA "
If StringInStr($eccMetaInfoId, "[b0]") Then $VicCommandline = $VicCommandline & "-cartB "
If StringInStr($eccMetaInfoId, "[20]") Then $VicCommandline = $VicCommandline & "-cart2 "
If StringInStr($eccMetaInfoId, "[40]") Then $VicCommandline = $VicCommandline & "-cart4 "
If StringInStr($eccMetaInfoId, "[60]") Then $VicCommandline = $VicCommandline & "-cart6 "
$VicCommandline = $VicCommandline & $RomFile
EndIf
EndIf

Run($Emulator & " " & $VicCommandline)
ToolTip("Running script, please wait...", @DesktopWidth/2, @DesktopHeight/2, "XVIC Script", 1, 6)

If StringInStr($eccMetaInfoId, "[sys") Then ;Autoload the ROM
;Get the SYS value
$SysValueRaw1 = StringSplit($eccMetaInfoId, "[sys", 1)
$SysValueRaw2 = StringSplit($SysValueRaw1[2], "]", 1)
Global $SysValue = $SysValueRaw2[1]

AutoItSetOption("SendKeyDownDelay", 300)
EmuWindowControl("VICE: VIC20", 0)

; Load GAME ROM
If $eccFileRomExtension = "crt" Then
Sleep(4000) ;CRT load faster.
Else
Sleep(8000) ;PRG (and others?) load slower.
EndIf

Global $KBLayout = GetActiveKeyboardLayout(WinGetHandle(''))
If $KBLayout = "0407" Or $KBLayout = "1407" Or $KBLayout = "1007" Or $KBLayout = "807" Then
Send("szs" & $SysValue) ;Keyboardsetting for Germany, QWERTZ keyboard layout (Z=Y)
Else
Send("sys" & $SysValue) ;Keyboardsetting for most users, QWERTY keyboard layout
EndIf

Send("{ENTER}")
EndIf

ToolTip("")
; ------------------------------------------------------------------------------
; END OF SCRIPT
; ------------------------------------------------------------------------------
Exit
imagepacks:
Done: Vic20, N64, Philips VG-5000 G7000 G7400, SordM5, Amstrad GX4000, Enterprise 64/128
Progress: Atari 8bit, Dosbox, Exelvision EXL 100
Vicman's eCC-Clips on You Tube

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest