示例#1
0
        private void drawDungeonItems()
        {
            Bitmap    bmp = new Bitmap(128, 128);
            FastPixel fp  = new FastPixel(bmp);

            fp.rgbValues = new byte[128 * 128 * 4];
            fp.Lock();
            for (int x = 0; x < 4; x++)
            {
                for (int y1 = 0; y1 < 8; y1++)
                {
                    for (int x1 = 0; x1 < 8; x1++)
                    {
                        if (x == 0)
                        {
                            fp.SetPixel(x1 + (x * 8), y1, chestPalette[graphicsData[0, x1, y1]]);
                        }
                        else if (x == 3)
                        {
                            fp.SetPixel(x1 + (x * 8), y1, Color.FromArgb(44, 50, 89));
                        }
                        else
                        {
                            fp.SetPixel(x1 + (x * 8), y1, bwPalette[graphicsData[x, x1, y1]]);
                        }
                    }
                }
            }
            fp.Unlock(true);
            pTiles.Image = bmp;
        }
示例#2
0
        private Bitmap drawOverworldTile()
        {
            MinimapLoader minimapLoader = new MinimapLoader(LAGame);

            byte[,,] graphicsData = minimapLoader.loadMinimapOverworld();

            Bitmap    bmp = new Bitmap(8, 8);
            FastPixel fp  = new FastPixel(bmp);

            fp.rgbValues = new byte[8 * 8 * 4];
            fp.Lock();

            byte i;

            for (int y = 0; y < 8; y++)
            {
                for (int x = 0; x < 8; x++)
                {
                    byte miniD = (byte)nTile.Value;
                    byte pal   = (byte)nPalette.Value;
                    if (miniD == 0x70 || miniD == 0x71 || miniD == 0x72 || miniD == 0x73 || miniD == 0x74 || miniD == 0x75)
                    {
                        i = (byte)(miniD - 0x66);
                    }
                    else
                    {
                        i = (byte)(miniD + 16);
                    }
                    fp.SetPixel(x, y, palette[pal, graphicsData[i, x, y]]);
                }
            }
            fp.Unlock(true);
            return(bmp);
        }
示例#3
0
        public Bitmap drawMap(Bitmap tiles, byte[] mapData)
        {
            Bitmap    bmp = new Bitmap(160, 128);
            FastPixel fp  = new FastPixel(bmp);
            FastPixel src = new FastPixel(tiles);

            fp.rgbValues  = new byte[160 * 128 * 4];
            src.rgbValues = new byte[256 * 256 * 4];
            fp.Lock();
            src.Lock();
            for (int y = 0; y < 8; y++)
            {
                for (int x = 0; x < 10; x++)
                {
                    byte v = mapData[x + (y * 10)];

                    for (int yy = 0; yy < 16; yy++)
                    {
                        for (int xx = 0; xx < 16; xx++)
                        {
                            fp.SetPixel(x * 16 + xx, y * 16 + yy, src.GetPixel((v % 16) * 16 + xx, (v / 16) * 16 + yy));
                        }
                    }
                }
            }
            fp.Unlock(true);
            src.Unlock(true);

            return(bmp);
        }
示例#4
0
        public Bitmap drawOverworldMinimapTiles(byte[,,] graphicsData, byte[] minimapGraphics, byte[] overworldPal, Color[,] palette)
        {
            Bitmap    bmp = new Bitmap(128, 128);
            FastPixel fp  = new FastPixel(bmp);

            fp.rgbValues = new byte[128 * 128 * 4];
            fp.Lock();
            byte i;

            for (int y = 0; y < 16; y++)
            {
                for (int x = 0; x < 16; x++)
                {
                    byte miniD = minimapGraphics[x + (y * 16)];
                    if (miniD == 0xFF || miniD == 0xFE || miniD == 0xFD || miniD == 0xFC || miniD == 0xFB || miniD == 0xFA)
                    {
                        i = (byte)(miniD - 0xF0);
                    }
                    else
                    {
                        i = (byte)(miniD + 16);
                    }
                    for (int y1 = 0; y1 < 8; y1++)
                    {
                        for (int x1 = 0; x1 < 8; x1++)
                        {
                            fp.SetPixel(x1 + (x * 8), y1 + (y * 8), palette[overworldPal[x + (y * 16)], graphicsData[i, x1, y1]]);
                        }
                    }
                }
            }
            fp.Unlock(true);
            return(bmp);
        }
示例#5
0
        public Bitmap DrawCollisions(Bitmap tiles, byte[] mapData, bool borders)
        {
            Bitmap    b   = new Bitmap(160, 128);
            FastPixel fp  = new FastPixel(b);
            FastPixel src = new FastPixel(tiles);

            src.rgbValues = new byte[256 * 256 * 4];
            fp.rgbValues  = new byte[160 * 128 * 4];
            fp.Lock();
            src.Lock();
            for (int y = 0; y < 8; y++)
            {
                for (int x = 0; x < 10; x++)
                {
                    byte id = mapData[x + (y * 10)];
                    for (int yy = 0; yy < 16; yy++)
                    {
                        for (int xx = 0; xx < 16; xx++)
                        {
                            fp.SetPixel(x * 16 + xx, y * 16 + yy, src.GetPixel((id % 16) * 16 + xx, (id / 16) * 16 + yy));
                        }
                    }
                }
            }
            fp.Unlock(true);
            src.Unlock(true);
            if (borders)
            {
                drawBorders(b);
            }
            return(b);
        }
示例#6
0
文件: Sprites.cs 项目: john-lay/LALE
        public Bitmap drawSelectedSprite(Image map, Object selected)
        {
            Bitmap    b  = (Bitmap)map;
            FastPixel fp = new FastPixel(b);

            fp.rgbValues = new byte[160 * 128 * 4];
            fp.Lock();
            if (selected.x > 9 || selected.y > 7)
            {
                fp.Unlock(true);
                return(b);
            }
            for (int yy = 0; yy < 16; yy++)
            {
                for (int xx = 0; xx < 16; xx++)
                {
                    int x = selected.x * 16;
                    int y = selected.y * 16;
                    if (xx == 0 || xx == 15)
                    {
                        if (xx == 0)
                        {
                            //  fp.SetPixel(x + (xx - 1), y + yy, Color.White);
                            fp.SetPixel(x + xx, y + yy, Color.White);
                        }
                        else if (xx == 15)
                        {
                            //    fp.SetPixel(x + (xx + 1), y + yy, Color.White);
                            fp.SetPixel(x + xx, y + yy, Color.White);
                        }
                    }
                    else
                    {
                        if (yy == 0)
                        {
                            //      fp.SetPixel(x + xx, y + (yy - 1), Color.White);
                            fp.SetPixel(x + xx, y + yy, Color.White);
                            //      if (xx == 0)
                            //         fp.SetPixel(x + (xx - 1), y + yy, Color.White);
                            //     else if (xx == 15)
                            //         fp.SetPixel(x + (xx + 1), y + yy, Color.White);
                        }
                        else if (yy == 15)
                        {
                            //    fp.SetPixel(x + xx, y + (yy + 1), Color.White);
                            fp.SetPixel(x + xx, y + yy, Color.White);
                            //     if (xx == 0)
                            //          fp.SetPixel(x + (xx - 1), y + yy, Color.White);
                            //     else if (xx == 15)
                            //       fp.SetPixel(x + (xx + 1), y + yy, Color.White);
                        }
                    }
                }
            }
            fp.Unlock(true);
            return(b);
        }
示例#7
0
        public Bitmap drawEntities(Bitmap image, List <Entity> entities)
        {
            FastPixel fp = new FastPixel(image);

            fp.rgbValues = new byte[160 * 128 * 4];
            fp.Lock();


            foreach (Entity selectedEntity in entities)
            {
                FastPixel src = new FastPixel(selectedEntity.sprite);
                src.rgbValues = new byte[16 * 16 * 4];
                src.Lock();

                int x = selectedEntity.xPos * 16;
                int y = selectedEntity.yPos * 16;

                if (selectedEntity.yPos < 8)
                {
                    if (selectedEntity.xPos < 10)
                    {
                        for (int yy = 0; yy < 16; yy++)
                        {
                            for (int xx = 0; xx < 16; xx++)
                            {
                                try
                                {
                                    if (src.GetPixel(xx, yy).A == 0)
                                    {
                                        continue;
                                    }
                                    fp.SetPixel(x + xx, y + yy, src.GetPixel(xx, yy));
                                }
                                catch
                                {
                                    System.Console.WriteLine("Out of bounds Y or X position.");
                                    break;
                                }
                            }
                        }
                    }
                }
                src.Unlock(true);
            }


            fp.Unlock(true);
            return(image);
        }
示例#8
0
        public Bitmap drawTileset(byte[, ,] graphicsData, Tile[] tiles)
        {
            Bitmap    bmp = new Bitmap(256, 256);
            FastPixel fp  = new FastPixel(bmp);

            fp.rgbValues          = new byte[256 * 256 * 4];
            byte[,] formationData = loadFormation();
            fp.Lock();
            for (int tile = 0; tile < 256; tile++)
            {
                for (int corner = 0; corner < 4; corner++)
                {
                    byte i = formationData[tile, corner];
                    Tile t = tiles[tile];
                    if (i >= 0xB0 && i < 0xB4 || i == 0xC0)
                    {
                        i -= i;
                    }

                    for (int y = 0; y < 8; y++)
                    {
                        for (int x = 0; x < 8; x++)
                        {
                            Color pal   = palette[t.palette[corner] % 8, graphicsData[(byte)(i + 0x10), x, y]];
                            int   mainX = (tile % 16) * 16;
                            int   mainY = (tile / 16) * 16;
                            int   xx    = mainX + ((corner % 2) * 8) + x;
                            int   yy    = mainY + ((corner / 2) * 8) + y;
                            if (t.hFlip[corner])
                            {
                                xx = mainX + ((corner % 2) * 8) + (7 - x);
                            }
                            if (t.vFlip[corner])
                            {
                                yy = mainY + ((corner / 2) * 8) + (7 - y);
                            }
                            fp.SetPixel(xx, yy, pal);
                        }
                    }
                }
            }
            fp.Unlock(true);
            return(bmp);
        }
示例#9
0
        public Bitmap drawDungeonMinimapTiles(byte[,,] graphicsData, byte[] minimapGraphics)
        {
            Color[] bwPalette    = new Color[] { Color.White, Color.LightGray, Color.FromArgb(44, 50, 89), Color.Black };
            Color[] chestPalette = new Color[] { Color.FromArgb(248, 248, 168), Color.FromArgb(216, 168, 32), Color.FromArgb(136, 80, 0), Color.Black };

            Bitmap    bmp = new Bitmap(128, 128);
            FastPixel fp  = new FastPixel(bmp);

            fp.rgbValues = new byte[128 * 128 * 4];
            fp.Lock();
            for (int y = 0; y < 8; y++)
            {
                for (int x = 0; x < 8; x++)
                {
                    byte miniD = minimapGraphics[x + (y * 8)];
                    for (int y1 = 0; y1 < 8; y1++)
                    {
                        for (int x1 = 0; x1 < 8; x1++)
                        {
                            if (miniD == 0xEF) //Regular room
                            {
                                fp.SetPixel(x1 + (x * 8), y1 + (y * 8), bwPalette[graphicsData[2, x1, y1]]);
                            }
                            else if (miniD == 0x7D) //Empty room
                            {
                                fp.SetPixel(x1 + (x * 8), y1 + (y * 8), Color.FromArgb(44, 50, 89));
                            }
                            else if (miniD == 0xED) //Chest room
                            {
                                fp.SetPixel(x1 + (x * 8), y1 + (y * 8), chestPalette[graphicsData[0, x1, y1]]);
                            }
                            else if (miniD == 0xEE) //Boss room
                            {
                                fp.SetPixel(x1 + (x * 8), y1 + (y * 8), bwPalette[graphicsData[1, x1, y1]]);
                            }
                        }
                    }
                }
            }
            fp.Unlock(true);
            return(bmp);
        }
示例#10
0
        public Bitmap drawSprites(int row)
        {
            Bitmap    bmp = new Bitmap(128, 8);
            FastPixel fp  = new FastPixel(bmp);

            fp.rgbValues = new byte[128 * 8 * 4];
            fp.Lock();
            for (int i = row * 16; i < (16 * (row + 1)); i++)
            {
                for (int y = 0; y < 8; y++)
                {
                    for (int x = 0; x < 8; x++)
                    {
                        fp.SetPixel(x + ((i % 16) * 8), y, bwPalette[spriteData[i, x, y]]);
                    }
                }
            }
            fp.Unlock(true);

            return(bmp);
        }
示例#11
0
文件: Sprites.cs 项目: john-lay/LALE
        public Bitmap DrawSprites(Bitmap map)
        {
            FastPixel fp = new FastPixel(map);

            fp.rgbValues = new byte[160 * 128 * 4];
            fp.Lock();
            foreach (Object obj in spriteList)
            {
                if (obj.x < 9 && obj.y < 8)
                {
                    for (int yy = 0; yy < 16; yy++)
                    {
                        for (int xx = 0; xx < 16; xx++)
                        {
                            fp.SetPixel((obj.x * 16) + xx, (obj.y * 16) + yy, Color.Black);
                        }
                    }
                }
            }
            fp.Unlock(true);
            return(map);
        }
示例#12
0
        private void drawOverworldItems()
        {
            MinimapLoader minimapLoader = new MinimapLoader(LAGame);

            byte[,,] graphicsData = minimapLoader.loadMinimapOverworld();

            Bitmap    bmp = new Bitmap(128, 64);
            FastPixel fp  = new FastPixel(bmp);

            fp.rgbValues = new byte[128 * 64 * 4];
            fp.Lock();
            int i = 0;

            for (int y = 1; y < 8; y++)
            {
                for (int x = 0; x < 16; x++)
                {
                    for (int y1 = 0; y1 < 8; y1++)
                    {
                        for (int x1 = 0; x1 < 8; x1++)
                        {
                            if (y == 7 && x < 6)
                            {
                                fp.SetPixel(x1 + (x * 8), y1 + ((y - 1) * 8), palette[(byte)nPalette.Value, graphicsData[x + (y * 16), x1, y1]]);
                                fp.SetPixel(x1 + (x * 8), y1 + (y * 8), palette[(byte)nPalette.Value, graphicsData[x + 10 + ((y - 7) * 16), x1, y1]]);
                            }
                            else
                            {
                                fp.SetPixel(x1 + (x * 8), y1 + ((y - 1) * 8), palette[(byte)nPalette.Value, graphicsData[x + (y * 16), x1, y1]]);
                            }
                        }
                    }

                    i++;
                }
            }
            fp.Unlock(true);
            gridBoxOverworldTile.Image = bmp;
        }
示例#13
0
        public Bitmap drawDungeonTiles(byte[, ,] graphicsData)
        {
            Bitmap    bmp = new Bitmap(128, 128);
            FastPixel fp  = new FastPixel(bmp);

            fp.rgbValues = new byte[128 * 128 * 4];
            fp.Lock();
            for (int y = 0; y < 8; y++)
            {
                for (int x = 0; x < 8; x++)
                {
                    byte miniD = minimapGraphics[x + (y * 8)];
                    for (int y1 = 0; y1 < 8; y1++)
                    {
                        for (int x1 = 0; x1 < 8; x1++)
                        {
                            if (miniD == 0xEF) //Regular room
                            {
                                fp.SetPixel(x1 + (x * 8), y1 + (y * 8), bwPalette[graphicsData[2, x1, y1]]);
                            }
                            else if (miniD == 0x7D) //Empty room
                            {
                                fp.SetPixel(x1 + (x * 8), y1 + (y * 8), Color.FromArgb(44, 50, 89));
                            }
                            else if (miniD == 0xED) //Chest room
                            {
                                fp.SetPixel(x1 + (x * 8), y1 + (y * 8), chestPalette[graphicsData[0, x1, y1]]);
                            }
                            else if (miniD == 0xEE) //Boss room
                            {
                                fp.SetPixel(x1 + (x * 8), y1 + (y * 8), bwPalette[graphicsData[1, x1, y1]]);
                            }
                        }
                    }
                }
            }
            fp.Unlock(true);
            return(bmp);
        }
示例#14
0
        public Bitmap drawSelectedEntity(Bitmap image, Entity selectedEntity)
        {
            FastPixel fp     = new FastPixel(image);
            Color     border = Color.White;

            fp.rgbValues = new byte[160 * 128 * 4];
            fp.Lock();

            int x = selectedEntity.xPos * 16;
            int y = selectedEntity.yPos * 16;

            if (selectedEntity.yPos < 8)
            {
                if (selectedEntity.xPos < 10)
                {
                    for (int yy = 0; yy < 16; yy++)
                    {
                        for (int xx = 0; xx < 16; xx++)
                        {
                            if (yy > 0 && yy != 15)
                            {
                                if (xx == 0 || xx == 15)
                                {
                                    fp.SetPixel(x + xx, y + yy, border);
                                }
                            }
                            else
                            {
                                fp.SetPixel(x + xx, y + yy, border);
                            }
                        }
                    }
                }
            }

            fp.Unlock(true);
            return(image);
        }
示例#15
0
        private void drawSprites()
        {
            byte[, ,] data = new byte[64, 8, 8];
            gb.ReadTiles(16, 4, spriteGraphics, ref data);

            Bitmap    bmp = new Bitmap(128, 32);
            FastPixel fp  = new FastPixel(bmp);

            fp.rgbValues = new byte[128 * 32 * 4];
            fp.Lock();
            for (int i = 0; i < 64; i++)
            {
                for (int y = 0; y < 8; y++)
                {
                    for (int x = 0; x < 8; x++)
                    {
                        fp.SetPixel(x + ((i % 16) * 8), y + ((i / 16) * 8), bwPalette[data[i, x, y]]);
                    }
                }
            }
            fp.Unlock(true);

            pBox.Image = bmp;
        }
示例#16
0
        public Bitmap drawBorders(Bitmap image)
        {
            FastPixel fp = new FastPixel(image);

            fp.rgbValues = new byte[160 * 128 * 4];
            fp.Lock();
            foreach (LAObject obj in objects)
            {
                int x = obj.x * 16;
                int y = obj.y * 16;
                if (obj.hFlip)
                {
                    x = -16;
                }
                if (obj.vFlip)
                {
                    y = -16;
                }
                bool v = false;
                bool h = false;
                if (!obj.is3Byte)
                {
                    if (obj.x > 9 || obj.y > 7)
                    {
                        continue;
                    }
                }
                if (!obj.is3Byte)
                {
                    if (obj.isEntrance || obj.isDoor1 || obj.isDoor2)
                    {
                        for (int yy = 0; yy < obj.h * 16; yy++)
                        {
                            for (int xx = 0; xx < obj.w * 16; xx++)
                            {
                                if (x < 0 && !h)
                                {
                                    xx = xx + 16;
                                    h  = true;
                                }
                                if (y < 0 && !v)
                                {
                                    yy = yy + 16;
                                    v  = true;
                                }
                                if (x + xx >= 160 || x + xx < 0)
                                {
                                    continue;
                                }
                                if (y + yy >= 128 || y + yy < 0)
                                {
                                    continue;
                                }
                                if (yy > 0 && yy != ((obj.h * 16) - 1))
                                {
                                    if (xx == 0 || xx == (obj.w * 16) - 1)
                                    {
                                        fp.SetPixel(x + xx, y + yy, Color.DeepPink);
                                    }
                                }
                                else
                                {
                                    fp.SetPixel(x + xx, y + yy, Color.DeepPink);
                                }
                            }
                        }
                    }
                    else
                    {
                        for (int yy = 0; yy < 16; yy++)
                        {
                            for (int xx = 0; xx < 16; xx++)
                            {
                                if (yy > 0 && yy != 15)
                                {
                                    if (xx == 0 || xx == 15)
                                    {
                                        fp.SetPixel(x + xx, y + yy, Color.DarkGreen);
                                    }
                                }
                                else
                                {
                                    fp.SetPixel(x + xx, y + yy, Color.DarkGreen);
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (!obj.isDoor1 || !obj.isDoor2 || !obj.isEntrance)
                    {
                        if (obj.direction == 8)
                        {
                            for (int yy = 0; yy < 16; yy++)
                            {
                                for (int xx = 0; xx < (obj.length * 16); xx++)
                                {
                                    if (x < 0 && !h)
                                    {
                                        xx = xx + 16;
                                        h  = true;
                                    }
                                    if (y < 0 && !v)
                                    {
                                        yy = yy + 16;
                                        v  = true;
                                    }
                                    if (x + xx >= 160 || x + xx < 0)
                                    {
                                        continue;
                                    }
                                    if (y + yy >= 128 || y + yy < 0)
                                    {
                                        continue;
                                    }
                                    if (yy > 0 && yy != 15)
                                    {
                                        if (xx == 0 || xx == (obj.length * 16) - 1)
                                        {
                                            fp.SetPixel(x + xx, y + yy, Color.DarkRed);
                                        }
                                    }
                                    else
                                    {
                                        fp.SetPixel(x + xx, y + yy, Color.DarkRed);
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (int yy = 0; yy < obj.length * 16; yy++)
                            {
                                for (int xx = 0; xx < 16; xx++)
                                {
                                    if (x < 0 && !h)
                                    {
                                        xx = xx + 16;
                                        h  = true;
                                    }
                                    if (y < 0 && !v)
                                    {
                                        yy = yy + 16;
                                        v  = true;
                                    }
                                    if (x + xx >= 160 || x + xx < 0)
                                    {
                                        continue;
                                    }
                                    if (y + yy >= 128 || y + yy < 0)
                                    {
                                        continue;
                                    }
                                    if (yy > 0 && yy != (obj.length * 16) - 1)
                                    {
                                        if (xx == 0 || xx == 15)
                                        {
                                            fp.SetPixel(x + xx, y + yy, Color.DarkBlue);
                                        }
                                    }
                                    else
                                    {
                                        fp.SetPixel(x + xx, y + yy, Color.DarkBlue);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (obj.direction == 8)
                        {
                            for (int i = 0; i < obj.length; i++)
                            {
                                for (int yy = 0; yy < obj.h * 16; yy++)
                                {
                                    for (int xx = 0 + (i * 16); xx < obj.w * (obj.length * 16); xx++)
                                    {
                                        if (x < 0 && !h)
                                        {
                                            xx = xx + 16;
                                            h  = true;
                                        }
                                        if (y < 0 && !v)
                                        {
                                            yy = yy + 16;
                                            v  = true;
                                        }
                                        if (x + xx >= 160 || x + xx < 0)
                                        {
                                            continue;
                                        }
                                        if (y + yy >= 128 || y + yy < 0)
                                        {
                                            continue;
                                        }
                                        if (yy > 0 && yy != ((obj.h * 16) - 1))
                                        {
                                            if (xx == 0 || xx == ((obj.length * 16) * obj.w) - 1)
                                            {
                                                fp.SetPixel(x + xx, y + yy, Color.DarkGoldenrod);
                                            }
                                        }
                                        else
                                        {
                                            fp.SetPixel(x + xx, y + yy, Color.DarkGoldenrod);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (int i = 0; i < obj.length; i++)
                            {
                                for (int yy = 0 + (i * 16); yy < obj.h * (obj.length * 16); yy++)
                                {
                                    for (int xx = 0; xx < obj.w * 16; xx++)
                                    {
                                        if (x < 0 && !h)
                                        {
                                            xx = xx + 16;
                                            h  = true;
                                        }
                                        if (y < 0 && !v)
                                        {
                                            yy = yy + 16;
                                            v  = true;
                                        }
                                        if (x + xx >= 160 || x + xx < 0)
                                        {
                                            continue;
                                        }
                                        if (y + yy >= 128 || y + yy < 0)
                                        {
                                            continue;
                                        }
                                        if (yy > 0 && yy != ((obj.length * 16) * obj.h) - 1)
                                        {
                                            if (xx == 0 || xx == obj.w * 16)
                                            {
                                                fp.SetPixel(x + xx, y + yy, Color.Purple);
                                            }
                                        }
                                        else
                                        {
                                            fp.SetPixel(x + xx, y + yy, Color.Purple);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            fp.Unlock(true);
            return(image);
        }
示例#17
0
        public Bitmap drawBorders(Bitmap image, List <CollisionObject> objects)
        {
            FastPixel fp = new FastPixel(image);
            Color     border;

            fp.rgbValues = new byte[160 * 128 * 4];
            fp.Lock();
            foreach (CollisionObject obj in objects)
            {
                if (obj.is3Byte && !obj.multiTileFlag && obj.direction == 8)
                {
                    border = Color.DarkRed;
                }
                else if (obj.is3Byte && !obj.multiTileFlag && obj.direction == 0xC)
                {
                    border = Color.DarkBlue;
                }
                else if (obj.is3Byte && obj.multiTileFlag && obj.direction == 8)
                {
                    border = Color.DarkGoldenrod;
                }
                else if (obj.is3Byte && obj.multiTileFlag && obj.direction == 0xC)
                {
                    border = Color.Purple;
                }
                else if (!obj.is3Byte && !obj.multiTileFlag)
                {
                    border = Color.DarkGreen;
                }
                else
                {
                    border = Color.DeepPink;
                }
                int x = obj.xPos * 16;
                int y = obj.yPos * 16;
                if (obj.hFlip)
                {
                    x = -16;
                }
                if (obj.vFlip)
                {
                    y = -16;
                }
                bool v = false;
                bool h = false;
                if (!obj.is3Byte && !obj.multiTileFlag)
                {
                    if (obj.xPos > 9 || obj.yPos > 7)
                    {
                        continue;
                    }
                }
                if (!obj.is3Byte)
                {
                    if (!obj.multiTileFlag)
                    {
                        for (int yy = 0; yy < 16; yy++)
                        {
                            for (int xx = 0; xx < 16; xx++)
                            {
                                if (yy > 0 && yy != 15)
                                {
                                    if (xx == 0 || xx == 15)
                                    {
                                        fp.SetPixel(x + xx, y + yy, border);
                                    }
                                }
                                else
                                {
                                    fp.SetPixel(x + xx, y + yy, border);
                                }
                            }
                        }
                    }
                    else
                    {
                        for (int yy = 0; yy < obj.height * 16; yy++)
                        {
                            for (int xx = 0; xx < obj.width * 16; xx++)
                            {
                                if (x < 0 && !h)
                                {
                                    xx = xx + 16;
                                    h  = true;
                                }
                                if (y < 0 && !v)
                                {
                                    yy = yy + 16;
                                    v  = true;
                                }
                                if (x + xx >= 160 || x + xx < 0)
                                {
                                    continue;
                                }
                                if (y + yy >= 128 || y + yy < 0)
                                {
                                    continue;
                                }
                                if (yy > 0 && yy != ((obj.height * 16) - 1))
                                {
                                    if (xx == 0 || xx == (obj.width * 16) - 1)
                                    {
                                        fp.SetPixel(x + xx, y + yy, border);
                                    }
                                }
                                else
                                {
                                    fp.SetPixel(x + xx, y + yy, border);
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (!obj.multiTileFlag)
                    {
                        if (obj.direction == 8)
                        {
                            for (int yy = 0; yy < 16; yy++)
                            {
                                for (int xx = 0; xx < (obj.length * 16); xx++)
                                {
                                    if (x < 0 && !h)
                                    {
                                        xx = xx + 16;
                                        h  = true;
                                    }
                                    if (y < 0 && !v)
                                    {
                                        yy = yy + 16;
                                        v  = true;
                                    }
                                    if (x + xx >= 160 || x + xx < 0)
                                    {
                                        continue;
                                    }
                                    if (y + yy >= 128 || y + yy < 0)
                                    {
                                        continue;
                                    }
                                    if (yy > 0 && yy != 15)
                                    {
                                        if (xx == 0 || xx == (obj.length * 16) - 1)
                                        {
                                            fp.SetPixel(x + xx, y + yy, border);
                                        }
                                    }
                                    else
                                    {
                                        fp.SetPixel(x + xx, y + yy, border);
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (int yy = 0; yy < obj.length * 16; yy++)
                            {
                                for (int xx = 0; xx < 16; xx++)
                                {
                                    if (x < 0 && !h)
                                    {
                                        xx = xx + 16;
                                        h  = true;
                                    }
                                    if (y < 0 && !v)
                                    {
                                        yy = yy + 16;
                                        v  = true;
                                    }
                                    if (x + xx >= 160 || x + xx < 0)
                                    {
                                        continue;
                                    }
                                    if (y + yy >= 128 || y + yy < 0)
                                    {
                                        continue;
                                    }
                                    if (yy > 0 && yy != (obj.length * 16) - 1)
                                    {
                                        if (xx == 0 || xx == 15)
                                        {
                                            fp.SetPixel(x + xx, y + yy, border);
                                        }
                                    }
                                    else
                                    {
                                        fp.SetPixel(x + xx, y + yy, border);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (obj.direction == 8)
                        {
                            for (int i = 0; i < obj.length; i++)
                            {
                                for (int yy = 0; yy < obj.height * 16; yy++)
                                {
                                    for (int xx = 0 + (i * 16); xx < obj.width * (obj.length * 16); xx++)
                                    {
                                        if (x < 0 && !h)
                                        {
                                            xx = xx + 16;
                                            h  = true;
                                        }
                                        if (y < 0 && !v)
                                        {
                                            yy = yy + 16;
                                            v  = true;
                                        }
                                        if (x + xx >= 160 || x + xx < 0)
                                        {
                                            continue;
                                        }
                                        if (y + yy >= 128 || y + yy < 0)
                                        {
                                            continue;
                                        }
                                        if (yy > 0 && yy != ((obj.height * 16) - 1))
                                        {
                                            if (xx == 0 || xx == ((obj.length * 16) * obj.width) - 1)
                                            {
                                                fp.SetPixel(x + xx, y + yy, border);
                                            }
                                        }
                                        else
                                        {
                                            fp.SetPixel(x + xx, y + yy, border);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (int i = 0; i < obj.length; i++)
                            {
                                for (int yy = 0 + (i * 16); yy < obj.height * (obj.length * 16); yy++)
                                {
                                    for (int xx = 0; xx < obj.width * 16; xx++)
                                    {
                                        if (x < 0 && !h)
                                        {
                                            xx = xx + 16;
                                            h  = true;
                                        }
                                        if (y < 0 && !v)
                                        {
                                            yy = yy + 16;
                                            v  = true;
                                        }
                                        if (x + xx >= 160 || x + xx < 0)
                                        {
                                            continue;
                                        }
                                        if (y + yy >= 128 || y + yy < 0)
                                        {
                                            continue;
                                        }
                                        if (yy > 0 && yy != ((obj.length * 16) * obj.height) - 1)
                                        {
                                            if (xx == 0 || xx == (obj.width * 16) - 1)
                                            {
                                                fp.SetPixel(x + xx, y + yy, border);
                                            }
                                        }
                                        else
                                        {
                                            fp.SetPixel(x + xx, y + yy, border);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            fp.Unlock(true);
            return(image);
        }
示例#18
0
        public Bitmap drawSpritePair16(byte[] tileData, byte entityTileOffset)
        {
            Bitmap    bmp = new Bitmap(16, 16);
            FastPixel fp  = new FastPixel(bmp);

            fp.rgbValues = new byte[16 * 16 * 4];
            fp.Lock();

            loadPalette();

            int ctr;

            if (tileData == null)
            {
                for (int yy = 0; yy < 16; yy++)
                {
                    for (int xx = 0; xx < 16; xx++)
                    {
                        fp.SetPixel(xx, yy, Color.Black);
                    }
                }
                fp.Unlock(true);

                return(bmp);
            }

            byte palOffset = 0;

            for (int i = 0; i < tileData.Length; i += 2)
            {
                palOffset = ((byte)(tileData[i + 1] & 0x0f));

                for (int y = 0; y < 8; y++)
                {
                    ctr = 7;
                    for (int x = 0; x < 8; x++)
                    {
                        if ((tileData[i + 1] & 0x60) == 0x60) //Y and X Flip
                        {
                            fp.SetPixel(x + ((i / 2) * 8), y, palette[palOffset, spriteData[tileData[i] + entityTileOffset - 0x40, ctr, ctr]]);
                            fp.SetPixel(x + ((i / 2) * 8), y + 8, palette[palOffset, spriteData[tileData[i] + 1 + entityTileOffset - 0x40, ctr, ctr]]);
                            ctr--;
                        }
                        else if ((tileData[i + 1] & 0x20) == 0x20)//X Flip
                        {
                            fp.SetPixel(x + ((i / 2) * 8), y, palette[palOffset, spriteData[tileData[i] + entityTileOffset - 0x40, ctr, y]]);
                            fp.SetPixel(x + ((i / 2) * 8), y + 8, palette[palOffset, spriteData[tileData[i] + 1 + entityTileOffset - 0x40, ctr, y]]);
                            ctr--;
                        }
                        else if ((tileData[i + 1] & 0x40) == 0x40)//Y Flip
                        {
                            fp.SetPixel(x + ((i / 2) * 8), y, palette[palOffset, spriteData[tileData[i] + entityTileOffset - 0x40, x, ctr]]);
                            fp.SetPixel(x + ((i / 2) * 8), y + 8, palette[palOffset, spriteData[tileData[i] + 1 + entityTileOffset - 0x40, x, ctr]]);
                            ctr--;
                        }
                        else //Normal
                        {
                            fp.SetPixel(x + ((i / 2) * 8), y, palette[palOffset, spriteData[tileData[i] + entityTileOffset - 0x40, x, y]]);
                            fp.SetPixel(x + ((i / 2) * 8), y + 8, palette[palOffset, spriteData[tileData[i] + 1 + entityTileOffset - 0x40, x, y]]);
                        }
                    }
                }
            }

            fp.Unlock(true);
            if (spriteBank != 0 || LAGame.dungeon == 0xFF)
            {
                bmp.MakeTransparent(palette[palOffset, 0]);
            }
            return(bmp);
        }
示例#19
0
        public Bitmap drawSelectedObject(Bitmap image, List <CollisionObject> collisionObjects, int selectedObjectIndex)
        {
            FastPixel fp     = new FastPixel(image);
            Color     border = Color.White;

            fp.rgbValues = new byte[160 * 128 * 4];
            fp.Lock();
            CollisionObject selected = collisionObjects[selectedObjectIndex];

            foreach (CollisionObject obj in collisionObjects)
            {
                if (obj.xPos != selected.xPos)
                {
                    continue;
                }
                if (obj.yPos != selected.yPos)
                {
                    continue;
                }
                if (obj.direction != selected.direction)
                {
                    continue;
                }
                if (obj.length != selected.length)
                {
                    continue;
                }
                if (obj.id != selected.id)
                {
                    continue;
                }
                int x = obj.xPos * 16;
                int y = obj.yPos * 16;
                if (obj.hFlip)
                {
                    x = -16;
                }
                if (obj.vFlip)
                {
                    y = -16;
                }
                bool v = false;
                bool h = false;
                if (!obj.is3Byte && !obj.multiTileFlag)
                {
                    if (obj.xPos > 9 || obj.yPos > 7)
                    {
                        continue;
                    }
                }
                if (!obj.is3Byte)
                {
                    if (!obj.multiTileFlag)
                    {
                        for (int yy = 0; yy < 16; yy++)
                        {
                            for (int xx = 0; xx < 16; xx++)
                            {
                                if (yy > 0 && yy != 15)
                                {
                                    if (xx == 0 || xx == 15)
                                    {
                                        fp.SetPixel(x + xx, y + yy, border);
                                    }
                                }
                                else
                                {
                                    fp.SetPixel(x + xx, y + yy, border);
                                }
                            }
                        }
                    }
                    else
                    {
                        for (int yy = 0; yy < obj.height * 16; yy++)
                        {
                            for (int xx = 0; xx < obj.width * 16; xx++)
                            {
                                if (x < 0 && !h)
                                {
                                    xx = xx + 16;
                                    h  = true;
                                }
                                if (y < 0 && !v)
                                {
                                    yy = yy + 16;
                                    v  = true;
                                }
                                if (x + xx >= 160 || x + xx < 0)
                                {
                                    continue;
                                }
                                if (y + yy >= 128 || y + yy < 0)
                                {
                                    continue;
                                }
                                if (yy > 0 && yy != ((obj.height * 16) - 1))
                                {
                                    if (xx == 0 || xx == (obj.width * 16) - 1)
                                    {
                                        fp.SetPixel(x + xx, y + yy, border);
                                    }
                                }
                                else
                                {
                                    fp.SetPixel(x + xx, y + yy, border);
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (!obj.multiTileFlag)
                    {
                        if (obj.direction == 8)
                        {
                            for (int yy = 0; yy < 16; yy++)
                            {
                                for (int xx = 0; xx < (obj.length * 16); xx++)
                                {
                                    if (x < 0 && !h)
                                    {
                                        xx = xx + 16;
                                        h  = true;
                                    }
                                    if (y < 0 && !v)
                                    {
                                        yy = yy + 16;
                                        v  = true;
                                    }
                                    if (x + xx >= 160 || x + xx < 0)
                                    {
                                        continue;
                                    }
                                    if (y + yy >= 128 || y + yy < 0)
                                    {
                                        continue;
                                    }
                                    if (yy > 0 && yy != 15)
                                    {
                                        if (xx == 0 || xx == (obj.length * 16) - 1)
                                        {
                                            fp.SetPixel(x + xx, y + yy, border);
                                        }
                                    }
                                    else
                                    {
                                        fp.SetPixel(x + xx, y + yy, border);
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (int yy = 0; yy < obj.length * 16; yy++)
                            {
                                for (int xx = 0; xx < 16; xx++)
                                {
                                    if (x < 0 && !h)
                                    {
                                        xx = xx + 16;
                                        h  = true;
                                    }
                                    if (y < 0 && !v)
                                    {
                                        yy = yy + 16;
                                        v  = true;
                                    }
                                    if (x + xx >= 160 || x + xx < 0)
                                    {
                                        continue;
                                    }
                                    if (y + yy >= 128 || y + yy < 0)
                                    {
                                        continue;
                                    }
                                    if (yy > 0 && yy != (obj.length * 16) - 1)
                                    {
                                        if (xx == 0 || xx == 15)
                                        {
                                            fp.SetPixel(x + xx, y + yy, border);
                                        }
                                    }
                                    else
                                    {
                                        fp.SetPixel(x + xx, y + yy, border);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (obj.direction == 8)
                        {
                            for (int i = 0; i < obj.length; i++)
                            {
                                for (int yy = 0; yy < obj.height * 16; yy++)
                                {
                                    for (int xx = 0 + (i * 16); xx < obj.width * (obj.length * 16); xx++)
                                    {
                                        if (x < 0 && !h)
                                        {
                                            xx = xx + 16;
                                            h  = true;
                                        }
                                        if (y < 0 && !v)
                                        {
                                            yy = yy + 16;
                                            v  = true;
                                        }
                                        if (x + xx >= 160 || x + xx < 0)
                                        {
                                            continue;
                                        }
                                        if (y + yy >= 128 || y + yy < 0)
                                        {
                                            continue;
                                        }
                                        if (yy > 0 && yy != ((obj.height * 16) - 1))
                                        {
                                            if (xx == 0 || xx == ((obj.length * 16) * obj.width) - 1)
                                            {
                                                fp.SetPixel(x + xx, y + yy, border);
                                            }
                                        }
                                        else
                                        {
                                            fp.SetPixel(x + xx, y + yy, border);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (int i = 0; i < obj.length; i++)
                            {
                                for (int yy = 0 + (i * 16); yy < obj.height * (obj.length * 16); yy++)
                                {
                                    for (int xx = 0; xx < obj.width * 16; xx++)
                                    {
                                        if (x < 0 && !h)
                                        {
                                            xx = xx + 16;
                                            h  = true;
                                        }
                                        if (y < 0 && !v)
                                        {
                                            yy = yy + 16;
                                            v  = true;
                                        }
                                        if (x + xx >= 160 || x + xx < 0)
                                        {
                                            continue;
                                        }
                                        if (y + yy >= 128 || y + yy < 0)
                                        {
                                            continue;
                                        }
                                        if (yy > 0 && yy != ((obj.length * 16) * obj.height) - 1)
                                        {
                                            if (xx == 0 || xx == (obj.width * 16) - 1)
                                            {
                                                fp.SetPixel(x + xx, y + yy, border);
                                            }
                                        }
                                        else
                                        {
                                            fp.SetPixel(x + xx, y + yy, border);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            fp.Unlock(true);
            return(image);
        }
示例#20
0
        public Bitmap drawSelectedObject(Bitmap image, LAObject selected)
        {
            Color     border = Color.White;
            FastPixel fp     = new FastPixel(image);

            fp.rgbValues = new byte[160 * 128 * 4];
            fp.Lock();
            foreach (LAObject obj in objects)
            {
                if (obj.x != selected.x)
                {
                    continue;
                }
                if (obj.y != selected.y)
                {
                    continue;
                }
                if (obj.direction != selected.direction)
                {
                    continue;
                }
                if (obj.length != selected.length)
                {
                    continue;
                }
                if (obj.id != selected.id)
                {
                    continue;
                }
                int x = obj.x * 16;
                int y = obj.y * 16;
                if (obj.hFlip)
                {
                    x = -16;
                }
                if (obj.vFlip)
                {
                    y = -16;
                }
                bool v = false;
                bool h = false;

                if (!obj.is3Byte)
                {
                    if (obj.x > 9 || obj.y > 7)
                    {
                        continue;
                    }
                }
                if (!obj.is3Byte)
                {
                    if (obj.isEntrance || obj.isDoor1 || obj.isDoor2)
                    {
                        for (int yy = 0; yy < obj.h * 16; yy++)
                        {
                            for (int xx = 0; xx < obj.w * 16; xx++)
                            {
                                if (x < 0 && !h)
                                {
                                    xx = xx + 16;
                                    h  = true;
                                }
                                if (y < 0 && !v)
                                {
                                    yy = yy + 16;
                                    v  = true;
                                }
                                if (x + xx >= 160 || x + xx < 0)
                                {
                                    continue;
                                }
                                if (y + yy >= 128 || y + yy < 0)
                                {
                                    continue;
                                }
                                if (yy > 0 && yy != ((obj.h * 16) - 1))
                                {
                                    if (xx == 0 || xx == (obj.w * 16) - 1)
                                    {
                                        fp.SetPixel(x + xx, y + yy, border);
                                    }
                                }
                                else
                                {
                                    fp.SetPixel(x + xx, y + yy, border);
                                }
                            }
                        }
                    }
                    else
                    {
                        for (int yy = 0; yy < 16; yy++)
                        {
                            for (int xx = 0; xx < 16; xx++)
                            {
                                if (yy > 0 && yy != 15)
                                {
                                    if (xx == 0 || xx == 15)
                                    {
                                        fp.SetPixel(x + xx, y + yy, border);
                                    }
                                }
                                else
                                {
                                    fp.SetPixel(x + xx, y + yy, border);
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (!obj.isDoor1 || !obj.isDoor2 || !obj.isEntrance)
                    {
                        if (obj.direction == 8)
                        {
                            for (int yy = 0; yy < 16; yy++)
                            {
                                for (int xx = 0; xx < (obj.length * 16); xx++)
                                {
                                    if (x < 0 && !h)
                                    {
                                        xx = xx + 16;
                                        h  = true;
                                    }
                                    if (y < 0 && !v)
                                    {
                                        yy = yy + 16;
                                        v  = true;
                                    }
                                    if (x + xx >= 160 || x + xx < 0)
                                    {
                                        continue;
                                    }
                                    if (y + yy >= 128 || y + yy < 0)
                                    {
                                        continue;
                                    }
                                    if (yy > 0 && yy != 15)
                                    {
                                        if (xx == 0 || xx == (obj.length * 16) - 1)
                                        {
                                            fp.SetPixel(x + xx, y + yy, border);
                                        }
                                    }
                                    else
                                    {
                                        fp.SetPixel(x + xx, y + yy, border);
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (int yy = 0; yy < obj.length * 16; yy++)
                            {
                                for (int xx = 0; xx < 16; xx++)
                                {
                                    if (x < 0 && !h)
                                    {
                                        xx = xx + 16;
                                        h  = true;
                                    }
                                    if (y < 0 && !v)
                                    {
                                        yy = yy + 16;
                                        v  = true;
                                    }
                                    if (x + xx >= 160 || x + xx < 0)
                                    {
                                        continue;
                                    }
                                    if (y + yy >= 128 || y + yy < 0)
                                    {
                                        continue;
                                    }
                                    if (yy > 0 && yy != (obj.length * 16) - 1)
                                    {
                                        if (xx == 0 || xx == 15)
                                        {
                                            fp.SetPixel(x + xx, y + yy, border);
                                        }
                                    }
                                    else
                                    {
                                        fp.SetPixel(x + xx, y + yy, border);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (obj.direction == 8)
                        {
                            for (int i = 0; i < obj.length; i++)
                            {
                                for (int yy = 0; yy < obj.h * 16; yy++)
                                {
                                    for (int xx = 0 + (i * 16); xx < obj.w * (obj.length * 16); xx++)
                                    {
                                        if (x < 0 && !h)
                                        {
                                            xx = xx + 16;
                                            h  = true;
                                        }
                                        if (y < 0 && !v)
                                        {
                                            yy = yy + 16;
                                            v  = true;
                                        }
                                        if (x + xx >= 160 || x + xx < 0)
                                        {
                                            continue;
                                        }
                                        if (y + yy >= 128 || y + yy < 0)
                                        {
                                            continue;
                                        }
                                        if (yy > 0 && yy != ((obj.h * 16) - 1))
                                        {
                                            if (xx == 0 || xx == ((obj.length * 16) * obj.w) - 1)
                                            {
                                                fp.SetPixel(x + xx, y + yy, border);
                                            }
                                        }
                                        else
                                        {
                                            fp.SetPixel(x + xx, y + yy, border);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (int i = 0; i < obj.length; i++)
                            {
                                for (int yy = 0 + (i * 16); yy < obj.h * (obj.length * 16); yy++)
                                {
                                    for (int xx = 0; xx < obj.w * 16; xx++)
                                    {
                                        if (x < 0 && !h)
                                        {
                                            xx = xx + 16;
                                            h  = true;
                                        }
                                        if (y < 0 && !v)
                                        {
                                            yy = yy + 16;
                                            v  = true;
                                        }
                                        if (x + xx >= 160 || x + xx < 0)
                                        {
                                            continue;
                                        }
                                        if (y + yy >= 128 || y + yy < 0)
                                        {
                                            continue;
                                        }
                                        if (yy > 0 && yy != ((obj.length * 16) * obj.h) - 1)
                                        {
                                            if (xx == 0 || xx == obj.w * 16)
                                            {
                                                fp.SetPixel(x + xx, y + yy, border);
                                            }
                                        }
                                        else
                                        {
                                            fp.SetPixel(x + xx, y + yy, border);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            fp.Unlock(true);
            return(image);
        }
示例#21
0
        private void nAddress_ValueChanged(object sender, EventArgs e)
        {
            tTextBox.Clear();
            pText.Image       = null;
            cQuestion.Enabled = true;
            cQuestion.Checked = false;
            int index;

            textLoc           = (int)nAddress.Value;
            gb.BufferLocation = textLoc;
            int  i = 0;
            byte h = gb.ReadByte();

            while (h != 0xFF)
            {
                i++;
                h = gb.ReadByte();
                if (h == 0xFE)
                {
                    break;
                }
            }

            int length = i;

            if (length != 0)
            {
                textASCII = new byte[i];
                if (length % 16 != 0)
                {
                    int add = 16 - (length % 16);
                    i        += add;
                    textBytes = new byte[0x10 * i];
                    for (int black = 0; black < (add * 0x10); black++)
                    {
                        textBytes[(length * 0x10) + black] = 0xFF;
                    }
                    length = i;
                }
                else
                {
                    textBytes = new byte[0x10 * i];
                }
                i = 0;
                int g;
                gb.BufferLocation = textLoc;
                h = gb.ReadByte();
                while (h != 0xFF)
                {
                    if (h == 0xFE)
                    {
                        cQuestion.Checked = true;
                        break;
                    }
                    textASCII[i] = h;
                    if (h == 0x20)
                    {
                        for (int i2 = 0; i2 < 0x10; i2++)
                        {
                            textBytes[(i * 0x10) + i2] = 0xFF;
                        }
                        i++;
                        h = gb.ReadByte();
                        continue;
                    }
                    g = (gb.ReadByte(0x70641 + h) << 4);
                    gb.BufferLocation = g + 0x3D000;
                    for (int i2 = 0; i2 < 0x10; i2++)
                    {
                        textBytes[(i * 0x10) + i2] = gb.ReadByte();
                    }
                    i++;
                    gb.BufferLocation = textLoc + i;
                    h = gb.ReadByte();
                }

                byte[, ,] data = new byte[length, 8, 8];
                gb.ReadTiles(16, length / 16, textBytes, ref data);
                Bitmap    bmp = new Bitmap(128, length / 2);
                FastPixel fp  = new FastPixel(bmp);
                fp.rgbValues = new byte[128 * (length / 2) * 4];
                fp.Lock();
                for (int q = 0; q < length; q++)
                {
                    for (int y = 0; y < 8; y++)
                    {
                        for (int x = 0; x < 8; x++)
                        {
                            fp.SetPixel(x + ((q % 16) * 8), y + ((q / 16) * 8), bwPalette[data[q, x, y]]);
                        }
                    }
                }
                fp.Unlock(true);

                pText.Image = bmp;

                StringBuilder builder = new StringBuilder();
                for (int s = 0; s < i; s++)
                {
                    if ((textASCII[s] >> 4) > 7)
                    {
                        builder.Append('#');
                        builder.Append(hexChar[textASCII[s] >> 4]);
                        builder.Append(hexChar[textASCII[s] & 0xF]);
                        continue;
                    }
                    builder.Append((char)textASCII[s]);
                }
                tTextBox.Text = builder.ToString();
            }
            else
            {
                pText.Image = null;
            }
            try
            {
                index           = textAddresses.FindIndex(item => item == textLoc);
                nTextBank.Value = index;
            }
            catch
            {
                ;
            }
        }
示例#22
0
        private void tTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                e.SuppressKeyPress = true;
                pText.Image        = null;
                int index = 0;
                int skip  = 0;
                int r     = 0;
                textASCII = new byte[tTextBox.Text.Length];
                foreach (char c in tTextBox.Text)
                {
                    if (c == '#')
                    {
                        if (index + 1 != textASCII.Length)
                        {
                            char ch = tTextBox.Text[index + r + 1];
                            if (Array.IndexOf(hexChar, ch) != -1 && Array.IndexOf(hexChar, tTextBox.Text[index + r + 2]) != -1)
                            {
                                int b1 = Array.IndexOf(hexChar, ch);
                                int b2 = Array.IndexOf(hexChar, tTextBox.Text[index + r + 2]);
                                int b  = ((b1 << 4) + b2);
                                textASCII[index] = (byte)b;
                                r += 2;
                                byte[] textASCIIp = new byte[tTextBox.Text.Length - r];
                                skip = 2;
                                Array.Copy(textASCII, textASCIIp, tTextBox.Text.Length - r);
                                textASCII = textASCIIp;
                                index++;
                                continue;
                            }
                        }
                    }
                    if (skip != 0)
                    {
                        skip--;
                        continue;
                    }
                    textASCII[index] = Convert.ToByte(c);
                    index++;
                }
                int i      = textASCII.Length;
                int length = i;
                if (length != 0)
                {
                    if (length % 16 != 0)
                    {
                        int add = 16 - (length % 16);
                        i        += add;
                        textBytes = new byte[0x10 * i];
                        for (int black = 0; black < (add * 0x10); black++)
                        {
                            textBytes[(length * 0x10) + black] = 0xFF;
                        }
                        length = i;
                    }
                    else
                    {
                        textBytes = new byte[0x10 * i];
                    }

                    i = 0;
                    int g;

                    foreach (byte q in textASCII)
                    {
                        if (q == 0x20)
                        {
                            for (int i2 = 0; i2 < 0x10; i2++)
                            {
                                textBytes[(i * 0x10) + i2] = 0xFF;
                            }
                            i++;
                            continue;
                        }
                        g = (gb.ReadByte(0x70641 + q) << 4);
                        gb.BufferLocation = g + 0x3D000;
                        for (int i2 = 0; i2 < 0x10; i2++)
                        {
                            textBytes[(i * 0x10) + i2] = gb.ReadByte();
                        }
                        i++;
                        gb.BufferLocation = textLoc + i;
                    }

                    byte[, ,] data = new byte[length, 8, 8];
                    gb.ReadTiles(16, length / 16, textBytes, ref data);
                    Bitmap    bmp = new Bitmap(128, length / 2);
                    FastPixel fp  = new FastPixel(bmp);
                    fp.rgbValues = new byte[128 * (length / 2) * 4];
                    fp.Lock();
                    for (int q = 0; q < length; q++)
                    {
                        for (int y = 0; y < 8; y++)
                        {
                            for (int x = 0; x < 8; x++)
                            {
                                fp.SetPixel(x + ((q % 16) * 8), y + ((q / 16) * 8), bwPalette[data[q, x, y]]);
                            }
                        }
                    }
                    fp.Unlock(true);

                    pText.Image = bmp;
                }
                else
                {
                    pText.Image = null;
                }
            }
        }