Hi Cap,
Reading Patrick O'Brien, and back in Aubrey's day, they'd have "fired on the roll" ... which isn't a nice thing to do to bakery products, but there you go...

Gyro-stabilised guns? Like the things modern tanks have?
I don't think it can be as simple as a one-pot-shop. For example, if the turret's trained to port, the movement of the barrel will have to be the inverse of when it's trained starboard, for any given angle of roll. And if you were to take pitch into consideration, then you'd need two-axis calculations, plus info on which angle the turret's trained, before you could generate a figure for a suitable "level".
But it gets worse: once the turret axis
is off vertical, and if the ship is rolling, pitching and yawing, then you
can calculate a gun angle which will remain locked on a particular vector, but it'll be having to train and elevate/depress constantly in order to do so - and you'd best be in the world of <gulp> quaternions.

A not-very-brief aside (and apologies to all if this is stuff you know) -
Back when NASA did proper manned stuff in space, rather than just ferry toilets the eight minutes to low Earth orbit, there was a thing called gimbal lock. It makes an appearance in the film Apollo 13. When the axes of a gyro line up, the gyro's information becomes useless. Your heading information is lost. That's gimbal lock, and it's best avoided if you want to fire a thruster with any idea of where you'll end up.
Because modern jet aircraft and smart ordinance can end up at any old angle, and we have computers that can do impressive sums in real time, there was a move towards using quaternions - which do not suffer a mathematical version of gimbal lock. These were invented around the end of the 19th century for no reason whatsoever, and lie quite squarely in the "insane" area of mathematics. But with them, you can happily add or subtract any angles you like from a start position and rest safe in the knowledge that the final angle is "correct".
I got an A-level in Maths back in 1981 (and by 'eck it were tough back in my day) and I use maths everyday in my work. I needed to use quaternions for some 3d animation modelling I was working on a year or so ago. Now, maybe it's my age, but it took me a good fortnight to begin to get my head around what was happening in the calculations, and I had to assume the use of the square root of minus one had any "reality" (they appear in quaternions), and finally FINALLY! got the model working.
Within
a day of writing the script, little of the maths made sense. I had to just accept it. A month later and it was like looking at ancient Mayan. Today I've returned to the blissful ignorance of not understanding them any more. Have you ever read any H.P.Lovecraft?
That's quaternions.
In conclusion -
Gun stabilisation would look extremely cool for modern single-gunned frigates and the like, cutting speedy S-curves and rolling in the bends. But it's a can of worms I'd approach with extreme care! (And wouldn't gyro-controlled stabilisers be better - a one-axis, and therefore considerably easier & more practical application?)
Andy, fitting gunwales to the 42' sailing launch...