public void Assemble()
        {
            int offset = index * 4 + 0x1DDE00;

            //
            rom[offset]  = 0;
            rom[offset]  = (byte)(allySpriteBuffer << 5);
            rom[offset] |= extraSpriteBuffer;
            Bits.SetBit(rom, offset, 4, extraSprites);
            Bits.SetBit(rom, offset, 7, fullPaletteBuffer);
            offset++;
            //
            rom[offset]  = cloneAsprite;
            rom[offset] |= (byte)(cloneAmain << 4);
            Bits.SetBit(rom, offset, 7, cloneAindexing);
            offset++;
            //
            rom[offset]  = cloneBsprite;
            rom[offset] |= (byte)(cloneBmain << 4);
            Bits.SetBit(rom, offset, 7, cloneBindexing);
            offset++;
            //
            rom[offset]  = cloneCsprite;
            rom[offset] |= (byte)(cloneCmain << 4);
            Bits.SetBit(rom, offset, 7, cloneCindexing);
            offset++;
        }
Example #2
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);
        }
Example #3
0
        public void Assemble()
        {
            Bits.SetChars(rom, 0x3959F4 + (index * 13), name);
            //
            int offset = (index * 4) + 0x391226;

            rom[offset] = attackLevel;
            Bits.SetBit(rom, offset, 3, instantDeath);
            Bits.SetBit(rom, offset, 4, noDamageA);
            Bits.SetBit(rom, offset, 5, hideDigits);
            Bits.SetBit(rom, offset++, 6, noDamageB);
            //
            rom[offset++] = hitRate;
            Bits.SetBit(rom, offset, 0, effectMute);
            Bits.SetBit(rom, offset, 1, effectSleep);
            Bits.SetBit(rom, offset, 2, effectPoison);
            Bits.SetBit(rom, offset, 3, effectFear);
            Bits.SetBit(rom, offset, 5, effectMushroom);
            Bits.SetBit(rom, offset, 6, effectScarecrow);
            Bits.SetBit(rom, offset++, 7, effectInvincible);
            //
            Bits.SetBit(rom, offset, 3, upMagicAttack);
            Bits.SetBit(rom, offset, 4, upAttack);
            Bits.SetBit(rom, offset, 5, upMagicDefense);
            Bits.SetBit(rom, offset, 6, upDefense);
        }
Example #4
0
 public void Assemble()
 {
     fontPalettesDialogue.Assemble();
     fontPalettesMenu.Assemble();
     Bits.SetBit(Model.ROM, 0x3E2D6C, 7, true);
     Bits.SetBit(Model.ROM, 0x3E2D74, 7, true);
     foreach (FontCharacter f in fontMenu)
     {
         f.Assemble();
     }
     foreach (FontCharacter f in fontDialogue)
     {
         f.Assemble();
     }
     foreach (FontCharacter f in fontDescription)
     {
         f.Assemble();
     }
     foreach (FontCharacter f in fontTriangle)
     {
         f.Assemble();
     }
     Bits.SetBytes(rom, 0x3DF000, Model.DialogueGraphics, 0, 0x700);
     Bits.SetBytes(rom, 0x015943, Model.BattleDialogueTileset_bytes, 0, 0x100);
     //
     Bits.SetBytes(rom, 0x03F800, Model.NumeralGraphics, 0, 0x400);
     Model.NumeralPaletteSet.Assemble();
     Buffer.BlockCopy(Model.BattleMenuGraphics, 0, rom, 0x1F200, 0x600);
     Buffer.BlockCopy(Model.BattleMenuGraphics, 0x600, rom, 0x1ED00, 0x140);
     Model.BattleMenuPalette.Assemble();
 }
 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);
     }
 }
        // 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);
            }
        }
        public void Assemble()
        {
            int offset = (index * 6) + 0x3DC000;

            //
            rom[offset] = baseTileHeight;
            Bits.SetBit(rom, offset, 4, conveyorBeltFast);
            Bits.SetBit(rom, offset, 5, conveyorBeltNormal);
            Bits.SetBit(rom, offset, 6, baseTileHeight_Half);
            Bits.SetBit(rom, offset++, 7, solidTile);
            //
            rom[offset] = overheadTileZ;
            Bits.SetBit(rom, offset, 4, solidEdgeNW);
            Bits.SetBit(rom, offset, 5, solidEdgeNE);
            Bits.SetBit(rom, offset, 6, solidEdgeSW);
            Bits.SetBit(rom, offset, 7, solidEdgeSE);
            if (conveyorBeltFast || conveyorBeltNormal)
            {
                rom[offset] = (byte)(converyorBeltDirection << 4);
            }
            offset++;
            rom[offset] = overheadTileHeight;
            switch (stairsDirection)
            {
            case 1: rom[offset] |= 0x90; break;

            case 2: rom[offset] |= 0xB0; break;
            }
            offset++;
            Bits.SetBit(rom, offset, 0, solidQuadN);
            Bits.SetBit(rom, offset, 1, solidQuadW);
            Bits.SetBit(rom, offset, 2, solidQuadE);
            Bits.SetBit(rom, offset, 3, solidQuadS);
            Bits.SetBit(rom, offset, 4, p3objectOnEdge);
            Bits.SetBit(rom, offset, 5, p3objectAboveEdge);
            Bits.SetBit(rom, offset, 6, p3objectOnTile);
            Bits.SetBit(rom, offset++, 7, solidQuadrantFlag);
            //
            rom[offset] = waterTileZ;
            if (specialTileFormat == 1)
            {
                rom[offset] |= 0x10;
            }
            else if (specialTileFormat == 2)
            {
                rom[offset] |= 0x80;
            }
            offset++;
            rom[offset] = (byte)(door << 5);
            Bits.SetBit(rom, offset, 0, b5b0);
            Bits.SetBit(rom, offset, 1, b5b1);
            Bits.SetBit(rom, offset, 2, b5b2);
            Bits.SetBit(rom, offset, 3, b5b3);
            Bits.SetBit(rom, offset, 4, b5b4);
        }
        public void Assemble()
        {
            int offset = (index * 4) + 0x39222A;

            rom[offset++] = (byte)formations[0];
            rom[offset++] = (byte)formations[1];
            rom[offset++] = (byte)formations[2];
            Bits.SetBit(rom, offset, 0, formations[0] >= 0x100);
            Bits.SetBit(rom, offset, 1, formations[1] >= 0x100);
            Bits.SetBit(rom, offset, 2, formations[2] >= 0x100);
        }
Example #9
0
 public void Assemble(int offset)
 {
     rom[offset] = x;
     Bits.SetBit(rom, offset++, 7, b0b7);
     rom[offset] = y;
     Bits.SetBit(rom, offset++, 7, b1b7);
     rom[offset] = z;
     Bits.SetBit(rom, offset, 5, b2b5);
     Bits.SetBit(rom, offset, 6, b2b6);
     Bits.SetBit(rom, offset++, 7, b2b7);
     rom[offset] = type;
 }
        public void Assemble()
        {
            int offset = (index * 0x1A) + 0x39C000;

            Bits.SetBit(rom, offset, 7, use[0]);
            Bits.SetBit(rom, offset, 6, use[1]);
            Bits.SetBit(rom, offset, 5, use[2]);
            Bits.SetBit(rom, offset, 4, use[3]);
            Bits.SetBit(rom, offset, 3, use[4]);
            Bits.SetBit(rom, offset, 2, use[5]);
            Bits.SetBit(rom, offset, 1, use[6]);
            Bits.SetBit(rom, offset++, 0, use[7]);
            //
            Bits.SetBit(rom, offset, 7, hide[0]);
            Bits.SetBit(rom, offset, 6, hide[1]);
            Bits.SetBit(rom, offset, 5, hide[2]);
            Bits.SetBit(rom, offset, 4, hide[3]);
            Bits.SetBit(rom, offset, 3, hide[4]);
            Bits.SetBit(rom, offset, 2, hide[5]);
            Bits.SetBit(rom, offset, 1, hide[6]);
            Bits.SetBit(rom, offset++, 0, hide[7]);
            //
            for (int i = 0; i < 8; i++)
            {
                rom[offset++] = monsters[i];
                rom[offset++] = x[i];
                rom[offset++] = y[i];
            }
            //
            offset        = (index * 3) + 0x392AAA;
            rom[offset++] = unknown;
            if (battleEvent == 102)
            {
                rom[offset++] = 0xff;
            }
            else
            {
                rom[offset++] = battleEvent;
            }
            if (music == 8)
            {
                rom[offset] = 0xC0;
            }
            else
            {
                rom[offset] = (byte)(music << 2);
            }
            Bits.SetBitsByByte(rom, offset++, 0x03, cantRun);
        }
        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);
        }
Example #12
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++;
     }
 }
Example #13
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++;
         }
     }
 }
Example #14
0
        public void Assemble()
        {
            int offset = (index * 16) + 0x3A44DF;

            Bits.SetBit(rom, offset, 0, buyFrogCoinOne);
            Bits.SetBit(rom, offset, 1, buyFrogCoin);
            Bits.SetBit(rom, offset, 2, buyOnlyA);
            Bits.SetBit(rom, offset, 3, buyOnlyB);
            Bits.SetBit(rom, offset, 4, discount6);
            Bits.SetBit(rom, offset, 5, discount12);
            Bits.SetBit(rom, offset, 6, discount25);
            Bits.SetBit(rom, offset++, 7, discount50);
            for (int i = 0; i < 15; i++)
            {
                rom[offset++] = items[i];
            }
        }
Example #15
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;
                    }
                }
            }
        }
Example #16
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);
        }
        public void Invert(int[] palette)
        {
            int maxY = GetBottomMostPixel(palette);
            int maxX = GetRightMostPixel(palette);
            int minY = GetTopMostPixel(palette);
            int minX = GetLeftMostPixel(palette);

            for (int x = minX; x < maxX + 1; x++)
            {
                for (int a = minY, b = maxY; a < b; a++, b--)
                {
                    byte rowA    = (byte)a;
                    byte colA    = (byte)x;
                    byte bitA    = (byte)((colA & 7) ^ 7);
                    int  offsetA = rowA * 2;
                    byte rowB    = (byte)b;
                    byte colB    = (byte)x;
                    byte bitB    = (byte)((colB & 7) ^ 7);
                    int  offsetB = rowB * 2;
                    switch (Type)
                    {
                    case FontType.Menu:
                    case FontType.Description:
                        bool tempM = Bits.GetBit(Graphics, offsetA, bitA);
                        bool tempN = Bits.GetBit(Graphics, offsetA + 1, bitA);
                        Bits.SetBit(Graphics, offsetA, bitA, Bits.GetBit(Graphics, offsetB, bitB));
                        Bits.SetBit(Graphics, offsetA + 1, bitA, Bits.GetBit(Graphics, offsetB + 1, bitB));
                        Bits.SetBit(Graphics, offsetB, bitB, tempM);
                        Bits.SetBit(Graphics, offsetB + 1, bitB, tempN);
                        break;

                    case FontType.Dialogue:
                        offsetA += colA >= 8 ? 24 : 0;
                        offsetB += colB >= 8 ? 24 : 0;
                        goto case 0;

                    case FontType.Triangles:
                        offsetA += colA >= 8 ? 16 : 0;
                        offsetB += colB >= 8 ? 16 : 0;
                        goto case 0;
                    }
                }
            }
        }
Example #18
0
 private void ExportTileset(byte[] array, int layer, int offset)
 {
     if (checkBox3.Checked && tileset.Tilesets_tiles.Length >= layer + 1 && tileset.Tilesets_tiles[layer] != null)
     {
         foreach (Tile tile in tileset.Tilesets_tiles[layer])
         {
             foreach (Subtile subtile in tile.Subtiles)
             {
                 Bits.SetShort(array, offset, subtile.Index);
                 offset       += 2;
                 array[offset] = (byte)subtile.Palette;
                 Bits.SetBit(array, offset, 5, subtile.Priority1);
                 Bits.SetBit(array, offset, 6, subtile.Mirror);
                 Bits.SetBit(array, offset, 7, subtile.Invert);
                 offset++;
             }
         }
     }
 }
        public void Assemble()
        {
            int offset = (index * 15) + 0x1D2440;

            rom[offset++] = graphicSetA;
            rom[offset++] = graphicSetB;
            rom[offset++] = graphicSetC;
            rom[offset++] = graphicSetD;
            rom[offset++] = graphicSetE;
            rom[offset++] = tilesetL1;
            //
            rom[offset] = tilesetL2;
            Bits.SetBit(rom, offset++, 7, topPriorityL3);
            //
            rom[offset++] = tilemapL1;
            rom[offset++] = tilemapL2;
            rom[offset++] = solidityMap;
            rom[offset++] = paletteSet;
            rom[offset++] = graphicSetL3;
            rom[offset++] = tilesetL3;
            rom[offset++] = (byte)(tilemapL3 + 0x40);
            rom[offset]   = battlefield;
        }
 public void Assemble(ref int offset, int engageType)
 {
     rom[offset] = propertyA;
     if (engageType == 0)
     {
         Bits.SetBitsByByte(rom, offset, (byte)(propertyB << 5), true);
     }
     else if (engageType == 2)
     {
         Bits.SetBitsByByte(rom, offset, (byte)(propertyB << 4), true);
     }
     if (engageType == 0)
     {
         Bits.SetBitsByByte(rom, offset, (byte)(propertyC << 3), true);
     }
     offset++;
     //
     rom[offset] = x;
     Bits.SetBit(rom, offset, 7, xb7); offset++;
     rom[offset] = y;
     Bits.SetBit(rom, offset, 7, yb7); offset++;
     rom[offset] = z;
     Bits.SetBitsByByte(rom, offset, (byte)(f << 5), true); offset++;
 }
Example #21
0
 public void Assemble(byte[] data, ref int offset)
 {
     data[offset] = (byte)this.x;
     Bits.SetBit(data, offset++, 7, b0b7);
     data[offset] = (byte)this.y;
     Bits.SetBit(data, offset++, 7, width == 1 && height == 1);
     if (!(width == 1 && height == 1))
     {
         data[offset]    = (byte)(width - 1);
         data[offset++] |= (byte)((height - 1) << 4);
     }
     for (int i = 0, c = 0; c < (width * height) * 2; i++)
     {
         if (i % 5 == 0)
         {
             data[offset++] = 0;
         }
         else
         {
             data[offset]              = tiles[c++];
             data[offset++ - (i % 5)] |= (byte)(tiles[c++] << (((i % 5) - 1) * 2));
         }
     }
 }
        public void DrawTileset(Tile[] src, byte[] dst)
        {
            ushort  tile;
            Subtile source;
            int     offset = 0;

            for (int i = 0; i < src.Length; i++)
            {
                for (int z = 0; z < 2; z++)
                {
                    source = src[i].Subtiles[z];
                    tile   = (ushort)source.Index;
                    Bits.SetShort(dst, offset, tile); offset++;
                    dst[offset] |= (byte)(source.Palette << 2);
                    Bits.SetBit(dst, offset, 5, source.Priority1);
                    Bits.SetBit(dst, offset, 6, source.Mirror);
                    Bits.SetBit(dst, offset, 7, source.Invert); offset++;
                }
                offset += 60; // 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++;
                    dst[offset] |= (byte)(source.Palette << 2);
                    Bits.SetBit(dst, offset, 5, source.Priority1);
                    Bits.SetBit(dst, offset, 6, source.Mirror);
                    Bits.SetBit(dst, offset, 7, source.Invert); offset++;
                }
                if ((i - 15) % 16 == 0)
                {
                    offset += 64;
                }
                offset -= 64; // jump back in buffer so that we can start the next 16x16 tile
            }
        }
Example #23
0
        public void Assemble()
        {
            int offset = (index * 3) + 0x1D0000;

            Bits.SetBit(rom, offset, 0, mainscreenL1);
            Bits.SetBit(rom, offset, 1, mainscreenL2);
            Bits.SetBit(rom, offset, 2, mainscreenL3);
            Bits.SetBit(rom, offset, 4, mainscreenOBJ);
            offset++;
            Bits.SetBit(rom, offset, 0, subscreenL1);
            Bits.SetBit(rom, offset, 1, subscreenL2);
            Bits.SetBit(rom, offset, 2, subscreenL3);
            Bits.SetBit(rom, offset, 4, subscreenOBJ);
            offset++;
            Bits.SetBit(rom, offset, 0, colorMathL1);
            Bits.SetBit(rom, offset, 1, colorMathL2);
            Bits.SetBit(rom, offset, 2, colorMathL3);
            Bits.SetBit(rom, offset, 4, colorMathOBJ);
            Bits.SetBit(rom, offset, 5, colorMathBG);
            if (colorMathHalfIntensity == 1)
            {
                Bits.SetBit(rom, offset, 6, true);
            }
            else
            {
                Bits.SetBit(rom, offset, 6, false);
            }
            if (colorMathMinusSubscreen == 1)
            {
                Bits.SetBit(rom, offset, 7, true);
            }
            else
            {
                Bits.SetBit(rom, offset, 7, false);
            }
        }
Example #24
0
        // assemblers
        public void Assemble(int width, int layer)
        {
            if (tilesets_tiles[layer] == null)
            {
                return;
            }
            //
            int offset = 0;

            if (Type == TilesetType.Level || Type == TilesetType.Title)
            {
                for (int y = 0; y < tilesets_tiles[layer].Length / width; y++)
                {
                    for (int x = 0; x < width; x++)
                    {
                        int index = y * width + x;
                        if (index >= tilesets_tiles[layer].Length)
                        {
                            continue;
                        }
                        Tile tile = tilesets_tiles[layer][index];
                        for (int s = 0; s < 4; s++)
                        {
                            offset  = y * (width * 8) + (x * 4);
                            offset += (s % 2) * 2;
                            offset += (s / 2) * (width * 4);
                            Subtile subtile = tile.Subtiles[s];
                            if (subtile == null)
                            {
                                continue;
                            }
                            Bits.SetShort(tilesets_bytes[layer], offset, (ushort)subtile.Index);
                            tilesets_bytes[layer][offset + 1] |= (byte)(subtile.Palette << 2);
                            Bits.SetBit(tilesets_bytes[layer], offset + 1, 5, subtile.Priority1);
                            Bits.SetBit(tilesets_bytes[layer], offset + 1, 6, subtile.Mirror);
                            Bits.SetBit(tilesets_bytes[layer], offset + 1, 7, subtile.Invert);
                        }
                    }
                }
                if (Type == TilesetType.Level)
                {
                    if (layer == 0)
                    {
                        Model.EditTilesets[levelMap.TilesetL1 + 0x20] = true;
                    }
                    if (layer == 1)
                    {
                        Model.EditTilesets[levelMap.TilesetL2 + 0x20] = true;
                    }
                    if (layer == 2)
                    {
                        Model.EditTilesets[levelMap.TilesetL3] = true;
                    }
                    //
                    Buffer.BlockCopy(graphics, 0, Model.GraphicSets[levelMap.GraphicSetA + 0x48], 0, 0x2000);
                    Buffer.BlockCopy(graphics, 0x2000, Model.GraphicSets[levelMap.GraphicSetB + 0x48], 0, 0x1000);
                    Buffer.BlockCopy(graphics, 0x3000, Model.GraphicSets[levelMap.GraphicSetC + 0x48], 0, 0x1000);
                    Buffer.BlockCopy(graphics, 0x4000, Model.GraphicSets[levelMap.GraphicSetD + 0x48], 0, 0x1000);
                    Buffer.BlockCopy(graphics, 0x5000, Model.GraphicSets[levelMap.GraphicSetE + 0x48], 0, 0x1000);
                    //
                    Model.EditGraphicSets[levelMap.GraphicSetA + 0x48] = true;
                    Model.EditGraphicSets[levelMap.GraphicSetB + 0x48] = true;
                    Model.EditGraphicSets[levelMap.GraphicSetC + 0x48] = true;
                    Model.EditGraphicSets[levelMap.GraphicSetD + 0x48] = true;
                    Model.EditGraphicSets[levelMap.GraphicSetE + 0x48] = true;
                }
                else if (Type == TilesetType.Title)
                {
                    Buffer.BlockCopy(tilesets_bytes[0], 0, Model.TitleData, 0, 0x1000);
                    Buffer.BlockCopy(tilesets_bytes[1], 0, Model.TitleData, 0x1000, 0x1000);
                    Buffer.BlockCopy(tilesets_bytes[2], 0, Model.TitleData, 0xBBE0, 0x300);
                    Buffer.BlockCopy(graphics, 0, Model.TitleData, 0x6C00, 0x4FE0);
                    Buffer.BlockCopy(graphicsL3, 0x40, Model.TitleData, 0xBEE0, 0x1B80);
                }
            }
            else
            {
                Assemble(width);
            }
        }
 public void Assemble(ref int offset)
 {
     rom[offset] = (byte)this.x;
     Bits.SetBit(rom, offset++, 7, b0b7);
     rom[offset] = (byte)this.y;
     Bits.SetBit(rom, offset++, 7, this.width == 1 && this.height == 1);
     rom[offset] = (byte)(this.width - 1);
     Bits.SetBit(rom, offset, 5, this.layer1);
     Bits.SetBit(rom, offset, 6, this.layer2);
     Bits.SetBit(rom, offset++, 7, this.layer3);
     if (!(this.height == 1 && this.width == 1))
     {
         rom[offset] = (byte)(this.height - 1);
         Bits.SetBit(rom, offset++, 7, this.set);
     }
     if (layer1)
     {
         for (int i = 0, c = 0; c < (width * height) * 2; i++)
         {
             if (i % 9 == 0)
             {
                 rom[offset++] = 0;
             }
             else
             {
                 rom[offset]              = tilemapsA[0][c++];
                 rom[offset++ - (i % 9)] |= (byte)(tilemapsA[0][c++] << ((i % 9) - 1));
             }
         }
     }
     if (layer2)
     {
         for (int i = 0, c = 0; c < (width * height) * 2; i++)
         {
             if (i % 9 == 0)
             {
                 rom[offset++] = 0;
             }
             else
             {
                 rom[offset]              = tilemapsA[1][c++];
                 rom[offset++ - (i % 9)] |= (byte)(tilemapsA[1][c++] << ((i % 9) - 1));
             }
         }
     }
     if (layer3)
     {
         for (int i = 0, c = 0; c < width * height; i++)
         {
             if (i % 9 == 0)
             {
                 rom[offset++] = 0;
             }
             else
             {
                 rom[offset++] = tilemapsA[2][c++];
             }
         }
     }
     if (!set)
     {
         return;
     }
     if (layer1)
     {
         for (int i = 0, c = 0; c < (width * height) * 2; i++)
         {
             if (i % 9 == 0)
             {
                 rom[offset++] = 0;
             }
             else
             {
                 rom[offset]              = tilemapsB[0][c++];
                 rom[offset++ - (i % 9)] |= (byte)(tilemapsB[0][c++] << ((i % 9) - 1));
             }
         }
     }
     if (layer2)
     {
         for (int i = 0, c = 0; c < (width * height) * 2; i++)
         {
             if (i % 9 == 0)
             {
                 rom[offset++] = 0;
             }
             else
             {
                 rom[offset]              = tilemapsB[1][c++];
                 rom[offset++ - (i % 9)] |= (byte)(tilemapsB[1][c++] << ((i % 9) - 1));
             }
         }
     }
     if (layer3)
     {
         for (int i = 0, c = 0; c < width * height; i++)
         {
             if (i % 9 == 0)
             {
                 rom[offset++] = 0;
             }
             else
             {
                 rom[offset++] = tilemapsB[2][c++];
             }
         }
     }
 }
Example #26
0
        public void Assemble(ref int descriptionOffset)
        {
            int offset = 0x3A46EF + (index * 15);

            Bits.SetChars(rom, offset, name);
            this.baseOffsetName = offset;
            // description
            int length = 0;

            if (index <= 0xB0)
            {
                Bits.SetShort(rom, 0x3A2F20 + index * 2, descriptionOffset);
                if (this.descriptionError)
                {
                    MessageBox.Show("Unable to save item #" + this.index + "'s description.");
                }
                else
                {
                    length = (ushort)description.Length;
                    Bits.SetChars(rom, 0x3A0000 + descriptionOffset, description); // Write the actual description
                }
            }
            descriptionOffset += length;
            // price
            Bits.SetShort(rom, (index * 2) + 0x3A40F2, price);
            this.baseOffsetPrice = offset;
            // stats
            offset = (index * 18) + 0x3A014D;
            this.baseOffsetStats = offset;
            rom[offset]          = itemType;
            Bits.SetBit(rom, offset, 3, usageBattleMenu);
            Bits.SetBit(rom, offset, 4, usageOverworldMenu);
            Bits.SetBit(rom, offset, 5, usageReusable);
            Bits.SetBit(rom, offset++, 7, usageInstantDeath);
            //
            switch (attackType)
            {
            case 0: rom[offset] = 0x02; break;

            case 1: rom[offset] = 0x01; break;

            case 2: rom[offset] = 0x04; break;

            case 3: rom[offset] = 0x00; break;
            }
            // cursor
            if (cursorBehavior == 1)
            {
                Bits.SetBit(rom, offset, 5, true);
            }
            Bits.SetBit(rom, offset, 6, restoreFP);
            Bits.SetBit(rom, offset++, 7, restoreHP);
            //
            Bits.SetBit(rom, offset, 0, equipMario);
            Bits.SetBit(rom, offset, 1, equipToadstool);
            Bits.SetBit(rom, offset, 2, equipBowser);
            Bits.SetBit(rom, offset, 3, equipGeno);
            Bits.SetBit(rom, offset++, 4, equipMallow);
            //
            Bits.SetBit(rom, offset, 1, targetLiveAlly);
            Bits.SetBit(rom, offset, 2, targetEnemy);
            Bits.SetBit(rom, offset, 4, targetAll);
            Bits.SetBit(rom, offset, 5, targetWoundedOnly);
            Bits.SetBit(rom, offset, 6, targetOnePartyOnly);
            Bits.SetBit(rom, offset++, 7, targetNotSelf);
            //
            switch (elemAttack)
            {
            case 0: rom[offset++] = 0x10; break;                // Ice

            case 1: rom[offset++] = 0x20; break;                // Thunder

            case 2: rom[offset++] = 0x40; break;                // Fire

            case 3: rom[offset++] = 0x80; break;                // Earth

            case 4: rom[offset++] = 0x00; break;
            }
            // elemental attributes: nullify
            Bits.SetBit(rom, offset, 4, elemNullIce);
            Bits.SetBit(rom, offset, 5, elemNullThunder);
            Bits.SetBit(rom, offset, 6, elemNullFire);
            Bits.SetBit(rom, offset++, 7, elemNullJump);
            // elemental attributes: weakness
            Bits.SetBit(rom, offset, 4, elemWeakIce);
            Bits.SetBit(rom, offset, 5, elemWeakThunder);
            Bits.SetBit(rom, offset, 6, elemWeakFire);
            Bits.SetBit(rom, offset++, 7, elemWeakJump);
            // status effect
            Bits.SetBit(rom, offset, 0, effectMute);
            Bits.SetBit(rom, offset, 1, effectSleep);
            Bits.SetBit(rom, offset, 2, effectPoison);
            Bits.SetBit(rom, offset, 3, effectFear);
            Bits.SetBit(rom, offset, 5, effectMushroom);
            Bits.SetBit(rom, offset, 6, effectScarecrow);
            Bits.SetBit(rom, offset++, 7, effectInvincible);
            // status change
            Bits.SetBit(rom, offset, 3, changeMagicAttack);
            Bits.SetBit(rom, offset, 4, changeAttack);
            Bits.SetBit(rom, offset, 5, changeMagicDefense);
            Bits.SetBit(rom, offset++, 6, changeDefense);
            //
            rom[offset++] = (byte)speed;
            rom[offset++] = (byte)attack;
            rom[offset++] = (byte)defense;
            rom[offset++] = (byte)magicAttack;
            rom[offset++] = (byte)magicDefense;
            rom[offset++] = attackRange;
            rom[offset++] = inflictionAmount;
            // inflict function
            switch (inflictFunction)
            {
            case 0: rom[offset++] = 0x00; break;

            case 1: rom[offset++] = 0x01; break;                        // Revive

            case 2: rom[offset++] = 0x02; break;                        // Recover FP

            case 3: rom[offset++] = 0x03; break;                        // etc...

            case 4: rom[offset++] = 0x04; break;

            case 5: rom[offset++] = 0x05; break;

            case 6: rom[offset++] = 0x06; break;

            case 7: rom[offset++] = 0x07; break;

            case 8: rom[offset++] = 0xFF; break;
            }
            Bits.SetBit(rom, offset, 2, hideDigits);
            // timing
            if (index < 37)
            {
                offset        = (index * 4) + 0x3A438A;
                rom[offset++] = weaponStartLevel1;
                rom[offset++] = weaponStartLevel2;
                rom[offset++] = weaponEndLevel2;
                rom[offset++] = weaponEndLevel1;
            }
        }
Example #27
0
        public void Assemble(ref int psychopathOffset)
        {
            // name
            Bits.SetChars(rom, 0x3992d1 + (index * 13), name);
            // psychopath
            int length = 0;

            Bits.SetShort(rom, 0x399FD1 + index * 2, psychopathOffset);
            if (this.psychopathError)
            {
                MessageBox.Show("There was a problem saving monster #" + this.index + "'s psychopath message.");
            }
            else
            {
                length = psychopath.Length;
                Bits.SetChars(rom, 0x390000 + psychopathOffset, psychopath);
            }
            psychopathOffset += length;
            // stats
            int offset = Bits.GetShort(rom, 0x390026 + index * 2) + 0x390000;

            // B0
            Bits.SetShort(rom, offset, hp); offset += 2;
            // B1-8
            rom[offset++] = speed;
            rom[offset++] = attack;
            rom[offset++] = defense;
            rom[offset++] = magicAttack;
            rom[offset++] = magicDefense;
            rom[offset++] = fp;
            rom[offset++] = evade;
            rom[offset++] = magicEvade;
            // B9
            Bits.SetBit(rom, offset, 0, disableAutoDeath);
            Bits.SetBit(rom, offset++, 1, palette2bpp);
            // B10
            rom[offset] = (byte)((strikeSound << 4) + (morphSuccess << 2));
            Bits.SetBit(rom, offset, 0, invincible);
            Bits.SetBit(rom, offset++, 1, mortalityProtection);
            // B11
            Bits.SetBit(rom, offset, 4, elemNullIce);
            Bits.SetBit(rom, offset, 5, elemNullThunder);
            Bits.SetBit(rom, offset, 6, elemNullFire);
            Bits.SetBit(rom, offset++, 7, elemNullJump);
            // B12
            rom[offset] = otherSound;
            Bits.SetBit(rom, offset, 4, elemWeakIce);
            Bits.SetBit(rom, offset, 5, elemWeakThunder);
            Bits.SetBit(rom, offset, 6, elemWeakFire);
            Bits.SetBit(rom, offset++, 7, elemWeakJump);
            // B13
            Bits.SetBit(rom, offset, 0, effectNullMute);
            Bits.SetBit(rom, offset, 1, effectNullSleep);
            Bits.SetBit(rom, offset, 2, effectNullPoison);
            Bits.SetBit(rom, offset, 3, effectNullFear);
            Bits.SetBit(rom, offset, 5, effectNullMushroom);
            Bits.SetBit(rom, offset, 6, effectNullScarecrow);
            Bits.SetBit(rom, offset++, 7, effectNullInvincible);
            // B14
            rom[offset] = (byte)(entranceStyle + (elevation << 4) + (coinSize << 6));
            // rewards
            offset = Bits.GetShort(rom, 0x39142a + index * 2) + 0x390000;
            Bits.SetShort(rom, offset, experience); offset += 2;
            rom[offset++] = coins;
            rom[offset++] = yoshiCookie;
            rom[offset++] = itemWinA;
            rom[offset++] = itemWinB;
            // flower bonus
            offset      = index + 0x39BB44;
            rom[offset] = (byte)(flowerBonus + (flowerOdds << 4));
            // death animation
            offset = index * 2 + 0x350202;
            switch (spriteBehavior)                                     // DEATH ANIMATION
            {
            case 0: Bits.SetShort(rom, offset, 0x058A); break;          // no movement for "Escape"

            case 1: Bits.SetShort(rom, offset, 0x0596); break;          // slide backward when hit

            case 2: Bits.SetShort(rom, offset, 0x05A2); break;          // etc...

            case 3: Bits.SetShort(rom, offset, 0x05AE); break;

            case 4: Bits.SetShort(rom, offset, 0x05BA); break;

            case 5: Bits.SetShort(rom, offset, 0x0898); break;

            case 6: Bits.SetShort(rom, offset, 0x0985); break;

            case 7: Bits.SetShort(rom, offset, 0x0991); break;

            case 8: Bits.SetShort(rom, offset, 0x0AD3); break;

            case 9: Bits.SetShort(rom, offset, 0x0ADF); break;

            case 10: Bits.SetShort(rom, offset, 0x0AEB); break;

            case 11: Bits.SetShort(rom, offset, 0x0CF2); break;

            case 12: Bits.SetShort(rom, offset, 0x0CFE); break;

            case 13: Bits.SetShort(rom, offset, 0x0D0A); break;

            case 14: Bits.SetShort(rom, offset, 0x0D16); break;

            case 15: Bits.SetShort(rom, offset, 0x0E60); break;

            case 16: Bits.SetShort(rom, offset, 0x0E6C); break;

            case 17: Bits.SetShort(rom, offset, 0x0E78); break;
            }
            // cursor
            rom[0x39B944 + index]  = (byte)(cursorX << 4);
            rom[0x39B944 + index] |= cursorY;
        }
        public void Assemble()
        {
            // set sm to new byte with largest possible size
            byte[] temp = new byte[0x10000];
            // now start writing dynamic data
            temp[6] = (byte)sequences.Count;
            temp[7] = (byte)molds.Count;
            temp[8] = (byte)(vramAllocation >> 8);
            // Sequences
            int offset = 12; // where sequences begin

            Bits.SetShort(temp, 2, (ushort)0x0C);
            int fOffset = sequences.Count * 2 + 2;  // offset of first frame packet

            foreach (Sequence s in sequences)
            {
                if (s.Frames.Count != 0 && s.Active)
                {
                    Bits.SetShort(temp, offset, (ushort)(fOffset + offset));
                    fOffset += s.Frames.Count * 2 - 1;
                }
                else if (s.Active)
                {
                    Bits.SetShort(temp, offset, (ushort)(fOffset + offset));
                    fOffset -= 1;
                }
                else
                {
                    Bits.SetShort(temp, offset, 0xFFFF);
                    fOffset -= 2;
                }
                offset += 2;
            }
            Bits.SetShort(temp, offset, 0); offset += 2;
            foreach (Sequence s in sequences)
            {
                foreach (Sequence.Frame f in s.Frames)
                {
                    Bits.SetByte(temp, offset++, f.Duration);
                    Bits.SetByte(temp, offset++, f.Mold);
                }
                if (s.Active)
                {
                    Bits.SetByte(temp, offset++, 0);
                }
            }
            // Molds
            Bits.SetShort(temp, 4, (ushort)offset);
            int mOffset = molds.Count * 2 + 2;    // offset of first mold tilemap

            foreach (Mold m in molds)
            {
                if (index == 162 && mOffset == 0x132)
                {
                    index = 162;
                }
                if (m.Tiles.Count != 0)
                {
                    if (m.Gridplane)
                    {
                        Bits.SetShort(temp, offset, (ushort)(mOffset + offset + 0x8000));
                        Mold.Tile tile = m.Tiles[0];
                        if (tile.Subtile_bytes != null)
                        {
                            mOffset += tile.Length - 2;
                        }
                    }
                    else
                    {
                        Bits.SetShort(temp, offset, (ushort)(mOffset + offset));
                        mOffset += m.Recompress(mOffset + offset, molds).Length - 1;
                    }
                }
                else
                {
                    Bits.SetShort(temp, offset, (ushort)0xFFFF);
                    mOffset -= 2;
                }
                offset += 2;
            }
            Bits.SetShort(temp, offset += 2, 0);
            foreach (Mold m in molds)
            {
                if (m.Tiles.Count == 0)
                {
                    continue;
                }
                if (m.Gridplane)
                {
                    Mold.Tile tile = m.Tiles[0];
                    if (tile.Subtile_bytes == null)
                    {
                        continue;
                    }
                    temp[offset] = (byte)(tile.Format & 3);
                    Bits.SetBit(temp, offset, 3, tile.Is16bit);
                    Bits.SetBit(temp, offset, 4, tile.YPlusOne == 1);
                    Bits.SetBit(temp, offset, 5, tile.YMinusOne == 1);
                    Bits.SetBit(temp, offset, 6, tile.Mirror);
                    Bits.SetBit(temp, offset++, 7, tile.Invert);
                    int size = tile.Is16bit ? tile.Length - 3 : tile.Length - 1;
                    // set bits for tiles that are 16bit
                    if (tile.Is16bit)
                    {
                        for (int i = 0; i < size; i++)
                        {
                            Bits.SetBit(temp, offset, i, tile.Subtile_bytes[i] >= 0x100);
                        }
                        offset += 2;
                    }
                    for (int i = 0; i < size; i++)
                    {
                        temp[offset++] = (byte)tile.Subtile_bytes[i];
                    }
                }
                else
                {
                    byte[] mold = m.Recompress(offset, molds);
                    mold.CopyTo(temp, offset);
                    offset        += mold.Length;
                    temp[offset++] = 0;
                }
            }
            // finally, set the animation length
            Bits.SetShort(temp, 0, (ushort)offset);
            buffer = new byte[offset];
            Bits.SetBytes(buffer, 0, temp);
        }
Example #29
0
        public void Assemble()
        {
            int offset = index * 16 + 0x3EF830;

            rom[offset++] = x;
            rom[offset++] = y;
            Bits.SetShort(rom, offset, (ushort)((showCheckAddress - 0x7045) << 3));
            rom[offset++] |= showCheckBit;
            Bits.SetBit(rom, offset++, 6, goLocation);
            if (!goLocation)
            {
                Bits.SetShort(rom, offset, runEvent); offset += 2;
                Bits.SetShort(rom, offset, 0xFFFF); offset   += 2;
            }
            else
            {
                Bits.SetShort(rom, offset, (ushort)((whichLocationCheckAddress - 0x7045) << 3));
                rom[offset]  |= whichLocationCheckBit; offset += 2;
                rom[offset++] = goLocationA;
                rom[offset++] = goLocationB;
            }
            if (!enabledToEast)
            {
                Bits.SetShort(rom, offset, 0xFFFF);
                offset += 2;
            }
            else
            {
                Bits.SetShort(rom, offset, (ushort)((checkAddressToEast - 0x7045) << 3));
                rom[offset++] |= checkBitToEast;
                rom[offset++] |= (byte)(locationToEast << 1);
            }
            if (!enabledToSouth)
            {
                Bits.SetShort(rom, offset, 0xFFFF);
                offset += 2;
            }
            else
            {
                Bits.SetShort(rom, offset, (ushort)((checkAddressToSouth - 0x7045) << 3));
                rom[offset++] |= checkBitToSouth;
                rom[offset++] |= (byte)(locationToSouth << 1);
            }
            if (!enabledToWest)
            {
                Bits.SetShort(rom, offset, 0xFFFF);
                offset += 2;
            }
            else
            {
                Bits.SetShort(rom, offset, (ushort)((checkAddressToWest - 0x7045) << 3));
                rom[offset++] |= checkBitToWest;
                rom[offset++] |= (byte)(locationToWest << 1);
            }
            if (!enabledToNorth)
            {
                Bits.SetShort(rom, offset, 0xFFFF);
                offset += 2;
            }
            else
            {
                Bits.SetShort(rom, offset, (ushort)((checkAddressToNorth - 0x7045) << 3));
                rom[offset++] |= checkBitToNorth;
                rom[offset++] |= (byte)(locationToNorth << 1);
            }
        }
Example #30
0
        public void Assemble(int width)
        {
            int offset = 0;

            if (Type != TilesetType.Mode7)
            {
                for (int l = 0; l < tilesets_tiles.Length; l++)
                {
                    if (tilesets_tiles[l] == null)
                    {
                        continue;
                    }
                    for (int y = 0; y < tilesets_tiles[l].Length / width; y++)
                    {
                        for (int x = 0; x < width; x++)
                        {
                            Tile tile = tilesets_tiles[l][y * width + x];
                            for (int s = 0; s < 4; s++)
                            {
                                offset  = y * (width * 8) + (x * 4);
                                offset += (s % 2) * 2;
                                offset += (s / 2) * (width * 4);
                                Subtile subtile = tile.Subtiles[s];
                                if (subtile == null)
                                {
                                    continue;
                                }
                                Bits.SetShort(tilesets_bytes[l], offset, (ushort)subtile.Index);
                                tilesets_bytes[l][offset + 1] |= (byte)(subtile.Palette << 2);
                                Bits.SetBit(tilesets_bytes[l], offset + 1, 5, subtile.Priority1);
                                Bits.SetBit(tilesets_bytes[l], offset + 1, 6, subtile.Mirror);
                                Bits.SetBit(tilesets_bytes[l], offset + 1, 7, subtile.Invert);
                            }
                        }
                    }
                }
                if (Type == TilesetType.Level)
                {
                    Model.EditTilesets[levelMap.TilesetL1 + 0x20] = true;
                    Model.EditTilesets[levelMap.TilesetL2 + 0x20] = true;
                    Model.EditTilesets[levelMap.TilesetL3]        = true;
                    //
                    Buffer.BlockCopy(graphics, 0, Model.GraphicSets[levelMap.GraphicSetA + 0x48], 0, 0x2000);
                    Buffer.BlockCopy(graphics, 0x2000, Model.GraphicSets[levelMap.GraphicSetB + 0x48], 0, 0x1000);
                    Buffer.BlockCopy(graphics, 0x3000, Model.GraphicSets[levelMap.GraphicSetC + 0x48], 0, 0x1000);
                    Buffer.BlockCopy(graphics, 0x4000, Model.GraphicSets[levelMap.GraphicSetD + 0x48], 0, 0x1000);
                    Buffer.BlockCopy(graphics, 0x5000, Model.GraphicSets[levelMap.GraphicSetE + 0x48], 0, 0x1000);
                    //
                    Model.EditGraphicSets[levelMap.GraphicSetA + 0x48] = true;
                    Model.EditGraphicSets[levelMap.GraphicSetB + 0x48] = true;
                    Model.EditGraphicSets[levelMap.GraphicSetC + 0x48] = true;
                    Model.EditGraphicSets[levelMap.GraphicSetD + 0x48] = true;
                    Model.EditGraphicSets[levelMap.GraphicSetE + 0x48] = true;
                }
                else if (Type == TilesetType.SideScrolling)
                {
                    Buffer.BlockCopy(graphics, 0, Model.MinecartSSGraphics, 0, graphics.Length);
                }
                else if (Type == TilesetType.Title)
                {
                    Buffer.BlockCopy(tilesets_bytes[0], 0, Model.TitleData, 0, 0x1000);
                    Buffer.BlockCopy(tilesets_bytes[1], 0, Model.TitleData, 0x1000, 0x1000);
                    Buffer.BlockCopy(tilesets_bytes[2], 0, Model.TitleData, 0xBBE0, 0x300);
                    Buffer.BlockCopy(graphics, 0, Model.TitleData, 0x6C00, 0x4FE0);
                    Buffer.BlockCopy(graphicsL3, 0x40, Model.TitleData, 0xBEE0, 0x1B80);
                }
                else if (Type == TilesetType.Opening)
                {
                    Buffer.BlockCopy(tilesets_bytes[0], 0, Model.OpeningData, 0, 0x480);
                    Buffer.BlockCopy(graphics, 0, Model.OpeningData, 0x480, 0x1340);
                }
            }
            else
            {
                if (Tileset_tiles == null)
                {
                    return;
                }
                for (int y = 0; y < 16; y++)
                {
                    for (int x = 0; x < 16; x++)
                    {
                        int i = y * 16 + x;
                        for (int z = 0; z < 4; z++)
                        {
                            offset  = y * (width * 4) + (x * 2);
                            offset += z % 2;
                            offset += (z / 2) * (width * 2);
                            Subtile subtile = Tileset_tiles[i].Subtiles[z];
                            byte    tilenum = (byte)subtile.Index;
                            subtile_bytes[offset]  = tilenum;
                            palette_bytes[tilenum] = (byte)subtile.Palette;
                        }
                    }
                }
                Buffer.BlockCopy(graphics, 0, Model.MinecartM7Graphics, 0, graphics.Length);
            }
        }