Example #1
0
        public static ObjRec[] readBlocksLinear(byte[] romdata, int addr, int w, int h, int count, bool withAttribs, bool transposeIndexes = false)
        {
            var objects   = new ObjRec[count];
            int blockSize = w * h;
            int pw        = (int)Math.Ceiling(w / 2.0);
            int ph        = (int)Math.Ceiling(h / 2.0);
            int palSize   = pw * ph;
            int fullSize  = withAttribs ? blockSize + palSize : blockSize;

            for (int i = 0; i < count; i++)
            {
                var indexes  = new int[blockSize];
                var palBytes = new int[palSize];
                int baseAddr = addr + i * fullSize;
                Array.Copy(romdata, baseAddr, indexes, 0, blockSize);
                if (withAttribs)
                {
                    Array.Copy(romdata, baseAddr + blockSize, palBytes, 0, palSize);
                }
                if (transposeIndexes)
                {
                    indexes = Utils.transpose(indexes, w, h);
                }
                objects[i] = new ObjRec(w, h, indexes, palBytes);
            }
            return(objects);
        }
Example #2
0
 protected void btClear_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Are you sure want to clear all blocks?", "Clear", MessageBoxButtons.YesNo)!= DialogResult.Yes)
       return;
     for (int i = 0; i < ConfigScript.getBlocksCount(); i++)
         objects[i] = new ObjRec(0,0,0,0,0);
     dirty = true;
     refillPanel();
 }
 static void writeBlocksToAlignedArraysTT(ObjRec[] objects, byte[] romdata, int addr, int count)
 {
   for (int i = 0; i < count; i++)
   {
     var obj = objects[i];
     romdata[addr + i] = obj.c1;
     romdata[addr + count * 1 + i] = obj.c3;
     romdata[addr + count * 2 + i] = obj.c2;
     romdata[addr + count * 3 + i] = obj.c4;
   }
 }
Example #4
0
 public void setBlocks(int tileId, ObjRec[] blocks)
 {
   int addr = ConfigScript.getTilesAddr(tileId);
   for (int i = 0; i < getBlocksCount(); i++)
   {
       var obj = blocks[i];
       Globals.romdata[addr + 4 * i + 0] = obj.c1;
       Globals.romdata[addr + 4 * i + 1] = obj.c2;
       Globals.romdata[addr + 4 * i + 2] = obj.c3;
       Globals.romdata[addr + 4 * i + 3] = obj.c4;
       Globals.romdata[0x14C1C + i] = obj.typeColor;
   }
 }
Example #5
0
 protected void btClear_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Are you sure want to clear all blocks?", "Clear", MessageBoxButtons.YesNo) != DialogResult.Yes)
     {
         return;
     }
     for (int i = 0; i < ConfigScript.getBlocksCount(curActiveBigBlock); i++)
     {
         objects[i] = new ObjRec(0, 0, 0, 0, 0, 0);
     }
     dirty = true;
     refillPanel();
 }
 static ObjRec[] readBlocksFromAlignedArraysTT(byte[] romdata, int addr, int count)
 {
     var objects = new ObjRec[count];
     byte c1, c2, c3, c4, typeColor;
     for (int i = 0; i < count; i++)
     {
         c1 = romdata[addr + i];
         c3 = romdata[addr + count*1 + i]; //tt version
         c2 = romdata[addr + count*2 + i];
         c4 = romdata[addr + count*3 + i];
         typeColor = 0;
         objects[i] = new ObjRec(c1, c2, c3, c4, typeColor);
     }
     return objects;
 }
Example #7
0
 public ObjRec[] getBlocks(int tileId)
 {
   int addr = ConfigScript.getTilesAddr(tileId);
   var objects = new ObjRec[getBlocksCount()];
   for (int i = 0; i < getBlocksCount(); i++)
   {
       byte c1 = Globals.romdata[addr + 4 * i + 0];
       byte c2 = Globals.romdata[addr + 4 * i + 1];
       byte c3 = Globals.romdata[addr + 4 * i + 2];
       byte c4 = Globals.romdata[addr + 4 * i + 3];
       byte typeColor = Globals.romdata[0x14C1C + i];
       objects[i] = new ObjRec(c1, c2, c3, c4, typeColor);
   }
   return objects;
 }
 public ObjRec[] getBlocks(int blockIndex)
 {
     int count = getBlocksCount();
     int addr  = getBlocksOffset().beginAddr;
     var objects = new ObjRec[count];
     for (int i = 0; i < count; i++)
     {
     byte c1, c2, c3, c4, typeColor;
     c1 = Globals.romdata[addr + i*4 + 0];
     c2 = Globals.romdata[addr + i*4 + 2];
     c3 = Globals.romdata[addr + i*4 + 1];
     c4 = Globals.romdata[addr + i*4 + 3];
     typeColor = Globals.romdata[addr + count * 4 + i];
     objects[i] = new ObjRec(c1, c2, c3, c4, typeColor);
     }
     return objects;
 }
 public static ObjRec[] getBlocks(int blockIndex)
 {
     int count = ConfigScript.getBlocksCount();
     int addr  = ConfigScript.getTilesAddr(blockIndex);
     var objects = new ObjRec[count];
     for (int i = 0; i < count; i++)
     {
     byte c1, c2, c3, c4, typeColor;
     c1 = Globals.romdata[addr + i*4 + 0];
     c2 = Globals.romdata[addr + i*4 + 2];
     c3 = Globals.romdata[addr + i*4 + 1];
     c4 = Globals.romdata[addr + i*4 + 3];
     typeColor = Globals.romdata[addr + count * 4 + i];
     objects[i] = new ObjRec(c1, c2, c3, c4, typeColor);
     }
     return objects;
 }
Example #10
0
        public static ObjRec[] readBlocksFromAlignedArrays(byte[] romdata, int addr, int count)
        {
            //capcom version
            var objects = new ObjRec[count];

            for (int i = 0; i < count; i++)
            {
                byte c1, c2, c3, c4, typeColor;
                c1         = romdata[addr + i];
                c2         = romdata[addr + count * 1 + i];
                c3         = romdata[addr + count * 2 + i];
                c4         = romdata[addr + count * 3 + i];
                typeColor  = romdata[addr + count * 4 + i];
                objects[i] = new ObjRec(c1, c2, c3, c4, typeColor);
            }
            return(objects);
        }
Example #11
0
        public static ObjRec[] readBlocksFromAlignedArrays(byte[] romdata, int addr, int count, bool readType)
        {
            //capcom version
            var objects = new ObjRec[count];

            for (int i = 0; i < count; i++)
            {
                byte c1, c2, c3, c4, typeColor;
                c1        = romdata[addr + i];
                c2        = romdata[addr + count * 1 + i];
                c3        = romdata[addr + count * 2 + i];
                c4        = romdata[addr + count * 3 + i];
                typeColor = romdata[addr + count * 4 + i];
                int pal  = typeColor & 0x3;
                int type = 0;
                if (readType)
                {
                    type = (typeColor & 0xF0) >> 4;
                }
                objects[i] = new ObjRec(c1, c2, c3, c4, type, pal);
            }
            return(objects);
        }
 /*public bool setObjectsDt2(int levelNo, List<ObjectList> objects)
 {
   //todo : add save for duck tales 2
   return true;
 }*/
 
 public void setBlocksDt2(int blockIndex, ObjRec[] objects)
 {
   int addr = ConfigScript.getTilesAddr(blockIndex);
   int count = getBlocksCount();
   for (int i = 0; i < count; i++)
   {
       var obj = objects[i];
       Globals.romdata[addr + i] = obj.c1;
       Globals.romdata[addr + count * 1 + i] = obj.c2;
       Globals.romdata[addr + count * 2 + i] = obj.c3;
       Globals.romdata[addr + count * 3 + i] = obj.c4;
   }
   for (int i = 0; i < count/4; i++)
   {
       Globals.romdata[addr + count * 4 + i] = objects[i].typeColor;
   }
 }
 public static void setBlocks(int blockIndex, ObjRec[] blocksData)
 {
     writeBlocksToAlignedArraysTT(blocksData, Globals.romdata, ConfigScript.getTilesAddr(blockIndex), ConfigScript.getBlocksCount());
 }
 public Dt2ObjRec(ObjRec b, int _index)
     : base(b)
 {
     index = _index;
 }
    public void setBlocksDt2(int blockIndex, ObjRec[] objects)
    {
        int addr = ConfigScript.getTilesAddr(blockIndex);
        int count = getBlocksCount();
        for (int i = 0; i < count; i++)
        {
        var obj = objects[i];
        Globals.romdata[addr + i] = obj.c1;
        Globals.romdata[addr + count * 1 + i] = obj.c2;
        Globals.romdata[addr + count * 2 + i] = obj.c3;
        Globals.romdata[addr + count * 3 + i] = obj.c4;
        }

        int palInfoCount = getBlocksCount()/4;
        for (int i = 0; i < palInfoCount; i++)
        {
        var palInfoByte =
          (objects[i*4+0].typeColor<<0) |
          (objects[i*4+1].typeColor<<2) |
          (objects[i*4+2].typeColor<<4) |
          (objects[i*4+3].typeColor<<6);

        Globals.romdata[addr + count * 4 + i] = (byte)palInfoByte;
        }
    }
 public void setBlocksJB(int blockIndex, ObjRec[] objects)
 {
     var secondPart = new ObjRec[0x80];
     Array.Copy(objects, 0x80, secondPart, 0, 0x80);
     Utils.writeBlocksToAlignedArrays(objects   , Globals.romdata, BlocksAddrs[blockIndex].hiAddr, 0x80);
     Utils.writeBlocksToAlignedArrays(secondPart, Globals.romdata, BlocksAddrs[blockIndex].loAddr, 0x80);
 }
 public void setBlocks(int blockIndex, ObjRec[] blocksData)
 {
     int count = getBlocksCount();
     int addr  = getBlocksOffset().beginAddr;
     for (int i = 0; i < count; i++)
     {
     var obj = blocksData[i];
     Globals.romdata[addr + i*4 + 0] = obj.c1;
     Globals.romdata[addr + i*4 + 2] = obj.c2;
     Globals.romdata[addr + i*4 + 1] = obj.c3;
     Globals.romdata[addr + i*4 + 3] = obj.c4;
     Globals.romdata[addr + count * 4 + i] = obj.typeColor;
     }
 }
 public void setBlocks(int blockIndex, ObjRec[] blocksData)
 {
     Utils.writeBlocksToAlignedArrays(blocksData, Globals.romdata, Globals.getTilesAddr(blockIndex), getBlocksCount());
 }
 public static void setBlocks(int blockIndex, ObjRec[] blocksData)
 {
     int count = ConfigScript.getBlocksCount();
     int addr  = ConfigScript.getTilesAddr(blockIndex);
     for (int i = 0; i < count; i++)
     {
     var obj = blocksData[i];
     Globals.romdata[addr + i*4 + 0] = obj.c1;
     Globals.romdata[addr + i*4 + 2] = obj.c2;
     Globals.romdata[addr + i*4 + 1] = obj.c3;
     Globals.romdata[addr + i*4 + 3] = obj.c4;
     Globals.romdata[addr + count * 4 + i] = obj.typeColor;
     }
 }
 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 public static ObjRec[] getBlocksJB(int blockIndex)
 {
   var part1 = Utils.readBlocksFromAlignedArrays(Globals.romdata, BlocksAddrs[blockIndex].hiAddr, BlocksAddrs[blockIndex].hiCount);
   var part2 = Utils.readBlocksFromAlignedArrays(Globals.romdata, BlocksAddrs[blockIndex].loAddr, BlocksAddrs[blockIndex].loCount);
   var total = new ObjRec[256];
   Array.Copy(part1, total, part1.Length);
   Array.Copy(part2, 0, total, BlocksAddrs[blockIndex].loCount, part2.Length); //copy to index 110, no 128!!! bug of game developers?
   return total;
 }
 public void setBlocksJB(int blockIndex, ObjRec[] objects)
 {
   int loCount = BlocksAddrs[blockIndex].loCount;
   var secondPart = new ObjRec[loCount];
   Array.Copy(objects, loCount, secondPart, 0, loCount);
   Utils.writeBlocksToAlignedArrays(objects   , Globals.romdata, BlocksAddrs[blockIndex].hiAddr, BlocksAddrs[blockIndex].hiCount);
   Utils.writeBlocksToAlignedArrays(secondPart, Globals.romdata, BlocksAddrs[blockIndex].loAddr, loCount);
 }
Example #22
0
        public Bitmap makeObject(int index, ObjRec[] objects, Bitmap[] objStrips, float scale, MapViewType drawType, int constantSubpal = -1)
        {
            int i = index;
            var mblock = new Bitmap((int)(16 * scale), (int)(16 * scale));
            var co = objects[i];
            Bitmap curStrip;
            if (constantSubpal == -1)
            {
                if (Globals.getGameType() == GameType.DT2)
                {
                    var objectForColor = objects[i / 4];
                    curStrip = objStrips[objectForColor.getSubpalleteForDt2(i % 4)];
                }
                else
                {
                    curStrip = objStrips[co.getSubpallete()];
                }
            }
            else
            {
                curStrip = objStrips[constantSubpal];
            }

            int scaleInt8 = (int)(scale * 8);
            int scaleInt16 = (int)(scale * 16);
            using (Graphics g2 = Graphics.FromImage(mblock))
            {
                g2.DrawImage(curStrip, new Rectangle(0, 0, scaleInt8, scaleInt8), new Rectangle(co.c1 * scaleInt8, 0, scaleInt8, scaleInt8), GraphicsUnit.Pixel);
                g2.DrawImage(curStrip, new Rectangle(scaleInt8, 0, scaleInt8, scaleInt8), new Rectangle(co.c2 * scaleInt8, 0, scaleInt8, scaleInt8), GraphicsUnit.Pixel);
                g2.DrawImage(curStrip, new Rectangle(0, scaleInt8, scaleInt8, scaleInt8), new Rectangle(co.c3 * scaleInt8, 0, scaleInt8, scaleInt8), GraphicsUnit.Pixel);
                g2.DrawImage(curStrip, new Rectangle(scaleInt8, scaleInt8, scaleInt8, scaleInt8), new Rectangle(co.c4 * scaleInt8, 0, scaleInt8, scaleInt8), GraphicsUnit.Pixel);
                if (drawType == MapViewType.ObjType)
                {
                    if (Globals.getGameType() == GameType.DT2)
                    {
                        g2.FillRectangle(new SolidBrush(CadObjectTypeColors[co.getTypeForDt2(i)]), new Rectangle(0, 0, scaleInt16, scaleInt16));
                        g2.DrawString(String.Format("{0:X}", co.getTypeForDt2(i)), new Font("Arial", 6), Brushes.White, new Point(0, 0));
                    }
                    else
                    {
                        g2.FillRectangle(new SolidBrush(CadObjectTypeColors[co.getType()]), new Rectangle(0, 0, scaleInt16, scaleInt16));
                        g2.DrawString(String.Format("{0:X}", co.getType()), new Font("Arial", 6), Brushes.White, new Point(0, 0));
                    }
                }
                else if (drawType == MapViewType.ObjNumbers)
                {
                    g2.FillRectangle(new SolidBrush(Color.FromArgb(192, 255, 255, 255)), new Rectangle(0, 0, scaleInt16, scaleInt16));
                    g2.DrawString(String.Format("{0:X}", i), new Font("Arial", 6), Brushes.Red, new Point(0, 0));
                }
            }
            return mblock;
        }
 public void setBlocks(int blockIndex, ObjRec[] blocksData)
 {
     Utils.writeBlocksLinear(blocksData, Globals.romdata, ConfigScript.getTilesAddr(blockIndex), getBlocksCount());
 }