From 1f3f3f36f2185d3f9935adf2b0a1683cfb2b4911 Mon Sep 17 00:00:00 2001 From: giomba Date: Mon, 28 Jun 2021 21:38:39 +0200 Subject: [PATCH] line, frame as words (16 bit) --- main.S | 67 +++++++++++++++++++++------------------------------------- 1 file changed, 24 insertions(+), 43 deletions(-) diff --git a/main.S b/main.S index 26a1ca5..c4f84f5 100644 --- a/main.S +++ b/main.S @@ -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