Banner
Views: 235,876,326
Time: 2013-05-19 10:27:52 AM
22 users online: aj6666, Counterfeit, CrispyYoshi, DragezeeY, o Ersanio, FireLeafGreen200, o grishnax, o Hadron, HyperMario, Koopster, levelengine, LimeMaster92, Maniek, Mariohacker14, Mogsiah, pieordie1, Ramidalv, Rockythetigre, superdragonyoshi1, UED, WhiteYoshiEgg, o Zildjian - Guests: 27 - Bots: 17Users: 22,840 (1,288 active)
Latest: neagix
Tip: Make sure you can beat your own levels without savestates, slowdown, or rewinding.
Sprite Memory Shared Between Areas (Patch + Code)
Forum Index - SMW Hacking - Resource and Tool Releases - Sprite Memory Shared Between Areas (Patch + Code)
Pages: « 1 »
I downloaded mikeyk's Yoshi Coin sprite, and I was disappointed at the fact that it re-appears when I exit and re-enter the area after Mario gets it. So... I decided to work on a way to prevent it from re-appearing.

I'm posting this for anyone who would like to use it in their own custom sprites.

This code uses the item memory index just like objects do.

First, patch this to your ROM with XKAS. It sets all the values in the table to zero.
Code
header lorom !Spr_InterLevelTable = $7F8B00 ;0x200 bytes org $0491D8 JSR.w ZeroInterLevel org $04FFB1 ZeroInterLevel: STA.w $0DC2 PHX ; does this even need to be preserved? REP #%00010000 LDX.w #$0000 SprTblLoop: LDA.b #$00 STA.l !Spr_InterLevelTable,x INX CPX.w #$0200 BCC SprTblLoop SEP #%00010000 PLX RTS



Add this to the very beginning of the sprite (or you can just type the address directly into the following pieces of code)
Code
SPR_INTERLEVEL = $7F8B00



Add this to the very beginning of the INIT routine, right after 'dcb "INIT"'
Code
LDA $161A,x STA $00 STZ $01 LDA $13BE REP #%00110000 AND.w #$00FF XBA LSR A CLC ADC $00 PHX TAX SEP #%00100000 LDA SPR_INTERLEVEL,x PLX SEP #%00010000 CMP #$00 BEQ NotDestroyed: STZ $14C8,x RTL NotDestroyed:



and use this code to prevent the sprite from reloading. In mikeyk's Yoshi Coin sprite, add it after "BCC NoContact"
Code
LDA $161A,x STA $00 STZ $01 LDA $13BE REP #%00110000 AND.w #$00FF XBA LSR A CLC ADC $00 PHX TAX SEP #%00100000 LDA #$01 STA SPR_INTERLEVEL,x PLX SEP #%00010000


By the way, there might be a little bit of room for optimization in this code.


You can also use the table for other purposes, and you can add extra tables by modifying the patch to zero them out.
Here's an example of a modified patch:
Code
header lorom !Spr_InterLevelTable = $7F8B00 ;0x200 bytes !Spr_InterLevelTable2 = $7F8D00 ;0x200 bytes org $0491D8 JSR.w ZeroInterLevel org $04FFB1 ZeroInterLevel: STA.w $0DC2 PHX ; does this even need to be preserved? REP #%00010000 LDX.w #$0000 SprTblLoop: LDA.b #$00 STA.l !Spr_InterLevelTable,x STA.l !Spr_InterLevelTable2,x INX CPX.w #$0200 BCC SprTblLoop SEP #%00010000 PLX RTS
Will you submit this to the patches section? If so, what will it's name be? I remember you talking about this on the IRC.
I probably won't submit this to the patches section. I'll probably just include it with sprites that use it, since it's completely useless without sprites that use it.

As for a name, I don't know. Maybe something along the lines of "InterLevel Sprite Memory".
There needs to be a "misc" option in the sidebar...
Pages: « 1 »
Forum Index - SMW Hacking - Resource and Tool Releases - Sprite Memory Shared Between Areas (Patch + Code)

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