I am heading for work now. So not much time.

You need to symbol portA and portB to there locations.
Then peek portA (say into B0), do any logic on it
Then poke portB with your results from B0.

What happened if two PIRs are tripped? Do you have a priority for them?
You will probably want to make sure there is only one bit set in B0 otherwise
you will have two or more relays flip on (multiple video coming in).

If this does not help, later I will see if I can send a sample. Just running late right now.