CommonPIC32

Annotated examples/vga/vga.h

103:b09769a6eaa5
2018-11-04 Paul Boddie Fixed screen edge updates where update columns span the background image edge. Maintain the scroll origin as signed integers to allow general subtraction, with more general value wrapping employed to keep the origin point in the background image within limits.
paul@24 1
/*
paul@24 2
 * Generate a VGA signal using a PIC32 microcontroller.
paul@24 3
 *
paul@24 4
 * Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk>
paul@24 5
 *
paul@24 6
 * This program is free software: you can redistribute it and/or modify
paul@24 7
 * it under the terms of the GNU General Public License as published by
paul@24 8
 * the Free Software Foundation, either version 3 of the License, or
paul@24 9
 * (at your option) any later version.
paul@24 10
 *
paul@24 11
 * This program is distributed in the hope that it will be useful,
paul@24 12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
paul@24 13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
paul@24 14
 * GNU General Public License for more details.
paul@24 15
 *
paul@24 16
 * You should have received a copy of the GNU General Public License
paul@24 17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
paul@24 18
 */
paul@24 19
paul@24 20
#ifndef __VGA_H__
paul@24 21
#define __VGA_H__
paul@24 22
paul@80 23
#include "vga_common.h"
paul@80 24
paul@24 25
#define LINE_LENGTH             160 /* pixels */
paul@93 26
#define LINE_COUNT              256 /* display lines per frame */
paul@93 27
#define FRAME_COUNT             1   /* double-buffered display */
paul@24 28
paul@24 29
/* 24MHz cycle measurements. */
paul@24 30
paul@24 31
#define HFREQ_LIMIT             643
paul@24 32
#define HSYNC_START             460
paul@24 33
#define HSYNC_LIMIT             64
paul@24 34
#define HSYNC_END               (HSYNC_START + HSYNC_LIMIT)
paul@24 35
paul@41 36
/* Framebuffer properties. */
paul@24 37
paul@41 38
#define SCREEN_SIZE             (LINE_LENGTH * LINE_COUNT)
paul@45 39
paul@93 40
/* A frame has an entire screen plus one line to allow horizontal scrolling,
paul@93 41
   since a horizontal scroll offset causes the final transfer line to exceed the
paul@93 42
   screen limit. */
paul@93 43
paul@99 44
#define FRAME_SIZE              (SCREEN_SIZE + LINE_LENGTH)
paul@93 45
paul@45 46
/* Transfer and pixel allocation properties. */
paul@45 47
paul@45 48
#define TRANSFER_CELL_SIZE      LINE_LENGTH
paul@45 49
#define CELL_SIZE               LINE_LENGTH
paul@24 50
paul@24 51
#endif /* __VGA_H__ */