Language…
8 users online: Dark Mario Bros, Firstnamebutt, Golden Yoshi, Isikoro, krizeth, monkey03297, qantuum,  Ringo - Guests: 235 - Bots: 293
Users: 64,795 (2,376 active)
Latest user: mathew

Auto-walking on overworld?

I've been trying to add code to cause Mario to auto-walk on the overworld, after custom exits where he normally wouldn't auto-walk. Haven't had any success though.

I've tried hijacking the routine in the $04920F region, but it seems it's not run at all (even adding a BRK has no effect), leading me to conclude Lunar Magic bypasses it.

I've also tried telling the player to auto-walk as part of the tertiary exit code I've added, as seen below. The commented lines either softlocked or seemed to do nothing, though.

Edit: It's working now. I've updated the code in this post in case it's useful to anyone else.
Code
!ExitFreeRAM = $0DD9        ; used for tertiary exit to activate
!TertiaryExitFlags = $1F2B  ; 3-byte table for tertiary exits, free RAM that's saved with the file
!AutoWalkRAM = $1477        ; set during tertiary exit processing to cause an auto-walk [cleared on overworld load]

org $84E5EE
autoclean JSL TertiaryExitIncrement : NOP
   ; hijack overworld code that runs when exiting a level

org $84925F
autoclean JML OWMarioWalk
   ; hijack where the game checks for controller arrow input on the overworld

freecode

TertiaryExitIncrement:
LDA !ExitFreeRAM
BEQ .Skip        ; code runs only if there's a tertiary exit flag to activate

DEC              ; decrement A (#$00 isn't a valid tertiary exit index)
PHA
AND #$07         ;\
TAX              ;/ X: bit number (lowest 3 bits, index for $85B35B,x)
PLA
LSR #3           ;\
TAY              ;/ Y: byte number

LDA.w !TertiaryExitFlags,y  ; load the relevant tertiary exit flag byte
AND.l $85B35B,x  ; filter out one bit from tertiary exit byte
BNE +            ;\ if this bit isn't set yet...
INC !ExitCount   ;/ increment exit counter

  ; special code to auto-walk on tertiary exit #$08
LDA !ExitFreeRAM
CMP #$08
BNE +
LDA $1EE3        ;\ $1EA2+41 (translevel 41 = level 11D)
ORA #$08         ;| set bit 3 to enable upward
STA $1EE3        ;/
LDA #$01         ;\ play coin sound effect (seems to play at the end of events)
STA $1DFC        ;/
LDA #$08         ;\ auto-walk upward (____udlr)
STA !AutoWalkRAM ;/
+
LDA.w !TertiaryExitFlags,y
ORA.l $85B35B,x  ; set the bit
STA.w !TertiaryExitFlags,y

.Finish
STZ !ExitFreeRAM ; clear free RAM so routine doesn't activate repeatedly
LDA #$FF         ;\ clear event to activate
STA $1DEA        ;/ (otherwise the game could activate a normal event after a tertiary exit)
LDA #$80         ;\
STA $0DD5        ;/ set level to be exited via Start-Select instead of normal/secret exit

.Skip
LDA $0DD5        ;\ replaced
CMP #$02         ;| 
RTL              ;/ 


OWMarioWalk:
LDA !AutoWalkRAM
BNE .ForceAutoWalk
LDA $16          ;\ replaced (load directions pressed from controller)
AND #$0F         ;/
JML $849263

.ForceAutoWalk
STZ !AutoWalkRAM ; clear free RAM so routine doesn't activate repeatedly
JML $849263      ; return, as if the direction in !AutoWalkRAM was pressed


–=–=–=–=–=–=–
Advynia: a Yoshi's Island editor - Alyssa's Unlikely Trap demo 3
Managed to fix it! Found a better hijack, the check for whether the player's pressing a button to move on the overworld.

I'll edit the code into my original post, in case anyone's curious/finds some way to improve it.

–=–=–=–=–=–=–
Advynia: a Yoshi's Island editor - Alyssa's Unlikely Trap demo 3