Created
July 14, 2010 17:51
-
-
Save FiXato/475752 to your computer and use it in GitHub Desktop.
TCL plugin script for openMSX Emulator to record a video of MSX software that makes use of switching frame rate frequencies.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TCL plugin script for openMSX Emulator | |
# by Albert "BiFiMSX" Beevendorp and Filip H.F. "FiXato" Slagter | |
# Used to record a video of MSX software that makes use of switching frame rate frequencies. | |
# Version 0.7 | |
# | |
# `toggle_vblank` enables/disables auto-'splitting' of videos at the frame rate change. | |
# `record_with_vblank` is a wrapper that enables the vblank detection, and allows for | |
# passing along `record start` parameters such as -prefix and -doublesize. | |
# It automatically starts the video recording and will stop and start recording a new video when | |
# the frame rate change is detected. | |
# | |
# Usage examples: | |
# Manually: | |
# record start | |
# toggle_vblank | |
# Automatically: | |
# record_with_vblank -doublesize -prefix "\[MSX\] N.O.P. - Unknown Reality" | |
# | |
# Changelog: | |
# 0.1 Initial `toggle_vblank` and `check` script by BiFiMSX | |
# 0.2 Removed extra ) in `check` proc | |
# 0.3 Added `record_with_vblank` proc and support for $record_args to toggle_vblank | |
# 0.4 Bugfix: called variable on cur_wp in `record_with_vblank` | |
# 0.5 Put the watchpoint creation in a helper proc and made it conditional to prevent | |
# duplicate watchpoints. | |
# 0.6 Refactored some more and removed the helper proc again. | |
# 0.7 Added some output to indicate the Frame rate changes, and the start of a new video. | |
namespace eval vblank { | |
variable cur_wp "" | |
variable old_r9 0 | |
variable record_args "" | |
proc check {} { | |
variable old_r9 | |
variable record_args | |
# TODO: Implement check if video recording is already in progress. | |
if {[expr [vdpreg 9] & 2] != $old_r9} { | |
puts "Frame rate change detected from [expr ($old_r9 eq 0) ? 60 : 50] to [expr ([expr [vdpreg 9] & 2] eq 0) ? 60 : 50]. Starting recording of next video." | |
set old_r9 [expr [vdpreg 9] & 2] | |
record stop | |
eval [linsert $record_args 0 record start] | |
} | |
} | |
proc toggle_vblank {} { | |
variable cur_wp | |
if {$cur_wp == ""} { | |
variable old_r9 | |
set old_r9 [expr [vdpreg 9] & 2] | |
set cur_wp [debug set_watchpoint write_io 0x99 1 { vblank::check }] | |
} else { | |
debug remove_watchpoint $cur_wp | |
set cur_wp "" | |
} | |
return "" | |
} | |
proc record_with_vblank { args } { | |
variable record_args | |
variable cur_wp | |
set record_args $args | |
if {$cur_wp == ""} { | |
toggle_vblank | |
} | |
eval [linsert $record_args 0 record start] | |
} | |
namespace export toggle_vblank | |
namespace export record_with_vblank | |
}; #namespace | |
namespace import vblank::* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment