"diagonal line"

not the whole screen, but vertically locked
actually it has some issues, there is a single dot (at the
end/beginning of a cycle) that messes up the horizontal sync and moves
all the picture... must be fixed
This commit is contained in:
giomba 2021-06-26 23:42:23 +02:00
parent 29990cd93a
commit 97e0ff26fa
2 changed files with 35 additions and 20 deletions

40
main.S
View File

@ -9,6 +9,9 @@ status:
offset: offset:
.byte 78 .byte 78
line:
.word 0
.text .text
.global main_s .global main_s
@ -21,10 +24,10 @@ main_s:
out IO(MCUCR), r16 out IO(MCUCR), r16
out IO(MCUCR), r17 out IO(MCUCR), r17
ldi r16, 0x3 ; enable falling edge interrupt 0 ldi r16, 0xa ; external interrupt 0 and 1, falling edge
sts EICRA, r16 sts EICRA, r16
ldi r16, 0x1 ; external interrupt mask enable ldi r16, 0x3 ; external interrupt 0 and 1, mask enable
sts EIMSK, r16 sts EIMSK, r16
sei sei
@ -66,26 +69,33 @@ wait2:
jmp again jmp again
.global int0_handler .global int_horizontal_sync
int0_handler: int_horizontal_sync:
push r31 push r31
in r31, IO(SREG) ; status register in r31, IO(SREG) ; status register
push r31 push r31
lds r31, line
cpi r31, 255
brsh int_horizontal_sync_end
inc r31
sts line, r31
lds r31, status
cpi r31, 0
brne int_horizontal_sync_end
lds r31, offset lds r31, offset
dec r31 dec r31
cpi r31, 1 cpi r31, 1
brne 1f brne 1f
ldi r31, 78 ldi r31, 140
1: 1:
sts offset, r31 sts offset, r31
loop: loop:
dec r31 dec r31
brne loop brne loop
lds r31, status
cpi r31, 1
brne 1f
sbi IO(PORTB), 4 sbi IO(PORTB), 4
nop nop
nop nop
@ -98,9 +108,21 @@ loop:
nop nop
nop nop
cbi IO(PORTB), 4 cbi IO(PORTB), 4
1:
int_horizontal_sync_end:
pop r31 pop r31
out IO(SREG), r31 out IO(SREG), r31
pop r31 pop r31
reti reti
.global int_vertical_sync
int_vertical_sync:
push r31
ldi r31, 0
sts line, r31
ldi r31, 140
sts offset, r31
pop r31
reti

15
main.c
View File

@ -2,20 +2,13 @@
#include <avr/interrupt.h> #include <avr/interrupt.h>
void main_s(void); void main_s(void);
void int0_handler(void);
void pippo() {
asm("nop");
asm("push r1");
int i = 0;
i = 2;
i += 1;
reti();
}
ISR(INT0_vect, ISR_NAKED) { ISR(INT0_vect, ISR_NAKED) {
asm("jmp int0_handler"); asm("jmp int_vertical_sync");
}
ISR(INT1_vect, ISR_NAKED) {
asm("jmp int_horizontal_sync");
} }
int main() { int main() {