Gota7 / SM64DSe-Ultimate

This is an edited version of sm64dse 2.3.5.
GNU General Public License v3.0
23 stars 16 forks source link

Discussion: Message ID to Sign table #38

Open axel7083 opened 1 year ago

axel7083 commented 1 year ago

Description

The Sign, does not use the Message ID to select which message to display. There is a Mapping table for object message ids (parameter of the objects) to object message ids (the ones in the text editor).

A lot of element does not have a match corresponding in the text editor. Which makes it very weird. I was hopping to have a clear match between the Sign first parameter value and the text. But sometime I can't found the matching correspondance in the table

Some weird sign I do not understand the mapping:

Location Parameter 1 message ID
image 0x73E 0x006A (I changed the message value from the editor)

Extracted and formatted table

This table is located at 0x0208eeec, it seems to be a table of short with a size of 196. object ID message ID
0x0000 0x0000 (Dear Mario:\nPlease c...)
0x6400 0x0004 (Yoshi!...)
0x7800 0x000d (Oh!...)
0x8200 0x0016 (Oh!...)
0xc800 0x0017 (You need a key to \no...)
0xe803 0x002a (BEWARE OF CHAIN-CHOM...)
0x1a04 0x0033 (I'm sleeping because...)
0x4c04 0x0038 (ATTENTION! \nRead Bef...)
0x7e04 0x003b (Warning!\nCold, Cold ...)
0xb004 0x003e (You don't stand a gh...)
0xe204 0x0040 (Both ways fraught wi...)
0x1405 0x004c (It's Lethal Lava Lan...)
0x4605 0x004d (Watch out! Don't let...)
0x7805 0x004f (empty)
0xaa05 0x0050 (BRRR! Frostbite Dang...)
0xdc05 0x0052 (The mystery is of We...)
0x0e06 0x0053 (STRONG WIND!\nHold on...)
0x4006 0x0054 (It's not our problem...)
0x7206 0x0056 (empty)
0xa406 0x0057 (empty)
0xd606 0x0058 (Watch out for \nBowse...)
0x0807 0x005c (Princess Toadstool's...)
0x3a07 0x0066 (Pssst! The Boos are ...)
0xd007 0x0083 (In Standard Mode, pr...)
0xd107 0x0087 (You there, sir.\nWatc...)
0xd207 0x008b (Danger! We're in the...)
0xd307 0x008f (Thank you! The Big \n...)
0xdb07 0x009a (I'm the Big Bob-omb,...)
0xdc07 0x009e (Ow! That hurts! How ...)
0x0208 0x00a2 (That was such a good...)
0x3408 0x00a6 (No! Crushed again!\nI...)
0x6608 0x00a7 (empty)
0x7308 0x00b3 (Ayiiieee! Please don...)
0x9808 0x00b4 (So it IS true that \n...)
0xca08 0x00b6 (Boooooo-m! Here come...)
0xfc08 0x00b7 (empty)
0x2e09 0x00b8 (empty)
0x6009 0x00ba (Grrrrumbbble!\nWhat.....)
0x9209 0x00bb (empty)
0xc409 0x00bc (Hey! \nWho's there?\nW...)
0xf609 0x00bd (empty)
0x280a 0x00c4 (Uukee-kee! Don't eat...)
0x5a0a 0x00ca (Owwch! Uncle! Uncle!...)
0x8c0a 0x00cb (empty)
0xbe0a 0x00cc (empty)
0xc60a 0x00d7 (Bwa ha ha!\nI'm no or...)
0xc70a 0x00db (Beaten by a pip-sque...)
0xc80a 0x00df (empty)
0xc90a 0x00e3 (empty)
0xca0a 0x00e7 (Hmm? I see you have ...)
0xcb0a 0x00eb (I simply cannot beli...)
0xf00a 0x00ec (Eee hee hee...\nI am ...)
0xf10a 0x00f0 (Thank heavens you \nc...)
0xf20a 0x00f4 (The Star you chose a...)
0xf30a 0x00f8 (Bowser took all the ...)
0xf40a 0x00fc (Wow! You've recovere...)
0xf50a 0x0100 (Thank you, Yoshi!\nTh...)
0xf60a 0x0104 (You don't normally w...)
0xf70a 0x0108 (That dinosaur-skin l...)
0xf80a 0x010c (Wow! Look at all tho...)
0xf90a 0x0110 (Wow! Look at all tho...)
0xfa0a 0x0114 (You've finally corne...)
0xfb0a 0x0118 (You've got Bowser\nco...)
0xff0a 0x011f (Noooo! Don't eat me!...)
0x000b 0x0123 (What part of ”I'm no...)
0x010b 0x0127 (Aaaargh!\nOh no, plea...)
0x020b 0x012b (I already gave you t...)
0x070b 0x0133 (Oh, no! Oh, no!\nI lo...)
0x130b 0x0142 (Yoshi! Mario and the...)
0x220b 0x014a (You got the key to\nt...)
0x270b 0x0152 (Looks like red caps ...)
0x280b 0x0156 (Green caps are all t...)
0x290b 0x015a (Yellow caps are real...)
0xb80b 0x0160 (Awesome!\nYou've coll...)
0xea0b 0x0161 (Chasing Mario led yo...)
0x1c0c 0x0162 (Hello! The Lakitu Br...)
0x4e0c 0x0163 (empty)
0x800c 0x0164 (Snow Mountain Summit...)
0xb20c 0x0167 (Luigi... Luigi......)
0xe40c 0x0168 (empty)
0x160d 0x0169 (Don't be a pushover!...)
0x480d 0x016a (empty)
0x7a0d 0x016b (empty)
0xac0d 0x016c (empty)
0xde0d 0x016d (empty)
0x100e 0x016e (empty)
0x420e 0x016f (empty)
0x740e 0x0170 (empty)
0xa60e 0x0171 (empty)
0xd80e 0x0175 (empty)
0x0a0f 0x0183 (Uh-oh. Looks like th...)
0x1e0f 0x018d (You've retrieved the...)
0x8813 0x0196 (While searching for ...)
0xb013 0x01b3 ( THE SECRET OF BAT...)
0xec13 0x01b4 ( CASTLE SECRET STA...)
0x7017 0x0224 (The door to the thir...)
0x581b 0x024e (Shell Smash\n\nHit Koo...)
0x401f 0x0276 (All Rights,\nincludin...)
axel7083 commented 1 year ago

The function responsible of converting ObjectID to MessageID will be called ObjectMessageIDToActualMessageID and is located at 0x0201fc10.

An implementation of the function would like this:

int ObjectMessageIDToActualMessageID(unsigned short param_1)
{
    int iVar1 = 97;
    do {
        unsigned short indexValue = (MSG_ID_CHAR_MAP)[iVar1 * 2];
        if (param_1 < indexValue) {
            unsigned short nextIndexValue = MSG_ID_CHAR_MAP[(iVar1 - 1) * 2];
            if (nextIndexValue <= param_1) {
                unsigned short difference = param_1 - nextIndexValue;
                unsigned short correspondingValue = MSG_ID_CHAR_MAP[(iVar1 + -1) * 2 + 1] & 0xffff;
                return difference + correspondingValue;
            }
        }
        iVar1 = iVar1 + -1;
    } while (0 < iVar1);
    return param_1;
}

The function is not looking for a match, but will rather compute it.

Here is a step by step example:

(1) You have the ObjectID

In our example we will take 0x73E == 1854.

(2) Iterate over the ObjectID

The ObjectID column is sorted, you need to found the range where MSG_ID_CHAR_MAP[i] < ObjectID <MSG_ID_CHAR_MAP[i +2]

We found the lower bound to be 1850.

(3) Take the difference

Between the lower bound 1850 and your 1854, the difference is 4.

(4) sum the lower bound corresponding value with the difference

The corresponding MessageID of 1850 is 102, so we got 102+4=106 our messageID is 106

axel7083 commented 1 year ago

Mapping table with NUMBERS formatted properly

ObjectID MessageID
0 0
100 4
120 13
130 22
200 23
1000 42
1050 51
1100 56
1150 59
1200 62
1250 64
1300 76
1350 77
1400 79
1450 80
1500 82
1550 83
1600 84
1650 86
1700 87
1750 88
1800 92
1850 102
2000 131
2001 135
2002 139
2003 143
2011 154
2012 158
2050 162
2100 166
2150 167
2163 179
2200 180
2250 182
2300 183
2350 184
2400 186
2450 187
2500 188
2550 189
2600 196
2650 202
2700 203
2750 204
2758 215
2759 219
2760 223
2761 227
2762 231
2763 235
2800 236
2801 240
2802 244
2803 248
2804 252
2805 256
2806 260
2807 264
2808 268
2809 272
2810 276
2811 280
2815 287
2816 291
2817 295
2818 299
2823 307
2835 322
2850 330
2855 338
2856 342
2857 346
3000 352
3050 353
3100 354
3150 355
3200 356
3250 359
3300 360
3350 361
3400 362
3450 363
3500 364
3550 365
3600 366
3650 367
3700 368
3750 369
3800 373
3850 387
3870 397
5000 406
5040 435
5100 436
6000 548
7000 590
8000 630