From a1cc016a743058ea29d7078d3c59919cdccd0af3 Mon Sep 17 00:00:00 2001 From: hue Date: Tue, 14 Nov 2023 21:09:23 -0300 Subject: [PATCH 1/2] fix bug involving disk reads --- source/devices/disk.d | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/source/devices/disk.d b/source/devices/disk.d index 54f8b35..1ea351a 100644 --- a/source/devices/disk.d +++ b/source/devices/disk.d @@ -51,23 +51,19 @@ class Disk : Device { if (input.length < 3) { return; } - ushort sector = input[1]; ushort amount = input[2]; data ~= cast(ushort) 'R'; - for (uint i = sector; i < sector + amount; ++ i) { - uint sectorStart = i * 512; - uint sectorEnd = sectorStart + 512; - - for (uint j = sectorStart; j < sectorEnd; ++ j) { - data ~= diskData[j]; - } + for (int i = 512*sector; i<512*(sector + amount); ++ i) { + data ~= diskData[i]; } + input = []; + waiting = false; break; } - case 'W': { + case 'W': { // todo: test writes if (input.length < 514) { return; } From 85a6983e83ce3e051e9c1c090279706051fe4419 Mon Sep 17 00:00:00 2001 From: huey1116 <74214862+huey1116@users.noreply.github.com> Date: Tue, 14 Nov 2023 21:20:02 -0300 Subject: [PATCH 2/2] minor issues xd --- source/devices/disk.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/devices/disk.d b/source/devices/disk.d index 1ea351a..f0685ed 100644 --- a/source/devices/disk.d +++ b/source/devices/disk.d @@ -56,7 +56,7 @@ class Disk : Device { data ~= cast(ushort) 'R'; - for (int i = 512*sector; i<512*(sector + amount); ++ i) { + for (uint i = 512*sector; i < 512*(sector + amount); ++ i) { data ~= diskData[i]; } input = [];