Skip to content

Commit

Permalink
refactor: TypeOfLoad -> DosExecOperation enum
Browse files Browse the repository at this point in the history
  • Loading branch information
maximilien-noal committed Oct 26, 2024
1 parent 6a1b374 commit 948b4a1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/Spice86.Core/Emulator/InterruptHandlers/Dos/DosInt21Handler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -721,12 +721,6 @@ public void ModifyMemoryBlock(bool calledFromVm) {
State.BX = 0;
}
}

private enum TypeOfLoad : byte {
LoadAndExecute = 0,
LoadOnly = 1,
LoadOverlay = 2
}

/// <summary>
/// Load and or execute a program.
Expand All @@ -745,11 +739,12 @@ private enum TypeOfLoad : byte {
public void LoadAndOrExecuteProgram(bool calledFromVm) {
bool success = false;
byte typeOfLoadByte = State.AL;
if (!Enum.IsDefined(typeof(TypeOfLoad), typeOfLoadByte)) {
if (!Enum.IsDefined(typeof(DosExecOperation), typeOfLoadByte)) {
SetCarryFlag(false, calledFromVm);
return;
}
TypeOfLoad typeOfLoad = (TypeOfLoad)State.AL;
DosExecParameterBlock dosExecParameterBlock = new DosExecParameterBlock(Memory, MemoryUtils.ToPhysicalAddress(State.ES, State.BX));

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This assignment to
dosExecParameterBlock
is useless, since its value is never read.
DosExecOperation dosExecOperation = (DosExecOperation)State.AL;
string programName = GetZeroTerminatedStringAtDsDx();
string? fullHostPath = _dosFileManager.TryGetFullHostPathFromDos(programName);

Expand All @@ -759,25 +754,25 @@ public void LoadAndOrExecuteProgram(bool calledFromVm) {
}

if (LoggerService.IsEnabled(LogEventLevel.Verbose)) {
LoggerService.Verbose("LOAD AND/OR EXECUTE PROGRAM {TypeOfLoad}, {ProgramName}", typeOfLoad, programName);
LoggerService.Verbose("LOAD AND/OR EXECUTE PROGRAM {DosExecOperation}, {ProgramName}", dosExecOperation, programName);
}

bool isComFile = string.Equals(Path.GetExtension(programName).ToLowerInvariant(), ".com", StringComparison.OrdinalIgnoreCase);

switch (typeOfLoad) {
case TypeOfLoad.LoadAndExecute:
switch (dosExecOperation) {
case DosExecOperation.LoadAndExecute:
if (isComFile) {
LoadAndExecComFile(fullHostPath, "", 0x1000);
} else {
LoadAndExecExeFile(fullHostPath, "", 0x1000);
}
success = true;
break;
case TypeOfLoad.LoadOnly:
case DosExecOperation.LoadOnly:
// Not implemented
success = false;
break;
case TypeOfLoad.LoadOverlay:
case DosExecOperation.LoadOverlay:
// Not implemented
success = false;
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Spice86.Core.Emulator.OperatingSystem.Enums;
public enum DosExecOperation : byte {
/// <summary>
/// Load and execute a new program
/// </summary>
LoadAndExecute = 0,
/// <summary>
/// Load the program and stay resident
/// </summary>
LoadOnly = 1,
/// <summary>
/// Load program overlay
/// </summary>
LoadOverlay = 2
}

0 comments on commit 948b4a1

Please sign in to comment.