line, frame as words (16 bit)

This commit is contained in:
giomba 2021-06-28 21:38:39 +02:00
parent 0448c64be4
commit 1f3f3f36f2
1 changed files with 24 additions and 43 deletions

67
main.S
View File

@ -3,14 +3,12 @@
#include "const.h" #include "const.h"
.data .data
vertical_offset:
.byte 0
frame: frame:
.byte 0 .word 0
line: line:
.byte 0 .word 0
.text .text
@ -42,21 +40,20 @@ int_horizontal_sync:
push r31 push r31
in r31, IO(SREG) ; status register in r31, IO(SREG) ; status register
push r31 push r31
push r30
lds r31, vertical_offset ; if (line >= VERTICAL_OFFSET), then enter
lds r30, line
lds r31, line + 1
adiw z, 1
sts line, r30
sts line + 1, r31
cpi r31, 0 cpi r31, 0
breq enter brne enter
dec r31 cpi r30, VERTICAL_OFFSET
sts vertical_offset, r31 brlo int_horizontal_sync_end
jmp int_horizontal_sync_end
enter: enter:
lds r31, line
cpi r31, 0
breq int_horizontal_sync_end
inc r31
sts line, r31
ldi r31, HORIZONTAL_OFFSET_CYCLE ; skip back porch ldi r31, HORIZONTAL_OFFSET_CYCLE ; skip back porch
1: 1:
dec r31 dec r31
@ -79,27 +76,8 @@ enter:
nop nop
cbi IO(PORTB), 4 cbi IO(PORTB), 4
#if 0
ldi r31, 140
1:
dec r31
brne 1b
sbi IO(PORTB), 4
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
cbi IO(PORTB), 4
#endif
int_horizontal_sync_end: int_horizontal_sync_end:
pop r30
pop r31 pop r31
out IO(SREG), r31 out IO(SREG), r31
pop r31 pop r31
@ -110,18 +88,21 @@ int_vertical_sync:
push r31 push r31
in r31, IO(SREG) in r31, IO(SREG)
push r31 push r31
push r30
lds r31, frame lds r31, frame + 1
inc r31 lds r30, frame
sts frame, r31 adiw z, 1
sts frame + 1, r31
sts frame, r30
ldi r31, 1 ldi r30, 1
sts line, r31 ldi r31, 0
sts line, r30
ldi r31, VERTICAL_OFFSET sts line + 1, r31
sts vertical_offset, r31
int_vertical_sync_end: int_vertical_sync_end:
pop r30
pop r31 pop r31
out IO(SREG), r31 out IO(SREG), r31
pop r31 pop r31