User:Blaziken257/T1 Origin research
I'm keeping this here for now because it's currently a mess.
Assigning origin to Denjuu
ASM code for assigning an origin to a Denjuu starts at 29:4055 (0xA4055 in ROM), then calls a function to 2A:4539 (0xA8539 in ROM).
First, the current map is determined (0xC904 in RAM). This reads from different parts of the ROM depending on the map.
If the current map is the overworld (internal IDs 0x02 to 0x09):
- Obtain the coordinate (0xC906 in RAM).
- Note: This is NOT quadrant-based. Here, this is treated as a full 16x16 map. So for example, if you're in coordinate (14,13), then it is treated as (14,13), not (6,5). The resulting index is 0x10 * y + x. So (14,13) would result in 0xED.
- There is a table of pointers starting at 0xAA4D5. To get the right pointer, take your index, multiply it by 2, and add it to 0xAA4D5. For example, if you're in (14,13), the pointer would be found at:
- 0xAA4D5 + 2*0xED = 0xAA6AF
- Find this pointer, and then go to that address. If you follow this example, the resulting pointer at 0xAA6AF is D8 66, which converts to 0xAA6D8.
- The value at this address is the origin. For example, at 0xAA6D8, it's 3, which corresponds to Palm Sea.
If the current map is marts/houses (internal ID 0x0B):
- Obtain the coordinate (0xC906 in RAM).
- If the internal coordinate ID is 0x38 ((0,7), since it's now 0x8 * y + x like on every 8x8 map), the origin is 0x05.
- Otherwise, it's 0x00.
For all other maps:
- Obtain the map ID (0xC904 in RAM, list here.)
- There is a table of pointers starting at 0xAA6E5. To get the right pointer, take your index, multiply it by 2, and add it to 0xAA6E5. For example, if you're in Toronko Spring, which has an internal map ID of 0x0A, the pointer would be found at:
- 0xAA6E5 + 2*0x0A = 0xAA6F9
- Find this pointer, and then go to that address. If you follow this example, the resulting pointer at 0xAA6FD is 4F 67, which converts to 0xAA74F.
- The value at this address is the origin. For example, at 0xAA74F, it's 0x0F, which corresponds to Toronko Village Spring.
When the origin is obtained (regardless of map):
It is output in external RAM bank 2, at address 0xA000 + (Denjuu no.)*0x10 + 0x08, where Denjuu # depends on the order you befriended them (the starting Denjuu is 0, etc.) For example, for the first Denjuu, it is 0xA008, for the second Denjuu, it is 0xA018, etc...
Overworld origin table
Here is a list of pointers for the overworld (endianness adjusted for readability):
0xAA4D5 - 0xAA6D4: 66E4 66E4 66E4 66E4 66E4 66E0 66E0 66E0 66E0 66E2 66E2 66E2 66E2 66DC 66DC 66DC 66E4 66E4 66E4 66E4 66E4 66E0 66E0 66E0 66E0 66E2 66E2 66E2 66E2 66DC 66DC 66DC 66E4 66E4 66E4 66E4 66E0 66E0 66E0 66E0 66E0 66E1 66E1 66E1 66E1 66DC 66DC 66DC 66E4 66E4 66E4 66E4 66E0 66E0 66E0 66E0 66E0 66E1 66E1 66E1 66E1 66DC 66DC 66DC 66E3 66E3 66E4 66D5 66D5 66E0 66E0 66E0 66E0 66E1 66E1 66E1 66E1 66DC 66DC 66DC 66E3 66E3 66E4 66D5 66D5 66DF 66DF 66DF 66DF 66E1 66E1 66E1 66E1 66DC 66DC 66DC 66E3 66E3 66D5 66D5 66D5 66D5 66DF 66DF 66DF 66E1 66E1 66E1 66E1 66DE 66DE 66DE 66E3 66E3 66D5 66D5 66D5 66D5 66DF 66DF 66DF 66DA 66DA 66DA 66DA 66DE 66DE 66DE 66E3 66E3 66D5 66D5 66D5 66DF 66DF 66DF 66DF 66DA 66DA 66DA 66DA 66DA 66D7 66D7 66D6 66D6 66D5 66D5 66D5 66DB 66DB 66DB 66DB 66D9 66D9 66DA 66DA 66DA 66D7 66D7 66D6 66D6 66D5 66D5 66D5 66DB 66DB 66DB 66DB 66D9 66D9 66DA 66DA 66D7 66D7 66D7 66D6 66D6 66D6 66DB 66DB 66DB 66DB 66DB 66DB 66D9 66D9 66DA 66DA 66D7 66D7 66D7 66D6 66D6 66D6 66DB 66DB 66DB 66DB 66DB 66D9 66D9 66D9 66DA 66DA 66DA 66D7 66D8 66DD 66DD 66DD 66DB 66DB 66DB 66DB 66DB 66D9 66D9 66D9 66D9 66D8 66D8 66D8 66D8 66DD 66DD 66DD 66DB 66DB 66DB 66DB 66DB 66D9 66D9 66D9 66D9 66D8 66D8 66D8 66D8 66DD 66DD 66DD 66DB 66DB 66DB 66DB 66DB 66D9 66D9 66D9 66D9 66D8 66D8 66D8 66D8
Here is the list of origins:
0xAA6D5 - 0xAA6E4: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 15 0E
Here is the most important part, a readable list of origins:
0E 0E 0E 0E 0E 0B 0B 0B 0B 0D 0D 0D 0D 07 07 07 0E 0E 0E 0E 0E 0B 0B 0B 0B 0D 0D 0D 0D 07 07 07 0E 0E 0E 0E 0B 0B 0B 0B 0B 0C 0C 0C 0C 07 07 07 0E 0E 0E 0E 0B 0B 0B 0B 0B 0C 0C 0C 0C 07 07 07 15 15 0E 00 00 0B 0B 0B 0B 0C 0C 0C 0C 07 07 07 15 15 0E 00 00 0A 0A 0A 0A 0C 0C 0C 0C 07 07 07 15 15 00 00 00 00 0A 0A 0A 0C 0C 0C 0C 09 09 09 15 15 00 00 00 00 0A 0A 0A 05 05 05 05 09 09 09 15 15 00 00 00 0A 0A 0A 0A 05 05 05 05 05 02 02 01 01 00 00 00 06 06 06 06 04 04 05 05 05 02 02 01 01 00 00 00 06 06 06 06 04 04 05 05 02 02 02 01 01 01 06 06 06 06 06 06 04 04 05 05 02 02 02 01 01 01 06 06 06 06 06 04 04 04 05 05 05 02 03 08 08 08 06 06 06 06 06 04 04 04 04 03 03 03 03 08 08 08 06 06 06 06 06 04 04 04 04 03 03 03 03 08 08 08 06 06 06 06 06 04 04 04 04 03 03 03 03
Origin table for other maps
Here is the origin table for other maps (endianness for pointers adjusted for readability):
0xAA6E5 - 0xAA74E: 674F 674F 674F 674F 674F 674F 674F 674F 674F 674F 674F 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 675A 675B 675C 675D 675E 675F 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 676A 676B 676C 676D 676E 676F 6770 6770 6770 6770 6771 6772 6773 6774 6774 6774
And here is the list of origins themselves:
0xAA74F - 0xAA774: 0F 00 10 10 11 12 13 13 13 13 13 14 14 14 14 14 0D 0D 0D 0D 0D 0D 0D 0D 0E 0E 0E 0E 0E 0E 0E 0E 0E 00 00 04 00 06
This corresponds to a following list:
Hex | Map | Origin |
---|---|---|
00 | ??? (Most likely unused) | 0F |
01 | ??? (Most likely unused) | 0F |
02 | Overworld Map - Upper left quadrant | 0F |
03 | Overworld Map - Upper right quadrant | 0F |
04 | Overworld Map - Lower left quadrant | 0F |
05 | Overworld Map - Lower right quadrant | 0F |
06 | Antenna Tree - Upper left quadrant | 0F |
07 | Antenna Tree - Upper right quadrant | 0F |
08 | Antenna Tree - Lower left quadrant | 0F |
09 | Antenna Tree - Lower right quadrant | 0F |
0A | Toronko Village Spring | 0F |
0B | Marts & Houses | 00 |
0C | Northeast Cavern - Floor 1 | 10 |
0D | Northeast Cavern - Floor 2 | 10 |
0E | Craft Research Center | 11 |
0F | Dimenza's Mansion | 12 |
10 | Toulipa Antenna Tree Cave - Floor 1 | 13 |
11 | Toulipa Antenna Tree Cave - Floor 2 | 13 |
12 | Toulipa Antenna Tree Cave - Floor 3 | 13 |
13 | Toulipa Antenna Tree Cave - Floor 4 | 13 |
14 | Toulipa Antenna Tree Cave - Floor 5 | 13 |
15 | Pepperi Mountain - Floor 1 | 14 |
16 | Pepperi Mountain - Floor 2 | 14 |
17 | Pepperi Mountain - Floor 3 | 14 |
18 | Pepperi Mountain - Floor 4 | 14 |
19 | Pepperi Mountain - Floor 5 | 14 |
1A | Cactos Ruins - Floor 1 | 0D |
1B | Cactos Ruins - Floor 2 | 0D |
1C | Cactos Ruins - Floor 3 | 0D |
1D | Cactos Ruins - Floor 4 | 0D |
1E | Cactos Ruins - Floor 5 | 0D |
1F | Cactos Ruins - Floor 6 | 0D |
20 | Cactos Ruins - Floor 7 | 0D |
21 | Cactos Ruins - Floor 8 | 0D |
22 | Bryon Ruins - Floor 1 | 0E |
23 | Bryon Ruins - Floor 2 | 0E |
24 | Bryon Ruins - Floor 3 | 0E |
25 | Bryon Ruins - Floor 4 | 0E |
26 | Bryon Ruins - Floor 5 | 0E |
27 | Bryon Ruins - Floor 6 | 0E |
28 | Bryon Ruins - Floor 7 | 0E |
29 | Bryon Ruins - Floor 8 | 0E |
2A | Bryon Ruins - Floor 9 | 0E |
2B | Human World - Main Area | 00 |
2C | Human World - Antenna Tree | 00 |
2D | Human World - Unused Buildings | 00 |
2E | Teletel/Dendel's cave | 00 |
2F | Unused replica of Golaking's room | 00 |
30 | Room with second D-Shot | 04 |
31 | Room with switch which activates Palm Sea Antenna Tree | 00 |
32 | Sanaeba Research Center - Floor 1 | 06 |
33 | Sanaeba Research Center - Basement 1 | 06 |
34 | Sanaeba Research Center - Basement 2 | 06 |
Weird that there's a list for maps 0x00-0x09, and 0x0B... are these considered unused?
Also, this table of origins seem to affect the music somehow... at least I noticed it for the overworld, I didn't look much for the other maps.
Number of turns based on origin
Will work on this later...