Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

Commit 78e17b9

Browse files
committed
Better handling for file-sizes
1 parent b44e2c0 commit 78e17b9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cpm/cpm_bdos.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,6 +1584,16 @@ func BdosSysCallFileSize(cpm *CPM) error {
15841584
// of records
15851585
records := int(fileSize / 128)
15861586

1587+
// Block size is used so round up, if we need to.
1588+
if (fileSize % blkSize) != 0 {
1589+
records += 1
1590+
}
1591+
1592+
// Cap the size appropriately.
1593+
if records >= 65536 {
1594+
records = 65536
1595+
}
1596+
15871597
// Store the value in the three fields
15881598
fcbPtr.R0 = uint8(records & 0xFF)
15891599
fcbPtr.R1 = uint8(records >> 8)

0 commit comments

Comments
 (0)