MZ 700 - detect PAL/NTSC

hlide
Posts: 477
Joined: Thu Jan 25, 2018 9:31 pm

Re: MZ 700 - detect PAL/NTSC

Post by hlide » Thu Nov 07, 2019 9:17 am

I guess you wrap it with

Code: Select all

DI : ... : EI
to delete any interrupt?

hlide
Posts: 477
Joined: Thu Jan 25, 2018 9:31 pm

Re: MZ 700 - detect PAL/NTSC

Post by hlide » Thu Nov 07, 2019 10:40 am

Emulator: I'm not expecting the emulator to run each instruction at an accurate 3.57 MHz frequency. An emulator tends to run a batch of instructions then pause to make the overall speed close to the simulated frequency. So you may not capture the counter value at the right time.

Hardware: Was it a true MZ-700 or a MZ-800 in MZ-700 mode?

BLNK(MZ-700)/HSYNC(MZ-800) frequency is 15.6KHz. So 15.6KHz / 509 ~= 30 Hz.

For me the computation should be : lines = 1024 - counter1.

Code: Select all

uint8_t lobyte = *((uint8_t*)0xe005);
uint8_t hibyte = *((uint8_t*)0xe005);
uint16_t lines = 1024 - ((uint16_t(hibyte) << 8) | uint16_t(lobyte));
By the way, it seems you read first high byte then low byte - remember Intel is little-endian, not big-endian.

hlide
Posts: 477
Joined: Thu Jan 25, 2018 9:31 pm

Re: MZ 700 - detect PAL/NTSC

Post by hlide » Thu Nov 07, 2019 10:45 am

Anyway, I agree something is still fishy with counter1. I will check it on my MZ-700 with Unicard. ^^

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

Re: MZ 700 - detect PAL/NTSC

Post by Jo Even » Thu Nov 07, 2019 8:48 pm

hlide wrote:
Thu Nov 07, 2019 9:17 am
I guess you wrap it with

Code: Select all

DI : ... : EI
to delete any interrupt?
No, I did not. Tried this now but it did not make a difference.
hlide wrote:
Thu Nov 07, 2019 10:40 am
Emulator: I'm not expecting the emulator to run each instruction at an accurate 3.57 MHz frequency. An emulator tends to run a batch of instructions then pause to make the overall speed close to the simulated frequency. So you may not capture the counter value at the right time.
Yes, that's possible, I don't know the internals of this emulator. Unfortunately it's the only emulator I've got working on Linux.
hlide wrote:
Thu Nov 07, 2019 10:40 am
Hardware: Was it a true MZ-700 or a MZ-800 in MZ-700 mode?
It's a real 700.
hlide wrote:
Thu Nov 07, 2019 10:40 am
By the way, it seems you read first high byte then low byte - remember Intel is little-endian, not big-endian.
I know, it looks strange but this gives the correct result with this compiler. C is big endian, but shifting the most significant byte to the left gives the opposite result of what I expect.

hlide
Posts: 477
Joined: Thu Jan 25, 2018 9:31 pm

Re: MZ 700 - detect PAL/NTSC

Post by hlide » Sun Jul 05, 2020 6:55 pm

@Jo Even

I coded a VSYNC CHECKER (fully assembly code) to use the timer #2 to count BLNK and so to determine how many lines between frames.

Here is what I got with EmuZ-700 NTSC (262 lines):
2020-07-05_20-52-02.png
2020-07-05_20-52-02.png (20.71 KiB) Viewed 1948 times

And here is what I got with EmuZ-700 PAL (312 lines):
2020-07-05_20-51-56.png
2020-07-05_20-51-56.png (20.6 KiB) Viewed 1948 times
So I have a stable difference of 2 lines for both.

With mz800emu, I got something unrealistic like 33xx.

hlide
Posts: 477
Joined: Thu Jan 25, 2018 9:31 pm

Re: MZ 700 - detect PAL/NTSC

Post by hlide » Sun Jul 05, 2020 7:19 pm

And on a stock MZ-700, I have the same result as mz800emu... Gosh!

hlide
Posts: 477
Joined: Thu Jan 25, 2018 9:31 pm

Re: MZ 700 - detect PAL/NTSC

Post by hlide » Sun Jul 05, 2020 7:53 pm

It looks as if the way to set/read the two bytes of the counter #2 is giving trouble. So I decided for the timer #2 to count 2 BLNK instead of 1 so I can keep the counter in a byte. I got 306 for mz800emu and 308 for EmuZ-700 PAL. And... I got 306 on my stock MZ-700.

Now where did my missing 4-6 lines go?

hlide
Posts: 477
Joined: Thu Jan 25, 2018 9:31 pm

Re: MZ 700 - detect PAL/NTSC

Post by hlide » Sun Jul 05, 2020 9:11 pm

I'm starting thinking that 306 may be the part when /HSYNC is normal and we really got BLANK.

If you look at that picture:
pal_tv_diagram_non_interlace.jpg
pal_tv_diagram_non_interlace.jpg (38.28 KiB) Viewed 1941 times
You can see some lines where /SYNC has different values (three here). From the service manual, /HSY is around 4 µS when we get /HBLK and BLNK.

hlide
Posts: 477
Joined: Thu Jan 25, 2018 9:31 pm

Re: MZ 700 - detect PAL/NTSC

Post by hlide » Mon Jul 06, 2020 7:29 pm

I now try to count VTOTAL and VBLANK to check if VDISPLAY (= VTOTAL-VBLANK) equals to 200.

Note that the usual values are:

Code: Select all

Pixel	PAL	NTSC
VDISP	200	200
VBLANK	112	62
VTOTAL	312	262
It seems BLANK is only output when sync is normal (not long or short) so our VTOTAL and VBLANK are missing the lines when sync is not normal.

For mz800emu (stock mz-700 has the same result so far):
Sans titre.png
Sans titre.png (26.98 KiB) Viewed 1916 times
For EmuZ-700 PAL:
2020-07-06_21-10-23.png
2020-07-06_21-10-23.png (21.06 KiB) Viewed 1916 times
For EmuZ-700 NTSC:
2020-07-06_21-09-52.png
2020-07-06_21-09-52.png (21.07 KiB) Viewed 1916 times
Conclusion: For me, stock PAL MZ-700 tells me we get 306 BLNK signals per frame (or maybe 307 because I count two BLNKs as a unit), so I could write up to 306*14, that is, 4284 characters per frame.

Results for NTSC stay consistent with the table if we add 4 to VTOTAL and VBLANK.

Post Reply