News: 11 March 2016 - Forum Rules

Author Topic: [SOLVED] Fixing Bunny palette loading in A Link to the Past.  (Read 8472 times)

ShadowOne333

  • Hero Member
  • *****
  • Posts: 1683
    • View Profile
Good day, RomHacking.net.

I have worked on a hack called A Link to the Past: Redux for the last year or so.
Right now, most of the bugs related to it have been fixed thanks to the help of several gifted ALttP hackers, like qwertymodo, Conn and puzzledude.

However, there is but one bug remaining, and this bug is also present in the original A Link to the Past, but it is not noticeable because both palettes are the same.

So, the issue can be fully explained in detail here:
https://www.zeldix.net/t1314-the-bunny-palette-issue-solved

Basically, Link uses one of 4 palettes throughout the game.
Palette #1 is the usual green tunic sprite, Palette #2 is the Blue tunic sprite, Palette #3 is the Red tunic sprite, and Palette #4 is an exact replica of Palette #1, but this one is used for the Bunny Link sprite.

In that post, puzzledude mentions a workaround to this issue, which is to make Palette #4 exactly the same as Palette #1, so that the game loads at all times the same colour palette for both Green tunic Link and Bunny Link.
In vanilla A Link to the Past, this issue cannot be seen easily, since both palettes are the exact same.

However, problem comes when you edit Palette #1 but leave Palette #4 intact.
The issue can be seen in ALttP Redux.
Green tunic Link's palette has been changed so that his hair is now blonde to closely match his original artwork.
When you are transformed into a Bunny with the Rabbit Beam (the yellowish thing), the Bunny shows up perfectly fine even with the modified Palette #1:

   


However, problem starts when you press X to view the Map or go to another room, then you get this:



When you press X / go to another room, the game doesn't check which palette was loaded previously, (Pal 1 or Pal 4) and it defaults to Pal 1 every time.

So, right now I am seeking help of anyone who is well known in ASM hacking to debug this issue and hopefully fix this, as this bug is ALSO present in the original ALttP, but since both Pal 1 and Pal 4 are the same in terms of colours in vanilla ALttP, the issue is not noticeable at all in-game.

It's only when you edit Palette 1 that the issue comes to light.

Thanks in advance to anyone who is willing to help fixing this bug.

EDIT:
It seems that if I get converted into the Bunny in the Ice Palace with the Blue/Red tunic, and then I enter another room while still being Bunny Link, the palette for the Bunny reverts to that of Blue/Red tunic (Pal 2&3) Link instead of the normal Bunny palette.
« Last Edit: May 29, 2017, 08:26:50 pm by ShadowOne333 »

rainponcho

  • Sr. Member
  • ****
  • Posts: 275
    • View Profile
Re: Fixing Bunny palette loading in A Link to the Past.
« Reply #1 on: May 23, 2017, 05:08:40 pm »
This only fixes world map. To be used with ShadowOne333 redux patch (expanded rom).
https://www.sendspace.com/file/ji4jrp


Spoiler:
Map reads tunic color here
Code: [Select]
$0E/D6C8 AF 5B F3 7E LDA $7EF35B[$7E:F35B]

and this is how bunny is detected
Code: [Select]
lda $02e0
ora $56
beq tunic_normal

So we load tunic (0-2) or bunny (3) and done.


I could do other cases but need snes9x savestates or have to play those areas. It's pretty trivial once you know the bunny flags.

ShadowOne333

  • Hero Member
  • *****
  • Posts: 1683
    • View Profile
Re: Fixing Bunny palette loading in A Link to the Past.
« Reply #2 on: May 23, 2017, 05:30:12 pm »
Hey rainponcho!
Thanks for the code!
I can provide you with detailed save states and SRAM saves as well if you need them, just let me know what places in particular do you need save states for.

rainponcho

  • Sr. Member
  • ****
  • Posts: 275
    • View Profile
Re: Fixing Bunny palette loading in A Link to the Past.
« Reply #3 on: May 23, 2017, 05:54:21 pm »
I'll start by asking for an Ice Palace savestate bug (thanks!). Although I just noticed a bug in the code. 16-bit A register - small update.

Code: [Select]
bunny_map:

// check bunny
lda $2e0
ora $56
and.w #$00ff
beq bunny_map_normal

lda #$0303
rtl


bunny_map_normal:
lda $7ef35b
rtl

ShadowOne333

  • Hero Member
  • *****
  • Posts: 1683
    • View Profile
Re: Fixing Bunny palette loading in A Link to the Past.
« Reply #4 on: May 23, 2017, 06:34:59 pm »
On the contrary, thank YOU for all the help you have given me in a lot of my projects :)
Here's the savestate:
https://www.dropbox.com/s/hzp2zhjjgwjj1ta/Saves.rar?dl=0

In the RAR you will find the oops, 000, 001 and srm files for use with Snes9x v1.54.1
Savestate 000 is right before the room where you encounter the Rabbit beam enemy, and 001 is saved right before the rabbit beam enemy touches you. I used "A Link to the Past Redux (Header).ips" for this test. (Normal redux, not New GFX).

Here's how to reproduce the problem:
  • Let the Rabbit beam touch you. This will transform you into Bunny Link
  • Once you are transformed, hit X to open up the map.
  • Now exit the room

As soon as you exit the room after entering the map, you will see that Link's palette changes when going into another room.
The palette changes into the palette for the current tunic, in the case of this save, I have the Blue tunic, so when the palette bug occurs, Bunny Link changes colours into a Yellowish fur and Blue clothes (palette #2), and it should be Palette #4 (exclusive palette for Bunny Link).
I believe this problem is exclusive to indoors/dungeons, as I cannot seem to find any place where to reproduce this in an Overworld area.
The bug occurs in the Overworld whenever you press the Map button while in Bunny form.
Also, if you are in the Overworld as a Bunny and use the Magic Mirror, you can also catch a glimpse of the change in palette RIGHT before the mirror transition ends.

Hope this helps out, and thank you so much for all of your help!

rainponcho

  • Sr. Member
  • ****
  • Posts: 275
    • View Profile
Re: Fixing Bunny palette loading in A Link to the Past.
« Reply #5 on: May 23, 2017, 07:35:12 pm »
This should fix most bunny problems.
https://www.sendspace.com/file/s44pdc


Magic mirror - game issues new palette a little before the bunny sprite transforms. So still a few frames of strange golden type fur. Obj palette 7. This will be tricky. ^^


edit:
Done - last asm file for bunny palette.
https://www.sendspace.com/file/eehsz4

Ignore issuing a new color.


edit2:
Looking into new gfx redux - L/R item switch. I get what it's doing so it just needs a bit of a rewrite probably.
« Last Edit: May 23, 2017, 11:26:35 pm by rainponcho »

ShadowOne333

  • Hero Member
  • *****
  • Posts: 1683
    • View Profile
Re: Fixing Bunny palette loading in A Link to the Past.
« Reply #6 on: May 24, 2017, 10:32:00 am »
Oh wow rainponcho!
How do you manage to be so good at this? :D
And more so that you help others with this kind of top-notch hacking.
Really, really appreciated, seriously.

And this:
Quote from: rainponcho
Looking into new gfx redux - L/R item switch. I get what it's doing so it just needs a bit of a rewrite probably.
This goes above and beyond!

Just a quick recap of the issue for New GFX:
  • The problem seems to occur whenever you get any item which exists in the item table beyond where the Shovel should be (like a bottle with something like a Fairy for example). Once you get a bottle, if you switch with L/R up to the point where the Shovel would be, it appears in the menu out of nowhere, and the Ocarina does as well.

    Even weirder, the shovel gets replaced by an Ocarina as well, leaving you with 2 ocarinas at the same time in some occasions.

Let me know if you need any more detail about the issue to help debug it.

Btw, the last ASM you posted, that's for usage with xkas right?
« Last Edit: May 24, 2017, 10:48:55 am by ShadowOne333 »

rainponcho

  • Sr. Member
  • ****
  • Posts: 275
    • View Profile
Re: Fixing Bunny palette loading in A Link to the Past.
« Reply #7 on: May 24, 2017, 10:54:20 am »
Yup. xkas-plus for others to see how it works. Here's ips patch also
https://www.sendspace.com/file/n5exzt


Quote
How do you manage to be so good at this?

Lots of fails and experimenting. Great debuggers like fceux, bgb, geiger, bsnes-plus. And usually I try to stick with smaller isolated problems. Short handyman projects.

When it comes to translation level hacking, I tend to wind down into a blob of applesauce due to the amount of work, expectations, difficulty, time+, quality control or whatever ends up bothering me. Or huge amounts of prototype backporting by request only; some Japan games are messy broken.


Quote
Even weirder, the shovel gets replaced by an Ocarina as well, leaving you with 2 ocarinas at the same time in some occasions.

From what I understand atm, the newgfx shovel position is normally used by the 4 bottles submenu. So it loops through '4 bottles' based on "item ram position" but it overreads past the item list and you get strange items. It's probably fixable but I'm rolling this through my head still.

ShadowOne333

  • Hero Member
  • *****
  • Posts: 1683
    • View Profile
Re: Fixing Bunny palette loading in A Link to the Past.
« Reply #8 on: May 24, 2017, 10:59:22 am »
Yup. xkas-plus for others to see how it works. Here's ips patch also
https://www.sendspace.com/file/n5exzt


Lots of fails and experimenting. Great debuggers like fceux, bgb, geiger, bsnes-plus. And usually I try to stick with smaller isolated problems. Short handyman projects.

When it comes to translation level hacking, I tend to wind down into a blob of applesauce due to the amount of work, expectations, difficulty, time+, quality control or whatever ends up bothering me. Or huge amounts of prototype backporting by request only; some Japan games are messy broken.


From what I understand atm, the newgfx shovel position is normally used by the 4 bottles submenu. So it loops through '4 bottles' based on "item ram position" but it overreads past the item list and you get strange items. It's probably fixable but I'm rolling this through my head still.
Thanks for the IPS! :D
Here's something which might be of help:
https://www.zeldix.net/t387-24-item-menu-and-additional-hacks-like-shovel-time-counter-for-this-menu#19546

In that post you will find the original patches for the New GFX patch for Redux.
In the very comment I go to, you can find a specific post by puzzledude which mentions that indeed the problem with the LR item switch compatibility with the New GFX patch is that the item slot used for the shovel is using the bottle spot.
Perhaps something in that thread could help in one way or another, it's not lengthy at all.

rainponcho

  • Sr. Member
  • ****
  • Posts: 275
    • View Profile
Re: Fixing Bunny palette loading in A Link to the Past.
« Reply #9 on: May 24, 2017, 06:00:33 pm »
Thanks. Yeah, I see what's wrong now. New gfx uses some custom vars at 7f5020  - 7f5021 for shovel (1,0) vs potions (1-4,1). I'm going to rewrite the code in redux expanded rom to make it swap around like the drop-down menu: potions come last, instead of right after shovel.


edit:
Hack done. I think it works but could use more testing.
https://www.sendspace.com/file/auqfr2


edit2:
L/R seems okay atm with new gfx. Hope it sticks. :)
« Last Edit: May 24, 2017, 09:07:17 pm by rainponcho »

ShadowOne333

  • Hero Member
  • *****
  • Posts: 1683
    • View Profile
Re: Fixing Bunny palette loading in A Link to the Past.
« Reply #10 on: May 25, 2017, 12:12:16 pm »
It works! :)
Now the Flute and Ocarina do not appear when getting the bottles, so no longer sequence breaking due to getting the Shovel early :P

Although, I did find one bug.
When starting a new game, once you get two bottles, the L/R Item switch does not go beyond the first bottle.
For example, after getting out of the Sanctuary after leaving Zelda, you can get two bottles right off the back in Kakariko, one by buying it from the salesman and another by entering behind a house in Kakariko as well.

Now let's say you store a Fairy in bottle 1 and a Bee in bottle 2.
If you use the L button to scroll between the items, the scroll completely bypasses bottle #2 (Bee), and just recognizes the bottle with the Fairy, while the one with the Bee does not appear.
If you use the R button to scroll the items, the scrolling gets stuck when reaching the bottle #1 (Fairy), and it does continue into any other item nor Bottle #2 (Bee). You can still press L to go back into the previous item before the first bottle though, but this does not occur when scrolling with the L button.

If you get any more bottles, the LR Item switch still only recognizes the first bottle, while the rest are simply ignored (L button) or gets stuck in the first one (R Button).

So far so good, it's just that little bug remaining, but the ASM hack you did to fix the Flute/Ocarina problem works :D

rainponcho

  • Sr. Member
  • ****
  • Posts: 275
    • View Profile
Re: Fixing Bunny palette loading in A Link to the Past.
« Reply #11 on: May 25, 2017, 04:37:59 pm »
Hmm. Okie. I'll play that spot and think it over; maybe newgfx invented some new codes for jar items like those. We'll get this done somehow. ;)

ShadowOne333

  • Hero Member
  • *****
  • Posts: 1683
    • View Profile
Re: Fixing Bunny palette loading in A Link to the Past.
« Reply #12 on: May 25, 2017, 05:02:38 pm »
Hmm. Okie. I'll play that spot and think it over; maybe newgfx invented some new codes for jar items like those. We'll get this done somehow. ;)
Wait, don't play that spot xD
https://www.dropbox.com/s/8h386f6ged2y5y9/Saves.zip?dl=0

I forgot to put the link to the save state as well in the previous post.
In there you will be at Link's house right after the first dungeon with two bottles in your inventory already.
One with a Bee (Bottle 1) and one with a Fairy (Bottle 2).

The patches I applied to the ROM I used are:
Redux New GFX (Headerless).ips
Redux GFX LR Item Switch (Headerless).ips
swap_redux.ips

Once you have the ROM ready with those three patches, you can go ahead and load up the Save State #2.
I believe Save State #1 gets you to a 100% save. State #2 should be inside Link's house as I stated above.

Let me know if you need anything else.

rainponcho

  • Sr. Member
  • ****
  • Posts: 275
    • View Profile
Re: Fixing Bunny palette loading in A Link to the Past.
« Reply #13 on: May 25, 2017, 06:37:22 pm »
Thanks! I think this will cover both cases.
https://www.sendspace.com/file/5voj7d

ShadowOne333

  • Hero Member
  • *****
  • Posts: 1683
    • View Profile
Re: Fixing Bunny palette loading in A Link to the Past.
« Reply #14 on: May 25, 2017, 06:58:38 pm »
Thanks! I think this will cover both cases.
https://www.sendspace.com/file/5voj7d
Wow, really just... wow!
It's working flawlessly!

I will give the game a full playthrough during the week and let you know if sometimes comes up (which I don't think it will :P)
If everything's in place I will send the fixes to the hack page.

Thank you so much, rainponcho!
Words cannot express just how thankful I am for all of your help, I feel so useless and incapable for not being able to help you out in the same way you do for me. T-T
But if there's something, let me know if I can be of help in anything you might need to!

Edit:
Btw, would it be fine if I were to include both of your bugfixes to the Download package?
So that anyone who wants to apply the Bunny palette fix to their ALttP hack knows where to get a clean IPS for vanilla ALttP as well.
(I will verify if it works in vanilla ALttP by making a full playthrough as well)
« Last Edit: May 25, 2017, 07:08:25 pm by ShadowOne333 »

rainponcho

  • Sr. Member
  • ****
  • Posts: 275
    • View Profile
Re: Fixing Bunny palette loading in A Link to the Past.
« Reply #15 on: May 25, 2017, 07:33:20 pm »
Don't mind at all. But. Both fix patches require 2MB pre-expanded rom - didn't want to collide with all the other ALttP hacks out there; they'd gobble up all the normal free space. Knowing how my irl pseudo-rng works, it probably still will conflict anyway with the big Wagner grandiose, aggressive hacks or even other smaller bugfixes. And well, if they know how to make asm hacks, then they'll figure out how to rewrite my hack to make it smaller and fit. :mrgreen:

SunGodPortal

  • Hero Member
  • *****
  • Posts: 2939
  • 2 + 2 = 5
    • View Profile
Re: Fixing Bunny palette loading in A Link to the Past.
« Reply #16 on: May 25, 2017, 07:42:14 pm »
Don't mind at all. But. Both fix patches require 2MB pre-expanded rom - didn't want to collide with all the other ALttP hacks out there; they'd gobble up all the normal free space. Knowing how my irl pseudo-rng works, it probably still will conflict anyway with the big Wagner grandiose, aggressive hacks or even other smaller bugfixes. And well, if they know how to make asm hacks, then they'll figure out how to rewrite my hack to make it smaller and fit. :mrgreen:

http://www.romhacking.net/hacks/2880/

You could follow this author's example and provide an asm file so that the user could easily relocate the code in case of a conflict.
Cigarettes, ice-cream, figurines of the Virgin Mary...

rainponcho

  • Sr. Member
  • ****
  • Posts: 275
    • View Profile
Re: Fixing Bunny palette loading in A Link to the Past.
« Reply #17 on: May 25, 2017, 07:53:23 pm »
That makes sense - it's a really popular game to hack. Here's asm source.
https://www.sendspace.com/file/zahhz7

ShadowOne333

  • Hero Member
  • *****
  • Posts: 1683
    • View Profile
Re: Fixing Bunny palette loading in A Link to the Past.
« Reply #18 on: May 25, 2017, 09:28:13 pm »
I "think" I found a game breaking glitch with the LR Item switch hack.
It seems to only affect the New GFX patch.

If you try to use either the L or R buttons right before you get ANY item (i.e. the Lamp), the game crashes completely.
This one is easy to test, simply start a new file, wait for Zelda's text to be over, then get off the bed and press either L or R to make the game crash.

If you get the Lamp first and then try to press L or R, then everything works normally.

rainponcho

  • Sr. Member
  • ****
  • Posts: 275
    • View Profile
Re: Fixing Bunny palette loading in A Link to the Past.
« Reply #19 on: May 25, 2017, 10:09:13 pm »
Quite right. v3. ips + src (cleaned up)
https://www.sendspace.com/file/vs8iu0