; NTSC Video output list p=16f84, f=inhx8m include #define BANK0 bcf STATUS, RP0 ; Switches banks #define BANK1 bsf STATUS, RP0 #define dnop goto $+1 temp EQU 0x0C temp2 EQU 0x0D state EQU 0x0E interlace EQU 1 org 0 BANK1 clrf TRISA clrf TRISB BANK0 clrf PORTB clrf PORTA bcf state, interlace FrameLoop ; Step one: Generate 3 lines of vertical interval call vertserr call vertserr call vertserr call vertserr call vertserr call vertserr ; Step two: Generate 3 lines of equalization pulses call eqpulse call eqpulse call eqpulse call eqpulse call eqpulse call eqpulse ; Step three: generate 10 black(nothing there) lines movlw .10 movwf temp2 VLoopB call blackline decfsz temp2, f goto VLoopB ; Step four: Generate 243 video lines movlw .121 movwf temp2 VLoopC call blackline decfsz temp2, f goto VLoopC movlw .121 movwf temp2 VLoop call blankline decfsz temp2, f goto VLoop call blankline ; Step five: generate half line if even dnop ; btfss state, interlace ; call halfline ; Step six: wait out the front porch of the last horz line (since we are calling eq pulse) dnop dnop ; Step seven: generate 3 lines of eq pulses call eqpulse call eqpulse call eqpulse call eqpulse call eqpulse call eqpulse goto FrameLoop ; blankline: Call this from a loop without any loss of timing ; call one after another with 3 cycle delay in between blankline ;141 call hsync ;159 ;12 bsf PORTB, 0 ; video is ON ; delay for 120 cycles movlw .40 movwf temp Loopbl decfsz temp, f goto Loopbl ;133 bcf PORTB, 0 ;134 return ;136 ; decfsz xxx 137 ; goto xxx 139 ; blackline: Call this to get a completely black line blackline call hsync movlw .40 movwf temp Loopbk decfsz temp, f goto Loopbk dnop return ; halfline: generate half line of video halfline ;61 call hsync ;79 ;12 bsf PORTB, 0 ; video is ON ; delay for 40 movlw 10 movwf temp Loophl nop decfsz temp, f goto Loophl ;53 bcf PORTB, 0 ;54 return ;56 ; decfsz xxx 57 ; goto xxx 59 ; eqpulse: generates the equalizing pulse eqpulse bcf PORTA, 0 ; Pulse is 2.8uS wide dnop dnop dnop nop bsf PORTA, 0 ; 1 movlw .22 ; 2 movwf temp ; 3 loopeq decfsz temp, f goto loopeq ; 69 return ; 71 ; call eqpulse ; 73 ; vertser: generates the serration vertserr bcf PORTA, 0 ; 1 movlw .21 ; 2 movwf temp ; 3 loopser decfsz temp, f goto loopser ; 66 dnop ; 68 bsf PORTA, 0 dnop ; 2 dnop ; 4 dnop ; 6 dnop ; 8 return ; 10 ; call vertserr ; 12 ; hsync: Generates the horizontal sync tip, and also the front and back porch. ; 12 instruction cycles from sync hi to return. 18 from call to sync hi. hsync ;2 dnop ; H Front porch is 1.6 ms, so wait 4 cycles(2 thru call);4 bcf PORTA, 0 ; HSync width is 4.8 ms, so wait 12 cycles ;5 dnop ;7 dnop ;9 dnop ;11 dnop ;13 dnop ;15 dnop ;17 bsf PORTA, 0 ; H Back Porch is 4.8 ms, so wait 12 cycles ;18 dnop ;20 dnop ;22 dnop ;24 dnop ;26 dnop ;28 return ; Return is 2 cycles ;30 end