SX color TV 게임기
테트리스 회로, 소스
핑퐁 회로, 소스
NTSC 방식의 영상신호를 만드는 방법을 설명한다.
이 자료는 SX 칩으로 만든 기판을 NTSC TV에 연결하여 게임을 한다.
먼저 NTSC 방식의 영상신호를 만드는 방법을 설명한다.
SX28로 만든 기판으로 2가지 TV 게임기를 만든다.
주사선(scan line)과 비월(interaced) 주사(scan)
표준 TV는 2개 분리된 화면으로 부터 하나의 영상을 만든다.
각각의 화면은 매번 교차되어 1초에 30 번씩 모두 60번 들어온다.
지도에서 다른 표준을 사용하는 국가를 보여준다.
아날로그 TV의 표준은 NTSC, SECAM, PAL 이 있다. NTSC는 "국제 TV 장치 협회"의 약자이다.
NTSC의 주사선은 525개로, 화면의 갱신속도는 30Hz 이다.
SECAM은 "Sequential Color And Memory"의 약자로 프랑스의 표준이다.
SECAM은 색상의 안정도는 좋으나 분해능이 떨어진다.
유럽의 표준 PAL은 "Phase Alternating Lines"의 약자로, 625개의 주사선을 25Hz로 방송한다.
물론 PAL의 표준도 NTSC에서 파생된 것이나, 개선점은 색상의 오류를 매 라인마다 제거한다.
1초에 25~30 번 이하의 화면을 전송하면, 화면이 깜빡거리는 Flicker 현상이 나타난다.
그래서 1번은 1,3,5,7,9,,,로된 홀수선의 수평 영상을 화면을 표시하고
또 한번은 2,4,6,8,,,로된 짝수선의 수평영상을 화면에 표시해서 플리커를 개선한다.
연상신호는 0~1V 이다, 0.3V 는 흑색이다. 0~0.3V는 동기신호이다.
수평동기 신호는 1초에 525번 나타나고, 수직동기는 1초에 30번 나타난다.
수평동기 신호보다 넓은 수직동기에는, 겉보기 주파수를 높이기 위한 동기펄스가 들어간다.
주사선에 포함된 영상신호
An image is built from 625scanlines, but a TV doesn't show 625 lines.
Some of the lines are used for synchronization pulses, and some lines are invisible
because old TVs needed some time to move the electron beam from the bottom of the screen.
(Those invisible lines are nowadays used for other purposes, Text-TV for example).
아래 그림은 2개의 주사선에 올라탄 영상신호를 보여준다.
To tell the TV that a new image is coming, a special pattern of synchronization pulses is sent.
Since the picture is built from two half pictures, the pattern is different for the odd and even images.
The vertical synchronization pulses looks like this:
2개의 동기신호는 홀수와 짝수의 주사선에 포함된 동기신호이다.
밑에 있는 숫자는 주사선의 번호이다.
When color was introduced, it was the same problem as with any change in technology, there is always a demand for backwards compatibility that limited the new technology. For video signals this meant that a color video signal should look very much like a B&W signal so old TVs would still work. The problem was solved by overlaying the color signal with an amplitude modulated carrier on top of the video signal. In average the video signal would still be the same for B&W and it would not be noticed if the carrier had high enough frequency and the modulation also was kept to a low bandwidth.
The intensity of the TV signal is the sum of the Red, Green and Blue parts (weighted with the eyes sensitivity coefficients for those colors) in the video signal, and since that information is already given in the B&W signal then the additional color information only needs to contain two components with color difference. With the intensity sum and the two components G-R and G-B, it is possible to derive the R,B and G values. Humans have higher resolution for light intensity than for color, so using higher bandwisth for intensety than for colr variation is very appropriate. Limiting the color information to two components is especially great as it is possible to transfer two signals using quadrature modulation, making it possible to transfer color using only one carrier overlaid on the B&W video signal!
기본 원리는 4상진폭변조(4QAM)이다.
Quadrature modulation is a general method for modulation of a carrier. The idea is to change both amplitude and phase of the carrier to be able to send two signals with one carrier frequency. Each signal has its own carrier, one is sin (2pi*fc*t) and one is cos (2pi*fc*t), which makes it possible to reach all phases and amplitudes by modulating the voltages of the two signals. This method is not only used for TV color modulation, it is widely used, for example this is how stereo information is sent over radio also. It is a clever way to use the bandwidth to the maximum, with standard amplitude modulation only one channel is used, the other is just wasted. In order for this method to work, there must be a “pilot”, a reference signal that makes synchronizes the oscillator in the receiver with the one on the transmitter.
4상 변조의 방법에서 두 표준은 변조레벨이 상이하다.
나중에 나온 PAL은 CRT에 향상된 형광체를 사용한다.
색상의 감도는 무게가 주어진다, 즉 연상레벨과 변조레벨의 관계가 선형이 아니라는 뜻이다.
색상의 무게는 사람의 시감도를 보상하도록 주어진다.
The Y,U,V component transformation can be described as a matrix,
for PAL the matrix looks like the following:
In NTSC the U and V components are rotated 33 degrees to minimize bandwidth
for Q, the rotated components are called I and Q, calculated according this:
For NTSC the Y,I, Q components can be described using the following conversion matrix:
Putting it all together
The output is created with quadrature modulating as described before by modulating a cosine
and a sine with the U and V (I and Q for NTSC) components and sum the result together
with the lumination component Y.
For PAL there is also a change in sign of the sinus component to compensate
for phase error that will take out each other. (That is why it is called Phase Alternating Line).
The video signal is calculated according the following:
So the color coding is just as simple as that,
but there is one detail left, there must be a pilot signal in order for the quadrature modulating.
In most systems using quadrature modulation, the pilot signal is sent constantly as a tone in the signal,
for TVs however that would disturb the image too much.
If there is an oscillator in the TV that is very stable,
it would be enough to send a couple of cycles of the pilot periodically
for the oscillator to tune in to, just often enough for the oscillator to keep its phase.
In the B&W signal there is a gap of about 7us between the sync pulse and where the image information starts,
so it was an obvious place to put the reference carrier.
This is 10-12 cycles of the color carrier (amplitude of 20IRE = 0.15V) and referred to as the “color burst”.
The color burst is also shifted +-45 degrees on every scan-line for PAL.
As you would know after reading the chapter about video signals, the software needs to create modulated sinus and cosines waveforms for color information and sum them together with the intensity waveform. To get a good result the sample rate needs to be much higher than the color carrier frequency, and the software must also be able to do the needed calculations for the waveform which in total would need a very powerful processor if there is no hardware to help. An SX processor performing 50MIPS would not be good enough using this method.
However, there is fortunately a better way to do it.
The color carrier part of the signal is the sum of a sinus and a cosines
with the same frequency but different amplitude,
this is very fortunate as the cosines could be rewritten as a sinus
with it phase shifted 90 degrees compared to a cosines.
Ok so what good is that, well,
the sum of two sinuses with same frequency and fixed phase difference but
with varying amplitude could be rewritten as one sinus
with alternating phase and amplitude according to:
The coefficients preceded cos and sin describes a point on the unit circle
and could be replaced with cos and sin with the angle alpha according to:
This equals a rotation by an angle alpha according to:
Making it possible to express the sum of an aplitude modulated sin and cos
with one sin that is both aplitude and phase modulated.
Ok we got rid of one of the components but still have one sinus that needs to be generated requiring a lot of CPU power. At the input of a TV there is a low-pass filter to limit the signal within a video signals allowed bandwidth of about 5MHz, which is very good because that means that a square wave at the color carrier frequency would look like a sinus to the TV as the high frequency components of the square wave have been filtered away.
Now we are down to a square wave with changing phase, amplitude and offset,
which is possible to generate in software with an SX@50MHz if the number of phases is limited and the clock frequency is a multiple of the color carrier frequency.
In my projects I clock the SX with 12 times the carrier frequency for both PAL and NTSC, which gives 53.156550MHz for PAL and 42.954540 for NTSC, the over clocking of a 50MHz SX chip to 53MHz in the PAL case seems not to be a problem at all.
Our new parameters
The simplified signal with the square wave works like this:
The average voltage of the signal control the lumination, the amplitude of the signal controls the whiteness and phase controls the color. When using 12 times the color carrier it is possible us get 12different colors with different variation in intensity and whiteness.
The first test I made with color generation was to examine the 12 base colors available,
this test I shown in the picture to the left below.
All possible variations for the 12 base phases can be seen here to the right below
where all possible values for first and second amplitude are shown for all 12 phases and five bits.
(There are25*25*12/2-25*5=3625 combinations)
The 12 phases, generates these 12 base colors.
The available colors for 5bit DA and 12 phases.
신호의 발생은 DA-변환기가 필요하다, 간단한 저항기반의 DA를 만든다.
저항기반의 DA에는 2 종류가 있다 , 2N-net과 R2R-ladder 이다. 2N 망은 가단하다.
2N DA 변환회로.
2N-망은 복잡하다, R2R-ladder는 2배의 저항이 필요하다. 그러나 더 정밀도가 높다.
R2R DA 변환회로
5 비트 DA는 0~1.25V를 출력한다.
2R은 440 옴, R은 220 음을 사용한다.
구할 수 없다면, 220 옴과 110 옴을 사용해도 된다.
대역폭이 낮으므로, 색상을 빠르게 바꿀 수 없다, 영상 표현에 색상 위상값을 상수로 사용햇다.
그리고 매 색상 사이클마다 오직 밝기만 바꾼다. NTSC에서 분해능은 2233/12=186 픽셀이다.
게임에 사용한 흑백 공 (색상 위상변화를 주어 칼라로 보인다)
To save memory a palette is often used in computer graphics cards. A palette is basically a color lookup table. In most cases the palette contains 2N colors, usually 16 or 256 colors to be able to get each color into a nibble or a byte. If a picture only uses 16 different colors, then it needs 6 times less memory compared to if each byte would have been stored as three 8bit values with the RGB-components if a 16 color palette is used. In my games a palette is used to need less data for some of the graphics, a 16 color palette is used, however the lookup table doesn’t store the RGB values, instead it stores high and low period values for the square wave. In other words, my palette only contains info on brightness and whiteness, the color is set by the phase of the square wave which is not stored in the palette. Only one palette is used for both my games and it stars at black level, moves to color with maximum intensity, and then moves to maximum white. (See diagram below.) This palette makes it possible to generate objects with a 3D-feeling as it is possible to make dark shadows and more illuminated parts within the same object, but the object must be “monochrome”. It is possible to generate palettes with a 180 degree phase shift and get the complimentary color, but as the bandwidth is limited it is not possible to mix colors from the two phases in any order, it takes almost one color cycle for the phase change. (If the graphics is carefully planned to get few phase shifts, this could probably be used to do some really cool two colored objects)
It is possible to generate composite color video signals in software,
but it is a lot of work and it is only possible in some special cases.
NTSC is much more easy to do than PAL when doing the signal
in software as phaseshifting is better done in hardware.
The main reason for doing video in software is doing it for fun and that it is possible =),
this form of video generation has very little commercial value as
it takes huge amount of time to generate something with very poor result.
Doing software based monochrome signal colored with hardware would give
but the best result is of course done with memory mapped graphics outputted
with dedicated hardware.
|SX28 USB 분석장치 (SX-Atpapch)|
|SX28 Serial to TV|