aboutsummaryrefslogtreecommitdiff
path: root/src/io.c
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/io.c
parent4f298573f2634735a98200f3e13573722716b0de (diff)
downloadalftools-95b0453a75580864d46de747042f7c2e316d54be.tar.gz
unalf: Fix 15MB bug.
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c12
1 files changed, 10 insertions, 2 deletions
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);
}