Move find item flag calculation

From Final Fantasy Hacktics Wiki
Revision as of 01:29, 6 September 2024 by RetroTypes (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
#Parameters:
    #r4 = map ID
    #r5 = trap type
    #r6 = activation type
        0 = trap
        1 = item

#Returns:
    #r2 = activation outcome
        0 = no item found or no trap activated
        1 = item found or trap activated


001804c4: 000417c2 srl r2,r4,0x1f
001804c8: 00821021 addu r2,r4,r2
001804cc: 00023843 sra r7,r2,0x01			#r7 = (map ID) / 2 ?
001804d0: 30840001 andi r4,r4,0x0001
001804d4: 00042080 sll r4,r4,0x02
001804d8: 00852021 addu r4,r4,r5			#r4 = ((mapID % 2) * 4) + trap type
001804dc: 34020080 ori r2,r0,0x0080
001804e0: 10c0000b beq r6,r0,0x00180510		#branch if trap
001804e4: 00822007 srav r4,r2,r4

item?
001804e8: 3c018006 lui r1,0x8006
001804ec: 00270821 addu r1,r1,r7
001804f0: 90239414 lbu r3,-0x6bec(r1)			#load move find item flags for map
001804f4: 00000000 nop
001804f8: 00831825 or r3,r4,r3				#combine map flags with updated flags
001804fc: 3c018006 lui r1,0x8006
00180500: 00270821 addu r1,r1,r7
00180504: a0239414 sb r3,-0x6bec(r1)			#store new move find item flags for map
00180508: 0806014a j 0x00180528			#jump to End
0018050c: 34020001 ori r2,r0,0x0001			#return r2 = 1

trap?
00180510: 3c018006 lui r1,0x8006
00180514: 00270821 addu r1,r1,r7
00180518: 90229414 lbu r2,-0x6bec(r1)			#load move find item flags
0018051c: 00000000 nop
00180520: 00441024 and r2,r2,r4				#compare map flags with updated flags
00180524: 2c420001 sltiu r2,r2,0x0001			#reverse flags (if item has been found, trap activates)

End:
00180528: 03e00008 jr r31
0018052c: 00000000 nop

Return Locations

001802a0: Rare/common item determination
001803e0: Set map Item/trap data