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/71
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)

Offline

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

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

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.

Offline

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

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

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

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

Offline

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

KeiTaRo
Member
Registered: 2015-12-05
Post 9/71
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?

Offline

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

Mateo
Member
Registered: 2009-11-25
Post 3,277/3,627

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.


I am no longer active on this forum. I only pop in from time to time.

Offline

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

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

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

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

Offline

#7 2019-06-22 19:58:25

n.tsakalov
Member
Registered: 2019-06-21
Post 6/11

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

I added a SPRITE_SAILOR in pokereddatasprite_sets.asm, right after the SPRITE_SEEL and before SPRITE_LYING_OLD_MAN

SpriteSets:
; sprite set $01
    db SPRITE_BLUE
    db SPRITE_BUG_CATCHER
    db SPRITE_GIRL
    db SPRITE_FISHER2
    db SPRITE_BLACK_HAIR_BOY_1
    db SPRITE_GAMBLER
    db SPRITE_SEEL
    db SPRITE_SAILOR
    db SPRITE_OAK
    db SPRITE_SWIMMER
    db SPRITE_BALL
    db SPRITE_LYING_OLD_MAN

Then I added the new sprite in the data/mapObjects/Route1.asm

Route1_Object:
    db $b ; border block

    db 0 ; warps

    db 2 ; signs
    sign 13, 27, 3 ; Route1Text3
    sign 9, 23, 4 ; Route1Text4
    

    db 2 ; objects
    object SPRITE_BUG_CATCHER, 15, 13, WALK, 2, 1 ; personWith_POTION
    object SPRITE_SAILOR, 5, 24, WALK, 1, 2 ; personWith_OLD_ROD

    ; warp-to (unused)
    warp_to 2, 7, 4

Everything is fine until I visit VIRIDIAN CITY and PEWTER CITY.
In VIRIDIAN CITY the lying old man is messed up (it changes forms, it becomes a seel, then a boy, then a gambler etc but he is never a lying man).
Then When I visit PEWTER, the object SPRITE_BLACK_HAIR_BOY_2, 26, 25, WALK, 2, 4 ; person, is depicted as an old lying man, the girl as a sailor and the trainers on the way to MT.MOON, are depicted as TEAM ROCKET.

I also tried to add a SPRITE_SNORLAX in Pallet Town, and that messed Route1, Viridian City, Pewter City and Route21 (I dont know what else was messed up).

Moreover I tried to remove completely the SPRITE_SAILOR, and all returned to normal. The old man is on the ground and Pewter City became normal too.

I would like to add sprites in different maps, as the SPRITE_SAILOR, without messing up the rest maps. Is there anything else I should do, apart from adding the SPRITE_SAILOR as I showed in the code above? Thank you.

Last edited by n.tsakalov (2019-06-22 20:07:20)

Offline

#8 2019-06-22 21:03:55

Mateo
Member
Registered: 2009-11-25
Post 3,614/3,627

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

Spritesets are a fixed length.They can also only have 2 of the "still sprites" such as the lying old man or the pokeball. If you wanted to add a Sailor though, you could replace the SPRITE_LAPRAS in that spriteset, because it is not actually used by anything there.


I am no longer active on this forum. I only pop in from time to time.

Offline

#9 2019-06-22 21:14:27

n.tsakalov
Member
Registered: 2019-06-21
Post 7/11

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

I suspected that there is some fixed length, when I counted the sprites in each set.
Can that length be modified?

Also, when you suggest to modify the SPRITE_LAPRAS, you mean the SPRITE_LAPRAS_GIVER? Because I cannot find the SPRITE_LAPRAS in the sprite_sets.


I am also trying to understand this table in the data/sprite_sets.asm:

SplitMapSpriteSets:
    db $02,$25,$02,$01 ; $f1
    db $02,$32,$02,$03 ; $f2
    db $01,$39,$04,$08 ; $f3
    db $02,$15,$03,$08 ; $f4
    db $01,$08,$0A,$08 ; $f5
    db $01,$18,$09,$05 ; $f6
    db $01,$22,$09,$0A ; $f7
    db $01,$35,$01,$0A ; $f8
    db $02,$21,$02,$07 ; $f9
    db $02,$02,$07,$04 ; $fa
    db $01,$11,$05,$07 ; $fb
    db $01,$03,$07,$03 ; $fc

It explains the format, but I find it difficult to understand it...
(; Format:
; 00: determines whether the map is split East/West or North/South
; $01 = East/West divide
; $02 = North/South divide
; 01: coordinate of dividing line
; 02: sprite set ID if in the West or North side
; 03: sprite set ID if in the East or South side)

Thank you for your help you have been giving me up to now my friend.

Offline

#10 2019-06-22 21:30:35

Mateo
Member
Registered: 2009-11-25
Post 3,615/3,627

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

I actually meant SPRITE_SEEL. And no, you cannot just add more to a list, because there is not room in VRAM for additional sprites to be loaded at once. As for that second table, you only need to worry about that in certain situations. In some cases, a map (it will always be a route in the vanilla game) loads a different sprite set on different halves of a map, and there will be something like a cave or a gate house in the dividing area. That table determines those dividing lines and which set will be used on which side of it.


I am no longer active on this forum. I only pop in from time to time.

Offline

#11 2019-06-22 21:49:07

n.tsakalov
Member
Registered: 2019-06-21
Post 8/11

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

I changed the SPRITE_SEEL as per your suggestion and now everything works perfect.

As for the table above, could you give me a brief explanation of the first line? I would like to know what corresponds to what.

For eg:

SplitMapSpriteSets:
db $02,$25,$02,$01 ; $f1

If I understand well, the first column $02 refers to if the event will be North/South or East/West.
The rest 5 parameters, $25,$02,$01 ; $f1 , what are they?

Offline

#12 2019-06-22 21:55:07

Mateo
Member
Registered: 2009-11-25
Post 3,616/3,627

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

As the comments you quoted describe:

$02 = this is a North/South divide
$25 = the coordinate (in hex) for how far down the map the dividing line is
$02 = the spriteset it will use in the top half
$01 = the spriteset it will use in the bottom half


I am no longer active on this forum. I only pop in from time to time.

Offline

#13 2019-06-22 22:21:41

n.tsakalov
Member
Registered: 2019-06-21
Post 9/11

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

Now everything makes sense, SPRITES and how to use them.

Thank you for the explanation!

Offline

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

Board footer

Powered by FluxBB