; 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