Skip to content

Commit

Permalink
screen hole patching directly in c2d, more test options
Browse files Browse the repository at this point in the history
  • Loading branch information
datajerk committed Apr 22, 2017
1 parent f56cd48 commit 081a78b
Show file tree
Hide file tree
Showing 13 changed files with 136 additions and 92 deletions.
19 changes: 12 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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

9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 ([email protected])

Expand Down
Binary file modified bin/c2d
Binary file not shown.
Binary file modified bin/c2d.exe
Binary file not shown.
Binary file modified bin/page2text.exe
Binary file not shown.
Binary file modified bin/text2page.exe
Binary file not shown.
34 changes: 29 additions & 5 deletions c2d.c
Original file line number Diff line number Diff line change
@@ -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 ([email protected])
Expand Down Expand Up @@ -41,8 +41,9 @@ Based on work by:
#include <math.h>
#include <sys/stat.h>
#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
Expand All @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions c2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down
7 changes: 4 additions & 3 deletions c2d.h.0
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down
10 changes: 10 additions & 0 deletions holes.h
Original file line number Diff line number Diff line change
@@ -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
};
2 changes: 1 addition & 1 deletion test.scrp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
128 changes: 70 additions & 58 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
12 changes: 1 addition & 11 deletions text2page.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
#include <stdio.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
};
#include "holes.h"

#define NORMAL 0x80
#define BLINK 0x40
Expand Down

0 comments on commit 081a78b

Please sign in to comment.