Banner
Views: 730,828,077
Time:
19 users online: dakotaxx, Digital Entertainment, ECS.98, o Erik, Far, Flippn'Fences, Golden Yoshi, GroovyYoshi, idol, Majunia, Meirdent, NextTactics, o Plasmodium00, RussianMan, o Scrydan, squ0g, sss cs, o tcdw, UnclePropeller - Guests: 62 - Bots: 70Users: 38,459 (2,080 active)
Latest: syndrom
Tip: ALWAYS test anything that you've made before submitting it to SMW Central.Not logged in.
Making ghost sprites interact with objects
Forum Index - SMW Hacking - SMW Hacking Help - Making ghost sprites interact with objects
Pages: « 1 »
Greetings,

For my hack, I'm trying change the Big Boo disassembly by imamelia (https://www.smwcentral.net/?p=section&a=details&id=16235) so that it becomes capable of interacting with objects. My sprite ASM-fu isn't good enough to do this on my own yet, so I need your help.

Here is the code (without the GFX routine):

Code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; init routine
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

print "INIT ",pc
JSL $01ACF9|!BankB
STA !1570,x

if !AntiOrAlwaysChase == 0
	LDA !7FAB10,x		;load extra bits
	AND #$04		;check if first extra bit is set
	BEQ +			;if not set, Boo will chase normally.

	LDA #$01		;load value for EOR chase table value
	STA !1534,x		;store to sprite RAM.
	RTL

+
endif
	STZ !1534,x		;clear sprite RAM used for EOR chase table value.
RTL

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; main routine wrapper
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; main routine
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

BigBooMain:
LDA #$01
%SubOffScreen()

LDA #$20		;
STA $18B6|!Base2	; unknown RAM address?

LDA !14C8,x	;
CMP #$08		; if the sprite is not in normal status...
BNE SkipToGFX	;
LDA $9D		; or sprites are locked...
BEQ ContinueMain	; skip most of the main routine and just run the GFX routine
SkipToGFX:	;
JMP InteractGFX	;

ContinueMain:	;

%SubHorzPos()	;

LDA !1540,x	; if the timer is set...
BNE NoChangeState	;

LDA #$20			;
STA !1540,x		;
LDA !C2,x		; if the sprite state is zero...
BEQ NoCheckProximity	;
LDA $0E			;
CLC			;
ADC #$0A		;
CMP #$14		;
BCC Skip1		; skip the next part of code if the Boo is within a certain distance
NoCheckProximity:	;

if !AntiOrAlwaysChase != 0
LDA !7FAB10,x		;
AND #$04		; if the extra bit is set...
BNE NoChangeState	; make the Boo always follow the player
endif

STZ !C2,x		;
CPY $76			; if the Boo is facing the player...
BNE NoChangeState	; don't make it follow him/her
INC !C2,x		;

NoChangeState:		;
LDA $0E			;
CLC			;
ADC #$0A		;
CMP #$14			;
BCC Skip1		;

LDA !15AC,x		; if the sprite is turning...
BNE Skip2			; skip the check and set
TYA			;
CMP !157C,x		;
BEQ Skip1			;
LDA #$1F			;
STA !15AC,x		; set the turn timer
BRA Skip2			;

Skip1:

STZ !1602,x		;
LDA !C2,x		;
EOR !1534,x	;flip bit 0 if value is set
BEQ Skip3			;
LDA #$03			;
STA !1602,x		;
AND $13			;
BNE Skip4			;
INC !1570,x		;
LDA !1570,x		;
BNE NoSetTimer2		;
LDA #$20			;
STA !1558,x		;
NoSetTimer2:		;
LDA !B6,x		; increment or decrement the sprite X speed
BEQ XSpdZero		; depending on whether it is positive, negative, or zero
BPL XSpdPlus		;
INC			;
INC			;
XSpdPlus:			;
DEC			;
XSpdZero:			;
STA !B6,x			;
LDA !AA,x		; same for the Y speed
BEQ YSpdZero		;
BPL YSpdPlus		;
INC			;
INC			;
YSpdPlus:			;
DEC			;
YSpdZero:			;
STA !AA,x		;

Skip4:
JMP UpdatePosition

Skip2:

CMP #$10		;
BNE NoFlipDir	;
PHA		;
LDA !157C,x	;
EOR #$01		; flip sprite direction
STA !157C,x	;
PLA		;
NoFlipDir:	;
LSR #3		;
TAY		;
LDA Frame,y	;
STA !1602,x	;

Skip3:

STZ !1570,x	;
LDA $13		;
AND #$07	; skip this every 8 frames
BNE UpdatePosition	;

%SubHorzPos()	;

LDA !B6,x	;
CMP SpeedMax,y	;
BEQ NoIncXSpeed	;
CLC		;
ADC IncTable,y	;
STA !B6,x		;
NoIncXSpeed:	;

LDA $D3		;
PHA		;
SEC		;
SBC $18B6|!Base2	;
STA $D3		;
LDA $D4		;
PHA		;
SBC #$00		;
STA $D4		;

JSR SubVertPos2	;

PLA		;
STA $D4		;
PLA		;
STA $D3		;

LDA !AA,x	;
CMP SpeedMax,y	;
BEQ UpdatePosition	;
CLC		;
ADC IncTable,y	;
STA !AA,x	;

UpdatePosition:

JSL $018022	;
JSL $01801A	;

InteractGFX:	;

LDA !14C8,x	;
CMP #$08		; if the sprite is not in normal status...
BNE NoInteraction	; don't interact with the player

JSL $01A7DC	;

NoInteraction:	;

JSR BigBooGFX	;

RTS


My guess is I have to add something to NoSetTimer2 to set the x-speed to zero when touching a solid block, but I couldn't get it to work.

Your help would be much appreciated.


There's a good alternative: when you're calculating the sprite speeds, you have first to JSL $019138, which enables sprite<->object interaction. After, you check $1588,x to see if the sprite is blocked by a solid object, and set the speeds accordingly. Also, don't forget to uncheck the option 'Don't interact with objects' in the .cfg file.

--------------------


Signed Major Flare, a.k.a Br OW Hacker.


If I rewrite NoSetTimer2 by adding the first three lines, the game crashes:

Code
NoSetTimer2:		
JSL $019138
LDA $1588,x
BEQ XSpdZero
LDA !B6,x		; increment or decrement the sprite X speed
BEQ XSpdZero		; depending on whether it is positive, negative, or zero
BPL XSpdPlus		;
INC			;
INC			;
Pages: « 1 »
Forum Index - SMW Hacking - SMW Hacking Help - Making ghost sprites interact with objects

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: 25

Menu

Follow Us On

  • Facebook
  • Twitter
  • YouTube

Affiliates

  • Talkhaus
  • SMBX Community
  • GTx0
  • Super Luigi Bros
  • ROMhacking.net
  • MFGG
  • Gaming Reinvented