Functions

From Twilight Princess Wiki
Jump to navigation Jump to search

createItemForBoss[edit | edit source]

Info

  • Offset (NTSC): 8001c0d4
  • r3 = actor id
  • r4 = item id (crash if mismatch)

Assembly

8001c0d4	stwu	sp, -0x0020 (sp)			
8001c0d8	mflr	r0			                // Loads an address from the link register to r0
8001c0dc	stw	r0, 0x0024 (sp)			        // stores the word from r0 to *(&sp + 0x24)
8001c0e0	stfd	f31, 0x0018 (sp)			// stores 32bit Float from f31 to *(&sp + 0x18)
8001c0e4	stfd	f30, 0x0010 (sp)			// stores 32bit Float from f30 to *(&sp + 0x10)
8001c0e8	mr	r12, r3		                	// r12 = r3
8001c0ec	mr	r11, r5	                		// r11 = r5
8001c0f0	mr	r10, r6	                		// r10 = r6
8001c0f4	mr	r9, r7		                	// r9 = r7
8001c0f8	fmr	f30, f1	                		// f30 = f1
8001c0fc	fmr	f31, f2	                		// f31 = f2
8001c100	li	r0, 0	                		// r0 = 0
8001c104	stw	r0, 0x0008 (sp)	                // r0 = *(&sp + 0x8)
8001c108	li	r3, 539	                		// r3 = 539; 539 = Actor for HC/HP
8001c10c	rlwinm	r0, r8, 8, 0, 23 (00ffffff) // r0 = ((r8 << 8) & 0x00FFFFFF)???
8001c110	oris	r5, r0, 0xFFFF	            // r5 = ((r0 >> 16) | 0xFFFF) ???
8001c114	rlwinm	r0, r4, 0, 24, 31 (000000ff)// r0 = ((r4 << 0) & 0x000000FF)???
8001c118	or	r4, r5, r0		            	// r4 = (r5 | r0)
8001c11c	mr	r5, r12			                // r5 = r12
8001c120	mr	r6, r11		               	    // r6 = r11
8001c124	mr	r7, r10		                 	// r7 = r10
8001c128	mr	r8, r9		            	    // r8 = r9
8001c12c	li	r9, -1			                // r9 = -1
8001c130	li	r10, 0			                // r10 = 0
8001c134	bl	->0x80019E04 -> fastCreate		// calls actual item create function
8001c138	cmplwi	r3, 0			            // c3 = compare(0x0 with r0)
8001c13c	beq-	->0x8001C148 ►	↓		    // branch if equal (if r0 == 0)
8001c140	stfs	f30, 0x052C (r3)↓			// f30 = *(&r3 + 0x52C)
8001c144	stfs	f31, 0x04FC (r3)↓	 		// f31 = *(&r3 + 0x4FC)
8001c148	cmplwi	r3, 0	◄	   ◄            // c3 = compare(0x0 with r0)
8001c14c	beq-	->0x8001C158 ►►►►►► ↓	    // branch if equal (if r0 == 0)
8001c150	lwz	r3, 0x0004 (r3)		 	↓       // r3 = *(&r3 + 0x4) then r3 = 0
8001c154	b	->0x8001C15C ►	↓	 	↓       // goto 8001C15C
8001c158	li	r3, -1	 	◄◄◄ ↓ ◄◄◄◄◄◄        // r3 = -1
8001c15c	lfd	f31, 0x0018 (sp)◄   		    // Loads *(&sp + 0x18) to f31
8001c160	lfd	f30, 0x0010 (sp)			    // Loads *(&sp + 0x10) to f30
8001c164	lwz	r0, 0x0024 (sp)			        // Loads *(&sp + 0x24) to r0
8001c168	mtlr	r0			                // mtlr = r0 (r0 being Pointer/Address for next function)
8001c16c	addi	sp, sp, 32			        // sp += 32
8001c170	blr				                    // returns contents of the Link Register (note: mtlr = r0)