screen hole patching directly in c2d, more test options

This commit is contained in:
Egan Ford 2017-04-22 10:33:53 -06:00
parent f56cd484e6
commit 081a78b10f
13 changed files with 136 additions and 92 deletions

View File

@ -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 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 all: bin/c2d bin/text2page bin/page2text
@ -11,16 +10,16 @@ dist: all windows
c2d.h: c2d.h.0 asm/loader.s makeheader c2d.h: c2d.h.0 asm/loader.s makeheader
./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 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 $@ $< $(WIN32GCC) -Wall -Wno-missing-braces -I. -O3 -o $@ $<
bin/text2page: text2page.c bin/text2page: text2page.c holes.h
gcc -Wall -O3 -o $@ $< -lm gcc -Wall -O3 -o $@ $< -lm
bin/text2page.exe: text2page.c bin/text2page.exe: text2page.c holes.h
$(WIN32GCC) -Wall -O3 -o $@ $< $(WIN32GCC) -Wall -O3 -o $@ $<
bin/page2text: page2text.c bin/page2text: page2text.c
@ -36,6 +35,12 @@ clean:
gameserverclient.text: Makefile gameserverclient.text: Makefile
figlet -c -w 40 -f slant "Game Server Online Client" >$@ figlet -c -w 40 -f slant "Game Server Online Client" >$@
test: gameserverclient gameserverclient.mon gameserverclient.text dist emutest: gameserverclient gameserverclient.mon gameserverclient.text dist
EMU=$(EMUTEST) ./test.sh 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

View File

@ -51,13 +51,14 @@ Windows/MinGW:
``` ```
usage: c2d [-vh?] 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 -h|? this help
-m jump to monitor after booting -m jump to monitor after booting
-s XXXX jump to XXXX after booting -s XXXX jump to XXXX after booting
-t filename where filename is a 1K $400-$7FF text page splash screen. -t filename, where filename is a 1K $400-$7FF text page splash screen
The splash screen will display while the binary is loading. The splash screen will display while the binary is loading
-u do not patch screen holes
-v print version number and exit -v print version number and exit
Input without a .mon extension is assumed to be a binary with a 4 byte header. 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 ### 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) (c) 2012,2017 All Rights Reserved, Egan Ford (egan@sense.net)

BIN
bin/c2d

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

34
c2d.c
View File

@ -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) (c) 2012,2017 All Rights Reserved, Egan Ford (egan@sense.net)
@ -41,8 +41,9 @@ Bugs:
#include <math.h> #include <math.h>
#include <sys/stat.h> #include <sys/stat.h>
#include "c2d.h" #include "c2d.h"
#include "holes.h"
#define VERSION "Version 0.51" #define VERSION "Version 0.53"
#define INFILE argv[argc-2] #define INFILE argv[argc-2]
#define OUTFILE argv[argc-1] #define OUTFILE argv[argc-1]
#define BINARY 0 #define BINARY 0
@ -55,14 +56,14 @@ char *getext(char *filename);
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
FILE *ifp, *ofp; 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; int loaderstart, loader = 0, loadersize = 0, textpagesize = 0;
struct stat st; struct stat st;
char *filetypes[] = { "BINARY", "MONITOR" }; char *filetypes[] = { "BINARY", "MONITOR" };
char *ext, filename[256], load_address[10], *textpage = NULL; char *ext, filename[256], load_address[10], *textpage = NULL;
opterr = 1; opterr = 1;
while ((c = getopt(argc, argv, "t:vmh?s:")) != -1) while ((c = getopt(argc, argv, "t:vmh?s:u")) != -1)
switch (c) { switch (c) {
case 't': // load a splash page while loading binary case 't': // load a splash page while loading binary
loader = 1; loader = 1;
@ -79,6 +80,9 @@ int main(int argc, char **argv)
warm = 0; warm = 0;
start = (int) strtol(optarg, (char **) NULL, 16); // todo: input check start = (int) strtol(optarg, (char **) NULL, 16); // todo: input check
break; break;
case 'u':
unpatch = 1;
break;
case 'h': // help case 'h': // help
case '?': case '?':
usage(); usage();
@ -209,9 +213,25 @@ int main(int argc, char **argv)
return 1; return 1;
} }
// check for errors
fread(&blank.track[1].sector[0].byte[0], textpagesize, 1, ifp); fread(&blank.track[1].sector[0].byte[0], textpagesize, 1, ifp);
fclose(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) { if ((loadersize = sizeof(loadercode)) > 256) {
fprintf(stderr, "Loader code size %d > 256\n\n", loadersize); fprintf(stderr, "Loader code size %d > 256\n\n", loadersize);
return 1; return 1;
@ -233,7 +253,11 @@ int main(int argc, char **argv)
blank.track[1].sector[4].byte[loadersize + 4] = start >> 8; blank.track[1].sector[4].byte[loadersize + 4] = start >> 8;
loaderstart = 0x400; 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[0xE0] = ceil((loadersize + (loaderstart & 0xFF)) / 256.0);
blank.track[0].sector[1].byte[0xE7] = ((loaderstart + loadersize - 1) >> 8) + 1; blank.track[0].sector[1].byte[0xE7] = ((loaderstart + loadersize - 1) >> 8) + 1;

7
c2d.h
View File

@ -13,13 +13,14 @@ typedef struct d {
const char *usagetext="\n\ const char *usagetext="\n\
usage: c2d [-vh?]\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\ \n\
-h|? this help\n\ -h|? this help\n\
-m jump to monitor after booting\n\ -m jump to monitor after booting\n\
-s XXXX jump to XXXX 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\ -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\ 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\ -v print version number and exit\n\
\n\ \n\
Input without a .mon extension is assumed to be a binary with a 4 byte header.\n\ Input without a .mon extension is assumed to be a binary with a 4 byte header.\n\

View File

@ -13,13 +13,14 @@ typedef struct d {
const char *usagetext="\n\ const char *usagetext="\n\
usage: c2d [-vh?]\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\ \n\
-h|? this help\n\ -h|? this help\n\
-m jump to monitor after booting\n\ -m jump to monitor after booting\n\
-s XXXX jump to XXXX 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\ -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\ 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\ -v print version number and exit\n\
\n\ \n\
Input without a .mon extension is assumed to be a binary with a 4 byte header.\n\ Input without a .mon extension is assumed to be a binary with a 4 byte header.\n\

10
holes.h Normal file
View File

@ -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
};

View File

@ -10,7 +10,7 @@ on run argv
tell application "Virtual ][" tell application "Virtual ]["
activate activate
-- may need delay for this error: execution error: Virtual ][ got an error: Connection is invalid. (-609) -- 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 all open machines
close every machine saving no close every machine saving no
-- Create a new (AppleIIe) -- Create a new (AppleIIe)

128
test.sh
View File

@ -41,23 +41,26 @@ then
echo PASSED echo PASSED
fi fi
rm -f ${BIN}.dsk if ((WIN == 1))
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 then
echo PASSED rm -f ${BIN}.dsk
else echo
echo "FAILED $CHECK != $SUM (expected)" echo "Testing Windows c2d..."
exit 1 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 fi
SUM=c829f377a6a1040bebb68bd3365c522c SUM=45ac447dc3e2e762c2b5ab1180682d34
rm -f ${BIN}.dsk rm -f ${BIN}.dsk
echo echo
@ -95,22 +98,25 @@ then
echo PASSED echo PASSED
fi fi
rm -f ${BIN}.dsk if ((WIN == 1))
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 then
echo PASSED rm -f ${BIN}.dsk
else echo
echo "FAILED $CHECK != $SUM (expected)" echo "Testing Windows c2d textpage..."
exit 1 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 fi
BIN=gameserverclient BIN=gameserverclient
@ -133,23 +139,26 @@ else
exit 1 exit 1
fi fi
rm -f ${BIN}.dsk if ((WIN == 1))
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 then
echo PASSED rm -f ${BIN}.dsk
else echo
echo "FAILED $CHECK != $SUM (expected)" echo "Testing Windows c2d..."
exit 1 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 fi
SUM=c829f377a6a1040bebb68bd3365c522c SUM=45ac447dc3e2e762c2b5ab1180682d34
rm -f ${BIN}.dsk rm -f ${BIN}.dsk
echo echo
@ -168,22 +177,25 @@ else
exit 1 exit 1
fi fi
rm -f ${BIN}.dsk if ((WIN == 1))
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 then
echo PASSED rm -f ${BIN}.dsk
else echo
echo "FAILED $CHECK != $SUM (expected)" echo "Testing Windows c2d textpage..."
exit 1 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 fi
echo echo

View File

@ -1,15 +1,5 @@
#include <stdio.h> #include <stdio.h>
#include "holes.h"
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
};
#define NORMAL 0x80 #define NORMAL 0x80
#define BLINK 0x40 #define BLINK 0x40