Skip to content
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

refactor: DOSINT21H loads the initial DOS executable #871

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

maximilien-noal
Copy link
Member

@maximilien-noal maximilien-noal commented Sep 26, 2024

Description of Changes

Gives the DOS INT21H class the capability and responsibility to load the host file, if the ProgramExecutor determines that it is a DOS executable (.COM or .EXE file)

Rationale behind Changes

Makes it easier for a potential contributor to implement DOS function INT21H 0x4B (LOAD AND/OR EXECUTE).
Along with the DOS SDA, PSP chains, and eventually TSR support.

Suggested Testing Steps

Test this with your favorite game.
It should still load, even if you set a preferred start segment in the config, or even use program arguments.

Dune still works.

Just like on a real DOS implementation.

This makes it easier to implement the following:
- The SDA
- PSP chains
- DOS function INT21H 0x4B (Load and/or exec file)

and eventually, TSR support.

Signed-off-by: Maximilien Noal <noal.maximilien@gmail.com>
@maximilien-noal maximilien-noal self-assigned this Sep 26, 2024
@maximilien-noal maximilien-noal added DOS Related to DOS refactoring Involves refactoring existing code labels Sep 26, 2024
@maximilien-noal maximilien-noal changed the title refactor: DOSINT21H loads DOS executables refactor: DOSINT21H loads the initial DOS executable Sep 26, 2024
@JorisVanEijden
Copy link
Contributor

Krondor loads and runs.

But I don't think an interrupt handler is the right place for this file loading is it?
Feels like DosFileManager would be a better fit.

I'm also not quite sure how this makes it easier to implement DOS function INT21H 0x4B.

@maximilien-noal
Copy link
Member Author

Dosbox does this :

Call the command processor, which eventually calls dos int21h 0x4b to execute a DOS program with a DOS path and args as parameters given via CPU registers.

It also handles the SDA structure, PSP chains, DOS process management, TSRs and such.

What we do currently on master:

We completely side step the dos kernel and dos int handlers and the usage of a DOS path.

We directly load an executable in memory from an absolute host path, with class that are foreign to the OperatingSystem namespace.

We don't have the SDA, DOS process management, TSR support, etc.

What this does:

What I see as the first step : call the dos int21h class to load the DOS program, from an absolute host path.

It's a little bit better, because the rest of the modifications will be done in the dos kernel and the dos int21h handler.

@@ -776,13 +776,13 @@ public DosFileOperationResult RemoveDirectory(string dosDirectory) {

return DosFileOperationResult.NoValue();
} catch (IOException e) {
triedToDeleteCurrentDir = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is deleting the currentDir really the only cause for IOExceptions when deleting a directory?

fullHostPath, e);
}
}

return PathNotFoundError(dosDirectory);
return triedToDeleteCurrentDir ? RemoveCurrentDirError(dosDirectory) : PathNotFoundError(dosDirectory);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not return this at the end of the codeblock where that boolean is set?

@JorisVanEijden
Copy link
Contributor

Dosbox does this :

Call the command processor, which eventually calls dos int21h 0x4b to execute a DOS program with a DOS path and args as parameters given via CPU registers.

It also handles the SDA structure, PSP chains, DOS process management, TSRs and such.

What we do currently on master:

We completely side step the dos kernel and dos int handlers and the usage of a DOS path.

We directly load an executable in memory from an absolute host path, with class that are foreign to the OperatingSystem namespace.

We don't have the SDA, DOS process management, TSR support, etc.

What this does:

What I see as the first step : call the dos int21h class to load the DOS program, from an absolute host path.

It's a little bit better, because the rest of the modifications will be done in the dos kernel and the dos int21h handler.

The way I imagine it, we'd have a "FileLoader" class (or set of classes) that are used by both the int21handler and the ProgramExecutor.
I dunno, to me it just feels more like it belongs somewhere under the Spice86.Core.Emulator.OperatingSystem namespace rather than under the Spice86.Core.Emulator.InterruptHandlers.Dos namespace.

@maximilien-noal
Copy link
Member Author

I can do that.

Signed-off-by: Maximilien Noal <noal.maximilien@gmail.com>
Signed-off-by: Maximilien Noal <noal.maximilien@gmail.com>
@maximilien-noal maximilien-noal removed the request for review from kevinferrare September 30, 2024 17:36
@maximilien-noal maximilien-noal added the feature request This would be good to have label Sep 30, 2024
@maximilien-noal maximilien-noal marked this pull request as draft September 30, 2024 17:36
Signed-off-by: Maximilien Noal <noal.maximilien@gmail.com>
Signed-off-by: Maximilien Noal <noal.maximilien@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DOS Related to DOS feature request This would be good to have refactoring Involves refactoring existing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants