;;; Enemy_WithinRange ;;; ;; Parameters: ;; r0: Vertical range ;; r1: Horizontal range in front ;; r2: Horizontal range behind ;; Returns r0: 0 if out of range, 3 if in front range, Ch if in behind range 08011BE4 (T) push r4-r7,r14 08011BE6 (T) mov r7,r9 08011BE8 (T) mov r6,r8 08011BEA (T) push r6,r7 08011BEC (T) lsl r0,r0,10h ;\ 08011BEE (T) lsr r7,r0,10h ;} r7 = r0 parameter 08011BF0 (T) lsl r1,r1,10h ;\ 08011BF2 (T) lsr r1,r1,10h ;} r9 = r1 parameter 08011BF4 (T) mov r9,r1 ;/ 08011BF6 (T) lsl r2,r2,10h ;\ 08011BF8 (T) lsr r2,r2,10h ;} r8 = r2 parameter 08011BFA (T) mov r8,r2 ;/ 08011BFC (T) mov r0,0h ;\ 08011BFE (T) mov r12,r0 ;} r12 = return value (default 0) 08011C00 (T) mov r6,0h ; Which direction enemy is facing (default left) 08011C02 (T) ldr r2,=SamusData ;\ 08011C04 (T) mov r1,26h ;| 08011C06 (T) ldsh r0,[r2,r1] ;| 08011C08 (T) lsr r1,r0,1Fh ;| 08011C0A (T) add r0,r0,r1 ;| 08011C0C (T) asr r0,r0,1h ;| 08011C0E (T) ldrh r1,[r2,18h] ;| 08011C10 (T) add r0,r0,r1 ;| 08011C12 (T) lsl r0,r0,10h ;| 08011C14 (T) lsr r3,r0,10h ;| 08011C16 (T) ldrh r5,[r2,16h] ; r5 = XPosition 08011C18 (T) ldr r0,=EnemyOrientation ;| 08011C1A (T) ldrh r2,[r0,2h] ;} If |EnemyYPosition - YPosition + TopBoundryOffset(1+sgn)/2| >= r0 parameter 08011C1C (T) ldrh r4,[r0,4h] ; r4 = EnemyXPosition 08011C1E (T) mov r1,r0 ;| 08011C20 (T) cmp r2,r3 ;| 08011C22 (T) bls 8011C30h ;| 08011C24 (T) sub r0,r2,r3 ;| 08011C26 (T) b 8011C32h ;| 08011C28 dd 003001244h,0030006BCh ;| ;| 08011C30 (T) sub r0,r3,r2 ;| ;| 08011C32 (T) cmp r0,r7 ;| 08011C34 (T) blt 8011C3Ah ;/ 08011C36 (T) mov r0,0h ;\ 08011C38 (T) b 8011C80h ;} Return 0 08011C3A (T) ldrh r1,[r1] ;\ 08011C3C (T) mov r0,40h ;| 08011C3E (T) and r0,r1 ;} If EnemyOrientation has 40h (facing right) 08011C40 (T) cmp r0,0h ;| 08011C42 (T) beq 8011C46h ;/ 08011C44 (T) mov r6,1h ; r6 = 1 (facing right) 08011C46 (T) cmp r4,r5 ;\ 08011C48 (T) bls 8011C64h ;} If EnemyXPosition > XPosition: 08011C4A (T) cmp r6,0h ;\ 08011C4C (T) beq 8011C5Ah ;} If r6 != 0 (facing right): 08011C4E (T) sub r0,r4,r5 ;\ 08011C50 (T) cmp r0,r8 ;} If EnemyXPosition-XPosition >= r2 parameter: return 08011C52 (T) bge 8011C7Eh ;/ 08011C54 (T) mov r0,0Ch ;\ 08011C56 (T) mov r12,r0 ;} Return Ch 08011C58 (T) b 8011C7Eh ;/ 08011C5A (T) sub r0,r4,r5 ;\ r6 == 0 (facing left): 08011C5C (T) cmp r0,r9 ;} If EnemyXPosition-XPosition >= r1 parameter: return 08011C5E (T) bge 8011C7Eh ;/ 08011C60 (T) mov r1,3h ;\ 08011C62 (T) b 8011C7Ch ;} Return 3 08011C64 (T) cmp r6,0h ;\ EnemyXPosition <= XPosition: 08011C66 (T) beq 8011C74h ;} If r6 != 0 (facing right): 08011C68 (T) sub r0,r5,r4 ;\ 08011C6A (T) cmp r0,r9 ;} If XPosition-EnemyXPosition >= r1 parameter: return 08011C6C (T) bge 8011C7Eh ;/ 08011C6E (T) mov r0,3h ;\ 08011C70 (T) mov r12,r0 ;} Return 3 08011C72 (T) b 8011C7Eh ;/ 08011C74 (T) sub r0,r5,r4 ;\ r6 == 0 (facing left): 08011C76 (T) cmp r0,r8 ;} If XPosition-EnemyXPosition >= r2 parameter: return 08011C78 (T) bge 8011C7Eh ;/ 08011C7A (T) mov r1,0Ch ; Return Ch 08011C7C (T) mov r12,r1 08011C7E (T) mov r0,r12 08011C80 (T) pop r3,r4 08011C82 (T) mov r8,r3 08011C84 (T) mov r9,r4 08011C86 (T) pop r4-r7 08011C88 (T) pop r1 08011C8A (T) bx r1