Advertisement
Moolah60

ACCF MessageTag Commands

Nov 16th, 2022
1,005
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 42.53 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Navigation;
  6.  
  7. namespace Animal_Crossing_Text_Editor.Classes.Parser.Wii
  8. {
  9.     public static class MessageTags
  10.     {
  11.         public sealed class Conversion
  12.         {
  13.             public Func<byte, ushort, byte[], int, byte[], int> String2Bytes;
  14.             public Func<byte, ushort, byte[], string> Bytes2String;
  15.  
  16.             public void ToBytes(byte group, ushort index, in byte[] args, ref int write_ofs, in byte[] data)
  17.             {
  18.                 int res = String2Bytes(group, index, args, write_ofs, data);
  19.                 write_ofs += res;
  20.             }
  21.  
  22.             public string ToString(byte group, ushort index, in byte[] args) => Bytes2String(group, index, args);
  23.  
  24.             public static implicit operator Conversion(Func<byte, ushort, byte[], int, byte[], int> s2b)
  25.             {
  26.                 return new Conversion() { String2Bytes = s2b };
  27.             }
  28.  
  29.             public static implicit operator Conversion(Func<byte, ushort, byte[], string> b2s)
  30.             {
  31.                 return new Conversion() { Bytes2String = b2s };
  32.             }
  33.  
  34.             public static implicit operator Conversion((Func<byte, ushort, byte[], string>, Func<byte, ushort, byte[], int, byte[], int>) methods)
  35.             {
  36.                 return new Conversion() { Bytes2String = methods.Item1, String2Bytes = methods.Item2 };
  37.             }
  38.         }
  39.  
  40.         public sealed class MessageTag
  41.         {
  42.             public byte Group;
  43.             public ushort Index;
  44.             public int ArgsByteCount;
  45.  
  46.             public readonly Conversion Conversion;
  47.             public Func<byte[], int> GetArgsSize;
  48.  
  49.             public MessageTag(byte group, ushort index, int argsByteCount, Conversion conversion)
  50.             {
  51.                 Group = group;
  52.                 Index = index;
  53.                 ArgsByteCount = argsByteCount;
  54.                 Conversion = conversion;
  55.             }
  56.  
  57.             public MessageTag(byte group, ushort index, int argsByteCount, Func<byte, ushort, byte[], string> b2s, Func<byte, ushort, byte[], int, byte[], int> s2b)
  58.                 : this(group, index, argsByteCount, (b2s, s2b)) { }
  59.         }
  60.  
  61.         public static string GetMessageTagString(byte group, ushort index, in byte[] arguments = null)
  62.         {
  63.             if (Tags.ContainsKey(group) && Tags[group].ContainsKey(index))
  64.             {
  65.                 return Tags[group][index].Conversion.Bytes2String(group, index, arguments);
  66.             }
  67.  
  68.             var argsStr = arguments?.Aggregate("", (result, i) => result + i.ToString("X2") + " ").Trim() ?? "";
  69.             return $"<Unk {group:X2}|{index:X4}|{argsStr}>";
  70.         }
  71.  
  72.         private static readonly Func<byte, ushort, byte[], int, byte[], int> default_string2bytes = (group, index, args, i, data) =>
  73.         {
  74.             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  75.             data[i + 1] = WiiParser.TAG_CHARACTER;
  76.             data[i + 2] = 0x6;
  77.             data[i + 3] = group;
  78.             data[i + 4] = (byte)(index >> 8);
  79.             data[i + 5] = (byte)index;
  80.             return 6;
  81.         };
  82.  
  83.         private static readonly string[] Species = new string[33]
  84.         {
  85.             "Cat", "Elephant", "Sheep", "Bear", "Dog", "Squirrel", "Rabbit", "Duck",
  86.             "Hippo", "Wolf", "Kouse", "Pig", "Chicken", "Bull", "Cow", "Bird",
  87.             "Frog", "Crocodile", "Goat", "Tiger", "Anteater", "Koala", "Horse", "Octopus",
  88.             "Lion", "Cub", "Rhino", "Gorilla", "Ostrich", "Kangaroo", "Eagle", "Penguin",
  89.             "Monkey"
  90.         };
  91.  
  92.         public static readonly IReadOnlyDictionary<byte, IReadOnlyDictionary<ushort, MessageTag>> Tags = new Dictionary<byte, IReadOnlyDictionary<ushort, MessageTag>>()
  93.         {
  94.             {
  95.                 0x00, new Dictionary<ushort, MessageTag>
  96.                 {
  97.                     { 0x0003, new MessageTag(0x00, 0x0003, 0, (_, __, ___) => "<Music Symbol>", default_string2bytes) },
  98.                 }
  99.             },
  100.  
  101.             // Emotion/Reaction
  102.             { 0x02, new Dictionary<ushort, MessageTag>
  103.                 {
  104.                     { 0x0000, new MessageTag(0x02, 0x0000, 0, (_, __, ___) => "<Clear Reaction>", default_string2bytes) },
  105.                     { 0x000A, new MessageTag(0x02, 0x000A, 0, (_, __, ___) => "<Reaction (Joy)>", default_string2bytes) },
  106.                     { 0x000B, new MessageTag(0x02, 0x000B, 0, (_, __, ___) => "<Reaction (Curiosity)>", default_string2bytes) },
  107.                     { 0x0014, new MessageTag(0x02, 0x0014, 0, (_, __, ___) => "<Reaction (Happiness)>", default_string2bytes) },
  108.                     { 0x0016, new MessageTag(0x02, 0x0016, 0, (_, __, ___) => "<Reaction (Worry)>", default_string2bytes) }, // Not sure about this yet.
  109.                 }
  110.             },
  111.  
  112.             {
  113.                 /* Dynamic & Item Strings */
  114.                 0x04, new Dictionary<ushort, MessageTag>
  115.                 {
  116.                     {
  117.                         0x0001, new MessageTag(0x04, 0x0001, -1,
  118.                         (_, __, args) => $"<String [{args[0]}] [{Encoding.BigEndianUnicode.GetString(args, 1, (args.Length & 1) == 0 ? args.Length - 2 : args.Length - 1)}]>",
  119.                         (group, index, args, i, data) => {
  120.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  121.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  122.                             data[i + 2] = (byte)(0x6 + args.Length);
  123.                             data[i + 3] = group;
  124.                             data[i + 4] = (byte)(index >> 8);
  125.                             data[i + 5] = (byte)index;
  126.                             Buffer.BlockCopy(args, 0, data, i + 6, args.Length);
  127.                             return 6 + 1 * sizeof(ushort);
  128.                         })
  129.                         {
  130.                             GetArgsSize = (data) => data.Length // first byte is the number of characters to replace
  131.                         }
  132.                     }
  133.                 }
  134.             },
  135.  
  136.             // String
  137.             { 0x05, new Dictionary<ushort, MessageTag>
  138.                 {
  139.                     { 0x0000, new MessageTag(0x05, 0x0000, 0, (_, __, ___) => "<Player>", default_string2bytes) },
  140.                     { 0x0001, new MessageTag(0x05, 0x0001, 0, (_, __, ___) => "<NPC>", default_string2bytes) },
  141.                     { 0x0005, new MessageTag(0x05, 0x0005, 0, (_, __, ___) => "<Town>", default_string2bytes) },
  142.                     { 0x0006, new MessageTag(0x05, 0x0006, 0, (_, __, ___) => "<Catchphrase>", default_string2bytes) },
  143.                     { 0x0007, new MessageTag(0x05, 0x0007, 0, (_, __, ___) => "<Player Nickname>", default_string2bytes) },
  144.                 }
  145.             },
  146.  
  147.             // Base
  148.             { 0x06, new Dictionary<ushort, MessageTag>
  149.                 {
  150.                     { 0x0000, new MessageTag(0x06, 0x0000, 1 * sizeof(ushort),
  151.                         (_, __, args) => $"<Pause [{BitConverterBE.ToUInt16(args, 0)}]>",
  152.                         (group, index, args, i, data) => {
  153.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  154.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  155.                             data[i + 2] = 0x6 + sizeof(ushort);
  156.                             data[i + 3] = group;
  157.                             data[i + 4] = (byte)(index >> 8);
  158.                             data[i + 5] = (byte)index;
  159.                             data[i + 6] = args[0];
  160.                             data[i + 7] = args[1];
  161.                             return 6 + sizeof(ushort);
  162.                         })
  163.                     },
  164.                     { 0x0001, new MessageTag(0x06, 0x0001, 0, (_, __, ___) => $"<Press Button>", default_string2bytes) },
  165.                 }
  166.             },
  167.  
  168.             // Choices
  169.             {
  170.                 0x07, new Dictionary<ushort, MessageTag>
  171.                 {
  172.                     //{ 0x0000, (_, __, args) => $"<Set Choices [{args[0]:X2}] [{args[1]:X2}]>" },
  173.                     //{ 0x0001, (_, __, args) => $"<Set Choices [{args[0]:X2}] [{args[1]:X2}] [{args[2]:X2}]>" },
  174.                     //{ 0x0002, (_, __, args) => $"<Set Choices [{args[0]:X2}] [{args[1]:X2}] [{args[2]:X2}] [{args[3]:X2}]>" },
  175.                     { 0x0004, new MessageTag(0x07, 0x0004, 2 * sizeof(ushort),
  176.                         (_, __, args) => $"<Set Choices [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}]>",
  177.                         (group, index, args, i, data) => {
  178.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  179.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  180.                             data[i + 2] = 0x6 + 2 * sizeof(ushort);
  181.                             data[i + 3] = group;
  182.                             data[i + 4] = (byte)(index >> 8);
  183.                             data[i + 5] = (byte)index;
  184.                             data[i + 6] = args[0];
  185.                             data[i + 7] = args[1];
  186.                             data[i + 8] = args[2];
  187.                             data[i + 9] = args[3];
  188.                             return 6 + 2 * sizeof(ushort);
  189.                         })
  190.                     },
  191.                 }
  192.             },
  193.  
  194.             // Dynamic
  195.             {
  196.                 0x08, new Dictionary<ushort, MessageTag>
  197.                 {
  198.                     { 0x0000, new MessageTag(0x08, 0x0000, 2 * sizeof(ushort),
  199.                         (_, __, args) => $"<Random Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}]>",
  200.                         (group, index, args, i, data) => {
  201.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  202.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  203.                             data[i + 2] = 0x6 + 2 * sizeof(ushort);
  204.                             data[i + 3] = group;
  205.                             data[i + 4] = (byte)(index >> 8);
  206.                             data[i + 5] = (byte)index;
  207.                             data[i + 6] = args[0];
  208.                             data[i + 7] = args[1];
  209.                             data[i + 8] = args[2];
  210.                             data[i + 9] = args[3];
  211.                             return 6 + 2 * sizeof(ushort);
  212.                         })
  213.                     },
  214.                     { 0x0001, new MessageTag(0x08, 0x0001, 3 * sizeof(ushort),
  215.                         (_, __, args) => $"<Random Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}] [{BitConverterBE.ToUInt16(args, 4):X4}]>",
  216.                         (group, index, args, i, data) => {
  217.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  218.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  219.                             data[i + 2] = 0x6 + 3 * sizeof(ushort);
  220.                             data[i + 3] = group;
  221.                             data[i + 4] = (byte)(index >> 8);
  222.                             data[i + 5] = (byte)index;
  223.                             data[i + 6] = args[0];
  224.                             data[i + 7] = args[1];
  225.                             data[i + 8] = args[2];
  226.                             data[i + 9] = args[3];
  227.                             data[i + 10] = args[4];
  228.                             data[i + 11] = args[5];
  229.                             return 6 + 3 * sizeof(ushort);
  230.                         })
  231.                     },
  232.                     { 0x0002, new MessageTag(0x08, 0x0002, 1 * sizeof(byte) + 2 * sizeof(ushort),
  233.                         (_, __, args) => $"<Friendship Dialog Jump [{args[0]:X2}] [{BitConverterBE.ToUInt16(args, 1):X4}] [{BitConverterBE.ToUInt16(args, 3):X4}]>",
  234.                         (group, index, args, i, data) => {
  235.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  236.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  237.                             data[i + 2] = 0x6 + 1 * sizeof(byte) +2 * sizeof(ushort);
  238.                             data[i + 3] = group;
  239.                             data[i + 4] = (byte)(index >> 8);
  240.                             data[i + 5] = (byte)index;
  241.                             data[i + 6] = args[0];
  242.                             data[i + 7] = args[1];
  243.                             data[i + 8] = args[2];
  244.                             data[i + 9] = args[3];
  245.                             data[i + 10] = args[4];
  246.                             return 6 + 1 * sizeof(byte) + 2 * sizeof(ushort);
  247.                         })
  248.                     },
  249.                     { 0x0003, new MessageTag(0x08, 0x0003, 2 * sizeof(ushort),
  250.                         (_, __, args) => $"<Gender Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}]>",
  251.                         (group, index, args, i, data) => {
  252.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  253.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  254.                             data[i + 2] = 0x6 + 2 * sizeof(ushort);
  255.                             data[i + 3] = group;
  256.                             data[i + 4] = (byte)(index >> 8);
  257.                             data[i + 5] = (byte)index;
  258.                             data[i + 6] = args[0];
  259.                             data[i + 7] = args[1];
  260.                             data[i + 8] = args[2];
  261.                             data[i + 9] = args[3];
  262.                             return 6 + 2 * sizeof(ushort);
  263.                         })
  264.                     },
  265.                     { 0x0004, new MessageTag(0x08, 0x0004, 5 * sizeof(ushort),
  266.                         (_, __, args) => $"<House Size Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}] [{BitConverterBE.ToUInt16(args, 4):X4}] [{BitConverterBE.ToUInt16(args, 6):X4}] [{BitConverterBE.ToUInt16(args, 8):X4}]>",
  267.                         (group, index, args, i, data) => {
  268.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  269.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  270.                             data[i + 2] = 0x6 + 5 * sizeof(ushort);
  271.                             data[i + 3] = group;
  272.                             data[i + 4] = (byte)(index >> 8);
  273.                             data[i + 5] = (byte)index;
  274.                             data[i + 6] = args[0];
  275.                             data[i + 7] = args[1];
  276.                             data[i + 8] = args[2];
  277.                             data[i + 9] = args[3];
  278.                             data[i + 10] = args[4];
  279.                             data[i + 11] = args[5];
  280.                             data[i + 12] = args[6];
  281.                             data[i + 13] = args[7];
  282.                             data[i + 14] = args[8];
  283.                             data[i + 15] = args[9];
  284.                             return 6 + 5 * sizeof(ushort);
  285.                         })
  286.                     },
  287.                     { 0x0005, new MessageTag(0x08, 0x0005, 3 * sizeof(ushort), // First is < 60% completion, second is >= 60% completion, third is 100% completion
  288.                         (_, __, args) => $"<Insect Collection Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}] [{BitConverterBE.ToUInt16(args, 4):X4}]>",
  289.                         (group, index, args, i, data) => {
  290.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  291.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  292.                             data[i + 2] = 0x6 + 3 * sizeof(ushort);
  293.                             data[i + 3] = group;
  294.                             data[i + 4] = (byte)(index >> 8);
  295.                             data[i + 5] = (byte)index;
  296.                             data[i + 6] = args[0];
  297.                             data[i + 7] = args[1];
  298.                             data[i + 8] = args[2];
  299.                             data[i + 9] = args[3];
  300.                             data[i + 10] = args[4];
  301.                             data[i + 11] = args[5];
  302.                             return 6 + 3 * sizeof(ushort);
  303.                         })
  304.                     },
  305.                     { 0x0006, new MessageTag(0x08, 0x0006, 3 * sizeof(ushort), // First is < 60% completion, second is >= 60% completion, third is 100% completion
  306.                         (_, __, args) => $"<Fish Collection Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}] [{BitConverterBE.ToUInt16(args, 4):X4}]>",
  307.                         (group, index, args, i, data) => {
  308.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  309.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  310.                             data[i + 2] = 0x6 + 3 * sizeof(ushort);
  311.                             data[i + 3] = group;
  312.                             data[i + 4] = (byte)(index >> 8);
  313.                             data[i + 5] = (byte)index;
  314.                             data[i + 6] = args[0];
  315.                             data[i + 7] = args[1];
  316.                             data[i + 8] = args[2];
  317.                             data[i + 9] = args[3];
  318.                             data[i + 10] = args[4];
  319.                             data[i + 11] = args[5];
  320.                             return 6 + 3 * sizeof(ushort);
  321.                         })
  322.                     },
  323.                     { 0x0007, new MessageTag(0x08, 0x0007, 5 * sizeof(ushort), // First is 0-6 villagers, second is 7, third is 8, fourth is 9, fifth is 10
  324.                         (_, __, args) => $"<Villager Count Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}] [{BitConverterBE.ToUInt16(args, 4):X4}] [{BitConverterBE.ToUInt16(args, 6):X4}] [{BitConverterBE.ToUInt16(args, 8):X4}]>",
  325.                         (group, index, args, i, data) => {
  326.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  327.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  328.                             data[i + 2] = 0x6 + 5 * sizeof(ushort);
  329.                             data[i + 3] = group;
  330.                             data[i + 4] = (byte)(index >> 8);
  331.                             data[i + 5] = (byte)index;
  332.                             data[i + 6] = args[0];
  333.                             data[i + 7] = args[1];
  334.                             data[i + 8] = args[2];
  335.                             data[i + 9] = args[3];
  336.                             data[i + 10] = args[4];
  337.                             data[i + 11] = args[5];
  338.                             data[i + 12] = args[6];
  339.                             data[i + 13] = args[7];
  340.                             data[i + 14] = args[8];
  341.                             data[i + 15] = args[9];
  342.                             return 6 + 5 * sizeof(ushort);
  343.                         })
  344.                     },
  345.                     { 0x0008, new MessageTag(0x08, 0x0008, 4 * sizeof(ushort), // First is 05:00-11:59, second is 12:00-17:59, third is 18:00-23:59, fourth is 00:00-04:59
  346.                         (_, __, args) => $"<Time of Day Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}] [{BitConverterBE.ToUInt16(args, 4):X4}] [{BitConverterBE.ToUInt16(args, 6):X4}]>",
  347.                         (group, index, args, i, data) => {
  348.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  349.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  350.                             data[i + 2] = 0x6 + 4 * sizeof(ushort);
  351.                             data[i + 3] = group;
  352.                             data[i + 4] = (byte)(index >> 8);
  353.                             data[i + 5] = (byte)index;
  354.                             data[i + 6] = args[0];
  355.                             data[i + 7] = args[1];
  356.                             data[i + 8] = args[2];
  357.                             data[i + 9] = args[3];
  358.                             data[i + 10] = args[4];
  359.                             data[i + 11] = args[5];
  360.                             data[i + 12] = args[6];
  361.                             data[i + 13] = args[7];
  362.                             return 6 + 4 * sizeof(ushort);
  363.                         })
  364.                     },
  365.                     { 0x0009, new MessageTag(0x08, 0x0009, 8 * sizeof(ushort), // Weather based jump -- Args in order: Clear, Cloudy, Overcast, Rain, Heavy Rain, Snow, Heavy Snow, Cherry Blossoms
  366.                         (_, __, args) => $"<Weather Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}] [{BitConverterBE.ToUInt16(args, 4):X4}] [{BitConverterBE.ToUInt16(args, 6):X4}] [{BitConverterBE.ToUInt16(args, 8):X4}] [{BitConverterBE.ToUInt16(args, 10):X4}] [{BitConverterBE.ToUInt16(args, 12):X4}] [{BitConverterBE.ToUInt16(args, 14):X4}]>",
  367.                         (group, index, args, i, data) => {
  368.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  369.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  370.                             data[i + 2] = 0x6 + 8 * sizeof(ushort);
  371.                             data[i + 3] = group;
  372.                             data[i + 4] = (byte)(index >> 8);
  373.                             data[i + 5] = (byte)index;
  374.  
  375.                             for (int x = 0; x < 8*sizeof(ushort); x += 2)
  376.                             {
  377.                                 data[i + 6 + x] = args[x];
  378.                                 data[i + 7 + x] = args[x + 1];
  379.                             }
  380.  
  381.                             return 6 + 8 * sizeof(ushort);
  382.                         })
  383.                     },
  384.                     { 0x000A, new MessageTag(0x08, 0x000A, 4 * sizeof(ushort), // 0 = 1 player, 1 = 2 players, ...
  385.                         (_, __, args) => $"<Player Count Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}] [{BitConverterBE.ToUInt16(args, 4):X4}] [{BitConverterBE.ToUInt16(args, 6):X4}]>",
  386.                         (group, index, args, i, data) => {
  387.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  388.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  389.                             data[i + 2] = 0x6 + 4 * sizeof(ushort);
  390.                             data[i + 3] = group;
  391.                             data[i + 4] = (byte)(index >> 8);
  392.                             data[i + 5] = (byte)index;
  393.                             data[i + 6] = args[0];
  394.                             data[i + 7] = args[1];
  395.                             data[i + 8] = args[2];
  396.                             data[i + 9] = args[3];
  397.                             data[i + 10] = args[4];
  398.                             data[i + 11] = args[5];
  399.                             data[i + 12] = args[6];
  400.                             data[i + 13] = args[7];
  401.                             return 6 + 4 * sizeof(ushort);
  402.                         })
  403.                     },
  404.                     { 0x000B, new MessageTag(0x08, 0x000B, 7 * sizeof(ushort), // Day of week Jump (Monday -> Sunday)
  405.                         (_, __, args) => $"<Day of Week Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}] [{BitConverterBE.ToUInt16(args, 4):X4}] [{BitConverterBE.ToUInt16(args, 6):X4}] [{BitConverterBE.ToUInt16(args, 8):X4}] [{BitConverterBE.ToUInt16(args, 10):X4}] [{BitConverterBE.ToUInt16(args, 12):X4}]>",
  406.                         (group, index, args, i, data) => {
  407.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  408.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  409.                             data[i + 2] = 0x6 + 7 * sizeof(ushort);
  410.                             data[i + 3] = group;
  411.                             data[i + 4] = (byte)(index >> 8);
  412.                             data[i + 5] = (byte)index;
  413.  
  414.                             for (int x = 0; x < 7*sizeof(ushort); x += 2)
  415.                             {
  416.                                 data[i + 6 + x] = args[x];
  417.                                 data[i + 7 + x] = args[x + 1];
  418.                             }
  419.  
  420.                             return 6 + 7 * sizeof(ushort);
  421.                         })
  422.                     },
  423.                     { 0x000C, new MessageTag(0x08, 0x000C, 2 * sizeof(ushort), // args[0] = player lives in town, args[1] = player is foriegner
  424.                         (_, __, args) => $"<Foreign Player Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}]>",
  425.                         (group, index, args, i, data) => {
  426.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  427.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  428.                             data[i + 2] = 0x6 + 2 * sizeof(ushort);
  429.                             data[i + 3] = group;
  430.                             data[i + 4] = (byte)(index >> 8);
  431.                             data[i + 5] = (byte)index;
  432.                             data[i + 6] = args[0];
  433.                             data[i + 7] = args[1];
  434.                             data[i + 8] = args[2];
  435.                             data[i + 9] = args[3];
  436.                             return 6 + 2 * sizeof(ushort);
  437.                         })
  438.                     },
  439.                     { 0x000D, new MessageTag(0x08, 0x000D, 3 * sizeof(ushort),
  440.                         (_, __, args) => $"<Species Dialog Jump [{Species[BitConverterBE.ToUInt16(args, 0)]}] [{BitConverterBE.ToUInt16(args, 2):X4}] [{BitConverterBE.ToUInt16(args, 4):X4}]>",
  441.                         (group, index, args, i, data) => {
  442.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  443.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  444.                             data[i + 2] = 0x6 + 3 * sizeof(ushort);
  445.                             data[i + 3] = group;
  446.                             data[i + 4] = (byte)(index >> 8);
  447.                             data[i + 5] = (byte)index;
  448.                             data[i + 6] = args[0];
  449.                             data[i + 7] = args[1];
  450.  
  451.                             // TODO: Refactor how arguments work to be a string array and parse out needed values.
  452.  
  453.                             data[i + 8] = args[2];
  454.                             data[i + 9] = args[3];
  455.                             return 6 + 3 * sizeof(ushort);
  456.                         })
  457.                     },
  458.                     { 0x000E, new MessageTag(0x08, 0x000E, 1 * sizeof(uint) + 2 * sizeof(ushort), // first message id is >= bell value, second is less
  459.                         (_, __, args) => $"<Player Bell Value Dialog Jump [{BitConverterBE.ToUInt32(args, 0)}] [{BitConverterBE.ToUInt16(args, 4):X4}] [{BitConverterBE.ToUInt16(args, 6):X4}]>",
  460.                         (group, index, args, i, data) => {
  461.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  462.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  463.                             data[i + 2] = 0x6 + 1 * sizeof(uint) + 2 * sizeof(ushort);
  464.                             data[i + 3] = group;
  465.                             data[i + 4] = (byte)(index >> 8);
  466.                             data[i + 5] = (byte)index;
  467.                             data[i + 6] = args[0];
  468.                             data[i + 7] = args[1];
  469.  
  470.                             // TODO: Refactor how arguments work to be a string array and parse out needed values.
  471.  
  472.                             data[i + 8] = args[2];
  473.                             data[i + 9] = args[3];
  474.                             return 6 + 1 * sizeof(uint) + 2 * sizeof(ushort);
  475.                         })
  476.                     },
  477.                     { 0x000F, new MessageTag(0x08, 0x000F, 2 * sizeof(ushort), // first message idx is used when player has inventory space, second when they don't have any free space
  478.                         (_, __, args) => $"<Free Inventory Space Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}]>",
  479.                         (group, index, args, i, data) => {
  480.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  481.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  482.                             data[i + 2] = 0x6 + 2 * sizeof(ushort);
  483.                             data[i + 3] = group;
  484.                             data[i + 4] = (byte)(index >> 8);
  485.                             data[i + 5] = (byte)index;
  486.                             data[i + 6] = args[0];
  487.                             data[i + 7] = args[1];
  488.                             data[i + 8] = args[2];
  489.                             data[i + 9] = args[3];
  490.                             return 6 + 2 * sizeof(ushort);
  491.                         })
  492.                     },
  493.                     { 0x0010, new MessageTag(0x08, 0x0010, 8 * sizeof(ushort), // Tan level jump. Goes from pale -> dark
  494.                         (_, __, args) => $"<Tan Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}] [{BitConverterBE.ToUInt16(args, 4):X4}] [{BitConverterBE.ToUInt16(args, 6):X4}] [{BitConverterBE.ToUInt16(args, 8):X4}] [{BitConverterBE.ToUInt16(args, 10):X4}] [{BitConverterBE.ToUInt16(args, 12):X4}] [{BitConverterBE.ToUInt16(args, 14):X4}]>",
  495.                         (group, index, args, i, data) => {
  496.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  497.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  498.                             data[i + 2] = 0x6 + 8 * sizeof(ushort);
  499.                             data[i + 3] = group;
  500.                             data[i + 4] = (byte)(index >> 8);
  501.                             data[i + 5] = (byte)index;
  502.  
  503.                             for (int x = 0; x < 8*sizeof(ushort); x += 2)
  504.                             {
  505.                                 data[i + 6 + x] = args[x];
  506.                                 data[i + 7 + x] = args[x + 1];
  507.                             }
  508.  
  509.                             return 6 + 8 * sizeof(ushort);
  510.                         })
  511.                     },
  512.                     // TODO: Determine 0x0011
  513.                     { 0x0012, new MessageTag(0x08, 0x0012, 4 * sizeof(ushort), // 0 = 1 player playing, 1 = 2 players playing, ...
  514.                         (_, __, args) => $"<Players in Town Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}] [{BitConverterBE.ToUInt16(args, 4):X4}] [{BitConverterBE.ToUInt16(args, 6):X4}]>",
  515.                         (group, index, args, i, data) => {
  516.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  517.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  518.                             data[i + 2] = 0x6 + 4 * sizeof(ushort);
  519.                             data[i + 3] = group;
  520.                             data[i + 4] = (byte)(index >> 8);
  521.                             data[i + 5] = (byte)index;
  522.                             data[i + 6] = args[0];
  523.                             data[i + 7] = args[1];
  524.                             data[i + 8] = args[2];
  525.                             data[i + 9] = args[3];
  526.                             data[i + 10] = args[4];
  527.                             data[i + 11] = args[5];
  528.                             data[i + 12] = args[6];
  529.                             data[i + 13] = args[7];
  530.                             return 6 + 4 * sizeof(ushort);
  531.                         })
  532.                     },
  533.                     { 0x00013, new MessageTag(0x08, 0x0013, 4 * sizeof(ushort), // Complete RNG Dialog
  534.                         (_, __, args) => $"<Random Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}] [{BitConverterBE.ToUInt16(args, 4):X4}] [{BitConverterBE.ToUInt16(args, 6):X4}]>",
  535.                         (group, index, args, i, data) => {
  536.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  537.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  538.                             data[i + 2] = 0x6 + 4 * sizeof(ushort);
  539.                             data[i + 3] = group;
  540.                             data[i + 4] = (byte)(index >> 8);
  541.                             data[i + 5] = (byte)index;
  542.  
  543.                             for (int x = 0; x < 4 * sizeof(ushort); x += 2)
  544.                             {
  545.                                 data[i + 6 + x] = args[x];
  546.                                 data[i + 7 + x] = args[x + 1];
  547.                             }
  548.  
  549.                             return 6 + 4 * sizeof(ushort);
  550.                         })
  551.                     },
  552.                     { 0x00014, new MessageTag(0x08, 0x0014, 5 * sizeof(ushort), // Complete RNG Dialog
  553.                         (_, __, args) => $"<Random Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}] [{BitConverterBE.ToUInt16(args, 4):X4}] [{BitConverterBE.ToUInt16(args, 6):X4}] [{BitConverterBE.ToUInt16(args, 8):X4}]>",
  554.                         (group, index, args, i, data) => {
  555.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  556.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  557.                             data[i + 2] = 0x6 + 5 * sizeof(ushort);
  558.                             data[i + 3] = group;
  559.                             data[i + 4] = (byte)(index >> 8);
  560.                             data[i + 5] = (byte)index;
  561.  
  562.                             for (int x = 0; x < 5 * sizeof(ushort); x += 2)
  563.                             {
  564.                                 data[i + 6 + x] = args[x];
  565.                                 data[i + 7 + x] = args[x + 1];
  566.                             }
  567.  
  568.                             return 6 + 5 * sizeof(ushort);
  569.                         })
  570.                     },
  571.                     { 0x00015, new MessageTag(0x08, 0x0015, 6 * sizeof(ushort), // Complete RNG Dialog
  572.                         (_, __, args) => $"<Random Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}] [{BitConverterBE.ToUInt16(args, 4):X4}] [{BitConverterBE.ToUInt16(args, 6):X4}] [{BitConverterBE.ToUInt16(args, 8):X4}] [{BitConverterBE.ToUInt16(args, 10):X4}]>",
  573.                         (group, index, args, i, data) => {
  574.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  575.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  576.                             data[i + 2] = 0x6 + 6 * sizeof(ushort);
  577.                             data[i + 3] = group;
  578.                             data[i + 4] = (byte)(index >> 8);
  579.                             data[i + 5] = (byte)index;
  580.  
  581.                             for (int x = 0; x < 6 * sizeof(ushort); x += 2)
  582.                             {
  583.                                 data[i + 6 + x] = args[x];
  584.                                 data[i + 7 + x] = args[x + 1];
  585.                             }
  586.  
  587.                             return 6 + 6 * sizeof(ushort);
  588.                         })
  589.                     },
  590.                     { 0x00016, new MessageTag(0x08, 0x0016, 7 * sizeof(ushort), // Complete RNG Dialog
  591.                         (_, __, args) => $"<Random Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}] [{BitConverterBE.ToUInt16(args, 4):X4}] [{BitConverterBE.ToUInt16(args, 6):X4}] [{BitConverterBE.ToUInt16(args, 8):X4}] [{BitConverterBE.ToUInt16(args, 10):X4}] [{BitConverterBE.ToUInt16(args, 12):X4}]>",
  592.                         (group, index, args, i, data) => {
  593.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  594.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  595.                             data[i + 2] = 0x6 + 7 * sizeof(ushort);
  596.                             data[i + 3] = group;
  597.                             data[i + 4] = (byte)(index >> 8);
  598.                             data[i + 5] = (byte)index;
  599.  
  600.                             for (int x = 0; x < 7 * sizeof(ushort); x += 2)
  601.                             {
  602.                                 data[i + 6 + x] = args[x];
  603.                                 data[i + 7 + x] = args[x + 1];
  604.                             }
  605.  
  606.                             return 6 + 7 * sizeof(ushort);
  607.                         })
  608.                     },
  609.                     { 0x00017, new MessageTag(0x08, 0x0017, 8 * sizeof(ushort), // Complete RNG Dialog
  610.                         (_, __, args) => $"<Random Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}] [{BitConverterBE.ToUInt16(args, 4):X4}] [{BitConverterBE.ToUInt16(args, 6):X4}] [{BitConverterBE.ToUInt16(args, 8):X4}] [{BitConverterBE.ToUInt16(args, 10):X4}] [{BitConverterBE.ToUInt16(args, 12):X4}] [{BitConverterBE.ToUInt16(args, 14):X4}]>",
  611.                         (group, index, args, i, data) => {
  612.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  613.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  614.                             data[i + 2] = 0x6 + 8 * sizeof(ushort);
  615.                             data[i + 3] = group;
  616.                             data[i + 4] = (byte)(index >> 8);
  617.                             data[i + 5] = (byte)index;
  618.  
  619.                             for (int x = 0; x < 8 * sizeof(ushort); x += 2)
  620.                             {
  621.                                 data[i + 6 + x] = args[x];
  622.                                 data[i + 7 + x] = args[x + 1];
  623.                             }
  624.  
  625.                             return 6 + 8 * sizeof(ushort);
  626.                         })
  627.                     },
  628.                     { 0x00018, new MessageTag(0x08, 0x0018, 4 * sizeof(ushort), // Spring, Summer, Fall, Winter
  629.                         (_, __, args) => $"<Seasonal Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}] [{BitConverterBE.ToUInt16(args, 4):X4}] [{BitConverterBE.ToUInt16(args, 6):X4}]>",
  630.                         (group, index, args, i, data) => {
  631.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  632.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  633.                             data[i + 2] = 0x6 + 4 * sizeof(ushort);
  634.                             data[i + 3] = group;
  635.                             data[i + 4] = (byte)(index >> 8);
  636.                             data[i + 5] = (byte)index;
  637.  
  638.                             for (int x = 0; x < 4 * sizeof(ushort); x += 2)
  639.                             {
  640.                                 data[i + 6 + x] = args[x];
  641.                                 data[i + 7 + x] = args[x + 1];
  642.                             }
  643.  
  644.                             return 6 + 4 * sizeof(ushort);
  645.                         })
  646.                     },
  647.                     { 0x00019, new MessageTag(0x08, 0x0019, 4 * sizeof(ushort), // Cranny, Nook 'n Go, Nookway, Nookington's
  648.                         (_, __, args) => $"<Nook Store Size Dialog Jump [{BitConverterBE.ToUInt16(args, 0):X4}] [{BitConverterBE.ToUInt16(args, 2):X4}] [{BitConverterBE.ToUInt16(args, 4):X4}] [{BitConverterBE.ToUInt16(args, 6):X4}]>",
  649.                         (group, index, args, i, data) => {
  650.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  651.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  652.                             data[i + 2] = 0x6 + 4 * sizeof(ushort);
  653.                             data[i + 3] = group;
  654.                             data[i + 4] = (byte)(index >> 8);
  655.                             data[i + 5] = (byte)index;
  656.  
  657.                             for (int x = 0; x < 4 * sizeof(ushort); x += 2)
  658.                             {
  659.                                 data[i + 6 + x] = args[x];
  660.                                 data[i + 7 + x] = args[x + 1];
  661.                             }
  662.  
  663.                             return 6 + 4 * sizeof(ushort);
  664.                         })
  665.                     },
  666.                 }
  667.             },
  668.  
  669.             // System
  670.             {
  671.                 0xFF, new Dictionary<ushort, MessageTag>
  672.                 {
  673.                     { 0x0000, new MessageTag(0xFF, 0x0000, 1 * sizeof(byte),
  674.                         (_, __, args) => $"<Text Color [{args[0]}]>",
  675.                         (group, index, args, i, data) => {
  676.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  677.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  678.                             data[i + 2] = 0x6 + 1 * sizeof(byte);
  679.                             data[i + 3] = group;
  680.                             data[i + 4] = (byte)(index >> 8);
  681.                             data[i + 5] = (byte)index;
  682.                             data[i + 6] = args[0];
  683.                             return 6 + 1 * sizeof(byte);
  684.                         })
  685.                     }, // The argument array is 2 bytes long, idk what the second byte is for yet.
  686.                     { 0x0001, new MessageTag(0xFF, 0x0001, 1 * sizeof(ushort),
  687.                         (_, __, args) => $"<Font Scale [{BitConverterBE.ToUInt16(args, 0)}]>",
  688.                         (group, index, args, i, data) => {
  689.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  690.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  691.                             data[i + 2] = 0x6 + 1 * sizeof(ushort);
  692.                             data[i + 3] = group;
  693.                             data[i + 4] = (byte)(index >> 8);
  694.                             data[i + 5] = (byte)index;
  695.                             data[i + 6] = args[0];
  696.                             data[i + 7] = args[1];
  697.                             return 6 + 1 * sizeof(ushort);
  698.                         })
  699.                     },
  700.                     // Converts Kanji into Kana form when Kanji is disabled. Args are: u8 numKanji wchar16_t kana[]
  701.                     { 0x0002, new MessageTag(0xFF, 0x0002, -1,
  702.                         (_, __, args) => $"<Kana [{args[0]:X2}] [{Encoding.BigEndianUnicode.GetString(args, 1, (args.Length & 1) == 0 ? args.Length - 2 : args.Length - 1)}]>",
  703.                         (group, index, args, i, data) => {
  704.                             data[i + 0] = WiiParser.TAG_CHARACTER >> 8;
  705.                             data[i + 1] = WiiParser.TAG_CHARACTER;
  706.                             data[i + 2] = (byte)(0x6 + args.Length);
  707.                             data[i + 3] = group;
  708.                             data[i + 4] = (byte)(index >> 8);
  709.                             data[i + 5] = (byte)index;
  710.                             Buffer.BlockCopy(args, 0, data, i + 6, args.Length);
  711.                             return 6 + 1 * sizeof(ushort);
  712.                         })
  713.                         {
  714.                             GetArgsSize = (data) => data.Length // first byte is the number of characters to replace
  715.                         }
  716.                     }
  717.                 }
  718.             }
  719.         };
  720.  
  721.         // TODO: Check for the first index
  722.         private static string GetStringMessage(byte group, ushort index, byte[] arguments = null) => $"<String {index}>";
  723.     }
  724. }
  725.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement