The code is quite bad because it doesn't restore the DMACON settings properly. Correct way to do it is like this:
- store current DMACON settings (read register DMACONR, $dff002) so you can
- write this value back to DMACON ($dff096) upon exit (don't forget to set BIT #15 (SET/CLR) before)
I don't give any code example because it is a good exercise for you to do it yourself.