-
Notifications
You must be signed in to change notification settings - Fork 0
/
afd-run.ps1
43 lines (35 loc) · 1.29 KB
/
afd-run.ps1
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
Function afd ($name) {
if ($name -eq "" -or $null -eq $name ) {
return "Please provide a file name."
}
if (!(Test-Path -Path $name)) {
return "File not found."
}
# Check if NASM is installed
nasm --version
if (!($?)) {
return "NASM not found. Please run setup script first."
}
# Check if DOSBox-X is installed
dosbox-x --version
if (!($?)) {
return "DOSBox-X not found. Please run setup script first."
}
# Extract name without extension and extension
$nameWithoutExt = [System.IO.Path]::GetFileNameWithoutExtension($name)
$extension = [System.IO.Path]::GetExtension($name)
if ($extension -ne ".asm") {
return "Invalid file extension. Please provide a .asm file."
}
nasm $name -o "$nameWithoutExt.com" -l "$nameWithoutExt.lst"
if (!($?)) {
return "Error compiling $name."
}
if (!(Test-Path -Path "$nameWithoutExt.com")) {
return "Error compiling $name."
}
if (!(Test-Path -Path $HOME/Assembly-Tools/afd.exe)) {
return "AFD not found. Please run setup script first."
}
dosbox-x -nogui -c "set home=$home" -c "mount A '%home%\Assembly-Tools'" -c "mount C ." -c "C:" -c "A:\afd.exe $nameWithoutExt.com"
}