>>48618064>>48618128>>48618152Shiny Pokemon in Gen 2 worked by giving each Pokemon a separate palette file to read off of when shiny. It's manually picked; certain mons with identical normal palettes like Squirtle and Wartortle have different shiny colors.
Gen 3 makes the frontsprites normal palette, and backsprites shiny palette. When a Pokemon is normal, it'll use the front palette, while if shiny, it'll use the back palette. Not sure how it goes from 4 onwards but I know at least since the beginning they weren't algorithmically generated. It's also why ROMhacks are able to get proper shiny palettes for custom mons, whether it be later gen backports or flat out fakemons.