reverse.tcl 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. namespace eval reverse {
  2. variable is_dingux [string match dingux "[openmsx_info platform]"]
  3. variable is_android [string match android "[openmsx_info platform]"]
  4. variable default_auto_enable_reverse
  5. if {$is_dingux || $is_android} {
  6. set default_auto_enable_reverse "off"
  7. } else {
  8. set default_auto_enable_reverse "gui"
  9. }
  10. proc after_switch {} {
  11. # enabling reverse could fail if the active machine is an 'empty'
  12. # machine (e.g. because the last machine is removed or because
  13. # you explictly switch to an empty machine)
  14. catch {
  15. if {$::auto_enable_reverse eq "on"} {
  16. auto_enable
  17. } elseif {$::auto_enable_reverse eq "gui"} {
  18. reverse_widgets::enable_reversebar false
  19. }
  20. }
  21. after machine_switch [namespace code after_switch]
  22. }
  23. } ;# namespace reverse
  24. user_setting create string "auto_enable_reverse" \
  25. {Controls whether the reverse feature is automatically enabled on startup.
  26. Internally the reverse feature takes regular snapshots of the MSX state,
  27. this has a (small) cost in memory and in performance. On small systems you
  28. don't want this cost, so we don't enable the reverse feature by default.
  29. Possible values for this setting:
  30. off Reverse not enabled on startup
  31. on Reverse enabled on startup
  32. gui Reverse + reverse_bar enabled (see 'help toggle_reversebar')
  33. } $reverse::default_auto_enable_reverse
  34. user_setting create float "reversebar_fadeout_time" \
  35. {Time it takes for the reverse bar to fade out when it's not in focus. Set to 0 for no fade out at all.
  36. } 5.0 0.0 100.0
  37. user_setting create boolean "auto_save_replay" \
  38. {Enables automatically saving the current replay to filename specified \
  39. in the setting "auto_save_replay_filename" with the interval specified \
  40. in the setting "auto_save_replay_interval".
  41. The file will keep being overwritten until you disable the auto save again.\
  42. } false
  43. user_setting create string "auto_save_replay_filename" \
  44. {Filename of the replay file that will be saved to when auto_save_replay is \
  45. enabled.
  46. } "auto_save"
  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. # TODO hack:
  52. # The order in which the startup scripts are executed is not defined. But this
  53. # needs to run after the load_icons script has been executed.
  54. #
  55. # It also needs to run after 'after boot' proc in the autoplug.tcl script. The
  56. # reason is tricky:
  57. # - If this runs before autoplug, then the initial snapshot (initial snapshot
  58. # triggered by enabling reverse) does not contain the plugged cassette player
  59. # yet.
  60. # - Shortly after the autoplug proc runs, this will plug the cassetteplayer.
  61. # This plug command will be recorded in the event log. This is fine.
  62. # - The problem is that we don't serialize information for unplugged devices
  63. # ((only) in the initial snapshot, the cassetteplayer is not yet plugged). So
  64. # the information about the inserted tape is lost.
  65. # As a solution/hack, we trigger this script at emutime=0. This is after the
  66. # autoplug script (which triggers at 'after boot'. But also this is also
  67. # triggered when openmsx is started via a replay file from the command line
  68. # (in such case 'after boot' is skipped).
  69. after realtime 0 {reverse::after_switch}