forked from az64/mm-rando
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntrance.cs
41 lines (35 loc) · 1.25 KB
/
Entrance.cs
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
using System;
namespace MMRando
{
public partial class ROMFuncs
{
private static int GetEntranceAddr(int ent)
{
int offset = ((ent >> 9) * 12) + 0xC5BC64;
int f = AddrToFile((uint)offset);
CheckCompressed(f);
offset -= MMFileList[f].Addr;
uint p1 = Arr_ReadU32(MMFileList[f].Data, offset);
offset = ((ent >> 4) & 0x1F) * 4;
p1 = (uint)((p1 & 0xFFFFFF) + 0xA96540 - MMFileList[f].Addr);
p1 = Arr_ReadU32(MMFileList[f].Data, (int)(p1 + offset));
p1 = (uint)((p1 & 0xFFFFFF) + 0xA96540 - MMFileList[f].Addr);
offset = (ent & 0xF) << 2;
return (int)p1 + offset;
}
public static void WriteEntrances(int[] olde, int[] newe)
{
int f = AddrToFile(0xC5BC64);
CheckCompressed(f);
uint[] data = new uint[newe.Length];
for (int i = 0; i < newe.Length; i++)
{
data[i] = Arr_ReadU32(MMFileList[f].Data, GetEntranceAddr(newe[i]));
};
for (int i = 0; i < newe.Length; i++)
{
Arr_WriteU32(MMFileList[f].Data, GetEntranceAddr(olde[i]), data[i]);
};
}
}
}