Shop OBEX P1 Docs P2 Docs Learn Events
phaseflip in tv_drv_010? — Parallax Forums

phaseflip in tv_drv_010?

mparkmpark Posts: 1,305
edited 2007-08-22 17:28 in Propeller 1
Several Hydra source files contain this comment:

' colors are in reverse order from parallax drivers, or in order 0-360 phase lag from 0 = Blue, on NTSC color wheel
' so code $0 = 0 degrees, $F = 360 degrees, more intuitive mapping, and is 1:1 with actual hardware

I didn't know what it meant... until tonight, when I discovered that tv_drv_010 XORs the palette with $f0f0f0f0 (in NTSC mode), thus reversing the phase (and causing me to lose a couple of hours figuring out why my graphics driver was producing the "wrong" colors).

Anyone know why tv_drv_010 does what it does?

Comments

  • Dennis FerronDennis Ferron Posts: 480
    edited 2007-08-01 10:02
    I was wondering the same thing myself. I've been working on a line-by-line "deconstruction" of the Parallax TV driver, a tutorial intended to explain the purpose of every line of code in the driver, but the last thing I just can't figure out is WTF the phaseflip does and why they do it that way.
  • Dennis FerronDennis Ferron Posts: 480
    edited 2007-08-01 23:54
    BTW, if I'm not using PAL, can I just eliminate the phase flip and change our color constants to compensate? It would simplify the minimal-assembly code NTSC driver I'm working on.
  • deSilvadeSilva Posts: 2,967
    edited 2007-08-04 17:45
    I have no answer, but it now has become a convention, hasn't ist? Andre LaMothe has this table on page 240 of the Hydra book, and it is considered in TEXT.spin and GRAPHICS as well...
  • mparkmpark Posts: 1,305
    edited 2007-08-16 19:30
    I haven't been giving the phaseflip question too much thought because I'm quite happy with my little NTSC driver that doesn't do any phase flipping, but I'd still like a definitive answer.

    Here are my current thoughts on phaseflip, based on a cursory reading of tv_drv:

    In PAL mode, the phase has to alternate every line (that's what PAL means), so having phaseflip alternate between $f0f0f0f0 and $00000000 every scanline·and XORing palettes with phaseflip makes sense.

    In NTSC mode, phaseflip doesn't change every scanline, but in interlaced mode it appears that it does change between fields (so even fields have phaseflip = $f0f0f0f0 and odd fields have phaseflip = 0 or vice versa), so maybe because of the half-scanline you need to flip phases (on a per-field basis). One of these days I'll experiment with that.

    I'm kind of convincing myself that phaseflip is reasonable, but I have to wonder why they didn't invert the phase of phaseflip --·that is, make it $00000000 where it's $f0f0f0f0 now (and vice versa). If they had, then the colors produced by the Parallax driver would match·my (and presumably Dennis's)·barebones non-interlaced NTSC driver, and would have resulted in, as Andre states,
    more intuitive mapping,·... 1:1 with actual hardware
  • AndreLAndreL Posts: 1,004
    edited 2007-08-17 23:36
    That's chip's driver, just ask him in the propeller forum about it, he will be able to answer your questions about his code best.

    Andre'
  • ericballericball Posts: 774
    edited 2007-08-21 17:37
    I don't know about the driver, but from a signal spec perspective I can give the following info:

    For non-interlaced NTSC (262 lines), the color burst phase is rising on even lines (where sync is lines 4,5,6) and falling on odd lines.
    For interlaced NTSC, the color burst phase is rising on even lines & falling on odd lines for the two fields, then falling on even lines & rising on odd lines for the next two fields.

    However, most NTSC TVs will accept any phase burst. Active color is always WRT burst. (I think the four field sequence is only necessary for VBI data like CC where which field the data is on is important.)

    PAL switches the V phase every line. On even lines burst is 135 degrees (where U is 0 and V is 90), and on even lines it is 225 degrees. On the Prop (using native color generation) if burst is color 0 then blue will be color 9 on even lines and color 7 on odd lines. (i.e. even color = burst + offset, odd color = burst - offset) There's a similar field pattern for burst phase, but it's relative to U and my head hurts thinking about it. But as long as the color phase relative to the burst phase is correct then you should be okay. Non-interlaced PAL must be an even number of lines (typically 312) or you lose color. (NTSC isn't restricted, but it doesn't change the number of lines displayed.)
  • mparkmpark Posts: 1,305
    edited 2007-08-22 17:28
    Whoa. NTSC is way more complicated than I thought.
Sign In or Register to comment.