msxbuild/lib/openmsx/share/scripts/boot_env.tcl

109 lines
2.8 KiB
Tcl
Raw Normal View History

2020-12-23 17:14:13 +00:00
# boot_env -- Sets various openMSX settings based from environment variables.
#
# Typically used in automation tools which run openMSX without human interaction.
2024-06-28 17:04:15 +00:00
#
# Adds the following command to openMSX;
#
# 'boot_gui_mode'
# Enableds the renderer and throttle from the inside.
#
2020-12-23 17:14:13 +00:00
# Supported environment variables by this script;
#
2024-06-28 17:04:15 +00:00
# RENDERER=on|off
# Override video output from command line.
2020-12-23 17:14:13 +00:00
#
2024-06-28 17:04:15 +00:00
# RENDERER_TYPE=SDL
# Select video renderer type.
#
2024-06-21 22:45:48 +00:00
# SCALE_FACTOR=3
# Override video scale factor for SDL renderer.
#
2020-12-23 17:14:13 +00:00
# THROTTLE=off
# Disables msx speed emulation.
#
# SPEED=400
# Sets msx speed to 4x of original but only when throttle is on.
#
# JOYPORTA=mouse
# Inserts mouse in joyporta.
#
# JOYPORTB=mouse
# Inserts mouse in joyportb.
#
2024-06-28 12:31:06 +00:00
# RECORDER=bin/output.avi
# Enables the the video recorder.
#
2020-12-23 17:14:13 +00:00
2024-06-28 17:04:15 +00:00
# Enabled openMSX gui from inside
proc boot_gui_mode {} {
global renderer
global throttle
global boot_env_renderer_type
if {$boot_env_renderer_type != 0} {
set renderer $boot_env_renderer_type
set throttle on
2024-06-28 17:10:24 +00:00
} else {
puts stderr "error: Requested boot_gui_mode but env.RENDERER_TYPE is missing."
exit 1
2024-06-28 17:04:15 +00:00
}
}
# Globals
set boot_env_renderer_type 0
if {[info exists ::env(RENDERER_TYPE)] && ([string trim $::env(RENDERER_TYPE)] != "")} {
set boot_env_renderer_type [string trim $::env(RENDERER_TYPE)]
}
if {[info exists ::env(RENDERER)] && ([string trim $::env(RENDERER)] == "on")} {
if {[catch {set renderer $boot_env_renderer_type} err_msg]} {
2020-12-23 17:14:13 +00:00
puts stderr "error: env.RENDERER value $err_msg"
exit 1
}
}
if {[info exists ::env(SCALE_FACTOR)] && ([string trim $::env(SCALE_FACTOR)] != "")} {
if {[catch {set scale_factor [string trim $::env(SCALE_FACTOR)]} err_msg]} {
puts stderr "error: env.SCALE_FACTOR value $err_msg"
exit 1
}
}
2020-12-23 17:14:13 +00:00
if {[info exists ::env(THROTTLE)] && ([string trim $::env(THROTTLE)] != "")} {
if {[catch {set throttle [string trim $::env(THROTTLE)]} err_msg]} {
puts stderr "error: env.THROTTLE value $err_msg"
exit 1
}
}
if {[info exists ::env(SPEED)] && ([string trim $::env(SPEED)] != "")} {
if {[catch {set speed [string trim $::env(SPEED)]} err_msg]} {
puts stderr "error: env.SPEED value $err_msg"
exit 1
}
}
if {[info exists ::env(JOYPORTA)] && ([string trim $::env(JOYPORTA)] != "")} {
if {[catch {plug joyporta [string trim $::env(JOYPORTA)]} err_msg]} {
puts stderr "error: env.JOYPORTA value $err_msg"
exit 1
}
}
if {[info exists ::env(JOYPORTB)] && ([string trim $::env(JOYPORTB)] != "")} {
if {[catch {plug joyportb [string trim $::env(JOYPORTB)]} err_msg]} {
puts stderr "error: env.JOYPORTB value $err_msg"
exit 1
}
}
2024-06-28 12:31:06 +00:00
if {[info exists ::env(RECORDER)] && ([string trim $::env(RECORDER)] != "")} {
if {[catch {after time 1 "record start -prefix [string trim $::env(RECORDER)]"} err_msg]} {
2024-06-28 12:31:06 +00:00
puts stderr "error: env.RECORDER value $err_msg"
exit 1
}
after quit {
record stop
}
}