introduced line buffer of 160 pixel

This commit is contained in:
giomba 2021-07-03 15:02:01 +02:00
parent 77b1858311
commit 9eaf78d6b5
3 changed files with 22 additions and 19 deletions

View File

@ -2,3 +2,4 @@
#define VERTICAL_OFFSET 30
#define HORIZONTAL_OFFSET 192
#define LINE_BUFFER_SIZE 160

31
main.S
View File

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

9
main.c
View File

@ -1,5 +1,8 @@
#include <avr/io.h>
#include <avr/interrupt.h>
#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;
}
}