Language…
8 users online: Aeon, dacin, drkrdnk, GRIMMKIN, JezJitzu, Nemesis1407, Pink Gold Peach,  Segment1Zone2 - Guests: 230 - Bots: 280
Users: 64,795 (2,376 active)
Latest user: mathew

NPC Sprite seems to interfere with Dragon Coin saving in SA1 hack

So I have been trying to figure this problem out for some time now. After a long time of testing and re testing I think I might have narrowed down the problem. The issue is that I want to be able save the dragon coins found in levels and have it show up on the overworld map that the coins were collected. I am working with an SA1 enabled rom, I am using the overworld counters patch, the individual dragon coin save patch, and applying bwram plus. Everything seems to work fine for the most part but I will occasionally have a level not register that all the coins were collected. What I finally figured out is that the NPC sprite seems to interfere with saving the dragons when spoken to in level. If you "talk" to the sprite and it is set to display a message that is set a different level number, the coins will not save once you beat the level. This does not happen if the message that the sprite displays is from a level number that the original game is programmed to read from. It only happens when it displays a custom message that you tell the sprite to read that is set to read from another level. This is done using the palette editor and setting the x position to match. I don't know if I am wording all of this clearly but I am sure that this NPC sprite is the culprit to the coin saving issue. I really want to use the NPC sprite but I can't figure out what is happening in the code to make it so that dragon coins won't save when the message is triggered. Any help with this would be greatly appreciated.


This is the npc sprite

https://pastebin.com/Y3NbaHFB
Trust the Fungus.
You've narrowed the problem down really well! Without having tested it, it looks like it's pretty much as you said. When the NPC sprite displays a message from another level, it tricks the game into thinking the current level number is something else, but it never restores the proper level number after it's done, so it leaves the dragon coin patch thinking you're in another level.

Here's a quick fix that might work. After print "INIT ",pc, add these lines:

Code
LDA $13BF|!Base2
STA !C2,x


and after ReturnZ:, add these:

Code
LDA !C2,x
STA $13BF|!Base2


Not sure how well this will work, especially when there are multiple NPCs on-screen at the same time, but it's worth a try.

(Also, thanks for reminding me that I've been meaning to remake those sprites sometime. The current ones are showing their age.)


 
Well I tested it out. Good news is that it saves the coins now. Bad news is that it causes the npc to only read messages from the level it is in rather than being able to tell it to read from other levels. However, if you have it set to read 2 messages it will display the second message you tell it to read from.
Trust the Fungus.
So after playing around with I did find something that kinda works. If you put the second part of the routine you gave me where you said to put it, it resets the level data before the sprite can read from the right palette. However, I did find that if you put that same routine into any of the parts that handle the sprite's general movement it will work exactly as you would want it to. However, the issue is that it is only good if there is only one npc sprite on the screen. If there is more than one, the sprite will reset the other's palette before it can get the custom message out. You can have more than one npc in the same level but they have to be spaced far enough apart so that they don't show up together. I only have one case where I have 2 npc sprites on the screen at once that need to display messages so I just took the routine out of the stationary one. This is fine for my hack but I can't seem to find a solution to fix the overall problem so that other people can use it if they choose to have more than one npc on screen at a time.
Trust the Fungus.