Skip to content

Commit

Permalink
StudioSeldomAdventureSystem项目(sec5)完成
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkness-TX committed Jul 14, 2020
1 parent 814545d commit 7d7d653
Show file tree
Hide file tree
Showing 13 changed files with 1,289 additions and 16 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Niflheim
PC平台游戏程序
## TODO
#### 2020.07.15
* - [x] StudioSeldomAdventureSystem项目(sec5)完成,修复若干bug,导入导出文本程序不通用,特别注意:CODE文件中存在着海量的硬编码地址,导入新文本时切记也要修改这些地址
#### 2020.06.24
* - [x] StudioSeldomAdventureSystem项目(sec5)完成解包、封包、增加封包功能,经过了简单的测试,顺便修复了之前大量的bug,基于《恋色空模様》制作
* StudioSeldomAdventureSystem项目(sec5)的文本文件(CODE)中的文本导入导出
* - [x] StudioSeldomAdventureSystem项目(sec5)的文本文件(CODE)中的文本导入导出(2020.07.15)
#### 2019.09.06
* - [x] BALDR_HEART项目字库生成程序基本完成,增加可生成指定宽高不同的字模,Width默认为0,需要此功能时不使用默认0即可
#### 2019.08.22
Expand Down
181 changes: 181 additions & 0 deletions StudioSeldomAdventureSystem/RES2_info_dump/RES2_info_dump.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
/*
用于遍历RES2文件中的信息
made by Darkness-TX
2020.07.14
*/
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <io.h>
#include <direct.h>
#include <Windows.h>
#include <locale.h>

typedef unsigned char unit8;
typedef unsigned short unit16;
typedef unsigned int unit32;
typedef unsigned __int64 unit64;

unit32 FileNum = 0;//总文件数,初始计数为0

typedef struct fileinfo
{
unit32 offset;
char arc_name[MAX_PATH];
unit32 arc_index;
char arc_type[MAX_PATH];
char arc_path[MAX_PATH];
char name[MAX_PATH];
char type[MAX_PATH];
struct fileinfo *next;
}NodeFileInfo, *LinkFileInfo;
LinkFileInfo FileInfo = NULL;

unit32 ReadNumber(FILE *src, unit32 length_code)
{
unit32 count = 0, i = 0, n = 0, rank = 0, b = 0;
count = (length_code & 7) + 1;
if (count > 4)
{
printf("count大于4!pos:0x%X count:0x%X\n", ftell(src), count);
system("pause");
exit(0);
}
for (i = 0; i < count; ++i)
{
fread(&b, 1, 1, src);
n |= b << rank;
rank += 8;
}
if (count <= 3)
{
unit32 sign = n & (1 << (8 * count - 1));
if (sign != 0)
n -= sign << 1;
}
return n;
}

unit32 ReadInteger(FILE *src)
{
unit32 opcode = 0;
fread(&opcode, 1, 1, src);
if ((opcode & 0xE0) != 0)
{
if ((opcode & 0xF8) != 0x80)
{
printf("opcode不为0x80!pos:0x%X opcode:0x%X\n", ftell(src) - 1, opcode);
system("pause");
exit(0);
}
opcode = ReadNumber(src, opcode);
}
else
opcode = (opcode & 0x0F) - (opcode & 0x10);
return opcode;
}

void SkipObject(FILE *src)
{
unit32 opcode = 0;
fread(&opcode, 1, 1, src);
if ((opcode & 0xE0) != 0)
ReadNumber(src, opcode);
}

void ReadString(FILE *src, char *dstname)
{
unit32 opcode = 0, offset = 4, name_length = 0, savepos = 0;
char name_str[MAX_PATH];
fread(&opcode, 1, 1, src);
if ((opcode & 0xF8) != 0x90)
{
printf("opcode不等于0x90!pos:0x%X opcode:0x%X\n", ftell(src) - 1, opcode);
system("pause");
exit(0);
}
offset += ReadNumber(src, opcode);
savepos = ftell(src);
fseek(src, offset, SEEK_SET);
fread(&name_length, 4, 1, src);
fread(name_str, name_length, 1, src);
name_str[name_length] = '\0';
sprintf(dstname, "%s", name_str);
fseek(src, savepos, SEEK_SET);
}

void ReadIndex(char *fname)
{
unit32 opcode_off = 0, name_count = 0, param_count = 0, i = 0, j = 0;
char param_name[MAX_PATH];
FileInfo = malloc(sizeof(NodeFileInfo));
FileInfo->next = NULL;
LinkFileInfo p = FileInfo;
FILE *src = fopen("SEC5/RES2", "rb");
if (src == NULL)
{
printf("RES2打开错误,请检查SEC5文件夹下是否有RES2\n");
system("pause");
exit(0);
}
fread(&opcode_off, 4, 1, src);
opcode_off += 4;
fseek(src, opcode_off, SEEK_SET);
fread(&name_count, 4, 1, src);
for (i = 0; i < name_count; i++)
{
p->next = malloc(sizeof(NodeFileInfo));
p->next->offset = ftell(src);
p->next->arc_path[0] = '\0';
ReadString(src, p->next->name);
ReadString(src, p->next->type);
ReadString(src, p->next->arc_type);
param_count = ReadInteger(src);
for (j = 0; j < param_count; j++)
{
ReadString(src, param_name);
if (strncmp("path", param_name, 4) == 0)
ReadString(src, p->next->arc_name);
else if (strncmp("arc-index", param_name, 9) == 0)
p->next->arc_index = ReadInteger(src);
else if (strncmp("arc-path", param_name, 8) == 0)
ReadString(src, p->next->arc_path);
else
{
printf("发现未知的参数名:%s offset:0x%X\n", param_name, ftell(src));
system("pause");
SkipObject(src);
}
}
//printf("arc_name:%s arc_index:%d arc_type:%s file_name:%s file_type:%s arc_path:%s\n", p->next->arc_name, p->next->arc_index, p->next->arc_type, p->next->name, p->next->type, p->next->arc_path);
p = p->next;
p->next = NULL;
FileNum++;
}
}

void DumpInfo()
{
FILE *dst = NULL;
unit32 i = 0;
LinkFileInfo p = FileInfo;
dst = fopen("RES2_info.txt", "wt");
fputs("offset,arc_name,arc_index,arc_type,file_name,file_type,arc_path\n", dst);
for (i = 0; i < FileNum; i++)
{
p = p->next;
fprintf(dst, "0x%08X,%s,%d,%s,%s,%s,%s\n", p->offset, p->arc_name, p->arc_index, p->arc_type, p->name, p->type, p->arc_path);
}
}

int main(int argc, char *argv[])
{
setlocale(LC_ALL, "chs");
printf("project:Niflheim-StudioSeldomAdventureSystem\n用于遍历RES2文件中的信息。\n双击运行程序。\nby Darkness-TX 2020.07.14\n\n");
ReadIndex(argv[1]);
DumpInfo();
printf("已完成,总文件数%d\n", FileNum);
system("pause");
return 0;
}
154 changes: 154 additions & 0 deletions StudioSeldomAdventureSystem/RES2_info_dump/RES2_info_dump.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{66FB23D8-412C-41E7-98A3-7E03F3EF186D}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>RES2_info_dump</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="RES2_info_dump.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="RES2_info_dump.c">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>
Loading

0 comments on commit 7d7d653

Please sign in to comment.