Hi, I have an interesting problem with my Arduino Mega, it seems the hardware definitions for pins point to the wrong place.
For example, trying to read or write to pins 0, 1, 2, 3 actually points to pins 21, 20, 19, 18 (in this order), A0 points to A14...
Direct port manipulation works perfectly for reading and writing on all pins so I really don't understand this issue.
This board has had a different firmware at some point, Hoodloader, but it was having this exact problem so I used Arduino as ISP to burn the original firmware through the IDE so it has that now, but the problem persists.
That is very strange. It isn't likely a hardware error since Direct Register access works expected. My best guess would be something has gone very wrong with your Arduino install. I would re-install.