2024-07-01 09:57:30 +00:00
|
|
|
# headless -- Control openMSX in headless mode.
|
2020-12-23 17:14:13 +00:00
|
|
|
#
|
2024-07-01 09:57:30 +00:00
|
|
|
# Adds the following commands to openMSX;
|
2024-06-28 17:04:15 +00:00
|
|
|
#
|
2024-06-30 11:56:18 +00:00
|
|
|
# 'headless_exit'
|
|
|
|
# A normal exit of the openMSX emulator.
|
|
|
|
#
|
2024-06-30 11:52:33 +00:00
|
|
|
# 'headless_show_gui'
|
2024-06-29 02:46:30 +00:00
|
|
|
# Enables the renderer and throttle from the inside.
|
2024-06-28 17:04:15 +00:00
|
|
|
#
|
2020-12-23 17:14:13 +00:00
|
|
|
# Supported environment variables by this script;
|
|
|
|
#
|
2024-06-29 03:07:15 +00:00
|
|
|
# HEADLESS=on|off
|
2024-06-20 22:41:11 +00:00
|
|
|
# Override video output from command line.
|
2020-12-23 17:14:13 +00:00
|
|
|
#
|
2024-06-29 03:07:15 +00:00
|
|
|
# RENDERER=SDL
|
2024-06-29 13:47:52 +00:00
|
|
|
# Select video renderer type for GUI mode or in none headless mode.
|
2024-06-28 17:04:15 +00:00
|
|
|
#
|
2024-06-21 22:45:48 +00:00
|
|
|
# SCALE_FACTOR=3
|
2024-06-29 13:47:52 +00:00
|
|
|
# Override video scale factor for the renderer.
|
2024-06-21 22:45:48 +00:00
|
|
|
#
|
2020-12-23 17:14:13 +00:00
|
|
|
# THROTTLE=off
|
2024-06-29 13:47:52 +00:00
|
|
|
# Disables MSX speed emulation.
|
2020-12-23 17:14:13 +00:00
|
|
|
#
|
2024-06-29 13:47:52 +00:00
|
|
|
# SPEED=333
|
|
|
|
# Sets CPU speed to relative from normal but only when throttle is on.
|
2024-06-27 18:14:23 +00:00
|
|
|
#
|
2020-12-23 17:14:13 +00:00
|
|
|
|
2024-06-30 14:23:47 +00:00
|
|
|
set headless_renderer_type 0
|
|
|
|
set headless_renderer_done 0
|
2024-06-29 13:47:52 +00:00
|
|
|
|
2024-06-30 11:56:18 +00:00
|
|
|
proc headless_exit {} {
|
|
|
|
after time 1 "exit 0"
|
2024-07-02 13:34:26 +00:00
|
|
|
return "mb::head shutdown openMSX"
|
2024-06-30 11:56:18 +00:00
|
|
|
}
|
|
|
|
|
2024-06-30 23:12:51 +00:00
|
|
|
proc headless_reset {} {
|
|
|
|
after time 1 "reset"
|
2024-07-02 13:34:26 +00:00
|
|
|
return "mb::head reboot openMSX"
|
2024-06-30 23:12:51 +00:00
|
|
|
}
|
|
|
|
|
2024-06-30 11:52:33 +00:00
|
|
|
proc headless_show_gui {} {
|
2024-06-28 17:04:15 +00:00
|
|
|
global renderer
|
|
|
|
global throttle
|
2024-06-30 14:23:47 +00:00
|
|
|
global headless_renderer_type
|
|
|
|
global headless_renderer_done
|
|
|
|
if {$headless_renderer_done != 0} {
|
2024-07-02 13:34:26 +00:00
|
|
|
return "mb::head GUI already showing"
|
2024-06-30 14:23:47 +00:00
|
|
|
}
|
|
|
|
if {$headless_renderer_type != 0} {
|
|
|
|
after time 1 "set renderer $headless_renderer_type"
|
2024-07-02 22:04:21 +00:00
|
|
|
after time 2 "set throttle on"
|
2024-06-30 14:23:47 +00:00
|
|
|
set headless_renderer_done 1
|
2024-06-28 17:10:24 +00:00
|
|
|
} else {
|
2024-06-29 23:48:05 +00:00
|
|
|
puts stderr "error: Requested show gui but env.RENDERER is missing."
|
2024-06-28 17:10:24 +00:00
|
|
|
exit 1
|
2024-06-28 17:04:15 +00:00
|
|
|
}
|
2024-07-02 13:34:26 +00:00
|
|
|
return "mb::head GUI renderer $headless_renderer_type"
|
2024-06-28 17:04:15 +00:00
|
|
|
}
|
|
|
|
|
2024-06-29 03:07:15 +00:00
|
|
|
if {[info exists ::env(RENDERER)] && ([string trim $::env(RENDERER)] != "")} {
|
2024-06-30 14:23:47 +00:00
|
|
|
set headless_renderer_type [string trim $::env(RENDERER)]
|
2024-06-28 17:04:15 +00:00
|
|
|
}
|
|
|
|
|
2024-06-29 03:07:15 +00:00
|
|
|
if {[info exists ::env(HEADLESS)] && ([string trim $::env(HEADLESS)] != "on")} {
|
2024-06-30 21:24:15 +00:00
|
|
|
if {[catch {set renderer $headless_renderer_type} err_msg]} {
|
2024-06-29 03:07:15 +00:00
|
|
|
puts stderr "error: env.HEADLESS value $err_msg"
|
2020-12-23 17:14:13 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-21 20:35:44 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|