Posted: Sun Apr 04, 2010 11:15 am
Maybe run a cycle counter routine to tell whether it's running on NTSC or PAL (or even Dendy).
Sounds intriguing - is there example code of this technique available?Dwedit wrote:Maybe run a cycle counter routine to tell whether it's running on NTSC or PAL (or even Dendy).
Code: Select all
clc
loop:
lda counter+0 ;3
adc #1 ;2
sta counter+0 ;3
lda counter+1 ;3
adc #0 ;2
sta counter+1 ;3
lda giveup ;3
beq loop ;3
The simplest way I know of to detect NTSC vs PAL is having your NMI wait, say, 22 scanlines (NTSC Vblank has 20 scanlines, PAL has way more) as soon as it fires, and then check $2002. If the Vblank flag is set, it's a PAL console.neilbaldwin wrote:Sounds intriguing - is there example code of this technique available?
The vblank signaling in the NES PPU has a race condition bug. If you try to read vblank status out of PPUSTATUS ($2002), you'll miss even more vblanks than you would with an NMI handler. I think that's why Dwedit used 'giveup' instead of PPUSTATUS in his code sample.tokumaru wrote:the VBlank flag is cleared when you read it
And what does that have to do with the method I posted? The NMI fires, you wait a little more than 20 scanlines, read the PPU status and the VBlank flag will tell you if the system is PAL or NTSC (according to what you said about the Dendy, it would be detected as NTSC, which is nice). As far as I can tell, the racing condition doesn't affect anything in this case.tepples wrote:The vblank signaling in the NES PPU has a race condition bug.
Why would anyone want that? I check it every frame just because my VBlank code is timed anyway, and it's cool to have the program adapt to the other system on the fly, without resetting.tepples wrote:But if you want to measure a lot of frame timings to calibrate your engine, that's what a copyright notice screen is for.
Yeah, but the goal is not to find out how long the vertical blank is, the goal is to check the VBlank flag past the known duration of the NTSC vertical blank so that you get the answer (is the console NTSC or PAL) from a simple flag, without having to use a counter and check its value afterward. I find it simpler, but it will not detect a Dendy.Besides, you can find the end of vertical blanking by waiting for the sprite 0 flag to turn off.
Russia's unlicensed version of the Famicom. Apparently it has some unique hardware differences.Bregalad wrote:What is a dendy ?
Why would anyone change regions in the middle of a game? That's not even possible on the original hardware... O_otokumaru wrote:Why would anyone want that? I check it every frame just because my VBlank code is timed anyway, and it's cool to have the program adapt to the other system on the fly, without resetting.
You're right that it isn't possible on the NES, but it is on the Super NES. Apparently there's some sort of "50/60 switch".BMF54123 wrote:Why would anyone change regions in the middle of a game? That's not even possible on the original hardware... O_o
My game just supports this because in my case there is absolutely no extra cost in doing so, and it's cool to see a timing-sensitive program not breaking on emulators when the region is changed.BMF54123 wrote:Why would anyone change regions in the middle of a game? That's not even possible on the original hardware... O_o
What's a Dendy?
Generally speaking, it's the Asian PAL-Famiclones based on the 6527P/6538 chips (Dendy, Microgenius, Pegasus, etc.)Russia's unlicensed version of the Famicom. Apparently it has some unique hardware differences.