]>
git.defcon.no Git - avrfbosd/blob - fbosd.c
aa1127a582eeb554483fc29b01ee661221b6cd53
2 #include <avr/interrupt.h>
3 #include <util/delay.h>
6 #include "video_properties.h"
10 void (*line_handler
)( void );
12 const int vres_scale
= ( SCREEN_LINES
/ VRES
-1 );
13 const int hres_bytes
= HRES
/ 8;
15 volatile uint8_t* screen_buffer
;
18 volatile int buffer_position
;
20 void Delay_ms(int cnt
)
22 while(cnt
-->0) _delay_ms(1);
25 void active_lines ( void )
35 if ( buffer_position
< ((VRES
*hres_bytes
)) )
36 buffer_position
+= hres_bytes
;
43 void blank_lines ( void )
45 if ( line
< FIRST_LINE
)
50 line_handler
= active_lines
;
61 line_handler
= &blank_lines
;
62 EIMSK
&= ~(uint8_t)(1<<INT1
);
68 // VSync is getting close to done.
69 // Set line-handler to blank-handler to count-up the undesired lines,
70 // and enable HSync interrupts.
72 line_handler
= &blank_lines
;
82 // Note: PB0 is used as CLKO outputting 20MHz clock to ATtiny
84 // Using some pins on PORTB for debug-indicator-LEDs
85 DDRB
= (1 << PB1
)|(1 << PB2
);
88 // Using pin 7 on PD to clock out pixels \o/
92 /* LM1881 pins are connected to:
93 INT0 / PCINT18 / PD2 <- VSYNC
94 INT1 / PCINT19 / PD3 <- CSYNC
95 PCINT20 / PD4 <- ODD/EVEN
97 EICRA
|= (1<<ISC01
)|(1<<ISC00
); // Select Rising-edge interrupt for VSync
98 EICRA
|= (1<<ISC11
)|(1<<ISC10
); // Select Rising-edge interrupt for HSync
99 EIMSK
|= (1<<INT0
); // Enable VSync-interrupts
101 // And enable interrupts globally.
104 // Allocate the framebuffer :D
105 screen_buffer
= (uint8_t*) malloc( hres_bytes
* VRES
* sizeof(uint8_t) );
106 // And make sure it's cleared
109 // Do some static drawing :P
111 set_pixel(92, 82, 1);
114 set_pixel(28, 82, 1);
117 draw_line(0, 0, 128, 92, 1);
118 draw_line(128, 0, 0, 92, 1);
120 draw_rect( 0, 1, 127, 91, 1);
122 draw_rect( 34, 21, 60, 50, 1);
123 _draw_rect( 24, 11, 80, 70, 1, -1);
124 draw_rect( 34, 21, 60, 50, 1);
126 fill_circle( 64,46, 45, 1 );
127 fill_circle( 64,46, 40, 0 );
129 _draw_circle( 64,46, 35, 1, -1 );
130 draw_circle( 64,46, 30, 1 );
131 fill_rect( 38, 25, 52, 42, 1);
132 fill_rect( 41, 28, 46, 36, 0);
134 //fill_rect( 54, 41, 20, 10, 0);
139 for ( int j
= 0; j
< 92; j
++ )
141 draw_line(0,0,128,j
, 2);
142 draw_line(128,0,0,j
, 2);
143 draw_line(0,92,128,92-j
, 2);
144 draw_line(128,92,0,92-j
, 2);
149 for ( int j
= 0; j
< 92; j
++ )
151 draw_line(0,0,128,j
, 2);
152 draw_line(128,0,0,j
, 2);
153 draw_line(0,92,128,92-j
, 2);
154 draw_line(128,92,0,92-j
, 2);