Created
October 11, 2015 05:54
-
-
Save cbmeeks/f66b8a9f096abd2ffc07 to your computer and use it in GitHub Desktop.
Minimal NTSC Template for Propeller -- NON Interlace (262 lines)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CON | |
_CLKMODE = RCSlow ' Start prop in RCSlow mode internal crystal | |
PUB main | |
clkset(%01101000, 12_000_000) ' Set internal oscillator to RCFast and set PLL to start | |
waitcnt(cnt+120_000) ' wait approx 10ms at 12mhz for PLL to 'warm up' | |
clkset( %01101111, 80_000_000 ) ' 80MHz (5MHz PLLx16) | |
coginit( COGID, @cogstart, @cogstart ) | |
DAT | |
org 0 | |
cogstart | |
mov vcfg, ivcfg ' Sets up the parameters for video generation | |
mov ctra, ictra ' internal PLL mode, PLLA = 16 * colorburst frequency | |
mov frqa, ifrqa ' 2 * colorburst frequency | |
mov dira, idira ' Sets pin directions | |
mainloop | |
mov numline, #9 ' 9 lines of vsync | |
vsync0 | |
cmp numline, #6 wz ' lines 4,5,6 serration pulses | |
if_nz cmp numline, #5 wz ' lines 1,2,3 / 7,8,9 equalizing pulses | |
if_nz cmp numline, #4 wz ' | |
mov count, #2 ' 2 pulses per line | |
:half | |
if_nz mov VSCL, vscleqal ' equalizing pulse (short) | |
if_z mov VSCL, vsclselo ' serration pulse (long) | |
waitvid sync, #0 ' -40 IRE | |
if_nz mov VSCL, vscleqhi ' equalizing pulse (long) | |
if_z mov VSCL, vsclsync ' serration pulse (short) | |
waitvid sync, blank ' 0 IRE | |
djnz count, #:half | |
djnz numline, #vsync0 | |
mov numline, #12 ' 12 blank lines | |
blank0 | |
mov VSCL, vsclsync | |
waitvid sync, #0 ' -40 IRE | |
mov VSCL, vsclblnk | |
waitvid sync, blank ' 0 IRE | |
djnz numline, #blank0 | |
mov numline, #241 ' 241 lines of active video | |
active | |
mov VSCL, vsclsync ' horizontal sync (0H) | |
waitvid sync, #0 ' -40 IRE | |
mov VSCL, vscls2cb ' 5.3us 0H to burst | |
waitvid sync, blank | |
mov VSCL, vsclbrst ' 9 cycles of colorburst | |
waitvid sync, burst | |
mov VSCL, vsclbp ' backporch 9.2us OH to active video | |
waitvid sync, blank | |
'----------------------------------------------------------------------------------------------- | |
' VISIBLE SCAN LINE START | |
'----------------------------------------------------------------------------------------------- | |
movd :loop, #colors ' initialize pointer | |
mov count, #(17*6+2)/4 ' number of WAITVIDs | |
mov VSCL, vsclactv ' PLLA per pixel, 4 pixels per frame | |
:loop | |
waitvid colors, #%%3210 | |
add :loop, d1 | |
djnz count, #:loop | |
'----------------------------------------------------------------------------------------------- | |
' VISIBLE SCAN LINE END | |
'----------------------------------------------------------------------------------------------- | |
mov VSCL, vsclfp ' front porch 1.5us | |
waitvid sync, blank | |
djnz numline, #active | |
jmp #mainloop | |
'----------------------------------------------------------------------------------------------- | |
' CONFIG DATA | |
'----------------------------------------------------------------------------------------------- | |
ivcfg long %0_11_1_0_1_000_00000000000_001_0_01110000 ' demoboard | |
ictra long %0_00001_110_00000000_000000_000_000000 ' NTSC | |
ifrqa long $16E8_BA2F ' (7,159,090.9Hz/80MHz)<<32 NTSC demoboard & Hydra | |
idira long $0000_7000 ' demoboard | |
sync LONG $8A0200 ' %%0 = -40 IRE, %%1 = 0 IRE, %%2 = burst | |
blank LONG %%1111_1111_1111_1111 ' 16 pixels color 1 | |
burst LONG %%2222_2222_2222_2222 ' 16 pixels color 1 | |
vscleqal long 1<<12+135 ' NTSC sync/2 | |
vsclsync long 1<<12+269 ' NTSC sync = 4.7us | |
vsclblnk long 1<<12+3371 ' NTSC H-sync | |
vsclselo long 1<<12+1551 ' NTSC H/2-sync | |
vscleqhi long 1<<12+1685 ' NTSC H/2-sync/2 | |
vscls2cb long 1<<12+304-269 ' NTSC sync to colorburst | |
vsclbrst long 16<<12+16*9 ' NTSC 16 PLLA per cycle, 9 cycles of colorburst | |
vsclbp long 1<<12+(527-304-16*9)+213' NTSC back porch + overscan (213) | |
vsclactv long 25<<12+25*4 ' NTSC 25 PLLA per pixel, 4 pixels per frame | |
vsclfp long 1<<12+214+86 ' NTSC overscan (214) + front porch | |
numline long $0 | |
count long $0 | |
d1 long 1<<9 | |
colors | |
byte $02 ' LONG padding | |
byte $07, $06, $05, $04, $03, $02 ' white to black (6 levels) | |
BYTE $0B, $0C, $0D, $0E, $8F, $88 ' 16 hues, 6 shades/hue | |
BYTE $1B, $1C, $1D, $1E, $9F, $98 | |
BYTE $2B, $2C, $2D, $2E, $AF, $A0 | |
BYTE $3B, $3C, $3D, $3E, $BF, $B8 | |
BYTE $4B, $4C, $4D, $4E, $CF, $C8 | |
BYTE $5B, $5C, $5D, $5E, $DF, $D8 | |
BYTE $6B, $6C, $6D, $6E, $EF, $E8 | |
BYTE $7B, $7C, $7D, $7E, $FF, $F8 | |
BYTE $8B, $8C, $8D, $8E, $0F, $08 | |
BYTE $9B, $9C, $9D, $9E, $1F, $18 | |
BYTE $AB, $AC, $AD, $AE, $2F, $28 | |
BYTE $BB, $BC, $BD, $BE, $3F, $38 | |
BYTE $CB, $CC, $CD, $CE, $4F, $48 | |
BYTE $DB, $DC, $DD, $DE, $5F, $58 | |
BYTE $EB, $EC, $ED, $EE, $6F, $68 | |
BYTE $FB, $FC, $FD, $FE, $7F, $78 | |
byte $02 ' LONG padding | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment