Emotion-driven Piano Music Generation via Two-stage Disentanglement and Functional Representation