Controlling WowWee's Alive Elvis Part 3 - Animation ScriptsPosted by RetroPlayer on Monday, 1 December 2008
Previously, we dumped the original contents of the Elvis cartridge and constructed a custom cartridge in order to decode the animation script format. In part one, I presented the theory that was proposed in discussion on the forums. It turns out that this theory was correct. I owe a fellow RoboCommunity member, Sevik, a great deal of gratitude for helping me determine test scripts to try out.
First, another look at an animation script from SongNa01.txt:
I am showing only the first two frames of this animation, as it is enough to understand how the format works.
Each frame consists of as many as 12 tracks. A frame can contain one, two or any number of tracks, but the max is twelve. This is because there are max twelve motors in the animation script.
Wait a minute! I thought you said there was only 10 motors in the Elvis Bust! I hear you say. There is, but two unused motion capture points remain in the animation scripts. We'll see these in a minute. But, before we discuss the contents of this file, it is important to understand the rate at which these frames are played back. Each frame is played every 200ms, that is, 5 frames per second. Keep this in mind when creating your animations.
Now the actual format (let's grab a line from the hex dump above):
0000 6100 5100 3100
The first 16 bits ($0000) is the Frame number. In the example above you can see that there are 12 $0000 frames and 12 $0100 frames. Remember that the bytes are swapped, so these are actually just frame 0 and frame 1. Also, recall that there doesn't HAVE to be 12 frames. If a motor is not being used, it does not need to be included in the frame.
The second 16 bits ($6100) defines the motor to contol in this track. Again, bytes are swapped. Here is a list of all the motors:
61 - EYES U/D
62 - EYES L/R
63 - L EYELID
64 - R EYELID
65 - (Unkown)
66 - Eyebrows U/D
67 - (Unknown)
68 - Lip U/D
69 - Jaw U/D
6A - Head Tilt U/D
6B - Head Rotate L/R
6C - Head Tilt L/R
The third 16 bits ($5100) is the position that we want the motor to go to. Valid ranges are $4100 to $6100. I suspect there are realistic limits on some of the motors and this is being worked on right now, but know that $4100 is extreme Left or Up and that $6100 is extreme Right or Down. There are 32 possible positions available here, but again, not all motors appear to support this resolution.
The final 16 bits ($3100) is the speed or interval that you want the motor to reach the position. Valid range is $3000 to $3800; $3000 being the slowest and $3800, the fastest. 9 Possible speeds.
Using this information, it is possible to build a custom animation script and place it on the cartridge for playback. Obviously software needs to be written to generate decent scripts, but you can build them in a hex editor if you have the patience. I am looking at options and looking for help to build an application for animation scripting. My OS programming skills are nearly non-existant and would definitely appreciate some help with this.
Let's review some things and talk about using this information that we have learned.
First of all, there are some limitations to this method. All of the autonomous and startup routines are stored in a flash chip on the main board. This means that when Elvis is powered on, he will act and sound like Elvis, no matter what you put on the cartridge. Also, as designed, Elvis will play these routines randomly in between songs or monologues. This is a pretty big limitation and some work is being done to change the files on the main flash to work around this. Right now, it is already possible, but requires some equipment the average hobbyist is unlikely to have. For now, it is enough to just write a working and attractive animation script. So there will be lots to play with just with the cartridge. The format of the animations and audio on the main flash are the same as on the cartridge. No filenames, however there is an index. Not everything is known about the main flash contents yet, so it is premature to talk about modifying it.
Another limitation is that you have three modes of operation. On the remote, you can enter Song mode or monologue mode. You can also play/pause and skip forward and back among the files in either mode. All of the routines play in order, so mono01.* will be the first routine to play in monologue mode. Pressing NEXT will jump to mono02.* and so forth. In song mode, there are two modes, actually. One is full songs with Elvis vocals, and the other is without his vocals. You can enter the first mode simply by pressing the mode button. To get to the second mode, you press VOICE while in song mode. Each sub-mode has its own audio and animations associated with it. This gives you a total of 3 "modes" that you can fill up with as many as 99 routines for each mode. This is based on the two digit number in the filenames.
Again, the files for the different modes are:
Mono##.dat and Mono##.txt
Song##.dat and Song##.txt
CoSong##.dat and CoSong##.txt
SongNa##.dat and SongNa##.txt
Where ## is a double digit number. SongNa## files will play in either Song or Karaoke mode. I believe they can be excluded entirely. I will test this and update the article with my findings. I have been using monologue mode exclusively for my tests so far.
One last tip: When making your animations, include some silence at the end of each animation to set Elvis back to a normal position. This should also give you enough time to hit next before Elvis reverts to one of his random routines. If there is a limit to the length of an animation, it would theoretically be FFFE (65535) since the FrameID is 16 bits and FFFF marks an end of file in some cases. Practically, I have not discovered a limit yet. The songs are about a minute each, but the monologues are much shorter.