Skip to content

feat: High to low memory scanning in DOS Memory Manager and DOS UMB support - #2395

Open
maximilien-noal wants to merge 7 commits into
masterfrom
fix/alone_in_the_dark
Open

maximilien-noal wants to merge 7 commits into
masterfrom
fix/alone_in_the_dark

Conversation

@maximilien-noal

@maximilien-noal maximilien-noal commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Description of Changes

Adds DOS Upper Memory Block (UMB) support and extends DOS memory allocation to honor the configured allocation strategy across conventional and upper memory.

Detail

  • Adds an --Umb option, enabled by default. UMBs are available when the option is enabled and XMS is present.
  • Initializes a DOS-compatible UMB chain, with reduced UMB space when EMS is active.
  • Implements INT 21h/AH=58h allocation-strategy and UMB-chain link-state operations.
  • Supports first-fit, best-fit, and last-fit allocation in conventional memory, UMBs only, or UMBs followed by conventional memory.
  • Adds XMS UMB request and release handling, restoring the prior allocation strategy and chain-link state after a request.
  • Improves MCB freeing and coalescing, including freeing process-owned blocks in an unlinked UMB chain.
  • Adds debug-level memory-map logging and DOS/XMS integration fixtures for UMB behavior.

Rationale behind Changes

Hopefully the new memory scan strategy will fix games such as Alone in the Dark and others that complain about not enough memory.

DOS UMB support also makes more MCBs available to DOS applications.

Testing

  • Added unit and integration coverage for UMB allocation strategies, chain linking, EMS sizing, disabled UMB behavior, and XMS request/release.

@maximilien-noal maximilien-noal self-assigned this Oct 9, 2026
@maximilien-noal
maximilien-noal marked this pull request as draft October 9, 2026 06:32
@maximilien-noal maximilien-noal changed the title feat: Log memory allocations for DOS at Debug log level + DOS UMB support feat: High to low memory scanning in DOS Memory Manager and DOS UMB support Oct 10, 2026
@maximilien-noal
maximilien-noal marked this pull request as ready for review October 10, 2026 04:20
@maximilien-noal maximilien-noal added compatibility Emulator compatibility with DOS apps memory Emulator memory access mode and layout DOS Related to DOS 16 bit Related to 16 bit programs support labels Oct 10, 2026
Comment thread src/Spice86.Core/Emulator/OperatingSystem/Dos.cs Dismissed
@maximilien-noal
maximilien-noal force-pushed the fix/alone_in_the_dark branch 2 times, most recently from 9b5eded to c3dc521 Compare October 10, 2026 04:53
@maximilien-noal
maximilien-noal removed the request for review from kevinferrare October 10, 2026 06:00
@maximilien-noal
maximilien-noal marked this pull request as draft October 10, 2026 06:00
feat: Add support for DOS Upper Memory Blocks (UMBs) in memory management

Refactor UMB handling and enhance memory allocation strategies

- Changed the `Umb` property in `Configuration` from init-only to settable.
- Updated `DosInt21Handler` to use a new method for finding the largest free size for allocation.
- Enhanced `ExtendedMemoryManager` to manage UMB requests and releases more effectively.
- Refactored `DosMemoryManager` to support new allocation strategies and improved memory block management.
- Introduced new methods for validating and setting memory allocation strategies.
- Updated `DosMemoryAllocationStrategy` enum to clarify UMB handling.
- Added integration tests for UMB functionality, including allocation strategies and error handling.
- Created assembly test resources to validate UMB behavior in various scenarios.

fix: Improve upper memory block release logic and enhance memory chain handling

fix: Update UMB release logic and add FreeUpperMemoryBlock method for better memory management

refactor: ExtendedMemoryManager to enforce non-nullable DosMemoryManager and update related constructors
@maximilien-noal
maximilien-noal requested review from kevinferrare and a balanced review from Copilot October 11, 2026 06:49
@maximilien-noal
maximilien-noal marked this pull request as ready for review October 11, 2026 06:49

This comment was marked as outdated.

Update DOS memory initialization to set `DosSysVars.FirstMCB` and
`MemAllocScanStart` from the actual conventional-memory chain head,
remove the hardcoded `FirstMcbSegment` default, and adjust docs and
UMB integration tests to follow the sysvars chain head.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

16 bit Related to 16 bit programs support 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