-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.lua
115 lines (81 loc) · 2.64 KB
/
build.lua
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env lua
--------------
-- Settings --
--------------
-- Create the debug ROM.
local debug = false
-- ROM padding
local padding = false
---------------------
-- End of settings --
---------------------
-- Delete old files.
os.remove("Sonic.gen")
local common = require "AS.lua.common"
local compression = "kosinskiplus"
-- Assemble the ROM.
local message, abort = common.build_rom("Sonic", "Sonic", "", "-p=FF -z=0," .. compression .. ",Size_of_DAC_driver_guess,after", false, "https://github.com/sonicretro/skdisasm")
if message then
exit_code = false
end
if abort then
os.exit(exit_code, true)
end
-- Buld DEBUG ROM
if debug then
local message, abort = common.build_rom("Sonic", "Sonic.Debug", "-D __DEBUG__ -OLIST Sonic.Debug.lst", "-p=FF -z=0," .. compression .. ",Size_of_DAC_driver_guess,after", false, "https://github.com/sonicretro/skdisasm")
if message then
exit_code = false
end
if abort then
os.exit(exit_code, true)
end
end
-- Append symbol table to the ROM.
local extra_tools = common.find_tools("debug symbol generator", "https://github.com/vladikcomper/md-modules", "https://github.com/sonicretro/skdisasm", "convsym")
if not extra_tools then
os.exit(false)
end
os.execute(extra_tools.convsym .. " Sonic.lst Sonic.gen -input as_lst -range 0 FFFFFF -exclude -filter \"z[A-Z].+\" -a")
os.execute(extra_tools.convsym .. " Sonic.lst RAM.asm -in as_lst -out asm -range FF0000 FFFFFF")
if debug then
os.execute(extra_tools.convsym .. " Sonic.Debug.lst Sonic.Debug.gen -input as_lst -range 0 FFFFFF -exclude -filter \"z[A-Z].+\" -a")
os.execute(extra_tools.convsym .. " Sonic.Debug.lst RAM.asm -in as_lst -out asm -range FF0000 FFFFFF")
end
if padding then
-- ROM padding process
common.rom_padding("Sonic.gen")
end
-- Correct the ROM's header with a proper checksum and end-of-ROM value.
common.fix_header("Sonic.gen")
if debug then
if padding then
-- ROM padding process
common.rom_padding("Sonic.Debug.gen")
end
common.fix_header("Sonic.Debug.gen")
end
-- copy ROM.
local os_name, arch_name = require "AS.lua.get_os_name".get_os_name()
local source = "Sonic.gen"
local destination = "_CD"
local command
if os_name == "Windows" then
command = "copy " .. source .. " " .. destination
else
command = "cp " .. source .. " " .. destination
end
os.execute(command)
if debug then
local os_name, arch_name = require "AS.lua.get_os_name".get_os_name()
local source = "Sonic.Debug.gen"
local destination = "_CD"
local command
if os_name == "Windows" then
command = "copy " .. source .. " " .. destination
else
command = "cp " .. source .. " " .. destination
end
os.execute(command)
end
os.exit(exit_code, false)