Esempio n. 1
0
        private static List <int> ReadMapObjects(byte[] Map, int Addr, int Count)
        {
            List <int> Objects = new List <int>();

            for (int i = 0; i < Count; i++)
            {
                Objects.Add(ReadWriteUtils.Arr_ReadU16(Map, Addr + (i * 2)));
            }
            return(Objects);
        }
Esempio n. 2
0
 private static Color[] ReadColours(int fileNumber, int addressInFile, int count)
 {
     Color[] colorArray = new Color[count];
     for (int i = 0; i < count; i++)
     {
         int    colorAddress = addressInFile + (i * 2);
         ushort rgba         = ReadWriteUtils.Arr_ReadU16(RomData.MMFileList[fileNumber].Data, colorAddress);
         colorArray[i] = ColorUtils.FromRGBA5551(rgba);
     }
     return(colorArray);
 }
Esempio n. 3
0
        private static void UpdateShop(ItemObject itemObject, List <MessageEntry> newMessages, MessageTable messageTable)
        {
            var location = itemObject.NewLocation.Value;

            var shopInventories = location.GetAttributes <ShopInventoryAttribute>();

            foreach (var shopInventory in shopInventories)
            {
                var messageId  = ReadWriteUtils.ReadU16(shopInventory.ShopItemAddress + 0x0A);
                var oldMessage = messageTable.GetMessage((ushort)(messageId + 1));
                var cost       = ReadWriteUtils.Arr_ReadU16(oldMessage.Header, 5);
                newMessages.Add(new MessageEntryBuilder()
                                .Id(messageId)
                                .Message(it =>
                {
                    it.Red(() =>
                    {
                        it.RuntimeItemName(itemObject.DisplayName(), location).Text(": ").Text(cost.ToString()).Text(" Rupees").NewLine();
                    })
                    .RuntimeWrap(() =>
                    {
                        it.RuntimeItemDescription(itemObject.DisplayItem, shopInventory.Keeper, location);
                    })
                    .DisableTextBoxClose()
                    .EndFinalTextBox();
                })
                                .Build()
                                );

                newMessages.Add(new MessageEntryBuilder()
                                .Id((ushort)(messageId + 1))
                                .Message(it =>
                {
                    it.RuntimeItemName(itemObject.DisplayName(), location).Text(": ").Text(cost.ToString()).Text(" Rupees").NewLine()
                    .Text(" ").NewLine()
                    .StartGreenText()
                    .TwoChoices()
                    .Text("I'll buy ").RuntimePronoun(itemObject.DisplayItem, location).NewLine()
                    .Text("No thanks")
                    .EndFinalTextBox();
                })
                                .Build()
                                );
            }
        }
Esempio n. 4
0
        private static List <Actor> ReadMapActors(byte[] Map, int Addr, int Count)
        {
            List <Actor> Actors = new List <Actor>();

            for (int i = 0; i < Count; i++)
            {
                Actor  a  = new Actor();
                ushort an = ReadWriteUtils.Arr_ReadU16(Map, Addr + (i * 16));
                a.m   = an & 0xF000;
                a.n   = an & 0x0FFF;
                a.p.x = (short)ReadWriteUtils.Arr_ReadU16(Map, Addr + (i * 16) + 2);
                a.p.y = (short)ReadWriteUtils.Arr_ReadU16(Map, Addr + (i * 16) + 4);
                a.p.z = (short)ReadWriteUtils.Arr_ReadU16(Map, Addr + (i * 16) + 6);
                a.r.x = (short)ReadWriteUtils.Arr_ReadU16(Map, Addr + (i * 16) + 8);
                a.r.y = (short)ReadWriteUtils.Arr_ReadU16(Map, Addr + (i * 16) + 10);
                a.r.z = (short)ReadWriteUtils.Arr_ReadU16(Map, Addr + (i * 16) + 12);
                a.v   = ReadWriteUtils.Arr_ReadU16(Map, Addr + (i * 16) + 14);
                Actors.Add(a);
            }
            return(Actors);
        }
Esempio n. 5
0
        public static void UpdateKafeiTunic(ref byte[] objectData, Color targetColor)
        {
            int[] kafeiPaletteAddress = new int[] { 0xB538, 0xDF68, 0xDF68, 0xD1B0 };
            int[] hairPaletteAvoid    = new int[] { 0, 4, 5, 6, 7, 9, 0xB, 0x14, 0x17, 0x18, 0x22, 0x23, 0x31, 0x32, 0x3E, 0x6B, 0x71, 0x8E, 0x100 };
            var   averageColour       = new Color();

            for (int i = 0; i < 4; i++)
            {
                var colourMask   = new bool[0x100];
                var coloursFound = new Color[0x100];
                var k            = 0;
                for (int j = 0; j < 0x100; j++)
                {
                    var thisColour = ColorUtils.FromRGBA5551(ReadWriteUtils.Arr_ReadU16(objectData, kafeiPaletteAddress[i] + (j << 1)));
                    // separate palette colours used for hair/clothes or they won't adjust very well
                    if (i == 1)
                    {
                        if (j == hairPaletteAvoid[k])
                        {
                            colourMask[j]   = true;
                            coloursFound[k] = thisColour;
                            k++;
                        }
                        ;
                    }
                    else if (i == 2)
                    {
                        if (j != hairPaletteAvoid[j - k])
                        {
                            colourMask[j]   = true;
                            coloursFound[k] = thisColour;
                            k++;
                        }
                        ;
                    }
                    else if ((thisColour.B != 0) && ((thisColour.G == 0) || ((i != 0) && (thisColour.B > thisColour.G) &&
                                                                             (thisColour.B > thisColour.R) && (thisColour.B + thisColour.R > 2.2 * thisColour.G))))
                    {
                        colourMask[j]   = true;
                        coloursFound[k] = thisColour;
                        k++;
                    }
                    ;
                }
                ;
                if (i != 1)
                {
                    averageColour = ColorUtils.GetAverageColour(coloursFound, k);
                }
                ;
                coloursFound = ShiftHue(coloursFound, targetColor, k, averageColour);
                k            = 0;
                for (int j = 0; j < 0x100; j++)
                {
                    if (colourMask[j])
                    {
                        ReadWriteUtils.Arr_WriteU16(objectData, kafeiPaletteAddress[i] + (j << 1), ColorUtils.ToRGBA5551(coloursFound[k]));
                        k++;
                    }
                }
            }
        }