Banner
Views: 793,787,948
Time:
9 users online: 7 up, Alucard648, Cheolpeoduck, DPBOX,  dtothefourth, Isikoro,  KevinM, OGS93, Yoshi Master - Guests: 25 - Bots: 196 Users: 41,429 (1,483 active)
Latest: ncf1975
Tip: Do you want to create custom blocks, but have little to no experience with ASM? Use Kipernal's Blockreator!Not logged in.
Sprite Memory Shared Between Areas (Patch + Code)
Forum Index - SMW Hacking - Resource & 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.
Balloon Party.
At times like this, you need to step back and say, "Where's the Balloon Party?"
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...
Balloon Party.
At times like this, you need to step back and say, "Where's the Balloon Party?"
Pages: « 1 »
Forum Index - SMW Hacking - Resource & 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 - 2019 - SMW Central
Legal Information - Privacy Policy - Link To Us


Total queries: 7

Menu

Follow Us On

  • YouTube
  • Twitch
  • Twitter

Affiliates

  • SMBX Community
  • ROMhacking.net
  • MFGG