aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2025-12-03 04:21:26 -0500
committerB. Watson <urchlay@slackware.uk>2025-12-03 04:21:26 -0500
commit95b0453a75580864d46de747042f7c2e316d54be (patch)
treefc7815773805f43344f638f37750ff1d1f54c363 /src
parent4f298573f2634735a98200f3e13573722716b0de (diff)
downloadalftools-95b0453a75580864d46de747042f7c2e316d54be.tar.gz
unalf: Fix 15MB bug.
Diffstat (limited to 'src')
-rw-r--r--src/alf.126
-rw-r--r--src/alf.rst26
-rw-r--r--src/asmcode.c7
-rw-r--r--src/io.c12
-rw-r--r--src/unalf.18
-rw-r--r--src/unalf.rst10
6 files changed, 55 insertions, 34 deletions
diff --git a/src/alf.1 b/src/alf.1
index 371f903..53af9a8 100644
--- a/src/alf.1
+++ b/src/alf.1
@@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
-.TH "ALF" 1 "2025-12-02" "0.3.0" "Urchlay's Atari 8-bit Tools"
+.TH "ALF" 1 "2025-12-03" "0.3.0" "Urchlay's Atari 8-bit Tools"
.SH NAME
alf \- create Atari 8-bit ALF archives
.\" RST source for alf(1) man page. Convert with:
@@ -121,7 +121,7 @@ Can be given twice for more detail, or 3 times to dump the token
tables (\fIlots\fP of output; for debugging only).
.TP
.B \-V\fP,\fB \-\-version
-Show \fBunalf\fP version number and exit.
+Show \fBalf\fP version number and exit.
.UNINDENT
.\" show version number.
.
@@ -197,12 +197,26 @@ old disk images as \fBUNALF.COM\fP, and \fBLZ.COM\fP is sometimes called
\fBALF.COM\fP or \fBALFER.COM\fP\&. I\(aqve used the original names partly
out of respect for the original author, and partly to avoid confusion
between my \fBalf\fP/\fBunalf\fP and his Atari ones.
+.SS Compression Characteristics
+.sp
+Larger files compress better than smaller ones. Very small files
+will get larger when compressed. Files with lots of entropy (random
+garbage, files that are already compressed) will also get larger.
+.sp
+For text files, compression is usually around 45% to 50%, which
+is comparable with \fBarc\fP\&. For SAVEd Atari BASIC, the average is
+a little worse: 35% to 40%. For executables, it seems to average
+around 30%... unless the executables are already compressed (e.g.
+self\-decompressing), in which case they\(aqll get bigger when compressed
+with \fBalf\fP\&.
.SS File Size Limits
.sp
-\fBalf\fP (and \fBLZ.COM\fP) have a 16MB file size limit. \fBuanlf\fP
-actually can\(aqt handle files above about 15MB, if you compress one with
-\fBalf\fP\&. Real Atari 8\-bit files are never this large anyway, so it\(aqs
-a pathological case. A real Atari would take hours or even days to
+\fBalf\fP (and \fBLZ.COM\fP) have a 16MB file size limit. This applies to
+both the input file size, and the compressed size (in case of files
+that grow when compressed, e.g. random data).
+.sp
+Real Atari 8\-bit files are never this large anyway, so it\(aqs a
+pathological case. A real Atari would take hours or even days to
compress/decompress such files, and you\(aqd have to have a hard disk and
a DOS capable of handling multi\-megabyte files...
.SS Performance
diff --git a/src/alf.rst b/src/alf.rst
index 267f993..f265697 100644
--- a/src/alf.rst
+++ b/src/alf.rst
@@ -95,7 +95,7 @@ OPTIONS
tables (*lots* of output; for debugging only).
-V, --version
- Show **unalf** version number and exit.
+ Show **alf** version number and exit.
.. show version number.
@@ -175,13 +175,29 @@ old disk images as **UNALF.COM**, and **LZ.COM** is sometimes called
out of respect for the original author, and partly to avoid confusion
between my **alf**\/**unalf** and his Atari ones.
+Compression Characteristics
+---------------------------
+
+Larger files compress better than smaller ones. Very small files
+will get larger when compressed. Files with lots of entropy (random
+garbage, files that are already compressed) will also get larger.
+
+For text files, compression is usually around 45% to 50%, which
+is comparable with **arc**. For SAVEd Atari BASIC, the average is
+a little worse: 35% to 40%. For executables, it seems to average
+around 30%... unless the executables are already compressed (e.g.
+self-decompressing), in which case they'll get bigger when compressed
+with **alf**.
+
File Size Limits
----------------
-**alf** (and **LZ.COM**) have a 16MB file size limit. **uanlf**
-actually can't handle files above about 15MB, if you compress one with
-**alf**. Real Atari 8-bit files are never this large anyway, so it's
-a pathological case. A real Atari would take hours or even days to
+**alf** (and **LZ.COM**) have a 16MB file size limit. This applies to
+both the input file size, and the compressed size (in case of files
+that grow when compressed, e.g. random data).
+
+Real Atari 8-bit files are never this large anyway, so it's a
+pathological case. A real Atari would take hours or even days to
compress/decompress such files, and you'd have to have a hard disk and
a DOS capable of handling multi-megabyte files...
diff --git a/src/asmcode.c b/src/asmcode.c
index 831ba1c..9cdf2f8 100644
--- a/src/asmcode.c
+++ b/src/asmcode.c
@@ -252,7 +252,8 @@ L7737:
cpy_i(0x88);
beq(L7771);
// jmp(cleanup_and_exit);
- exit(0);
+ // printf("got here, Y is %d, C is %d\n", Y, CF);
+ // exit(0); /* was causing early exit with large (5+MB) files */
/* ---------------------------------------------------------------------------- */
L7771:
jsr(L79E7);
@@ -345,7 +346,7 @@ void L7A19(void) {
beq(L7A28);
L7A21:
jsr(readblock);
- Y = 1; /* CIO would set this */
+ // Y = 1; /* CIO would set this */
jsr(L7A5D);
rts();
L7A28:
@@ -369,7 +370,7 @@ L7A40:
ora(buf_len_h);
beq(L7A57);
jsr(readblock);
- Y = 1; /* CIO would set this */
+ // Y = 1; /* CIO would set this */
L7A57:
ldy_i(0x88);
jsr(L7A5D);
diff --git a/src/io.c b/src/io.c
index 9a0486d..c4fa295 100644
--- a/src/io.c
+++ b/src/io.c
@@ -1,3 +1,4 @@
+// #include <f65.h>
#include "unalf.h"
#include "addrs.h"
@@ -130,6 +131,7 @@ int read_alf_header(void) {
/* read buf_len_l/h bytes into buf_adr_l/h, then store the number
of bytes actually read in buf_len_l/h. TODO: what about EOF? */
void readblock(void) {
+ static int bytes_read = 0;
int bytes, len, bufadr;
u8 *buf;
@@ -137,9 +139,15 @@ void readblock(void) {
buf = mem + bufadr;
len = dpeek(buf_len_l);
- // fprintf(stderr, "readblock, bufadr = $%04x, len = $%04x\n", bufadr, len);
-
bytes = fread(buf, 1, len, in_file);
+ bytes_read += bytes;
+
+ /* mimic CIO's behaviour */
+ if(feof(in_file)) {
+ ldy_i(0x88);
+ } else {
+ ldy_i(1);
+ }
dpoke(buf_len_l, bytes);
}
diff --git a/src/unalf.1 b/src/unalf.1
index 2c8054f..edcf2b8 100644
--- a/src/unalf.1
+++ b/src/unalf.1
@@ -399,14 +399,6 @@ old disk images as \fBUNALF.COM\fP, and \fBLZ.COM\fP is sometimes called
\fBALF.COM\fP or \fBALFER.COM\fP\&. I\(aqve used the original names partly
out of respect for the original author, and partly to avoid confusion
between my \fBalf\fP/\fBunalf\fP and his Atari ones.
-.SH BUGS
-.sp
-A minor one: \fBunalf\fP can\(aqt correctly extract files larger than about
-15MB. This could be a problem in \fBalf\fP (though the archives look
-OK to me), or it could be a bug I introduced when porting \fBunalf\fP,
-or it could be a bug in the original \fBDZ.COM\fP\&. Files this large are
-a pathological case for \fIALF\fP, anyway, since nobody ever used them on
-the Atari 8\-bit.
.SH COPYRIGHT
.sp
The original AlfCrunch (\fBDZ.COM\fP and \fBLZ.COM\fP) for the Atari
diff --git a/src/unalf.rst b/src/unalf.rst
index 069fad1..ed89d2d 100644
--- a/src/unalf.rst
+++ b/src/unalf.rst
@@ -351,16 +351,6 @@ old disk images as **UNALF.COM**, and **LZ.COM** is sometimes called
out of respect for the original author, and partly to avoid confusion
between my **alf**\/**unalf** and his Atari ones.
-BUGS
-====
-
-A minor one: **unalf** can't correctly extract files larger than about
-15MB. This could be a problem in **alf** (though the archives look
-OK to me), or it could be a bug I introduced when porting **unalf**,
-or it could be a bug in the original **DZ.COM**. Files this large are
-a pathological case for *ALF*, anyway, since nobody ever used them on
-the Atari 8-bit.
-
COPYRIGHT
=========