aboutsummaryrefslogtreecommitdiff
path: root/src/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/io.c b/src/io.c
index 9b8e40e..8469a6b 100644
--- a/src/io.c
+++ b/src/io.c
@@ -76,15 +76,29 @@ void readblock(void) {
dpoke(buf_len_l, bytes);
}
+int is_text_file(char *fn) {
+ if(globmatch("*.txt", fn)) return 1;
+ if(globmatch("*.doc", fn)) return 1;
+ if(globmatch("*.lst", fn)) return 1;
+ return 0;
+}
+
/* mirror of readblock() */
void writeblock(void) {
- int bytes, len, bufadr;
+ int i, bytes, len, bufadr;
u8 *buf;
+ extern char *out_filename;
bufadr = dpeek(buf_adr_l);
buf = mem + bufadr;
len = dpeek(buf_len_l);
+ if(opts.txtconv) {
+ if(opts.txtconv > 1 || is_text_file(out_filename))
+ for(i = 0; i < len; i++)
+ if(buf[i] == 0x9b) buf[i] = '\n';
+ }
+
// fprintf(stderr, "writeblock, bufadr = $%04x, len = $%04x\n", bufadr, len);
bytes = fwrite(buf, 1, len, out_file);