The drive to Yellowstone from Cody is about one hour just to the entrance. Then you have to plan on about another hour drive to get anywhere within the park. Add on the drive back to Cody and you can see why Cody is not a good home base for Yellowstone. However I recommend a stay in Cody just to visit the Buffalo Bill Historical Center. Just the gun museum portion of the Center alone will take a full day. Then you can move on to yellowstone and stay in the park for your visit there.
x3 (or more) Remember, given terrain, 2 lanes with other tourists ont he roads, wildlife, and speed limits, you won't be driving 50 miles in 50 minutes, or anything even close to that. If you want to basecamp outside Yellowstone for visiting the park, I strongly recommend West Yellowstone or Gardiner (North entrance) or Colter Bay area for South entrance, instead.
And yes, the Buffalo Bill Museum is a definite must!