;;; Enemy_CountEnemiesByID ;;; ;; Parameters: ;; r0: EnemyID ;; Returns r0: Number of matching enemies 08012858 (T) push r4-r6,r14 0801285A (T) lsl r0,r0,18h ;\ 0801285C (T) lsr r5,r0,18h ;} r5 = r0 parameter 0801285E (T) mov r4,0h ; r4 = counter 08012860 (T) mov r3,0h ; r3 = loop iteration 08012862 (T) ldr r6,=EnemySlot0 ; r6 = EnemySlot0 (r2 = EnemySlot[r3]) 08012864 (T) lsl r0,r3,3h ;\ 08012866 (T) sub r0,r0,r3 ;| 08012868 (T) lsl r0,r0,3h ;| 0801286A (T) add r2,r0,r6 ;| 0801286C (T) ldrh r1,[r2] ;} If Enemy[r3]Orientation has 01h: 0801286E (T) mov r0,1h ;| 08012870 (T) and r0,r1 ;| 08012872 (T) cmp r0,0h ;| 08012874 (T) beq 8012890h ;/ 08012876 (T) mov r0,r2 ;\ 08012878 (T) add r0,34h ;| 0801287A (T) ldrb r1,[r0] ;| 0801287C (T) mov r0,80h ;} If Enemy[r3]CollisionProperties has 80h: 0801287E (T) and r0,r1 ;| 08012880 (T) cmp r0,0h ;| 08012882 (T) beq 8012890h ;/ 08012884 (T) ldrb r0,[r2,1Dh] ;\ 08012886 (T) cmp r0,r5 ;} If Enemy[r3]ID == r0 parameter: 08012888 (T) bne 8012890h ;/ 0801288A (T) add r0,r4,1 ;\ 0801288C (T) lsl r0,r0,18h ;} Increment r4 0801288E (T) lsr r4,r0,18h ;/ 08012890 (T) add r0,r3,1 ;\ 08012892 (T) lsl r0,r0,18h ;} Increment r3 08012894 (T) lsr r3,r0,18h ;/ 08012896 (T) cmp r3,17h ;\ 08012898 (T) bls 8012864h ;} If r3 > 17: 0801289A (T) mov r0,r4 ; Return = r4 0801289C (T) pop r4-r6 0801289E (T) pop r1 080128A0 (T) bx r1 080128A2 dw 00000h 080128A4 dd 003000140h