There is plenty of evidence to support the idea that Hamlet is both grieving and laboring under extreme stress, but not "mad."
In Act IV, Scene 2, Hamlet uses a pointed metaphor with Rosencrantz and Guildenstern. He recognizes their duplicity and how they are being used by Claudius and calls them sponges; when Rosencrantz objects, Hamlet answers:
"Ay, sir, that soaks up the king's countenance, his rewards, his authorities. But such officers do the king best service in the end: he keeps them, like an ape, in the corner of his jaw; first mouthed, to be last swallowed: when he needs what you have gleaned, it is but squeezing you, and, sponge, you shall be dry again."
He spells out for them very clearly how they will be discarded when Claudius gets what he wants from them.
In Scene 3, Hamlet takes on Claudius with some very tricky wordplay. When he is asked where Polonius is, he responds, "at supper", and further elaborates:
"Not where he...
(The entire section contains 2 answers and 513 words.)