TCL in openMSX

صفحة 2/2
1 |

بواسطة ericb59

Paragon (1080)

صورة ericb59

04-05-2022, 08:18

Hi,
I'm using a TCL script to configure a MSX machine, and the emulator.
I use this command line from the shell (macOS) to start the emulator :

openmsx -script MyMsxConfig.tcl -carta mygame.rom

Inside the TCL script i'm using this to retrieve the -carta a parameter and insert the cartridge.

#Search if a ROM is passed as parameter
set cartridge_insert_A [lindex [carta] 1]
machine $MSX_MACHINE

# Insert the ROM as Cartridge Slot A
if {[string trim $cartridge_insert_A] != ""} {
	carta $cartridge_insert_A
}

بواسطة ericb59

Paragon (1080)

صورة ericb59

04-05-2022, 08:29

Hi,

I'm facing a problem that I can't solve.

I'm using a TCL script to start the emulator. The script is configuring the MSX machine and the emulator as I want to be.

I'm using this command line from Shell / Dos to start the emulator

openmsx -script myconfig.tcl -carta mygame.rom

inside the TCL script, I 'm using this code to retrieve the carta parameter and add the cartridge to the emulation:

  #Search if a ROM is passed as parameter
set cartridge_insert_A [lindex [carta] 1]
  #start the MSX
machine $MSX_MACHINE

  # Insert the ROM in Cartridge Slot A
if {[string trim $cartridge_insert_A] != ""} {
	carta $cartridge_insert_A
}

all this works well... My problem is : If i want to retrieve another parameter than "carta", it is not working.
For example I would like to pass the parameter -diska mydisk.dsk

thus, I add this code to retrieve the information:

set floppy_insert_A [lindex [diska] 1]

It is not working and i get the error : invalid command name "diska"

What am I doing wrong ? Is there another way to retrieve my parameters ? oO

بواسطة Manuel

Ascended (18961)

صورة Manuel

04-05-2022, 08:33

You are not retrieving the parameter, but you are looking what is in slot A and then insert it again... Why would you do that?

Anyway, you get this error if there is no disk drive in the emulated MSX.

Note that the order on the command line is relevant. If you also pass an argument that adds a disk drive to a diskless MSX, that may be evaluated later than your script. What is your full command line? Or are you indeed emulating a diskless MSX?

بواسطة ericb59

Paragon (1080)

صورة ericb59

04-05-2022, 10:54

Ok, I misunderstood.

Quote:

Why would you do that?

Because when using this command line, it does not insert the cartridge itself.
openmsx -script myconfig.tcl -carta mygame.rom

This is the full command line I'm using.
So if I understood, adding -diska midis.dsk is not working because the MSX is not yet initialised.

Is there a way to retrieve the parameters inside the TCL script ? arc / argv seems to not be available.

here is the kind of script I'm using. Different script for different MSX/configuration
but I need to pass dynamic values for the cartridge, and/or the floppy disk to insert


filepool add -path Desktop/WorkingFolder/openMSX/share/systemroms -types system_rom
filepool add -path ./openMSX/ -types disk


# _______________________________________________________________________________________
# -- Machine Configuration Variables --
# _______________________________________________________________________________________

# -- Set The MSX Machine to emulate
variable MSX_MACHINE Panasonic_FS-A1GT 

# -- Use Musical Memory Cartridge to have 1024K of RAM : 1=on 0=off
variable USE_MEMORY_1024K 0

# -- Use GFX9000 Video Cartridge : 1=on 0=off
variable USE_GFX9000 0

# -- Use FM PAC FM Cartridge : 1=on 0=off
variable USE_FMPAC 0

# -- Use SCC+ Cartridge : 1=on 0=off
variable USE_SCC 1

# -- Use a Slot Exnansio, Cartridge (To use more than 2 cartridges at same time) : 1=on 0=off
variable USE_EXPANDER 1

# -- Use Fusion-C's OpenMSX skin interface : 1=on 0=off
variable USE_FUSIONSKIN 1

# -- Default Scale Factor (OPenMSX's Window size  : 1, 2, 3)
variable DEFAULT_SCALE 2

# _______________________________________________________________________________________
# -- Drives source folders --
# _______________________________________________________________________________________

# -- Use Floppy Disk drive A : 1=on 0=off
variable USE_FLOPPY_A 1

# -- Use Floppy Disk drive B : 1=on 0=off
variable USE_FLOPPY_B 0

# -- Drive A: Content folders --
variable CONTENT_DSK_FOLDER1 "out/dska/"

# -- Drive B: Content folders --
variable CONTENT_DSK_FOLDER2 "out/dskb/"

# -- ROM content folder --
variable ROM_CONTENT_FOLDER "out/rom/"

# _______________________________________________________________________________________
# -- Export folders --
# _______________________________________________________________________________________

# -- Export folder for DSKA: --
variable CONTENT_EXPORT_DSKA "out/export/dska/"

# -- Export folder for DSKB: --
#variable CONTENT_EXPORT_DSKB "out/export/dskb/"


# _______________________________________________________________________________________
# -- General settings --
# _______________________________________________________________________________________

#-- Video & sound Settings --
set horizontal_stretch 302
set scale_algorithm simple
set scale_factor $DEFAULT_SCALE
set scanline 23
set blur 32
set glow 10
set maxframeskip 3
set master_volue 75
#set mute off
set save_settings_on_exit off
#set auto_enable_reverse off
#disable_reversebar
escape_grab
#set fullspeedwhenloading on

if {$USE_FUSIONSKIN eq "1"} {
	load_icons fusion-c
	set consolebackground skins/ConsoleBackgroundFusionC.png
	set consolecolumns 155
}


# _______________________________________________________________________________________ 
# Keys mapping Configuration
# meta = CMD key on MacOS / Win key on Windows
# _______________________________________________________________________________________

# Press META+CTRL+U Toggle Mute
bind META+CTRL+U "toggle mute"

# Press F11 to cycle from different video-sources if exists
bind F11 cycle videosource						

# Press F12 to Force or release all Mouse/Keyboard inputs grabbed by OpenMSX
bind F12 "toggle grabinput"		
 
# Press ALT+F11 to decrease OpenMSX window
bind ALT+F11 -repeat "incr scale_factor -1"					

# Press ALT+F12 to increase OpenMSX window
bind ALT+F12 -repeat "incr scale_factor 1"			

# Press SHIFT+F11 to decrease emulation Speed 10%
bind SHIFT+F11 -repeat "incr speed -10"							

# Press SHIFT+F12 to increase emulation Speed 10%
bind SHIFT+F12 -repeat "incr speed 10"		

# Press META+W to toggle Power ON/OFF
bind META+W "toggle power"	

# Press META+R to Reset The Emulated MSX
bind META+R reset	

# Press META+Y to Type the content of the file "autoexec.bat" to the MSX DOS windows / Basic Screen
bind META+Y "type_from_file $CONTENT_DSK_FOLDER1/autoexec.bat"	


# _______________________________________________________________________________________

# MSX Machine emulated

#Search if a ROM is passed as parameter
set cartridge_insert_A [lindex [carta] 1]

machine $MSX_MACHINE

# Insert the ROM as Cartridge Slot A
if {[string trim $cartridge_insert_A] != ""} {
	carta $cartridge_insert_A
}


# Plug a Slot Expansion cartridge
if {$USE_EXPANDER eq "1"} {
	ext slotexpander
}	

# Plug The Musical Memory Mapper with 1024K of RAM
if {$USE_MEMORY_1024K eq "1"} {							
	ext Musical_Memory_Mapper
}

# Plug GFX9000 Graphic Interface 
if {$USE_GFX9000 eq "1"} {
	ext gfx9000											
}

# Plug The FMPAC MUSIC Expansion cartridge
if {$USE_FMPAC eq "1"} {
	 ext fmpac
}

# Plug The SCC+ Expansion cartridge
if {$USE_SCC eq "1"} {
	 ext scc+
}
								
# Emulate the Cursors keys as Joystick in MSX's joystick Port A
plug joyporta keyjoystick1								

# Emulate your mouse as a MSX mouse in MSX's joystick port B
plug joyportb mouse 									

# Plug a Simple/Covox Module in the Printer Port. Default Audio output used
plug printerport simpl 									

# Enable The Fusion-C Debug Port. Use it with openMSX Debugger	
debug set_watchpoint read_io 0x2E						
		
# Starting the emulation at Full Speed
set throttle off										

# After 18 OpenMSX clocks (?), the normal speed of the computer is set back to normal
after time 18 "set throttle on"									


# _______________________________________________________________________________________
# Drive & Hard-drive
# _______________________________________________________________________________________



if {$USE_FLOPPY_A eq "1"} {
	diska $CONTENT_DSK_FOLDER1 										
}
if {$USE_FLOPPY_B eq "1"} {
	diskb $CONTENT_DSK_FOLDER2 									
}


بواسطة Manuel

Ascended (18961)

صورة Manuel

04-05-2022, 13:49

Looks like you get a default machine, then you look which cart is in slot a, then change machine and then insert it in the different machine.
So this scheme goes wrong if the default machine doesn't have a disk drive.

By the way, after time 18 means after 18 seconds of time in the emulated MSX.

بواسطة ericb59

Paragon (1080)

صورة ericb59

04-05-2022, 15:59

OK. I finally understood !
Thank you Wink

بواسطة Manuel

Ascended (18961)

صورة Manuel

04-05-2022, 19:56

How did you solve it?

بواسطة ericb59

Paragon (1080)

صورة ericb59

04-05-2022, 20:29

I understood I do not have to include "machine Panasonic_FS-A1GT" inside the TCL script, but add it to the command shell command line

openmsx -machine Panasonic_FS-A1GT -script myconfig.tcl -carta mygame.rom 

Thus, no more need to check carta or diska no more.

بواسطة Manuel

Ascended (18961)

صورة Manuel

04-05-2022, 21:44

That will certainly work better indeed, I hope it fits your use case.

صفحة 2/2
1 |