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"
.data
vertical_offset:
.byte 0
frame:
.byte 0
.word 0
line:
.byte 0
.word 0
.text
@ -42,21 +40,20 @@ int_horizontal_sync:
push r31
in r31, IO(SREG) ; status register
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
breq enter
dec r31
sts vertical_offset, r31
jmp int_horizontal_sync_end
brne enter
cpi r30, VERTICAL_OFFSET
brlo int_horizontal_sync_end
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
1:
dec r31
@ -79,27 +76,8 @@ enter:
nop
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:
pop r30
pop r31
out IO(SREG), r31
pop r31
@ -110,18 +88,21 @@ int_vertical_sync:
push r31
in r31, IO(SREG)
push r31
push r30
lds r31, frame
inc r31
sts frame, r31
lds r31, frame + 1
lds r30, frame
adiw z, 1
sts frame + 1, r31
sts frame, r30
ldi r31, 1
sts line, r31
ldi r31, VERTICAL_OFFSET
sts vertical_offset, r31
ldi r30, 1
ldi r31, 0
sts line, r30
sts line + 1, r31
int_vertical_sync_end:
pop r30
pop r31
out IO(SREG), r31
pop r31