Shop OBEX P1 Docs P2 Docs Learn Events
P2 Tile Driver for PAL Composite Video? — Parallax Forums

P2 Tile Driver for PAL Composite Video?

Hi,
is there a simple :) tile driver for a composite video signal for a PAL monitor for P2?
To hopefully be able to understand it and for the reason to have low memory hunger, I would be happy with black and white or greyscale.
My P2 is running at 200MHz.
Thanks a lot, Christof

Comments

  • RaymanRayman Posts: 16,221

    I've got a VGA tile driver for 1080p. Suppose that could be converted to composite...

    Usages is fairly simple, a bit like P1 tile driver.
    But, the driver itself is not simple...

  • Wuerfel_21Wuerfel_21 Posts: 5,827
    edited 2026-04-02 17:05

    @rogloh 's video driver can do text mode with PAL output if you want something that just works, but that one's very complicated.
    My VNG driver set (MegaVGA etc) also does PAL (60Hz variant only) and the code is slightly less complex, but it exclusively displays line buffers that another cog needs to be rendering.

    Other than that I don't think anyone did PAL.

    Putting together a basic driver yourself is only slightly more complex than e.g. VGA. (I think I posted an example of that ages ago? Anyways it's like 5 minutes trivial)

    For the simplest case of non-interlaced non-color, you just need to generate the same old ...->active->front porch->hsync->back porch->.. sequence for regular lines and a long sync pulse for the VSync lines. (though you technically can't call that PAL at all, it'll work). Just need to get the timing right.

    Color requires splitting the back porch into 3 segments: the breezeway, color burst and the remaining back porch that doesn't have a catchy name. The hardware does the modulation for you, you just need to send the right "color" during burst (see below). For PAL (as opposed to NTSC) you also need to alternate the CY register between two values. Slightly tricky because CSC register are NOT buffered like the streamer commands are, so you need to change it at a time where you know that you're in blanking. I recommend doing it shortly after putting the HSync pulse command into the streamer (this ensures the streamer is in front porch)

    These are the CY/CI/CQ register settings I use for NTSC and PAL (slightly cleaned up for clarity). You can't actually reach the correct levels for the summed luma+chroma signal with the 75Ω DAC mode (P_DAC_75R_2V), so these are designed for use with P_DAC_124R_3V mode.
    This is partially result of trial and error to get good colors on a variety of monitors, but everyone else's values (especially on the NTSC side) just look worse or cause issues. And you all know my perfectionism...
    (For monochrome only, you'd simply set the IQSCALE constant to zero, then it'll not bother you)

    CON  ' CSC constant calculation
    
        ONE_IRE = 255.0 / 180.0
    
        BLANKING_LEVEL = ONE_IRE*40.0
        PEDESTAL = 0.0 'ONE_IRE*7.5 ' NTSC only, other standards (including NTSC-J) don't have pedestal
    
        BLANK_LEVEL = round(BLANKING_LEVEL)
    
        B2W_NTSC = ONE_IRE*100.0 - PEDESTAL
        YSCALE_NTSC = 127.0*(B2W_NTSC/255.0)
        IQSCALE_NTSC = YSCALE_NTSC * 1.33
    
        B2W_PAL = ONE_IRE*100.0
        YSCALE_PAL = 127.0*(B2W_PAL/255.0)
        IQSCALE_PAL = YSCALE_PAL * 1.33 ' Can't set correct amplitude (around 1.47) because weird overflow?
    
        CY_NTSC      = (round(0.299*YSCALE_NTSC)&$FF)<<24 + (round(0.587*YSCALE_NTSC)&$FF)<<16 + (round(0.114*YSCALE_NTSC)&$FF)<<8 + round(BLANKING_LEVEL+PEDESTAL)
        CI_NTSC      = (round(+0.5959*IQSCALE_NTSC)&$FF)<<24 + (round(-0.2746*IQSCALE_NTSC)&$FF)<<16 + (round(-0.3216*IQSCALE_NTSC)&$FF)<<8 + round(BLANKING_LEVEL)
        CQ_NTSC      = (round(+0.2115*IQSCALE_NTSC)&$FF)<<24 + (round(-0.5227*IQSCALE_NTSC)&$FF)<<16 + (round(+0.3112*IQSCALE_NTSC)&$FF)<<8 + 128
    
        CY_PAL      = (round(0.299*YSCALE_PAL)&$FF)<<24 + (round(0.587*YSCALE_PAL)&$FF)<<16 + (round(0.114*YSCALE_PAL)&$FF)<<8 + round(BLANKING_LEVEL)
        CI_PAL      = (round(-0.147*IQSCALE_PAL)&$FF)<<24 + (round(-0.289*IQSCALE_PAL)&$FF)<<16 + (round(+0.436*IQSCALE_PAL)&$FF)<<8 + round(BLANKING_LEVEL)
        CQ_PAL_ODD  = (round(+0.615*IQSCALE_PAL)&$FF)<<24 + (round(-0.515*IQSCALE_PAL)&$FF)<<16 + (round(-0.100*IQSCALE_PAL)&$FF)<<8 + 128
        CQ_PAL_EVEN = (round(-0.615*IQSCALE_PAL)&$FF)<<24 + (round(+0.515*IQSCALE_PAL)&$FF)<<16 + (round(+0.100*IQSCALE_PAL)&$FF)<<8 + 128
    
    
        COLOR_BURST_NTSC  = $7C9900_01
        COLOR_BURST_PAL   = $D8A351_01
    
Sign In or Register to comment.