Compare commits
3 Commits
77b1858311
...
53da6b7171
Author | SHA1 | Date |
---|---|---|
giomba | 53da6b7171 | |
giomba | 1764a5f2b3 | |
giomba | 9eaf78d6b5 |
4
const.h
4
const.h
|
@ -2,3 +2,7 @@
|
|||
|
||||
#define VERTICAL_OFFSET 30
|
||||
#define HORIZONTAL_OFFSET 192
|
||||
#define LINE_BUFFER_SIZE 160
|
||||
|
||||
#define BLACK 0x00
|
||||
#define WHITE 0xff
|
||||
|
|
40
main.S
40
main.S
|
@ -2,14 +2,6 @@
|
|||
#include "macro.h"
|
||||
#include "const.h"
|
||||
|
||||
.data
|
||||
|
||||
frame:
|
||||
.word 0
|
||||
|
||||
line:
|
||||
.word 0
|
||||
|
||||
.text
|
||||
|
||||
.global main
|
||||
|
@ -43,9 +35,12 @@ main:
|
|||
ldi r16, 1
|
||||
sts line, r16
|
||||
|
||||
call setup_c
|
||||
|
||||
sei ; global interrupt enable
|
||||
|
||||
1:
|
||||
call loop_c
|
||||
rjmp 1b
|
||||
|
||||
.global int_horizontal_sync
|
||||
|
@ -94,6 +89,8 @@ int_timer_0:
|
|||
push r31
|
||||
in r31, IO(SREG)
|
||||
push r31
|
||||
push r30
|
||||
push r29
|
||||
|
||||
; turn off interrupt
|
||||
lds r31, TIMSK0
|
||||
|
@ -101,28 +98,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
|
||||
|
|
43
main.c
43
main.c
|
@ -1,5 +1,11 @@
|
|||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include "const.h"
|
||||
#include <string.h>
|
||||
|
||||
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");
|
||||
|
@ -10,3 +16,40 @@ ISR(INT1_vect, ISR_NAKED) {
|
|||
ISR(TIMER0_COMPA_vect, ISR_NAKED) {
|
||||
asm("jmp int_timer_0");
|
||||
}
|
||||
|
||||
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;
|
||||
switch (current_line) {
|
||||
case 76: case 134: memcpy(line_buffer, "AAAAAAAAAAAAAAAAAAAAAA", 22); break;
|
||||
case 80: memcpy(line_buffer, "11111111AAAA1111111111", 22); break;
|
||||
case 84: memcpy(line_buffer, "111111111AAA1111111111", 22); break;
|
||||
case 88: case 98: memcpy(line_buffer, "11AAAAA111AA11AAAAAAAA", 22); break;
|
||||
case 92: memcpy(line_buffer, "11AAAAAA11AA11AAAAAAAA", 22); break;
|
||||
case 102: memcpy(line_buffer, "111111111AAA11111111AA", 22); break;
|
||||
case 106: memcpy(line_buffer, "11111111AAAA11111111AA", 22); break;
|
||||
case 110: memcpy(line_buffer, "11A111AAAAAA11AAAAAAAA", 22); break;
|
||||
case 114: memcpy(line_buffer, "11AA111AAAAA11AAAAAAAA", 22); break;
|
||||
case 118: memcpy(line_buffer, "11AAA111AAAA11AAAAAAAA", 22); break;
|
||||
case 122: memcpy(line_buffer, "11AAAA111AAA11AAAAAAAA", 22); break;
|
||||
case 126: memcpy(line_buffer, "11AAAAA111AA1111111111", 22); break;
|
||||
case 130: memcpy(line_buffer, "11AAAAAA11AA1111111111", 22); break;
|
||||
}
|
||||
line_buffer[60] = (current_line > 50 && current_line < 100) ? WHITE : BLACK;
|
||||
|
||||
if (current_line > 200 && 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue