diff --git a/Makefile b/Makefile index 7e8df3b..8da771d 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,4 @@ -EMUTEST = 1 WIN32GCC = /usr/local/gcc-4.8.0-qt-4.8.4-for-mingw32/win32-gcc/bin/i586-mingw32-gcc all: bin/c2d bin/text2page bin/page2text @@ -11,16 +10,16 @@ dist: all windows c2d.h: c2d.h.0 asm/loader.s makeheader ./makeheader -bin/c2d: c2d.c c2d.h +bin/c2d: c2d.c c2d.h holes.h gcc -Wall -Wno-missing-braces -I. -O3 -o $@ $< -lm -bin/c2d.exe: c2d.c c2d.h +bin/c2d.exe: c2d.c c2d.h holes.h $(WIN32GCC) -Wall -Wno-missing-braces -I. -O3 -o $@ $< -bin/text2page: text2page.c +bin/text2page: text2page.c holes.h gcc -Wall -O3 -o $@ $< -lm -bin/text2page.exe: text2page.c +bin/text2page.exe: text2page.c holes.h $(WIN32GCC) -Wall -O3 -o $@ $< bin/page2text: page2text.c @@ -36,6 +35,12 @@ clean: gameserverclient.text: Makefile figlet -c -w 40 -f slant "Game Server Online Client" >$@ -test: gameserverclient gameserverclient.mon gameserverclient.text dist - EMU=$(EMUTEST) ./test.sh +emutest: gameserverclient gameserverclient.mon gameserverclient.text dist + EMU=1 WIN=1 ./test.sh + +fulltest: gameserverclient gameserverclient.mon gameserverclient.text dist + EMU=0 WIN=1 ./test.sh + +test: gameserverclient gameserverclient.mon gameserverclient.text all + EMU=0 WIN=0 ./test.sh diff --git a/README.md b/README.md index 90955f2..8c27036 100644 --- a/README.md +++ b/README.md @@ -51,13 +51,14 @@ Windows/MinGW: ``` usage: c2d [-vh?] - c2d [-m] [-t filename] [-s start address override] input[.mon],[load_address] output.dsk + c2d [-mu] [-t filename] [-s start address override] input[.mon],[load_address] output.dsk -h|? this help -m jump to monitor after booting -s XXXX jump to XXXX after booting - -t filename where filename is a 1K $400-$7FF text page splash screen. - The splash screen will display while the binary is loading. + -t filename, where filename is a 1K $400-$7FF text page splash screen + The splash screen will display while the binary is loading + -u do not patch screen holes -v print version number and exit Input without a .mon extension is assumed to be a binary with a 4 byte header. @@ -103,7 +104,7 @@ Yes. No input checking. Big Endian untested. ### The Ugly Stuff -c2d, Code to Disk, Version 0.51, Fri Apr 21 23:13:38 UTC 2017 +c2d, Code to Disk, Version 0.53 (c) 2012,2017 All Rights Reserved, Egan Ford (egan@sense.net) diff --git a/bin/c2d b/bin/c2d index a9bccf0..3517130 100755 Binary files a/bin/c2d and b/bin/c2d differ diff --git a/bin/c2d.exe b/bin/c2d.exe index 82bdd1a..833721b 100755 Binary files a/bin/c2d.exe and b/bin/c2d.exe differ diff --git a/bin/page2text.exe b/bin/page2text.exe index 0b66a0f..77bd009 100755 Binary files a/bin/page2text.exe and b/bin/page2text.exe differ diff --git a/bin/text2page.exe b/bin/text2page.exe index 3ee63ac..7b2781d 100755 Binary files a/bin/text2page.exe and b/bin/text2page.exe differ diff --git a/c2d.c b/c2d.c index 0d8228e..e9a8f60 100644 --- a/c2d.c +++ b/c2d.c @@ -1,6 +1,6 @@ /* -c2d, Code to Disk, Version 0.51, Fri Apr 21 23:13:38 UTC 2017 +c2d, Code to Disk, Version 0.53 (c) 2012,2017 All Rights Reserved, Egan Ford (egan@sense.net) @@ -41,8 +41,9 @@ Bugs: #include #include #include "c2d.h" +#include "holes.h" -#define VERSION "Version 0.51" +#define VERSION "Version 0.53" #define INFILE argv[argc-2] #define OUTFILE argv[argc-1] #define BINARY 0 @@ -55,14 +56,14 @@ char *getext(char *filename); int main(int argc, char **argv) { FILE *ifp, *ofp; - int c, i, j, k, start = 0, loadaddress, inputtype, warm = 0, filesize = 0; + int c, i, j, k, start = 0, loadaddress, inputtype, warm = 0, filesize = 0, unpatch = 0; int loaderstart, loader = 0, loadersize = 0, textpagesize = 0; struct stat st; char *filetypes[] = { "BINARY", "MONITOR" }; char *ext, filename[256], load_address[10], *textpage = NULL; opterr = 1; - while ((c = getopt(argc, argv, "t:vmh?s:")) != -1) + while ((c = getopt(argc, argv, "t:vmh?s:u")) != -1) switch (c) { case 't': // load a splash page while loading binary loader = 1; @@ -79,6 +80,9 @@ int main(int argc, char **argv) warm = 0; start = (int) strtol(optarg, (char **) NULL, 16); // todo: input check break; + case 'u': + unpatch = 1; + break; case 'h': // help case '?': usage(); @@ -209,9 +213,25 @@ int main(int argc, char **argv) return 1; } + // check for errors fread(&blank.track[1].sector[0].byte[0], textpagesize, 1, ifp); fclose(ifp); + // patch holes + if(!unpatch) + { + uint64_t *p = (uint64_t *)&blank.track[1].sector[0].byte[0]; // set to start of splash page + uint64_t *h = (uint64_t *)&holes; // holes are 64-bits + int i; + + p -= 1; // back up virtual hole + + for(i = 0; i < 8; i++) { + p += 16; // 3 lines x 40 columns + last hole / 8 (64-bit); + *p = *h++; // copy screen hole data + } + } + if ((loadersize = sizeof(loadercode)) > 256) { fprintf(stderr, "Loader code size %d > 256\n\n", loadersize); return 1; @@ -233,7 +253,11 @@ int main(int argc, char **argv) blank.track[1].sector[4].byte[loadersize + 4] = start >> 8; loaderstart = 0x400; - loadersize += (1024 + 5); // textpage + loader + loader args + + // temp hack to effect the sound of the drive, i.e. to make consistent + // longer term put binary payload at end of loader + // loadersize += (1024 + 5); // textpage + loader + loader args + loadersize = 4096; blank.track[0].sector[1].byte[0xE0] = ceil((loadersize + (loaderstart & 0xFF)) / 256.0); blank.track[0].sector[1].byte[0xE7] = ((loaderstart + loadersize - 1) >> 8) + 1; diff --git a/c2d.h b/c2d.h index 1d0621c..631728c 100644 --- a/c2d.h +++ b/c2d.h @@ -13,13 +13,14 @@ typedef struct d { const char *usagetext="\n\ usage: c2d [-vh?]\n\ - c2d [-m] [-t filename] [-s start address override] input[.mon],[load_address] output.dsk\n\ + c2d [-mu] [-t filename] [-s start address override] input[.mon],[load_address] output.dsk\n\ \n\ -h|? this help\n\ -m jump to monitor after booting\n\ -s XXXX jump to XXXX after booting\n\ - -t filename, where filename is a 1K $400-$7FF text page splash screen.\n\ - The splash screen will display while the binary is loading.\n\ + -t filename, where filename is a 1K $400-$7FF text page splash screen\n\ + The splash screen will display while the binary is loading\n\ + -u do not patch screen holes\n\ -v print version number and exit\n\ \n\ Input without a .mon extension is assumed to be a binary with a 4 byte header.\n\ diff --git a/c2d.h.0 b/c2d.h.0 index 4108116..bd3c82a 100644 --- a/c2d.h.0 +++ b/c2d.h.0 @@ -13,13 +13,14 @@ typedef struct d { const char *usagetext="\n\ usage: c2d [-vh?]\n\ - c2d [-m] [-t filename] [-s start address override] input[.mon],[load_address] output.dsk\n\ + c2d [-mu] [-t filename] [-s start address override] input[.mon],[load_address] output.dsk\n\ \n\ -h|? this help\n\ -m jump to monitor after booting\n\ -s XXXX jump to XXXX after booting\n\ - -t filename, where filename is a 1K $400-$7FF text page splash screen.\n\ - The splash screen will display while the binary is loading.\n\ + -t filename, where filename is a 1K $400-$7FF text page splash screen\n\ + The splash screen will display while the binary is loading\n\ + -u do not patch screen holes\n\ -v print version number and exit\n\ \n\ Input without a .mon extension is assumed to be a binary with a 4 byte header.\n\ diff --git a/holes.h b/holes.h new file mode 100644 index 0000000..e6d6bf5 --- /dev/null +++ b/holes.h @@ -0,0 +1,10 @@ +unsigned char holes[] = { + 0x37, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, + 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x17, 0xff, 0xff, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0xff, 0xff, 0x00, 0xd0, 0xff, 0xff, 0x00, 0x00, + 0xc6, 0xff, 0x00, 0x07, 0xff, 0xff, 0x00, 0x00 +}; diff --git a/test.scrp b/test.scrp index 79d583f..ce33a3b 100644 --- a/test.scrp +++ b/test.scrp @@ -10,7 +10,7 @@ on run argv tell application "Virtual ][" activate -- may need delay for this error: execution error: Virtual ][ got an error: Connection is invalid. (-609) - delay 0.5 + delay 1.0 -- Close all open machines close every machine saving no -- Create a new (AppleIIe) diff --git a/test.sh b/test.sh index 85185ae..98a6a2c 100755 --- a/test.sh +++ b/test.sh @@ -41,23 +41,26 @@ then echo PASSED fi -rm -f ${BIN}.dsk -echo -echo "Testing Windows c2d..." -echo -PATH=$HOME/wine/bin:$PATH -echo "wine bin/c2d.exe ${BIN},${ADDR} ${BIN}.dsk" -wine bin/c2d.exe ${BIN},${ADDR} ${BIN}.dsk 2>&1 | sed 's/^/ /' -CHECK=$(md5sum ${BIN}.dsk | awk '{print $1}') -if [ "$CHECK" = "$SUM" ] +if ((WIN == 1)) then - echo PASSED -else - echo "FAILED $CHECK != $SUM (expected)" - exit 1 + rm -f ${BIN}.dsk + echo + echo "Testing Windows c2d..." + echo + PATH=$HOME/wine/bin:$PATH + echo "wine bin/c2d.exe ${BIN},${ADDR} ${BIN}.dsk" + wine bin/c2d.exe ${BIN},${ADDR} ${BIN}.dsk 2>&1 | sed 's/^/ /' + CHECK=$(md5sum ${BIN}.dsk | awk '{print $1}') + if [ "$CHECK" = "$SUM" ] + then + echo PASSED + else + echo "FAILED $CHECK != $SUM (expected)" + exit 1 + fi fi -SUM=c829f377a6a1040bebb68bd3365c522c +SUM=45ac447dc3e2e762c2b5ab1180682d34 rm -f ${BIN}.dsk echo @@ -95,22 +98,25 @@ then echo PASSED fi -rm -f ${BIN}.dsk -echo -echo "Testing Windows c2d textpage..." -echo -PATH=$HOME/wine/bin:$PATH -echo "wine bin/text2page.exe <${BIN}.text >${BIN}.textpage" -wine bin/text2page.exe <${BIN}.text >${BIN}.textpage -echo "wine bin/c2d.exe -t ${BIN}.textpage ${BIN},${ADDR} ${BIN}.dsk" -wine bin/c2d.exe -t ${BIN}.textpage ${BIN},${ADDR} ${BIN}.dsk 2>&1 | sed 's/^/ /' -CHECK=$(md5sum ${BIN}.dsk | awk '{print $1}') -if [ "$CHECK" = "$SUM" ] +if ((WIN == 1)) then - echo PASSED -else - echo "FAILED $CHECK != $SUM (expected)" - exit 1 + rm -f ${BIN}.dsk + echo + echo "Testing Windows c2d textpage..." + echo + PATH=$HOME/wine/bin:$PATH + echo "wine bin/text2page.exe <${BIN}.text >${BIN}.textpage" + wine bin/text2page.exe <${BIN}.text >${BIN}.textpage + echo "wine bin/c2d.exe -t ${BIN}.textpage ${BIN},${ADDR} ${BIN}.dsk" + wine bin/c2d.exe -t ${BIN}.textpage ${BIN},${ADDR} ${BIN}.dsk 2>&1 | sed 's/^/ /' + CHECK=$(md5sum ${BIN}.dsk | awk '{print $1}') + if [ "$CHECK" = "$SUM" ] + then + echo PASSED + else + echo "FAILED $CHECK != $SUM (expected)" + exit 1 + fi fi BIN=gameserverclient @@ -133,23 +139,26 @@ else exit 1 fi -rm -f ${BIN}.dsk -echo -echo "Testing Windows c2d..." -echo -PATH=$HOME/wine/bin:$PATH -echo "wine bin/c2d.exe ${BIN},${ADDR} ${BIN}.dsk" -wine bin/c2d.exe ${MON} ${BIN}.dsk 2>&1 | sed 's/^/ /' -CHECK=$(md5sum ${BIN}.dsk | awk '{print $1}') -if [ "$CHECK" = "$SUM" ] +if ((WIN == 1)) then - echo PASSED -else - echo "FAILED $CHECK != $SUM (expected)" - exit 1 +rm -f ${BIN}.dsk + echo + echo "Testing Windows c2d..." + echo + PATH=$HOME/wine/bin:$PATH + echo "wine bin/c2d.exe ${BIN},${ADDR} ${BIN}.dsk" + wine bin/c2d.exe ${MON} ${BIN}.dsk 2>&1 | sed 's/^/ /' + CHECK=$(md5sum ${BIN}.dsk | awk '{print $1}') + if [ "$CHECK" = "$SUM" ] + then + echo PASSED + else + echo "FAILED $CHECK != $SUM (expected)" + exit 1 + fi fi -SUM=c829f377a6a1040bebb68bd3365c522c +SUM=45ac447dc3e2e762c2b5ab1180682d34 rm -f ${BIN}.dsk echo @@ -168,22 +177,25 @@ else exit 1 fi -rm -f ${BIN}.dsk -echo -echo "Testing Windows c2d textpage..." -echo -PATH=$HOME/wine/bin:$PATH -echo "wine bin/text2page.exe <${BIN}.text >${BIN}.textpage" -wine bin/text2page.exe <${BIN}.text >${BIN}.textpage -echo "wine bin/c2d.exe -t ${BIN}.textpage ${BIN},${ADDR} ${BIN}.dsk" -wine bin/c2d.exe -t ${BIN}.textpage ${MON} ${BIN}.dsk 2>&1 | sed 's/^/ /' -CHECK=$(md5sum ${BIN}.dsk | awk '{print $1}') -if [ "$CHECK" = "$SUM" ] +if ((WIN == 1)) then - echo PASSED -else - echo "FAILED $CHECK != $SUM (expected)" - exit 1 + rm -f ${BIN}.dsk + echo + echo "Testing Windows c2d textpage..." + echo + PATH=$HOME/wine/bin:$PATH + echo "wine bin/text2page.exe <${BIN}.text >${BIN}.textpage" + wine bin/text2page.exe <${BIN}.text >${BIN}.textpage + echo "wine bin/c2d.exe -t ${BIN}.textpage ${BIN},${ADDR} ${BIN}.dsk" + wine bin/c2d.exe -t ${BIN}.textpage ${MON} ${BIN}.dsk 2>&1 | sed 's/^/ /' + CHECK=$(md5sum ${BIN}.dsk | awk '{print $1}') + if [ "$CHECK" = "$SUM" ] + then + echo PASSED + else + echo "FAILED $CHECK != $SUM (expected)" + exit 1 + fi fi echo diff --git a/text2page.c b/text2page.c index 5252ecf..98780eb 100644 --- a/text2page.c +++ b/text2page.c @@ -1,15 +1,5 @@ #include - -unsigned char holes[] = { - 0x37, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, - 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x17, 0xff, 0xff, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0xff, 0xff, 0x00, 0xd0, 0xff, 0xff, 0x00, 0x00, - 0xc6, 0xff, 0x00, 0x07, 0xff, 0xff, 0x00, 0x00 -}; +#include "holes.h" #define NORMAL 0x80 #define BLINK 0x40