1.1 --- a/examples/vga/main.c Fri Nov 02 02:15:09 2018 +0100
1.2 +++ b/examples/vga/main.c Fri Nov 02 18:26:06 2018 +0100
1.3 @@ -30,21 +30,33 @@
1.4 #include "font.h"
1.5 #include "main.h"
1.6 #include "vga.h"
1.7 +#include "vga_display.h"
1.8
1.9 -#ifndef TRANSFER_CPU
1.10 -#include "vga_display.h"
1.11 +
1.12 +
1.13 +/* Define DMA channels if not indicated in the build configuration. */
1.14 +
1.15 +/* CPU-based transfers: no channels. */
1.16 +
1.17 +#ifdef TRANSFER_CPU
1.18 +#define LINE_CHANNELS 0
1.19 +#define SCROLL_XSTEP 1
1.20 +
1.21 +/* DMA-based transfers: single channel by default. */
1.22 +
1.23 #else
1.24 -#include "vga_display_cpu.h"
1.25 +
1.26 +#ifndef LINE_CHANNELS
1.27 +#define LINE_CHANNELS 1
1.28 +#endif
1.29 +
1.30 +#define SCROLL_XSTEP LINE_CHANNELS
1.31 #endif
1.32
1.33
1.34
1.35 /* Define timers if not indicated in the build configuration. */
1.36
1.37 -#ifndef LINE_CHANNELS
1.38 -#define LINE_CHANNELS 1
1.39 -#endif
1.40 -
1.41 #ifndef LINE_TIMER
1.42 #define LINE_TIMER 2
1.43 #endif
1.44 @@ -116,10 +128,25 @@
1.45
1.46 static void animate(uint32_t delay)
1.47 {
1.48 + /* Stored region behind the sprite. */
1.49 +
1.50 uint8_t background[sprite_width * sprite_height];
1.51 +
1.52 + /* Sprite position. */
1.53 +
1.54 int x, y;
1.55 - int dir[] = {1, 0, -1, 0, 1}, i = 0, width, column_width;
1.56 - int xsource, xdisplay, xorigin = 0, yorigin = 0;
1.57 +
1.58 + /* Scrolling directions. */
1.59 +
1.60 + int dir[] = {1, 0, -1, 0, 1}, i = 0;
1.61 +
1.62 + /* Scrolling position. */
1.63 +
1.64 + int xorigin = 0, yorigin = 0;
1.65 +
1.66 + /* Replotted column details. */
1.67 +
1.68 + int width, column_width, xsource, xdisplay;
1.69
1.70 while (1)
1.71 {
1.72 @@ -171,7 +198,7 @@
1.73 involves two pixel increments and thus requires a two-
1.74 pixel column to be plotted. */
1.75
1.76 - width = dir[i] * LINE_CHANNELS;
1.77 + width = dir[i] * SCROLL_XSTEP;
1.78 column_width = width < 0 ? -width : width;
1.79
1.80 /* Plot either at the left or right edge. */
1.81 @@ -283,11 +310,7 @@
1.82 timer and any transfer timer, with an initiating channel being introduced
1.83 if a transfer timer is specified. */
1.84
1.85 -#ifndef TRANSFER_CPU
1.86 init_vga_with_timers(&display_config, LINE_CHANNELS, LINE_TIMER, TRANSFER_TIMER);
1.87 -#else
1.88 - init_vga_with_timer(&display_config, LINE_TIMER);
1.89 -#endif
1.90
1.91 /* Configure VGA output transfer to the output register, also configuring
1.92 output compare units for horizontal and vertical sync. */
1.93 @@ -326,29 +349,7 @@
1.94
1.95 void interrupt_handler(void)
1.96 {
1.97 - uint32_t ifs;
1.98 -
1.99 -#ifdef TRANSFER_CPU
1.100 - /* Check for a timer interrupt condition. */
1.101 -
1.102 - ifs = REG(TIMERIFS) & TIMER_INT_FLAGS(LINE_TIMER, TxIF);
1.103 -
1.104 - if (ifs)
1.105 - {
1.106 - vga_transfer_interrupt_handler();
1.107 - CLR_REG(TIMERIFS, ifs);
1.108 - }
1.109 -#endif
1.110 -
1.111 - /* Check for a OC1 interrupt condition. */
1.112 -
1.113 - ifs = REG(OCIFS) & OC_INT_FLAGS(1, OCxIF);
1.114 -
1.115 - if (ifs)
1.116 - {
1.117 - vga_interrupt_handler();
1.118 - CLR_REG(OCIFS, ifs);
1.119 - }
1.120 + vga_interrupt_handler();
1.121 }
1.122
1.123