From bc4d4f10b0522362bc5ad247d4988537c7a25ce2 Mon Sep 17 00:00:00 2001 From: S0urceror Date: Mon, 26 Feb 2024 18:27:02 +0100 Subject: [PATCH 1/2] bugfix, in file append mode the seek pointer should not return to 0 --- src/agon_machine.rs | 3 ++- src/mos.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/agon_machine.rs b/src/agon_machine.rs index 0c9f3de..d6e9667 100644 --- a/src/agon_machine.rs +++ b/src/agon_machine.rs @@ -1000,7 +1000,8 @@ impl AgonMachine { // save the size in the FIL structure let mut file_len = f.seek(SeekFrom::End(0)).unwrap(); - f.seek(SeekFrom::Start(0)).unwrap(); + if (mode & mos::FA_SEEKEND != 0) + f.seek(SeekFrom::Start(0)).unwrap(); // XXX don't support files larger than 512KiB file_len = file_len.min(1<<19); diff --git a/src/mos.rs b/src/mos.rs index cd9f2eb..bf55af0 100644 --- a/src/mos.rs +++ b/src/mos.rs @@ -21,7 +21,7 @@ pub const FILINFO_MEMBER_FNAME_256BYTES: u32 = 22; pub const FA_WRITE: u32 = 2; pub const FA_CREATE_NEW: u32 = 4; pub const FA_CREATE_ALWAYS: u32 = 8; - +pub const FA_SEEK_END: u32 = 0x20; #[derive(Clone, Default)] pub struct MosMap { pub f_chdir: u32, From b62ae9e2e036873dff43b93666394c2701863a22 Mon Sep 17 00:00:00 2001 From: S0urceror Date: Mon, 26 Feb 2024 20:35:41 +0100 Subject: [PATCH 2/2] bugfix not tested well, now working --- src/agon_machine.rs | 4 ++-- src/mos.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/agon_machine.rs b/src/agon_machine.rs index d6e9667..39d5178 100644 --- a/src/agon_machine.rs +++ b/src/agon_machine.rs @@ -1000,8 +1000,9 @@ impl AgonMachine { // save the size in the FIL structure let mut file_len = f.seek(SeekFrom::End(0)).unwrap(); - if (mode & mos::FA_SEEKEND != 0) + if mode & mos::FA_SEEKEND == 0 { f.seek(SeekFrom::Start(0)).unwrap(); + } // XXX don't support files larger than 512KiB file_len = file_len.min(1<<19); @@ -1020,7 +1021,6 @@ impl AgonMachine { _ => cpu.state.reg.set24(Reg16::HL, 1) } } - } Environment::new(&mut cpu.state, self).subroutine_return(); } diff --git a/src/mos.rs b/src/mos.rs index bf55af0..f1667b1 100644 --- a/src/mos.rs +++ b/src/mos.rs @@ -21,7 +21,8 @@ pub const FILINFO_MEMBER_FNAME_256BYTES: u32 = 22; pub const FA_WRITE: u32 = 2; pub const FA_CREATE_NEW: u32 = 4; pub const FA_CREATE_ALWAYS: u32 = 8; -pub const FA_SEEK_END: u32 = 0x20; +pub const FA_SEEKEND: u32 = 0x20; + #[derive(Clone, Default)] pub struct MosMap { pub f_chdir: u32,