As far as contribution of drives from the sub-cortical structures:
My take is that the old brain structures are configured to work somewhat like a Hopfield or Boltzmann network with each of the nodes being one of the basic behavior states like feeding, fleeing, fighting, mating, seeking shelter, sleeping, drinking, exploring, grooming, nesting, whatever else you can think of.
The various body sensors are inputs to this tipping the current state to whatever has the strongest input.
The sensory system has memory associated with it that registers the elements of…
I have been addressing various aspects of the interplay between the subcortical structures and the cortex for a long time. This post collects pointers to some of the key ideas:
My take on this is that much of the heavy lifting here is done in evolutionary older brain stem structures where the basic animal behaviour is shaped by the much smarter cortex. Call them instincts if it helps.
I have some prior posts that may help you get started on sorting this out: