mirror of https://github.com/datajerk/c2d.git
added text2page tool
This commit is contained in:
parent
e1f98db29c
commit
e5c8ac68e7
10
Makefile
10
Makefile
|
@ -1,9 +1,9 @@
|
|||
|
||||
WIN32GCC = /usr/local/gcc-4.8.0-qt-4.8.4-for-mingw32/win32-gcc/bin/i586-mingw32-gcc
|
||||
|
||||
all: bin/c2d
|
||||
all: bin/c2d bin/text2page
|
||||
|
||||
windows: bin/c2d.exe
|
||||
windows: bin/c2d.exe bin/text2page.exe
|
||||
|
||||
dist: all windows
|
||||
|
||||
|
@ -16,6 +16,12 @@ bin/c2d: c2d.c c2d.h
|
|||
bin/c2d.exe: c2d.c c2d.h
|
||||
$(WIN32GCC) -Wall -Wno-missing-braces -I. -O3 -o bin/c2d.exe c2d.c
|
||||
|
||||
bin/text2page: text2page.c
|
||||
gcc -Wall -O3 -o bin/text2page text2page.c -lm
|
||||
|
||||
bin/text2page.exe: text2page.c
|
||||
$(WIN32GCC) -Wall -O3 -o bin/text2page.exe text2page.c
|
||||
|
||||
clean:
|
||||
rm -f bin/* *.dsk
|
||||
|
||||
|
|
BIN
bin/c2d.exe
BIN
bin/c2d.exe
Binary file not shown.
15
c2d.c
15
c2d.c
|
@ -66,7 +66,7 @@ char *getext(char *filename);
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
FILE *ifp, *ofp;
|
||||
int c, j, k, start = 0, loadaddress, inputtype, warm = 0, filesize = 0;
|
||||
int c, i, j, k, start = 0, loadaddress, inputtype, warm = 0, filesize = 0;
|
||||
int loaderstart, loader = 0, loadersize = 0, textpagesize = 0;
|
||||
struct stat st;
|
||||
char *filetypes[] = {"BINARY","MONITOR"};
|
||||
|
@ -224,16 +224,13 @@ int main(int argc, char **argv)
|
|||
fread(&blank.track[1].sector[0].byte[0], textpagesize, 1, ifp);
|
||||
fclose(ifp);
|
||||
|
||||
if ((ifp = fopen(LOADER, "rb")) == NULL) {
|
||||
fprintf(stderr,"Cannot read: %s\n\n",LOADER);
|
||||
if((loadersize = sizeof(loadercode)) > 256) {
|
||||
fprintf(stderr,"Loader code size %d > 256\n\n",loadersize);
|
||||
return 1;
|
||||
}
|
||||
|
||||
stat(LOADER,&st);
|
||||
loadersize = st.st_size;
|
||||
|
||||
fread(&blank.track[1].sector[4].byte[0], loadersize, 1, ifp);
|
||||
fclose(ifp);
|
||||
for(i=0;i<loadersize;i++)
|
||||
blank.track[1].sector[4].byte[i]=loadercode[i];
|
||||
|
||||
// loader args
|
||||
// lasttrack
|
||||
|
@ -271,7 +268,7 @@ int main(int argc, char **argv)
|
|||
fprintf(stderr,"After boot, jump to: $%04X\n",loaderstart);
|
||||
fprintf(stderr,"After loader, jump to: $%04X\n",start);
|
||||
fprintf(stderr,"\n");
|
||||
fprintf(stderr,"Writing %s to T:02/S:00 - T:%02d/S:%02d on %s\n\n",filename,blank.track[1].sector[4].byte[st.st_size],blank.track[1].sector[4].byte[st.st_size+1],OUTFILE);
|
||||
fprintf(stderr,"Writing %s to T:02/S:00 - T:%02d/S:%02d on %s\n\n",filename,blank.track[1].sector[4].byte[sizeof(loadercode)],blank.track[1].sector[4].byte[sizeof(loadercode)+1],OUTFILE);
|
||||
}
|
||||
|
||||
if ((ofp = fopen(OUTFILE, "wb")) == NULL) {
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
|
||||
____ _____ _____ ___ ___
|
||||
/ __ `/ __ `/ __ `__ \/ _ \
|
||||
/ /_/ / /_/ / / / / / / __/
|
||||
\__, /\__,_/_/ /_/ /_/\___/
|
||||
/____/
|
||||
|
||||
________ ______ _____ _____
|
||||
/ ___/ _ \/ ___/ | / / _ \/ ___/
|
||||
(__ ) __/ / | |/ / __/ /
|
||||
/____/\___/_/ |___/\___/_/
|
||||
|
||||
___ __
|
||||
_____/ (_)__ ____ / /_
|
||||
/ ___/ / / _ \/ __ \/ __/
|
||||
/ /__/ / / __/ / / / /_
|
||||
\___/_/_/\___/_/ /_/\__/
|
||||
|
||||
|
||||
|
||||
LOADING...
|
Binary file not shown.
30
test.sh
30
test.sh
|
@ -33,3 +33,33 @@ else
|
|||
exit 1
|
||||
fi
|
||||
|
||||
SUM=d12ba3c2db1cd3de352f182e0530940d
|
||||
|
||||
rm -f ${BIN}.dsk
|
||||
echo
|
||||
echo "Testing OS/X c2d textpage..."
|
||||
bin/text2page <${BIN}.text >${BIN}.textpage
|
||||
bin/c2d -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
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -f ${BIN}.dsk
|
||||
echo
|
||||
echo "Testing Windows c2d textpage..."
|
||||
PATH=$HOME/wine/bin:$PATH
|
||||
wine bin/text2page.exe <${BIN}.text >${BIN}.textpage
|
||||
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
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
#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
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
char c, highbit = 0x80;
|
||||
int i, j, k, columns = 0, lines = 0, linemap[24];
|
||||
unsigned char screen[24][40];
|
||||
|
||||
// build table
|
||||
for(j=0,i=0;i<8;i++) {
|
||||
linemap[ 0 + j]=0+3*j;
|
||||
linemap[ 8 + j]=1+3*j;
|
||||
linemap[16 + j]=2+3*j;
|
||||
j++;
|
||||
}
|
||||
|
||||
// clear screen
|
||||
for(i=0;i<24;i++)
|
||||
for(j=0;j<40;j++)
|
||||
screen[linemap[i]][j] = ' ' | highbit;
|
||||
|
||||
while((c = getchar()) != EOF) {
|
||||
if(c == '\r') // windows trash
|
||||
continue;
|
||||
if(columns > 40) // user didn't read the docs
|
||||
continue;
|
||||
if(lines > 24) // ditto
|
||||
break;
|
||||
if(c == '\n') { // end of line
|
||||
columns=0;
|
||||
lines++;
|
||||
continue;
|
||||
}
|
||||
|
||||
screen[linemap[lines]][columns] = c | highbit;
|
||||
columns++;
|
||||
}
|
||||
|
||||
// dump to stdout
|
||||
for(i=0;i<24;i++) {
|
||||
for(j=0;j<40;j++)
|
||||
putchar(screen[i][j]);
|
||||
if((i + 1) % 3 == 0)
|
||||
for(k=0;k<8;k++)
|
||||
putchar(holes[(i/3)*8+k]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue