News:

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

Main Menu

[ZM_U] [ASM] Event Handler

Started by Jiffy962, August 15, 2024, 07:04:34 AM

Previous topic - Next topic

Jiffy962

Metroid Zero Mission - Clipdata Event Handler

This patch allows for more tailored event handling, by chaining clipdata together. With this patch, you are able to set, clear, or toggle any event whenever Samus enters a room. Aims to be simple to use for ROM hackers that aren't into writing ASM for events. Useful for things like switch-based toggle puzzles, end-of-hack boss rushes, or just any custom event handling you may need for your hack.

[spoiler=Patching]

  • Place an unmodified copy of your Zero Mission ROM (named zm.gba) into this folder.
  • Drag ZM_U_EventHandler.asm onto ARMIPS.exe. This will apply the patch.
  • Your new, modified ROM is zm_eventhandler.gba.
  • If you need to change the freespace this writes to, modify line 36. This patch uses freespace at 0x8043DF0, ie. Croco AI, but this is shared among many patches, so I'd recommend changing this to something else if you're using multiple patches.
  • If you need to change the clipdata for the event operators, modify lines 52, 54 and 56.
[/spoiler]

[spoiler=How to use]

  • Locate a room in your ROM, and navigate to the top left corner.
  • Choose an event you wish to handle. A list of event IDs can be found at: https://labk.org/maps/app/?game=zm&map=enums
  • Place clipdata in the top corner of your room, corresponding to your event operator. E0 clears the event (OFF), E1 sets the event (ON), and E2 toggles the event. (ON <-> OFF)
  • Place clipdata to the right of this, corresponding to the event ID the event operator will use.
  • If you wish to modify multiple events, repeat steps 2-4 to the right of your previous clipdata, creating a chain.
  • Done! Now the event will be set when Samus enters the room. The effect of the event will become obvious in the next room upon loading.

In this example in the image provided, I have a chain of event operators. In order, every time you enter this room, it will set the Kraid and Ridley Defeated events, clear the Grabbed By Statue events for Long Beam, Bombs, and Ice Beam, and toggle the event corresponding to Hard Mode. This is how your chains should look, but I doubt anyone would ever handle this many events at once...

[spoiler=Example][/spoiler]

I guess the only design flaw is game interactions with this layer of clipdata. The trivial solution is to increase your room vertical height by 1 scroll, and modify the scroll viewboxes accordingly. Plus, all the "useful" clipdata has a coincidentally higher value than any event we can modify!

[/spoiler]

Anyway, enjoy! Any questions or help, hit me up.