Page 1 of 2

MZ 700 - detect PAL/NTSC

Posted: Tue Oct 01, 2019 6:50 pm
by Jo Even
Is there a way to detect video mode (PAL/NTSC) in software? Except for counting cycles between frames of course.

Re: MZ 700 - detect PAL/NTSC

Posted: Tue Oct 01, 2019 7:04 pm
by hlide
Detect which monitor ROM? well, not very standard as well...

Re: MZ 700 - detect PAL/NTSC

Posted: Wed Oct 02, 2019 11:29 am
by mz-80a
Interesting! Presumably just for the MZ-700 / 800 ?

Re: MZ 700 - detect PAL/NTSC

Posted: Wed Oct 02, 2019 1:39 pm
by hlide
Hardware: get the pin 41 of M60719 (N/P): L = PAL / H = NTSC. But you need to make a circuit to let teh CPU to capture this signal.

Software: 8253.CLK1 = /BLNK. Between two fall-edge /VSYNC count how many /BLNK occurs (reading CNT1 before and after and compute delta for instance). It should give the number of lines which should reflect a PAL or NTSC number of lines.

Re: MZ 700 - detect PAL/NTSC

Posted: Mon Nov 04, 2019 9:26 pm
by Jo Even
hlide wrote:
Wed Oct 02, 2019 1:39 pm
Software: 8253.CLK1 = /BLNK. Between two fall-edge /VSYNC count how many /BLNK occurs (reading CNT1 before and after and compute delta for instance). It should give the number of lines which should reflect a PAL or NTSC number of lines.
Just tested this, and while it worked fine (sort of) in the emulator it did not work on real hardware. Probably inaccurate implementation of the 8253, I guess the counter is running even when it has not been initialised. Now I'll have to try to understand the confusing 8253 docs :)

Re: MZ 700 - detect PAL/NTSC

Posted: Mon Nov 04, 2019 10:07 pm
by hlide
What does the real hardware give you?

Re: MZ 700 - detect PAL/NTSC

Posted: Tue Nov 05, 2019 11:42 am
by Jo Even
Only 0xffff.

Re: MZ 700 - detect PAL/NTSC

Posted: Tue Nov 05, 2019 4:45 pm
by hlide
Well remind me on FB that I should try a code to count /BLNK events in a frame on my MZ-700 this weekend.

Re: MZ 700 - detect PAL/NTSC

Posted: Wed Nov 06, 2019 9:32 pm
by Jo Even
I'll try to remember that :)

Did some more test and got things "working" on real hardware. "Working" as in "something happens". I don't understand the results.

The crude test code looks like this:

Code: Select all

	vbl();
	*((unsigned char *)0xe007) = 0x74;
	*((unsigned char *)0xe005) = 0x00;
	*((unsigned char *)0xe005) = 0x04;

	vbl();
	lines = *((unsigned char *)0xe005);
	lines = 4*0xff - (lines << 8) | *((unsigned char *)0xe005);
I wait for vbl, initalise the counter, set it to 1024, wait for another vbl and reads the value of the counter. On the emulator it has counted down between 254 and 252, on real hardware it has counted down 509. I have no idea how to interpret these values, I would have expected either the number of PAL/NTSC lines (525 or 576) or half that value since the MZ output isn't interlaced.

Most likely I've misunderstood how the 8253 works.

Btw the vbl code looks like this:

Code: Select all

	__asm
	push af
wait1:	ld a,(0e002h)
	rlca
	jr nc,wait1
wait2:	ld a,(0e002h)
	rlca
	jr c,wait2
	pop af
	__endasm

Re: MZ 700 - detect PAL/NTSC

Posted: Wed Nov 06, 2019 10:00 pm
by Jo Even
Btw I "solved" this problem by not using this timer at all, I count how many times I can increment a variable between two VBL's. Not the most elegant solution but it's working.