Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
openMSX script for recording video/audio of MoonBlaster tracks running via openMSX.
# TCL plugin script for openMSX Emulator
# Used to record MoonBlaster MBWave 1.16 tracks running through openMSX, in WAV and AVI.
# Version 0.9.5
#
# Changelog:
# 0.9.5 No need for global; variable will do;
# 0.9.4 Dual-licensed this script with GPL 2.0 for inclusion with openMSX;
# Bugfix: releasing the automatically pressed keys;
# Added: automatically stopping playback of song.
# 0.9.3 Updated documentation;
# 0.9.2 Added "auto" support; Thanks go out to BiFi for helping with the keyboard matrix.
# Bugfix: watchpoint was not deleted;
# 0.9.1 Added xLoop Position support. Thanks to mth for finding its memory address.
#
# Copyright 2010 Filip H.F. "FiXato" Slagter
# Contact me via http://twitter.com/FiXato
# This software is dual-licensed under:
# "Creative Commons Attribution-Share Alike 3.0 Unported" License, http://creativecommons.org/licenses/by-sa/3.0/
# "Creative Commons GNU General Public License 2.0" License, http://creativecommons.org/licenses/GPL/2.0/
namespace eval moonblaster_recorder {
variable status
variable loop_watchpoint
variable position_watchpoint
set_help_text moonblaster_recorder \
{Convenience function to record MoonBlaster MBWave 1.16 songs to wav + avi.
NOTE: This will most likely only work for MBWave version 1.16, since it relies on 2 specific memory addresses.
There are three subcommands: start, mark and stop. Though the latter 2 are more meant for internal use by the 'start' subcommand.
* Start will start the WAV recording. Add 'auto' after the filename to make the script automatically start MoonBlaster
playback, disable throttling and hide the console.
WAV recording will continue till 'mark' or 'stop' are called either manually
or till MoonBlaster returns to the song's Loop position.
* Mark can be used to mark the end of the song, after which openmsx will reverse to where the recording started.
It will then continue with AVI recording from the beginning.
AVI recording will continue till 'stop' is called, or till MoonBlaster returns once again to the song's Loop position.
* Stop will stop all recording at all times. It will also pause openMSX and (re-)enable throttling.
Usage:
moonblaster_recorder start [filename_without_extension] [auto]
moonblaster_recorder mark
moonblaster_recorder stop
Example:
Start up MoonBlaster, load your favourite tune and type in the console:
moonblaster_recorder start "FiX in the MiX - Fabulous Song" auto
Then sit back and watch the tune first get recorded to WAV, reversed and then recorded to AVI.
}
set_tabcompletion_proc moonblaster_recorder [namespace code tab_moonblaster_recorder]
proc tab_moonblaster_recorder { args } {
if {[llength $args] == 2} {
return "start mark stop"
}
}
proc moonblaster_recorder { args } {
variable filename
variable status
set status [lindex $args 0]
switch $status {
start {
set filename [lindex $args 1]
reverse start
record start -audioonly $filename
set_position_watchpoint
puts "MoonBlaster Recorder started with audio-only phase"
if {[lindex $args 2] == "auto"} {
keymatrixdown 6 0x20
after frame {keymatrixup 6 0x20}
toggle console
set ::throttle false
}
}
mark {
set ::pause true
record stop
reverse savereplay $filename
savestate $filename
reverse goto 1
set_position_watchpoint
record start -doublesize $filename
set ::pause false
puts "MoonBlaster Recorder entering video recording phase"
}
stop {
reverse stop
record stop
keymatrixdown 7 0x04
set ::throttle true
after time 1 {keymatrixup 7 0x04; after frame {set ::pause true}}
puts "MoonBlaster Recorder stopped"
}
}
}
proc set_position_watchpoint {} {
variable position_watchpoint
set position_watchpoint [debug set_watchpoint write_mem 0x51f7 {[debug read memory 0x51f7] == 0} {moonblaster_recorder::set_loop_watchpoint}]
debug list_watchpoints
}
proc set_loop_watchpoint {} {
variable loop_watchpoint
variable position_watchpoint
debug list_watchpoints
debug remove_watchpoint $position_watchpoint
debug list_watchpoints
set loop_watchpoint [debug set_watchpoint read_mem 0x3eeb {} {moonblaster_recorder::recorder_watchpoint_event}]
}
proc recorder_watchpoint_event {} {
variable status
variable loop_watchpoint
debug remove_watchpoint $loop_watchpoint
switch $status {
start {
moonblaster_recorder mark
}
mark {
moonblaster_recorder stop
}
}
}
namespace export moonblaster_recorder
}
namespace import moonblaster_recorder::*
@FiXato
Copy link
Author

FiXato commented Jan 5, 2013

@Bifi I miss something in that lunar-blower script
<+FiXato> oh, moonblaster ><
@Bifi the FlyBy demo video probably also suffers from this
@Bifi you probably use the mbstereo extension
<+FiXato> likely
<+FiXato> it's been a long time since I last used it
@Bifi to get a real moonblaster stereo effect like the real thing:
@Bifi 1. the PSG balance setting should be equal to the MSX-MUSIC balance
@Bifi 2. on a machine with built-in MSX-MUSIC its balance setting should be equal to the MSX-MUSIC balance setting (FM-PAC) of the mbstereo extension
@Bifi the balance setting of the FM-PAC in the mbstereo extension is set, but on a machine with built-in MSX-MUSIC it doesn't even play

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment