I don't know if this has been posted before, but whatevs. It came to my attention today that the bag in FireRed crashes if a "main" pocket has more than 42 items (the normal max for regular items). I had always assumed the malloc was done based on a multiple of the numbers inputted at the routine beginning 0x08099E44, because the TM pocket works fine even with over 100 items, but apparently the berry/TM cases mean they run off of something different. Anyhow, to allow for sufficient malloc requests, change ".equ largest_pocket_size" to your new max and insert this:
Code:
.equ largest_pocket_size, CHANGE THIS LINE
.equ largest_pocket_size_plus_one, largest_pocket_size + 1
.equ strings_size, largest_pocket_size_plus_one * 19
.org 0x08002B9C
malloc:
push {lr}
mov r1, r0
.org 0x081083F4
main:
push {r4, lr}
ldr r4, =(0x0203AD18)
mov r0, #largest_pocket_size_plus_one
lsl r0, r0, #0x3
bl malloc
str r0, [r4, #0x0]
cmp r0, #0x0
beq return
ldr r0, =strings_size
bl malloc
str r0, [r4, #0x4]
cmp r0, #0x0
beq return
mov r0, #0x1
return:
pop {r4}
pop {r1}
bx r1
EDIT: I haven't done much testing. I've only thrown like 60 items into the general items pocket before I got bored & assumed this routine was the only problem.
Info on 0x08099E44:
http://www.pokecommunity.com/showpost.php?p=9014911&postcount=2018