#7055 - Darkain - Sat Jun 07, 2003 10:54 am
ok, so i spent most of the night trying to figure out how i broke the emulators, yet still got this stuff to work on hardware..
basically, what i was trying to ocomplish was this:
i wanted to halt the CPU (put it into power saving mode), until an interupt occured. i was trying to use both keyboard and vblank interupts at the same time.
so, in my IRQ handler, i first checked to see if it was vblank, and processed if needed. then, i checked to see if keys where pressed, and processes as needed. but... there was a problem. the code for checking for key input was NEVER called when running on emulators (Mappy worked, but all others failed). the code, however, worked on the actual GBA.
after hours of searching, and chatting w/ peoples on IRC, we finally solved the problem. it turns out that the emulators will call the interupt for key input the exact same time it will call the vsync interupt. this within itself wasnt a problem.
next, at the end of my vsenc code, i had it remove the vsync flag from REG_IF, as documented. im not sure why of this, but apparently, it sets the entire value to 0, not just the flag. therefor, on the very next line of code, where it checked to see if key input interupt occured, it would fail.
after find this out, i was then informed that apparently crt0 will set all of the REG_IF flags after an interupt for me. so i removed ever call to setting one of its flags to erase it.
also, i learned that the emulators (except for mappy) call the key input irq at the same exact time it calls the vsync irq. therefor, checking for == failes (tho i already wasnt), but at the same time, other problems may arise, and therefor extra checks need to be made.
the difference why it works on hardware is because the GBA will call the key input IRQ at the very moment a key is pressed, NOT check to see if there should be an IRQ when a vblank occures.
so, all n all, this was an "interesting" learning experince for me, and i thought i would just share it with others, so they dont try to make the smae mistake w/ their irq handlers.
thanx to all the peeps online that helped out! ya saved me on a huge headache!!! :)
(i still think this would be neato as an extra layer of copy-protection for commercial games, but if a company where to do that, i would ask em nicely to please donate $$$ to this site)
_________________
-=- Darkain Dragoon -=-
http://www.darkain.com
DarkStar for Nintendo DS
basically, what i was trying to ocomplish was this:
i wanted to halt the CPU (put it into power saving mode), until an interupt occured. i was trying to use both keyboard and vblank interupts at the same time.
so, in my IRQ handler, i first checked to see if it was vblank, and processed if needed. then, i checked to see if keys where pressed, and processes as needed. but... there was a problem. the code for checking for key input was NEVER called when running on emulators (Mappy worked, but all others failed). the code, however, worked on the actual GBA.
after hours of searching, and chatting w/ peoples on IRC, we finally solved the problem. it turns out that the emulators will call the interupt for key input the exact same time it will call the vsync interupt. this within itself wasnt a problem.
next, at the end of my vsenc code, i had it remove the vsync flag from REG_IF, as documented. im not sure why of this, but apparently, it sets the entire value to 0, not just the flag. therefor, on the very next line of code, where it checked to see if key input interupt occured, it would fail.
after find this out, i was then informed that apparently crt0 will set all of the REG_IF flags after an interupt for me. so i removed ever call to setting one of its flags to erase it.
also, i learned that the emulators (except for mappy) call the key input irq at the same exact time it calls the vsync irq. therefor, checking for == failes (tho i already wasnt), but at the same time, other problems may arise, and therefor extra checks need to be made.
the difference why it works on hardware is because the GBA will call the key input IRQ at the very moment a key is pressed, NOT check to see if there should be an IRQ when a vblank occures.
so, all n all, this was an "interesting" learning experince for me, and i thought i would just share it with others, so they dont try to make the smae mistake w/ their irq handlers.
thanx to all the peeps online that helped out! ya saved me on a huge headache!!! :)
(i still think this would be neato as an extra layer of copy-protection for commercial games, but if a company where to do that, i would ask em nicely to please donate $$$ to this site)
_________________
-=- Darkain Dragoon -=-
http://www.darkain.com
DarkStar for Nintendo DS