This question came up in the Online 10-day Retreat Nov 3, 2020, guided by Delson Armstrong. Day 6 was part of a daily 30-minute discussion on the suttas, the Dhamma talk and reflections.
Slightly edited to improve readability
In the case of rebirth on the macro level, one consciousness links into another Mentality-Materiality at the point of death, in the very deep layers of mind. You might have heard of people who have had near-death experiences. This happens in the mind, in the mentality of the Mentality-Materiality. The Formations are arising and produce these experiences, and then that consciousness attaches to it through clinging, identifying, and craving and that happens with intention.
When one is experiencing death, there will be memories that arise, there will be other images that arise, and these are all different Formations coming to fruition. These are coming into the mind’s eye if you will. If any part of the mind attaches craving to it, attaches that sense of ignorance that there is a self here, then through intention of attaching to that Formation, there arises a new consciousness that spontaneously links with a new Mentality-Materiality at the point of conception. Then, that consciousness drives forward all the Formations that it attaches to. So, those Formations will be at the foreground of that birth. It will manifest in the form of a birth related to those kinds of Formations.
Which is why, when someone is dying, it is important to keep them in a state of comfort, in a state of good feelings and good Formations, and good thoughts and experiences, because that can relate to a better rebirth, or better circumstances.
Having said that, it does not mean certain Formations, related to negative experiences or negative Kamma, will not come to fruition. They will still manifest, even if you have a ‘positive’ birth or better circumstances.
And on the flip side, if you are in a negative situation and you have a negative rebirth, so to speak, there will still be the seeds of the positive Formations that will still take root through the experiences that you have.
It is not necessarily completely black and white, but to simplify; when at the point of death, you see these experiences, if there is clinging to them, if there is attachment to them, if there’s identification to them, the intention to attach to them drives forward the consciousness and transfers all those Formations and links spontaneously through that process of rebirth, to a new Mentality-Materiality at the point of conception. That creates the rest of the links of Dependent Origination on the macro level, to where there is a being, in the case of a human birth, that gets born [arises in the womb] and their consciousness dissipates and then more consciousnesses arise within the development of that fetus in the womb. And then of course, the physical birth happens for that being.