public void DrawTileset(byte[] dst, Tile[] src)
        {
            ushort  tile;
            Subtile source;
            int     offset = 0;
            int     i      = 0;

            for (; i < src.Length; i++)
            {
                if (i > 0 && i % 8 == 0)
                {
                    offset += 32;
                }
                for (int z = 0; z < 2; z++)
                {
                    source = src[i].Subtiles[z];
                    tile   = (ushort)source.Index;
                    Bits.SetShort(dst, offset, tile); offset += 2;
                }
                offset += 28; // jump forward in buffer to grab correct 8x8 tiles
                for (int a = 2; a < 4; a++)
                {
                    source = src[i].Subtiles[a];
                    tile   = (ushort)source.Index;
                    Bits.SetShort(dst, offset, tile); offset += 2;
                }
                offset -= 32; // jump back in buffer so that we can start the next 16x16 tile
            }
        }
Esempio n. 2
0
 public static void SetBit(byte[] data, int offset, int bit, bool value)
 {
     try
     {
         if (bit < 8)
         {
             if (value)
             {
                 data[offset] |= (byte)(Math.Pow(2, bit));
             }
             else if (!value)
             {
                 data[offset] &= (byte)((byte)(Math.Pow(2, bit)) ^ 0xFF);
             }
         }
         else
         {
             ushort number = Bits.GetShort(data, offset);
             if (value)
             {
                 number |= (ushort)(Math.Pow(2, bit));
             }
             else
             {
                 number &= (ushort)((ushort)(Math.Pow(2, bit)) ^ 0xFFFF);
             }
             Bits.SetShort(data, offset, number);
         }
     }
     catch
     {
         ShowError(offset, data.Length);
         throw new Exception();
     }
 }
 public void Assemble(int offset)
 {
     Bits.SetShort(rom, offset++, destination);
     Bits.SetBit(rom, offset, 3, showMessage);
     if (exitType == 0)
     {
         Bits.SetBit(rom, offset, 5, true);
     }
     else if (exitType == 1)
     {
         Bits.SetBit(rom, offset, 6, true);
     }
     Bits.SetBit(rom, offset++, 7, width > 0);
     rom[offset] = x;
     Bits.SetBit(rom, offset++, 7, x_half);
     rom[offset] = y;
     Bits.SetBit(rom, offset++, 7, y_half);
     rom[offset] = z;
     Bits.SetBitsByByte(rom, offset++, (byte)(height << 5), true);
     if (exitType == 0)
     {
         rom[offset] = dstX;
         Bits.SetBit(rom, offset++, 7, dstXb7);
         rom[offset] = dstY;
         Bits.SetBit(rom, offset++, 7, dstYb7);
         rom[offset] = dstZ;
         Bits.SetBitsByByte(rom, offset++, (byte)(dstFace << 5), true);
     }
     if (width > 0)
     {
         rom[offset] = width;
         Bits.SetBitsByByte(rom, offset++, (byte)(f << 7), true);
     }
 }
Esempio n. 4
0
        public void Assemble(ref int offset)
        {
            if (index >= 0x0800)
            {
                Bits.SetShort(rom, 0x37E000 + index * 2, (ushort)(offset - 4));
            }
            else
            {
                Bits.SetShort(rom, 0x37E000 + index * 2, (ushort)(offset - 8));
            }
            int dlgOffset = 0;

            // Select bank to save to
            if (index >= 0x0C00)
            {
                dlgOffset = offset + 0x240000;
            }
            else if (index >= 0x0800)
            {
                dlgOffset = offset + 0x230000;
            }
            else
            {
                dlgOffset = offset + 0x220000;
            }
            Bits.SetChars(rom, dlgOffset, text);
            offset += text.Length;
        }
Esempio n. 5
0
 public void Assemble(ref int offset)
 {
     if (index == 0)
     {
         return;
     }
     //int offset = Bits.Get24Bit(data, index * 3 + 0x042748) - 0xC00000;
     Bits.SetInt24(rom, index * 3 + 0x42748, offset + 0xC00000);
     rom[offset++] = DelayTime;
     rom[offset++] = DecayFactor;
     rom[offset++] = Echo;
     foreach (SampleIndex sample in samples)
     {
         if (sample == null || !sample.Active)
         {
             continue;
         }
         rom[offset++] = (byte)sample.Sample;
         rom[offset++] = (byte)sample.Volume;
     }
     rom[offset++] = 0xFF;
     Bits.SetShort(rom, offset, Length); offset += 2;
     //
     AssembleSPCData();
     Bits.SetBytes(rom, offset, spcData);
     offset += spcData.Length;
 }
            // universal functions
            public void Assemble()
            {
                int offset = ((index - 2) * 2) + 0x3A1AFF;

                if (owner == 0)
                {
                    Bits.SetShort(rom, offset, expNeeded);
                }
                //
                offset = (owner * 3) + ((index - 2) * 15) + 0x3A1B39;
                Bits.SetByte(rom, offset, hpPlus); offset++;
                Bits.SetByte(rom, offset, (byte)((attackPlus << 4) + defensePlus)); offset++;
                Bits.SetByte(rom, offset, (byte)((mgAttackPlus << 4) + mgDefensePlus)); offset++;
                //
                offset = (owner * 3) + ((index - 2) * 15) + 0x3A1CEC;
                Bits.SetByte(rom, offset, hpPlusBonus); offset++;
                Bits.SetByte(rom, offset, (byte)((attackPlusBonus << 4) + defensePlusBonus)); offset++;
                Bits.SetByte(rom, offset, (byte)((mgAttackPlusBonus << 4) + mgDefensePlusBonus)); offset++;
                //
                if (spellLearned == 0x20)
                {
                    rom[owner + ((index - 2) * 5) + 0x3A42F5] = 0xFF;
                }
                else
                {
                    rom[owner + ((index - 2) * 5) + 0x3A42F5] = spellLearned;
                }
            }
Esempio n. 7
0
        public void Assemble()
        {
            int offset = index * 7 + 0x1DB800;

            //
            Bits.SetShort(rom, offset++, sprite);
            rom[offset]   |= (byte)(byte1a << 2);
            rom[offset++] |= (byte)(byte1b << 5);
            //
            Bits.SetBit(rom, offset, 5, priority0);
            Bits.SetBit(rom, offset, 6, priority1);
            Bits.SetBit(rom, offset, 7, priority2);
            Bits.SetBit(rom, offset, 0, b2b0);
            Bits.SetBit(rom, offset, 1, b2b1);
            Bits.SetBit(rom, offset, 2, b2b2);
            Bits.SetBit(rom, offset, 3, b2b3);
            Bits.SetBit(rom, offset++, 4, b2b4);
            //
            rom[offset] = yPixelShiftUp;
            Bits.SetBit(rom, offset, 4, shift16pxDown);
            rom[offset] &= 0x9F;
            rom[offset] |= (byte)(shadow << 5);
            Bits.SetBit(rom, offset++, 7, activeVRAM);
            //
            rom[offset]    = acuteAxis;
            rom[offset++] |= (byte)(obtuseAxis << 4);
            //
            rom[offset] = height;
            Bits.SetBit(rom, offset, 5, showShadow);
            Bits.SetBit(rom, offset, 6, b5b6);
            Bits.SetBit(rom, offset++, 7, b5b7);
            //
            Bits.SetBit(rom, offset, 2, b6b2);
        }
Esempio n. 8
0
        public void Assemble(ref int offsetStart)
        {
            int pointerOffset = (index * 2) + 0x20E000;

            Bits.SetShort(rom, pointerOffset, offsetStart);
            int offset = offsetStart + 0x200000;

            rom[offset++] = music;
            Bits.SetShort(rom, offset, entranceEvent); offset += 2;
            offsetStart = (ushort)(offset - 0x200000);
            // no exit fields for level
            if (events.Count == 0)
            {
                return;
            }
            //
            foreach (Event EVENT in events)
            {
                EVENT.Assemble(rom, offset);
                offset += 5;
                if (EVENT.Width > 0)
                {
                    offset++;
                }
            }
            offsetStart = (ushort)(offset - 0x200000);
        }
        public void Assemble(ref int offsetStart)
        {
            int offset        = 0;
            int pointerOffset = (index * 2) + 0x1D2D64;

            // set the new pointer for the fields
            Bits.SetShort(rom, pointerOffset, offsetStart);
            // no exit fields for level
            if (exits.Count == 0)
            {
                return;
            }
            offset = offsetStart + 0x1D0000;
            foreach (Exit exit in exits)
            {
                exit.Assemble(offset);
                offset += 5;
                if (exit.ExitType == 0)
                {
                    offset += 3;
                }
                if (exit.Width > 0)
                {
                    offset += 1;
                }
            }
            offsetStart = (ushort)(offset - 0x1D0000);
        }
Esempio n. 10
0
 public void Assemble(ref int offset)
 {
     Bits.SetShort(rom, pointerOffset + index * 2, offset);
     this.offset = offset + baseOffset;
     //
     Bits.SetChars(rom, this.offset, text);
     offset += text.Length;
 }
Esempio n. 11
0
        public void Assemble()
        {
            int offset = (index * 4) + 0x250000;

            Bits.SetShort(rom, offset, image); offset++;
            rom[offset] |= (byte)(paletteIndex << 1); offset++;
            Bits.SetShort(rom, offset, animationPacket);
        }
Esempio n. 12
0
        private void ImportTilemap(byte[] array, int layer, int offset)
        {
            if (!checkBox4.Checked || tilemap.Tilemaps_Tiles[layer] == null)
            {
                return;
            }
            int  counter = 0;
            int  extratiles = 256;
            bool mirror, invert;

            for (int i = 0; i < tilemap.Tilemaps_Tiles[layer].Length; i++)
            {
                int tile = Bits.GetShort(array, offset) & 0x1FF;
                mirror = Bits.GetBit(array, offset + 1, 6);
                invert = Bits.GetBit(array, offset + 1, 7);
                tilemap.Tilemaps_Tiles[layer][i] = tileset.Tilesets_tiles[layer][tile];
                if (layer != 2)
                {
                    Bits.SetShort(tilemap.Tilemaps_Bytes[layer], counter, tile);
                    counter += 2; offset += 2;
                }
                else
                {
                    tilemap.Tilemaps_Bytes[layer][counter] = (byte)tile;
                    counter++; offset += 2;
                }
                if (tileset.Tilesets_tiles[layer] == null || tileset.Tilesets_tiles[layer].Length != 512)
                {
                    continue;
                }
                if (mirror || invert)
                {
                    Tile copy = tileset.Tilesets_tiles[layer][tile].Copy();
                    if (mirror)
                    {
                        Do.FlipHorizontal(copy);
                    }
                    if (invert)
                    {
                        Do.FlipVertical(copy);
                    }
                    Tile contains = Do.Contains(tileset.Tilesets_tiles[layer], copy);
                    if (contains == null)
                    {
                        tileset.Tilesets_tiles[layer][extratiles]       = copy;
                        tileset.Tilesets_tiles[layer][extratiles].Index = extratiles;
                        tilemap.Tilemaps_Tiles[layer][i] = tileset.Tilesets_tiles[layer][extratiles];
                        Bits.SetShort(tilemap.Tilemaps_Bytes[layer], counter - 2, extratiles);
                        extratiles++;
                    }
                    else
                    {
                        tilemap.Tilemaps_Tiles[layer][i] = tileset.Tilesets_tiles[layer][contains.Index];
                        Bits.SetShort(tilemap.Tilemaps_Bytes[layer], counter - 2, contains.Index);
                    }
                }
            }
        }
Esempio n. 13
0
        // tooltips
        public void Assemble()
        {
            Model.ROM[0x037DCF] = (byte)this.music.SelectedIndex;
            //
            Model.Compress(Model.WorldMapLogos, 0x3E004C, 0x2000, 0xE1C, "World map logos, banners");
            //
            foreach (WorldMap wm in worldMaps)
            {
                wm.Assemble();
            }
            // Graphics
            Model.WorldMapLogoPalette.Assemble(Model.MenuPalettes, 0xE0);
            int offset  = Bits.GetShort(Model.ROM, 0x3E000C) + 0x3E0000;
            int maxComp = Bits.GetShort(Model.ROM, 0x3E000E) - Bits.GetShort(Model.ROM, 0x3E000C);

            Model.Compress(Model.MenuPalettes, offset, 0x200, maxComp, "World map logo palettes");
            Model.Compress(Model.WorldMapGraphics, 0x3E2E81, 0x8000, 0x56F6, "Graphics");
            //   Model.Compress(Model.WorldMapSprites, 0x3E90A7, 0x400, 0x1F8, "Sprite Graphics");
            // Tilesets
            byte[] compress  = new byte[0x800];
            int    totalSize = 0;
            int    pOffset   = 0x3E0014;
            int    dOffset   = 0x3E929F;
            int    size      = 0;

            for (int i = 0; i < Model.WorldMapTilesets.Length; i++)
            {
                Bits.SetShort(Model.ROM, pOffset, (ushort)dOffset);
                size       = Comp.Compress(Model.WorldMapTilesets[i], compress);
                totalSize += size + 1;
                if (totalSize > 0x4D8)
                {
                    MessageBox.Show(
                        "Recompressed tilesets exceed allotted ROM space by " + (totalSize - 0x4D6).ToString() + " bytes.\nSaving has been discontinued for tilesets " + i.ToString() + " and higher.\nChange or delete some tiles to reduce the size.",
                        "LAZY SHELL");
                    break;
                }
                else
                {
                    Model.ROM[dOffset] = 1; dOffset++;
                    Bits.SetBytes(Model.ROM, dOffset, compress, 0, size - 1);
                    dOffset += size;
                    pOffset += 2;
                }
            }
            Bits.SetShort(Model.ROM, pOffset, (ushort)dOffset);
            Model.Compress(Model.WorldMapLogoTileset, dOffset, 0x800, 0xC1, "World map logo tileset");
            // Palettes
            palettes.Assemble(Model.WorldMapPalettes, 0);
            Model.Compress(Model.WorldMapPalettes, 0x3E988C, 0x100, 0xD4, "Palette set");
            foreach (Location mp in locations)
            {
                mp.Assemble();
            }
            AssembleLocationTexts();
            this.Modified = false;
        }
Esempio n. 14
0
        public void Assemble(ref int pointer)
        {
            Bits.SetShort(rom, 0x249000 + index * 2, pointer);
            int offset = pointer + 0x249100;

            char[] raw = new char[text.Length + 1]; text.CopyTo(raw, 0);
            Bits.SetChars(rom, offset, raw);
            pointer += raw.Length;
        }
        // assemblers
        public void Assemble(int width, int height)
        {
            int offset = 0;

            for (int q = 0; q < 4; q++)
            {
                for (int y = 0; y < height; y++)
                {
                    for (int x = 0; x < width; x++)
                    {
                        Tile tile = tileset_tiles[(y * width + x) + (q * 256)];
                        if (tile == null)
                        {
                            continue;
                        }
                        for (int s = 0; s < 4; s++)
                        {
                            offset  = y * (width * 2 * 2 * 2) + (x * 2 * 2);
                            offset += (s % 2) * 2;
                            offset += (s / 2) * (width * 2 * 2);
                            offset += (q * 256) * 8;
                            Subtile subtile = tile.Subtiles[s];
                            if (subtile == null)
                            {
                                continue;
                            }
                            Bits.SetShort(tileset_bytes, offset, (ushort)subtile.Index);
                            tileset_bytes[offset + 1] |= (byte)(subtile.Palette << 2);
                            Bits.SetBit(tileset_bytes, offset + 1, 5, subtile.Priority1);
                            Bits.SetBit(tileset_bytes, offset + 1, 6, subtile.Mirror);
                            Bits.SetBit(tileset_bytes, offset + 1, 7, subtile.Invert);
                        }
                    }
                }
            }
            Model.EditTilesetsBF[battlefield.TileSet] = true;
            if (battlefield.GraphicSetA < 0xC8)
            {
                Buffer.BlockCopy(graphics, 0, Model.GraphicSets[battlefield.GraphicSetA + 0x48], 0, 0x2000);
            }
            if (battlefield.GraphicSetB < 0xC8)
            {
                Buffer.BlockCopy(graphics, 0x2000, Model.GraphicSets[battlefield.GraphicSetB + 0x48], 0, 0x1000);
            }
            if (battlefield.GraphicSetC < 0xC8)
            {
                Buffer.BlockCopy(graphics, 0x3000, Model.GraphicSets[battlefield.GraphicSetC + 0x48], 0, 0x1000);
            }
            if (battlefield.GraphicSetD < 0xC8)
            {
                Buffer.BlockCopy(graphics, 0x4000, Model.GraphicSets[battlefield.GraphicSetD + 0x48], 0, 0x1000);
            }
            if (battlefield.GraphicSetE < 0xC8)
            {
                Buffer.BlockCopy(graphics, 0x5000, Model.GraphicSets[battlefield.GraphicSetE + 0x48], 0, 0x1000);
            }
        }
Esempio n. 16
0
        public static byte[] BRRToWAV(byte[] inBrr, int rate, int loopStart)
        {
            if (inBrr == null)
            {
                inBrr = new byte[9];
            }
            p1 = 0; p2 = 0;
            short[] samples = new short[0];
            byte[]  BRR     = new byte[9];
            int     size    = (int)inBrr.Length;
            //if (size % 9 != 0)
            //{
            //    MessageBox.Show("Error : BRR file isn't a multiple of 9 bytes or is too big.");
            //    return null;
            //}
            int blockamount = size / 9;
            int offset      = 0;

            size = 0;
            for (int i = 0; i < blockamount; i++)
            {
                BRR     = Bits.GetBytes(inBrr, offset, 9); offset += 9;
                samples = append(samples, DecodeBRR(BRR));      //Append 16 BRR samples to existing array
                size   += 16;
            }
            //
            int position = loopStart / 9 * 16;

            if (position >= size)
            {
                position = 0;
            }
            size -= position;
            //
            byte[] outWav = new byte[(size << 1) + 44];
            offset = 0;
            Bits.SetChars(outWav, offset, "RIFF".ToCharArray()); offset     += 4;
            Bits.SetInt32(outWav, offset, (size << 1) + 36); offset         += 4;
            Bits.SetChars(outWav, offset, "WAVEfmt ".ToCharArray()); offset += 8;
            Bits.SetInt32(outWav, offset, 16); offset                   += 4;
            Bits.SetShort(outWav, offset, 1); offset                    += 2;
            Bits.SetShort(outWav, offset, 1); offset                    += 2;
            Bits.SetInt32(outWav, offset, rate); offset                 += 4;
            Bits.SetInt32(outWav, offset, rate * 2); offset             += 4;
            Bits.SetShort(outWav, offset, 2); offset                    += 2;
            Bits.SetShort(outWav, offset, 16); offset                   += 2;
            Bits.SetChars(outWav, offset, "data".ToCharArray()); offset += 4;
            Bits.SetInt32(outWav, offset, size << 1); offset            += 4;
            //
            for (int i = position; i < size + position; i++)
            {
                Bits.SetShort(outWav, offset, samples[i]);
                offset += 2;
            }
            return(outWav);
        }
        public void Assemble(ref int offset)
        {
            int pointerOffset = (index * 2) + 0x1D5EBD;

            Bits.SetShort(rom, pointerOffset, (ushort)offset);
            foreach (Mod mod in mods)
            {
                mod.Assemble(ref offset);
            }
        }
        public void Assemble()
        {
            int    offset  = (index * 4) + 0x251800;
            byte   bank    = (byte)((graphicOffset - 0x280000) >> 16);
            ushort pointer = (ushort)(graphicOffset & 0xFFF0);

            Bits.SetShort(rom, offset, pointer);
            rom[offset] |= bank; offset += 2;
            //
            Bits.SetShort(rom, offset, (ushort)(paletteNum * 30 + 0x3000));
        }
Esempio n. 19
0
            public override void SetTileNum(int tilenum, int layer, int x, int y)
            {
                int offset = 0x41 * (y / 2);

                if (y % 2 != 0)
                {
                    offset += 0x21;
                }
                offset += x;
                offset *= 2;
                Bits.SetShort(tilemap_Bytes, offset, (ushort)tilenum);
            }
Esempio n. 20
0
        public void AssembleSPCData()
        {
            int offset = 0;

            spcData = new byte[percussives.Count * 5 + 1];
            foreach (Percussives percussive in percussives)
            {
                spcData[offset++] = (byte)percussive.PitchIndex;
                spcData[offset++] = percussive.Sample;
                spcData[offset++] = percussive.Pitch;
                spcData[offset++] = percussive.Volume;
                spcData[offset++] = percussive.Balance;
            }
            spcData[offset++] = 0xFF;
            int spcOffset = offset + 16;
            int length    = spcOffset;

            for (int i = 0; i < channels.Length; i++)
            {
                if (activeChannels[i] && channels[i] != null)
                {
                    foreach (SPCCommand ssc in channels[i])
                    {
                        length += ssc.Length;
                    }
                }
            }
            this.Length = length;
            Array.Resize <byte>(ref spcData, length);
            for (int i = 0; i < 8; i++)
            {
                if (activeChannels[i] && channels[i] != null)
                {
                    Bits.SetShort(spcData, offset, spcOffset + 0x2000);
                }
                else
                {
                    Bits.SetShort(spcData, offset, 0);
                }
                offset += 2;
                if (!activeChannels[i] || channels[i] == null)
                {
                    continue;
                }
                foreach (SPCCommand ssc in channels[i])
                {
                    Bits.SetBytes(spcData, spcOffset, ssc.CommandData);
                    spcOffset += ssc.Length;
                }
            }
        }
Esempio n. 21
0
 public void Assemble()
 {
     for (int i = 0; i < count; i++)
     {
         for (int a = (32 - length) / 2; a < size; a++)
         {
             int    r     = reds[i * size + a] / 8;
             int    g     = greens[i * size + a] / 8;
             int    b     = blues[i * size + a] / 8;
             ushort color = (ushort)((b << 10) | (g << 5) | r);
             Bits.SetShort(buffer, (i * length) + (a * 2) + offset, color);
         }
     }
 }
Esempio n. 22
0
        public void Assemble()
        {
            int offset = (index * 20) + 0x3A002C;

            //
            rom[offset++] = startingLevel;
            Bits.SetShort(rom, offset, startingCurrentHP); offset += 2;
            Bits.SetShort(rom, offset, startingMaxHP); offset     += 2;
            rom[offset++] = startingSpeed;
            rom[offset++] = startingAttack;
            rom[offset++] = startingDefense;
            rom[offset++] = startingMgAttack;
            rom[offset++] = startingMgDefense;
            Bits.SetShort(rom, offset, startingExperience); offset += 2;
            rom[offset++] = startingWeapon;
            rom[offset++] = startingArmor;
            Bits.SetByte(rom, offset, startingAccessory); offset += 2;
            //
            int a = 0;

            for (int o = 0; o < 4; o++, offset++)
            {
                for (int i = 0; i < 8; i++)
                {
                    Bits.SetBit(rom, offset, i, startingMagic[a++]);
                }
            }
            //
            foreach (LevelUp l in levels)
            {
                if (l != null)
                {
                    l.Assemble();
                }
            }
            if (index == 0)
            {
                Bits.SetShort(rom, 0x3A00DB, startingCoins);
                rom[0x3A00DD] = startingCurrentFP;
                rom[0x3A00DE] = startingMaximumFP;
                Bits.SetShort(rom, 0x3A00DF, startingFrogCoins);
                //
                rom[0x02C9B3] = defenseStartL1;
                rom[0x02C9B9] = defenseStartL2;
                rom[0x02C9BF] = defenseEndL2;
                rom[0x02C9C5] = defenseEndL1;
            }
            Bits.SetChars(rom, 0x3a134d + (index * 10), name);
        }
Esempio n. 23
0
        private void Assemble()
        {
            int offset = 0;

            byte[]    temp         = new byte[0x700];
            MenuTexts lastMenuText = null;

            foreach (MenuTexts menuText in Model.MenuTexts)
            {
                if (lastMenuText != null && menuText.Length != 0 && Bits.Compare(menuText.Text, lastMenuText.Text))
                {
                    Bits.SetShort(Model.ROM, menuText.Index * 2 + 0x3EEF00, lastMenuText.Offset);
                    menuText.Offset = lastMenuText.Offset;
                    continue;
                }
                if (offset + menuText.Length + 1 >= 0x700)
                {
                    MessageBox.Show("Menu texts exceed allotted ROM space. Stopped saving at index " + menuText.Index + ".");
                    break;
                }
                menuText.Offset = offset;
                lastMenuText    = menuText;
                //
                Bits.SetShort(Model.ROM, menuText.Index * 2 + 0x3EEF00, offset);
                Bits.SetChars(temp, offset, menuText.Text);
                offset        += menuText.Length;
                temp[offset++] = 0;
                switch (menuText.Index)
                {
                case 14: Bits.SetByteBits(Model.ROM, 0x03328E, (byte)(menuText.X * 2), 0x3F); break;

                case 15: Bits.SetByteBits(Model.ROM, 0x03327E, (byte)(menuText.X * 2), 0x3F); break;

                case 16: Bits.SetByteBits(Model.ROM, 0x033282, (byte)(menuText.X * 2), 0x3F); break;

                case 17: Bits.SetByteBits(Model.ROM, 0x033286, (byte)(menuText.X * 2), 0x3F); break;

                case 18: Bits.SetByteBits(Model.ROM, 0x03328A, (byte)(menuText.X * 2), 0x3F); break;

                case 19: Bits.SetByteBits(Model.ROM, 0x03327A, (byte)(menuText.X * 2), 0x3F); break;
                }
            }
            Bits.SetBytes(Model.ROM, 0x3EF000, temp);
            //Bits.SetShort(Model.Data, 0x3EF600, 0x344F);
            menus.Assemble();
            menus.Modified = false;
            this.Modified  = false;
        }
Esempio n. 24
0
 public void Assemble(byte[] data, int offset)
 {
     Bits.SetShort(data, offset, runEvent); offset++;
     Bits.SetBit(data, offset, 7, width > 0); offset++;
     data[offset] = x;
     Bits.SetBit(data, offset, 7, x_half); offset++;
     data[offset] = y;
     Bits.SetBit(data, offset, 7, y_half); offset++;
     data[offset] = z;
     Bits.SetBitsByByte(data, offset, (byte)(height << 5), true); offset++;
     if (width > 0)
     {
         data[offset] = width;
         Bits.SetBitsByByte(data, offset, (byte)(f << 7), true); offset++;
     }
 }
Esempio n. 25
0
 public void Assemble(ref int offset)
 {
     if (sample == null)
     {
         Bits.SetInt24(rom, index * 3 + 0x042333, 0);
         return;
     }
     Bits.SetInt24(rom, index * 3 + 0x042333, offset + 0xC00000);
     Bits.SetShort(rom, offset, sample.Length); offset += 2;
     Bits.SetBytes(rom, offset, sample);
     offset += sample.Length;
     //
     Bits.SetShort(rom, index * 2 + 0x04248F, loopStart);
     Bits.SetShort(rom, index * 2 + 0x042577, relGain);
     Bits.SetShort(rom, index * 2 + 0x04265F, relFreq);
 }
Esempio n. 26
0
 public void Assemble(ref int offset)
 {
     Bits.SetShort(Model.ROM, Index * 2 + 0x02F967, offset);
     Model.ROM[0x020000 + offset++] = (byte)Text.Length;
     foreach (char letter in Text)
     {
         int index = Lists.IndexOf(Lists.KeystrokesBonus, letter.ToString());
         if (index >= 0 || index <= 31)
         {
             Model.ROM[0x020000 + offset++] = (byte)index;
         }
         else
         {
             Model.ROM[0x020000 + offset++] = 0x1F;
         }
     }
 }
Esempio n. 27
0
 private void ExportTilemap(byte[] array, int layer, int offset)
 {
     if (checkBox4.Checked && tilemap.Tilemaps_Tiles.Length >= 1 && tilemap.Tilemaps_Tiles[layer] != null)
     {
         foreach (Tile tile in tilemap.Tilemaps_Tiles[layer])
         {
             if (tile == null)
             {
                 offset += 2;
                 continue;
             }
             Bits.SetShort(array, offset, tile.Index); offset++;
             Bits.SetBit(array, offset, 6, tile.Mirror);
             Bits.SetBit(array, offset, 7, tile.Invert); offset++;
         }
     }
 }
Esempio n. 28
0
        public void DrawTileset(Tile[] src, byte[] dst)
        {
            ushort  tilenum = 0;
            Subtile subtile;
            int     offset = 0;

            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < 16; x++)
                {
                    int index = y * Width + x;
                    if (index >= src.Length)
                    {
                        continue;
                    }
                    for (int z = 0; z < 4; z++)
                    {
                        if (z == 2)
                        {
                            offset += tilesize * 30;
                        }
                        subtile = src[index].Subtiles[z];
                        if (tilesize == 2)
                        {
                            tilenum = (ushort)subtile.Index;
                            Bits.SetShort(dst, offset, tilenum); offset++;
                            dst[offset] |= (byte)(subtile.Palette << 2);
                            Bits.SetBit(dst, offset, 5, subtile.Priority1);
                            Bits.SetBit(dst, offset, 6, subtile.Mirror);
                            Bits.SetBit(dst, offset, 7, subtile.Invert); offset++;
                        }
                        else
                        {
                            tilenum = (byte)subtile.Index;
                            subtile_bytes[offset++] = (byte)tilenum;
                            palette_bytes[tilenum]  = (byte)subtile.Palette;
                        }
                    }
                    if (x < 15)
                    {
                        offset -= tilesize * 32;
                    }
                }
            }
        }
Esempio n. 29
0
        public void Assemble()
        {
            int offset = index * 5 + 0x1DB000;

            //
            rom[offset]    = sprite;
            rom[offset++] |= (byte)(b0 << 6);
            rom[offset]    = b1a;
            rom[offset]   |= (byte)(b1b << 3);
            rom[offset++] |= (byte)(b1c << 5);
            Bits.SetBit(rom, offset, 2, b2b2);
            Bits.SetBit(rom, offset, 3, b2b3);
            Bits.SetBit(rom, offset, 4, b2b4);
            Bits.SetBit(rom, offset, 5, showShadow);
            rom[offset++] |= (byte)(b2 << 6);
            Bits.SetShort(rom, offset++, action);
            rom[offset] |= (byte)(b4 << 4);
        }
Esempio n. 30
0
        public void Assemble(ref int offsetStart)
        {
            int pointerOffset = (index * 2) + 0x148000;

            Bits.SetShort(rom, pointerOffset, offsetStart);
            if (npcs.Count == 0)
            {
                return;
            }
            int offset = offsetStart + 0x140000;

            rom[offset++] = partition;
            foreach (NPC npc in npcs)
            {
                npc.Assemble(ref offset);
            }
            offsetStart = (ushort)(offset - 0x140000);
        }