• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Which Pokémon Masters protagonist do you like most? Let us know by casting a vote in our Masters favorite protagonist poll here!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[ASM & Hex] [Emerald] Setting or changing player backsprite before a battle (tag battles, etc)

  • 14
    Posts
    12
    Years
    • Seen Oct 4, 2020
    Hello again.

    For my hack, there are a few points in the story where it would be really nice if the player participated in a multi battle with and/or against some of the major characters. Pokemon Emerald is the only gen3 game (and the first game in the series), to implement this feature in the player/Steven v Maxie/Tabitha battle at the Mosdeep Space Center. Unfortunately for me, this battle is hard-coded into the game, meaning that from XSE you can only ever start that one battle that's stored in the ROM. The script looks something like this (got it from here annotated by me):

    Spoiler:


    Since the battle is hard-coded unto the game, you only have that one to play with. You can change Steven's party pokemon simple enough, and change Maxie and Tabitha to two different trainers, and make your one tag battle a different tag battle. But if you want multiple tag battles like me, you're out of luck.

    The now-deprecated and amazing (yet frustratingly undocumented) Pokemon Battle Engine Upgrade has implemented a way to have as many different custom tag battles as you want, but it doesn't work for what I want to do for a number of reasons. So I've decided to implement this feature on my own as well as some other niche battle types if I can figure it out (disable bag, disable exp, that kind of stuff). special 0x3E happens to queue a battle task to start later using whatever trainer battle information is currently in RAM. So I've been abusing it: if I can write some ASM that changes all the necessary flags to start the right kind of battle I want, hypothetically it should just do, yes?

    Okay, so onto the problem.

    So far, I can get a tag battle to load correctly with custom partner pokemon and custom opponents. However, when the battle starts, it looks like this (good)

    [PokeCommunity.com] [Emerald] Setting or changing player backsprite before a battle (tag battles, etc)


    and this (not good)

    [PokeCommunity.com] [Emerald] Setting or changing player backsprite before a battle (tag battles, etc)


    and this (also not good)

    [PokeCommunity.com] [Emerald] Setting or changing player backsprite before a battle (tag battles, etc)


    So first of all, I want to stop and acknowledge how funny this is. This is hilarious I mean they just stare at you all dopey like. Why is this the default behavior? Why is it not just programmed to load a default backsprite? Why is it even possible to load front sprites in the backsprite slots. Like... WHAT? And the game is doing it purposefully too; if you change the partner the partner sprite changes to some different frontsprite. Just... whhhyyyyyy.

    The rest of the battle loads fine too. The frontsprites scroll off screen and throw a pokeball like nothing's wrong and the game plays as it should from there-on.

    So TL;DR - how do I tell the game which backsprites I want it to load in ASM (or C, same thing at this point)? My expectation is that in RAM, there's a pointer somewhere for your backsprite and a pointer somewhere for the partner backsprite and two more for the palettes, and if I change those I change what gets loaded. If not, there's a set-up function I'm forgetting to call. But where?

    I know thanks to staring at the Battle Engine Upgrade source code for days now that there's a variable in ram for storing the index of the player sprite (at 0x02022FF3) and one for the partner (at 0x02022FF2). But setting those does NOT make the game load the correct sprites. The Battle Engine Upgrade rewrites the entire battle system so it has its own way of handling this. I tried to copy what it does but it just segfaulted the ROM and it seems overly complicated and not applicable with the route I ended up taking.

    If you don't know where these pointers to change are, some guidance on how to start looking for these pointers would be great too. I need to learn how to do research, it would make the process at lot easier. For now though, I'm pretty stuck.

    Oh, and, if it helps, here's what the function I wrote that sets all the necessary tag battle flags looks like. Basically all the offsets I just stole from the Battle Engine Upgrade's ld file. It's in C, but I'll happily take and adapt a solution in ASM.

    Spoiler:


    Thanks in advance
     
    So I did a little more research and it turns out this is actually expected behavior which sucks for me I guess but whatever I'll figure it out.

    Basically, in the battle frontier you're allowed to have an AI partner, but they didn't want to make a few more backsprites for every trainer class. So instead what they do is if the partner is going to be Steven, it loads the backsprites correctly, otherwise it loads the frontsprites. The graphical glitches I assume are related to the fact that it only looks right in the battle frontier.

    I found after looking into pokeemerald for a while. See the function PlayerPartnerHandleDrawTrainerPic in this file.

    I also set the partner to Steven in my own code and sure enough the backsprites are drawn as expected:

    [PokeCommunity.com] [Emerald] Setting or changing player backsprite before a battle (tag battles, etc)


    So that function has to be replaced for this to work. Yeah yeah using the decomp would be easier I know. But I'm this close to getting this to act the way I want so I won't stop now
     
    Back
    Top