[Chinese] Game Tutorial Chapter 4: Change the picture words to system words

The original poster: Cry & Little Sorrow Views: 2663 Replies: 5 Posted in: 2011-12-18 07:09:07
This is a supplementary content, but it is also very important and needs to be memorized carefully -----
Picture characters are to draw characters on pictures, while system characters are to call the fonts that come with the phone, which can basically be distinguished from the appearance. After the text of this kind of game is directly translated into Chinese, the game will all display "口口口口口口" (blank). For games that use their own picture characters, the Chinese translation methods include matrix Chineseization and modification to system characters. Dot matrix localization has its limitations, such as too much text, dot matrix indexes in class files, etc., and is only applicable to some games. More are modified to system words. Modification requires you to have a certain understanding of the Java language, so before reading this tutorial, if you do not know Java, it is recommended to download and learn JAVA Beginners to understand JAVA (needs to be decompressed). S40 side preparation tools: MC, MobyExplorer,
Mocha decompilation
BE bytecode editor
jasmin(/ur l)
(url=http://down2.s60net.com:8118/res/201112/10/17938831/paojiao_94825.jar?) prev auditor ( /url)
(url=http://down2.s60net.com:8118/res/20118/15/89301505/paojiao_89300.jar?) Disass embler2Jasmin


Among the Java games that use picture fonts, the games of the DigitalChocolate game manufacturer are the simplest. Generally, the DigitalChocolate game is modified. The Chocolate game is an introduction to learning. The modification method of this manufacturer's game is a fixed formula and is not very complicated. Take DigitalChocolate's " My Pet Shop My Pet Store" as an example. After decompressing the game, use Mocha decompilation to decompile the class files in it, and browse through them briefly to find the following methods: public? (Image image, DataInputStreamdatainputstream, Font font, int?, int?) {} We found that it is in i. In class, generally speaking, the files of this method are in class files of 3 to 4K. Therefore, give priority to opening 3 to 4K files for browsing, and you will find them quickly. public i (Image image, DataInputStreamdataInputStream, Font font, inti1, int j1) {int k; int i2; int j2; char ch; if (image ! = null) (omitted...) What we have to do is add image = null above if (image! = null). Don't think about it in i. Adding it in java will not work. Due to confusion or tool reasons, basically the decompiled java file cannot be compiled back into a class file. The purpose can be achieved by modifying the bytecode. First create new folders "1" and "2", and put i. Put the class in, open the software Disassembler2Jasmin, and there are two address boxes. Fill in the first one, E:/1/i. Fill in the second field of class, E:/2/Click "Unshell" in the left soft key, and change i. Class is decompiled into bytecode, which will generate i. j file. Open i with text editor. j, which is the so-called bytecode, found at the beginning: invokespecial java/lang/Object/ () Vaload_1ifnull Label216 What we have to do is to add aconst_null
astore_1 before aload_1 and finally: invokespecial java/lang/Object/() Vaconst_nullastore_1aload_1ifnull Label216 Okay, save the changes, now put i. j compiles back to i. class, open Jasmin, there are two address boxes. Fill in the first one, E:/2/i. j Fill in the second one, E:/2/Click "Compile" in the left soft key. After the compilation is successful, it will be pre-audited. The compiled class file must pass the verification of the auditor before it can be packaged back into the software for use. Open the auditor Preverifier, fill in both path boxes with E:/2/, and start auditing. Let's check to see if it has been added correctly, using the modified and reviewed i in the Mocha Reverse 2 folder. class, see if image=null is added to the if (image ! = null) line of code? Well, if the addition is successful, just replace the original i. class, repackage, install and run the game to see the effect. The font looks like this before modification: The font looks like this after modification: Look, the font has changed and is the same as the mobile phone system font. In addition to the above tools, you can also use the bytecode editor BytecodeEditor to make modifications without decompiling, which is faster and faster. Software that can be used to view and modify the constant pool, fields, methods, etc. of a class and directly modify the bytecode. The process is to open the software - find and open i. class--method-"init", do you see familiar code? invokespecial java/lang/Object/() Vaload_1ifnull Label216 Edit and add aconst_null
astore_1 and then save and review it, which is much more convenient. -------------The basic operation process is like this, why do you need to modify it like this? Let's talk about the principle below. In i. We see this method in java: public void a (Graphics graphics, String string, int i1, int j1, int k1) {if (a! = null) {... graphics. setClip(i5, j5, k5 - i5, i6 - j5); graphics. drawImage(a, i1 - (a[i4] & 255), j1 - a[i4] - b2, 20);}i1 += b1 + c;}graphics. setClip(i2, k2, i3, j3); return;} Note: Many games use the public void a (Graphics graphics, String string, int i1, int j1, int k1...) method to draw strings. In the if section, we see the setClip method for cutting pictures. The principle of the setClip method is to display only a part of the content on the screen so that the content of the picture exactly located in that part is displayed. drawImage is a method used to draw specified pictures. It is easy to imagine that the method in if is used to display picture words. graphics. setFont(a); int j2 = graphics. getColor();if (a){......graphics. setColor(b); graphics. drawString(string, i1, j1 - 1, k1); graphics. drawString(string, i1 - 1, j1, k1); graphics. drawString(string, i1 + 1, j1, k1); graphics. drawString(string, i1, j1 + 1, k1);} graphics. setColor(a); graphics. drawString(string, i1, j1, k1); graphics. setColor(j2);} Note: The part below the if is the key part. We have seen the drawString method for drawing strings, so we know what we have to do is to make this method not execute the part inside the if, but directly go to the system word part below. (Supplement: If conditional divergence statements are converted into different processes according to different conditions. Then look at the beginning if (a! = null), we see that it is judged by judging the variable a. And where is this variable defined? Earlier we talked about the public c (Image image, DataInputStreamdatainputstream, Font font, int i, int j) method, we might as well cut over and take a look. public i (Image image, DataInputStreamdataInputStream, Font font, int i1, int j1) {int k; int i2; int j2; char ch; if (image ! = null) {a = image; ...} else {a = font; a = i1;b = j1; a = j1! = -1; } Note: You can see that this method involves the variable a, and the responsibility of this variable is to determine whether the image quantity is null. Then I saw a = font in else; this sentence means to assign the font amount to a (font variable), which can be understood as assigning the system font to a. So we hope to try to make this method always execute else, so we can add image = null before if (image ! = null); In this way, the value of image is null at the beginning, and the part in else will be executed. In the bytecode: aload_1ifnull Label216 corresponds to if (image! = null). (Because of the tool, it is more difficult to modify the positioning on the mobile phone than on the computer.) aload_1 is to load the first (1) object referenced by the local variable and push it onto the stack. The first local variable corresponds to the image in the first position of the method name. Add image=null here to create a null amount for image. aconst_nullastore_1 If you want to know more about the principle, you can take a look at Java Bytecode Revealed. It should be noted that the "1" in astore_1 is based on the previous if (image ! = null). We see that the third line is aload_1, here it is 1, then astore_1 must also be 1. In turn, if it is aload_2, then it should be astore_2 and so on. aconst_null
astore_1 This code segment is relatively mechanical, so you can remember it. The games produced by Digital Chocolate are relatively fixed, and everyone who wants to localize their games should modify them in this way. DC's game modifications are basically the basis for many game modifications. Therefore, it is recommended that everyone master it thoroughly. Games from other manufacturers are not that easy, and even games from the same manufacturer may have different modification methods. What is needed is continuous learning and practice, accumulating experience, and deepening the understanding of Java.

-------------------Chinese version of the text of Digital Chocolate game. After successfully changing the picture characters into system characters, you can directly Chineseize the text. The language files are basically l0_0, l0_1, l0_2 and so on. In "My Pet Store", generally choose Chinese l0_0 (English). Use the plug-in in the SUMEA folder in the computer tool Halo to open and modify it directly. On the mobile phone, you need to use hexadecimal. Open l0_0 in hexadecimal. 00 00 3c 75 represents the total number of bytes 15477, 00 00 01 6c represents the total number of starting bytes 364, 00 00 05 b8, 00 00 05 c1... represents the field starting byte. What is the field start byte? Left soft key - Edit - Go to the address, enter the address 0x5b8 or decimal 1464. After confirmation, you will find that it goes to the byte number 00 06 of English. Then enter the second 0x5c1 to go to the 00 02 of Ok below. Each starting byte corresponds to the following fields in turn. To put it bluntly, 5b8 is the total number of bytes before 00 06. The number of bytes will change when we localize it, and these need to be modified, which is quite complicated and troublesome.
reply 🤍 0 📤 share collect
Too profound!
Top…………
This is what you call difficult…
The one above is barely passable, this one I really don't understand.
If I open it with BE, inside there is only invokespecial java/lang/Object/()V, and nothing else afterwards. What should I do?
— All replies loaded —

Leave a Reply