How does the valve gear on Puffing Billy work?

This is something that's been bugging me for some time now. I know Era 1 locomotives didn't have any kind of standard valve gear, since before the Stephenson engines like Planet, it was all new and experimental territory.

https://preview.redd.it/18jpsewfbgpe1.png?width=418&format=png&auto=webp&s=cae8d1c17ad68c576643875d1722afd3b8089100

Looking at Puffing BIlly, I can see where the piston beams connect the up and down motion of the cylinders into rotational movement through gears between the frames. This is highlighted in green. What I'm not understanding is this forest of connecting rods between what I'm guessing is primitive valve gear. I know there would be no cutoff at this point in history, so it's literally all about timing the admission of steam to ensure it moves in the correct direction of travel.

What's confusing me is how it connects together, and how these connections do the job they're made for. Is there anyone here more knowledgeable on Era 1 steam locomotive engineering that can help me figure it out?