I have a spreadsheet I used to generate these - needs some tweaks to generate the code automatically, but most of the stuff needed is there.