Banner
Views: 236,690,163
Time: 2013-05-25 08:34:58 AM
24 users online: Alcaro, buggy789, Delta, o Doopy Buckride, Dr. Tapeworm, Dylancd5010, Egadd, everest700, gigmadesh200, Lui37, Neidave, pat94plus, Pribor, segredo, o ShadowPhoenix, Shinnok, Shizufuzu, SMW_Forever, Sokobansolver, tatanga, o Undy, Vitor Vilela, wiiqwertyuiop, o x-treme - Guests: 35 - Bots: 12Users: 22,885 (1,281 active)
Latest: ar1an1
Tip: Verify your ROM is unedited by using ROMclean.
Spawning Multiple Custom Sprites at Once
Forum Index - SMW Hacking - General SMW Hacking Help - ASM & Related Topics - Spawning Multiple Custom Sprites at Once
Pages: « 1 »
I am having some trouble getting my custom sprite to spawn more than one custom sprite at a time. I can get one sprite to spawn very easily but the second one just doesn't load for some reason. If I try to spawn two, it only ends up creating one and after several more attempts the game slows down bad and eventually crashes. It's like the 2nd sprite is accounted for but it doesn't process right and doesn't show up at all on the screen. I've rewritten the function I think 3 times and I still haven't gotten anywhere. Does anyone know what the problem might be?

I also have another bonus question. When spawning a custom sprite, is there a way to skip its init routine? At the time it spawns I want to manually set up the sprite myself without the need for init. I have tried setting up all the variables created in the original init routine and then setting the sprite status to 08 but that crashes the game when I try that. And when it doesn't crash it still loads the original init routine and overwrites any changes I have made to the sprite tables.

The code is a tad long but I wanted to include everything. I appreciate any help I can get!

Code
; NOTE: $00-$03 already contain the X/Y position I want to spawn these sprites at SpawnChildren: LDA !Size,x DEC A STA $0F LDA #$00 STA $0E LDY #$0B .SpriteGenLoop LDA $14C8,y BNE .Next PHX LDA $7FAB9E,x TYX STA $7FAB9E,x LDA #$01 STA $14C8,y LDX $0E LDA SpinyTableOffset,x CLC ADC $0F TAX LDA $00 CLC ADC SpinyDispXLow,x STA $00E4,y LDA $01 ADC SpinyDispXHigh,x STA $14E0,y LDA $02 CLC ADC SpinyDispYLow,x STA $00D8,y LDA $03 ADC SpinyDispYHigh,x STA $14D4,y TYX JSL $07F7D2 JSL $0187A7 LDA #$08 STA $7FAB10,x LDX $0E LDA SpinySpeedX,x STA $00B6,y LDA SpinySpeedY,x STA $00AA,y LDA #$01 STA.w !Direction,y PLX DEC $0E LDA $0E BMI .DestroySpiny .Next DEY CPY #$00 BPL .SpriteGenLoop .DestroySpiny STZ $14C8,x LDA #$03 STA $1DF9 .Return RTS SpinyTableOffset: db $00,$03 SpinyDispXLow: db $E8,$D8,$C8 db $08,$08,$08 SpinyDispXHigh: db $FF,$FF,$FF db $00,$00,$00 SpinyDispYLow: db $F0,$E8,$E0 db $F0,$E8,$E0 SpinyDispYHigh: db $FF,$FF,$FF db $FF,$FF,$FF SpinySpeedX: db $E8,$18 SpinySpeedY: db $C0,$C0
It's actually not hard. Create another routine where it spawns a sprite and JSR to it. A good one to download is my Magica deSpell. Feel free to borrow some of the code
I was able to resolve my problems. Turns out I had some scratch RAM conflicts and also I think there was a problem with the positioning of the new sprites. It isn't entirely evident what I was doing wrong but at least I have it working like I want now.

dahnamics: I looked at your Magica deSpell code and what you did in there was one of the approaches I had tried and that had failed. I did pick up a few things though. Always learning!
I'm curious how it failed. I've used it many times and worked
Pages: « 1 »
Forum Index - SMW Hacking - General SMW Hacking Help - ASM & Related Topics - Spawning Multiple Custom Sprites at Once

The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.

Copyright © 2005 - 2013 - SMW Central
Legal Information - Link To Us


Total queries: 29

Menu