PDA

View Full Version : Composite NTSC Video



mcglacy
- 3rd March 2008, 10:29
hi!

below is a working codes for generating composite ntsc video, Can anyone convert this code to PicBasic or C
Thank you in advance!


;************************************************* *****

list p=16F84,r=hex

__config 0x3FFA

w equ 0
f equ 1
pcl equ 0x02

status equ 0x03
porta equ 0x05
portb equ 0x06
indf equ 0x00
fsr equ 0x04
eedata equ 0x08
eeadr equ 0x09
;eecon1 equ 0x08

rd equ 0
rp0 equ 5



counter0 equ 0x12
counter1 equ 0x13
counter2 equ 0x14
videostuff equ 0x15
line equ 0x16
pl equ 0x17
counter5 equ 0x18
delaycnt equ 0x19

counter3 equ 0x1C
counter4 equ 0x1D

stuff equ 0x21
strptr equ 0x22
strptr2 equ 0x23
stringbuff equ 0x24






delay MACRO
LOCAL label
movwf delaycnt
label decfsz delaycnt,f
goto label
ENDM

dnop MACRO
LOCAL label
label goto label+1
ENDM





;org 0x000
goto menu

table
numbers addwf pcl,f

;A

retlw 0x3C
retlw 0x66
retlw 0x66
retlw 0x66
retlw 0x7E
retlw 0x66
retlw 0x66
retlw 0x0

;B

retlw 0x3E
retlw 0x66
retlw 0x66
retlw 0x3E
retlw 0x66
retlw 0x66
retlw 0x3E
retlw 0x0

;C

retlw 0x7C
retlw 0x06
retlw 0x06
retlw 0x06
retlw 0x06
retlw 0x06
retlw 0x7C
retlw 0x0


;D

retlw 0x3E
retlw 0x66
retlw 0x66
retlw 0x66
retlw 0x66
retlw 0x66
retlw 0x3E
retlw 0x0

;E

retlw 0x7E
retlw 0x06
retlw 0x06
retlw 0x7E
retlw 0x06
retlw 0x06
retlw 0x7E
retlw 0x0


;F
retlw 0x7E
retlw 0x06
retlw 0x06
retlw 0x7E
retlw 0x06
retlw 0x06
retlw 0x06
retlw 0x0

;G
retlw 0x7C
retlw 0x06
retlw 0x06
retlw 0x76
retlw 0x66
retlw 0x66
retlw 0x5C
retlw 0x0


;H

retlw 0x66
retlw 0x66
retlw 0x66
retlw 0x7E
retlw 0x66
retlw 0x66
retlw 0x66
retlw 0x0


;I

retlw 0x3C
retlw 0x18
retlw 0x18
retlw 0x18
retlw 0x18
retlw 0x18
retlw 0x3C
retlw 0x0


;J

retlw 0x60
retlw 0x60
retlw 0x60
retlw 0x66
retlw 0x66
retlw 0x66
retlw 0x3C
retlw 0x0


;K
retlw 0x66
retlw 0x66
retlw 0x36
retlw 0x1E
retlw 0x36
retlw 0x66
retlw 0x66
retlw 0x0

;L
retlw 0x06
retlw 0x06
retlw 0x06
retlw 0x06
retlw 0x06
retlw 0x06
retlw 0x7E
retlw 0x0

;M
retlw 0x82
retlw 0xC6
retlw 0xEE
retlw 0xFE
retlw 0xD6
retlw 0xC6
retlw 0xC6
retlw 0x0

;N
retlw 0x62
retlw 0x66
retlw 0x6E
retlw 0x7E
retlw 0x76
retlw 0x66
retlw 0x46
retlw 0x0

;O
retlw 0x3C
retlw 0x66
retlw 0x66
retlw 0x66
retlw 0x66
retlw 0x66
retlw 0x3C
retlw 0x0

;P
retlw 0x3E
retlw 0x66
retlw 0x66
retlw 0x66
retlw 0x3E
retlw 0x06
retlw 0x06
retlw 0x0

;Q
retlw 0x3C
retlw 0x66
retlw 0x66
retlw 0x66
retlw 0x76
retlw 0x36
retlw 0x5C
retlw 0x0

;R
retlw 0x3E
retlw 0x66
retlw 0x66
retlw 0x66
retlw 0x3E
retlw 0x66
retlw 0x66
retlw 0x0

;S
retlw 0x7C
retlw 0x06
retlw 0x0E
retlw 0x3C
retlw 0x78
retlw 0x60
retlw 0x3E
retlw 0x0

;T
retlw 0x7E
retlw 0x18
retlw 0x18
retlw 0x18
retlw 0x18
retlw 0x18
retlw 0x18
retlw 0x0

;U
retlw 0x66
retlw 0x66
retlw 0x66
retlw 0x66
retlw 0x66
retlw 0x66
retlw 0x3C
retlw 0x0

;V
retlw 0x66
retlw 0x66
retlw 0x66
retlw 0x66
retlw 0x24
retlw 0x3C
retlw 0x18
retlw 0x0

;W
retlw 0xB6
retlw 0xB6
retlw 0xB6
retlw 0xB6
retlw 0xB6
retlw 0xFE
retlw 0x6C
retlw 0x0

;X
retlw 0x66
retlw 0x66
retlw 0x3C
retlw 0x18
retlw 0x3C
retlw 0x66
retlw 0x66
retlw 0x0

;Y
retlw 0x66
retlw 0x66
retlw 0x66
retlw 0x66
retlw 0x3C
retlw 0x18
retlw 0x18
retlw 0x0

;Z
retlw 0x7E
retlw 0x70
retlw 0x38
retlw 0x1C
retlw 0x0E
retlw 0x06
retlw 0x7E
retlw 0x0



; space
retlw 0x0
retlw 0x0
retlw 0x0
retlw 0x0
retlw 0x0
retlw 0x0
retlw 0x0
retlw 0x0







l_A EQU 0x00
l_B EQU 0x08
l_C EQU 0x10
l_D EQU 0x18
l_E EQU 0x20
l_F EQU 0x28
l_G EQU 0x30
l_H EQU 0x38
l_I EQU 0x40
l_J EQU 0x48
l_K EQU 0x50
l_L EQU 0x58
l_M EQU 0x60
l_N EQU 0x68
l_O EQU 0x70
l_P EQU 0x78
l_Q EQU 0x80
l_R EQU 0x88
l_S EQU 0x90
l_T EQU 0x98
l_U EQU 0xA0
l_V EQU 0xA8
l_W EQU 0xB0
l_X EQU 0xB8
l_Y EQU 0xC0
l_Z EQU 0xC8
l_space EQU 0xD0


shortsync movwf counter1
shortsync_l0 bcf porta,0 ;2us sync
bcf portb,0
dnop
movlw 0x1D ;30us black
movwf counter2
nop
bsf porta,0
shortsync_l1 decfsz counter2,f
goto shortsync_l1
decfsz counter1,f
goto shortsync_l0
retlw 5



vertsync movlw 5
btfss videostuff,0
movlw 6
call shortsync
incf videostuff,f

longsync movwf counter1
longsync_l0 movlw 0x1D
movwf counter2
bcf porta,0 ;30 us sync
bcf portb,0
longsync_l1 decfsz counter2,f
goto longsync_l1
nop ;2us black
bsf portb,0
nop
decfsz counter1,f
goto longsync_l0

movlw 5
btfss videostuff,0
movlw 4
call shortsync
return







emptycharline movlw 0x10 - 2 ;17 black lines
dnop
emptylines movwf counter1
dnop
nop
ell bcf porta,0
bcf portb,0
movlw 3
delay
movlw 0x7
bsf porta,0
delay
btfsc stuff,0
bsf portb,0


movlw 0x2F
delay
decfsz counter1,f
goto ell
nop
bcf porta,0
goto syncret



menu bcf stuff,0

movwf counter4
movlw 0x0E
tris porta

menul movlw 0x00
tris portb
call vertsync ;do vertical retrace
call emptycharline
call emptycharline
call emptycharline
movlw a_str
dnop
call printstring
call emptycharline
dnop
movlw b_str
call printstring
call emptycharline

movlw c_str
call printstring
call emptycharline
dnop
movlw d_str
call printstring
call emptycharline
movfw counter4

dnop
call printstring
dnop
movlw 0x3E
call emptylines
movlw 0xff
movwf portb
movlw 0xFE
tris portb
movfw counter4

movlw e_str ;5th line

bcf portb,0
movwf counter4
movlw 3
delay
bsf portb,0
movlw 59
delay

goto menul



printstring movwf strptr
clrf line
movlw 0x08
movwf counter1

printstrl0 bcf porta,0
movlw 0x08
movwf counter0
movlw stringbuff
movwf fsr
movfw strptr
movwf eeadr
dnop
dnop
nop
bsf porta,0
prnstrl1 bsf status,rp0
bsf eecon1,rd
bcf status,rp0
movfw eedata
addwf line,w
call table
movwf indf
incf fsr,f
incf eeadr,f
decfsz counter0,f
goto prnstrl1
movlw 0xE
delay
incf line,f
bcf porta,0

movlw 0x08
movwf counter0
movlw stringbuff
movwf fsr
movlw 2
delay
bsf porta,0
movlw 0xD ;22us black + 8us black col brst
delay
prnstrl2 movfw indf
movwf portb
rrf portb,f
rrf portb,f
rrf portb,f
rrf portb,f
rrf portb,f
rrf portb,f
rrf portb,f
bcf portb,0
incf fsr,f
decfsz counter0,f
goto prnstrl2
movlw 0x8 ;22us black
delay
decfsz counter1,f
goto printstrl0
nop
bcf porta,0
goto syncret

syncret movlw 2
delay
nop
bsf porta,0
movlw 0x38
delay
return

org 0x2100





a_str equ 0x0
dw l_A
dw l_B
dw l_C
dw l_D
dw l_E
dw l_F
dw l_G
dw l_H

b_str equ 0x8
dw l_I
dw l_J
dw l_K
dw l_L
dw l_M
dw l_N
dw l_O
dw l_P

c_str equ 0x10
dw l_Q
dw l_R
dw l_S
dw l_T
dw l_U
dw l_V
dw l_W
dw l_X

d_str equ 0x18
dw l_Y
dw l_Z
dw l_space
dw l_space
dw l_space
dw l_space
dw l_space
dw l_space

e_str equ 0x20
dw l_space
dw l_space
dw l_space
dw l_space
dw l_space
dw l_space
dw l_space
dw l_space
end

;************************************************* **