diff --git a/const.h b/const.h index 95d854d..51c8eb5 100644 --- a/const.h +++ b/const.h @@ -3,3 +3,6 @@ #define VERTICAL_OFFSET 30 #define HORIZONTAL_OFFSET 192 #define LINE_BUFFER_SIZE 160 + +#define BLACK 0x00 +#define WHITE 0xff diff --git a/main.S b/main.S index ff513ee..9e73528 100644 --- a/main.S +++ b/main.S @@ -2,14 +2,6 @@ #include "macro.h" #include "const.h" -.data - -frame: -.word 0 - -line: -.word 0 - .text .global main @@ -43,11 +35,12 @@ main: ldi r16, 1 sts line, r16 - call main_c + call setup_c sei ; global interrupt enable 1: + call loop_c rjmp 1b .global int_horizontal_sync diff --git a/main.c b/main.c index 027d9fe..4590968 100644 --- a/main.c +++ b/main.c @@ -2,7 +2,9 @@ #include #include "const.h" -char line_buffer[LINE_BUFFER_SIZE]; +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"); @@ -14,8 +16,23 @@ ISR(TIMER0_COMPA_vect, ISR_NAKED) { asm("jmp int_timer_0"); } -void main_c() { +void setup_c() { + /* for (int i = 0; i < LINE_BUFFER_SIZE; ++i) { line_buffer[i] = (i % 2) ? 0x0 : 0xff; } + */ +} + +void loop_c() { + for (;;) { + const int current_line = line; + line_buffer[20] = (current_line > 50 && current_line < 100) ? WHITE : BLACK; + if (current_line % 8 == 0) { + const uint8_t current_number = frame >> 2; + for (uint8_t i = 0; i < 8; ++i) { + line_buffer[i] = ((current_number >> i) & 0x1) ? WHITE : BLACK; + } + } + } }