cashandler.tcl 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. namespace eval cashandler {
  2. user_setting create boolean fast_cas_load_hack_enabled \
  3. "Whether you want to enable a hack that enables you to quickly load CAS files
  4. with the cassetteplayer, without converting them to WAV first. This is not
  5. recommended and several cassetteplayer functions will not work anymore (motor
  6. control, position indication, size indication). Also note that this hack only
  7. works when inserting cassettes when the MSX is already started up, not when
  8. inserting them via the openMSX command line." false
  9. variable old_value $::fast_cas_load_hack_enabled
  10. variable hack_is_already_enabled false
  11. proc set_hack {} {
  12. variable hack_is_already_enabled
  13. # example: turboR..
  14. # for now, ignore the commands... it's quite complex to
  15. # get this 100% water tight with adding/removing machines
  16. # at run time
  17. if {[catch "machine_info connector cassetteport"]} return
  18. if {$::fast_cas_load_hack_enabled && !$hack_is_already_enabled} {
  19. interp hide {} cassetteplayer
  20. interp alias {} cassetteplayer {} cashandler::tapedeck
  21. set hack_is_already_enabled true
  22. puts "Fast cas load hack installed."
  23. } elseif {!$::fast_cas_load_hack_enabled && $hack_is_already_enabled} {
  24. interp alias {} cassetteplayer {}
  25. interp expose {} cassetteplayer
  26. set hack_is_already_enabled false
  27. puts "Fast cas load hack uninstalled."
  28. }
  29. }
  30. proc setting_changed {name1 name2 op} {
  31. variable old_value
  32. if {$::fast_cas_load_hack_enabled != $old_value} {
  33. set_hack
  34. set old_value $::fast_cas_load_hack_enabled
  35. }
  36. }
  37. trace add variable ::fast_cas_load_hack_enabled write [namespace code setting_changed]
  38. proc initial_set {} {
  39. if {$::fast_cas_load_hack_enabled} {
  40. set_hack
  41. }
  42. }
  43. after realtime 0 [namespace code initial_set]
  44. } ;# namespace cashandler