Skip to content

Fix/dos mem allocation - #2342

Closed
maximilien-noal wants to merge 3 commits into
masterfrom
fix/dos_mem_allocation
Closed

Fix/dos mem allocation#2342
maximilien-noal wants to merge 3 commits into
masterfrom
fix/dos_mem_allocation

Conversation

@maximilien-noal

@maximilien-noal maximilien-noal commented Sep 5, 2026

Copy link
Copy Markdown
Member

Description of Changes

Changes DOS Memory Manager behavior when allocating MCBs

Rationale behind Changes

Fixes DOS Memory Manager behavior so Alone in the Dark works fully now.

Suggested Testing Steps

@maximilien-noal maximilien-noal self-assigned this Sep 5, 2026
Copilot AI lite review requested due to automatic review settings September 5, 2026 12:47
@maximilien-noal maximilien-noal added compatibility Emulator compatibility with DOS apps memory Emulator memory access mode and layout DOS Related to DOS bugfix fixes a bug labels Sep 5, 2026

This comment was marked as outdated.

@maximilien-noal
maximilien-noal force-pushed the fix/dos_mem_allocation branch 2 times, most recently from e776658 to bbab09d Compare September 5, 2026 12:53
fusefib and others added 2 commits September 5, 2026 14:55
INT 16h may invoke INT 09h while waiting for a keystroke. When the
8042 output buffer is empty, reading port 0x60 returns the previous
data byte, causing the same scancode to be processed repeatedly.

Check the controller status before reading the keyboard data port.
@maximilien-noal
maximilien-noal marked this pull request as draft September 5, 2026 12:56
@maximilien-noal
maximilien-noal marked this pull request as ready for review September 5, 2026 12:57
@maximilien-noal
maximilien-noal requested a lite review from Copilot September 5, 2026 12:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new compression/resize logic has a couple of correctness/robustness issues (notably missing MCB validity checks in compression and an ignored SplitBlock failure path) that should be addressed before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 3
  • Review effort level: Lite

Comment on lines +229 to +233
// Shrinking MCB
SplitBlock(block, newSizeInParagraphs);
block.PspSegment = _sda.CurrentProgramSegmentPrefix;
CompressMemory();
return DosErrorCode.NoError;
Comment on lines +563 to +567
private void CompressMemory() {
DosMemoryControlBlock? current = _start;
while (current is not null && !current.IsLast) {
DosMemoryControlBlock? next = current.GetNextOrDefault();
if (next is null) {
Comment on lines 326 to 330
@@ -327,7 +329,11 @@ public void ReduceSizeOfFreeBlock() {
/// conjoining free blocks of memory. Therefore even though a free memory block can effectively
/// be allocated by trying to reduce its size, it can never be allocated by trying to increase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix fixes a bug compatibility Emulator compatibility with DOS apps DOS Related to DOS memory Emulator memory access mode and layout

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants