-
Notifications
You must be signed in to change notification settings - Fork 33
fixes PSP commandline encoding #1600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
dd8dcab to
fbc900a
Compare
fbc900a to
2d6cd66
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes the PSP (Program Segment Prefix) command line encoding/decoding to match native DOS and DOSBox behavior. The implementation addresses incorrect handling of spaces, length calculation, and termination characters in the DOS command tail structure.
Key changes:
- Introduces
PrepareCommandlineStringmethod to normalize command line arguments with proper DOS formatting (leading space, trailing whitespace trimming, length limits) - Refactors
DosCommandTail.Commandproperty with explicit ASCII encoding/decoding instead of relying on zero-terminated string helpers - Adds comprehensive test coverage with multiple command line scenarios including empty strings, whitespace handling, and special characters
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
tests/Spice86.Tests/Dos/DosProgramSegmentPrefixCmdTest.cs |
New test file with 6 test cases validating command line encoding against DOS byte format expectations |
src/Spice86.Core/Emulator/OperatingSystem/Structures/DosCommandTail.cs |
Adds PrepareCommandlineString and CheckParameterString methods; refactors Command getter/setter with explicit byte-level encoding; updates constants |
src/Spice86.Core/Emulator/OperatingSystem/DosProcessManager.cs |
Removes obsolete ArgumentsToDosBytes method; simplifies PSP command tail setup to use new PrepareCommandlineString |
src/Spice86.Core/Emulator/OperatingSystem/Structures/DosCommandTail.cs
Outdated
Show resolved
Hide resolved
src/Spice86.Core/Emulator/OperatingSystem/Structures/DosCommandTail.cs
Outdated
Show resolved
Hide resolved
src/Spice86.Core/Emulator/OperatingSystem/Structures/DosCommandTail.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
maximilien-noal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with a few suggestions. :)
Thank you for this @LowLevelMahn !
Really appreciate it.
It's much better than the old code.
|
|
||
| // there needs to be a blank as first char in parameter string, if there isn't already | ||
| if (ag[0] != ' ') { | ||
| ag = ' ' + ag; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be ag = $" {ag}";
|
|
||
| public const int MaxCharacterLength = 128; | ||
| public const int MaxSize = 128; | ||
| public const int MaxCharacterLength = MaxSize - 2; // length-byte + 126 chars max + \r |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be visible for users of the Nuget package, this comment could be a ///
above the const.
| for (int i = 0; i < length; i++) { | ||
| buffer[i] = UInt8[(uint)(1 + i)]; | ||
| } | ||
| return Encoding.ASCII.GetString(buffer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldnt this work?
get => Encoding.ASCII.GetString(GetUInt8Array(1, Length).ToArray());
Description of Changes
change the encode/decoding of the PSP Commandline
Rationale behind Changes
Behavior was different to native DOS or dosbox, did not work properbly
Suggested Testing Steps
there is a DosProgramSegmentPrefixCmdTest to test encoding/decoding with some cases