From 48da25958e5f2d5c59476ef7381c9166a7738831 Mon Sep 17 00:00:00 2001 From: giomba Date: Mon, 28 Jun 2021 21:54:25 +0200 Subject: [PATCH] back porch skipping, wasting clock cycles, basically --- const.h | 2 +- main.S | 31 +++++++++++++++++-------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/const.h b/const.h index 41e6bd0..2ed9307 100644 --- a/const.h +++ b/const.h @@ -1,4 +1,4 @@ #pragma once #define VERTICAL_OFFSET 30 -#define HORIZONTAL_OFFSET_CYCLE 50 +#define HORIZONTAL_OFFSET_CYCLE 56 diff --git a/main.S b/main.S index c4f84f5..202d79c 100644 --- a/main.S +++ b/main.S @@ -36,24 +36,27 @@ main: rjmp 1b .global int_horizontal_sync -int_horizontal_sync: - push r31 - in r31, IO(SREG) ; status register - push r31 - push r30 +int_horizontal_sync: ; +3 + push r31 ; +5 + in r31, IO(SREG) ; +6, status register + push r31 ; +8 + push r30 ; +10 ; 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 - brne enter - cpi r30, VERTICAL_OFFSET - brlo int_horizontal_sync_end + lds r30, line ; +12 + lds r31, line + 1 ; +14 + adiw z, 1 ; +16 + sts line, r30 ; +18 + sts line + 1, r31 ; +20 + cpi r31, 0 ; +21 + brne enter ; +22, +23 + cpi r30, VERTICAL_OFFSET ; +23 + brlo int_horizontal_sync_end ; +24 enter: + ; here, +23 or +24 cycles have passed since horizontal sync + ; so, there are still ~168 cycles before first useful data + ; or 56 3-cycle instructions (HORIZONTAL_OFFSET_CYCLE) ldi r31, HORIZONTAL_OFFSET_CYCLE ; skip back porch 1: dec r31