videochargen/main.c

56 lines
2.0 KiB
C
Raw Normal View History

#include <avr/io.h>
#include <avr/interrupt.h>
2021-07-03 13:02:01 +00:00
#include "const.h"
#include <string.h>
2021-07-03 13:02:01 +00:00
2021-07-03 13:44:01 +00:00
volatile uint16_t frame;
volatile uint16_t line;
volatile char line_buffer[LINE_BUFFER_SIZE];
ISR(INT0_vect, ISR_NAKED) {
asm("jmp int_vertical_sync");
}
ISR(INT1_vect, ISR_NAKED) {
asm("jmp int_horizontal_sync");
}
ISR(TIMER0_COMPA_vect, ISR_NAKED) {
asm("jmp int_timer_0");
}
2021-07-03 13:02:01 +00:00
2021-07-03 13:44:01 +00:00
void setup_c() {
/*
2021-07-03 13:02:01 +00:00
for (int i = 0; i < LINE_BUFFER_SIZE; ++i) {
line_buffer[i] = (i % 2) ? 0x0 : 0xff;
}
2021-07-03 13:44:01 +00:00
*/
}
void loop_c() {
for (;;) {
const int current_line = line;
switch (current_line) {
case 76: case 134: memcpy(line_buffer, "AAAAAAAAAAAAAAAAAAAAAA", 22); break;
case 80: memcpy(line_buffer, "11111111AAAA1111111111", 22); break;
case 84: memcpy(line_buffer, "111111111AAA1111111111", 22); break;
case 88: case 98: memcpy(line_buffer, "11AAAAA111AA11AAAAAAAA", 22); break;
case 92: memcpy(line_buffer, "11AAAAAA11AA11AAAAAAAA", 22); break;
case 102: memcpy(line_buffer, "111111111AAA11111111AA", 22); break;
case 106: memcpy(line_buffer, "11111111AAAA11111111AA", 22); break;
case 110: memcpy(line_buffer, "11A111AAAAAA11AAAAAAAA", 22); break;
case 114: memcpy(line_buffer, "11AA111AAAAA11AAAAAAAA", 22); break;
case 118: memcpy(line_buffer, "11AAA111AAAA11AAAAAAAA", 22); break;
case 122: memcpy(line_buffer, "11AAAA111AAA11AAAAAAAA", 22); break;
case 126: memcpy(line_buffer, "11AAAAA111AA1111111111", 22); break;
case 130: memcpy(line_buffer, "11AAAAAA11AA1111111111", 22); break;
}
line_buffer[60] = (current_line > 50 && current_line < 100) ? WHITE : BLACK;
if (current_line > 200 && current_line % 8 == 0) {
2021-07-03 13:44:01 +00:00
const uint8_t current_number = frame >> 2;
for (uint8_t i = 0; i < 8; ++i) {
line_buffer[i] = ((current_number >> i) & 0x1) ? WHITE : BLACK;
}
}
}
2021-07-03 13:02:01 +00:00
}