Jump to content
IGNORED

automating dasm and makewav in linux


hendersonn

Recommended Posts

Hey guys/gals,

I'm a bit bored with studying and figured I'd distract myself by posting something that's made working with DASM and MAKWAV a bit easier over that past year or so. It's nothing flashy (at all), just a bash script I use frequently. The key here is setting up folders for inputs (*.asm files) and outputs (*.bin [stella], *.txt

  • , and .wav [supercharger] files), then dividing everything up. I like this because it keeps everything organized, as well as reduces the effort required to assemble/run programs. I have it structured to ask you for the name of the assembly file; The script then takes that, navigates to the folder DASM is located (~/dasm), runs the assembler, and outputs the binary and list files into their respective folders. Once that is complete, the script runs MAKEWAV via WINE to create an audio file for the Starpath Supercharger. Once everything has been assembled, the script will ask if you would like to run the file via STELLA.
#! /bin/bash
#auto dasm
#matt henderson
#2014
export DISPLAY=:0
clear
echo "Auto DASM/MakeWav"
echo "================="
echo "Input (*.asm) files are read from 'asm_input'"
echo "Output (*.bin) is sent to 'bin_output'"
echo "List files are sent to 'list_output'"
echo "Wav files are sent to 'sc_output'"
echo
echo -n "What is the name of the *.asm file? "
read input
cd /~/projects/atari2600/assembler/dasm
./dasm /~/projects/atari2600/asm_input/$input.asm -l/~/projects/atari2600/list_output/$input.txt -f3 -v5 -o/~/projects/atari2600/bin_output/$input.bin
cd /~/projects/atari2600/assembler/makewav4.2
wine makewav -ts -d2 -f0 /~/projects/atari2600/bin_output/$input.bin
mv /~/projects/atari2600/bin_output/$input.wav /~/projects/atari2600/sc_output
clear
echo "Auto DASM/MakeWav"
echo "================="
echo
echo "Run '"$input"' in Stella? (lowercase: y/n)"
echo
read stellarun
if [ $stellarun = "y" ] ; then
    cd /~/projects/atari2600/bin_output
    stella $input.bin
else
    clear
fi

One last thing, you could run this script like any other by navigating to the folder the script is located in and typing "./asm" or "sh asm", but thats too much work, am I right? Type sudo nano /etc/bash.bashrc and append the following to the bottom (the tilde represents the path to the script):

alias asm='sh /~/asm'

After you logout/login again, typing "asm" will run the script globally (as if it were any other system command).

 

You can rename the folders to whatever you'd like (remember, the tilde is to represent the path to the appropriate folders). Just note that you will have to alter the script to match your folder names/paths, specifically the locations of DASM and MAKEWAV (In fact, if you do not have WINE or MAKEWAV installed, you can cut out the lines "cd /~/projects/atari2600/assembler/makewav4.2", "wine makewav -ts -d2 -f0 /~/projects/atari2600/bin_output/$input.bin", and "mv /~/projects/atari2600/bin_output/$input.wav /~/projects/atari2600/sc_output" to avoid any nasty error messages.)

 

This is all because I'm lazy and has no real benefit, but I figured I'd share anyway. There may be more efficient ways to accomplish all this, but this works for me.

Also, this obviously only works with Linux, although a Windows/DOS batch file wouldn't be too hard to replicate.

Link to comment
Share on other sites

Also, this obviously only works with Linux

Script would work on Mac OS X as well, just needs some minor tweaks as Stella's launched a little differently* and wine isn't normally installed. I have the source for makewav somewhere, would just need to compile a new bin so it could be run w/out using wine. The bin I have built was built back when I had a PowerPC Mac and Rosetta's been depreciated so Intel Macs no longer support legacy code.

 

This is a script I used to compress object data for the levels in Stay Frosty 2:

#! /bin/bash

rm *.bin
rm *.sbin
rm *.sbin2

for file in *.asm
	do
		root=${file%.*}
		dasm $file -f3 -v0 -o$root.bin
		for platform in ../platforms/*${root: -2}*.bin
		do
			shrink/shrink $root.bin $platform $root.sbin
			shrink2/shrink $root.bin $platform $root.sbin2
		done
	done

ls -l *.bin | awk '{total += $5} END {print total}'
ls -l *.sbin | awk '{total += $5} END {print total}'
ls -l *.sbin2 | awk '{total += $5} END {print total}'
The each level's object data is stored in a DASM source file, so the script compiles each one then compresses the results using 2 different methods. The last part outputs ROM usage for uncompressed and compressed data so I could see the savings and decide which version of "shrink" to use for the final game, which ended up being shrink2.

 

The platform data is compressed separately because some of the levels are reused with a different arrangement of objects.

 

 

* from my blog entry about compiling and running 2600 code via jEdit, stella $input.bin would become:

/Applications/Stella.app/Contents/MacOS/Stella $input.bin

You might like to check out using jEdit, syntax highlighting is a nice feature to have.

Edited by SpiceWare
Link to comment
Share on other sites

 

Yeah, I couldn't remember if there was a source available for Makewav or not, I probably just went the Wine route originally due to convenience (aka laziness) since I already use wine for other Windows applications. I wasn't thinking of OSX for some reason either, good point. I also liked the compression methods used; I'll note it for future use.

 

As for jEdit, I downloaded it a while ago, but never really worked with it.

Link to comment
Share on other sites

The compression routines are custom, Thomas Jentzsch and I came up with the ones used for Stay Frosty.

If your current editor doesn't do any syntax highlighting, the I highly recommend you at least install the assembly-6502 mode file from this blog entry and use jEdit for a few days to see the benefits.

 

You might like to check out this blog entry as well on customizing the colors that are used.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...