A good chunk of the peripherals are implemented in mame/audio/leland.c. Using that as a starting point would be a good idea.
That code looks very like the code in the mess compis driver, which I saw after posting my original query. I used that as a base.