line buffer dynamic update

This commit is contained in:
giomba 2021-07-03 15:44:01 +02:00
parent 9eaf78d6b5
commit 1764a5f2b3
3 changed files with 24 additions and 11 deletions

View File

@ -3,3 +3,6 @@
#define VERTICAL_OFFSET 30
#define HORIZONTAL_OFFSET 192
#define LINE_BUFFER_SIZE 160
#define BLACK 0x00
#define WHITE 0xff

11
main.S
View File

@ -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

21
main.c
View File

@ -2,7 +2,9 @@
#include <avr/interrupt.h>
#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;
}
}
}
}