FBI

Free supporter

Male
Unknown Island
Seen 4 Hours Ago
Posted December 17th, 2019
1,910 posts
7.5 Years

Pokemon Storage (outside the PC)



Basically, in it's current state, this is effectively a storage system. It stores Pokemon and can be interacted with by the player to withdraw or deposit Pokemon. It's standalone from the PC storage system and is also much smaller (I've limited it to 6, but it can go upto 47). Some things that you will be able to do with this routine (and conjunction with some smaller ones) include:
- Extra Pokemon storage, you can possibly get a little over 1 box worth
- Flash back battles (complete swap between stored Pokemon and party Pokemon with capabilities to swap back)
- Carry a party of greater than 6 Pokemon (you can use the 2nd party for HM slaves, or whatever)
- Trade evolver guy! He will take your Pokemon and then when you come back it can be evolved! (silent evolution ftw!)
- Separate Daycare holding larger amount of Pokemon at once

I've tested it thoroughly and there doesn't seem to be any problems. I will be adding more and more features into this because I believe that it has the potential to become a very useful feature.
Currently planning to add:
- Party swap completely all in one go (this will actually be in the very near future..maybe today even :P)
- Partial swapping (believe it or not, this is hard because there's no graphical support)
- Suggest me more :D

How to insert:

Compile into free space the following routine:
Spoiler:

.text
.align 2
.thumb
.thumb_func

main:
	push {r0, r4, lr}
	ldr r0, .FROM
	ldr r1, [r0]
	cmp r1, #0x0 @party
	beq addParty

addStorage:
	ldr r0, .STORAGE
	sub r0, r0, #0x1
	ldrb r1, [r0]
	cmp r1, #0x6 @limit of storage. Change depending on your space situation
	beq end
	add r0, r0, #0x1
	mov r2, #0x50
	cmp r1, #0x0
	beq skipline
	sub r1, r1, #0x1
	mul r1, r1, r2
	add r0, r0, r1 @destination
	ldr r1, =(0x20370C0)
	ldrb r1, [r1]
	ldr r2, .PARTY
	mov r3, #0x64
	mul r1, r1, r3
	add r1, r1, r2 @source
	mov r2, #0x50 @size
	ldr r3, =(0x8040B08 +1) @func
	bl linker
	@need to fix up Player's party slots
	ldr r1, =(0x20370C0)
	ldrb r1, [r1]
	cmp r1, #0x5
	beq writeLastZero
	mov r2, #0x5
	sub r2, r2, r1
	mov r3, #0x64
	mul r2, r2, r3 @size
	ldr r0, .PARTY
	mul r1, r1, r3
	add r0, r0, r1 @dest
	add r3, r3, r0
	mov r1, r3      @src
	ldr r3, =(0x8040B08 +1) @func
	bl linker
	

writeLastZero:
	ldr r0, =(0x2024478)
	mov r1, #0x0
	mov r2, #0x64
	ldr r3, =(0x81E5ED8 +1)
	bl linker

correctCounters:
	ldr r0, .STORAGE
	sub r0, r0, #0x1
	ldrb r2, [r0]  @pks in storage counter
	ldr r1, =(0x2024029)
	ldrb r3, [r1] @pks in party
	add r2, r2, #0x1
	strb r2, [r0]
	sub r3, r3, #0x1
	strb r3, [r1]
	b end
	


addParty:
	ldr r0, =(0x2024029)
	ldrb r0, [r0]
	cmp r0, #0x6
	beq end
	ldr r1, .PARTY
	mov r2, #0x64
	mul r0, r0, r2
	add r0, r0, r1 @destination
	mov r4, r0
	ldr r3, .STORAGE
	ldr r1, =(0x20370C0) @var 0x8004 determines which slot of storage to take from
	ldrb r1, [r1]
	mov r2, #0x50 @size
	mul r1, r1, r2
	add r1, r1, r3 @source
	ldr r3, =(0x8040B08 +1) @func
	bl linker
	@update stats 
	mov r0, r4
	ldr r3, =(0x803E47C +1)
	bl linker
	@adjust the storage
	ldr r0, =(0x20370C0)
	ldrb r0, [r0]
	cmp r0, #0x5 @storage limit minus 1
	beq writeZero
	mov r2, #0x5
	sub r2, r2, r0
	mov r3, #0x50
	mul r2, r2, r3 @size
	ldr r1, .STORAGE
	mul r0, r0, r3
	add r0, r0, r1 @dest
	add r3, r3, r0
	mov r1, r3      @src
	ldr r3, =(0x8040B08 +1) @func
	bl linker

writeZero:
	ldr r0, .STORAGE
	mov r1, #0xC8
	lsl r1, r1, #0x1
	add r0, r0, r1
	mov r1, #0x0
	mov r2, #0x50
	ldr r3, =(0x81E5ED8 +1)
	bl linker

updateCounters:
	ldr r0, .STORAGE
	sub r0, r0, #0x1
	ldrb r2, [r0]
	ldr r1, =(0x2024029)
	ldrb r3, [r1]
	sub r2, r2, #0x1
	strb r2, [r0]
	add r3, r3, #0x1
	strb r3, [r1]

end:
	pop {r0-r4, pc}	

linker:
	bx r3	
	
.align 2

.FROM:
	.word 0x20270B8 + (0x8000 *2)

.STORAGE:
	.word 0x203C001 @storage location

.PARTY:
	.word 0x2024284 @player's party


Here's a compiled version:
11 B5 38 48 01 68 00 29 32 D0 37 48 01 38 01 78 06 29 65 D0 01 30 50 22 51 43 40 18 34 49 09 78 32 4A 64 23 59 43 89 18 50 22 32 4B 00 F0 59 F8 2F 49 09 78 05 29 0B D0 05 22 52 1A 64 23 5A 43 2A 48 59 43 40 18 1B 18 19 1C 2A 4B 00 F0 49 F8 29 48 00 21 64 22 29 4B 00 F0 43 F8 22 48 01 38 02 78 27 49 0B 78 01 32 02 70 01 3B 0B 70 37 E0 23 48 00 78 06 28 33 D0 1C 49 64 22 50 43 40 18 04 1C 19 4B 1A 49 09 78 50 22 51 43 C9 18 19 4B 00 F0 27 F8 20 1C 1B 4B 00 F0 23 F8 14 48 00 78 05 28 0B D0 05 22 12 1A 50 23 5A 43 0E 49 58 43 40 18 1B 18 19 1C 0F 4B 00 F0 13 F8 0A 48 C8 21 49 00 40 18 00 21 50 22 0C 4B 00 F0 0A F8 06 48 01 38 02 78 0A 49 0B 78 01 3A 02 70 01 33 0B 70 1F BD 18 47 B8 70 03 02 01 C0 03 02 84 42 02 02 C0 70 03 02 09 0B 04 08 78 44 02 02 D9 5E 1E 08 29 40 02 02 7D E4 03 08
Usage:

The routine itself manages party storage and storage extraction. What you need to do is determine which one it performs.
If you want to remove a Pokemon from the party and into storage, setvar 0x8000 anything but zero
if you want to remove a Pokemon from storage, setvar 0x8000 0x0
Which variable you used can be changed, as always, by editing the pointer at the bottom of the routine.
The next thing is variable 0x8004. I use this variable to determine the slot of extraction for both the Party and the Storage system.
If I wanted to take the 3rd Pokemon in the party and put it in storage:
setvar 0x8004 0x2
setvar 0x8000 0x1
callasm 0x[routine] +1

The reason for this is to support easy use of special 0x9F. Though you can use copyvar, I suppose.

Finally, the routine writes to RAM a counter, which keeps track of how many Pokemon are in the storage.
This is written at 0x203C000, and can be retrieved by using the "copybyte" scripting command. For example:
copybyte 0x20370D0 0x203C000 'puts the storage counter into variable 0x800D (lastresult).

I tried to keep it simple, and do the work inside the routine, hopefully that paid off.
Here's a very poor sample script. Poor because it handles all the cases, but it doesn't display the system's full potential :P

Spoiler:

PKSV script.
#dyn 0x740000
#org @start
lock
faceplayer
copybyte 0x20370D0 0x203C000 ' storage count into last result
compare LASTRESULT 0x0
if == jump @putOnly
msgbox @add
callstd MSG_YESNO 'want to take?
compare LASTRESULT 0x1
if == jump @addParty
jump @putOnly

#org @putOnly
countpokemon
copyvar 0x8000 0x800D
compare 0x8000 0x1
if <= jump @greetings
msgbox @put
callstd MSG_YESNO 'want to put?
compare LASTRESULT 0x1
if == jump @addStorage
msgbox @exit
callstd MSG_NORMAL
release
end

#org @addStorage
setvar 0x8000 0x1
special 0x9F
waitspecial
countpokemon
compare LASTRESULT 0x8004
if < jump @noSelection
callasm 0x[routine +1]
msgbox @gave
callstd MSG_NORMAL
release
end


#org @addParty
setvar 0x8000 0x0
countpokemon
compare LASTRESULT 0x6
if == jump @fullP
msgbox @store
callstd MSG_NORMAL
setvar 0x8004 0x0 'gotta rework this to work a better way
callasm 0x[routine +1]
fanfare 0x101
msgbox @complete
callstd MSG_NORMAL
release
end

#org @greetings
msgbox @hello
callstd MSG_NORMAL
release
end

#org @fullP
msgbox @full
callstd MSG_NORMAL
release
end

#org @noSelection
msgbox @exit
callstd MSG_NORMAL
release
end

#org @full
= You're party is full!

#org @hello
= Hi, I can't do anything\nyour slots are full or empty\lor mine are full while yours are\lfull[.]

#org @complete
= I gave it back.

#org @store
= Alright, I'll give it to you.

#org @gave
= Thanks for giving me this.

#org @exit
= Alright, next time then.

#org @add
= Want your Pokemon back?

#org @put
= Want to give me a pokemon?


That's it for now. Keep an eye out for "addons" for this routine in the future :)
Sorry for the double post. I like seperate posts for my routines to keep the first post's links neat :x
...