예제 #1
0
        /// <param name="data">Data</param>
        /// <param name="addr">Data address</param>
        /// <param name="bytemap">Bytemap</param>
        /// <param name="px">Bytemap position X</param>
        /// <param name="py">Bytemap position Y</param>
        public override void ConvertChrToMem(Byte[] data, int addr, Bytemap bytemap, int px, int py)
        {
            // Convert back to the Neo Geo's 4bpp linear mixed columns format.

            for (int x = 0; x < CharWidth; x++)
            {
                int tileAddr = addr;                            // set base address

                for (int y = 0; y < CharHeight; y++)
                {
                    // encode this tile.

                    // fallthrough is intentional.
                    switch (x)
                    {
                    case 0:
                    case 1:
                        tileAddr = addr + ColDataOffsets[0] + y;
                        break;

                    case 2:
                    case 3:
                        tileAddr = addr + ColDataOffsets[1] + y;
                        break;

                    case 4:
                    case 5:
                        tileAddr = addr + ColDataOffsets[2] + y;
                        break;

                    case 6:
                    case 7:
                        tileAddr = addr + ColDataOffsets[3] + y;
                        break;
                    }

                    // bmValue for current pixel.
                    Point p       = base.GetAdvancePixelPoint(px + x, py + y);
                    int   bmAddr  = bytemap.GetPointAddress(p.X, p.Y);
                    byte  bmValue = bytemap.Data[bmAddr];

                    // combine the data
                    int c0, outVal;
                    int curData = data[tileAddr];
                    if (x % 2 == 0)
                    {
                        // even column (0x0F)
                        c0     = (byte)(bmValue & 0x0F);
                        outVal = (byte)((curData & 0xF0) | c0);
                    }
                    else
                    {
                        // odd column (0xF0)
                        c0     = (byte)(bmValue & 0x0F);
                        outVal = (byte)((c0 << 4) | (curData & 0x0F));
                    }
                    data[tileAddr] = (byte)outVal;
                }
            }
        }
예제 #2
0
        //for displaying
        public override void ConvertMemToChr(Byte[] data, int addr, Bytemap bytemap, int px, int py)
        {
            for (int i = 0; i < base.CharHeight; i++)
            {
                int  index = (i * 16) + addr;
                byte num1  = data[index];
                byte num2  = data[index + 1];
                byte num3  = data[index + 2];
                byte num4  = data[index + 3];
                byte num5  = data[index + 4];
                byte num6  = data[index + 5];
                byte num7  = data[index + 6];
                byte num8  = data[index + 7];
                byte num1a = data[index + 8];
                byte num2a = data[index + 9];
                byte num3a = data[index + 10];
                byte num4a = data[index + 11];
                byte num5a = data[index + 12];
                byte num6a = data[index + 13];
                byte num7a = data[index + 14];
                byte num8a = data[index + 15];

                int pointAddress = bytemap.GetPointAddress(px, py + i);
                for (int j = 0; j < 8; j++)
                {
                    byte num9  = (byte)((num2 >> (7 - j)) & 1);
                    byte num10 = (byte)((num4 >> (7 - j)) & 1);
                    byte num11 = (byte)((num6 >> (7 - j)) & 1);
                    byte num12 = (byte)((num8 >> (7 - j)) & 1);
                    bytemap.Data[pointAddress++] = (byte)((((num12 << 3) | (num11 << 2)) | (num10 << 1)) | num9);
                }
                for (int k = 0; k < 8; k++)
                {
                    byte num13 = (byte)((num1 >> (7 - k)) & 1);
                    byte num14 = (byte)((num3 >> (7 - k)) & 1);
                    byte num15 = (byte)((num5 >> (7 - k)) & 1);
                    byte num16 = (byte)((num7 >> (7 - k)) & 1);
                    bytemap.Data[pointAddress++] = (byte)((((num16 << 3) | (num15 << 2)) | (num14 << 1)) | num13);
                }
                for (int j = 0; j < 8; j++)
                {
                    byte num9  = (byte)((num2a >> (7 - j)) & 1);
                    byte num10 = (byte)((num4a >> (7 - j)) & 1);
                    byte num11 = (byte)((num6a >> (7 - j)) & 1);
                    byte num12 = (byte)((num8a >> (7 - j)) & 1);
                    bytemap.Data[pointAddress++] = (byte)((((num12 << 3) | (num11 << 2)) | (num10 << 1)) | num9);
                }
                for (int k = 0; k < 8; k++)
                {
                    byte num13 = (byte)((num1a >> (7 - k)) & 1);
                    byte num14 = (byte)((num3a >> (7 - k)) & 1);
                    byte num15 = (byte)((num5a >> (7 - k)) & 1);
                    byte num16 = (byte)((num7a >> (7 - k)) & 1);
                    bytemap.Data[pointAddress++] = (byte)((((num16 << 3) | (num15 << 2)) | (num14 << 1)) | num13);
                }
            }
        }
예제 #3
0
        //for editing
        public override void ConvertChrToMem(Byte[] data, int addr, Bytemap bytemap, int px, int py)
        {
            for (int i = 0; i < base.CharHeight; i++)
            {
                int  index        = (i * 16) + addr;
                int  pointAddress = bytemap.GetPointAddress(px, py + i);
                byte num1         = 0;
                byte num2         = 0;
                byte num3         = 0;
                byte num4         = 0;
                for (int j = 0; j < 8; j++)
                {
                    byte num9  = (byte)(bytemap.Data[pointAddress++]);
                    byte num20 = (byte)(num9 & 1);
                    byte num21 = (byte)((num9 >> 1) & 1);
                    byte num22 = (byte)((num9 >> 2) & 1);
                    byte num23 = (byte)((num9 >> 3) & 1);
                    num1 = (byte)(num1 | ((byte)(num20 << (7 - j))));
                    num2 = (byte)(num2 | ((byte)(num21 << (7 - j))));
                    num3 = (byte)(num3 | ((byte)(num22 << (7 - j))));
                    num4 = (byte)(num4 | ((byte)(num23 << (7 - j))));
                }
                byte num5 = 0;
                byte num6 = 0;
                byte num7 = 0;
                byte num8 = 0;
                for (int k = 0; k < 8; k++)
                {
                    byte num10 = (byte)(bytemap.Data[pointAddress++]);
                    byte num25 = (byte)(num10 & 1);
                    byte num26 = (byte)((num10 >> 1) & 1);
                    byte num27 = (byte)((num10 >> 2) & 1);
                    byte num28 = (byte)((num10 >> 3) & 1);
                    num5 = (byte)(num5 | ((byte)(num25 << (7 - k))));
                    num6 = (byte)(num6 | ((byte)(num26 << (7 - k))));
                    num7 = (byte)(num7 | ((byte)(num27 << (7 - k))));
                    num8 = (byte)(num8 | ((byte)(num28 << (7 - k))));
                }

                byte num1a = 0;
                byte num2a = 0;
                byte num3a = 0;
                byte num4a = 0;
                for (int j = 0; j < 8; j++)
                {
                    byte num9  = (byte)(bytemap.Data[pointAddress++]);
                    byte num20 = (byte)(num9 & 1);
                    byte num21 = (byte)((num9 >> 1) & 1);
                    byte num22 = (byte)((num9 >> 2) & 1);
                    byte num23 = (byte)((num9 >> 3) & 1);
                    num1a = (byte)(num1a | ((byte)(num20 << (7 - j))));
                    num2a = (byte)(num2a | ((byte)(num21 << (7 - j))));
                    num3a = (byte)(num3a | ((byte)(num22 << (7 - j))));
                    num4a = (byte)(num4a | ((byte)(num23 << (7 - j))));
                }

                byte num5a = 0;
                byte num6a = 0;
                byte num7a = 0;
                byte num8a = 0;
                for (int k = 0; k < 8; k++)
                {
                    byte num10 = (byte)(bytemap.Data[pointAddress++]);
                    byte num25 = (byte)(num10 & 1);
                    byte num26 = (byte)((num10 >> 1) & 1);
                    byte num27 = (byte)((num10 >> 2) & 1);
                    byte num28 = (byte)((num10 >> 3) & 1);
                    num5a = (byte)(num5a | ((byte)(num25 << (7 - k))));
                    num6a = (byte)(num6a | ((byte)(num26 << (7 - k))));
                    num7a = (byte)(num7a | ((byte)(num27 << (7 - k))));
                    num8a = (byte)(num8a | ((byte)(num28 << (7 - k))));
                }

                data[index]     = num5;
                data[index + 1] = num1;
                data[index + 2] = num6;
                data[index + 3] = num2;
                data[index + 4] = num7;
                data[index + 5] = num3;
                data[index + 6] = num8;
                data[index + 7] = num4;

                data[index + 8]  = num5a;
                data[index + 9]  = num1a;
                data[index + 10] = num6a;
                data[index + 11] = num2a;
                data[index + 12] = num7a;
                data[index + 13] = num3a;
                data[index + 14] = num8a;
                data[index + 15] = num4a;
            }
        }
예제 #4
0
        /// <param name="data">Data</param>
        /// <param name="addr">Data address</param>
        /// <param name="bytemap">Bytemap</param>
        /// <param name="px">Bytemap position X</param>
        /// <param name="py">Bytemap position Y</param>
        public override void ConvertMemToChr(Byte[] data, int addr, Bytemap bytemap, int px, int py)
        {
            // Convert the 4bpp linear, mixed columns data:

            /* ----------------------- LR LR LR LR LR LR LR LR
             * data 1 x8 (columns 5,4) 54 54 54 54 54 54 54 54
             * data 2 x8 (columns 7,6) 76 76 76 76 76 76 76 76
             * data 3 x8 (columns 1,0) 10 10 10 10 10 10 10 10
             * data 4 x8 (columns 3,2) 32 32 32 32 32 32 32 32
             */

            // one row of fix data consists of reading the bytes of:
            // data 3, data 4, data 1, and data 2, in that order.

            // dat1 dat2 dat3 dat4
            // 0x00,0x08,0x10,0x18 <- tile 1/8 (y=0)
            // 0x01,0x09,0x11,0x19 <- tile 2/8 (y=1)
            // 0x02,0x0A,0x12,0x1A <- tile 3/8 (y=2)
            // 0x03,0x0B,0x13,0x1B <- tile 4/8 (y=3)
            // 0x04,0x0C,0x14,0x1C <- tile 5/8 (y=4)
            // 0x05,0x0D,0x15,0x1D <- tile 6/8 (y=5)
            // 0x06,0x0E,0x16,0x1E <- tile 7/8 (y=6)
            // 0x07,0x0F,0x17,0x1F <- tile 8/8 (y=7)

            for (int x = 0; x < CharWidth; x++)
            {
                // each group of bytes defines a column.
                for (int y = 0; y < CharHeight; y++)
                {
                    // decode this tile.
                    int  tileAddr = addr;                       // set base address
                    byte pixByte  = 0x00;

                    // the base address for this pixel depends on the X and Y values.
                    switch (x)
                    {
                    case 0:                                     // column 0: ColDataOffsets[0], data 3, mask 0x0F
                        tileAddr = addr + ColDataOffsets[0] + y;
                        pixByte  = (byte)(data[tileAddr] & 0x0F);
                        break;

                    case 1:                                     // column 1: ColDataOffsets[0], data 3, mask 0xF0
                        tileAddr = addr + ColDataOffsets[0] + y;
                        pixByte  = (byte)((data[tileAddr] & 0xF0) >> 4);
                        break;

                    case 2:                                     // column 2: ColDataOffsets[1], data 4, mask 0x0F
                        tileAddr = addr + ColDataOffsets[1] + y;
                        pixByte  = (byte)(data[tileAddr] & 0x0F);
                        break;

                    case 3:                                     // column 3: ColDataOffsets[1], data 4, mask 0xF0
                        tileAddr = addr + ColDataOffsets[1] + y;
                        pixByte  = (byte)((data[tileAddr] & 0xF0) >> 4);
                        break;

                    case 4:                                     // column 4: ColDataOffsets[2], data 1, mask 0x0F
                        tileAddr = addr + ColDataOffsets[2] + y;
                        pixByte  = (byte)(data[tileAddr] & 0x0F);
                        break;

                    case 5:                                     // column 5: ColDataOffsets[2], data 1, mask 0xF0
                        tileAddr = addr + ColDataOffsets[2] + y;
                        pixByte  = (byte)((data[tileAddr] & 0xF0) >> 4);
                        break;

                    case 6:                                     // column 6: ColDataOffsets[3], data 2, mask 0x0F
                        tileAddr = addr + ColDataOffsets[3] + y;
                        pixByte  = (byte)(data[tileAddr] & 0x0F);
                        break;

                    case 7:                                     // column 7: ColDataOffsets[3], data 2, mask 0xF0
                        tileAddr = addr + ColDataOffsets[3] + y;
                        pixByte  = (byte)((data[tileAddr] & 0xF0) >> 4);
                        break;
                    }

                    Point p           = base.GetAdvancePixelPoint(px + x, py + y);
                    int   bytemapAddr = bytemap.GetPointAddress(p.X, p.Y);
                    bytemap.Data[bytemapAddr] = pixByte;
                }
            }
        }