Exemplo n.º 1
0
        public override LeNSConvResult Conv(LeafPack.LeafFileInfo SrcInfo, byte[] SrcData)
        {
            int p_scn;
            int p_txt;
            int scn_size;
            int txt_size;
            byte[] scn_data;
            byte[] txt_data;

            // �V�i���I�A�e�L�X�g�f�[�^�̊J�n�ʒu��擾
            p_scn = getShort(SrcData, 0) * 16;
            p_txt = getShort(SrcData, 2) * 16;

            // ���ꂼ��̃T�C�Y��擾
            scn_size = getLong(SrcData, p_scn);
            txt_size = getLong(SrcData, p_txt);

            int tmp_len;
            byte[] tmp_data;

            // �V�i���I�f�[�^�̉�
            tmp_len = p_txt - p_scn;
            tmp_data = new byte[tmp_len];
            for (int p = 0; p < tmp_len; p++)
            {
                tmp_data[p] = SrcData[p_scn + p];
            }
            scn_data = lzs2(tmp_data, scn_size, 4);

            // �e�L�X�g�f�[�^�̉�
            tmp_len = SrcData.Length - p_txt;
            tmp_data = new byte[tmp_len];
            for (int p = 0; p < tmp_len; p++)
            {
                tmp_data[p] = SrcData[p_txt + p];
            }
            txt_data = lzs2(tmp_data, txt_size, 4);

            // �𓀌�̃_���v�f�[�^�o��(��͗p)
            //dumpData(srcInfo, scnData, txtData);
            return decodeEvent(SrcInfo, scn_data, txt_data);
        }
Exemplo n.º 2
0
        // �ϊ�����
        public override LeNSConvResult Conv(LeafPack.LeafFileInfo SrcInfo, byte[] SrcData)
        {
            byte[] img_data;

            // �p���b�g���
            palette = new Color[16];

            LeNSSDTInfo sdt_info;
            if (sdtTable.ContainsKey(SrcInfo.Name))
            {
                sdt_info = sdtTable[SrcInfo.Name];
            }
            else
            {
                _message = SrcInfo.Name + ":����`��SDT�t�@�C���ł��B";
                return LeNSConvResult.warning;
            }

            // �擾����SDT����Z�b�g
            palette = sdt_info.Pallete;
            int translate_color = sdt_info.TranslateColor;

            // �𓀌�T�C�Y�̎擾
            int size = SrcData[0] | (SrcData[1] << 8) | (SrcData[2] << 16) | (SrcData[3] << 24);

            // ���k�W�J
            img_data = lzs2(SrcData, size, 4);

            // �r�b�g�}�b�v�擾
            // SDT�t�@�C���͖�����Ń��T�C�Y�Ȃ��̏o��
            Rectangle create_size = new Rectangle(0, 0, sdt_info.Width, sdt_info.Height);
            Rectangle real_size = new Rectangle(0, 0, sdt_info.Width, sdt_info.Height);

            Bitmap wk = getBitmap(img_data, translate_color, create_size, real_size);

            // PNG�ŕۑ�
            writeFile(SrcInfo.Name, wk);
            wk.Dispose();

            return LeNSConvResult.ok;
        }
Exemplo n.º 3
0
        // �ϊ�����
        public override LeNSConvResult Conv(LeafPack.LeafFileInfo SrcInfo, byte[] SrcData)
        {
            int p;
            byte[] img_data;

            // �p���b�g���
            palette = new Color[16];

            // �}�W�b�N�R�[�h�`�F�b�N
            String strBuf = "";
            for (p = 0; p < 8; p++)
            {
                strBuf += ((char)SrcData[p]).ToString();
            }
            if (!strBuf.Equals("LEAFCODE"))
            {
                throw new InvalidDataException("LFGData�ł͂���܂���B");
            }

            // �p���b�g���̎擾
            int palidx = 0;
            byte[] palbuf = new byte[48];

            for (p = 8; p < 32; p++)
            {
                // �擾�������l��4bit�V�t�g���Đݒ�(16��256�K��)
                // upper
                palbuf[palidx] = (byte)(SrcData[p] & 0xf0);
                palbuf[palidx] |= (byte)(palbuf[palidx] >> 4);
                palidx++;
                // lower
                palbuf[palidx] = (byte)(SrcData[p] << 4);
                palbuf[palidx] |= (byte)(palbuf[palidx] >> 4);
                palidx++;
            }
            for (p = 0; p < 16; p++)
            {
                palette[p] = Color.FromArgb(palbuf[p * 3],
                                            palbuf[(p * 3) + 1],
                                            palbuf[(p * 3) + 2]);
            }

            // �W�I���g�����̎擾
            int xoffset = (SrcData[33] << 8 | SrcData[32]) * 8;
            int yoffset = SrcData[35] << 8 | SrcData[34];
            int width = ((SrcData[37] << 8 | SrcData[36]) + 1) * 8;
            int height = ((SrcData[39] << 8 | SrcData[38]) + 1);

            // �W�J�����̎擾
            direction = SrcData[40];

            // ���ߐF�̎擾
            int translate_color = SrcData[41];

            // OP2_MN_W.LFG�͐F�ύX
            if (option.conv == LeNSConvMode.MODE_KZ && SrcInfo.Name.Equals("OP2_MN_W.LFG"))
            {
                palette[15] = Color.Black;
            }

            // �𓀌�T�C�Y�̎擾
            int size = SrcData[44] | (SrcData[45] << 8) | (SrcData[46] << 16) | (SrcData[47] << 24);

            // ���k�W�J
            img_data = lzs(SrcData, size, 48);

            // �摜���T�C�Y�擾
            int rwidth = width - xoffset;
            int rheight = height - yoffset;

            // �r�b�g�}�b�v�擾
            Rectangle create_size;
            Rectangle real_size = new Rectangle(xoffset, yoffset, rwidth, rheight);

            // �摜��640x400�ō쐬����ƁA�Z�[�u���ɕs����o����ۂ�(bgalia�ʼn���”\�H)
            // �̂ŁA�摜��640x480�ɕύX�Ay�I�t�Z�b�g��+40����
            switch (SrcInfo.Type)
            {
                case LeafPack.LeNSFileType.BGGraphic:
                    real_size.Y += 40;
                    create_size = new Rectangle(0, 0, 640, 480);
                    translate_color = 0xff;
                    // ���I�[�v�j���O�摜��y�I�t�Z�b�g����炷
                    if (option.conv == LeNSConvMode.MODE_SZ &&
                        SrcInfo.Name.Substring(0, 4).Equals("OP_S"))
                    {
                        real_size.Y += 157;

                        // �p���b�g��ςȂ̂ŏC��(�F���Â��c)
                        //palette[1] = Color.FromArgb(255, 64, 48, 208);
                    }
                    else if (width > 320)
                    {
                        create_size.Width = 640;
                    }

                    break;
                case LeafPack.LeNSFileType.CharaGraphic:
                    real_size.Y += 40;

                    if (rwidth <= 320)
                    {
                        create_size = new Rectangle(0, 0, 320, 480);

                        // ���̈ꕔ�摜�ŕs����o�邽�ߑΉ�(�w�i�����n)
                        if (option.conv == LeNSConvMode.MODE_SZ &&
                            (SrcInfo.Name.Equals("MAX_C37.LFG") ||
                             SrcInfo.Name.Equals("MAX_C6A.LFG")))
                        {
                            create_size.Width = 640;
                        }
                        else if (width > 320)
                        {
                            create_size.Width = 640;
                        }
                    }
                    else
                    {
                        create_size = new Rectangle(0, 0, 640, 480);
                    }

                    break;
                case LeafPack.LeNSFileType.EtcGraphic:
                default:
                    create_size = new Rectangle(0, 0, rwidth, rheight);
                    real_size.X = 0; real_size.Y = 0;

                    break;
            }

            String[] file_suffix = { "", "B", "C", "D", "E" };

            // �����G�͖�̃p�^�[��������΂n�j
            if (SrcInfo.Type == LeafPack.LeNSFileType.CharaGraphic)
            {
                file_suffix[1] = "";
                file_suffix[2] = "N";
                file_suffix[3] = "";
                file_suffix[4] = "";
            }

            if (paletteMap.ContainsKey(SrcInfo.Name))
            {
                String[] map = paletteMap[SrcInfo.Name].Split(',');
                for(int i = 0; i < 5; i++)
                {
                    if (map[i + 1].Equals("1"))
                    {
                        setPalette(i);
                        writeBitmap(Path.GetFileNameWithoutExtension(SrcInfo.Name) + file_suffix[i] + ".LFG", img_data, translate_color, create_size, real_size);
                    }
                }
            }
            else
            {
                writeBitmap(SrcInfo.Name, img_data, translate_color, create_size, real_size);
            }

            return LeNSConvResult.ok;
        }
Exemplo n.º 4
0
        // PAK�t�@�C���ϊ��W�J(�V�i���I�t�@�C��)
        private void convertScenario(String fileName)
        {
            _progressValue = 0;
            _progressMax = 0;
            LeafPack pak = new LeafPack();

            LeNSConvResult result;
            LeNSConvSCN conv_scn;

            // �R���o�[�^�I�u�W�F�N�g�𐶐�
            switch (Option.conv)
            {
                case LeNSConvMode.MODE_SZ:
                    conv_scn = new LeNSConvSCNSZ(Option);
                    break;
                case LeNSConvMode.MODE_KZ:
                    conv_scn = new LeNSConvSCNKZ(Option);
                    break;
                case LeNSConvMode.MODE_TH:
                    conv_scn = new LeNSConvSCNTH(Option);
                    break;
                default:
                    // �����ɂ͗��Ȃ��͂�
                    return;
            }

            conv_scn.SoundCache = soundCache;

            try
            {
                outputLog(fileName + "�̃V�i���I�t�@�C���ϊ�����݂܂�", false);
                conv_scn.CreateFile();
                _processingPack = fileName;
                _processingTask = "Extracting... " + fileName;
                pak.Open(Option.pakPath + "\\" + fileName, System.IO.FileMode.Open);
                _progressValue = 0;
                _progressMax = (int)pak.ScenarioNum;
                outputLog(fileName + " = " + _progressMax.ToString() + "files.");

                foreach (LeafPack.LeafFileInfo info in pak.Files.Values)
                {
                    String ext = Path.GetExtension(info.Name);

                    if (info.Type == LeafPack.LeNSFileType.ScenarioFile)
                    {
                        _processingTask = fileName + "@" + info.Name;
                        _progressValue++;

                        // �ϊ������R�[��
                        _processingTask += " -> " + conv_scn.GetSaveName(info.Name);
                        result = conv_scn.Conv(info, pak.Get(info.Name));
                    }
                    else
                    {
                        _processingTask = "searching...";
                    }
                }
            }
            finally
            {
                pak.Close();
                _processingPack = "";
                _progressValue = 0;
                _progressMax = 0;
            }
        }
Exemplo n.º 5
0
        // PAK�t�@�C���ϊ��W�J(�f�ރt�@�C��)
        private void convertOther(String fileName)
        {
            _progressValue = 0;
            _progressMax = 0;
            LeafPack pak = new LeafPack();

            LeNSConvResult result;
            LeNSConvLFG conv_lfg = new LeNSConvLFG(Option);
            LeNSConvSDT conv_sdt = new LeNSConvSDT(Option);
            LeNSConvP16 conv_p16 = new LeNSConvP16(Option);

            switch (Option.conv)
            {
                case LeNSConvMode.MODE_KZ:
                    conv_lfg.LoadPaletteMap("kizuato.pal");
                    break;
            }

            try
            {
                outputLog(fileName + "�̑f�ރt�@�C���ϊ�����݂܂�", false);
                _processingPack = fileName;
                _processingTask = "Extracting... " + fileName;
                pak.Open(Option.pakPath + "\\" + fileName, System.IO.FileMode.Open);
                _progressValue = 0;
                _progressMax = (int)pak.OtherNum;
                outputLog(fileName + " = " + _progressMax.ToString() + "files.");

                foreach (LeafPack.LeafFileInfo info in pak.Files.Values)
                {
                    String ext = Path.GetExtension(info.Name);

                    if (info.Type != LeafPack.LeNSFileType.ScenarioFile)
                    {
                        _processingTask = fileName + "@" + info.Name;
                        _progressValue++;

                        // �g���q���ƂɑΉ�����t�@�C���ւƃR���o�[�g����
                        if (info.Type == LeafPack.LeNSFileType.SpecialFile)
                        {
                            // ����t�@�C���ϊ�
                        }
                        else
                        {
                            switch (ext)
                            {
                                // �V�i���I�t�@�C���̓X�L�b�v
                                case ".SCN":
                                    break;
                                // �摜�t�@�C��(LFG)
                                case ".LFG":
                                    _processingTask += " -> " + conv_lfg.GetSaveName(info.Name);
                                    result = conv_lfg.Conv(info, pak.Get(info.Name));
                                    if (result == LeNSConvResult.warning)
                                    {
                                        outputLog(conv_lfg.Message, true);
                                    }

                                    break;
                                // �摜�t�@�C��(SDT)
                                case ".SDT":
                                    _processingTask += " -> " + conv_sdt.GetSaveName(info.Name);
                                    result = conv_sdt.Conv(info, pak.Get(info.Name));
                                    if (result == LeNSConvResult.warning)
                                    {
                                        outputLog(conv_sdt.Message, true);
                                    }

                                    break;
                                // �摜�t�@�C��(LF2)
                                case ".LF2":
                                    //outputLog(info.Name + ":�������쐬�ł�", true);
                                    _processingTask += " -> " + Path.GetFileNameWithoutExtension(info.Name) + ".PNG";
                                    break;
                                // �����t�@�C��
                                case ".P16":
                                    _processingTask += " -> " + conv_p16.GetSaveName(info.Name);
                                    result = conv_p16.Conv(info, pak.Get(info.Name));
                                    if (result == LeNSConvResult.warning) outputLog(conv_p16.Message, true);
                                    soundCache.Add(info.Name, info.PlayTime);

                                    // ������Đ����K�v�ȃt�@�C���𐶐�
                                    // �����ɏ�肢�������Ȃ��c�B
                                    switch (Option.conv)
                                    {
                                        case LeNSConvMode.MODE_KZ:
                                            switch(info.Name.ToUpper())
                                            {
                                                case "KZ_VD04.P16":
                                                    result = conv_p16.Conv(info, pak.Get(info.Name), 2);
                                                    if (result == LeNSConvResult.warning) outputLog(conv_p16.Message, true);
                                                    break;
                                                case "KZ_VD08.P16":
                                                    result = conv_p16.Conv(info, pak.Get(info.Name), 2);
                                                    if (result == LeNSConvResult.warning) outputLog(conv_p16.Message, true);
                                                    result = conv_p16.Conv(info, pak.Get(info.Name), 3);
                                                    if (result == LeNSConvResult.warning) outputLog(conv_p16.Message, true);
                                                    break;
                                                case "KZ_VD12.P16":
                                                    result = conv_p16.Conv(info, pak.Get(info.Name), 2);
                                                    if (result == LeNSConvResult.warning) outputLog(conv_p16.Message, true);
                                                    break;
                                                case "KZ_VD19.P16":
                                                    result = conv_p16.Conv(info, pak.Get(info.Name), 2);
                                                    if (result == LeNSConvResult.warning) outputLog(conv_p16.Message, true);
                                                    break;
                                            }
                                            break;
                                    }

                                    break;
                                // ����`
                                default:
                                    outputLog(info.Name + ":����`�t�@�C���`���̂��߃X�L�b�v����܂���", true);
                                    _processingTask += " : Undefined Type.";
                                    break;
                            }
                        }
                    }
                    else
                    {
                        _processingTask = "searching...";
                    }
                }
            }
            finally
            {
                pak.Close();
                _processingPack = "";
                _progressValue = 0;
                _progressMax = 0;
            }
        }
Exemplo n.º 6
0
 public abstract LeNSConvResult Conv(LeafPack.LeafFileInfo SrcInfo, byte[] SrcData);
Exemplo n.º 7
0
 // �t�@�C����������
 protected void writeFile(LeafPack.LeafFileInfo srcInfo, StringBuilder str)
 {
     // �������݂̓A�y���h�ōs��
     FileStream fs = new FileStream(getSavePath(srcInfo.Name), FileMode.Append);
     try
     {
         StreamWriter sw = new StreamWriter(fs, Encoding.GetEncoding(932));
         try
         {
             sw.Write(str.ToString());
         }
         finally
         {
             sw.Close();
         }
     }
     finally
     {
         fs.Close();
     }
 }
Exemplo n.º 8
0
        // �_���v�f�[�^�o��(�f�o�b�O�p)
        protected void dumpData(LeafPack.LeafFileInfo srcInfo, byte[] scnData, byte[] txtData)
        {
            FileStream fs;
            fs = new FileStream(getSavePath() + "\\" + Path.GetFileNameWithoutExtension(srcInfo.Name) + ".EVT", FileMode.Create);
            try
            {
                BinaryWriter bw = new BinaryWriter(fs);
                try
                {
                    bw.Write(scnData);
                }
                finally
                {
                    bw.Close();
                }
            }
            finally
            {
                fs.Close();
            }

            fs = new FileStream(getSavePath() + "\\" + Path.GetFileNameWithoutExtension(srcInfo.Name) + ".MSG", FileMode.Create);
            try
            {
                BinaryWriter bw = new BinaryWriter(fs);
                try
                {
                    bw.Write(txtData);
                }
                finally
                {
                    bw.Close();
                }
            }
            finally
            {
                fs.Close();
            }
        }
Exemplo n.º 9
0
 // �C�x���g�f�R�[�_(�p����Ŏ���)
 protected abstract LeNSConvResult decodeEvent(LeafPack.LeafFileInfo srcInfo, byte[] scnData, byte[] txtData);
Exemplo n.º 10
0
        // �ϊ�����
        public LeNSConvResult Conv(LeafPack.LeafFileInfo SrcInfo, byte[] SrcData, int Number)
        {
            // �����������11MHzStereo�̐��f�[�^�ɂȂ�̂Ńw�b�_�t���ďo�́B
            // �ꕔ�f�[�^����o�C�g�ɂȂ��Ă���̂ŁA0��������ŃT�C�Y����킹��B
            // ���킹�Ȃ��ƕ�����Đ��Ńo�O��B
            FileStream fs;
            BinaryWriter bw;
            int length = SrcData.Length;
            if (length % 2 == 1)
            {
                // ��T�C�Y�̏ꍇ�̓T�C�Y��+1�o�C�g
                length++;
            }
            length *= Number;

            fs = new FileStream(getSavePath(SrcInfo.Name, Number), FileMode.Create);

            try
            {
                bw = new BinaryWriter(fs);
                try
                {
                    //�@���育����Ə����o��
                    bw.Write('R');                          // RIFF�w�b�_
                    bw.Write('I');
                    bw.Write('F');
                    bw.Write('F');
                    bw.Write((Int32)(length + 36));         // �f�[�^�T�C�Y + 36byte
                    bw.Write('W');                          // WAVE�w�b�_
                    bw.Write('A');
                    bw.Write('V');
                    bw.Write('E');
                    bw.Write('f');                          // fmt�`�����N
                    bw.Write('m');
                    bw.Write('t');
                    bw.Write(' ');
                    bw.Write((Int32)(16));                  // fmt�`�����N�T�C�Y(16)
                    bw.Write((Int16)(1));                   // �t�H�[�}�b�g(���j�APCM=1)
                    bw.Write((Int16)(2));                   // �`���l����(2)
                    bw.Write((Int32)(11025));               // �T���v�����O���[�g(11025)
                    bw.Write((Int32)(44100));               // 44100Byte/sec)
                    bw.Write((Int16)(4));                   // Byte/sample�~�`�����l����
                    bw.Write((Int16)(16));                  // 16bit
                    bw.Write('d');                          // data�`�����N
                    bw.Write('a');
                    bw.Write('t');
                    bw.Write('a');
                    bw.Write((Int32)(length));              // �f�[�^�T�C�Y

                    // �Đ��񐔕��o��
                    for (int i = 1; i <= Number; i++ )
                    {
                        bw.Write(SrcData);                  // �g�`�f�[�^
                        if (SrcData.Length % 2 == 1)
                        {
                            bw.Write((byte)0);
                        }
                    }
                }
                finally
                {
                    bw.Close();
                }
            }
            finally
            {
                fs.Close();
            }

            return LeNSConvResult.ok;
        }
Exemplo n.º 11
0
 // �ϊ�����
 public override LeNSConvResult Conv(LeafPack.LeafFileInfo SrcInfo, byte[] SrcData)
 {
     return Conv(SrcInfo, SrcData, 1);
 }