Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Fire Emblem Ultimate Tutorial.doc
Скачиваний:
1
Добавлен:
01.07.2025
Размер:
7.86 Mб
Скачать

I digressed a lot, but back to the point:

strb r0, [r1]

So strb stores a byte. How does this code work? Well, this one’s a bit tricky. We’re actually storing the byte of r0 into r1. It’s been a while, but in this example, r0 = 0x03, and r1 = 0x0202BC13. Now that we know how to use thumbref, let’s see what it says about this.

STRB Store Register (unsigned byte)

STRB Rd, [Rn, #] [Rn + (#<<2)] = Rd

STRB Rd, [Rn, Rm] [Rn + Rm] = Rd

No pic this time because there’s this stupid grey line plaguing my thumbref and it looks ugly. So raw text instead.

Anyhow, what we’re doing doesn’t really match either of these formats. However, you can kind of think of it as either one, except we’re ignoring a parameter. There is no extra # or register we’re dealing with. Our code is just strb r0, [r1, #0x00] if you want to think of it that way, though I wouldn’t write it that way.

So what it’s saying is that it’s storing a byte from Rd into Rn. Which is odd, because we said “into Rn”, and yet “Rd” is the destination register. Yeah, I don’t really understand it myself, but that’s how it works. Back to the example, that means we are storing r0, 0x03, into the OFFSET 0x0202BC13. Why offset? Because as I mentioned earlier, brackets denote an offset, giving an actual meaning to the word “0x0202BC13”.

Okay, so now we know 0x0202BC13 is an offset. What’s at this offset? We made it so that we changed the value at 0x0202BC13 to 0x03. That’s what “strb” does. Well, what we did is kind of like memory hacking—0x0202BC13 contains the value for the mode, which I actually mentioned a while back. If it’s 0x03, the game reads it as “Hector’s mode”. So what we did was changed the value so it’s 0x03. We essentially memory hacked using assembly, except we did it FOR the player. Cool beans, huh?

Now, I’ve taught a lot, so let’s do some practice. Well, just one little practice. I’m going to give you something just like before and you’re going to tell me, to the best of your capability, what it does.

ldr r1, =0x0202BC0C

mov r0, #0x40

strb r0, [r1]

…It’s actually the next part of the ASM hack we’re looking at here. Look through it and try to figure out what it does. Think about what value is stored in each register. Try to figure out what the values “0x0202BC0C” and 0x40 do—I specify it a while back. Then, read on.

What it does is load 0x0202BC0C into r1, replacing the old value that was there. We don’t need whatever was in r1 before, so we’re just overwriting it.

Then, it moves the number 0x40 into r0, meaning r0 is now equal to 0x40.

Lastly, it stores the value 0x40 at the offset (denoted by brackets) 0x0202BC0C.

From a practical stand point, we “memory hacked” the offset 0x0202BC0C to be 0x40, which sets the mode to “hard mode”.

If you understood all of that, great job—if not, I suggest you review it before you move on. Remember that there are other resources to make use of besides this tutorial. ^_^

Now, we only have one line left. W00t! ALMOST THERE! It’s taken forever, but there was a lot to teach besides just the opcodes. You’ve learned a lot. Let’s wrap this up.

bx r14

Our shortest code yet, but there will be another long explanation.

…You see, there are 16 registers. r0-r15. I think. (I know, I’m never sure of anything.)

But some registers have special purposes. Generally speaking, r0-r7 are free for you to use. r8-r13, I dunno, don’t ask. r14 and r15 are a bit special though. r14 contains the address that the “game” or “processor” or whatever you want to call the “thing” that runs through ASM was at before it last branched. I think. Don’t quote me. On the other hand, r15 contains the address of where you are right now.

Thus it’s a little bit risky to mess with these, but they’re also very important to have a working knowledge of. FYI, r13 is also called sp (stack pointer), r14 is also called lr (link register), and r15 is also called pc (program counter). They’re all super important in more complex hacks. For now, what this does is “branches and exchanges” to r14. Since r14 contains the address of where the game was at its last branch, what it does in this case is takes you back to where you just were before you started running this code.

Think about this from the game perspective: everything runs through ASM, correct? So before the game ran this ASM routine, what was it doing?

…Wasn’t it running ASM related to the event codes right before it?

I think it was.

So what will it do?

It will return to that point and start running from right after the ASM call you did with ASMC. In other words, it’ll run the next event code.

IN OTHER WORDS, it ends the ASM routine. It says “we’re done here—go back to whatever you were doing before you were running me”.

IN OTHER WORDS, we’re done here.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]