I was stepping through the code of Pokemon Sapphire and I was especially
interested in what Game Freak's interrupt routine looked like. It turns
out that it looks almost exactly like the multiple interrupts routine with
user stack switching and cart interrupt handling that is in Jeff's crtls.
It looked like only the order (i.e. priority) of the interrupts was
changed.
So, I checked Super Mario Advance. Same code (except the priorities).
Now I'm starting to worry. People are so nervous about including
Nintendo's logo data, but disassembling code and distributing it is
apparently just fine.
Interesting things to note. I cannot find evidence that either game
copies its ISR to ram, yet they both attempt to handle the cart interrupt
by going into an infinite loop. This won't happen because the cart will
be gone. Pokemon makes an additional mistake of making the cart interrupt
the lowest priority, which would intermittently fail (Mario makes it top
priority). Maybe they do copy their ISR's to RAM, but the interrupt
vector is set to its load address in ROM instead of its VMA.
Anyway, I am wondering if this is all just an amazing coincidence, or did
someone copy nintendo's code?
I was stepping through the code of Pokemon Sapphire and I was especially interested in what Game Freak's interrupt routine looked like. It turns out that it...
Jason Wilkins
fenix@...
May 1, 2003 7:31 pm
... And I keep reassuring them that after Sega v. Accolade, people who include logo data have nothing to worry about. ... If there's only one efficient way to...
... I believe this too, but if Nintendo took you to court, it would be a huge hassle to get in front of a judge and tell Nintendo how mistaken it is. ... I...
Jason Wilkins
fenix@...
May 1, 2003 10:35 pm
I'd be more willing to bet they used Jeff's code and modified it. Since it is a nice generic place to start. Kurt...
... I wouldn't, Super Mario Advance was a launch title. The interrupt handling in crtls was not added until months later, if I recall correctly. (at least, i...
Jason Wilkins
fenix@...
May 1, 2003 9:21 pm
I was able to confirm that the interrupt code in crtls is indeed copied from Nintendo's very own 'reintr' sample program which demonstrates handling multiple...
Jason Wilkins
fenix@...
May 1, 2003 10:35 pm
... Many developers make/made the same mistake. I only handle the cart interrupt correctly in my most recent projects (i.e.: ISR in (IW)RAM and cart interrupt...
Jan-Lieuwe Koopmans
jan-lieuwe@...
May 1, 2003 8:52 pm
... I found a bug in Wind Waker. Lost 2 hours of game time ^_^ Be careful you do not fall off a ledge at the same time that you get mail from a post box. ... ...
Jason Wilkins
fenix@...
May 1, 2003 10:07 pm
... Ever played "Golden Sun"? If you pak-swap from GS1 to GS2, it's rumored that you can keep your characters. "Banjo-Tooie" for N64 initially was going to...
... I actually thought of a feature like this, but I didn't mention it because that is not what these games are trying to do. After doing some more...
Jason Wilkins
fenix@...
May 2, 2003 1:31 pm
So just to make sure I'm upto to date: Proper card interrupt handling: Copy your isr(interrupt service routine) to iwram/ewram Handle the card interrupt at...
From: "Willem Kokke" <wkokke@...> ... Looks ok. ... ... or whatever you think is appropriate ! I wonder if it would be feasible to just say "Please...
Jonathan Perret
jonathan.perret@...
May 2, 2003 11:49 am
... I have not read the documentation, but I never thought about if another IRQ is generated when the cart, or a different cart, is inserted. I guess that it...
Jason Wilkins
fenix@...
May 2, 2003 1:48 pm
... It's not limited to just the first 4 KB; witness 'mb -p' that can dump all 32 MB of a cartridge over the MBV2 cable. ... Read the header at 0x08000000...
... I don't even think that the emulators support emulation of flash cartridges yet. Considering that many of use write software for people with flash carts,...
Jason Wilkins
fenix@...
May 2, 2003 7:20 pm
Hmm, would be interesting.. Does anybody know wheter you can distinguish between a insert card and remove cart interrupt?? What happens when you try to read...
... there's no need to handle game pak interrupt at highest priority. only one interrupt is handled per entry to the main ISR (for most usual setups), so ...
... I think I see what you mean. If you have multiple interrupts enabled like how Nintendo has demonstrated, then a "lower priority" interrupt will still...
Jason Wilkins
fenix@...
May 2, 2003 2:50 pm
From: "Damian Yerrick" <d_yerrick@...> ... I've been wondering about that. The specs (e.g. gbatek) explicitly say that most of the cart ROM is locked...
Jonathan Perret
jonathan.perret@...
May 2, 2003 5:36 pm
... oops... I meant 'mb -1'. It's -1 to read a cart and -p to write. ... Perhaps Nintendo wrote that in the spec but didn't put it in the first generation...
From: "Jason Wilkins" <fenix@...> ... if you're handling a higher priority (in terms of its order in the branch table in the dispatch routine) interrupt,...
... Actually, it is. The IME is saved, and then set at the beginning of the ISR. Interrupts are still disabled in the CPSR, so interrupts are still disabled...
Jason Wilkins
fenix@...
May 4, 2003 12:31 pm
FYI People were talking about the cart removed interrupt. Well, be sure you disable DMA, or probably better yet, set the audio volume to zero in the loop while...
Mike Schwartz
mykes@...
May 4, 2003 5:02 pm
... more ... DMA ... a ... additional ... Yes, that's a good question IMHO. In a non-embedded OS it is generally considered very bad practice to have...
Jonathan Perret
jonathan.perret@...
May 5, 2003 1:00 pm
... Now, of course the issues are not the same on the GBA; if there's just one handler that occasionnally needs more time to do its work perhaps it's not...
... The multiple interrupt code in my crt0.S is nearly identical to Nintendo code as a result of my "review" :-) of N examples. However, I made small changes...
... interrupt handler Well, I guess, although it seems to be more of a 'timed request processor'. ... return immediately to the BIOS while user control returns...
... Part of the point I was trying to make is that switching the CPU back into System mode to execute the handler, then returning to IRQ mode just before...
Jonathan Perret
jonathan.perret@...
May 7, 2003 3:29 pm
Okay you guys have sucked me into this. My limited understanding of how ARM sees the world is the same or similar to where some of these ideas are headed. I...