Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
59 lines (45 loc) · 1.67 KB

File metadata and controls

59 lines (45 loc) · 1.67 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
rom_start = 0x08000000
end_of_code = 0x080ce438
end_of_data = 0x08e7f1f4
addresses = set()
with open('asm/code.s') as code:
for line in code.readlines():
line = line.strip()
if ".4byte 0x08" in line:
address = int(line.split("0x0")[1], 16)
if address >= end_of_code and address < end_of_data:
addresses.add(address)
addresses_with_size = []
sorted_addresses = sorted(addresses)
def upper_addr(addr):
return "0x" + hex(addr).split('0x')[1].upper()
def format_memory_addr(addr):
return "0x0" + hex(addr).split("0x")[1].upper()
def to_var_name(addr):
without_hex = addr.split("0x")[1]
return f"gUnknown_{without_hex}"
for i in range(len(sorted_addresses)):
address = sorted_addresses[i]
if i + 1 < len(sorted_addresses):
next_address = sorted_addresses[i + 1]
else:
next_address = end_of_data
addresses_with_size.append((address, format_memory_addr(address), upper_addr(next_address - address)))
summed = 0
with open("data/new_data.s", "w") as data_file:
data_file.write(' .section .rodata\n')
data_file.write('\n')
for raw_addr, addr, size in addresses_with_size:
summed += int(size, 16)
var = to_var_name(addr)
data_file.write(f""" .global {var}
{var}:
.incbin "data/baserom.gba", 0x{f"{(raw_addr - rom_start):08x}".upper()}, {size}
""")
print(hex(summed))
with open("asm/new_code.s", "w") as new_rom:
existing_code = "".join(open("asm/code.s").readlines())
for _, addr, __ in addresses_with_size:
var = to_var_name(addr)
existing_code = existing_code.replace(addr, to_var_name(addr))
new_rom.write(existing_code)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.