Therefore, I assume that, when pistons 1 and 4 are at the top, one of them is compressing the fuel air mixture for combustion and one of them is releasing the exaust gasses?
Yes, and to determine which is which, you need to look at the position of the camshaft.
On one cylinder, in this position, both valves will be shut as it prepares to fire. On the other cylinder, the exhaust valve will be closing and the inlet valve will be opening as you're at the end of the exhaust stroke and the beginning of the next induction stroke.
If you think about the distributor, it's driven by the camshaft, so it "knows" which cylinder will fire next. If the ECU doesn't have a cam sensor, it doesn't, and this is how wasted spark systems work. They don't need to know.
Put a cam sensor on, and the ECU has all the information that is available to a distributor, so it can inject fuel to whichever cylinder has its' inlet valve open, instead of injecting onto an closed inlet valve on some of the cylinders. It can also control an individual spark to that cylinder instead of a spark to both cylinders in the pair.
The main timing reference is always taken from the crankshaft, however, because the cam shaft is connected to it through a belt or chain which has a little bit (a few degrees) of slop. This is a big advantage over having the timing reference from a distributor. Timing can be controlled much more accurately with a crank sensor.
Kevin