Free supporter

Unknown Island
Seen 8 Hours Ago
Posted 1 Day Ago
1,906 posts
6.7 Years

Minute Routines Frame Structure

This is very similar to my original Battle Modes routines. It's another frame structure routine. I was working on roaming and now swarming and encountered myself using this quite often. It's also the case that many people may need to access this kind of "minute executed" structure because there may be timed events and such you will need to hook out of the default routine!

"But FBI, what about your Roaming Pokemon routine?" Good question, lad. I've updated that routine to work off of this as well. Optimizations which lead to expansion and custimization trigger my hacking sensation 10/10 rap.

How to insert:

First of all take a look at the orange text in the spoiler'd routine. The orange text needs to be modified to a pointer in the ROM which will be used as the table for all the routines which are called once every minute or upon the change of the minute. I would personally allot about 40 bytes of free space (that's enough for 10 routines).

Once you've done that, compile the routine into free space.


.align 2

	push {r0-r7}
	mov r4, #0x0
	ldr r0, .TABLE
	mov r1, #0x4
	mul r1, r1, r4
	add r0, r0, r1
	ldr r0, [r0] @load routine
	mov r1, r0
	lsr r1, r1, #0x18
	cmp r1, #0xFF
	beq noCrash @if end of routine table, break out
	bl linker
	add r4, r4, #0x1
	b loop
	bx r0

	pop {r0-r7}
	ldrb r0, [r1, #0x10]
	cmp r0, #0x59
	bls end
	strb r3, [r1, #0x10]
	ldr r0, =(0x80548B0 +1)
	bx r0

	pop {r0}
	bx r0

.align 2

	.word 0x8[free space in ROM. Do not add 1]

Now navigate to 0x548A8 and insert the following byte changes:
00 48 00 47 XX XX XX 08
Where XX XX XX is where you inserted this routine +1 in reverse hex.


This routine will run through all the pointers in the table you provided. It will keep going until it reaches FF FF FF FF with is read as the terminating pointer (i.e it stops reading pointers after that value is reached). So basically to add more routines into the list of executed routines, you would just append another pointer (in reverse hex +1) to your new routine's location. The actual calling and everything is done inside the game. I should and will also mention that this routine is called at the part where the game timer's Minute is updated.

Even if you don't have minutes routines right now, I suggest you insert this one, because it will definitely come in useful for the near near future (I promise :P).

Roaming Pokemon has also been updated to use this routine.