z80 clocks

For anything related to sound (YM2612, PSG, Z80, PCM...)

Moderator: BigEvilCorporation

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Wed Feb 19, 2014 2:42 pm

There is 262 or 313 lines per frame. It sums up to an even number, and that is what makes the image "progressive". If there was odd number of lines you will get interlacing, which is nothing more than a byproduct of how syncing works in CRT TVs. If you had 1/3 lines you get interlacing that takes 3 fields to complete a "frame" for example.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Eke
Very interested
Posts: 884
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Wed Feb 19, 2014 4:08 pm

r57shell wrote:
Eke wrote:full Horiz. resolution with borders is 283 pixels (13 + 256 + 14) or 347 (13 + 320 + 14),
Now I wonder how stretching in 256 mode is working?
"stretching" is caused by the fact that active line width is always the same, i.e 2560 MCLKS, no matter what the internal resolution is.

Analog TV does not see any "pixels", just analog signal with voltage variations. So, "pixels" should be considered as distinct samples of the analog signal: less distinct samples on active line part means that variations are more spaced. The number of pixels and their "width" is directly related to the VDP pixel clock.

There was also some discussion about that subject in this thread:
viewtopic.php?t=237

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Wed Feb 19, 2014 6:34 pm

Eke wrote:So, "pixels" should be considered as distinct samples of the analog signal: less distinct samples on active line part means that variations are more spaced.
Not "should", it "can" be considered this. As I understand (from wiki), there is only one signal which is modulated somehow. And there is even scheme:
Image
Though I don't understand this scheme :lol:
So, there ARE pixels. And sound samples.
And, I know now, that you told me about VDP intertnal horizontal resolution, and thanks for this info, good to know (because I didn't).
Image

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Wed Feb 19, 2014 6:43 pm

That diagram only applies to RF (and composhit video if you remove sound stuff).
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Eke
Very interested
Posts: 884
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Wed Feb 19, 2014 7:25 pm

r57shell wrote:
Eke wrote:So, "pixels" should be considered as distinct samples of the analog signal: less distinct samples on active line part means that variations are more spaced.
Not "should", it "can" be considered this. As I understand (from wiki), there is only one signal which is modulated somehow. And there is even scheme:
Image
Though I don't understand this scheme :lol:
So, there ARE pixels. And sound samples.
And, I know now, that you told me about VDP intertnal horizontal resolution, and thanks for this info, good to know (because I didn't).
Let's not discuss semantics as we are both non-native english speaker :lol:

What I wanted to say was that pixels are digital samples of analog video and any notions of pixel clock and pixels are lost once you enter the analog world, which happens immediately past the DACs inside the VDP, at RGB output signals. How these signals are then encoded does not really matter, pixels do not exist anymore, only voltage variations and SYNC signals.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Wed Feb 19, 2014 8:14 pm

r57shell wrote:Now I wonder how stretching in 256 mode is working?
The VDP fetches and displays the data using a different (slower) clock. The slower VDP clock also means the DMA is slower, which is why less data is transfered in narrow mode, and you have fewer sprites (the sprite DMA is also slower).
And, if both fields on same lines then is it still 525 lines or 524 or 526?
In NTSC standard odd number of lines chosen not accidentally.
524. It simply doesn't do the half-line, just the full 262 lines. So over two fields, it's only 524, with the second field being displayed EXACTLY over top the first field. In effect, it's indistinguishable from 262 lines progressive, even if the TV doesn't act that way.

As to how you associate "pixels" when speaking of analogue signals, engineers specify "lines" based on old patterns that TV stations broadcast when testing the signal. The standard is 80 lines per MHz. What that meant was you could discern 320 lines on a chart when the signal was 4 MHz in bandwidth (for the luma signal). If you filter the luma too much, the pixels will "smear" into each other, which is where the blending affect of composite comes in - the color signal is so low in bandwidth that the number of lines of resolution are well below how many pixels the console generates. This was specifically used for generating more colors on quite a few old MD games (and on other consoles, too).

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Thu Feb 20, 2014 5:24 am

Eke wrote:What I wanted to say was that pixels are digital samples of analog video and any notions of pixel clock and pixels are lost once you enter the analog world, which happens immediately past the DACs inside the VDP, at RGB output signals.
I was wrong. I thought that TV has one ray, and it somehow switched between red/green/blue for each pixel. But it really has three rays, each for red/green/blue correspondingly. And all of them going in line. All of them just "wave".
Eke wrote:How these signals are then encoded does not really matter, pixels do not exist anymore, only voltage variations and SYNC signals.
It does really matter. If it was encoded in other way, screen doesn't stretching then. Important thing: ratios (for example aspect ratio).
I know that 4:3 common ratio, but what happens with borders then?
Chilly Willy wrote:It simply doesn't do the half-line, just the full 262 lines. So over two fields, it's only 524, with the second field being displayed EXACTLY over top the first field.
I wondering how all of old TV support this "odd" mode? :o
Image

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Thu Feb 20, 2014 6:35 am

r57shell wrote:I know that 4:3 common ratio, but what happens with borders then?
Most TVs today have a user selectable setting for what to do. Old TVs just displayed black bars. Better old TVs had the ability to show gray that matched the average luminance of the video to prevent burn in of the black bars (stronger phosphors because they rarely got used). TVs now have several stretched modes in addition to black bars.
Chilly Willy wrote:It simply doesn't do the half-line, just the full 262 lines. So over two fields, it's only 524, with the second field being displayed EXACTLY over top the first field.
I wondering how all of old TV support this "odd" mode? :o
On CRTs, the half line affects when the vertical deflection is reset to the top of the TV. By making the line half as long, it resets to the middle at the top instead of the top left corner. Without the half line, the vertical deflection is ALWAYS to the top left, so no interlace.

It's actually tougher for LCD TVs to deal with interlace than CRTs. They have to detect that half line and increment with row of LCD cells to activate. That's why many didn't bother - they simply assume interlaced regardless of the signal.

Eke
Very interested
Posts: 884
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Thu Feb 20, 2014 8:16 am

r57shell wrote: It does really matter. If it was encoded in other way, screen doesn't stretching then. Important thing: ratios (for example aspect ratio).
No, as I said above, pixel width and therefore what you call "stretching" is caused by the VDP pixel clock, nothing else. How RGB output signals are encoded (into composite video or raw RGB with sync) really has nothing to do with the stretching, the "length" of the signals remain the same.

What changes is "pixel aspect ratio" and number of pixel per line. Display aspect ratio (4:3) is determined by the active "length" of the displayed line and by the number of active lines.

r57shell wrote:I know that 4:3 common ratio, but what happens with borders then?
If you are talking about the few pixels on the left/right sides which takes the border color then they are displayed like any other pixels, they are actually part of the active video signal (just not part of VDP active video). Most CRT TV are not able to show full part of the active video signal so these borders are usally barely seen.

Keep in mind 4:3 is display aspect ratio, it's not the number of pixels (with borders or not) divided by the number of lines.

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Thu Feb 20, 2014 4:04 pm

Chilly Willy wrote:TVs now have several stretched modes in addition to black bars.
You always can configure mad aspect, but I'm interesting in aspect "what meant to be".
Chilly Willy wrote:By making the line half as long, it resets to the middle at the top instead of the top left corner. Without the half line, the vertical deflection is ALWAYS to the top left, so no interlace.
Half line long in horizontal? Top middle in horizontal? If it is, then I don't belive. Let's call lines as in Wikipedia, then interlaced {2,4,6...524,1,3,5,...525} full cycle. And MD force {2,4,6,...,524,2,4,...524...} forcely resync to first field?
Chilly Willy wrote:That's why many didn't bother - they simply assume interlaced regardless of the signal.
If they assume interlaced then
2->2
4->4
...
524->524
2->1
4->3
...
524->523
2->525 (?????? or there will be just sync to 2?)
4->2
6->4
If not sync (skip) at 525 line, then whole screen will roll.

It doesn't really matter for me, I'm just curious :? Matters for me only that both fields on same lines.
Eke wrote:How these signals are then encoded does not really matter, pixels do not exist anymore, only voltage variations and SYNC signals.
I didn't see "then".
I mean VDP->TV->Display
TV->display = same always.
but VDP->TV does really matter, and there stretching occurs.

Well, I restate in a different way:
Is that true, that 320x224 showed by TV with pixel ratio 1:1?
If not, then how?
And ratio of borders?
For example, if 320x224 (with borders) showed by TV with pixel ratio 1:1,
and 256x225 (without borders) showed by TV with such pixel ratio that stretched to 320x224(without borders) screen with 1:1 ratio i.e. 1.25:1, then if borders showed with same 1.25:1 pixel ratio,
then whole display would be bigger than for 320x224.
Simple calculations: (13 + 256 + 14)*1.25 = 353.75 > 347 = (13 + 320 + 14)*1
If it fits with borders, then aspect can be 1.226:1
(13 + 256 + 14)*1.226 = 346.958
Image

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Thu Feb 20, 2014 6:27 pm

r57shell wrote:Half line long in horizontal? Top middle in horizontal? If it is, then I don't belive.
How interlacing affected horizontal and vertical deflection is something only people who worked on CRTs learned. Wikipedia doesn't cover it because it's written by folks who probably never used a CRT, much less had all the old training. I had to hunt this page down, but it gives a much clearer image of what interlace is actually doing rather than the "digital" image that wiki seems to think is what happens.

http://graffiti.virgin.net/ljmayes.mal/var/tvsync.htm

Scroll down a bit to the figure labeled "The Appearance of a Raster on a CRT (with zero flyback time)". That is for PAL, but it's exactly the same for NTSC other than the number of lines.

Yes, half a line long in the horizontal; yes, the top middle. Look at the figure mentioned and you'll see WHY you reset the signal to HALF WAY THROUGH THE LINE. LCD TVs don't normally show the half lines - they're suppressed along with much of the overscan region. You need a CRT with no overscan to see those half lines, but they ARE there!
Last edited by Chilly Willy on Thu Feb 20, 2014 6:38 pm, edited 1 time in total.

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Thu Feb 20, 2014 6:28 pm

This is why image is interlaced with an half line :

Image

Image
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Thu Feb 20, 2014 7:19 pm

Chilly Willy wrote:Wikipedia doesn't cover it because it's written by folks who probably never used a CRT, much less had all the old training.
Yeah, that's true.
Chilly Willy wrote:http://graffiti.virgin.net/ljmayes.mal/var/tvsync.htm

Scroll down a bit to the figure labeled "The Appearance of a Raster on a CRT (with zero flyback time)". That is for PAL, but it's exactly the same for NTSC other than the number of lines.
(and image)
Yay! Awesome! Now everything is clear.
Post this image or this link to everyone who'll ask it again.
Nothing can be more easy to understand than scheme.
But, It would be better to have such scheme for MD case (always same field)

I got it. Now what can be only not clear that is "pixels on line" and stretching.
Image

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Thu Feb 20, 2014 7:56 pm

r57shell wrote:(and image)
Yay! Awesome! Now everything is clear.
It's always easier with an image to give you an idea of what's going on. :)

I got it. Now what can be only not clear that is "pixels on line" and stretching.
Think of it like this: say a horizontal line lasts 125 usec. That isn't the case, but we're pretending using something with simple math to make a point. Now assume that the horizontal sync pulse takes 25 usec. That means that 100 usec of signal are visible. The TV stretches that 100 usec signal to fit the width of the TV. Now say the VDP outputs a pixel every 0.25 usec - that means that 400 pixels are output in that 100 usec time, so the TV makes those 400 pixels fit the width of the TV. Now assume that in low-res mode, the VDP cuts the video clock in half. So instead of a pixel every 0.25 usec, it's a pixel every 0.5 usec. That means that 200 pixels are output in that 100 usec, and the TV is still showing that 100 usec of display as a full line on the TV, so we now have 200 pixels as our line on the TV. Note that the TV is simply showing ANYTHING in that 100 usec period as a full line on the TV, whether that be 400 pixels or 4 pixels (if the VDP generated a pixel every 25 usec).

It's the rate at which the VDP outputs pixels divided into the length of time a line lasts (minus the time for the horizontal sync) that determines how many pixels per line there are. Note that the VDP doesn't care about things like aspect ratio. All it's doing is outputting a pixel every so often. It's up to the programmer to handle things like aspect ratio.

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Post by r57shell » Thu Feb 20, 2014 9:18 pm

Chilly Willy wrote:Note that the TV is simply showing ANYTHING in that 100 usec period as a full line on the TV, whether that be 400 pixels or 4 pixels (if the VDP generated a pixel every 25 usec).
Question is: where is left border, image, and right border, placed in 100 usec for both 320 and 256 modes. Because it's not just 400 and 200 pixels. It is 347 and 283. May be clock devision turned on to 5/4 (1.25) within image, and turned of on borders.
Chilly Willy wrote:Note that the VDP doesn't care about things like aspect ratio. All it's doing is outputting a pixel every so often.
VDP doesn't care, that's true. Engineers took care of aspect during VDP developing.
Image

Post Reply