#!/bin/bash

make apple

cp rel/apple/CMD#061000 prodos/CMD.BIN
cp rel/apple/CMD.128#061000 prodos/CMD.128.BIN
cp rel/apple/PLASMA.SYSTEM#FF2000 prodos/PLASMA.SYSTEM.SYS
cp rel/apple/PLVM.128#FF2000 prodos/PLVM.128.SYS
cp rel/apple/PLVM16#FF2000 prodos/PLVM16.SYS
cp ../doc/Editor.md prodos/EDITOR.README.TXT

rm -rf prodos/sys
mkdir prodos/sys
cp rel/apple/FILEIO#FE1000 prodos/sys/FILEIO.REL
cp rel/apple/CONIO#FE1000 prodos/sys/CONIO.REL
cp rel/LINES#FE1000 prodos/sys/LINES.REL
cp rel/TURTLE#FE1000 prodos/sys/TURTLE.REL
cp rel/SINCOS#FE1000 prodos/sys/SINCOS.REL
cp rel/apple/HGRFONT#FE1000 prodos/sys/HGRFONT.REL
cp rel/apple/HGRTILE#FE1000 prodos/sys/HGRTILE.REL
cp rel/apple/HGRSPRITE#FE1000 prodos/sys/HGRSPRITE.REL
cp rel/apple/HGRLIB#FE1000 prodos/sys/HGRLIB.REL
cp rel/apple/GRLIB#FE1000 prodos/sys/GRLIB.REL
cp rel/apple/DGRLIB#FE1000 prodos/sys/DGRLIB.REL
cp rel/apple/VBLANK#FE1000 prodos/sys/VBLANK.REL
cp rel/apple/COPY#FE1000 prodos/sys/COPY.REL
cp rel/apple/DEL#FE1000 prodos/sys/DEL.REL
cp rel/apple/REN#FE1000 prodos/sys/REN.REL
cp rel/apple/CAT#FE1000 prodos/sys/CAT.REL
cp rel/apple/NEWDIR#FE1000 prodos/sys/NEWDIR.REL
cp rel/apple/TYPE#FE1000 prodos/sys/TYPE.REL
cp rel/apple/INITSLOT#FE1000 prodos/sys/INITSLOT.REL
cp rel/apple/MATCHFILES#FE1000 prodos/sys/MATCHFILES.REL
cp rel/LZ4CAT#FE1000 prodos/sys/LZ4CAT.REL
cp rel/ARGS#FE1000 prodos/sys/ARGS.REL
cp rel/ED#FE1000 prodos/sys/ED.REL
cp rel/FIBER#FE1000 prodos/sys/FIBER.REL
cp rel/LONGJMP#FE1000 prodos/sys/LONGJMP.REL
cp rel/MEMMGR#FE1000 prodos/sys/MEMMGR.REL
cp rel/INET#FE1000 prodos/sys/INET.REL
cp rel/DHCP#FE1000 prodos/sys/DHCP.REL
cp rel/ETHERIP#FE1000 prodos/sys/ETHERIP.REL
cp rel/apple/MOUSE#FE1000 prodos/sys/MOUSE.REL
cp rel/apple/UTHERNET2#FE1000 prodos/sys/UTHERNET2.REL
cp rel/apple/UTHERNET#FE1000 prodos/sys/UTHERNET.REL
cp rel/apple/PORTIO#FE1000 prodos/sys/PORTIO.REL
cp rel/apple/JOYBUZZ#FE1000 prodos/sys/JOYBUZZ.REL
cp rel/apple/SNDSEQ#FE1000 prodos/sys/SNDSEQ.REL
cp rel/apple/JIT#FE1000 prodos/sys/JIT.REL
cp rel/apple/JIT16#FE1000 prodos/sys/JIT16.REL
cp rel/apple/JITUNE#FE1000 prodos/sys/JITUNE.REL
cp rel/apple/ZIPCHIP#FE1000 prodos/sys/ZIPCHIP.REL
cp rel/LZ4#FE1000 prodos/sys/LZ4.REL
cp rel/TFTPD#FE1000 prodos/sys/TFTPD.REL
cp rel/INT32#FE1000 prodos/sys/INT32.REL
cp rel/FPSTR#FE1000 prodos/sys/FPSTR.REL
cp rel/FPU#FE1000 prodos/sys/FPU.REL
cp rel/SANE#FE1000 prodos/sys/SANE.REL
cp ../sysfiles/FP6502.CODE#060000 prodos/sys/FP6502.CODE.BIN
cp ../sysfiles/ELEMS.CODE#060000 prodos/sys/ELEMS.CODE.BIN
cp rel/apple/SOS#FE1000 prodos/sys/SOS.REL
cp rel/apple/GRAFIX#FE1000 prodos/sys/GRAFIX.REL
cp rel/HRFORTH#FE1000 prodos/sys/HRFORTH.REL
cp rel/HR2FORTH#FE1000 prodos/sys/HR2FORTH.REL
cp rel/TX2FORTH#FE1000 prodos/sys/TX2FORTH.REL
cp rel/PLFORTH#FE1000 prodos/sys/PLFORTH.REL

mkdir prodos/sys/scripts
cp scripts/plasma.4th prodos/sys/scripts/PLASMA.4TH.TXT
cp scripts/machid.4th prodos/sys/scripts/MACHID.4TH.TXT
cp scripts/conio.4th prodos/sys/scripts/CONIO.4TH.TXT
cp scripts/fileio.4th prodos/sys/scripts/FILEIO.4TH.TXT
cp scripts/grlib.4th prodos/sys/scripts/GRLIB.4TH.TXT
cp scripts/dgrlib.4th prodos/sys/scripts/DGRLIB.4TH.TXT
cp scripts/hgrlib.4th prodos/sys/scripts/HGRLIB.4TH.TXT
cp scripts/hgrtile.4th prodos/sys/scripts/HGRTILE.4TH.TXT
cp scripts/hgrfont.4th prodos/sys/scripts/HGRFONT.4TH.TXT
cp scripts/turtle.4th prodos/sys/scripts/TURTLE.4TH.TXT
cp scripts/grafix.4th prodos/sys/scripts/GRAFIX.4TH.TXT
cp scripts/int32.4th prodos/sys/scripts/INT32.4TH.TXT
cp scripts/fpu.4th prodos/sys/scripts/FPU.4TH.TXT
cp scripts/portio.4th prodos/sys/scripts/PORTIO.4TH.TXT

rm -rf prodos/demos
mkdir prodos/demos
cp rel/INT32TEST#FE1000 prodos/demos/INT32TEST.REL
cp rel/apple/CONIOTEST#FE1000 prodos/demos/CONIOTEST.REL
cp rel/apple/ROD#FE1000 prodos/demos/ROD.REL
cp rel/RPNCALC#FE1000 prodos/demos/RPNCALC.REL
cp ../doc/ROGUE.LZ4.BIN prodos/demos/ROGUE.LZ4.BIN
cp rel/PRIMEGAP#FE1000 prodos/demos/PRIMEGAP.REL

mkdir prodos/demos/rogue
cp rel/ROGUE#FE1000 prodos/demos/rogue/ROGUE.REL
cp rel/ROGUECOMBAT#FE1000 prodos/demos/rogue/ROGUECOMBAT.REL
cp rel/ROGUEMAP#FE1000 prodos/demos/rogue/ROGUEMAP.REL
cp samplesrc/LEVEL0#040000 prodos/demos/rogue/LEVEL0.TXT
cp samplesrc/LEVEL1#040000 prodos/demos/rogue/LEVEL1.TXT

mkdir prodos/demos/music
cp rel/apple/PLAYSEQ#FE1000 prodos/demos/music/PLAYSEQ.REL
cp rel/apple/PLAYPCM#FE1000 prodos/demos/music/PLAYPCM.REL
cp mockingboard/ultima3.seq prodos/demos/music/ULTIMA3.SEQ.BIN
cp mockingboard/startrek.seq prodos/demos/music/STARTREK.SEQ.BIN
cp mockingboard/bells.pcm prodos/demos/music/BELLS.PCM.BIN

mkdir prodos/demos/net
cp rel/HTTPD#FE1000 prodos/demos/net/HTTPD.REL
cp samplesrc/index.html prodos/demos/net/INDEX.HTML.TXT

mkdir prodos/demos/apple2
cp rel/apple/TILETEST#FE1000 prodos/demos/apple2/TILETEST.REL
cp rel/apple/HGRTEST#FE1000 prodos/demos/apple2/HGRTEST.REL
cp rel/apple/GRTEST#FE1000 prodos/demos/apple2/GRTEST.REL
cp rel/apple/DGRTEST#FE1000 prodos/demos/apple2/DGRTEST.REL
cp rel/apple/MAZE#FE1000 prodos/demos/apple2/MAZE.REL

mkdir prodos/demos/apple2/spiders
cp rel/apple/SFM#FE1000 prodos/demos/apple2/spiders/SFM.REL
cp rel/apple/SFMSPRT#FE1000 prodos/demos/apple2/spiders/SFMSPRT.REL

mkdir prodos/demos/apple2/sdutils
cp rel/apple/SPIPORT#FE1000 prodos/demos/apple2/sdutils/SPIPORT.REL
cp rel/apple/SDFAT#FE1000 prodos/demos/apple2/sdutils/SDFAT.REL
cp rel/apple/FATCAT#FE1000 prodos/demos/apple2/sdutils/FATCAT.REL
cp rel/apple/FATGET#FE1000 prodos/demos/apple2/sdutils/FATGET.REL
cp rel/apple/FATPUT#FE1000 prodos/demos/apple2/sdutils/FATPUT.REL
cp rel/apple/FATREADDSK#FE1000 prodos/demos/apple2/sdutils/FATREADDSK.REL
cp rel/apple/FATWRITEDSK#FE1000 prodos/demos/apple2/sdutils/FATWRITEDSK.REL

mkdir prodos/demos/apple3
cp rel/apple/GFXDEMO#FE1000 prodos/demos/apple3/GFXDEMO.REL
cp samplesrc/APPLE3.PIX#060000 prodos/demos/apple3/APPLE3.PIX.BIN

rm -rf prodos/bld
mkdir prodos/bld
cp rel/PLASM#FE1000 prodos/bld/PLASM.REL
cp rel/CODEOPT#FE1000 prodos/bld/CODEOPT.REL
cp ../sysfiles/EDASM#FF2000 prodos/bld/EDASM.SYS
cp ../sysfiles/EDASM.ASM#063000 prodos/bld/EDASM.ASM.BIN
cp ../sysfiles/EDASM.ED#063000 prodos/bld/EDASM.ED.BIN
cp ../sysfiles/EDASM.SWAP#062000 prodos/bld/EDASM.SWAP.BIN
mkdir prodos/bld/basic
cp ../sysfiles/BASIC.SYSTEM#FF2000 prodos/bld/basic/BASIC.SYS
cp samplesrc/rod.bas prodos/bld/basic/ROD.BAS.TXT

mkdir prodos/bld/samples
cp samplesrc/hello.pla prodos/bld/samples/HELLO.PLA.TXT
cp samplesrc/int32test.pla prodos/bld/samples/INT32TEST.PLA.TXT
cp samplesrc/coniotest.pla prodos/bld/samples/CONIOTEST.PLA.TXT
cp samplesrc/grtest.pla prodos/bld/samples/GRTEST.PLA.TXT
cp samplesrc/dgrtest.pla prodos/bld/samples/DGRTEST.PLA.TXT
cp samplesrc/hgrtest.pla prodos/bld/samples/HGRTEST.PLA.TXT
cp samplesrc/tiletest.pla prodos/bld/samples/TILETEST.PLA.TXT
cp samplesrc/maze.pla prodos/bld/samples/MAZE.PLA.TXT
cp samplesrc/fibertest.pla prodos/bld/samples/FIBERTEST.PLA.TXT
cp samplesrc/mousetest.pla prodos/bld/samples/MOUSETEST.PLA.TXT
cp samplesrc/memtest.pla prodos/bld/samples/MEMTEST.PLA.TXT
cp samplesrc/rod.pla prodos/bld/samples/ROD.PLA.TXT
cp samplesrc/sieve.pla prodos/bld/samples/SIEVE.PLA.TXT
cp samplesrc/test.pla prodos/bld/samples/TEST.PLA.TXT
cp samplesrc/testlib.pla prodos/bld/samples/TESTLIB.PLA.TXT
cp samplesrc/playseq.pla prodos/bld/samples/PLAYSEQ.PLA.TXT
cp samplesrc/playpcm.pla prodos/bld/samples/PLAYPCM.PLA.TXT
cp samplesrc/rpncalc.pla prodos/bld/samples/RPNCALC.PLA.TXT
cp samplesrc/fatcat.pla prodos/bld/samples/FATCAT.PLA.TXT
cp samplesrc/gfxdemo.pla prodos/bld/samples/GFXDEMO.PLA.TXT
cp samplesrc/sfm.pla prodos/bld/samples/SFM.PLA.TXT
cp samplesrc/sfmsprt.pla prodos/bld/samples/SFMSPRT.PLA.TXT
cp samplesrc/fppow.pla prodos/bld/samples/FPPOW.PLA.TXT
cp utilsrc/apple/mon.pla prodos/bld/samples/MON.PLA.TXT
cp utilsrc/apple/zipchip.pla prodos/bld/samples/ZIPCHIP.PLA.TXT

cp samplesrc/testrel.asm prodos/bld/samples/TESTREL.ASM.TXT
cp samplesrc/testext.asm prodos/bld/samples/TESTEXT.ASM.TXT
cp samplesrc/testasm.pla prodos/bld/samples/TESTASM.PLA.TXT

cp libsrc/apple/debug.asm prodos/bld/samples/DEBUG.ASM.TXT
cp libsrc/apple/mxtui.pla prodos/bld/samples/MXTUI.PLA.TXT

mkdir prodos/bld/scripts
cp scripts/rod.4th prodos/bld/scripts/ROD.4TH.TXT
cp scripts/bounce.4th prodos/bld/scripts/BOUNCE.4TH.TXT
cp scripts/dbounce.4th prodos/bld/scripts/DBOUNCE.4TH.TXT
cp scripts/hrbounce.4th prodos/bld/scripts/HRBOUNCE.4TH.TXT
cp scripts/plot.4th prodos/bld/scripts/PLOT.4TH.TXT
cp scripts/grturtle.4th prodos/bld/scripts/GRTURTLE.4TH.TXT
cp scripts/hrplot.4th prodos/bld/scripts/HRPLOT.4TH.TXT
cp scripts/hrturtle.4th prodos/bld/scripts/HRTURTLE.4TH.TXT
cp scripts/gfxplot.4th prodos/bld/scripts/GFXPLOT.4TH.TXT
cp scripts/hny26.4th prodos/bld/scripts/HNY26.4TH.TXT
cp scripts/hdinstall.4th prodos/bld/scripts/HDINSTALL.4TH.TXT
cp scripts/hdinstall1.4th prodos/bld/scripts/HDINSTALL1.4TH.TXT
cp scripts/hdinstall2.4th prodos/bld/scripts/HDINSTALL2.4TH.TXT

mkdir prodos/bld/lisp
cp rel/SEXPR#FE1000 prodos/bld/lisp/SEXPR.REL
cp rel/SMATH#FE1000 prodos/bld/lisp/SMATH.REL
cp rel/DRAWL#FE1000 prodos/bld/lisp/DRAWL.REL
cp lisp/set.lisp prodos/bld/lisp/SET.LISP.TXT
cp lisp/list.lisp prodos/bld/lisp/LIST.LISP.TXT
cp lisp/maplist.lisp prodos/bld/lisp/MAPLIST.LISP.TXT
cp lisp/gcd.lisp prodos/bld/lisp/GCD.LISP.TXT
cp lisp/fact.lisp prodos/bld/lisp/FACT.LISP.TXT
cp lisp/loop.lisp prodos/bld/lisp/LOOP.LISP.TXT
cp lisp/minmax.lisp prodos/bld/lisp/MINMAX.LISP.TXT
cp lisp/prog.lisp prodos/bld/lisp/PROG.LISP.TXT
cp lisp/lores.lisp prodos/bld/lisp/LORES.LISP.TXT
cp lisp/defun.lisp prodos/bld/lisp/DEFUN.LISP.TXT
cp lisp/rod.lisp prodos/bld/lisp/ROD.LISP.TXT

#mkdir prodos/bld/examples
#cp samplesrc/examples/ex.1.pla  prodos/bld/examples/EX.1.PLA.TXT
#cp samplesrc/examples/ex.2.pla  prodos/bld/examples/EX.2.PLA.TXT
#cp samplesrc/examples/ex.3.pla  prodos/bld/examples/EX.3.PLA.TXT
#cp samplesrc/examples/ex.4.pla  prodos/bld/examples/EX.4.PLA.TXT
#cp samplesrc/examples/ex.5.pla  prodos/bld/examples/EX.5.PLA.TXT
#cp samplesrc/examples/ex.6.pla  prodos/bld/examples/EX.6.PLA.TXT
#cp samplesrc/examples/ex.7.pla  prodos/bld/examples/EX.7.PLA.TXT
#cp samplesrc/examples/ex.8.pla  prodos/bld/examples/EX.8.PLA.TXT
#cp samplesrc/examples/ex.9.pla  prodos/bld/examples/EX.9.PLA.TXT
#cp samplesrc/examples/ex.10.pla prodos/bld/examples/EX.10.PLA.TXT
#cp samplesrc/examples/ex.11.pla prodos/bld/examples/EX.11.PLA.TXT
#cp samplesrc/examples/ex.12.pla prodos/bld/examples/EX.12.PLA.TXT
#cp samplesrc/examples/ex.13.pla prodos/bld/examples/EX.13.PLA.TXT
#cp samplesrc/examples/ex.14.pla prodos/bld/examples/EX.14.PLA.TXT
#cp samplesrc/examples/ex.15.pla prodos/bld/examples/EX.15.PLA.TXT
#cp samplesrc/examples/ex.16.pla prodos/bld/examples/EX.16.PLA.TXT
#cp samplesrc/examples/ex.17.pla prodos/bld/examples/EX.17.PLA.TXT

mkdir prodos/bld/inc
cp inc/args.plh prodos/bld/inc/ARGS.PLH.TXT
cp inc/matchfiles.plh prodos/bld/inc/MATCHFILES.PLH.TXT
cp inc/cmdsys.plh prodos/bld/inc/CMDSYS.PLH.TXT
cp inc/conio.plh prodos/bld/inc/CONIO.PLH.TXT
cp inc/lines.plh prodos/bld/inc/LINES.PLH.TXT
cp inc/turtle.plh prodos/bld/inc/TURTLE.PLH.TXT
cp inc/sincos.plh prodos/bld/inc/SINCOS.PLH.TXT
cp inc/hgrfont.plh prodos/bld/inc/HGRFONT.PLH.TXT
cp inc/hgrtile.plh prodos/bld/inc/HGRTILE.PLH.TXT
cp inc/hgrsprite.plh prodos/bld/inc/HGRSPRITE.PLH.TXT
cp inc/hgrlib.plh prodos/bld/inc/HGRLIB.PLH.TXT
cp inc/grlib.plh prodos/bld/inc/GRLIB.PLH.TXT
cp inc/dgrlib.plh prodos/bld/inc/DGRLIB.PLH.TXT
cp inc/vblank.plh prodos/bld/inc/VBLANK.PLH.TXT
cp inc/fiber.plh prodos/bld/inc/FIBER.PLH.TXT
cp inc/fileio.plh prodos/bld/inc/FILEIO.PLH.TXT
cp inc/int32.plh prodos/bld/inc/INT32.PLH.TXT
cp inc/fpstr.plh prodos/bld/inc/FPSTR.PLH.TXT
cp inc/fpu.plh prodos/bld/inc/FPU.PLH.TXT
cp inc/mouse.plh prodos/bld/inc/MOUSE.PLH.TXT
cp inc/inet.plh prodos/bld/inc/INET.PLH.TXT
cp inc/longjmp.plh prodos/bld/inc/LONGJMP.PLH.TXT
cp inc/memmgr.plh prodos/bld/inc/MEMMGR.PLH.TXT
cp inc/sane.plh prodos/bld/inc/SANE.PLH.TXT
cp inc/joybuzz.plh prodos/bld/inc/JOYBUZZ.PLH.TXT
cp inc/portio.plh prodos/bld/inc/PORTIO.PLH.TXT
cp inc/sdfat.plh prodos/bld/inc/SDFAT.PLH.TXT
cp inc/sndseq.plh prodos/bld/inc/SNDSEQ.PLH.TXT
cp inc/spiport.plh prodos/bld/inc/SPIPORT.PLH.TXT
cp inc/testlib.plh prodos/bld/inc/TESTLIB.PLH.TXT
cp inc/grafix.plh prodos/bld/inc/GRAFIX.PLH.TXT
cp inc/lz4.plh prodos/bld/inc/LZ4.PLH.TXT
cp inc/plasma.inc prodos/bld/inc/PLASMA.INC.TXT
cp inc/extheader.inc prodos/bld/inc/EXTHEADER.INC.TXT
cp inc/extdefseg.inc prodos/bld/inc/EXTDEFSEG.INC.TXT

make -f dhgr.tk/makefile all
