TITLE "pong test" SUBTITLE "video bar test" ; This code is compiled with gpasm/gplink. I know it is not pretty. Processor pic12f675 Radix DEC EXPAND include "p12f675.inc" ; ; define config fuses - note not necessarily works. ; __CONFIG (_CPD_OFF & _CP_OFF & _BODEN_OFF & _MCLRE_OFF & _PWRTE_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT & b'1111000111111111') CBLOCK 0x20 linech linecl color_sync color_black color_gray color_white condc fieldcount ENDC RESET_VECTOR CODE 0x000 restart goto start INT_VECTOR CODE 0x004 goto restart start call 0x3ff BANKSEL OSCCAL movwf OSCCAL movlw b'00000111' BANKSEL CMCON movwf CMCON movlw b'10000000' BANKSEL OPTION_REG movwf OPTION_REG BANKSEL INTCON clrf INTCON BANKSEL IOC clrf IOC BANKSEL VRCON clrf VRCON BANKSEL T1CON clrf T1CON BANKSEL ADCON0 clrf ADCON0 movlw b'00111011' BANKSEL TRISIO movwf TRISIO movlw 0xff BANKSEL GPIO movwf GPIO movlw b'00111011' movwf color_sync movlw b'00101011' movwf color_black movwf condc movlw b'00011011' movwf color_gray movlw b'00001011' movwf color_white movlw 25 movwf fieldcount BANKSEL TRISIO field_I_d4 nop ; 57 nop ; 58 nop ; 59 nop ; 60 field_I ;; start with Field I ;; Vertical sync ;; 26 µs sync, 6 µs black, repeat ;; line 1 call syn_syn ; 61 ;; line 2 call syn_syn ;; line 3 call syn_eq ;; line 4 call eq_eq ;; line 5 call eq_eq9 ; 61 nop ; 54 nop ; 55 movlw 2 ; 56 movwf linech ; 57 movlw low 305 ; 58 movwf linecl ; 59 lineout_d3 nop ; 60 nop ; 61 lineout_d1 nop ; 62 ;; line 6 to line 310 lineout movf color_sync,w ; 63 movwf TRISIO ; 0 nop ; 1 nop ; 2 movf color_black,w ; 3 movwf TRISIO ; 4 call delay4 ; 5 nop ; 9 nop ; 10 movf color_white,w ; 11 movwf TRISIO ; 12 bsf TRISIO,5 ; 13 call delay16 ; 14 movf color_gray,w ; 30 movwf TRISIO ; 31 movf color_white,w ; 32 movwf TRISIO ; 33 movf color_gray,w ; 34 movwf TRISIO ; 35 movf color_black,w ; 36 movwf TRISIO ; 37 nop ; 38 movf condc,w ; 39 movwf TRISIO ; 40 nop ; 41 nop ; 42 nop ; 43 movf color_black,w ; 44 movwf TRISIO ; 45 movf color_black,w ; 46 movwf condc ; 47 movf linecl,w ; 48 sublw 250 ; 49 btfsc STATUS,C ; 50 bcf condc,5 ; 51 nop ; 52 nop ; 53 nop ; 54 nop ; 55 nop ; 56 decfsz linecl ; 57 57 goto lineout_d3 ; 58 decfsz linech ; 59 goto lineout_d1 ; 60 ;; line 311 call eq_eq ; 61 ;; line 312 call eq_eq ; 61 ;; line 313 call eq_syn ; 61 ;; line 314 call syn_syn ;; line 315 call syn_syn ;; line 316 call eq_eq ;; line 317 call eq_eq9 ; 61 movlw 2 ; 54 movwf linech ; 55 movlw low 305 ; 56 movwf linecl ; 57 line2out_d5 nop ; 58 nop ; 59 line2out_d3 nop ; 60 nop ; 61 nop ; 62 ;; lines 318 to 622 line2out movf color_sync,w ; 63 movwf TRISIO ; 0 nop ; 1 nop ; 2 movf color_black,w ; 3 movwf TRISIO ; 4 call delay4 ; 5 nop ; 9 nop ; 10 movf color_white,w ; 11 movwf TRISIO ; 12 bsf TRISIO,5 ; 13 call delay16 ; 14 movf color_gray,w ; 30 movwf TRISIO ; 31 movf color_white,w ; 32 movwf TRISIO ; 33 movf color_gray,w ; 34 movwf TRISIO ; 35 nop ; 36 extra width movf color_black,w ; 37 movwf TRISIO ; 38 movf condc,w ; 39 movwf TRISIO ; 40 nop ; 41 nop ; 42 nop ; 43 movf color_black,w ; 44 movwf TRISIO ; 45 movf color_black,w ; 46 movwf condc ; 47 movf linecl,w ; 48 sublw 250 ; 49 btfsc STATUS,C ; 50 bcf condc,5 ; 51 nop ; 52 nop ; 53 nop ; 54 decfsz linecl ; 55 55 goto line2out_d5 ; 56 decfsz linech ; 57 goto line2out_d3 ; 58 nop ; 59 nop ; 60 ;; line 623 call eq_eq ; 61 ;; line 624 call eq_eq ; 61 ;; line 625 call eq_eq9 ; 61 ;decfsz fieldcount ; 54 nop ; 54 goto field_I_d4 ; 55 ;; equalizing pulse x 2 eq_eq movf color_sync,w ; 31 movwf TRISIO ; 0 movf color_black,w ; 1 movwf TRISIO ; 2 call delay16 ; 3 call delay8 ; 19 call delay4 ; 27 movf color_sync,w ; 31 movwf TRISIO ; 0 movf color_black,w ; 1 movwf TRISIO ; 2 call delay16 ; 3 call delay8 ; 19 return ; 27 ;; before following call; 29 ;; equalizing pulse x 2, less delay ;; outside this routine there must be 9 cycles ;; of delay, because this has only 55 cycles eq_eq9 movf color_sync,w ; 31 movwf TRISIO ; 0 movf color_black,w ; 1 movwf TRISIO ; 2 call delay16 ; 3 call delay8 ; 19 call delay4 ; 27 movf color_sync,w ; 31 movwf TRISIO ; 0 movf color_black,w ; 1 movwf TRISIO ; 2 call delay16 ; 3 nop ; 19 return ; 20 ;; before following call; 22 ;; sync pulse and equalizing pulse syn_eq movf color_sync,w ; 31 movwf TRISIO ; 0 call delay16 ; 1 call delay8 ; 17 movf color_black,w ; 25 movwf TRISIO ; 26 call delay4 ; 27 movf color_sync,w ; 31 movwf TRISIO ; 0 movf color_black,w ; 1 movwf TRISIO ; 2 call delay16 ; 3 call delay8 ; 19 return ; 27 ;; before following call; 29 ;; equalizing pulse and sync pulse eq_syn movf color_sync,w ; 31 movwf TRISIO ; 0 movf color_black,w ; 1 movwf TRISIO ; 2 call delay16 ; 3 call delay8 ; 19 call delay4 ; 27 movf color_sync,w ; 31 movwf TRISIO ; 0 call delay16 ; 1 call delay8 ; 17 movf color_black,w ; 25 movwf TRISIO ; 26 return ; 27 ;; before following call; 29 ;; sync pulse x 2 syn_syn movf color_sync,w ; 31 movwf TRISIO ; 0 call delay16 ; 1 call delay8 ; 17 movf color_black,w ; 25 movwf TRISIO ; 26 call delay4 ; 27 movf color_sync,w ; 31 movwf TRISIO ; 0 call delay16 ; 1 call delay8 ; 17 movf color_black,w ; 25 movwf TRISIO ; 26 return ; 27 ;; before following call; 29 delay16 call delay8 delay8 call delay4 delay4 return END