Banner
Views: 729,575,385
Time:
10 users online: Atari2.0, ECS.98, EddyCartoon, lordkronos100, Maarfy, MarioFanGamer, OEOTeam, PokerFace, Romano338, toad64 - Guests: 27 - Bots: 178Users: 38,404 (2,150 active)
Latest: Nahvee
Tip: Keep track of ALL patches and hex edits in case you need to transfer your data to a new ROM. It's definitely worth the trouble.Not logged in.
8x8 player hitbox
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - 8x8 player hitbox
Pages: « 1 »
I'm using this sprite to make Mario move freely on the screen. My issue with this, though, is the hitbox, which right now (as small mario) is 16x16.
I was wondering if there are any ways to edit Mario's hitbox and make it 8x8, with center on that sprite.
I tried this too: the "small" hitbox does help a little, but it's still not an 8x8 hitbox, and I don't feel like editing stuff in that patch, due to my limited asm knowledge.
Any help with this, I'd greatly appreciate.
Found this after a small research in all.log:
Code
MairoClipDispY:                   .db $06,$14,$10,$18

MarioClippingHeight:               .db $1A,$0C,$20,$18

GetMarioClipping:   DA            PHX                       
CODE_03B665:        A5 94         LDA RAM_MarioXPos         ; \ 
CODE_03B667:        18            CLC                       ;  | 
CODE_03B668:        69 02         ADC.B #$02                ;  | 
CODE_03B66A:        85 00         STA $00                   ;  | $00 = (Mario X position + #$02) Low byte 
CODE_03B66C:        A5 95         LDA RAM_MarioXPosHi       ;  | 
CODE_03B66E:        69 00         ADC.B #$00                ;  | 
CODE_03B670:        85 08         STA $08                   ; / $08 = (Mario X position + #$02) High byte 
CODE_03B672:        A9 0C         LDA.B #$0C                ; \ $06 = Clipping width X (#$0C) 
CODE_03B674:        85 02         STA $02                   ; / 
CODE_03B676:        A2 00         LDX.B #$00                ; \ If mario small or ducking, X = #$01 
CODE_03B678:        A5 73         LDA RAM_IsDucking         ;  | else, X = #$00 
CODE_03B67A:        D0 04         BNE CODE_03B680           ;  | 
CODE_03B67C:        A5 19         LDA RAM_MarioPowerUp      ;  | 
CODE_03B67E:        D0 01         BNE CODE_03B681           ;  | 
CODE_03B680:        E8            INX                       ; / 
CODE_03B681:        AD 7A 18      LDA.W RAM_OnYoshi         ; \ If on Yoshi, X += #$02 
CODE_03B684:        F0 02         BEQ CODE_03B688           ;  | 
CODE_03B686:        E8            INX                       ;  | 
CODE_03B687:        E8            INX                       ; / 
CODE_03B688:        BF 60 B6 03   LDA.L MarioClippingHeight,X ; \ $03 = Clipping height 
CODE_03B68C:        85 03         STA $03                   ; / 
CODE_03B68E:        A5 96         LDA RAM_MarioYPos         ; \ 
CODE_03B690:        18            CLC                       ;  | 
CODE_03B691:        7F 5C B6 03   ADC.L MairoClipDispY,X    ;  | 
CODE_03B695:        85 01         STA $01                   ;  | $01 = (Mario Y position + displacement) Low byte 
CODE_03B697:        A5 97         LDA RAM_MarioYPosHi       ;  | 
CODE_03B699:        69 00         ADC.B #$00                ;  | 
CODE_03B69B:        85 09         STA $09                   ; / $09 = (Mario Y position + displacement) High byte 
CODE_03B69D:        FA            PLX                       
Return03B69E:       6B            RTL                       ; Return 

This is the routine that get Mario's clipping values and positions.

When your free movement sprite is active, you could set a flag using some free RAM, that'd be used in a hijack of this code to change the clippings.
Changing the width and X position of the hitbox is easy, but fiddling with the height and Y position might be harder: Is Mario, in your case, always small ? Or can he also be big as usual ?
As for sprite interaction you can just do what mathos said. I made a fixed hitbox a while ago so here is a version that checks a freeram address first:

Code
!RAM_fixedHitbox = $5C

!DEF_XOFF = $02
!DEF_YOFF = $14
!DEF_WIDTH = $0C
!DEF_HEIGHT = $0C

org $03B665
	autoclean JML Check
	NOP

freecode
Check:
	LDA !RAM_fixedHitbox
	BNE .fixedhitbox
	LDA $94
	CLC : ADC #$02
	JML $03B66A
.fixedhitbox
	LDA $94
	CLC : ADC #!DEF_XOFF 
	STA $00
	LDA $95
	ADC.B #$00
	STA $08
	LDA.B #!DEF_WIDTH
	STA $02
	LDA #!DEF_HEIGHT
	STA $03 
	LDA $96
	CLC : ADC #!DEF_YOFF
	STA $01
	LDA $97
	ADC #$00
	STA $09
	JML $03B69D


As for layer collision you'll have to do the same with the collision points of the player. I don't know where they are located though.
That was fast wow.
Anyways no, in the levels where I need the 8x8 hitbox, Mario will be forced to be small thanks to an uberasm code that keeps him small.

Edit: Tested TheBiob's code, set a flag and all with uberasm tool, and seems that it works really good with sprites!
Now the only thing left would be the interaction with layer 1.
There is a documentation on player <-> level collision points here
Assuming I understood that document correctly something like

Code
!RAM_hitbox = $5C

org $00F44F
	autoclean JML Hitbox

freecode
XOff:
	dw $0E0C,$0008,$000E,$000E
	dw $0008,$0005,$000B,$0008
	dw $0002,$0002,$0008,$000B
	dw $0005,$0008,$000E,$000E
	dw $0008,$0005,$000B,$0008
	dw $0002,$0002,$0008,$000B
	dw $0005,$0008,$000E,$000E
	dw $0008,$0005,$000B,$0008
	dw $0002,$0002,$0008,$000B
	dw $0005,$0008,$000E,$000E
	dw $0008,$0005,$000B,$0008
	dw $0002,$0002,$0008,$000B
	dw $0005,$0010,$0020,$0007
	dw $0000,$FFF0
YOff:
	dw $0008,$0018,$001A,$0016
	dw $0010,$0020,$0020,$0018
	dw $001A,$0016,$0010,$0020
	dw $0020,$0012,$001A,$000F
	dw $0008,$0020,$0020,$0012
	dw $001A,$000F,$0008,$0020
	dw $0020,$001D,$0028,$0019
	dw $0013,$0030,$0030,$001D
	dw $0028,$0019,$0013,$0030
	dw $0030,$001A,$0028,$0016
	dw $0010,$0030,$0030,$001A
	dw $0028,$0016,$0010,$0030
	dw $0030,$0018,$0018,$0018
	dw $0018,$0018,$0018

Hitbox:
	LDA !RAM_hitbox
	BNE .newHitbox
	REP #$20
	LDA $94
	JML $00F453
.newHitbox
	PHB : PHK : PLB
		REP #$20
		LDA $94
		CLC : ADC.W XOff,x
		STA $9A
		LDA $96
		CLC : ADC.W YOff,X
		STA $98
	PLB
	JML $00F461


should allow you to use custom collision points when the flag is set. Haven't experimented with it much though.
Okay, that also works. I toyed a bit with the values in that table until I got a good enough result. Thank you very much to both!

Silly question, but this patch is safe to insert multiple times into a rom, isn't it? I got my values with pretty much trial and error; I think I inserted the patch like 10 times or so.
Yes, autoclean should take care of that.
i have to put something here or it breaks

no egg
Originally posted by Wakana
Silly question, but this patch is safe to insert multiple times into a rom, isn't it? I got my values with pretty much trial and error; I think I inserted the patch like 10 times or so.

It's fine with every patch, once you add it again it replaces the original code or lastest patch applied (autoclean)

--------------------
~Ultrabi

One day I'll make a layout...
Asar would usually throw an error if it detects that freespace isn't properly cleaned and asks you if you are sure about inserting that patch before modifing your rom. So as long as asar doesn't have some odd bug that no one ever found it should be fine to insert it and asar should tell you if it isn't.
Oh okay, didn't know about that at all.
Thank you very much! #smw{:TUP:}
Pages: « 1 »
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - 8x8 player hitbox

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

Menu

Follow Us On

  • Facebook
  • Twitter
  • YouTube

Affiliates

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