You may have noticed, that in the last 2 months I have been busy with vectrex things again. This includes but is not limited to surfing the internet and looking what other people have been up to.
Quite some time ago I found an interesting page:
Really fascinating, what other people can do with a soldering iron… I have been – and always will be – a software guy, nonetheless “Sprites mods” – I am very impressed and full of awe and respect for your achievment.
The software stuff he created and some descriptions are all online available, so naturally I was quite intrigued to try some things on my own.
I have produced a Vide “runnable” version of BadApple, that was not as “easy” going as I would have expected, but nonetheless achievable. Here I will write some of my stumbling blocks and how I navigated around them.
(I did everything on a 2011 IMac, running El Capitan)
- Download stuff from above page you will get a “veccart.tgz” which contains all sources you need
- Download “any” version of BadApple from YouTube, the version I got was 13.464.02 bytes, MP4 and plays 5:23
- You need free software for whatever system you are running on as follows:
- MPlayer (home)
Here the first “trouble” started, the script uses a command line version. I tried searching the net, but I think NOWHERE can you download a simple command line version. BUT, here it is nice to have some insights about how Mac Apps work. You don’t have to!
I used the standard installation of MPlayerX, than went to my application folder (ok, you better have copy paste ready):
I copied that entire directory to my BadApple working dir, and made sure to have the mplayer executable in my path.
- ImageMagick (home)
Again we are led to belive everything would work straight out of the box, that was not the case for me.
Downloading the Mac stuff worked alright. I set up a working directory, a batch (shell) script, that set all needed paths, but the darn thing still would not work. It always complained about wanting to have a libpng15.15.dylib – which did not come with the installer. Sad thing is – I can’t remember what all the steps were which I took and which ones in combination led to finaly working. I am pretty sure that at one stage I installed “MacPorts” and “Homebrew” and installed stuff till, lib png was “correctly” installed in /usr/local/lib.
Since it still didn’t work I established a symbolic link from the 16 version of the library to the 15 (which I needed), I think that finally did the trick, but I tried many steps and I am not sure if that was all that was really needed.
- Potrace (home)
This one is nice and easy, download it, place it, where you can access it -> done.
- Sox (home)
- ASM6809 (home)
- For vecx (a special version of the emulator is needed later) we also need SDL 2.0 (Framework), I am pretty sure one must copy that by hand to “/Library/Framework”, I did also install via “Homebrew”, while you are at it, also get the packages “image” and “gfx” you will need them.
- Now back to the “veccart.tgz”, obviously – unpack it somewhere.
- The directory we are interested in now is: “badapple”, copy the mp4 from step 2 to that directory and name it: “Touhou-Bad_Apple.mp4”, to get a short version of what I am writing out here – read the “README.txt”
- If the files “convert.sh” and “combine.php” are not executable, flag them such!
- I edited “convert.sh” to setup paths etc for the above binaries, the start of my batch looks like:
#!/bin/bash # # Script to convert a mp4 file into a raw audio file and a bunch of vector files # Needs mplayer, imagemagick, potrace and sox # mp4="Touhou-Bad_Apple.mp4" export MAGICK_HOME="$(pwd)/ImageMagick" export PATH="$MAGICK_HOME/bin:$PATH" export DYLD_LIBRARY_PATH="$MAGICK_HOME/lib/" if [ "$1" = "clean" ]; then rm -rf png pnm vec fi if [ ! -e png ] || [ ! -e audiodump.wav ]; then mkdir png cd png ../mplayer/mplayer -ao pcm:fast -vo png "../$mp4" -benchmark mv audiodump.wav .. cd .. fi ...
- If your unpacker is as stupid as mine, you might check your files. In some of the directories of “veccart.tgz” there are links to files in other directories. Make sure the links are either correct, correct them, or just copy the files. You may have doubles, but it will work ok.
- Go to the vecx directory, type make -> and you will see some errors :-).
The gist of these errors is (I think) that SpritesMods did the package after Doom, not after BadApple, so the files are “configured” for doom. But we (at least I) want BadApple!
- Find the file “cart.c” (and if you have doubles, than all of them) In the method cartWrite() comment out the line starting with “voomVectrexFrame(“, we don’t need that and it throws an error.
- Also, since we later want sound, in the same function find the (commented) lines:
if (addr==0) printf(“DBG: 0 %02x\n”, data);
if (addr==1) cHi=data<<8;
if (addr==2) printf(“DBG: 1 %04x\n”, data|cHi);
and uncomment them (oh well addr 0 is not important, but the other two). These lines are later necessary for vecx to generate “sync” information for the digitized sound.
- If I haven’t forgotten anything and all installs are correct, you might try a “make” in the vecx directory, if you have troubles > solve them.
- going back to the BadApple directory, last thing befor we start a “real” try. Edit the file “combine.php”, scroll way down, in line 41x something you see:
For now comment that line. Otherwise an error message is written to stdout. But stdout is where all our output goes (our generated bin file!). So if you do not have timing information yet -> the bin file will start with an error!
But befor we start in earnest, we come back to edit this file again…
- We will now try actually doing something! Run the script “convert.sh”, if you have troubles > solve them.
- After one of the stages of building images or such, you may “break” the script, since befor we actually have a good try we need to know how many images are generated. mplayer should have generated a few thousand images in the new “directory” png. Go there, count them! (or just look at the highest number!).
Take that number and edit the file “combine.php” again. In the top there is a line like:
//Amount of frames in the movie
$framect=7777; (or any other number, 7777 is mine!)
Enter your number there! Scroll down to the end, somewhere arround 41x is a line:
Enter that number there as well.
- Save it.
- Delete the newly generated directories (or at least the ones that did not “finish” their job), run convert again.
- If everything is alright after 1-2 Minutes, the script will exit and you have a vec.bin (mine is about 12MB, but that depends on the mp4 file you actually chose).
- Copy that to the badapple-vec directory
Make sure the rom.dat is correct and that you have access to AS6809 and vecx.
If everything was ok, you see vecx playing the movie as a vector movie and stuttering non discernable sound.
Let it play all through. After everything is finished press “ESC” there should be a file called “timing.log” (mine is about 140 MB). Take that and copy it back to the badapple directory – and go there!
- edit combine.php again, and uncomment the above line
- Run it again.
Now you have a 12 MB vectrex binary!
a) To run it, you must tell your emulator to run badapple.bin.
b) The file vec.bin must be in the same directory
c) The emulator must be able to do so!
If it is vecx based there are only a couple of lines to change:
1) the function
unsigned char read8 (unsigned address) /write8 (unsigned address)
must be enhanced with two or three lines (see source) and the file cart.c/h must be included.
Vide runs badapple just fine!
(was easy, wasn’t it?)