From 9eaf78d6b5f4ce183d92b68c9f07b0d5363d2b06 Mon Sep 17 00:00:00 2001 From: giomba Date: Sat, 3 Jul 2021 15:02:01 +0200 Subject: [PATCH] introduced line buffer of 160 pixel --- const.h | 1 + main.S | 31 ++++++++++++------------------- main.c | 9 +++++++++ 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/const.h b/const.h index fe2112f..95d854d 100644 --- a/const.h +++ b/const.h @@ -2,3 +2,4 @@ #define VERTICAL_OFFSET 30 #define HORIZONTAL_OFFSET 192 +#define LINE_BUFFER_SIZE 160 diff --git a/main.S b/main.S index d1dbfe2..ff513ee 100644 --- a/main.S +++ b/main.S @@ -43,6 +43,8 @@ main: ldi r16, 1 sts line, r16 + call main_c + sei ; global interrupt enable 1: @@ -94,6 +96,8 @@ int_timer_0: push r31 in r31, IO(SREG) push r31 + push r30 + push r29 ; turn off interrupt lds r31, TIMSK0 @@ -101,28 +105,17 @@ int_timer_0: sts TIMSK0, r31 ; draw things - lds r31, frame - andi r31, 0x70 - cpi r31, 0 - breq 2f -1: - dec r31 - brne 1b -2: + ldi r30, lo8(line_buffer) + ldi r31, hi8(line_buffer) - sbi IO(PORTB), 4 +.rept LINE_BUFFER_SIZE + ld r29, z+ + out IO(PORTB), r29 nop - nop - nop - nop - nop - nop - nop - nop - nop - nop - cbi IO(PORTB), 4 +.endr + pop r29 + pop r30 pop r31 out IO(SREG), r31 pop r31 diff --git a/main.c b/main.c index c7dfacf..027d9fe 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,8 @@ #include #include +#include "const.h" + +char line_buffer[LINE_BUFFER_SIZE]; ISR(INT0_vect, ISR_NAKED) { asm("jmp int_vertical_sync"); @@ -10,3 +13,9 @@ ISR(INT1_vect, ISR_NAKED) { ISR(TIMER0_COMPA_vect, ISR_NAKED) { asm("jmp int_timer_0"); } + +void main_c() { + for (int i = 0; i < LINE_BUFFER_SIZE; ++i) { + line_buffer[i] = (i % 2) ? 0x0 : 0xff; + } +}