
set -x

export CC65_HOME=/Users/egan/Apple/cc65/lib/cc65
PATH=/Users/egan/Apple/cc65/bin:$PATH
applecmd='java -jar /Applications/AppleCommander.app/Contents/Resources/Java/AppleCommander.jar'


rm codebreaker code.1 code.2 *.o *.wav *.aif *.mon

# contiguous 8k version (280-1FFF)
rm codebreaker *.o
ca65 -D CODESEG=0 -t none --listing --list-bytes 100 -o getkey.o getkey.s 
ca65 -D CODESEG=0 -t none --listing --list-bytes 100 -o putchar.o putchar.s 
cl65 -D CODESEG=0 -T -O --static-locals -t apple1 -C apple1-8k.cfg -o codebreaker codebreaker.c getkey.o putchar.o

c2t -l codebreaker codebreaker.8k.mon
c2t -1et -r 48000 codebreaker codebreaker.8k.wav


# 4+4 config, 280-FFF, E000-EFFF
rm code.1 code.2 *.o 
ca65 -D CODESEG=1 -t none --listing --list-bytes 100 -o getkey.o getkey.s 
ca65 -D CODESEG=1 -t none --listing --list-bytes 100 -o putchar.o putchar.s 
cl65 -D CODESEG=1 -T -O --static-locals -t apple1 -C apple1.cfg -o code.header codebreaker.c getkey.o putchar.o

c2t -l code.1,280 code.2,e000 codebreaker.4+4k.mon
c2t -1et -r 48000 code.1,280 code.2,e000 codebreaker.4+4k.wav

rm codebreaker.po
$applecmd -pro140 codebreaker.po codebreaker
tail -c $(( $(stat -f "%z" codebreaker) - 4 )) codebreaker | $applecmd -p codebreaker.po codebreaker bin 0x0280 bin
$applecmd -p codebreaker.po codebreaker.pt1 bin 0xe000 bin < code.2
$applecmd -p codebreaker.po codebreaker.pt2 bin 0x0280 bin < code.1
$applecmd -ll codebreaker.po 

