OXYGENHUB
◆ main openmsx / share / scripts / cashandler.tcl
1.8 KiB · Tcl · last changed chore(): initial commit 1 month ago source blame history raw
1
namespace eval cashandler {
2
3
user_setting create boolean fast_cas_load_hack_enabled \
4
"Whether you want to enable a hack that enables you to quickly load CAS files
5
with the cassetteplayer, without converting them to WAV first. This is not
6
recommended and several cassetteplayer functions will not work anymore (motor
7
control, position indication, size indication). Also note that this hack only
8
works when inserting cassettes when the MSX is already started up, not when
9
inserting them via the openMSX command line." false
10
11
variable old_value $::fast_cas_load_hack_enabled
12
variable hack_is_already_enabled false
13
14
proc set_hack {} {
15
	variable hack_is_already_enabled
16
	
17
	if {$::fast_cas_load_hack_enabled && !$hack_is_already_enabled} {
18
		# if no cassetteport (e.g. turboR), you can't install the hack
19
		# (but we do allow uninstalling it)
20
		if {[catch "machine_info connector cassetteport"]} return
21
		interp hide {} cassetteplayer
22
		interp alias {} cassetteplayer {} cashandler::tapedeck
23
		set hack_is_already_enabled true
24
		puts "Fast cas load hack installed."
25
	} elseif {!$::fast_cas_load_hack_enabled && $hack_is_already_enabled} {
26
		interp alias {} cassetteplayer {}
27
		interp expose {} cassetteplayer
28
		set hack_is_already_enabled false
29
		puts "Fast cas load hack uninstalled."
30
	}
31
}
32
33
proc setting_changed {name1 name2 op} {
34
	variable old_value
35
36
	if {$::fast_cas_load_hack_enabled != $old_value} {
37
		set_hack
38
		set old_value $::fast_cas_load_hack_enabled
39
	}
40
}
41
42
trace add variable ::fast_cas_load_hack_enabled write [namespace code setting_changed]
43
44
proc set_hack_on_new_machine {} {
45
	if {$::fast_cas_load_hack_enabled} {
46
		set_hack
47
	}
48
	after machine_switch [namespace code set_hack_on_new_machine]
49
}
50
51
after machine_switch [namespace code set_hack_on_new_machine]
52
53
} ;# namespace cashandler