;--- Initialisierung ----------------------------------------------------------- STARTUP: ;Stackpointer initialisieren (ans Ende des internen RAM setzen) ldi temp,low(ramend) out spl,temp ldi temp,high(ramend) out sph,temp ;Ports initialisieren: Ein - / Ausgaberichtung ldi temp,sync_mask ; Richtungsmaske für SYNC Pin setzen out sync_dir,temp ser temp out col_dir,temp ;Startbild ldi pict,1 ; 1. Halbbild ;--- Hauptprogramm ------------------------------------------------------------- ; Generieren des Videosignals; In Schleife 2 Halbbilder ausgeben: ; 1. HALBBILD 2. HALBBILD ; 005 Zeilen VSYNC (Hauptimpulse + Nachtrabanten) 005 Zeilen VSYNC (Hauptimpulse + Nachtrabanten) ; 033 Zeilen (HSYNC --> Schwarz) 0.5 Zeilen (KEIN HSYNC --> Schwarz) ; 256 Zeilen (HSYNC --> Video) 033 Zeilen (HSYNC --> Schwarz) ; 016 Zeilen (HSYNC --> Schwarz) 256 Zeilen (HSYNC --> Video) ; 2.5 Zeilen VSYNC (Vortrabanten) 015 Zeilen (HSYNC --> Schwarz) ; 0.5 Zeilen (HSYNC --> Schwarz) ; 2.5 Zeilen VSYNC (Vortrabanten VSYNC1: ;---------------------------------------------- ;VSYNC1 Hauptimpulse und Nachtrabanten ;---------------------------------------------- ;5 Zeilen VSYNC (Hauptimpulse + Nachtrabanten) ;5 Takte bis Impulsbeginn (--> neues Halbbild beginnt in 5 Takten) rcall mainpulse ;nächster Impulsbeginn in 529 Takten --> 524 Takte warten nop nop ldi temp,174 rcall wait rcall subpulse ;Impulsende in 529 Takten ;Wenn 2. Halbbild: 0.5 Zeilen KEIN HSYNC --> Schwarz ;--> 1. Halbbild: 529 Takte warten ;--> 2. Halbbild: 1105 Takte warten ldi temp,150 ;450 Takte warten rcall wait nop ldi temp,25 sbrs pict,0 ;Wartezeit um 576 Takte erhöhen, wenn 2. Halbbild ldi temp,217 nop rcall wait ;---------------------------------------------- ;LINES Videodaten (304 Zeilen) ;---------------------------------------------- ;304 Zeilen Video ldi r17,52 lin0_loop: rcall LINE_BLACK dec r17 brne lin0_loop ldi r17,64 lin1_loop: rcall LINE_WHITE3 dec r17 brne lin1_loop ldi r17,22 lin2_loop: rcall LINE_BLACK dec r17 brne lin2_loop ldi r17,23 lin6_loop: rcall LINE_WHITE2 dec r17 brne lin6_loop ldi r17,32 lin5_loop: rcall LINE_BLACK dec r17 brne lin5_loop ldi r17,96 lin3_loop: rcall LINE_WHITE dec r17 brne lin3_loop ldi r17,15 lin4_loop: rcall LINE_BLACK dec r17 brne lin4_loop ;---------------------------------------------- ;VSYNC2 Vortrabanten ;---------------------------------------------- ;Wenn 1. Halbbild: 1 Zeile HSYNC --> SCHWARZ ;Wenn 2. Halbbild: 0.5 Zeilen HSYNC --> SCHWARZ nop ;23 Takte warten nop ldi temp,7 rcall wait ;HSYNC begann vor 23 Takten rcall hsync ;529 Takte bis 99 HSYNC Ende --> bis Vortrabanten: 1035 Takte wenn 1., 459 Takte wenn 2. Halbbild ldi temp,110 ;330 Takte warten rcall wait nop ldi temp,40 sbrc pict,0 ;Wartezeit um 576 Takte erhöhen, wenn 1. Halbbild ldi temp,232 nop rcall wait ;2.5 Zeilen VSYNC (Vorttrabanten) --> 5x ;5 Takte bis Vorttrabanten rcall subpulse ;529 Takte bis nächstes Halbbild inc pict ;nächstes Halbbild = 1. oder 2.? andi pict,1 nop ;520 Takte warten ldi temp,173 rcall wait ;7 Takte bis nächstes Halbbild rjmp VSYNC1 ;nächstes Halbbild ;--- Nebenimpulse -------------------------------------------------------------- ; vor CALL: genau 5 Takte bis Impulsbeginn ; nach RET: genau 529 Takte bis Impulsende ; Register: R16,R17 SUBPULSE: ; 03 Takte für Aufruf ldi r17,4 ; 01 subpulse_loop: cbi sync_port,sync_bit ; 2.35µs = 42 Takte SYNC = LO nop ldi temp,13 rcall wait sbi sync_port,sync_bit ; 29.65µs = 534 Takte SYNC = HI nop ldi temp,176 rcall wait dec r17 ; nächster brne subpulse_loop nop cbi sync_port,sync_bit ; 2.35µs = 42 Takte SYNC = LO nop ldi temp,13 rcall wait sbi sync_port,sync_bit ; 29.65µs = 534 Takte SYNC = HI ret ; 04 Rückkehr ;--- Hauptimpulse -------------------------------------------------------------- ; vor CALL: genau 5 Takte bis Impulsbeginn ; nach RET: genau 80 Takte bis Impulsende ; Register: R16,R17 MAINPULSE: ; 03 Takte für Aufruf ldi r17,4 ; 01 mainpulse_loop: cbi sync_port,sync_bit ; 27.3µs = 491 Takte Sync = LO ldi temp,163 rcall wait sbi sync_port,sync_bit ; 4.7µs = 85 Takte Sync = HI nop nop ldi temp,26 rcall wait dec r17 brne mainpulse_loop nop cbi sync_port,sync_bit ; 27.3µs = 491 Takte Sync = LO ldi temp,163 rcall wait sbi sync_port,sync_bit ; 4.7µs = 85 Takte Sync = HI ret ; 04 Rückkehr ;--- HSYNC --------------------------------------------------------------------- ; vor CALL: Impulsbeginn genau 23 Takte her ; nach RET: genau 99 Takte bis Impulsende ; Register: R16 HSYNC: ; 03 Takte für Aufruf cbi sync_port,sync_bit ; 4.7µs = 85 Takte Sync = LO nop nop ldi temp,27 rcall wait sbi sync_port,sync_bit ; 5.8µs = 104 Takte SYNC = HI ret ; 04 ;--- Wait ---------------------------------------------------------------------- ; von Aufruf bis Rückkehr genau 3*R16-1 Takte warten ; R16 = 4..259(3) --> Wartezeit = 11 bis 776 Takte ; Register: R16 WAIT: ; 03 Takte für Aufruf benötigt subi r16,3 ; 01 Taktausgleich; 9 Takte subtrahieren wait_loop: ; R16 x 3 Takte warten dec r16 brne wait_loop nop ret ; 04 Rückkehr ;Aufruf : 1 Takte nach HSYNC ;Rückkehr: 2 Takte vor nächstem HSYNC ; 1149 Takte / Zeile LINE_BLACK: ;HSYNC vor 4 Takten --> 19 Takte "Restschwarz" ldi temp,0 out col_port,temp nop nop ldi temp,5 rcall wait rcall hsync ;99+59 Takte Schwarz nop nop ldi temp,52 rcall wait ;818 Takte Video nop nop ldi temp,200 rcall wait ldi temp,72 rcall wait ;nächstes HSync in 59 Takten --> 53 Takte warten ;26 Takte warten ldi temp,0 out col_port,temp ldi temp,17 rcall wait ret LINE_WHITE: ;HSYNC vor 4 Takten --> 19 Takte "Restschwarz" ldi temp,0 out col_port,temp nop nop ldi temp,5 rcall wait rcall hsync ;99+59 Takte Schwarz nop nop ldi temp,82 rcall wait ;818 Takte Video ldi temp,1 out col_port,temp ldi temp,200 rcall wait ldi temp,12 rcall wait ;nächstes HSync in 59 Takten --> 53 Takte warten ;26 Takte warten ldi temp,0 out col_port,temp ldi temp,47 rcall wait ret LINE_WHITE2: ;HSYNC vor 4 Takten --> 19 Takte "Restschwarz" ldi temp,0 out col_port,temp nop nop ldi temp,5 rcall wait rcall hsync ;99+59 Takte Schwarz ldi temp,58 rcall wait ;818 Takte Video ldi r22,130 test: mov r21,r22 add r21,r17 out col_port,r21 dec r22 brne test nop nop ldi temp,0 out col_port,temp ldi temp,23 rcall wait ret LINE_WHITE3: ;HSYNC vor 4 Takten --> 19 Takte "Restschwarz" ldi temp,0 out col_port,temp nop nop ldi temp,5 rcall wait rcall hsync ;99+59 Takte Schwarz nop nop ldi temp,82 rcall wait ;818 Takte Video ldi temp,1 out col_port,temp ldi temp,0 out col_port,temp nop ldi temp,1 out col_port,temp nop ldi temp,0 out col_port,temp nop ldi temp,1 out col_port,temp nop ldi temp,0 out col_port,temp nop ldi temp,1 out col_port,temp nop ldi temp,0 out col_port,temp nop ldi temp,1 out col_port,temp nop ldi temp,0 out col_port,temp nop ldi temp,1 out col_port,temp nop ldi temp,0 out col_port,temp nop ldi temp,1 out col_port,temp nop ldi temp,188 rcall wait ldi temp,12 rcall wait ;nächstes HSync in 59 Takten --> 53 Takte warten ;26 Takte warten ldi temp,0 out col_port,temp ldi temp,47 rcall wait ret