Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2017-05-09 00:29:17

Maniac379
Member
Registered: 2015-01-15
Post 72/121

SpriteSet Explanation?

Ever since I updated all Pokemon graphics I've been trying to correctly show Pokemon sprites on the overworld.  I have found that if I reset and load my save in a map the Pokemon sprites are shown correctly.  If I leave the mapgroup and come back, the Pokemon sprites switch to incorrect Pokemon.  Always the same incorrect Pokemon.  I've been reading the mechanics posted in these threads (https://hax.iimarckus.org/topic/6829/ and https://hax.iimarckus.org/topic/6875/).  Both of which stop before really explaining. 

From what I gather sprite sets need to match up if you can walk from one map to another.  I noticed a lot of original maps shared common sprite sets so I went through and combined them in pokecrystal.  It turns out you can put multiple mapheaders over a sprite set and they will load.  This reduced my total sprite sets in half probably.  The ones left are all quite similar.  It would seem Rangi 'brute forced' his sprites to work by replacing unused sprites with the same thing which I am happy to try but it sounds like the mechanics are more well known.  Reading those 2 threads I have a couple of questions.

1. Why are 23 sprites listed if only 11 (9 walking/2 standing) sprites apparently the only ones that work
2. What determines what sprites are used of the 23, they seem jumbled based on what ones are used and not in the list.  Does it simply not matter?
3. If indoor sprites are separate from the outdoor sprites, where are these changed at?  Why is old link nurse a sprite in most sprite sets, or is it just unused?
4. Rangi mentioned the last sprite in the list being loaded as a player sprite, but none of the sprite sets list a player sprite, unless again the last sprite in the list is always unused maybe?
5. Why would Pokemon sprites be the only sprites to error in a map?  I have changed mine to the patch on this site so each Pokemon has a unique sprite (https://hax.iimarckus.org/topic/4771/).
6. For sprite sets of neighboring maps, in addition to having the same sprites do they have to be in the same order?  I noticed many sprite sets of 23 seem to share a similar order of sprites.


---
Pokémon White Crystal
A simple quality of life and gameplay improved hack

Offline

#2 2017-05-09 00:43:45

Rangi
Member
Registered: 2016-05-09
Post 655/870

Re: SpriteSet Explanation?

I PMed you this on Reddit, but it may make a good public reference.

BGB's VRAM viewer can really help with understanding overworld sprite sets.

Here's a screenshot of Ecruteak City in Polished Crystal, showing which sprites are in its group, and what the resulting VRAM looks like:

TydPsOz.png

The right side is called VRAM1, and the left side is VRAM0. (The original GameBoy did not have VRAM1.) Notice that each side is divided into thirds. The top two thirds are used for still sprites; the bottom two thirds for tilesets; the left middle third for text; and the right middle third for sprites' walking animations.

The player's sprite gets loaded first, and then each non-duplicate set sprite, in order. So the green one right after Kris (I added the colors myself) is Breeder, then a blue Beauty, brown Bug Catcher, etc, all the way up to blue Youngster. They also have corresponding walking frames.

Each third has 128 tiles. One sprite uses 4 tiles, so up+down+side views use 12. 128 / 12 rounded down is 10, so there was room for 10 sprites there, nine from the set plus the player.

You could fit another 10 sprites in VRAM0's top third, but since text uses the middle third, they can't have walking frames. That's why the Hex Maniac in Ecruteak and the Officer in the adjacent Route don't move around: their animations would use text characters instead of proper sprite tiles.

I haven't investigated why each group has 23 entries. But a while ago I tried removing the padding ones and got some kind of glitch. I haven't tried again because it would only save a few bytes.

(Gold and Silver supported the Super GameBoy, so they didn't use VRAM1. Instead, they would dynamically load the text tiles only when textboxes show up, and would pause sprite movement while text shows up because the text tiles replaced the walking tiles. Also, they had less total space available, so they couldn't have as many different sprites in one group, nor as many tiles. Basically everything you see in VRAM1 would be impossible in G/S.)

(Even Crystal doesn't take full advantage of its VRAM. Tiles can be flipped—you can see that only the left sides exist for the ledge-hopping shadow and grass-rustling sprites, and of course walking frames get flipped every other step. This could theoretically be done for map tilesets too, so if you have a symmetrical building or tree or something it could use flipped tiles. Plus, Crystal didn't use all of the possible tileset space. This thread explains how I extended it based on Danny-E' similar technique for pokered.)

Like I said, I don't know why the tables contain 23 sprites—MAX_OUTDOOR_SPRITES is 23 but SPRITE_GFX_LIST_CAPACITY is 32—but listing the sprites in order, with up to 9 walking ones first and a repeated filler one at the end, works for me. It could all be arbitrary: 23 is more space than any map group needs but less than could possibly overflow the true max capacity of 32 (or come to think of it, maybe somebody swapped the 3 and 2 digits and it just didn't matter). And the random unused sprites in each group are just filler.

Edit: I finally took comet's advice and made the lists 0-terminated instead of fixed-length. I see no apparent bugs even for the longest group, with 18 used sprites.

For some hacks it may well be worth getting rid of the popup location name signs for the sake of fitting twice as many walking sprites per group. Or even, redesigning the location sign system to load only the necessary font tiles, in some unused VRAM, so that it doesn't interfere with the sprites at all.

Last edited by Rangi (2017-05-09 01:09:08)


Pokémon Polished Crystal (GitHub) — version 2.2.0 released
Pokémon Red★ and Blue★: Space World Edition (GitHub) — updated August 19!
Polished Map: pokered+pokecrystal map, tileset, and palette editor — version 3.5.1 released!

Offline

#3 2017-05-09 01:03:51

Maniac379
Member
Registered: 2015-01-15
Post 73/121

Re: SpriteSet Explanation?

I agree about a public reference being good.  When I saw my sprite in vram I noticed that when they were loaded incorrectly they appeared to be from the same location still somehow, possibly just the RAM location.

Btw did you try taking out sprites so no filler sprites, what happened?  I'm assuming it broke for some reason.

Also btw did you keep sprite sets of neighboring maps in similar order?


---
Pokémon White Crystal
A simple quality of life and gameplay improved hack

Offline

#4 2017-05-09 01:10:28

Rangi
Member
Registered: 2016-05-09
Post 656/870

Re: SpriteSet Explanation?

Maniac379 wrote:

I agree about a public reference being good.  When I saw my sprite in vram I noticed that when they were loaded incorrectly they appeared to be from the same location still somehow, possibly just the RAM location.

Btw did you try taking out sprites so no filler sprites, what happened?  I'm assuming it broke for some reason.

Also btw did you keep sprite sets of neighboring maps in similar order?

My sprite sets are mostly alphabetical, but there's no reason or necessity for it. All that matters is that the 9-or-fewer walking sprites come first.

I edited the post re: getting rid of filler.


Pokémon Polished Crystal (GitHub) — version 2.2.0 released
Pokémon Red★ and Blue★: Space World Edition (GitHub) — updated August 19!
Polished Map: pokered+pokecrystal map, tileset, and palette editor — version 3.5.1 released!

Offline

#5 2017-05-09 01:48:15

Maniac379
Member
Registered: 2015-01-15
Post 74/121

Re: SpriteSet Explanation?

I cleaned up the sprite sets in overworld.asm a LOT.  Each now only has 11 (9 walking).  It was basically the same filler in all although I suspect I need to fit Sudowoodo back into the correct sprite set somehow.

https://github.com/maniac379/White-Crys … 553ca16698

Sprites seem to work correctly still.  Pokemon sprites are still broken.  I realize that for Slowbro in Cerulean city I did not correctly line up the sprite names (which is why it shows player sprite, I imagine).  Every other sprite does as I mention and loads correctly on a reset but once opening menu or leaving the map group shows incorrectly.  Day care pokemon load correctly.

I assumed this whole time is was from sprite sets but something else must be going on....

Last edited by Maniac379 (2017-05-09 01:49:02)


---
Pokémon White Crystal
A simple quality of life and gameplay improved hack

Offline

#6 2017-05-31 22:16:46

Maniac379
Member
Registered: 2015-01-15
Post 85/121

Re: SpriteSet Explanation?

Have finally fixed the glitch.  Ragni's commit I copied from did not have comet's sprite fix included as seen in my changes to engine/mon_icons.asm

https://github.com/maniac379/White-Crys … 0098e9df2a


---
Pokémon White Crystal
A simple quality of life and gameplay improved hack

Offline

Board footer

Powered by FluxBB