Jump to content
IGNORED

Auto detect PAL vs NTSC


Lisboa2k6

Recommended Posts

Hi,
I am searching for a routine to auto detect PAL-50 vs NTSC-60 on Atari VCS 2600? Is it possible to read any registers or otherwise detect it from hardware? I was thinking maybe to use collision detection together with timers, but not sure if that is even possible, or if it will make any distinct difference for PAL vs NTSC. Anyone tried to solve this, or ready to take the challenge?

Link to comment
Share on other sites

27 minutes ago, Lisboa2k6 said:

Hi,
I am searching for a routine to auto detect PAL-50 vs NTSC-60 on Atari VCS 2600? Is it possible to read any registers or otherwise detect it from hardware? I was thinking maybe to use collision detection together with timers, but not sure if that is even possible, or if it will make any distinct difference for PAL vs NTSC. Anyone tried to solve this, or ready to take the challenge?

 

Not possible without additional hardware I'm afraid.

 

  • Like 1
Link to comment
Share on other sites

The PAL 2600's clock runs around 1% slower than NTSC, but you can't measure the difference using the RIOT timers and TIA registers, because they both measure time in clocks, not the actual time.

 

@SpiceWare has solved this using the additional ARM chip in the Harmony cartridge, see:

 

He also shared the code here:

 

Edited by Dionoid
  • Like 2
Link to comment
Share on other sites

As noted, you can do it in ARM-based games.  Here's my auto-detect code...

 

#define DETECT_FRAME_COUNT 10


void detectConsoleType() {

    switch (frame) {

    case 0:

        T1TC = 0;
        T1TCR = 1;

        mm_tv_type = TV_TYPE = 0;                // force NTSC frame
        break;

    
    case DETECT_FRAME_COUNT: {

        int detectedPeriod = T1TC;
        
        struct fmt {
            int frequency;
            unsigned char format;
        };

        static const struct fmt mapTimeToFormat[] = {

        // Timings from Gopher, 20220827

#define NTSC_70MHZ      (0xB25FCD * DETECT_FRAME_COUNT / 10)
#define PAL_70MHZ       (0xB3856E * DETECT_FRAME_COUNT / 10)
#define SECAM_70MHZ     (( (PAL_70MHZ - NTSC_70MHZ) / 2 + NTSC_70MHZ) * DETECT_FRAME_COUNT / 10)

            { NTSC_70MHZ,   NTSC,    },
            { SECAM_70MHZ,  SECAM,   },
            { PAL_70MHZ,    PAL_60,  },

#define NTSC_60MHZ      (0x98EB2F * DETECT_FRAME_COUNT / 10)
#define PAL_60MHZ       (0x9A0EEF  * DETECT_FRAME_COUNT / 10)
#define SECAM_60MHZ     (( (PAL_60MHZ - NTSC_60MHZ) / 2 + NTSC_60MHZ) * DETECT_FRAME_COUNT / 10)

            { NTSC_60MHZ,   NTSC,    },
            { SECAM_60MHZ,  SECAM,   },
            { PAL_60MHZ,    PAL_60,  },
        };


        int delta = INT_MAX;
        for (unsigned int i = 0; i < sizeof(mapTimeToFormat) / sizeof(struct fmt); i++) {

            int dist = detectedPeriod - mapTimeToFormat[i].frequency;
            if (dist < 0)
                dist = -dist;

            if (dist < delta) {
                delta = dist;
                mm_tv_type = mapTimeToFormat[i].format;
            }
        }

        menuLineTVType = TV_TYPE = mm_tv_type;
        break;
    }

    default:
        break;
    }

    frame++;

}

 

  • Like 2
Link to comment
Share on other sites

Discounting the ARM chip for a moment, let's imagine that somebody wanted to build a cartridge that was adaptive to NTSC/PAL during the early '80s. What would have been the cheapest/easiest method of achieving it at that time?

 

It would need a clock in order to measure the console against and it would also need a specific "bankswitching" protocol in order to get information from the clock. The protocol wouldn't need to be complex, just a binary response to the question, "has the clock elapsed since the last time [some address] was accessed?"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...