Hi bieb,
If you're entitled to a discount, it's cheaper to book your domestic flights before you leave - the discount is then 50%. If you book your flights within Madagascar, you get only 40% on that part of the fare which is not tax - i.e. they deduct the tax, reduce what's left by 40% and then add the unreduced tax back on, so that the net discount is quite a bit less than 40%.
The big question is, do you get a discount at all? In Air Mad's terms, Johannesburg is a regional and not a long-haul flight, and so doesn't qualify you. Posters on this forum have reported mixed success - some have said they got the discount when flying in from Jo'burg, others - myself included - have been refused it. You'll need to talk to the Air Mad agency in Jo'burg and/or the various Air Mad offices in country and plead with them.
One way to reduce costs if you're intending to do a two-leg journey involving a change of flight in Tana is to select flights that allow you to do the whole journey same day without a stopover in Tana and ask for a through ticket - Air Mad's staff won't always automatically tell you about this, but it can bring really big savings with or without the long-haul discount.
For example, I flew from Maroantsetra to Mahajanga via Tana for the same price as it would have cost me from Maroantsetra to Tana. The return trip cost double that because the timetabling meant I wasn't able to complete both legs on the same day.