Romhacking => ROM Hacking Discussion => Topic started by: Tailo on April 30, 2018, 01:26:24 pm

Title: Help With ASM!
Post by: Tailo on April 30, 2018, 01:26:24 pm

I need help to try to modify an order in the game Dragon Ball Z Buus Fury. I put you in situation. The thing is that there is a sequence in which two characters come out and I want one of them to appear instead. And you may ask, why do not you modify the sprite and that's it? Well because I want to introduce a new sprite and not replace the original, because it is also necessary in the game. The theme is that the code does not use a pointer to say that sprite should appear, but use a byte to designate the character what should appear That is, suppose that the code that gives the order is 02 77 00 01, this last byte (01) is the one that according to which hexadecimal number you put, a character or another appears. For example, 01 is Gohan, 02 is Goten, 03 Trunks, etc. It is like a kind of pointer that directs the pointer of the sprite in question, since I tried to leave it in 01 (Gohan) and replacing the pointer of the sprite of this by Vegeta and logically appear Vegeta. I hope to be explaining myself well. . That is, I want to get that for example, changing that byte to 09 for example, read the sprite that I have entered in a free offset. I tried to look a bit for asm, but it turns out that as I change that byte, it also changes the asm code (I checked it in CrystalTile2) For example: with the 01 byte, which is the original, comes the following: mrseq r7, CPSR, if I put 02 (it would be goten) it appears: andeq r7, r0, 80000h, if I put 03 (trunks) what appears to me is ????, if I put 04 (Vegeta) streq r7, [r0], -720h !. The problem is that I tried to find those functions (I do not know if they are called like that) but I can not find anything to explain what they do. I imagine it is normal in games, but apart from translating, re-spooling and modifying sprites, this escapes me a bit. I hope you can help me. Thank you.
Title: Re: Help With ASM!
Post by: Valendian on May 01, 2018, 09:36:04 am
Im not sure i fully understand the problem. But i can clarify at least one area of confusion. You are changing bytes and this effects the disassembly. There are two possible causes
1) the bytes are program instructions and by changing those bytes you are corrupting the program.
2) the bytes are data and just so happen to map to well formed instructions. This is possible and requires you to use reasoning to determine it is data.

Are there invalid instructions mixed in to this area of the program? If so then most likely it is data and the dissasembly has no meaningful information.
Otherwise the changes to the disassembly are purely because you changed the bytes. In this case you can assume that those bytes are part of the program and the data is elsewhere
Title: Re: Help With ASM!
Post by: FAST6191 on May 02, 2018, 04:43:40 am
There are two main ways a game does cutscenes and stuff like this.

1) Code level changes, in which case ASM is in your future.
2) A scripting engine within the game. Can be anything from a usefully Turing complete programming language to something rather more basic. Also yes this gets confusing at times when you are trying to figure out whether someone means the text in a game's script or the scripted events within a game, even more so if people come from the pokemon hacking world where edit scripts almost exclusively means stuff for cutscenes and in game events.

If you are playing with assembly for 2) then you are going to run into issues as you will most likely break the engine in your basic edits. Now you can still use ASM knowledge to help you figure out what the engine is doing, indeed it is probably the better way to do such a thing; there are a bunch of ways to edit text, many of them quicker and easier than assembly approaches, but for scripting I would probably start with assembly until I knew otherwise.

Anyway doing 1) for anything other than a very basic or one off scene is annoying so coders more and more opted for something in the 2) world. The GBA having more than enough power for the game devs to dodge having to ring up the programmer when you want a character to move in a slightly different way.
Title: Re: Help With ASM!
Post by: Tailo on May 02, 2018, 12:56:49 pm
I am afraid, then, that I will have to abandon the idea of modifying the script. I do not have time to learn ASM and it seems quite complicated. I have discovered that in the same code of the script there are some bytes that are the ones that order the map that must be loaded and others the position and orientation of the characters. I've also noticed that the byte that changes the character, not only changes the sprite, but it also loads the character completely, that is, sprite and attacks. I suppose it loads the ID of the character. I know in which offset the IDs are, but I am not able to relate the code of the function with the character that it loads. Anyway, thank you very much for the answers.
Title: Re: Help With ASM!
Post by: zhade on May 07, 2018, 06:08:22 pm
I am afraid, then, that I will have to abandon the idea of modifying the script. I do not have time to learn ASM and it seems quite complicated.

I too thought that ASM looked too complicated for a long time and kept away from it.. but later found out its really the simplest language there is in a way.. its so simple that making something that would be easy in a "normal" programming language can be harder.. but it doesnt take time to learn the basics and be able to figure out what some bit of code does / how to modify it so it does what you want. you might run into some commands you dont know sometimes and have to learn a bit more, but there is not so much you have to learn to get you started. Probably less than any other language actually.