4cade/bin/buildss.js

74 lines
1.8 KiB
JavaScript
Raw Normal View History

2021-10-12 23:37:45 +00:00
a = new ActiveXObject("scripting.filesystemobject")
entries = []
2021-10-20 19:02:42 +00:00
p = WScript.Arguments(0)
2021-10-12 23:37:45 +00:00
2021-10-20 19:02:42 +00:00
if (p.charAt(p.length - 1) == "*")
2021-10-12 23:37:45 +00:00
{
2021-10-20 19:02:42 +00:00
b = a.opentextfile(p.substr(0, p.length - 1))
while (!b.atendofstream)
{
c = b.readline()
entries.push(c.substr(c.lastIndexOf("\\") + 1))
}
p = c.substr(0, c.lastIndexOf("\\"))
}
else
{
for (b = new Enumerator(a.GetFolder(p).files); !b.atEnd(); b.moveNext())
{
entries.push(b.item().name)
}
2021-10-12 23:37:45 +00:00
}
2021-10-13 06:05:41 +00:00
entries.sort()
2021-10-20 19:02:42 +00:00
2021-10-22 06:17:04 +00:00
f = a.createtextfile("build\\GAMES.SORTED")
f.write(entries.toString().replace(/,/g, "\n"))
f.close()
2021-11-18 20:52:11 +00:00
ss_off = a.fileexists(WScript.Arguments(3)) ? a.getFile(WScript.Arguments(3)).size : 0
2021-10-20 19:02:42 +00:00
groups = "*=0\n" + "!le16 " + entries.length + ", 0\n"
2021-10-12 23:37:45 +00:00
2021-11-18 20:52:11 +00:00
q = 0
if (WScript.Arguments(2) != "nul")
{
q = a.createtextfile(WScript.Arguments(2))
q.writeline()
}
2021-10-12 23:37:45 +00:00
for (i = 0; i < entries.length; i++)
{
2021-10-20 19:02:42 +00:00
size = a.getfile(p + "\\" + entries[i]).size
c = ss_off
2021-10-13 06:05:41 +00:00
ss_off += size
2021-10-20 19:02:42 +00:00
2021-11-18 20:52:11 +00:00
if (WScript.Arguments.length == 6)
2021-10-20 19:02:42 +00:00
{
// 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))
}
2021-11-18 20:52:11 +00:00
groups += "!byte " + (entries[i].length + 7) + "\n" + "!byte " + entries[i].length + "\n" + "!text \"" + entries[i] + "\"\n" + "!be24 " + c + "\n" + "!le16 " + size + "\n"
if (typeof(q) == "object")
{
q.writeline(entries[i] + "," + c + "," + size)
}
}
if (typeof(q) == "object")
{
q.close()
2021-10-12 23:37:45 +00:00
}
2021-10-16 05:34:00 +00:00
f = a.createtextfile("build\\ss.tmp")
2021-10-12 23:37:45 +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\\ss.tmp', 0, 1)
2021-11-18 20:52:11 +00:00
x.run('cmd /c bin\\buildpreall.bat ' + p + ' ' + WScript.Arguments(3) + ' ' + WScript.Arguments(4), 0, 1)