Im not sure if this is the code i had years and years ago but i did put some code into the c64 years ago that did a similar thing but the big bonus was when i used the code ran it in my bedroom and turned off the lights so it was dark and no joke it was like a stobe light disco effect!! :)
Obviously im not going to be able to get the same effect from the size of the DS screen but thanks for jogging my memory a little gho. ;)