mirror of
https://github.com/dschmenk/apple2pi.git
synced 2024-11-24 12:31:30 +00:00
MERLIN <-> text conversion utility
This commit is contained in:
parent
d5daf6f970
commit
2eaf496d05
@ -1,4 +1,4 @@
|
||||
BIN=a2serclk a2pid a2mon a2term dskread dskwrite bintomon bload brun
|
||||
BIN=a2serclk a2pid a2mon a2term dskread dskwrite bintomon bload brun text2merlin merlin2text
|
||||
all: $(BIN)
|
||||
|
||||
fusea2pi: fusea2pi.c a2lib.c
|
||||
|
31
src/merlin2text.c
Executable file
31
src/merlin2text.c
Executable file
@ -0,0 +1,31 @@
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int fin, comment, charpos;
|
||||
char c;
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
fin = open(argv[1], O_RDONLY, 0);
|
||||
}
|
||||
else
|
||||
fin = 0;
|
||||
comment = charpos = 0;
|
||||
while (read(fin, &c, 1) == 1)
|
||||
{
|
||||
c &= 0x7f;
|
||||
if ((charpos++ == 0 && c == '*') || c == ';')
|
||||
comment = 1;
|
||||
if (c == '\r')
|
||||
{
|
||||
comment = charpos = 0;
|
||||
c = '\n';
|
||||
}
|
||||
if (c == ' ' && !comment)
|
||||
c = '\t';
|
||||
putc(c & 0x7f, stdout);
|
||||
}
|
||||
return (0);
|
||||
}
|
24
src/text2merlin.c
Executable file
24
src/text2merlin.c
Executable file
@ -0,0 +1,24 @@
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int fout;
|
||||
char c;
|
||||
|
||||
if (argc > 1)
|
||||
fout = open(argv[1], O_WRONLY|O_CREAT, 0644);
|
||||
else
|
||||
fout = 1;
|
||||
while ((c = getc(stdin)) != EOF)
|
||||
{
|
||||
if (c == '\n')
|
||||
c = '\r';
|
||||
if (c == '\t')
|
||||
c = ' ';
|
||||
c |= 0x80;
|
||||
write(fout, &c, 1);
|
||||
}
|
||||
close(fout);
|
||||
return (0);
|
||||
}
|
Loading…
Reference in New Issue
Block a user