I'm sorry your
betta isn't feeling well.
Do you know what his water parameters are?
It's hard to guess what could be wrong with him. Is he bloating? pooing regularly?
Has his water been at a warm consistant temp?
At this point, all you can do is watch him. Possibly try some different foods. Add a little extra stress coat, Vita-chem and garlic guard. All good things for your betta.
Two years is getting pretty old for a better especially if he was a cup baby. It's possible he's just slowing down in his older years.
Good luck, I hope he feels better soon.