Skip to content

Commit

Permalink
localization
Browse files Browse the repository at this point in the history
  • Loading branch information
Liu committed May 16, 2024
1 parent 5711c45 commit 3b6da63
Show file tree
Hide file tree
Showing 42 changed files with 150 additions and 37 deletions.
22 changes: 22 additions & 0 deletions docs/archive/bluekiller.htm

Large diffs are not rendered by default.

Binary file added docs/archive/bluekiller_files/Image_001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_002.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_003.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_004.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_006.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_007.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_008.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_009.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_011.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_012.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_013.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_014.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_015.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_016.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_017.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_018.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_019.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_020.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_021.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_022.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_023.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_024.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_025.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/archive/bluekiller_files/Image_026.jpg
Binary file added docs/archive/bluekiller_files/Image_027.jpg
Binary file added docs/archive/bluekiller_files/Image_028.png
Binary file added docs/archive/bluekiller_files/Image_029.jpg
Binary file added docs/archive/bluekiller_files/Image_030.jpg
Binary file added docs/archive/bluekiller_files/Image_031.jpg
Binary file added docs/archive/bluekiller_files/Image_032.jpg
Binary file added docs/archive/bluekiller_files/Image_033.jpg
Binary file added docs/archive/bluekiller_files/Image_034.png
Binary file added docs/archive/bluekiller_files/Image_035.png
1 change: 1 addition & 0 deletions docs/archive/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
本文件夹内为互联网中存档,版权归原作者所有。
12 changes: 8 additions & 4 deletions docs/debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,26 @@
使用实机Debug有很多好处

## Debug Using `PPSSPP`
> [《诡计对逻辑》汉化研究](https://pbteam.cn/posts/txl-hack/)
> https://datacrystal.romhacking.net/wiki/Blaze_Union/Tutorials
> https://github.com/Bunkai9448/digipet_PSP/blob/main/RE_Guide.md
> + [《诡计对逻辑》汉化研究](https://pbteam.cn/posts/txl-hack/)
> + https://datacrystal.romhacking.net/wiki/Blaze_Union/Tutorials
> + https://github.com/Bunkai9448/digipet_PSP/blob/main/RE_Guide.md
PPSSPP自带的调试工具算很强大了。简要介绍一下它的功能。

+ 查看寄存器
+ 查看内存
+ 给系统调用打断点

具体用法可以参考链接。

几种内存地址的变换

+ psp的内存地址空间
+ Dump出的内存
+ ELF中的vmaddr
+ ELF的二进制文件

## Makefile Example (From RetroArch)
### Debug using `PPSSPP` with `Ghidra`

## Makefile Example (From `RetroArch`)
+ After `include`
22 changes: 21 additions & 1 deletion docs/libs/font.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,24 @@ UCS2,可认为是UTF-16用二个字节来表示基本平面
UTF-16 编码表
Unicode 中的一个编码区段,编码从 U+0000 至 U+FFFF,也称基本多文种平面(Basic Multilingual Plane,BMP),或第零平面(Plane 0)。

Unicode 编码规定以下字符范围为控制字符,\U0000 - \U001F, \U007F, \U0080 - \U009F。
Unicode 编码规定以下字符范围为控制字符,\U0000 - \U001F, \U007F, \U0080 - \U009F。

# PGF

26.9 PGF

The PSP font format (.PGF files) is a bitmap based font format. Each letter (as well as its shadow) is a single, 4bpp bitmap, saved in the font file in a RLE compressed form. The bitmaps are encoded using either vertical or horizontal rows, depending on a certain 2-bit field in character metrics. Every [character, shadow] bitmap pair is preceded by a character metrics record. For Latin fonts the length of this record appears to be 12 bytes (with an optional 7-byte extension), for other families it's different. It's not known at this time what is the determinant of the record length. The metrics record contains the following fields:
14-bit offset of the shadow header record
7-bit width
7-bit height
7-bit signed horizontal adjustment
7-bit ascender
2-bit transposition (1 - horizontal rows, 2 - vertical rows)
1-bit modified record field (adds a 7-byte extension to the 12-byte header for ltn0.pgf)
46 bits of unknown data
5-bit horizontal advance
To find the character metrics one has to read the main pointer table. The table is constructed of N-bit pointers, where N is found in the file header at offset 0x1C. The number of pointers (and characters) can be found in the file header at offset 0x14. It is not known yet how to locate the main pointer table. The RLE compression works on 4-bit nibbles (the low nibble of a byte is considered to precede the high nibble in the stream). There are two sequences defined for this RLE:
a nibble N<8: take next nibble and replicate N+1 times into the output stream
a nibble N>7: take next 16-N nibbles and copy directly into the output stream

上面的文章好像是针对拉丁字符的,中文字符感觉要参考一下国内的程序,或者PPSSPP。
11 changes: 11 additions & 0 deletions docs/profiling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Profiling
PSP Toolchain 支持 `gprof`(GNU Prof)。
## GNU Prof
### 使用方法
1. 编译程序
直接编译:
链接:
2. 生成.out
3. 使用gprof分析.out文件。

参考资料:gprof官网
61 changes: 38 additions & 23 deletions docs/stublibs.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,36 @@
## 编写可被其他模块动态加载的PRX模块
> A PRX-format module can be used as a resident library. A resident library provides some of its functions to another module.
编写导出表,将导出表嵌入PRX模块。

1. 撰写PRX程序的C代码
不写main函数,写module_start()和module_stop()函数
注意:请于module_start()函数中加一行`printf()`函数调用,否则在由ELF文件生成PRX文件时会出现缺少.lib.stub段的问题(WHY?)。
2. 编写导出表,指定哪些函数可被其他模块引用
导出格式。
必须导出:
自定义导出:
据说不推荐导出变量。
3. 对导出表使用`psp-build-exports -b`生成C代码
### build.mak
```makefile
我们通过编写**导出表**来指定自己模块中哪些函数可以被外部访问

并通过向模块使用者提供**导入表**使其能引入自己的模块。

由于使用者能够**导入**的函数也就是编写者**导出**的函数,

我们只需要编写一次导出表,就可以通过导出表生成导入表。

### Step 1:编写导出表,将导出表嵌入PRX模块。

1. 撰写PRX程序的C代码:不写`main`函数,写`module_start()``module_stop()`函数
>!!! Hint
注意:请于module_start()函数中加一行`printf()`函数调用,否则在由ELF文件生成PRX文件时会出现缺少.lib.stub段的问题(WHY?)。
1. 编写导出表(`.exp`后缀的文本文件),指定哪些函数可被其他模块引用
> 导出格式。
>
> + 必须导出:
> + 自定义导出:
>
> 据说不推荐导出变量。
2. 对导出表使用`psp-build-exports -b`生成C代码
```makefile title="build.mak"
%.c: %.exp
psp-build-exports -b $< > $@
```
4. 编译1、3中的C代码得到可重定位目标文件,链接后生成PRX文件
### build.mak
```makefile
# 将3中C代码对应的目标文件设为构建目标
ifdef PRX_EXPORTS
EXPORT_OBJ=$(patsubst %.exp,%.o,$(PRX_EXPORTS))
EXTRA_CLEAN += $(EXPORT_OBJ)
3. 将步骤3中的C代码进行编译,与源程序相链接,从而将导出表信息嵌入源程序。
```makefile title="build.mak"
ifdef PRX_EXPORTS # 预先指定 PRX_EXPORTS = your_name.exp
EXPORT_OBJ=$(patsubst %.exp,%.o,$(PRX_EXPORTS)) # 将其纳入构建目标
EXTRA_CLEAN += $(EXPORT_OBJ) # 将可重定位目标文件纳入clean目标
```
```makefile
# 编译链接
Expand All @@ -52,13 +59,21 @@
$(FIXUP) $@
```
注意,链接时需要指定`LDFLAGS = -nostartfiles`以避免出现`main`函数符号未定义的问题。
**至此,导出表已嵌入PRX文件,接下来的步骤是为将要使用该PRX文件的模块准备的**
5. 对导出表使用`psp-build-exports -k`生成存根.S文件(module stubs / import table)
6. (可选)编译.S文件至.o文件并通过ar即得到存根库
### Step 2: 从导出表生成导入表
1. 对上一步编写的导出表使用`psp-build-exports -k`生成存根.S文件(module stubs / import table)
2. (可选)编译`.S`存根文件至`.o`可重定位目标文件并通过ar打包成`.a`静态链接库存档文件即得到存根库
## 在程序中动态加载PRX模块
+ 写代码时:包含存根库的头文件
+ 链接时:编译存根.S文件并与之链接 / 链接存根库
使用PSPSDK中加载动态库的函数
sceKernelLoadModule
sceKernelFindModuleByUID
sceKernelStartModule
+ 链接时:编译存根`.S`文件至并与之链接 / 链接存根库
`OBJS`中指定.S->.o的文件名
Expand Down
58 changes: 49 additions & 9 deletions docs/translate.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,60 @@
# Language Patch
这篇文章写的太好了,我觉得没必要再多说什么了。
https://github.com/Bunkai9448/digipet_PSP/blob/main/RE_Guide.md

这篇[Digivice Ver. Portable逆向工程教程](https://github.com/Bunkai9448/digipet_PSP/blob/main/RE_Guide.mdDigivice)写的太好了,涉及从逆向到发布的全过程与工具链,我觉得没必要再多说什么了。

> [digipet_PSP/RE_Guide.md](https://github.com/Bunkai9448/digipet_PSP/blob/main/RE_Guide.mdDigivice)
# 汉化相关
## 传统汉化方法
> !!! Hint
> + 码表:即编码字节同字符的对应表。
>
> + 字库:即储存字体字形图像的文件。
都是2010年前后,上个时代的资料了。现在的人应该用更现代的语言来表述。使用现代的工具链!
从二进制文件中检测潜在的字符串并生成<偏移量,字符数,字符内容>的一张表。通过这张表可以方便地对源文件进行替换和修改。

为了检测潜在的字符串,需要**编码字节与字符的对应表**,即“**码表**

由于游戏通常采用[SHIFT-JIS](http://www.rikai.com/library/kanjitables/kanji_codes.sjis.shtml)编码,而该编码中汉字字符数量极为有限。

https://xiongonline.github.io/[%E8%BD%AC%E8%BD%BD][NDS]NDS%E6%B1%89%E5%8C%96%E5%B0%8F%E7%99%BD%E6%95%99%E7%A8%8B.html#top
因而人们会**修改字体文件**,即“**字库**”,将原来的SHIFT-JIS字节序列对应的日文字符图像修改为其他的汉字字符图像。

https://www.romhacking.net/utilities/818/
此时字节序列同字符的对应关系已然发生改变。

https://bbs.chengyi.org/thread-111286-1-1.html
因而又要重新写一张字符和编码字节的对应表,将翻译后的文本映射到新的字节序列上。

近似字符表:https://github.com/ultrapre/GBK_SJIS/blob/master/gbksjisTBL/README.md
此时再对源二进制文件中的字符序列进行替换修改,便完成了文本的汉化过程。

> 参考资料
>
> 码表相关
>
> + [【GBA、NDS、PSP】汉化基础教程——文字篇(三)by PGCG](https://bbs.chengyi.org/thread-111286-1-1.html)
> + [NDS汉化小白教程 —— fengarea(A9VG汉化组)](https://xiongonline.github.io/[%E8%BD%AC%E8%BD%BD][NDS]NDS%E6%B1%89%E5%8C%96%E5%B0%8F%E7%99%BD%E6%95%99%E7%A8%8B.html#top) 第三话:字库码表篇•初步
> + [游戏汉化教学贴-文本的导入导出基础篇](archive/bluekiller.htm)
### 理想情况
能够从二进制文件和资源文件中找到字符串和字库,直接进行修改。
在2010年左右,`WQSG``CrystalScript`用于处理码表、检测二进制文件中潜在的字符串,`CrystalTile`用于处理二级制文件中的图片和字库。
> 参考资料
> [CrystalTile](https://www.romhacking.net/utilities/818/)
### 无法获得字符串或字库
由于加密等问题,汉化工作者有时无法从二进制文件中寻找到字符串和字库。此时往往有以下两种方法。
#### 近似汉化
在无法获得字库时,使用SHIFT-JIS中已有的同汉字相近的日文字符作为对应汉字的替代。
> 近似字符表:https://github.com/ultrapre/GBK_SJIS/blob/master/gbksjisTBL/README.md
#### 内存汉化
无法在源文件中获得字符串或字库,但由于游戏运行时未加密的字符串和字库会加载到内存中,因而可以通过插件在游戏运行时对内存相应区域进行替换修改。
> [CG汉化组-幻想传说汉化测试插件](http://bbs1.chinaemu.org/read-htm-tid-80057-uid-71886.html)
## 具体实现
都是2010年前后,上个时代的资料了。现在的人应该用更现代的语言来表述。使用现代的工具链!
### 仅仅对文件修改
按照传统的汉化方法,只需要对资源文件和可执行文件中出现的代表字符串的`字节序列``字库`进行修改汉化工作便完成了。这一步的难点就在文件格式的解密上。

SHIFTJIS表:http://www.rikai.com/library/kanjitables/kanji_codes.sjis.shtml
具体来讲,对于`PSP`汉化,可以通过`PPSSPP`的调试功能逐步分析文件格式。可以参考[《诡计对逻辑》汉化研究](https://pbteam.cn/posts/txl-hack/)
### 修改可执行文件/添加外部插件
对于一些需要使用内存汉化法或者调用的是系统字库的游戏,则需要进行程序逻辑的修改或者编写新的插件。也就是要进行反汇编、注入、劫持等操作。这更接近于本网站的主题。

https://uofw.github.io/upspd/docs/software/ModuleTutorialv1.pdf

Expand All @@ -31,4 +71,4 @@ v0:0x539F

8CB4-> 539F

08868dac调用sceFontGetCharInfo和sceFontGetCharGlyph
08868dac调用sceFontGetCharInfo和sceFontGetCharGlyph

0 comments on commit 3b6da63

Please sign in to comment.