Skip to content

Commit

Permalink
Better handling for file-sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
skx committed Jul 15, 2024
1 parent b44e2c0 commit 78e17b9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cpm/cpm_bdos.go
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,16 @@ func BdosSysCallFileSize(cpm *CPM) error {
// of records
records := int(fileSize / 128)

// Block size is used so round up, if we need to.
if (fileSize % blkSize) != 0 {
records += 1
}

// Cap the size appropriately.
if records >= 65536 {
records = 65536
}

// Store the value in the three fields
fcbPtr.R0 = uint8(records & 0xFF)
fcbPtr.R1 = uint8(records >> 8)
Expand Down

0 comments on commit 78e17b9

Please sign in to comment.