Romhacking => ROM Hacking Discussion => Topic started by: Mr. Saturn on April 02, 2020, 12:48:01 pm

Title: Move NES sprite position
Post by: Mr. Saturn on April 02, 2020, 12:48:01 pm
A couple days ago I made a post kinda like this about adding sprites, but I've since given up and made a few compromises.
I'm working on a Super Mario Bros 2 hack, and at the moment I'm changing the characters.
The whites in most of the characters' eyes are seperate sprites rendered behind the main sprites.
I was just wondering if it's possible to move said eyeballs over a little bit to fit the new characters.
Title: Re: Move NES sprite position
Post by: FAST6191 on April 02, 2020, 01:52:37 pm
Two main approaches

Find the routine handling their initial position and OAM updates, and shuffle that along by however many you need. You might even find someone already knows it, though Mario 2 is probably the least hacked of the big 3 NES efforts.

Alter the sprites themselves. For the NES I would be sort of surprised to see some super small custom size tiles be used for this (outside fonts it is still quite rare on the DS). Figure out whatever transparent is and shuffle all the data along by however many you need (you have already got all the data so it is not like any creative effort is needed), indeed your tile editor might even have some kind of select cut and paste functionality in it (I could probably fake it as well with changing offsets but I will skip that one for now). Do check it works in mirrored mode (which can just mean running the other way). If it is just a background it should not trouble hit detection compared to doing the same for main sprites. If they are already at an extreme and you have to go one further (doubtful on the NES but might appear) then you are back to the handling stuff.
Title: Re: Move NES sprite position
Post by: Mr. Saturn on April 02, 2020, 04:54:57 pm
Thanks, I'm not really familiar with OAM, so I spent some time reading about it and poking around making funky things happen, but I still don't really know what I'm doing there.

So I checked the sprites themselves, and there is a fair bit space on the eyeball sprites, but they don't cover the areas I need the eyeballs to be.
They only cover the front half of the face. I'm looking to cover the back half, or maybe (if it's even possible) both halves.
Title: Re: Move NES sprite position
Post by: bogaabogaa on April 26, 2020, 09:33:33 am
I did not look deep into it. Because it still takes a lot of time figuring out new formats. Some games make it easy on you with the OAM since they have a table of how many 8x16 pixels it will load into OAM and what attribute they have on one place. With SMB2 there is a table that just holds the 8x16 (2 tiles) So the Sprite assembly of mario is made of 4 byte from CPU $F2EC (PRG $1F2EC) The eye is only one byte.
If you look to change palettes and pixel offsets this might be handled in the code or a other table. Things like this it will be a bit of work to expand on it. Currently I think of a other entry of a 8x16 for more white cover..
There is a lot of figuring out on how it will work on other characters and how the other Sprite attributes are handled in OAM. I am not willing to spend the time needed but this might give you a idea what you are after. I can make a patch to move the sprite to the back-head. There seems not to be a other way since it reads offset position directly from player potion in RAM.

I made a patch that moves the eye sprite to the backhead. It seems to work for all character. I had to write code into the OAM update routine.

You can move the eye by 80 pixels in the x position by changing the ADC and SBC amount! I hijacked twice and added my code at PRG $1fb44.
You change the xpos offset at $1fb44 and $1fb4d.