MZ 700 - detect PAL/NTSC

Jo Even
Site Admin
Posts: 145
Joined: Wed Jan 17, 2018 9:28 pm

MZ 700 - detect PAL/NTSC

Post by Jo Even »

Is there a way to detect video mode (PAL/NTSC) in software? Except for counting cycles between frames of course.
hlide
Posts: 519
Joined: Thu Jan 25, 2018 9:31 pm

Re: MZ 700 - detect PAL/NTSC

Post by hlide »

Detect which monitor ROM? well, not very standard as well...
User avatar
mz-80a
Posts: 232
Joined: Thu Jan 25, 2018 10:46 am
Location: Devon, UK
Contact:

Re: MZ 700 - detect PAL/NTSC

Post by mz-80a »

Interesting! Presumably just for the MZ-700 / 800 ?
MZ-80A Secrets
https://mz-80a.com/

Sharpworks (Sharp MZ homebrew)
http://mz-sharpworks.co.uk/
hlide
Posts: 519
Joined: Thu Jan 25, 2018 9:31 pm

Re: MZ 700 - detect PAL/NTSC

Post 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.
Jo Even
Site Admin
Posts: 145
Joined: Wed Jan 17, 2018 9:28 pm

Re: MZ 700 - detect PAL/NTSC

Post by Jo Even »

hlide wrote: Wed Oct 02, 2019 1:39 pmSoftware: 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 :)
hlide
Posts: 519
Joined: Thu Jan 25, 2018 9:31 pm

Re: MZ 700 - detect PAL/NTSC

Post by hlide »

What does the real hardware give you?
Jo Even
Site Admin
Posts: 145
Joined: Wed Jan 17, 2018 9:28 pm

Re: MZ 700 - detect PAL/NTSC

Post by Jo Even »

Only 0xffff.
hlide
Posts: 519
Joined: Thu Jan 25, 2018 9:31 pm

Re: MZ 700 - detect PAL/NTSC

Post 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.
Jo Even
Site Admin
Posts: 145
Joined: Wed Jan 17, 2018 9:28 pm

Re: MZ 700 - detect PAL/NTSC

Post 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
Jo Even
Site Admin
Posts: 145
Joined: Wed Jan 17, 2018 9:28 pm

Re: MZ 700 - detect PAL/NTSC

Post 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.
Post Reply