Skeetendo

’Cause all games were better on the GBC

You are not logged in.

  • Index
  • → Help/Question
  • → Problem adding new overworld sprites to Pokered (weird behavior)

#1 2016-03-21 08:19:56

KeiTaRo
Member
Registered: 2015-12-05
Post 7/43
Website

Problem adding new overworld sprites to Pokered (weird behavior)

Hello! I'm fairly new to using the Pokered disassemby, but I've been learning very quickly. Recently however, I've had a problem when attempting to add some new overworld sprites to the game. Let me walk you through what I've done exactly and what's been happening. I added several sprites to the game, but all via this same method. The first of these was a Pikachu, so I'll use that as an example.

I created a pikachu_ow.png sprite sheet (basically just the one from Yellow) and at the very bottom of main.asm, I created a new bank (bank 0x30) because I added more sprites than I thought might be able to fit in one of the existing sprite gfx banks. I added the Pikachu sheet and several others to it, and it looks like this:

SECTION "bank30", ROMX,BANK[$30] ;Extra Overworld Sprites

PikachuSprite:           INCBIN "gfx/green/pikachu_ow.2bpp"
JigglypuffSprite:        INCBIN "gfx/green/jigglypuff_ow.2bpp"
BillSprite:              INCBIN "gfx/green/bill_ow.2bpp"

etc....there's more sprites in the bank than what's listed, but you get the idea.

Anyway, next step was going to sprite_sets.asm and at the bottom below SPRITE_LYING_OLD_MAN's setup, I added Pikachu and the others:

; SPRITE_PIKACHU
    dw PikachuSprite
    db $c0 ; byte count
    db BANK(PikachuSprite)

...and so on for the other sprites as well. Then after this, I went to sprite_constants.asm and under SPRITE_LYING_OLD_MAN's entry, I added:

SPRITE_PIKACHU                     EQU $49

...and so on for the other sprites as well. I assumed I was done here, so to test, I went back to sprite_sets.asm and changed the SPRITE_GYM_HELPER in sprite set $06 to SPRITE_PIKACHU. I then went in to data\mapObjects\pewtergym.asm and changed the SPRITE_GYM_HELPER reference in that to SPRITE_PIKACHU as well. I went in to Pewtwer Gym and a Pikachu showed up but when I spoke to it, the sprite refused to rotate or animate in any way. It would just stay facing forward no matter what. When I swapped the Pikachu in over an animated sprite, it would show all kinds of weird things when the character would walk. I changed the sprite to SPRITE_OAK just to see if that would work correctly, and it did. I'm not sure what I'm doing wrong. I even tried sticking the Pikachu graphics in the same bank as all the other sprites just in case that mattered, and the same thing still happened. What did I miss and what am I doing incorrectly here? Is there a step I'm missing?

Also, one other thing of note, I'm not entirely sure I understand how the various sprite sets work....I noticed SPRITE_GYM_HELPER is only listed under set $06, so I assumed that one is used for all of the gyms. However, SPRITE_BRUNETTE_GIRL (which is used for Misty) is not under this set, yet a character using that sprites is set up in ceruleangym.asm under mapObjects...as well as the Gym Helper. I'm really confused...so what's the point of the sprite sets if you are able to load things other than what is defined within them? or am I totally missing the point? Thanks for the help....I really appreciate it!

Last edited by KeiTaRo (2016-03-21 10:00:26)

Online

#2 2016-03-21 22:17:23

Danny-E 33
Administrator
Registered: 2012-06-09
Post 942/1,026

Re: Problem adding new overworld sprites to Pokered (weird behavior)

KeiTaRo wrote:

I went back to sprite_sets.asm and changed the SPRITE_GYM_HELPER in sprite set $06 to SPRITE_PIKACHU. I then went in to data\mapObjects\pewtergym.asm and changed the SPRITE_GYM_HELPER reference in that to SPRITE_PIKACHU as well. I went in to Pewtwer Gym and a Pikachu showed up but when I spoke to it, the sprite refused to rotate or animate in any way. It would just stay facing forward no matter what. When I swapped the Pikachu in over an animated sprite, it would show all kinds of weird things when the character would walk. I changed the sprite to SPRITE_OAK just to see if that would work correctly, and it did. I'm not sure what I'm doing wrong. I even tried sticking the Pikachu graphics in the same bank as all the other sprites just in case that mattered, and the same thing still happened. What did I miss and what am I doing incorrectly here? Is there a step I'm missing?

Also, one other thing of note, I'm not entirely sure I understand how the various sprite sets work....I noticed SPRITE_GYM_HELPER is only listed under set $06, so I assumed that one is used for all of the gyms. However, SPRITE_BRUNETTE_GIRL (which is used for Misty) is not under this set, yet a character using that sprites is set up in ceruleangym.asm under mapObjects...as well as the Gym Helper. I'm really confused...so what's the point of the sprite sets if you are able to load things other than what is defined within them? or am I totally missing the point? Thanks for the help....I really appreciate it!

The sprite sets defined in data/sprite_sets.asm are only used for outdoor maps (towns and routes) which are maps with an id of less than $25.
For indoor maps, sprite sets are not referenced, which is why Cerulean Gym can use SPRITE_GYM_HELPER and SPRITE_BRUNETTE_GIRL at the same time, even though SPRITE_GYM_HELPER is only in sprite set 6 and SPRITE_BRUNETTE_GIRL is not in that set. The answer is simply because Cerulean Gym is not using sprite set 6 at all. Instead, for indoor maps, the correct sprites are loaded into vram based on the sprite ids found in the map's object data.
You can take a look at engine/overworld/map_sprites.asm to see how this is accomplished.

Regarding the bug you are experiencing...
The reason is that the code I just referred to, engine/overworld/map_sprites.asm, handles the last several sprites differently than the others.
LoadMapSpriteTilePatterns: compares the sprite id of the sprite currently being loaded to SPRITE_BALL. If the id is less than SPRITE_BALL, load it like an ordinary, animated sprite. If the sprite id is equal to or greater than SPRITE_BALL, it is a special non-animated sprite that does not load new tile ids when being talked to from different sides.
So in order to fix this, all you have to do is add all new animated sprites after SPRITE_SEEL and before SPRITE_BALL.
And add all static sprites at the end of the list after SPRITE_LYING_OLD_MAN.



P.S.
To anyone who happens to read this, this is an A+++ example of what a Help/Question thread should look like.
He started by stating the goal, then listed the attempt at achieving the goal, followed by the undesired behavior, and lastly explained the attempts at fixing the undesired behavior.
This shows he is invested in dissecting this issue, truly understanding it, and learning from it.
1) It's simply a good characteristic to care this much about learning when you notice there is something you don't fully understand
2) More practically, by caring this much and taking the time to construct a high quality post, you make it so much easier anyone else to understand, solve, and explain the issue.

Thank you, KeiTaRo.


Red Hack: Pokémon Prototype

Total number of registered users: 7000+
Total number of active users: ~12

Offline

#3 2016-03-21 22:53:52

KeiTaRo
Member
Registered: 2015-12-05
Post 8/43
Website

Re: Problem adding new overworld sprites to Pokered (weird behavior)

Ah, I get it now! Thank you so much, that solution worked perfectly :)

Online

#4 2016-03-21 23:14:15

KeiTaRo
Member
Registered: 2015-12-05
Post 9/43
Website

Re: Problem adding new overworld sprites to Pokered (weird behavior)

Ah, actually....I do have one additional question. Outdoor places like Routes and Cities seem to have sprites defined in their mapObjects files as well....does that mean they are merely limited to using those defined in the sprite sets, or am I misunderstanding something?

Online

#5 2016-03-21 23:26:33

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 3,277/3,492

Re: Problem adding new overworld sprites to Pokered (weird behavior)

Right, they are limited to the ones in the sprite sets.

For indoor maps, you have to go through a warp to access them, so it doesn't matter what sprites are there-- they'll get loaded anyway. With outdoor maps like towns and routes, you can walk between them without going through a warp, which doesn't reload any graphics. As such, connected areas need to all have the same sprites in memory so that you can walk between them without having sprite issues, which is where the sprite sets come in.

Offline

#6 2016-03-21 23:33:55

KeiTaRo
Member
Registered: 2015-12-05
Post 10/43
Website

Re: Problem adding new overworld sprites to Pokered (weird behavior)

OH! Okay, that totally makes sense now...thanks again.

Online

  • Index
  • → Help/Question
  • → Problem adding new overworld sprites to Pokered (weird behavior)

Board footer

Powered by FluxBB