I'm a full-stack dev with 8 years experience mostly in startups. I was diagnosed about 5 years ago (at 32 years old), started on methylphenidate and moved to amphetamines 2 years ago. I've worked with legacy code very briefly and early on, and that experience is what made me want to seek out startups/new companies. That being said, I still come across convoluted spaghetti code or deeply nested UI components. I feel like it takes me a lot longer than my peers to gain a general understanding of what's going on, exactly as you describe. I keep a pen and notebook beside my keyboard at all times and in these situations I write/draw the structural heirarchy, logic flow, etc. While it takes me longer, I feel like my standard for "baseline" understanding is much higher and when I reach it, I have more understanding about the code in question than my peers.
...then I forget it after a week or so ๐
But really, writing/diagramming things really helps me. If physical writing isn't your thing you could try something like lucidchart or mermaid diagrams.
It's hard to objectively answer the question given it's one of my favorites and the nostalgia clouds my judgement.
I'll sometimes put this or A Link to the Past on in the background while I work, or just put Aquatic Ambience on loop ๐
(I do the same with the Morrowind soundtrack but that's for another community lol)