1.1 --- a/examples/vga-dual/vga.h Tue Oct 30 19:23:34 2018 +0100
1.2 +++ b/examples/vga-dual/vga.h Tue Oct 30 20:19:45 2018 +0100
1.3 @@ -20,9 +20,11 @@
1.4 #ifndef __VGA_H__
1.5 #define __VGA_H__
1.6
1.7 +#include "vga_common.h"
1.8 +
1.9 #define LINE_LENGTH 160 /* pixels */
1.10 #define LINE_COUNT 256 /* distinct display lines */
1.11 -#define LINE_MULTIPLIER 2
1.12 +#define LINE_MULTIPLIER (SCANLINES / LINE_COUNT)
1.13
1.14 /* 24MHz cycle measurements. */
1.15
1.16 @@ -31,19 +33,6 @@
1.17 #define HSYNC_LIMIT 64
1.18 #define HSYNC_END (HSYNC_START + HSYNC_LIMIT)
1.19
1.20 -/* Horizontal lines, back porch end. */
1.21 -
1.22 -#define VISIBLE_START 70
1.23 -#define VFP_START (VISIBLE_START + LINE_MULTIPLIER * LINE_COUNT)
1.24 -
1.25 -/* Horizontal lines, front porch end. */
1.26 -
1.27 -#define VSYNC_START 620
1.28 -
1.29 -/* Horizontal lines, back porch start. */
1.30 -
1.31 -#define VSYNC_END 622
1.32 -
1.33 /* Framebuffer properties. */
1.34
1.35 #define SCREEN_SIZE (LINE_LENGTH * LINE_COUNT)
2.1 --- a/examples/vga-pmp/vga.h Tue Oct 30 19:23:34 2018 +0100
2.2 +++ b/examples/vga-pmp/vga.h Tue Oct 30 20:19:45 2018 +0100
2.3 @@ -20,9 +20,11 @@
2.4 #ifndef __VGA_H__
2.5 #define __VGA_H__
2.6
2.7 +#include "vga_common.h"
2.8 +
2.9 #define LINE_LENGTH 160 /* pixels */
2.10 #define LINE_COUNT 256 /* distinct display lines */
2.11 -#define LINE_MULTIPLIER 2
2.12 +#define LINE_MULTIPLIER (SCANLINES / LINE_COUNT)
2.13
2.14 /* 48MHz cycle measurements. */
2.15
2.16 @@ -31,19 +33,6 @@
2.17 #define HSYNC_LIMIT 128
2.18 #define HSYNC_END (HSYNC_START + HSYNC_LIMIT)
2.19
2.20 -/* Horizontal lines, back porch end. */
2.21 -
2.22 -#define VISIBLE_START 70
2.23 -#define VFP_START (VISIBLE_START + LINE_MULTIPLIER * LINE_COUNT)
2.24 -
2.25 -/* Horizontal lines, front porch end. */
2.26 -
2.27 -#define VSYNC_START 620
2.28 -
2.29 -/* Horizontal lines, back porch start. */
2.30 -
2.31 -#define VSYNC_END 622
2.32 -
2.33 /* Framebuffer properties. */
2.34
2.35 #define SCREEN_SIZE (LINE_LENGTH * LINE_COUNT)
3.1 --- a/examples/vga-timer/vga.h Tue Oct 30 19:23:34 2018 +0100
3.2 +++ b/examples/vga-timer/vga.h Tue Oct 30 20:19:45 2018 +0100
3.3 @@ -20,9 +20,11 @@
3.4 #ifndef __VGA_H__
3.5 #define __VGA_H__
3.6
3.7 +#include "vga_common.h"
3.8 +
3.9 #define LINE_LENGTH 92 /* pixels */
3.10 #define LINE_COUNT 128 /* distinct display lines */
3.11 -#define LINE_MULTIPLIER 4
3.12 +#define LINE_MULTIPLIER (SCANLINES / LINE_COUNT)
3.13
3.14 /* 24MHz cycle measurements. */
3.15
3.16 @@ -31,19 +33,6 @@
3.17 #define HSYNC_LIMIT 40
3.18 #define HSYNC_END (HSYNC_START + HSYNC_LIMIT)
3.19
3.20 -/* Horizontal lines, back porch end. */
3.21 -
3.22 -#define VISIBLE_START 70
3.23 -#define VFP_START (VISIBLE_START + LINE_MULTIPLIER * LINE_COUNT)
3.24 -
3.25 -/* Horizontal lines, front porch end. */
3.26 -
3.27 -#define VSYNC_START 620
3.28 -
3.29 -/* Horizontal lines, back porch start. */
3.30 -
3.31 -#define VSYNC_END 622
3.32 -
3.33 /* Framebuffer properties. */
3.34
3.35 #define SCREEN_SIZE (LINE_LENGTH * LINE_COUNT)
4.1 --- a/examples/vga/vga.h Tue Oct 30 19:23:34 2018 +0100
4.2 +++ b/examples/vga/vga.h Tue Oct 30 20:19:45 2018 +0100
4.3 @@ -20,9 +20,11 @@
4.4 #ifndef __VGA_H__
4.5 #define __VGA_H__
4.6
4.7 +#include "vga_common.h"
4.8 +
4.9 #define LINE_LENGTH 160 /* pixels */
4.10 #define LINE_COUNT 256 /* distinct display lines */
4.11 -#define LINE_MULTIPLIER 2
4.12 +#define LINE_MULTIPLIER (SCANLINES / LINE_COUNT)
4.13
4.14 /* 24MHz cycle measurements. */
4.15
4.16 @@ -31,19 +33,6 @@
4.17 #define HSYNC_LIMIT 64
4.18 #define HSYNC_END (HSYNC_START + HSYNC_LIMIT)
4.19
4.20 -/* Horizontal lines, back porch end. */
4.21 -
4.22 -#define VISIBLE_START 70
4.23 -#define VFP_START (VISIBLE_START + LINE_MULTIPLIER * LINE_COUNT)
4.24 -
4.25 -/* Horizontal lines, front porch end. */
4.26 -
4.27 -#define VSYNC_START 620
4.28 -
4.29 -/* Horizontal lines, back porch start. */
4.30 -
4.31 -#define VSYNC_END 622
4.32 -
4.33 /* Framebuffer properties. */
4.34
4.35 #define SCREEN_SIZE (LINE_LENGTH * LINE_COUNT)
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/include/vga_common.h Tue Oct 30 20:19:45 2018 +0100
5.3 @@ -0,0 +1,43 @@
5.4 +/*
5.5 + * Generate a VGA signal using a PIC32 microcontroller.
5.6 + *
5.7 + * Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk>
5.8 + *
5.9 + * This program is free software: you can redistribute it and/or modify
5.10 + * it under the terms of the GNU General Public License as published by
5.11 + * the Free Software Foundation, either version 3 of the License, or
5.12 + * (at your option) any later version.
5.13 + *
5.14 + * This program is distributed in the hope that it will be useful,
5.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5.17 + * GNU General Public License for more details.
5.18 + *
5.19 + * You should have received a copy of the GNU General Public License
5.20 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
5.21 + */
5.22 +
5.23 +#ifndef __VGA_COMMON_H__
5.24 +#define __VGA_COMMON_H__
5.25 +
5.26 +/* Number of raster scan lines to be used. */
5.27 +
5.28 +#define SCANLINES 512
5.29 +
5.30 +/* Horizontal lines, back porch end. */
5.31 +
5.32 +#define VISIBLE_START 72
5.33 +
5.34 +/* Horizontal lines, front porch start. */
5.35 +
5.36 +#define VFP_START (VISIBLE_START + SCANLINES)
5.37 +
5.38 +/* Horizontal lines, front porch end. */
5.39 +
5.40 +#define VSYNC_START 620
5.41 +
5.42 +/* Horizontal lines, back porch start. */
5.43 +
5.44 +#define VSYNC_END 622
5.45 +
5.46 +#endif /* __VGA_COMMON_H__ */