Figured out the palette. Turns out setting palette entries works better _after_ you switch video modes. 😑 Porting the scaler has also gone well, minus one issue with signed indexes. But this pretty much only works because I've cranked the emulation speed up on DOSBox so it can draw everything in vblank.
I have realized to my horror that VGA doesn't do a 320x200x256 linear framebuffer graphics mode where you can flip pages. Mode 13h utilizes all four planes in "chain mode", so the one page of linear framebuffer is all you get. If you want page flipping, you have to modify this to a sort of interleaved planar mode where every fourth column of pixels lives in a plane. And to switch which plane you're writing to you have to twiddle some VGA registers, which are themselves abstracted behind address/data I/O port pairs. I knew the PC platform was a pile of bad hacks but I am still somewhat aghast that people put up with this. The good news is, this gives you some interesting data pathway tricks you can use to perform faster fills and copies. Which will probably be quite useful, actually.
So now I get to completely rewrite this...