Commit 370a1e5
fix: correct COMMAND.COM PSP[0x02] size, and DOS media ID tables segment and informations returned by DOS INT21H (#2138)
* fix: correct COMMAND.COM PSP CurrentSize to prevent TSR memory exhaustion
The DosProgramSegmentPrefix constructor was writing CurrentSize = LastFreeSegment
(0x9FFF = 40959 paragraphs) to memory on every instantiation, acting as a
destructive write rather than a pure memory view.
The fake COMMAND.COM PSP at segment 0x60 had PSP[0x02] = 0x9FFF because:
1. CreateRootCommandComPsp set it to 0x9FFF (old code)
2. Every call to `new DosProgramSegmentPrefix(memory, 0x60_address)` re-wrote
it to 0x9FFF (even pure read wrappers)
Games like Maupiti Island read the parent (COMMAND.COM) PSP[0x02] to compute
DX for INT 21h/31h (Terminate and Stay Resident). With the buggy 0x9FFF value,
TryModifyBlock would fail (0x9E8D block < 0x9FFF requested), leaving the entire
program block allocated and no conventional memory free for subsequent allocations.
Fix:
- Remove the destructive write from DosProgramSegmentPrefix constructor: it is
a memory view/wrapper and must not initialise fields on construction.
- Set CreateRootCommandComPsp to use a realistic value:
CommandComSegment + PspSizeInParagraphs = 0x60 + 0x10 = 0x70
(reflecting only the 16-paragraph PSP area, as real COMMAND.COM would have
after releasing its extra memory before loading the game).
TDD evidence (MCP-server style ASM test):
- Before fix: parent PSP[0x02] = 0x9FFF; largest free block = 12 paragraphs
- After fix: parent PSP[0x02] = 0x0070; largest free block = 0x9E2D paragraphs
Agent-Logs-Url: https://github.com/OpenRakis/Spice86/sessions/788b07bb-2457-4112-9e30-cbc5fa5319e4
Co-authored-by: maximilien-noal <1087524+maximilien-noal@users.noreply.github.com>
* fix: remove null-forgiving operator and clarify comment per review feedback
Agent-Logs-Url: https://github.com/OpenRakis/Spice86/sessions/788b07bb-2457-4112-9e30-cbc5fa5319e4
Co-authored-by: maximilien-noal <1087524+maximilien-noal@users.noreply.github.com>
* refactor: use Arrange/Act/Assert and share init code in TsrIntegrationTests
Agent-Logs-Url: https://github.com/OpenRakis/Spice86/sessions/3d9d957b-4161-4500-b596-c0a7316cd3d9
Co-authored-by: maximilien-noal <1087524+maximilien-noal@users.noreply.github.com>
* refactor: extract shared ResourceDir field in TsrIntegrationTests
Agent-Logs-Url: https://github.com/OpenRakis/Spice86/sessions/61eac897-87f7-4491-8a9a-5322f190d3dd
Co-authored-by: maximilien-noal <1087524+maximilien-noal@users.noreply.github.com>
* feat: implement INT 21h, AH=1Ch and related tests for drive allocation info
Co-authored-by: Copilot <copilot@github.com>
* refactor: DosTables constructor
* refactor: removed 'default!'
* refactor: streamline DOS media ID handling and improve drive manager initialization
Co-authored-by: Copilot <copilot@github.com>
* refactor: DosDriveManager initializes itself
* refactor: Removed unused field
* chore: Format DOSInt21Handler to respect java style code blocks
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: maximilien-noal <1087524+maximilien-noal@users.noreply.github.com>
Co-authored-by: Maximilien Noal <noal.maximilien@gmail.com>
Co-authored-by: Copilot <copilot@github.com>1 parent 3289185 commit 370a1e5
20 files changed
Lines changed: 397 additions & 187 deletions
File tree
- src
- Spice86.Core/Emulator
- InterruptHandlers/Dos
- OperatingSystem
- Structures
- Spice86
- tests/Spice86.Tests
- Dos
- Xms
- Resources/DosTsrTests
Lines changed: 63 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
49 | 52 | | |
50 | 53 | | |
51 | 54 | | |
| |||
621 | 624 | | |
622 | 625 | | |
623 | 626 | | |
624 | | - | |
625 | | - | |
626 | | - | |
| 627 | + | |
| 628 | + | |
627 | 629 | | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | 630 | | |
633 | | - | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
634 | 639 | | |
635 | 640 | | |
636 | 641 | | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | | - | |
| 642 | + | |
| 643 | + | |
641 | 644 | | |
642 | 645 | | |
643 | | - | |
644 | | - | |
645 | | - | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
652 | 685 | | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
653 | 695 | | |
654 | 696 | | |
655 | 697 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
186 | 189 | | |
187 | 190 | | |
188 | 191 | | |
189 | 192 | | |
190 | 193 | | |
191 | 194 | | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | 195 | | |
197 | 196 | | |
198 | 197 | | |
| |||
Lines changed: 31 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
30 | | - | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
86 | 88 | | |
87 | 89 | | |
88 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
89 | 94 | | |
90 | 95 | | |
91 | 96 | | |
| |||
106 | 111 | | |
107 | 112 | | |
108 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
109 | 137 | | |
110 | 138 | | |
111 | 139 | | |
| |||
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
261 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
262 | 268 | | |
263 | 269 | | |
264 | 270 | | |
| |||
Lines changed: 49 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
359 | | - | |
| 359 | + | |
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
| |||
0 commit comments