-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.ps1
60 lines (53 loc) · 2.5 KB
/
package.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Find the working directory
$dir = Resolve-Path "."
# Run the main build script if the application .63 or .epr file is missing
if (!((Test-Path VDrive.63) -And (Test-Path VDrive.epr))) {
./makeapp.cmd
}
# Write the bottom 8KB of the application
$data = [IO.File]::ReadAllBytes([IO.Path]::Combine($dir, "VDrive.63"))
[IO.File]::WriteAllBytes([IO.Path]::Combine($dir, "VDrive.ap0"), $data[0x2000..0x3FFF])
# Create the .app installer
$app = New-Object IO.BinaryWriter([IO.File]::Create([IO.Path]::Combine($dir, "VDrive.app")))
$app.Write([UInt16]0x5AA5) # Signature
$app.Write([Byte]1) # Number of banks
$app.Write([Byte]0) # Number of patches
$app.Write([Byte]0) # \
$app.Write([Byte]0) # > Pointer to first DOR
$app.Write([Byte]0) # /
$app.Write([Byte]0) # Flags for required even banks
$app.Write([UInt16]0x2000) # Offset of .AP0 file
$app.Write([UInt16]0x2000) # Length of .AP0 file
$app.Write([UInt16]0x0000) # Offset of .AP1 file
$app.Write([UInt16]0x0000) # Length of .AP1 file
$app.Write([UInt16]0x0000) # Offset of .AP2 file
$app.Write([UInt16]0x0000) # Length of .AP2 file
$app.Write([UInt16]0x0000) # Offset of .AP3 file
$app.Write([UInt16]0x0000) # Length of .AP3 file
$app.Write([UInt16]0x0000) # Offset of .AP4 file
$app.Write([UInt16]0x0000) # Length of .AP4 file
$app.Write([UInt16]0x0000) # Offset of .AP5 file
$app.Write([UInt16]0x0000) # Length of .AP5 file
$app.Write([UInt16]0x0000) # Offset of .AP6 file
$app.Write([UInt16]0x0000) # Length of .AP6 file
$app.Write([UInt16]0x0000) # Offset of .AP7 file
$app.Write([UInt16]0x0000) # Length of .AP7 file
$app.Close()
# Create package directories
if (Test-Path "package") {
Remove-Item -Path package -Recurse
}
New-Item -Path package -Type directory | Out-Null
New-Item -Path package/Installer -Type directory | Out-Null
New-Item -Path package/RomCombiner -Type directory | Out-Null
New-Item -Path package/Emulator -Type directory | Out-Null
# Copy files over
Get-ChildItem -Filter VDrive.ap? | Copy-Item -Destination package/Installer
Get-ChildItem -Filter VDrive.6? | Copy-Item -Destination package/RomCombiner
Get-ChildItem -Filter VDrive.epr | Copy-Item -Destination package/Emulator
# Compress the zip archive
Compress-Archive -Path package/Installer -DestinationPath VDrive.zip -Force
Compress-Archive -Path package/RomCombiner -DestinationPath VDrive.zip -Update
Compress-Archive -Path package/Emulator -DestinationPath VDrive.zip -Update
# Remove the temporary packaging path
Remove-Item -Path package -Recurse