News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: How can I change the sprite size from small to big in SNES games?  (Read 1105 times)

Vag

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
    • GreekRoms
Hello, I started translating Micro Machines for the SNES to Greek and I would appreciate some help please. There are some painted words that are sprites. I can translate all of them but one, because the new word is much longer than the original. The original word uses 20 sprites (20x4 bytes); the first 5 sprites are big (16x16) and the other 15 sprites are small (8x8). If I could change it so that 10 sprites are big and 10 are small, I could fit the new word perfectly in 20x4 bytes.
You can see here about the sprites, to understand what I'm saying about sprites: https://wiki.superfamicom.org/snes-sprites.

In the rom I have found the sprite table that has 4 bytes per sprite, I need to find the second sprite table, the one that has 2 bits per sprite (I can see both in OAM, but I'm talking about the rom and I think it's totally different). Has anyone done this before?

Alternatively, if there was a way to move these 20x4 bytes to an empty area in the rom (there is enough space), it would be perfectly acceptable, as when I add more sprites at the end of the 20 existing ones, they do appear in the game. I can only try it in the original position in the rom, as it affects the next sprites. So, instead of 10 big and 10 small sprites, I could have 5 big and as many small as needed. The on-screen result would be the same. If there are pointers to these sprite bytes though, they are not like the text pointers of the game.

I have tried changing many bytes that follow the sprites bytes, but they have nothing to do with them. There are many bytes before the sprites bytes that when changed, these sprites appear differently, but I'm not sure if they contain the data I need. Even changing one bit changes all sprites at the same time. So, trial and error / brute force is not the solution.

By the way, Micro Machines uses compression, you won't be able to see these graphics in a tile editor, so here are two screenshots:



Reld

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
Re: How can I change the sprite size from small to big in SNES games?
« Reply #1 on: August 16, 2020, 12:06:03 am »
I haven't taken a look at this game specifically, but if you know where the four bytes per sprite are in the ROM, changing the size of the sprite should be as simple as changing the last bit of the fourth byte.

From the wiki page you linked:
Code: [Select]
Sprite Table 1 (4-bytes per sprite)         
Byte 1:    xxxxxxxx    x: X coordinate
Byte 2:    yyyyyyyy    y: Y coordinate
Byte 3:    cccccccc    c: Starting tile #
Byte 4:    vhoopppc    v: vertical flip h: horizontal flip  o: priority bits
                       p: palette # c:sprite size (e.g. 8x8 or 16x16 pixel)

It's the "c" bit in byte 4.

Edit: "Last bit" is probably a poor choice of words since the bits are usually counted from right to left, but I think the idea is clear enough with the diagram from the wiki. It's bit zero, or the bit furthest to the right.
« Last Edit: August 16, 2020, 12:11:43 am by Reld »

Everything

  • Jr. Member
  • **
  • Posts: 31
    • View Profile
Re: How can I change the sprite size from small to big in SNES games?
« Reply #2 on: August 16, 2020, 01:11:18 am »
I don't believe the previous post is correct. Or maybe it is in some weird mode, but usually that last "c" is the MSB of the tile index. The sprite data is 512 bytes (128 sprites * 4 bytes each), followed by an additional 32-byte structure which contains two bits per sprite. The first bit (reading low to high) is the MSB of the x position and the second bit determines the sprite size (0 = small, 1 = large).

There is an extremely confusing and poorly translated explanation of this on page A-3 of the SNES Development Manual.

Reld

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
Re: How can I change the sprite size from small to big in SNES games?
« Reply #3 on: August 16, 2020, 02:36:01 am »
Hmm... I think you're right actually. Sorry for the confusion. I haven't touched sprites in a little bit.

I did a little poking around and there seems to be a work RAM buffer for these values around 7E24DC. For example, when the game is paused the size and X-position bit for the "Pause" text sprites starts with the byte at 7E24E0. Unfortunately these values seem to be hard-coded in the ASM. At 00E9CB it does an "lda #$aa" and then stores it to the buffer at 7E24E0 instead of loading the value from somewhere in ROM. That "lda #$aa" instruction at 00E9CB seems to be shared by at least the "Pause" and "Bonus" text sprites, so it might get kind of complicated if you need to modify them separately.

Vag

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
    • GreekRoms
Re: How can I change the sprite size from small to big in SNES games?
« Reply #4 on: August 16, 2020, 08:52:51 am »
Thank you both for your replies!
The fourth byte is 31 for all 20 sprites, so it couldn't be there, as they would all be the same (either small or big).

But your help was the catalyst for me finding it!


First of all, I was expecting value AA anyway, as AA is 10101010 and there were 5 (more than 4 I mean) big sprites. So, I was looking for AA in the rom, near the area of the bytes of the sprites. There was one AA byte (at 69CB) which was affecting all sprites, but I couldn't understand how and find the solution. Changing any other bytes near it was just corrupting everything (plus, changing this byte was affecting ALL the different words). When Reld said "lda #$aa", which is "A9 AA", I realized it must be the suspicious AA byte, as it was preceded by A9. Then I realized that there must be another A9 xx somewhere after it (instead of a xx byte without AA before it, as I thought at first). Well, 4 bytes after the AA there's an A9 02 and after another 4 bytes there's an A9 00. In fact, because there's a big distance between them, I hadn't found them by looking at them.

So, without the bytes between, we have A9AA A902 A900 A900 or AA020000, if we omit the A9s.
If we see that in binary:

 4  3  2  1    8  7  6  5   12 11 10  9   16 15 14 13
10 10 10 10   00 00 00 10   00 00 00 00   00 00 00 00 ...and so on

In the first row I have the sprite order*. So I need to change them to AAAA0A00 (10101010101010100000101000000000)

Of course it affects all words (Pause, Bonus, Play Off, etc.), but as it makes the sprites bigger, I can fix all of them one by one (I'll just rearrange the sprites bytes to show blank tiles).
*The bytes order above is not exactly like this. It was very confusing when I had to change the sprite bytes. I think the right order for AA AA 0A is really AA 0A AA for some reason, making the sprites 4 3 2 1 12 11 10 9 8 7 6 5 (probably, I didn't need to experiment more).

Now, I just need to try to center the sprite and then fix all the others, that now show extra tiles.
Again, thank you both very much for your replies, you saved me a lot of time and frustration!

Last night I searched the whole forum for anything similar. There were two or three discussions about how to make sprites bigger, but not this way and I think only for the NES. Changing the small sprites to big ones, means you can make the game sprites bigger! In fact, you can add 3 more tiles per small sprite (or more, if the big sprites are bigger than 16x16)!
As in the past I had done translations only, I never needed such a thing, but now I think it should be a common method to make sprites bigger. There are so many graphics hacks and I don't know if any of them do that.
« Last Edit: August 16, 2020, 09:17:17 am by Vag »

Reld

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
Re: How can I change the sprite size from small to big in SNES games?
« Reply #5 on: August 16, 2020, 10:21:15 am »
Awesome. Sorry again for the bad information the first time.