Banner
VLDC #13 ends in
4 DAYS, 5 HOURS, 30 MINUTES AND 7 SECONDS
Views: 994,992,217
Time:
8 users online: Anas, Bensalot, derv82, Gamet2004, Haithius, Infinity, Maw,  Segment1Zone2 - Guests: 61 - Bots: 209 Users: 54,541 (2,074 active)
Latest: Eli Jenkins YK
Tip: It's recommended to use these tools when ripping graphics.
Not logged in.
Modifying Behaviour of Custom 32x32 Chomp Sprite
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - Modifying Behaviour of Custom 32x32 Chomp Sprite
Pages: « 1 » Link
I am attempting to correct an issue with the 32x32 Chomp sprite found here https://www.smwcentral.net/?p=section&a=details&id=3740. The sprite spawns - bounces a set number of times and then does one final super bounce.

Problem: if you die at any point after initially spawning the sprite, when you return to the sprite again it seems to be in the same initial 'cycle', i.e. it does not fully reset it's number of bounces. So for example if the sprite bounces a total of 5 times, but the first time you try the level you die on the 3rd bounce; the second time you try the level the sprite will only bounce 2 more times not the original 5.

I have included the ASM code here for simplicity (note: I have commented some lines out to prevent the sprite from initially spawning in Mario's direction. These are the only changes I've made.)

Any help would be very welcomed! :)

Code
;==========
;Chomp
;==========

PROPERTIES: db $6F,$2F
PROPERTIES2: db $6D,$2D

TILEMAP: 
	db $40,$42,$60,$62
	db $44,$46,$64,$66
	db $40,$42,$60,$62
	db $44,$46,$64,$66

Y_Speeds:
	db $DA,$DC
	db $D7,$D5
	db $DB,$D9
	db $D8,$DB
	db $D7,$D5
	db $DB,$D9
	db $DA,$DC
	db $D7,$D5
	db $D6,$D4
	db $DA,$D9
X_Speeds: 
	db $1A,-$1A
	db $16,-$16
	db $18,-$18
	db $12,-$12
	db $1A,-$1A
	db $16,-$16
	db $18,-$18
	db $12,-$12
	
!SpeedValueCounter = $C2

print "INIT ", pc
	;%SubHorzPos()		;Face Mario, uncomment this line and the next two if you don't want that.
	;TYA
	;STA !157C,x
	RTL

Return:
	RTS

print "MAIN ", pc
	PHB
	PHK
	PLB
	JSR Run
	PLB
	RTL

SP: db $30,$D0
	
Run:
	JSR GFX
	LDA #$00
    %SubOffScreen()
	LDA !14C8,x		;If the sprite is dead..
	CMP #$08
	BNE Return		;..return
	LDA $9D
	BNE Return		;Also return if sprites are locked.

	JSL $01802A
	JSL $018032
	JSL $01A7DC	
	
	LDA !1588,x
	AND #$04
	BEQ NOT_ON_GND         

	;%SubHorzPos()
	;TYA
	;STA !157C,x
	
	LDA #$06
	STA $1887|!Base2
	
	LDY !SpeedValueCounter,x
	LDA Y_Speeds,y
	STA !AA,x
	LDA #$01
	STA $1DF9|!Base2
	INC !SpeedValueCounter,x
	INC !SpeedValueCounter,x
	LDA !SpeedValueCounter,x
	CMP #$10
	BCC NoIncOrReset
	STZ !SpeedValueCounter,x
	JMP Mode
NoIncOrReset:
	LDA !157C,x
	CLC
	ADC !SpeedValueCounter,x
	TAY
	LDA X_Speeds,y
	STA !B6,x
NOT_ON_GND:	
	LDA !1588,x
	AND #$03
	BEQ +
	LDA !157C,x
	EOR #$01
	STA !157C,x
+
	RTS

Mode:
	LDA #$01
	STA !1504,x
	LDA !1686,x
	ORA #$80
	STA !1686,x
	%SubHorzPos()
	TYA
	STA !157C,x

    LDA !7FAB10,x
    AND #$04
    BNE OhLongPart
    LDA #$C5
    STA !AA,x
    LDY !157C,x
    LDA SP,y
    STA !B6,x
	JSL $01802A
	RTS
    
OhLongPart:
	REP #$20
	LDA !14E0,x
	XBA
	LDA !E4,x
	SEC
	SBC $94
	SEP #$20
	PHA
	%SubHorzPos()
	PLA
	EOR DirFix,y
	LSR #4
	PHY
	TAY
	LDA XSPEEDS,y
	PHA
	LDA !157C,x
	BEQ .R
	PLA
	EOR #$FF
	INC A
	BRA ++
.R
	PLA
++
	STA !B6,x
	PLY
	
	REP #$20
	LDA !14D4,x
	XBA
	LDA !D8,x
	SEC
	SBC $96
	SEP #$20
	PHA
	%SubVertPos()
	PLA
	EOR DirFix,y
	LSR #4
	PHY
	TAY
	LDA YSPEEDS,y
	STA !AA,x
	PLY
EndAim:
	JSL $01802A
	RTS
	
XSPEEDS: 
	db $15,$20,$25,$30
	db $35,$45,$55,$60
	db $65,$70,$70,$75
	db $7F,$70,$7F,$7F
YSPEEDS:
	db $D0,$CD,$C5,$C0
	db $BD,$B0,$AD,$A8
	db $A0,$9A,$95,$8F
	db $88,$84,$80,$D0

DirFix: db $FF,$00	
	
;Sprite Routines

YDISP:  
	db $F0,$F0,$00,$00 
	db $F0,$F0,$00,$00 
	db $F0,$F0,$00,$00 
	db $F0,$F0,$00,$00 
 
XDISP:  
	db $00,$10,$00,$10 
	db $00,$10,$00,$10 
	db $10,$00,$10,$00 
	db $10,$00,$10,$00 

GFX:
	%GetDrawInfo()

	LDA $14			
	LSR #3
	AND #$01		
	ASL A 			
	ASL A			
	STA $03			

	LDA !157C,x
	STA $02			
	BNE NoAdd
	LDA $03			
	CLC			
	ADC #$08		
	STA $03			
NoAdd:
	PHX			
	LDX #$03		
Loop:
	PHX			
	TXA			
	ORA $03			
	TAX			

	LDA $00			
	CLC			
	ADC XDISP,x		
	STA $0300|!Base2,y		

	LDA $01			
	CLC			
	ADC YDISP,x		
	STA $0301|!Base2,y		
				

	LDA TILEMAP,x
	STA $0302|!Base2,y

	PHX			
	LDX $02			
	LDA PROPERTIES,x	
	STA $0303|!Base2,y		
	PLX			

	INY			
	INY			
	INY			
	INY			
		
	PLX			
	DEX							
	BPL Loop			
	PLX			

	LDY #$02		
	LDA #$03		
	JSL $01B7B3		
	RTS			
    


I'm not entirely sure why it wouldn't be getting reset ($C2 should get reset by default, anyway), but try adding this to the init code:

Code
	STZ !SpeedValueCounter,x


Professional frame-by-frame time wizard. YouTube - Twitter - SMW Glitch List - SMW Randomizer
That did it! Thanks!
Pages: « 1 » Link
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - Modifying Behaviour of Custom 32x32 Chomp Sprite

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

Copyright © 2005 - 2022 - SMW Central
Legal Information - Privacy Policy - Link To Us


Menu

Follow Us On

  • YouTube
  • Twitch
  • Twitter

Affiliates

  • Super Mario Bros. X Community
  • ROMhacking.net
  • Mario Fan Games Galaxy
  • sm64romhacks