Banner
Views: 852,655,787
Time:
12 users online: Dominicentek, FYRE150, IsaiahCannell, JoaoPaulo,  KevinM, le4che, Mathos, Nint,  Stivi, SuperMarisa1999, Zeldara109, Zidan3 - Guests: 37 - Bots: 73 Users: 47,014 (2,516 active)
Latest: OcelotMadness
Tip: Check the Documents section. Tutorials and other useful information can be found there.Not logged in.
Thread number two (Custom overworld paths)
Forum Index - Sunken Ghost Ship - C3 Museum - Summer 2015 - Thread number two (Custom overworld paths)
Tags:
Pages: « 1 »
This code is intended to be used in uberASM as game mode 0E, I'll try making a tutorial on how to use this in depth later.

In the meantime here is a demo video:
https://youtu.be/kl8gNgX6CWI

Features:
* Automatically can reverse paths
* Can run custom code
* Can be used as custom tiles (for example conditional level tiles)

Gamemode 0E init
Code
gamemode_init_E:
	STZ $1520	;Custom path state
	STZ $1524	;Current path frame counter
	STZ $1526	;Number of actions
	STZ $1528	;Speed table pointer
	STZ $152A	;Reverse flag
	STZ $152C	;Animation flag
	RTS


Gamemode 0E main

Code
pushpc	
	org $049828
		NOP #3
		JSL check_normal_movement

	org $04927d
		NOP #6
		JSL check_normal_animation 
		
	org $04EA1E
		NOP #3
		
pullpc

gamemode_E:
	LDA $13D4
	BEQ +
		RTS
	+
	PHP
	REP #$30
	
	LDA $1520
	BEQ +
		STZ $15
		STZ $17
	+
	ASL
	TAX
	JMP (custom_path_states,x)
	
custom_path_states:
	dw check_for_path
	dw run_path
	
check_for_path:	
	LDX $0DD6
	LDA $1F17,x
	sta $5003
	LDX #locator_offsets
	LDY #headers
	JSR search
	BCC .no_path_found
		TYA
		SEC
		SBC #locator_offsets
		ASL #2
		ADC #headers
		TAY
		
		LDX $0DD6
		LDA $1F19,x
			STA $5005
		CMP $0000,y
		BNE .no_path_found
			BRA path_found
	.no_path_found
custom_path_return:
	PLP
null_path_return:
	RTS
	
path_found:
	SEP #$20
	LDA $0005,y
	BMI .handle_reverse
		STA $1526
		STZ $152A
		STZ $152B
		BRA .button_check
	.handle_reverse
		AND #$7F
		STA $1526
		LDA #$FF
		STA $152A
		STA $152B
	.button_check
		LDA $0004,y
		BEQ .no_trigger
			CMP $15
			BNE custom_path_return
	.no_trigger
		REP #$20
		INC $1520
		LDA $0002,y
		LDX $152A
		BEQ .not_reverse
			STA $00
			LDA $1526
			ASL 
			ADC $1526 
			ASL 
			ADC #$0006 
			ADC $00
	.not_reverse
		SEC
		SBC #$0004
		STA $1528
		STZ $1524
		TYX
		JSR ($0006,x)

run_path:
	LDA #$0004
	STA $13D9
	
	JSR get_next_path
	LDX $0DD6
	
	LDA $0000,y
	EOR $152A
	CLC
	ADC $1F17,x
	STA $1F17,x
	
	LDA $1F19,x
	LDA $0002,y
	EOR $152A
	CLC
	ADC $1F19,x
	STA $1F19,x
	
	LDA $152A
	BEQ +
		INC $1F17,x
		INC $1F19,x
	+
	
	DEC $1524
	LDA $0DB3
	AND #$00FF
	ASL
	TAX
	LDA $152C
	STA $1F13,x
	PLP
	RTS
	
get_next_path:
	LDA $1524
	BNE +
		LDA $1528
		LDX $1526
		BEQ .done
		LDX $152A
		BEQ .forward
			SEC
			SBC #$000C
		.forward
			CLC
			ADC #$0004
			TAX
			
			LDA $0000,x
			XBA
			LSR #4
			AND #$000F
			STA $1524
			
			LDA $0000,x
			LDY $152A
			BNE .reverse
				XBA
			.reverse
			AND #$000F
			ASL
			STA $152C

			INX
			INX
			STX $1528
			DEC $1526
	+
	LDY $1528
	RTS
	
.done		;Finish the event here
	PLA	;DESTRUCTIVE RETURN
	STZ $1520
	LDA #$0003
	STA $13D9
	PLP
	RTS


cancel_path_return:
	STZ $1520
forced_path_return:
	PLA
	PLP
	RTS

search:	
	STA $02
	TYA
	
	STX $00
next:
	CMP $00
	BCC not_found
		PHA
		CLC
		ADC $00
		ROR
		AND #$FFFE
		TAY
		PLA
		
		LDX $0000,y
		CPX $02 
		BEQ found
		BCS larger
			INY
			INY
			STY $00
			BRA next
		larger:
			DEY
			DEY
			TYA
			BRA next
not_found:
	RTS	
found:
	SEC
	RTS
	
check_normal_movement:
	PHY
	LDY $1520
	BNE +
		STA $1F17,x
	+
	DEX
	DEX
	PLY
	DEY
	DEY
	RTL
	
	
check_normal_animation:
	LDA $1520
	BNE +
		LDA $1F13,x 
		AND #$08    
		ORA #$02    
		STA $1F13,x
	+
	RTL
	
disable_entry:
	LDA $15
	AND #$0F0F
	STA $15
	STZ $17
	
	jmp cancel_path_return
	
;Locator format: dw $XXXX (X = X position)
;Header format: dw $YYYY, $OOOO, %RLLLLLLLBBBBBBBB, $EEEE
;(Y = Y position, O = offset B = $16 button {byetUDLR}, L = length 7 bit, R = reverse 1 bit, E = Expansion Execute)
;Speed prefix: dw $FAEB (F = frames, A = animation (1F13 >> 1), B = Backward animation, E = Expansion -- all 4 bits)
;X Speed format: dw prefix, $XXXX, $YYYY  (X = "forward" speed, Y = "forward" speed (corresponded to by the A field))
function activation_prefix(buttons, reverse, length) = (buttons<<0)|(length<<8)|(reverse<<15)
function speed_prefix(frames, animation, expansion, return) = (frames<<12)|(animation<<8)|(expansion<<4)|(return<<0)
padding:
fillbyte $EA
fill padding&1
print "test ",pc
;NOTE: these MUST be in order from SMALLEST to LARGEST
locator_offsets:
	dw $0068
	dw $0076

;NOTE: These should correspond to the same order of the previous offsets
headers:
	dw $0078, custom_path_1, activation_prefix($08, $0, $C), null_path_return
	dw $0033, custom_path_1, activation_prefix($08, $1, $C), null_path_return

;Custom paths can be in any order you'd like though
;$1F13 >> 1:
;#$00 = Move up.
;#$01 = Move down or standing still (facing the screen).
;#$02 = Move left.
;#$03 = Move right.
;#$04 = Move up while in water.
;#$05 = Move down while in water, stand still while in water (facing the screen).
;#$06 = Move left while in water.
;#$07 = Move right while in water.
;#$08 = Sticking hand out (entering level).
;#$09 = Sticking hand out while in the water (entering level).
;#$0A = Climb ladder/vine, only used when descending path tile #$41.
;#$0B = Climb ladder/vine, regular.

;positive X = right, negative = left
;positive Y = down, negative = up
custom_path_1:
	dw speed_prefix($F, $0, $0, $1), -$0001, -$0001
	dw speed_prefix($F, $0, $0, $1), -$0001, -$0001
	dw speed_prefix($F, $0, $0, $1), -$0001, -$0001
	dw speed_prefix($1, $0, $0, $1), -$0001, -$0001
	dw speed_prefix($F, $B, $0, $B), $0000, -$0001
	dw speed_prefix($F, $B, $0, $B), $0000, -$0001
	dw speed_prefix($F, $B, $0, $B), $0000, -$0001
	dw speed_prefix($8, $B, $0, $B), $0000, -$0001
	dw speed_prefix($F, $3, $0, $2), $0001, $0000
	dw speed_prefix($F, $3, $0, $2), $0001, $0000
	dw speed_prefix($F, $3, $0, $2), $0001, $0001
	dw speed_prefix($F, $1, $0, $0), $0001, $0001



The comments should explain the most important parts for now though.

questions, comments?
It's about damn time! Totally gonna abuse this shit when I work on my hack.
So, can you set custom speeds based on paths with this patch? if yes that's a pretty awesome thing to do and I like it. I wonder though, can you make a path that goes only one-way, and even more importantly, how does this patch work with the switch submap tiles (aka the red tiles in the LM map editor).

--------------------
I wonder what a HFD opcode would do in ASM...
Sorry for being naive, but I fail to understand how this is different from regularly making overworld paths in Lunar Magic (other than the speed.)
Could you explain it to me in greater detail?
I'm actually really confused as to what is going on right now xD
I thought it was a joke entry at first then I saw the coding
My YouTube Channel
Best SMW Hacks Compilation
Originally posted by TLMB
So, can you set custom speeds based on paths with this patch? if yes that's a pretty awesome thing to do and I like it. I wonder though, can you make a path that goes only one-way, and even more importantly, how does this patch work with the switch submap tiles (aka the red tiles in the LM map editor).


It can't interact with normal exit tiles directly -- but you can simulate them via the routine system. And yes, one way paths are possible. In fact you could make a path that works in one direction the first time the OW is loaded and another direction the next (even and odd so to speak).

Quote

Sorry for being naive, but I fail to understand how this is different from regularly making overworld paths in Lunar Magic (other than the speed.)
Could you explain it to me in greater detail?


You can make shapes with this that are not possible in LM. This code has the granularity to produce tiles that can move mario as little as a single pixel even. Here is an early demo of something I did with this code when testing it for the rocket of VLDC: https://www.youtube.com/watch?v=0OfjERRcPyA

That entire walking animation is a single path -- total control.

Quote

I'm actually really confused as to what is going on right now xD
I thought it was a joke entry at first then I saw the coding


I figured it was pretty obvious this lets you make custom overworld paths beyond that which you can do in LM. want a tile that makes mario spin around? what about diagonal lines? or serpentine patterns? all are possible and more :)
I imagine this will be very useful for people that like to make awesome OWs. Good job man.

allow shy guy emojis in post footers you cowards!
Now to get FuSoYa to either implement this (doubtful) of make it possible to edit the appearance of path tiles in LM.(more likely)

Either way, great work. Guess I'll have to study the ASM code when I get the time.
Also, you obviously forgot to lock the youtube video, unlike all your other videos :P

--------------------
Anime statistic on MyAnimeList:
400 animes completed ✓
6000 episodes completed ✓
100 Days completed ✓
... what even am I doing with my life?
Pages: « 1 »
Forum Index - Sunken Ghost Ship - C3 Museum - Summer 2015 - Thread number two (Custom overworld paths)

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

Copyright © 2005 - 2020 - 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