OXYGENHUB
◆ main openmsx / share / scripts / reverse.tcl
2.7 KiB · Tcl · last changed chore(): initial commit 1 month ago source blame history raw
1
namespace eval reverse {
2
3
variable is_android [string match android "[openmsx_info platform]"]
4
5
variable default_auto_enable_reverse
6
if {$is_android} {
7
	set default_auto_enable_reverse "false"
8
} else {
9
	set default_auto_enable_reverse "true"
10
}
11
12
proc after_switch {} {
13
	# enabling reverse could fail if the active machine is an 'empty'
14
	# machine (e.g. because the last machine is removed or because
15
	# you explictly switch to an empty machine)
16
	catch {
17
		if {$::auto_enable_reverse} {
18
			auto_enable
19
		}
20
	}
21
	after machine_switch [namespace code after_switch]
22
}
23
24
} ;# namespace reverse
25
26
27
user_setting create boolean "auto_enable_reverse" \
28
{Controls whether the reverse feature is automatically enabled on startup (or
29
whenever a new machine is created). Internally the reverse feature takes
30
regular snapshots of the MSX state, this has a (small) cost in memory and in
31
performance. On small systems you may not want this cost, so for these the
32
reverse feature can be disabled by default using this setting.
33
} $reverse::default_auto_enable_reverse
34
35
user_setting create boolean "auto_save_replay" \
36
{Enables automatically saving the current replay to filename specified \
37
in the setting "auto_save_replay_filename" with the interval specified \
38
in the setting "auto_save_replay_interval".
39
The file will keep being overwritten until you disable the auto save again.\
40
} false
41
42
user_setting create string "auto_save_replay_filename" \
43
{Filename of the replay file that will be saved to when auto_save_replay is \
44
enabled.
45
} "auto_save"
46
47
user_setting create float "auto_save_replay_interval" \
48
{If enabled, auto save the current replay every number of seconds that is \
49
specified with this setting.
50
} 30.0 0.01 100000.0
51
52
# TODO hack:
53
# The order in which the startup scripts are executed is not defined. But this
54
# needs to run after the load_icons script has been executed.
55
#
56
# It also needs to run after 'after boot' proc in the autoplug.tcl script. The
57
# reason is tricky:
58
#  - If this runs before autoplug, then the initial snapshot (initial snapshot
59
#    triggered by enabling reverse) does not contain the plugged cassette player
60
#    yet.
61
#  - Shortly after the autoplug proc runs, this will plug the cassetteplayer.
62
#    This plug command will be recorded in the event log. This is fine.
63
#  - The problem is that we don't serialize information for unplugged devices
64
#    ((only) in the initial snapshot, the cassetteplayer is not yet plugged). So
65
#    the information about the inserted tape is lost.
66
67
# As a solution/hack, we trigger this script at emutime=0. This is after the
68
# autoplug script (which triggers at 'after boot'. But also this is also
69
# triggered when openmsx is started via a replay file from the command line
70
# (in such case 'after boot' is skipped).
71
72
after realtime 0 {reverse::after_switch}