Beispiel #1
0
        public CharControl(String lang,
            int charCode, sNFTR.HDWC.Info tileInfo, Byte[] tiles, int depth, int width, int height, int rotateMode,
            Color[] palette)
        {
            InitializeComponent();
            ReadLanguage(lang);

            this.charCode = charCode;
            this.tileInfo = tileInfo;
            this.tiles = tiles;
            this.depth = depth;
            this.width = width;
            this.height = height;
            this.rotateMode = rotateMode;
            this.palette = palette;

            txtCharCode.Text = String.Format("0x{0:X}", charCode);
            numericStart.Value = tileInfo.pixel_start;
            numericLength.Value = tileInfo.pixel_length;
            numericWidth.Value = tileInfo.pixel_width;

            Draw_Char();

            picPaletteColour.BackColor = palette[0];
            trackPalette.Maximum = Convert.ToByte(new String('1', depth), 2);
            trackPalette.Value = trackPalette.Maximum;
            picPaletteColour.BackColor = palette[trackPalette.Value];
        }
Beispiel #2
0
        private void btnAddChar_Click(object sender, EventArgs e)
        {
            font.hdwc.last_code++;
            sNFTR.HDWC.Info newInfo = new sNFTR.HDWC.Info();
            newInfo.pixel_start  = 0;
            newInfo.pixel_width  = 9;
            newInfo.pixel_length = 9;
            font.hdwc.info.Add(newInfo);

            List <byte[]> tiles = new List <byte[]>();

            tiles.AddRange(font.plgc.tiles);
            Byte[] newChar = new byte[8 * font.plgc.tile_length];
            tiles.Add(newChar);
            font.plgc.tiles = tiles.ToArray();

            picFont.Image = NFTR.Get_Chars(font, MAX_WIDTH, palette, ZOOM);
            comboChar.Items.Add("Char" + comboChar.Items.Count.ToString());
            comboChar.SelectedIndex = comboChar.Items.Count - 1;
        }
Beispiel #3
0
        public static sNFTR Read(sFile cfile, string lang)
        {
            sNFTR font = new sNFTR();

            font.id   = cfile.id;
            font.name = cfile.name;
            BinaryReader br = new BinaryReader(File.OpenRead(cfile.path));

            // Read the standard header
            font.header.type       = br.ReadChars(4);
            font.header.endianess  = br.ReadUInt16();
            font.header.unknown    = br.ReadUInt16();
            font.header.file_size  = br.ReadUInt32();
            font.header.block_size = br.ReadUInt16();
            font.header.num_blocks = br.ReadUInt16();

            // Font INFo section
            font.fnif.type       = br.ReadChars(4);
            font.fnif.block_size = br.ReadUInt32();

            font.fnif.unknown1      = br.ReadByte();
            font.fnif.height        = br.ReadByte();
            font.fnif.nullCharIndex = br.ReadUInt16();
            font.fnif.unknown4      = br.ReadByte();
            font.fnif.width         = br.ReadByte();
            font.fnif.width_bis     = br.ReadByte();
            font.fnif.encoding      = br.ReadByte();

            font.fnif.offset_plgc = br.ReadUInt32();
            font.fnif.offset_hdwc = br.ReadUInt32();
            font.fnif.offset_pamc = br.ReadUInt32();

            if (font.fnif.block_size == 0x20)
            {
                font.fnif.height_font = br.ReadByte();
                font.fnif.widht_font  = br.ReadByte();
                font.fnif.bearing_y   = br.ReadByte();
                font.fnif.bearing_x   = br.ReadByte();
            }

            // Character Graphics LP
            br.BaseStream.Position = font.fnif.offset_plgc - 0x08;
            font.plgc.type         = br.ReadChars(4);
            font.plgc.block_size   = br.ReadUInt32();
            font.plgc.tile_width   = br.ReadByte();
            font.plgc.tile_height  = br.ReadByte();
            font.plgc.tile_length  = br.ReadUInt16();
            font.plgc.unknown      = br.ReadUInt16();
            font.plgc.depth        = br.ReadByte();
            font.plgc.rotateMode   = br.ReadByte();

            font.plgc.tiles = new Byte[(font.plgc.block_size - 0x10) / font.plgc.tile_length][];
            for (int i = 0; i < font.plgc.tiles.Length; i++)
            {
                font.plgc.tiles[i] = BytesToBits(br.ReadBytes(font.plgc.tile_length));
                if (font.plgc.rotateMode >> 1 == 3)
                {
                    font.plgc.tiles[i] = Rotate270(font.plgc.tiles[i], font.plgc.tile_width, font.plgc.tile_height, font.plgc.depth);
                }
                else if (font.plgc.rotateMode >> 1 == 1)
                {
                    font.plgc.tiles[i] = Rotate90(font.plgc.tiles[i], font.plgc.tile_width, font.plgc.tile_height, font.plgc.depth);
                }
                else if (font.plgc.rotateMode >> 1 == 2)
                {
                    font.plgc.tiles[i] = Rotate180(font.plgc.tiles[i], font.plgc.tile_width, font.plgc.tile_height, font.plgc.depth);
                }
            }

            if (font.plgc.rotateMode >> 1 % 2 != 0)
            {
                byte w = font.plgc.tile_width;
                font.plgc.tile_width  = font.plgc.tile_height;
                font.plgc.tile_height = w;
            }

            // Character Width DH
            br.BaseStream.Position = font.fnif.offset_hdwc - 0x08;
            font.hdwc.type         = br.ReadChars(4);
            font.hdwc.block_size   = br.ReadUInt32();
            font.hdwc.fist_code    = br.ReadUInt16();
            font.hdwc.last_code    = br.ReadUInt16();
            font.hdwc.unknown1     = br.ReadUInt32();

            font.hdwc.info = new List <sNFTR.HDWC.Info>();
            for (int i = 0; i < font.plgc.tiles.Length; i++)
            {
                sNFTR.HDWC.Info info = new sNFTR.HDWC.Info();
                info.pixel_start  = br.ReadSByte();
                info.pixel_width  = br.ReadByte();
                info.pixel_length = br.ReadByte();
                font.hdwc.info.Add(info);
            }

            // Character MAP
            br.BaseStream.Position = font.fnif.offset_pamc - 0x08;
            font.pamc = new List <sNFTR.PAMC>();
            uint nextOffset = 0x00;

            do
            {
                sNFTR.PAMC pamc = new sNFTR.PAMC();
                pamc.type         = br.ReadChars(4);
                pamc.block_size   = br.ReadUInt32();
                pamc.first_char   = br.ReadUInt16();
                pamc.last_char    = br.ReadUInt16();
                pamc.type_section = br.ReadUInt32();
                nextOffset        = br.ReadUInt32();
                pamc.next_section = nextOffset;

                switch (pamc.type_section)
                {
                case 0:
                    sNFTR.PAMC.Type0 type0 = new sNFTR.PAMC.Type0();
                    type0.fist_char_code = br.ReadUInt16();
                    pamc.info            = type0;
                    break;

                case 1:
                    sNFTR.PAMC.Type1 type1 = new sNFTR.PAMC.Type1();
                    type1.char_code = new ushort[pamc.last_char - pamc.first_char + 1];
                    for (int i = 0; i < type1.char_code.Length; i++)
                    {
                        type1.char_code[i] = br.ReadUInt16();
                    }

                    pamc.info = type1;
                    break;

                case 2:
                    sNFTR.PAMC.Type2 type2 = new sNFTR.PAMC.Type2();
                    type2.num_chars = br.ReadUInt16();
                    type2.charInfo  = new sNFTR.PAMC.Type2.CharInfo[type2.num_chars];

                    for (int i = 0; i < type2.num_chars; i++)
                    {
                        type2.charInfo[i].chars_code = br.ReadUInt16();
                        type2.charInfo[i].chars      = br.ReadUInt16();
                    }
                    pamc.info = type2;
                    break;
                }

                font.pamc.Add(pamc);
                br.BaseStream.Position = nextOffset - 0x08;
            } while (nextOffset != 0x00 && (nextOffset - 0x08) < br.BaseStream.Length);

            //WriteInfo(font, lang);
            font.plgc.rotateMode &= 1;

            br.Close();
            return(font);
        }
Beispiel #4
0
        public static sNFTR Read(sFile cfile, string lang)
        {
            sNFTR font = new sNFTR();
            font.id = cfile.id;
            font.name = cfile.name;
            BinaryReader br = new BinaryReader(File.OpenRead(cfile.path));

            // Read the standard header
            font.header.type = br.ReadChars(4);
            font.header.endianess = br.ReadUInt16();
            font.header.unknown = br.ReadUInt16();
            font.header.file_size = br.ReadUInt32();
            font.header.block_size = br.ReadUInt16();
            font.header.num_blocks = br.ReadUInt16();

            // Font INFo section
            font.fnif.type = br.ReadChars(4);
            font.fnif.block_size = br.ReadUInt32();

            font.fnif.unknown1 = br.ReadByte();
            font.fnif.height = br.ReadByte();
            font.fnif.nullCharIndex = br.ReadUInt16();
            font.fnif.unknown4 = br.ReadByte();
            font.fnif.width = br.ReadByte();
            font.fnif.width_bis = br.ReadByte();
            font.fnif.encoding = br.ReadByte();

            font.fnif.offset_plgc = br.ReadUInt32();
            font.fnif.offset_hdwc = br.ReadUInt32();
            font.fnif.offset_pamc = br.ReadUInt32();

            if (font.fnif.block_size == 0x20)
            {
                font.fnif.height_font = br.ReadByte();
                font.fnif.widht_font = br.ReadByte();
                font.fnif.bearing_y = br.ReadByte();
                font.fnif.bearing_x = br.ReadByte();
            }

            // Character Graphics LP
            br.BaseStream.Position = font.fnif.offset_plgc - 0x08;
            font.plgc.type = br.ReadChars(4);
            font.plgc.block_size = br.ReadUInt32();
            font.plgc.tile_width = br.ReadByte();
            font.plgc.tile_height = br.ReadByte();
            font.plgc.tile_length = br.ReadUInt16();
            font.plgc.unknown = br.ReadUInt16();
            font.plgc.depth = br.ReadByte();
            font.plgc.rotateMode = br.ReadByte();

            font.plgc.tiles = new Byte[(font.plgc.block_size - 0x10) / font.plgc.tile_length][];
            for (int i = 0; i < font.plgc.tiles.Length; i++)
            {
                font.plgc.tiles[i] = BytesToBits(br.ReadBytes(font.plgc.tile_length));
                if (font.plgc.rotateMode == 2)
                    font.plgc.tiles[i] = Rotate270(font.plgc.tiles[i], font.plgc.tile_width, font.plgc.tile_height, font.plgc.depth);
                else if (font.plgc.rotateMode == 1)
                    font.plgc.tiles[i] = Rotate90(font.plgc.tiles[i], font.plgc.tile_width, font.plgc.tile_height, font.plgc.depth);
                else if (font.plgc.rotateMode == 3)
                    font.plgc.tiles[i] = Rotate180(font.plgc.tiles[i], font.plgc.tile_width, font.plgc.tile_height, font.plgc.depth);

            }

            // Character Width DH
            br.BaseStream.Position = font.fnif.offset_hdwc - 0x08;
            font.hdwc.type = br.ReadChars(4);
            font.hdwc.block_size = br.ReadUInt32();
            font.hdwc.fist_code = br.ReadUInt16();
            font.hdwc.last_code = br.ReadUInt16();
            font.hdwc.unknown1 = br.ReadUInt32();

            font.hdwc.info = new List<sNFTR.HDWC.Info>();
            for (int i = 0; i < font.plgc.tiles.Length; i++)
            {
                sNFTR.HDWC.Info info = new sNFTR.HDWC.Info();
                info.pixel_start = br.ReadByte();
                info.pixel_width = br.ReadByte();
                info.pixel_length = br.ReadByte();
                font.hdwc.info.Add(info);
            }

            // Character MAP
            br.BaseStream.Position = font.fnif.offset_pamc - 0x08;
            font.pamc = new List<sNFTR.PAMC>();
            uint nextOffset = 0x00;
            do
            {
                sNFTR.PAMC pamc = new sNFTR.PAMC();
                pamc.type = br.ReadChars(4);
                pamc.block_size = br.ReadUInt32();
                pamc.first_char = br.ReadUInt16();
                pamc.last_char = br.ReadUInt16();
                pamc.type_section = br.ReadUInt32();
                nextOffset = br.ReadUInt32();
                pamc.next_section = nextOffset;

                switch (pamc.type_section)
                {
                    case 0:
                        sNFTR.PAMC.Type0 type0 = new sNFTR.PAMC.Type0();
                        type0.fist_char_code = br.ReadUInt16();
                        pamc.info = type0;
                        break;
                    case 1:
                        sNFTR.PAMC.Type1 type1 = new sNFTR.PAMC.Type1();
                        type1.char_code = new ushort[(pamc.block_size - 0x14 - 0x02) / 2];
                        for (int i = 0; i < type1.char_code.Length; i++)
                            type1.char_code[i] = br.ReadUInt16();

                        pamc.info = type1;
                        break;
                    case 2:
                        sNFTR.PAMC.Type2 type2 = new sNFTR.PAMC.Type2();
                        type2.num_chars = br.ReadUInt16();
                        type2.charInfo = new sNFTR.PAMC.Type2.CharInfo[type2.num_chars];

                        for (int i = 0; i < type2.num_chars; i++)
                        {
                            type2.charInfo[i].chars_code = br.ReadUInt16();
                            type2.charInfo[i].chars = br.ReadUInt16();
                        }
                        pamc.info = type2;
                        break;
                }

                font.pamc.Add(pamc);
                br.BaseStream.Position = nextOffset - 0x08;
            } while (nextOffset != 0x00 && (nextOffset - 0x08) < br.BaseStream.Length);

            //WriteInfo(font, lang);
            font.plgc.rotateMode = 0;

            br.Close();
            return font;
        }
Beispiel #5
0
        private void btnAddChar_Click(object sender, EventArgs e)
        {
            font.hdwc.last_code++;
            sNFTR.HDWC.Info newInfo = new sNFTR.HDWC.Info();
            newInfo.pixel_start = 0;
            newInfo.pixel_width = 9;
            newInfo.pixel_length = 9;
            font.hdwc.info.Add(newInfo);

            List<byte[]> tiles = new List<byte[]>();
            tiles.AddRange(font.plgc.tiles);
            Byte[] newChar = new byte[8 * font.plgc.tile_length];
            tiles.Add(newChar);
            font.plgc.tiles = tiles.ToArray();

            picFont.Image = NFTR.Get_Chars(font, MAX_WIDTH, palette, ZOOM);
            comboChar.Items.Add("Char" + comboChar.Items.Count.ToString());
            comboChar.SelectedIndex = comboChar.Items.Count - 1;
        }