videochargen/main.c

100 lines
3.5 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>
#include "char_rom.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() {
const char* text = "1010 RETROFF";
const text_len = strlen(text);
2021-07-03 13:44:01 +00:00
for (;;) {
const int current_line = line;
if (current_line < 76) {
memset(line_buffer, 0, LINE_BUFFER_SIZE);
} else if (current_line < 80) {
for (uint8_t i = 0; i < text_len; ++i) {
memcpy(line_buffer + 12 * i, char_rom + (text[i] - '0') * 14 + 0, 10);
}
} else if (current_line < 88) {
for (uint8_t i = 0; i < text_len; ++i) {
memcpy(line_buffer + 12 * i, char_rom + (text[i] - '0') * 14 + 10, 10);
}
} else if (current_line < 96) {
for (uint8_t i = 0; i < text_len; ++i) {
memcpy(line_buffer + 12 * i, char_rom + (text[i] - '0') * 14 + 20, 10);
}
} else if (current_line < 104) {
for (uint8_t i = 0; i < text_len; ++i) {
memcpy(line_buffer + 12 * i, char_rom + (text[i] - '0') * 14 + 30, 10);
}
} else if (current_line < 112) {
for (uint8_t i = 0; i < text_len; ++i) {
memcpy(line_buffer + 12 * i, char_rom + (text[i] - '0') * 14 + 40, 10);
}
} else if (current_line < 120) {
for (uint8_t i = 0; i < text_len; ++i) {
memcpy(line_buffer + 12 * i, char_rom + (text[i] - '0') * 14 + 50, 10);
}
} else if (current_line < 128) {
for (uint8_t i = 0; i < text_len; ++i) {
memcpy(line_buffer + 12 * i, char_rom + (text[i] - '0') * 14 + 60, 10);
2021-07-03 13:44:01 +00:00
}
} /* else if (current_line < 136) {
for (uint8_t i = 0; i < text_len; ++i) {
memcpy(line_buffer + 12 * i, char_rom + (text[i] - '0') * 14 + 70, 10);
}
} else if (current_line < 144) {
for (uint8_t i = 0; i < text_len; ++i) {
memcpy(line_buffer + 12 * i, char_rom + (text[i] - '0') * 14 + 80, 10);
}
} else if (current_line < 152) {
for (uint8_t i = 0; i < text_len; ++i) {
memcpy(line_buffer + 12 * i, char_rom + (text[i] - '0') * 14 + 90, 10);
}
} else if (current_line < 160) {
for (uint8_t i = 0; i < text_len; ++i) {
memcpy(line_buffer + 12 * i, char_rom + (text[i] - '0') * 14 + 100, 10);
}
} else if (current_line < 168) {
for (uint8_t i = 0; i < text_len; ++i) {
memcpy(line_buffer + 12 * i, char_rom + (text[i] - '0') * 14 + 110, 10);
}
} else if (current_line < 176) {
for (uint8_t i = 0; i < text_len; ++i) {
memcpy(line_buffer + 12 * i, char_rom + (text[i] - '0') * 14 + 120, 10);
}
} else if (current_line < 184) {
for (uint8_t i = 0; i < text_len; ++i) {
memcpy(line_buffer + 12 * i, char_rom + (text[i] - '0') * 14 + 130, 10);
}
} */ else if (current_line < 192) {
memset(line_buffer, 0, LINE_BUFFER_SIZE);
2021-07-03 13:44:01 +00:00
}
}
2021-07-03 13:02:01 +00:00
}