4cade/bin/buildpre.js

44 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-10-14 00:37:41 +00:00
a = new ActiveXObject("scripting.filesystemobject")
2021-10-21 23:27:11 +00:00
b = a.opentextfile("build\\GAMES.SORTED")
2021-10-14 00:37:41 +00:00
entries = []
while (!b.atendofstream)
{
2021-10-21 23:27:11 +00:00
entries.push(b.readline())
2021-10-14 00:37:41 +00:00
}
2021-10-22 06:17:04 +00:00
osize = a.getfile(WScript.Arguments(0) + "\\STANDARD").size
pre_off = a.getfile(WScript.Arguments(2)).size + osize
2021-10-14 00:37:41 +00:00
2021-10-20 19:02:42 +00:00
groups = "*=0\n" + "!le16 " + entries.length + ", 0\n"
2021-10-14 00:37:41 +00:00
for (i = 0; i < entries.length; i++)
{
2021-10-22 06:17:04 +00:00
c = a.getfile(WScript.Arguments(2)).size
2021-10-14 00:37:41 +00:00
size = osize
if (a.fileexists(WScript.Arguments(0) + "\\" + entries[i]))
2021-10-14 00:37:41 +00:00
{
c = pre_off
size = a.getfile(WScript.Arguments(0) + "\\" + entries[i]).size
2021-10-14 00:37:41 +00:00
pre_off += size
}
2021-10-20 19:02:42 +00:00
if (WScript.Arguments.length == 4)
{
// if offset+size does not cross a block boundary, use the size
// otherwise adjust size until it ends at the next block boundary to avoid a partial copy on the last block
size = ((Math.floor(c / 512) == Math.floor((c + size) / 512)) ? size : (((c + size + 511) & -512) - c))
}
2022-09-08 01:36:26 +00:00
groups += "!byte " + (1 + 1 + entries[i].length + 3 + 2) + "\n" + "!byte " + entries[i].length + "\n" + "!text \"" + entries[i] + "\"\n" + "!be24 " + c + "\n" + "!le16 " + size + "\n"
2021-10-14 00:37:41 +00:00
}
2021-10-16 05:34:00 +00:00
f = a.createtextfile("build\\pre.tmp")
2021-10-14 00:37:41 +00:00
f.write(groups)
f.close()
2021-10-16 05:34:00 +00:00
x = new ActiveXObject("wscript.shell")
x.run('cmd /c %acme% -o ' + WScript.Arguments(1) + ' build\\pre.tmp', 0, 1)
2021-10-21 23:27:11 +00:00
x.run('cmd /c bin\\buildpreall.bat ' + WScript.Arguments(0) + ' ' + WScript.Arguments(2) + ' ' + WScript.Arguments(0) + '\\STANDARD', 0, 1)