Beispiel #1
0
        public void SaveEnemy(Enemy e)
        {
            gb.BufferLocation = e.baseLocation;
            gb.WriteByte(e.sprite);
            gb.WriteByte(e.vulnerable);
            gb.BufferLocation = e.subPointer + 1;
            gb.WriteByte(e.paletteFace);
            gb.BufferLocation -= 2;
            byte b = gb.ReadByte();

            b = (byte)(b * 2);
            gb.BufferLocation = 0xFDFB9 + b * 2;
            gb.WriteByte(e.collisionHeight);
            gb.WriteByte(e.collisionWidth);
            gb.WriteByte(e.damageDealt);
            gb.WriteByte(e.health);
            gb.BufferLocation = e.aiPointer;
            gb.WriteBytes(gb.Get2BytePointer(e.aiFinal));
        }
Beispiel #2
0
        public bool saveOverworldCollision(List <Object> objects, List <Warps> warps, byte map, byte floor, byte unknown, bool special, int usedspace, int freespace, bool s, int[] pointers, List <Int32> unSortedPointers)
        {
            int  cMapPointer;
            int  secondhalf;
            int  index;
            int  i = 0;
            bool check;

            if (s)
            {
                switch (map)
                {
                case 0x06: i = 0x31F4; break;

                case 0x0E: i = 0x31C4; break;

                case 0x1B: i = 0x3204; break;

                case 0x2B: i = 0x3214; break;

                case 0x79: i = 0x31E4; break;

                case 0x8C: i = 0x31D4; break;
                }
            }
            if (i > 0)
            {
                secondhalf = gb.Get2BytePointerAddress(i).Address + 1;
                if (map > 0x7F)
                {
                    secondhalf += 0x68000;
                }
                else
                {
                    secondhalf += 0x24000;
                }
            }
            else
            {
                secondhalf = 0x24000 + (map * 2);
                secondhalf = gb.Get2BytePointerAddress(secondhalf).Address + 1;
                if (map > 0x7F)
                {
                    secondhalf = 0x68000 + (secondhalf - 0x24000);
                }
            }
            cMapPointer       = secondhalf - 1;
            gb.BufferLocation = secondhalf;
            byte b = (byte)((unknown * 0x10) + floor);

            gb.WriteByte(b);
            foreach (Object obj in objects)
            {
                check = checkWrite(true, false);
                if (check != false)
                {
                    return(true);
                }
                if (obj.is3Byte)
                {
                    if (obj.direction == 8)
                    {
                        b = (byte)(0x80 + obj.length);
                        gb.WriteByte(b);
                        check = checkWrite(true, false);
                        if (check != false)
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        b = (byte)(0xC0 + obj.length);
                        gb.WriteByte(b);
                        check = checkWrite(true, false);
                        if (check != false)
                        {
                            return(true);
                        }
                    }
                    b = (byte)((obj.y * 0x10) + obj.x);
                    gb.WriteByte(b);
                    check = checkWrite(true, false);
                    if (check != false)
                    {
                        return(true);
                    }
                    gb.WriteByte(obj.id);
                    check = checkWrite(true, false);
                    if (check != false)
                    {
                        return(true);
                    }
                }
                else
                {
                    b = (byte)((obj.y * 0x10) + obj.x);
                    gb.WriteByte(b);
                    check = checkWrite(true, false);
                    if (check != false)
                    {
                        return(true);
                    }
                    gb.WriteByte(obj.id);
                    check = checkWrite(true, false);
                    if (check != false)
                    {
                        return(true);
                    }
                }
            }
            if (warps.Count != 0)
            {
                foreach (Warps warp in warps)
                {
                    check = checkWrite(true, false);
                    if (check != false)
                    {
                        return(true);
                    }
                    b = (byte)(0xE0 + warp.type);
                    gb.WriteByte(b);
                    check = checkWrite(true, false);
                    if (check != false)
                    {
                        return(true);
                    }
                    gb.WriteByte(warp.region);
                    check = checkWrite(true, false);
                    if (check != false)
                    {
                        return(true);
                    }
                    gb.WriteByte(warp.map);
                    check = checkWrite(true, false);
                    if (check != false)
                    {
                        return(true);
                    }
                    gb.WriteByte(warp.x);
                    check = checkWrite(true, false);
                    if (check != false)
                    {
                        return(true);
                    }
                    gb.WriteByte(warp.y);
                }
            }
            check = checkWrite(true, false);
            if (check != false)
            {
                return(true);
            }
            if (usedspace < freespace)
            {
                b = 0;
                gb.WriteByte(0xFE);
                usedspace += 1;
                while (usedspace != freespace)
                {
                    gb.WriteByte(b);
                    usedspace++;
                }
            }
            else if (usedspace > freespace && map != 0xFF)
            {
                gb.WriteByte(0xFE);
                byte[] bytes = gb.Get2BytePointer(gb.BufferLocation);
                gb.WriteByte(0);
                gb.WriteByte(0);
                index = Array.IndexOf(pointers, cMapPointer);
                int imaps  = 0;
                int index2 = 0;
                while (pointers[index + 1] == cMapPointer)
                {
                    index++;
                }
                index2      = index2 + index;
                cMapPointer = pointers[index2 + 1];
                while (pointers[index + 1] == cMapPointer)
                {
                    imaps++;
                    index++;
                }
                if (imaps != 1)
                {
                    int i2 = 0;
                    for (int imap = imaps; imap != 0; imap--)
                    {
                        index = unSortedPointers.IndexOf(cMapPointer);
                        gb.WriteBytes((0x24000 + ((index + i2) * 2)), bytes);
                        unSortedPointers.RemoveAt(index);
                        i2++;
                    }
                }
                else
                {
                    index = unSortedPointers.IndexOf(cMapPointer);
                    if (index > 255)
                    {
                        if (index == 256)
                        {
                            gb.BufferLocation = 0x31F4;
                        }
                        else if (index == 257)
                        {
                            gb.BufferLocation = 0x31C4;
                        }
                        else if (index == 258)
                        {
                            gb.BufferLocation = 0x3204;
                        }
                        else if (index == 259)
                        {
                            gb.BufferLocation = 0x3214;
                        }
                        else if (index == 260)
                        {
                            gb.BufferLocation = 0x31E4;
                        }
                        else if (index == 261)
                        {
                            gb.BufferLocation = 0x31D4;
                        }
                        gb.WriteBytes(bytes);
                    }
                    else
                    {
                        gb.WriteBytes((0x24000 + (index * 2)), bytes);
                    }
                }
            }
            return(false);
        }