Beispiel #1
0
    public void ExportAmiga(string _outfilename)
    {
        Debug.Log("Exporting tile bank (Amiga) to " + _outfilename);

        int headersize = 0;

        int numTiles = m_tiles.Count;

        // Export size = number of tiles * 64 pixels / 2 (because there are 2 bytes per pixel)
        int outsize = headersize + (numTiles * 32);         // 8*8 pixels, 8 bits per bytes/only 4 bits used

        byte[] outBytes = new byte[outsize];

        Debug.Log("exporting " + numTiles + " tiles");
        //Halp.Write16( outBytes, 0, numTiles );

        int iTile;

        for (iTile = 0; iTile < numTiles; iTile++)
        {
            Tile t = m_tiles[iTile];

            ChunkyToPlanar c2p = new ChunkyToPlanar(0, 3, 8, 4, 1);
            for (int y = 0; y < Tile.Height; y++)
            {
                c2p.ChunkyToPlanar8Pixels(t.m_pixels, 0, y, outBytes, 0, iTile * 8 + y);
            }
        }

        System.IO.File.WriteAllBytes(_outfilename, outBytes);
    }
 private byte[] ChunkyToPlanarImageInterleaved(byte[] chunkyImage)
 {
     int chunkyStepPerRow = m_width;
     int planarStepPerRow = m_width/8*4;
     int planarStepPerPlane = m_width/8;
     //		Debug.Log ("chunkyStepPerRow: " + chunkyStepPerRow);
     //		Debug.Log ("planarStepPerRow: " + planarStepPerRow);
     //		Debug.Log ("planarStepPerPlane: " + planarStepPerPlane);
     ChunkyToPlanar c2p = new ChunkyToPlanar(0, 3, chunkyStepPerRow, planarStepPerRow, planarStepPerPlane);
     return ChunkyToPlanarImage(chunkyImage, c2p);
 }
    private byte[] ChunkyToPlanarImageInterleaved(byte[] chunkyImage)
    {
        int chunkyStepPerRow   = m_width;
        int planarStepPerRow   = m_width / 8 * 4;
        int planarStepPerPlane = m_width / 8;
//		Debug.Log ("chunkyStepPerRow: " + chunkyStepPerRow);
//		Debug.Log ("planarStepPerRow: " + planarStepPerRow);
//		Debug.Log ("planarStepPerPlane: " + planarStepPerPlane);
        ChunkyToPlanar c2p = new ChunkyToPlanar(0, 3, chunkyStepPerRow, planarStepPerRow, planarStepPerPlane);

        return(ChunkyToPlanarImage(chunkyImage, c2p));
    }
Beispiel #4
0
    private byte[] ChunkyToPlanarSpriteFrames(byte[] chunkyImage)
    {
        int chunkyStepPerRow   = m_imageWidth;
        int planarStepPerRow   = m_spriteWidth / 8 * 4;       // 4 bitplanes
        int planarStepPerPlane = m_spriteWidth / 8;

        int dataSizePerFrame = m_imageHeight * m_spriteWidth / 8 * 4 * 2; // 8 pixels per byte, 4 bitplanes, and dont forget antoher 4 bitplanes for the mask

        int planarDataSize = m_numberOfFrames * dataSizePerFrame;         //

        byte[] spriteData = new byte[planarDataSize];

        ChunkyToPlanar c2p = new ChunkyToPlanar(0, 3, chunkyStepPerRow, planarStepPerRow, planarStepPerPlane);

        for (int frame = 0; frame < m_numberOfFrames; frame++)
        {
            for (int x = 0; x < m_spriteWidth; x += 8)
            {
                for (int y = 0; y < m_imageHeight; y++)
                {
                    {
                        c2p.ChunkyToPlanar8Pixels(chunkyImage, x + (frame * m_spriteWidth), y, spriteData, x, (frame * m_imageHeight * 2) + y);
                        int srcxoffs      = x / 8;
                        int srcyoffsframe = (frame * m_imageHeight * (m_spriteWidth / 8) * 4 * 2);
                        int srcyoffs      = y * (m_spriteWidth / 8) * 4;

                        int srcoffsbpl0 = srcxoffs + srcyoffsframe + srcyoffs;
                        int srcoffsbpl1 = srcoffsbpl0 + (1 * (m_spriteWidth / 8));
                        int srcoffsbpl2 = srcoffsbpl0 + (2 * (m_spriteWidth / 8));
                        int srcoffsbpl3 = srcoffsbpl0 + (3 * (m_spriteWidth / 8));

                        byte mask = 0;
                        mask |= spriteData[srcoffsbpl0];
                        mask |= spriteData[srcoffsbpl1];
                        mask |= spriteData[srcoffsbpl2];
                        mask |= spriteData[srcoffsbpl3];

                        int dstoffsbpl0 = srcoffsbpl0 + (m_imageHeight * m_spriteWidth / 8) * 4;
                        int dstoffsbpl1 = srcoffsbpl1 + (m_imageHeight * m_spriteWidth / 8) * 4;
                        int dstoffsbpl2 = srcoffsbpl2 + (m_imageHeight * m_spriteWidth / 8) * 4;
                        int dstoffsbpl3 = srcoffsbpl3 + (m_imageHeight * m_spriteWidth / 8) * 4;

                        spriteData[dstoffsbpl0] = mask;
                        spriteData[dstoffsbpl1] = mask;
                        spriteData[dstoffsbpl2] = mask;
                        spriteData[dstoffsbpl3] = mask;
                    }
                }
            }
        }
        return(spriteData);
    }
    private byte[] ChunkyToPlanarImageSequential(byte[] chunkyImage)
    {
        int chunkyStepPerRow   = m_width;
        int planarStepPerRow   = m_width / 8;
        int planarStepPerPlane = planarStepPerRow * m_height;
//		Debug.Log ("chunkyStepPerRow: " + chunkyStepPerRow);
//		Debug.Log ("planarStepPerRow: " + planarStepPerRow);
//		Debug.Log ("planarStepPerPlane: " + planarStepPerPlane);

        ChunkyToPlanar c2p = new ChunkyToPlanar(0, 3, chunkyStepPerRow, planarStepPerRow, planarStepPerPlane);

        return(ChunkyToPlanarImage(chunkyImage, c2p));
    }
    private byte[] ChunkyToPlanarImageSequential(byte[] chunkyImage)
    {
        int chunkyStepPerRow = m_width;
        int planarStepPerRow = m_width/8;
        int planarStepPerPlane = planarStepPerRow*m_height;
        //		Debug.Log ("chunkyStepPerRow: " + chunkyStepPerRow);
        //		Debug.Log ("planarStepPerRow: " + planarStepPerRow);
        //		Debug.Log ("planarStepPerPlane: " + planarStepPerPlane);

        ChunkyToPlanar c2p = new ChunkyToPlanar(0, 3, chunkyStepPerRow, planarStepPerRow, planarStepPerPlane);

        return ChunkyToPlanarImage(chunkyImage, c2p);
    }
    private byte[] ChunkyToPlanarSpriteFrames(byte[] chunkyImage)
    {
        int chunkyStepPerRow = m_imageWidth;
        int planarStepPerRow = m_spriteWidth / 8 * 4; // 4 bitplanes
        int planarStepPerPlane = m_spriteWidth / 8;

        int dataSizePerFrame = m_imageHeight * m_spriteWidth / 8 * 4 * 2; // 8 pixels per byte, 4 bitplanes, and dont forget antoher 4 bitplanes for the mask

        int planarDataSize = m_numberOfFrames * dataSizePerFrame; //
        byte[] spriteData = new byte[planarDataSize];

        ChunkyToPlanar c2p = new ChunkyToPlanar(0, 3, chunkyStepPerRow, planarStepPerRow, planarStepPerPlane);

        for (int frame = 0; frame < m_numberOfFrames; frame++) {
            for (int x = 0; x < m_spriteWidth; x += 8) {
                for (int y = 0; y < m_imageHeight; y ++) {
                    {
                        c2p.ChunkyToPlanar8Pixels (chunkyImage, x + (frame * m_spriteWidth), y, spriteData, x, (frame * m_imageHeight * 2) + y);
                        int srcxoffs = x / 8;
                        int srcyoffsframe = (frame * m_imageHeight * (m_spriteWidth / 8) * 4 * 2);
                        int srcyoffs = y * (m_spriteWidth / 8) * 4;

                        int srcoffsbpl0 = srcxoffs + srcyoffsframe + srcyoffs;
                        int srcoffsbpl1 = srcoffsbpl0 + (1 * (m_spriteWidth / 8));
                        int srcoffsbpl2 = srcoffsbpl0 + (2 * (m_spriteWidth / 8));
                        int srcoffsbpl3 = srcoffsbpl0 + (3 * (m_spriteWidth / 8));

                        byte mask = 0;
                        mask |= spriteData[srcoffsbpl0];
                        mask |= spriteData[srcoffsbpl1];
                        mask |= spriteData[srcoffsbpl2];
                        mask |= spriteData[srcoffsbpl3];

                        int dstoffsbpl0 = srcoffsbpl0 + (m_imageHeight * m_spriteWidth / 8) * 4;
                        int dstoffsbpl1 = srcoffsbpl1 + (m_imageHeight * m_spriteWidth / 8) * 4;
                        int dstoffsbpl2 = srcoffsbpl2 + (m_imageHeight * m_spriteWidth / 8) * 4;
                        int dstoffsbpl3 = srcoffsbpl3 + (m_imageHeight * m_spriteWidth / 8) * 4;

                        spriteData[dstoffsbpl0] = mask;
                        spriteData[dstoffsbpl1] = mask;
                        spriteData[dstoffsbpl2] = mask;
                        spriteData[dstoffsbpl3] = mask;
                    }
                }
            }
        }
        return spriteData;
    }
Beispiel #8
0
    private byte[] ChunkyToPlanarSpriteFrames(byte[] chunkyImage)
    {
        int chunkyStepPerRow   = m_imageWidth;
        int planarStepPerRow   = 4;
        int planarStepPerPlane = 2;

        int dataSizePerFrame = 16 + (m_imageHeight * 2 * 4);         // 2 bytes per row per bitplane, 4 bitplanes

        int planarDataSize = m_numberOfFrames * dataSizePerFrame;    //

        byte[] spriteData = new byte[planarDataSize];

        ChunkyToPlanar c2p1 = new ChunkyToPlanar(0, 1, chunkyStepPerRow, planarStepPerRow, planarStepPerPlane);
        ChunkyToPlanar c2p2 = new ChunkyToPlanar(2, 3, chunkyStepPerRow, planarStepPerRow, planarStepPerPlane);

        for (int frame = 0; frame < m_numberOfFrames; frame++)
        {
            for (int x = 0; x < m_spriteWidth; x += 8)
            {
                for (int y = 0; y < m_imageHeight; y++)
                {
                    {
                        c2p1.ChunkyToPlanar8Pixels(chunkyImage, x + (frame * m_spriteWidth), y, spriteData, x, (frame * 2 * (m_imageHeight + 2)) + 1 + y);
                        c2p2.ChunkyToPlanar8Pixels(chunkyImage, x + (frame * m_spriteWidth), y, spriteData, x, (frame * 2 * (m_imageHeight + 2)) + 3 + m_imageHeight + y);
                    }
                }
            }

            int baseGrej = frame * dataSizePerFrame;
            Halp.Write16(spriteData, baseGrej + 0, 0x2c40);
            Halp.Write16(spriteData, baseGrej + 2, 0x3c00);
            Halp.Write16(spriteData, baseGrej - 4 + (dataSizePerFrame / 2), 0x0000);
            Halp.Write16(spriteData, baseGrej - 2 + (dataSizePerFrame / 2), 0x0000);

            Halp.Write16(spriteData, baseGrej + 0 + (dataSizePerFrame / 2), 0x2c40);
            Halp.Write16(spriteData, baseGrej + 2 + (dataSizePerFrame / 2), 0x3c80);
            Halp.Write16(spriteData, baseGrej - 4 + dataSizePerFrame, 0x0000);
            Halp.Write16(spriteData, baseGrej - 2 + dataSizePerFrame, 0x0000);
        }
        return(spriteData);
    }
    private byte[] ChunkyToPlanarImage(byte[] chunkyImage, ChunkyToPlanar c2p)
    {
        int planarDataSize = m_height * m_width * 4 / 8;
        byte[] planarData = new byte[planarDataSize];

        //			Debug.Log (m_height);
        //			Debug.Log (m_width);
        //			Debug.Log (m_numberOfBitPlanes);
        //			Debug.Log (planarDataSize);
        //			Debug.Log (chunkyYOffs);
        //			Debug.Log (yoffsPlane3);
        for (int y = 0; y < m_height; y++)
        {
            for (int x = 0; x < m_width; x+=8)
            {
                c2p.ChunkyToPlanar8Pixels (chunkyImage, x, y, planarData, x, y);
            }
        }

        return planarData;
    }
    private byte[] ChunkyToPlanarImage(byte[] chunkyImage, ChunkyToPlanar c2p)
    {
        int planarDataSize = m_height * m_width * 4 / 8;

        byte[] planarData = new byte[planarDataSize];

        //			Debug.Log (m_height);
        //			Debug.Log (m_width);
        //			Debug.Log (m_numberOfBitPlanes);
        //			Debug.Log (planarDataSize);
        //			Debug.Log (chunkyYOffs);
        //			Debug.Log (yoffsPlane3);
        for (int y = 0; y < m_height; y++)
        {
            for (int x = 0; x < m_width; x += 8)
            {
                c2p.ChunkyToPlanar8Pixels(chunkyImage, x, y, planarData, x, y);
            }
        }

        return(planarData);
    }
    private byte[] ChunkyToPlanarSpriteFrames(byte[] chunkyImage)
    {
        int chunkyStepPerRow = m_imageWidth;
        int planarStepPerRow = 4;
        int planarStepPerPlane = 2;

        int dataSizePerFrame = 16 + (m_imageHeight * 2 * 4); // 2 bytes per row per bitplane, 4 bitplanes

        int planarDataSize = m_numberOfFrames * dataSizePerFrame; //
        byte[] spriteData = new byte[planarDataSize];

        ChunkyToPlanar c2p1 = new ChunkyToPlanar(0, 1, chunkyStepPerRow, planarStepPerRow, planarStepPerPlane);
        ChunkyToPlanar c2p2 = new ChunkyToPlanar(2, 3, chunkyStepPerRow, planarStepPerRow, planarStepPerPlane);

        for (int frame = 0; frame < m_numberOfFrames; frame++) {
                        for (int x = 0; x < m_spriteWidth; x += 8) {
                                for (int y = 0; y < m_imageHeight; y ++) {
                                        {
                                                c2p1.ChunkyToPlanar8Pixels (chunkyImage, x + (frame * m_spriteWidth), y, spriteData, x, (frame * 2 * (m_imageHeight + 2)) + 1 + y);
                                                c2p2.ChunkyToPlanar8Pixels (chunkyImage, x + (frame * m_spriteWidth), y, spriteData, x, (frame * 2 * (m_imageHeight + 2)) + 3 + m_imageHeight + y);

                                        }
                                }
                        }

                        int baseGrej = frame * dataSizePerFrame;
                        Halp.Write16 (spriteData, baseGrej + 0, 0x2c40);
                        Halp.Write16 (spriteData, baseGrej + 2, 0x3c00);
                        Halp.Write16 (spriteData, baseGrej - 4 + (dataSizePerFrame / 2), 0x0000);
                        Halp.Write16 (spriteData, baseGrej - 2 + (dataSizePerFrame / 2), 0x0000);

                        Halp.Write16 (spriteData, baseGrej + 0 + (dataSizePerFrame / 2), 0x2c40);
                        Halp.Write16 (spriteData, baseGrej + 2 + (dataSizePerFrame / 2), 0x3c80);
                        Halp.Write16 (spriteData, baseGrej - 4 + dataSizePerFrame, 0x0000);
                        Halp.Write16 (spriteData, baseGrej - 2 + dataSizePerFrame, 0x0000);
                }
        return spriteData;
    }
    private byte[] ChunkyToPlanarTilesInterleaved(byte[] chunkyImage)
    {
        int chunkyStepPerRow   = m_width;
        int planarStepPerRow   = 4;
        int planarStepPerPlane = 1;
        //		Debug.Log ("chunkyStepPerRow: " + chunkyStepPerRow);
        //		Debug.Log ("planarStepPerRow: " + planarStepPerRow);
        //		Debug.Log ("planarStepPerPlane: " + planarStepPerPlane);
        ChunkyToPlanar c2p = new ChunkyToPlanar(0, 3, chunkyStepPerRow, planarStepPerRow, planarStepPerPlane);

        int planarDataSize = m_height * m_width * 4 / 8;

        byte[] planarData = new byte[planarDataSize];

        //			Debug.Log (m_height);
        //			Debug.Log (m_width);
        //			Debug.Log (m_numberOfBitPlanes);
        //			Debug.Log (planarDataSize);
        //			Debug.Log (chunkyYOffs);
        //			Debug.Log (yoffsPlane3);
        int tile = 0;

        for (int x = 0; x < m_width; x += 8)
        {
            for (int y = 0; y < m_height; y += 8)
            {
                for (int yInner = 0; yInner < 8; yInner++)
                {
                    c2p.ChunkyToPlanar8Pixels(chunkyImage, x, y + yInner, planarData, 0, (tile * 8) + yInner);
                }
                tile++;
            }
        }

        return(planarData);
    }
Beispiel #13
0
    public void ExportAmiga( string _outfilename )
    {
        Debug.Log ("Exporting tile bank (Amiga) to " + _outfilename );

        int headersize = 0;

        int numTiles = m_tiles.Count;

        // Export size = number of tiles * 64 pixels / 2 (because there are 2 bytes per pixel)
        int outsize = headersize + (numTiles * 32); // 8*8 pixels, 8 bits per bytes/only 4 bits used
        byte[] outBytes = new byte[ outsize ];

        Debug.Log ("exporting " + numTiles + " tiles");
        //Halp.Write16( outBytes, 0, numTiles );

        int iTile;
        for( iTile=0; iTile<numTiles; iTile++ )
        {
            Tile t = m_tiles[ iTile ];

            ChunkyToPlanar c2p = new ChunkyToPlanar(0, 3, 8, 4, 1);
            for(int y=0; y<Tile.Height; y++ )
            {
                c2p.ChunkyToPlanar8Pixels(t.m_pixels, 0, y, outBytes, 0, iTile*8+y);
          	}
        }

        System.IO.File.WriteAllBytes( _outfilename, outBytes );
    }
    private byte[] ChunkyToPlanarTilesInterleaved(byte[] chunkyImage)
    {
        int chunkyStepPerRow = m_width;
        int planarStepPerRow = 4;
        int planarStepPerPlane = 1;
        //		Debug.Log ("chunkyStepPerRow: " + chunkyStepPerRow);
        //		Debug.Log ("planarStepPerRow: " + planarStepPerRow);
        //		Debug.Log ("planarStepPerPlane: " + planarStepPerPlane);
        ChunkyToPlanar c2p = new ChunkyToPlanar(0, 3, chunkyStepPerRow, planarStepPerRow, planarStepPerPlane);

        int planarDataSize = m_height * m_width * 4 / 8;
        byte[] planarData = new byte[planarDataSize];

        //			Debug.Log (m_height);
        //			Debug.Log (m_width);
        //			Debug.Log (m_numberOfBitPlanes);
        //			Debug.Log (planarDataSize);
        //			Debug.Log (chunkyYOffs);
        //			Debug.Log (yoffsPlane3);
        int tile = 0;
        for (int x = 0; x < m_width; x += 8)
        {
            for (int y = 0; y < m_height; y += 8)
            {
                for (int yInner = 0; yInner < 8; yInner++)
                {
                    c2p.ChunkyToPlanar8Pixels(chunkyImage, x, y + yInner, planarData, 0, (tile * 8) + yInner);
                }
                tile++;
            }
        }

        return planarData;
    }