dos33fsprogs/games/keen/story/make_story.c

85 lines
1.2 KiB
C
Raw Normal View History

2024-05-06 05:32:33 +00:00
#include <stdio.h>
2024-05-08 23:52:31 +00:00
#include <string.h>
2024-05-06 05:32:33 +00:00
2024-05-09 20:45:11 +00:00
/* If doing cycle-counted code we don't want to cross pages */
/* in that case, skip bytes from 240-256 */
static int dont_page_cross=1;
2024-05-06 05:32:33 +00:00
int main(int argc, char **argv) {
char string[BUFSIZ];
char *result;
int inverse=0;
2024-05-08 23:52:31 +00:00
int count,i,length;
2024-05-09 20:45:11 +00:00
int offset=0;
2024-05-06 05:32:33 +00:00
while(1) {
result=fgets(string,BUFSIZ,stdin);
if (result==NULL) break;
2024-05-08 23:52:31 +00:00
if (result[0]=='#') {
if (strstr(string,"inverse")) inverse=1;
if (strstr(string,"normal")) inverse=0;
continue;
}
count=0;
length=strlen(string);
if (inverse) {
putchar(' '&0x3f);
2024-05-09 20:45:11 +00:00
offset++;
2024-05-08 23:52:31 +00:00
}
else {
putchar(' '|0x80);
2024-05-09 20:45:11 +00:00
offset++;
2024-05-08 23:52:31 +00:00
}
for(i=0;i<length;i++) {
if (string[i]=='\n') continue;
if (inverse) {
putchar(string[i]&0x3f);
2024-05-09 20:45:11 +00:00
offset++;
2024-05-08 23:52:31 +00:00
}
else {
putchar(string[i]|0x80);
2024-05-09 20:45:11 +00:00
offset++;
2024-05-08 23:52:31 +00:00
}
}
for(i=0;i<(40-length);i++) {
if (inverse) {
putchar(' '&0x3f);
2024-05-09 20:45:11 +00:00
offset++;
2024-05-08 23:52:31 +00:00
}
else {
putchar(' '|0x80);
2024-05-09 20:45:11 +00:00
offset++;
2024-05-08 23:52:31 +00:00
}
}
2024-05-09 20:45:11 +00:00
if ((dont_page_cross) && ((offset%256)==240)) {
for(i=0;i<16;i++) {
if (inverse) {
putchar(' '&0x3f);
offset++;
}
else {
putchar(' '|0x80);
offset++;
}
}
}
2024-05-06 05:32:33 +00:00
}
return 0;
}