News:

Don't forget to visit the main site! There's lots of helpful docs, patches, and more!

Main Menu

[MZM] Hex codes for Game Items, and the Chozo statues?

Started by Amorsis, August 28, 2016, 02:48:54 AM

Previous topic - Next topic

Amorsis

So after watching countless speedruns and let's play's of some Metroid hacks, I decided on making my own. After a while of fiddling with Biosparks new tool MAGE, I noticed that Items were attached to their respective statues. Is there and way to seperate them? Also I was having issues with doors. Namely the doors without hatches like the secret ballspark area in Brinstar.

[spoiler][/spoiler]

biospark

Quote from: Amorsis on August 28, 2016, 02:48:54 AM
Is there and way to seperate them?

Not without some serious asm hacking.

Quote from: Amorsis on August 28, 2016, 02:48:54 AMAlso I was having issues with doors.

You'll have to be more specific than that.

Amorsis

#2
Well when I go into morphball and try to go through the door, nothing happens. Samus goes off the screen. Also, has anyone tried to seperate the items on the chozo statues before?
Here, I made a quick video : https://youtu.be/TCvCvDriyJ4

biospark

Quote from: Amorsis on August 28, 2016, 03:03:06 AM
has anyone tried to seperate the items on the chozo statues before?

I don't believe so.

Concerning the door, does it have the proper clipdata underneath it? If not, have you read the documentation? http://arkarian.org/tdk/mage/doc.html#doors

Amorsis

Quote from: biospark on August 28, 2016, 03:18:16 AM
Quote from: Amorsis on August 28, 2016, 03:03:06 AM
has anyone tried to seperate the items on the chozo statues before?

I don't believe so.

Concerning the door, does it have the proper clipdata underneath it? If not, have you read the documentation? http://arkarian.org/tdk/mage/doc.html#doors

I didnt have the correct clip data. Thank you. Bookmarked that page too :P My question still stands though, has anyone successfully seperated the Chozo item balls from the Chozo statues?

Amorsis

If anyone has the codes for both the major items and the Chozo statues, thatd be great. I dont have time to root around the games code right now, because Im trying to get to understand Hexadecimal. Also, does anyone know how to work Hex workshop? If so, please PM me.

interdpth

#6
Quote from: Amorsis on August 30, 2016, 05:03:59 AM
If anyone has the codes for both the major items and the Chozo statues, thatd be great. I dont have time to root around the games code right now, because Im trying to get to understand Hexadecimal. Also, does anyone know how to work Hex workshop? If so, please PM me.

Here is your bible:
http://datacrystal.romhacking.net/wiki/Metroid_Zero_Mission:RAM_map
3001530    Health capacity
3001532    Missile capacity
3001534    Super missile capacity
3001535    Power bomb capacity
3001536    Health status
3001538    Missile status
300153A    Super missile status
300153B    Power bomb status
300153C    Beam + Bomb status

    1 for Long beam
    2 for Ice beam
    4 for Wave beam
    8 for Plasma beam
    10 for Charge beam
    80 for Bombs

300153D    Beam + Bomb activation status

    1 for Long beam
    2 for Ice beam
    4 for Wave beam
    8 for Plasma beam
    10 for Charge beam
    80 for Bombs

300153E    Suit + Misc. status

    1 for Hi-jump
    2 for Speed booster
    4 for Space jump
    8 for Screw attack
    10 for Varia suit
    20 for Gravity suit
    40 for Morph ball
    80 for Power grip

300153F    Suit + Misc. activation status

    1 for Hi-jump
    2 for Speed booster
    4 for Space jump
    8 for Screw attack
    10 for Varia suit
    20 for Gravity suit
    40 for Morph ball
    80 for Power grip

3001540    Scanned map status

    1 for Brinstar
    2 for Kraid
    4 for Norfair
    8 for Ridley
    10 for Tourian
    20 for Crateria
    40 for Chozodia

3001541    Low health beep

    0 for not on
    1 for on

3001542    Extra Suit Status

    0 for normal suit
    1 for unknown items enabled
    2 for zero suit
    3 for combination of 1 + 2


In hexworkshop ctrl + g will take you to an address, make sure insert is off.

Once you're advanced enough, you can use mage to go to the chozo statue you want and get the AI for it. Then look in the related AI functions for when it grants Samus an ability.

In ASM  to grant Speed Booster you'd be looking for
LDR r0, =0x300153E
LDRB [r1], r0
mov r2, #2//Speed Booster value
OR   r1, r2
STRB [r0], r1


then you'd have the offset for the asm opcode mov r2, #2

in a hex editor it'd be like 02 something, so you'd change the 02 to another flag value

Amorsis

Thank you Interdpth. Although, as Im very inexperienced with asm and hexcoding, I think this will be quite the project for me. Do you have any recommendations on how to start or what I should do to practice before I end up destroying my rom?

interdpth

#8
Use the tables I copied from datacrystal and mess with equipment and samus' health to understand. They're all from a secton of memory called WRAM. This memory section starts at 0x3000000. Grab some version of VisualBoyAdvance. Open up the game, proceed to a part where you're ready to start messing around. Go to tools -> memory viewer.

So you're going to be greeted by a bunch of data. GBA is 32 bit, so you can have a variable with a max size of 4 bytes(not counting making them an array/list)

Nothing to really be afraid of.
1 byte has value 0-255(there's stuff called signed and unsigned you'll learn about eventually)
2 bytes has values 0-65356
You'll never see a 3 byte variable(unless the compiler was extremely weird)
4 bytes has values 0-4294967295

So you'll mainly want to operate in hexadecimal so let's redefine that list

1 byte has value 0-0xFF(there's stuff called signed and unsigned you'll learn about eventually)
2 bytes has values 0-0XFFFF
4 bytes has values 0-0XFFFFFFFF

Most of the stuff you'll mess with value wise is 1 or 2 bytes. 4 bytes usually indicate an address/pointer.

An address is like I mentioned above 0x3000000, there's also 0x2000000 which is another memory area.
0x8000000 is the address that the ROM lives in when it's loaded. Nothing you do in the emulator should affect your actual rom. That's why I suggest messing with memory first.

http://problemkaputt.de/gbatek.htm is an amazing resource for technical info.

But for a test. Say you just had samus land and in the memory viewer you want to give Samus 1000 health and give her morph ball and high jump  and ice beam and wave beam. 

So using the data crystal document, we know that Samus's health is at 0x3001536 but she always has a health capacity at 0x3001530. That's cool.  Her health is stored in straight values. The 0x donates we're working in base16/hexadecimal.

So we have those addresses prepped. So let's go ahead and make her have 1000 health. Open up your handy dandy windows calculator, go to program mode. Type in 1000, then switch to hex display. Samus' health is in two bytes. So in order to see that in the viewer correctly. Change the memory viewer to 16 bit mode. Otherwise we're working in 8 bit. Oh the difference is how it's stored in lil' endian. So type in the value from the calculator. Now real quick so you can understand something. Hop between the different displays. Notice how after 8 bit, the bytes get reversed to show their proper values?

When you open the ROM in a hex editor, it'll be in 8 bit. So always take that reversing into consideration. Switch back to 16 bit. Make sure both addresses for the health match. Then click on the game again so it continues running. Boom samus now has 1000 health(or 0x03e8) and make sure you put 0x03e8 and not 0x3e80. Or I'm sure some graphical bugs will happen.

Now for the part, granting morph ball and ice beam.

300153E  has our suit status. Now since you just put in a value for health, I bet you're wondering how to give samus everything when the list looks like this:   
    0x1 for Hi-jump
    0x2 for Speed booster
    0x4 for Space jump
    0x8 for Screw attack
    0x10 for Varia suit
    0x20 for Gravity suit
    0x40 for Morph ball
    0x80 for Power grip

So there's these two things called  Logical AND and Logical OR. These are special things.

OR is used to set.
And is used to check.

This is called bitstoring/bitpacking. If you wanted to give samus Powergrip, Morphball and Hi-jump go to windows calculator in programmer mode.

Perform the following PowerGrip Value OR Morphball Value OR Hi-jump value
You should get 0xC1

These status' are only 1 byte. But once you set the address to 0xC1. You should see the effects immediately. Please try to do the ice beam example yourself. This will give you a big start in understanding everything.

if you understand this all, grab no$gba debugger(it's free now) and I'll teach you how to find stuff
@FelixWright  if he finds any of this useful

Amorsis

Really got me excited Interdpth. Messing with memory is fun. On the line for the ice beam, I kept thinking since it was a diffrent beam, Id have to do down a byte. but no. I kept giving myself Varia, gravity, and hi jump boots by accident :P

https://postimg.org/image/mtmkehb97/

interdpth

Nice! Once you feel comfortable with it, you can grab no$gba. Then read up on it's debugging feature. Then go to a stature you want to change, set a break point on writing to that memory address for the thing it's giving and you should be able to find where it's setting the flag at. I can help you if I'm in #metconst and  online.

Amorsis

Quote from: interdpth on August 30, 2016, 07:51:01 PM
Nice! Once you feel comfortable with it, you can grab no$gba. Then read up on it's debugging feature. Then go to a stature you want to change, set a break point on writing to that memory address for the thing it's giving and you should be able to find where it's setting the flag at. I can help you if I'm in #metconst and  online.

I can't thank you enough. I really wanted to tinker with stuff like this before. Modding and such, I even tried to learn Java and C++, but to no avail. ROM hacking soo much simpler. Really. Thank you. I appreciate your help. I definitly will get back to you on what Im working on.

interdpth

You can make rom changes in VBA/no$gba by going to the 0x8000000 region of memory and making changes there. The world is your oyster.

Amorsis

Thanks Interdpth. I look forward to collaborating, and the future of this community.