public bool ExportToBuffer(out GR.Memory.ByteBuffer CharData, out GR.Memory.ByteBuffer ColorData, out GR.Memory.ByteBuffer CharSetData, int X, int Y, int Width, int Height, bool RowByRow)
        {
            CharData  = new GR.Memory.ByteBuffer();
            ColorData = new GR.Memory.ByteBuffer();

            CharSetData = new GR.Memory.ByteBuffer(CharSet.CharacterData());

            int numBytesPerChar = Lookup.NumBytesOfSingleCharacter(Lookup.TextCharModeFromTextMode(Mode));

            if (RowByRow)
            {
                // row by row
                for (int i = 0; i < Height; ++i)
                {
                    for (int x = 0; x < Width; ++x)
                    {
                        byte   newColor = (byte)((Chars[(Y + i) * ScreenWidth + X + x] & 0xff0000) >> 16);
                        ushort newChar  = (ushort)(Chars[(Y + i) * ScreenWidth + X + x] & 0xffff);

                        if (numBytesPerChar == 2)
                        {
                            CharData.AppendU16(newChar);
                        }
                        else
                        {
                            CharData.AppendU8((byte)newChar);
                        }
                        if (Lookup.TextModeUsesColor(Mode))
                        {
                            ColorData.AppendU8(newColor);
                        }
                    }
                }
            }
            else
            {
                for (int x = 0; x < Width; ++x)
                {
                    for (int i = 0; i < Height; ++i)
                    {
                        byte   newColor = (byte)((Chars[(Y + i) * ScreenWidth + X + x] & 0xff0000) >> 16);
                        ushort newChar  = (ushort)(Chars[(Y + i) * ScreenWidth + X + x] & 0xffff);

                        if (numBytesPerChar == 2)
                        {
                            CharData.AppendU16(newChar);
                        }
                        else
                        {
                            CharData.AppendU8((byte)newChar);
                        }
                        if (Lookup.TextModeUsesColor(Mode))
                        {
                            ColorData.AppendU8(newColor);
                        }
                    }
                }
            }
            return(true);
        }
Beispiel #2
0
        public bool ExportToBuffer(out GR.Memory.ByteBuffer CharData, out GR.Memory.ByteBuffer ColorData, out GR.Memory.ByteBuffer CharSetData, int X, int Y, int Width, int Height, bool RowByRow)
        {
            CharData  = new GR.Memory.ByteBuffer();
            ColorData = new GR.Memory.ByteBuffer();

            CharSetData = new GR.Memory.ByteBuffer(CharSet.CharacterData());

            if (RowByRow)
            {
                // row by row
                for (int i = 0; i < Height; ++i)
                {
                    for (int x = 0; x < Width; ++x)
                    {
                        byte newColor = (byte)((Chars[(Y + i) * ScreenWidth + X + x] & 0xff00) >> 8);
                        byte newChar  = (byte)(Chars[(Y + i) * ScreenWidth + X + x] & 0xff);

                        CharData.AppendU8(newChar);
                        ColorData.AppendU8(newColor);
                    }
                }
            }
            else
            {
                for (int x = 0; x < Width; ++x)
                {
                    for (int i = 0; i < Height; ++i)
                    {
                        byte newColor = (byte)((Chars[(Y + i) * ScreenWidth + X + x] & 0xff00) >> 8);
                        byte newChar  = (byte)(Chars[(Y + i) * ScreenWidth + X + x] & 0xff);

                        CharData.AppendU8(newChar);
                        ColorData.AppendU8(newColor);
                    }
                }
            }
            return(true);
        }
Beispiel #3
0
        public bool ExportToBuffer(ExportCharsetScreenInfo Info)
        {
            Info.ScreenCharData  = new GR.Memory.ByteBuffer();
            Info.ScreenColorData = new GR.Memory.ByteBuffer();
            Info.CharsetData     = new GR.Memory.ByteBuffer(CharSet.CharacterData());

            int numBytesPerChar = Lookup.NumBytesOfSingleCharacter(Lookup.TextCharModeFromTextMode(Mode));

            // NCM mode, one character covers two "slots"
            if ((Mode == TextMode.MEGA65_40_X_25_NCM) ||
                (Mode == TextMode.MEGA65_80_X_25_NCM))
            {
                Info.Area.X     = (Info.Area.X + 1) / 2;
                Info.Area.Width = (Info.Area.Width / 2);
            }

            if (Info.RowByRow)
            {
                // row by row
                for (int i = 0; i < Info.Area.Height; ++i)
                {
                    for (int x = 0; x < Info.Area.Width; ++x)
                    {
                        byte   newColor = (byte)ColorAt(Info.Area.X + x, Info.Area.Y + i);
                        ushort newChar  = CharacterAt(Info.Area.X + x, Info.Area.Y + i);

                        newChar = (ushort)(newChar + CharOffset);

                        if (numBytesPerChar == 2)
                        {
                            Info.ScreenCharData.AppendU16(newChar);
                        }
                        else
                        {
                            Info.ScreenCharData.AppendU8((byte)newChar);
                        }
                        if (Lookup.TextModeUsesColor(Mode))
                        {
                            if ((Mode == TextMode.MEGA65_80_X_25_HIRES) ||
                                (Mode == TextMode.MEGA65_40_X_25_HIRES))
                            {
                                // colors >= 16 and < 32 need to be shifted up
                                if (newColor >= 16)
                                {
                                    newColor += 64 - 16;
                                }
                                Info.ScreenColorData.AppendU8(newColor);
                            }
                            else if ((Mode == TextMode.MEGA65_40_X_25_NCM) ||
                                     (Mode == TextMode.MEGA65_80_X_25_NCM))
                            {
                                // set the NCM bit in color byte 0
                                Info.ScreenColorData.AppendU16NetworkOrder(0x0800);
                            }
                            else
                            {
                                Info.ScreenColorData.AppendU8(newColor);
                            }
                        }
                    }
                }
            }
            else
            {
                for (int x = 0; x < Info.Area.Width; ++x)
                {
                    for (int i = 0; i < Info.Area.Height; ++i)
                    {
                        byte   newColor = (byte)((Chars[(Info.Area.Y + i) * ScreenWidth + Info.Area.X + x] & 0xff0000) >> 16);
                        ushort newChar  = (ushort)(Chars[(Info.Area.Y + i) * ScreenWidth + Info.Area.X + x] & 0xffff);

                        newChar = (ushort)(newChar + CharOffset);

                        if (numBytesPerChar == 2)
                        {
                            Info.ScreenCharData.AppendU16(newChar);
                        }
                        else
                        {
                            Info.ScreenCharData.AppendU8((byte)newChar);
                        }
                        if (Lookup.TextModeUsesColor(Mode))
                        {
                            if ((Mode == TextMode.MEGA65_80_X_25_HIRES) ||
                                (Mode == TextMode.MEGA65_40_X_25_HIRES))
                            {
                                // colors >= 16 and < 32 need to be shifted up
                                if (newColor >= 16)
                                {
                                    newColor += 64 - 16;
                                }
                                Info.ScreenColorData.AppendU8(newColor);
                            }
                            else if ((Mode == TextMode.MEGA65_40_X_25_NCM) ||
                                     (Mode == TextMode.MEGA65_80_X_25_NCM))
                            {
                                // set the NCM bit in color byte 0
                                Info.ScreenColorData.AppendU16NetworkOrder(0x0800);
                            }
                            else
                            {
                                Info.ScreenColorData.AppendU8(newColor);
                            }
                        }
                    }
                }
            }
            return(true);
        }