Demo of low res colour vga video for stm32f3 discovery board
Dependencies: STM32F3-Discovery-minimal
Fork of Space_Invaders_Demo by
mth.c@17:833f1b69e11d, 2019-04-03 (annotated)
- Committer:
- MartinJohnson
- Date:
- Wed Apr 03 22:05:56 2019 +0000
- Revision:
- 17:833f1b69e11d
- Parent:
- 0:404dae88af71
update library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MartinJohnson | 0:404dae88af71 | 1 | /*************************************************************************** |
MartinJohnson | 0:404dae88af71 | 2 | * STM32 VGA demo |
MartinJohnson | 0:404dae88af71 | 3 | * Copyright (C) 2012 Artekit Italy |
MartinJohnson | 0:404dae88af71 | 4 | * http://www.artekit.eu |
MartinJohnson | 0:404dae88af71 | 5 | * Written by Ruben H. Meleca |
MartinJohnson | 0:404dae88af71 | 6 | |
MartinJohnson | 0:404dae88af71 | 7 | ### mth.c |
MartinJohnson | 0:404dae88af71 | 8 | |
MartinJohnson | 0:404dae88af71 | 9 | # This program is free software; you can redistribute it and/or modify |
MartinJohnson | 0:404dae88af71 | 10 | # it under the terms of the GNU General Public License as published by |
MartinJohnson | 0:404dae88af71 | 11 | # the Free Software Foundation; either version 2 of the License, or |
MartinJohnson | 0:404dae88af71 | 12 | # (at your option) any later version. |
MartinJohnson | 0:404dae88af71 | 13 | # |
MartinJohnson | 0:404dae88af71 | 14 | # This program is distributed in the hope that it will be useful, |
MartinJohnson | 0:404dae88af71 | 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
MartinJohnson | 0:404dae88af71 | 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MartinJohnson | 0:404dae88af71 | 17 | # GNU General Public License for more details. |
MartinJohnson | 0:404dae88af71 | 18 | # |
MartinJohnson | 0:404dae88af71 | 19 | # You should have received a copy of the GNU General Public License |
MartinJohnson | 0:404dae88af71 | 20 | # along with this program; if not, write to the Free Software |
MartinJohnson | 0:404dae88af71 | 21 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
MartinJohnson | 0:404dae88af71 | 22 | |
MartinJohnson | 0:404dae88af71 | 23 | ***************************************************************************/ |
MartinJohnson | 0:404dae88af71 | 24 | |
MartinJohnson | 0:404dae88af71 | 25 | #include "mth.h" |
MartinJohnson | 0:404dae88af71 | 26 | |
MartinJohnson | 0:404dae88af71 | 27 | static const i16 SineTable[360] = |
MartinJohnson | 0:404dae88af71 | 28 | { |
MartinJohnson | 0:404dae88af71 | 29 | 0, 174, 348, 523, 697, 871, 1045, 1218, 1391, |
MartinJohnson | 0:404dae88af71 | 30 | 1564, 1736, 1908, 2079, 2249, 2419, 2588, 2756, 2923, |
MartinJohnson | 0:404dae88af71 | 31 | 3090, 3255, 3420, 3583, 3746, 3907, 4067, 4226, 4383, |
MartinJohnson | 0:404dae88af71 | 32 | 4539, 4694, 4848, 4999, 5150, 5299, 5446, 5591, 5735, |
MartinJohnson | 0:404dae88af71 | 33 | 5877, 6018, 6156, 6293, 6427, 6560, 6691, 6819, 6946, |
MartinJohnson | 0:404dae88af71 | 34 | 7071, 7193, 7313, 7431, 7547, 7660, 7771, 7880, 7986, |
MartinJohnson | 0:404dae88af71 | 35 | 8090, 8191, 8290, 8386, 8480, 8571, 8660, 8746, 8829, |
MartinJohnson | 0:404dae88af71 | 36 | 8910, 8987, 9063, 9135, 9205, 9271, 9335, 9396, 9455, |
MartinJohnson | 0:404dae88af71 | 37 | 9510, 9563, 9612, 9659, 9702, 9743, 9781, 9816, 9848, |
MartinJohnson | 0:404dae88af71 | 38 | 9876, 9902, 9925, 9945, 9961, 9975, 9986, 9993, 9998, |
MartinJohnson | 0:404dae88af71 | 39 | 10000, 9998, 9993, 9986, 9975, 9961, 9945, 9925, 9902, |
MartinJohnson | 0:404dae88af71 | 40 | 9876, 9848, 9816, 9781, 9743, 9702, 9659, 9612, 9563, |
MartinJohnson | 0:404dae88af71 | 41 | 9510, 9455, 9396, 9335, 9271, 9205, 9135, 9063, 8987, |
MartinJohnson | 0:404dae88af71 | 42 | 8910, 8829, 8746, 8660, 8571, 8480, 8386, 8290, 8191, |
MartinJohnson | 0:404dae88af71 | 43 | 8090, 7986, 7880, 7771, 7660, 7547, 7431, 7313, 7193, |
MartinJohnson | 0:404dae88af71 | 44 | 7071, 6946, 6819, 6691, 6560, 6427, 6293, 6156, 6018, |
MartinJohnson | 0:404dae88af71 | 45 | 5877, 5735, 5591, 5446, 5299, 5150, 5000, 4848, 4694, |
MartinJohnson | 0:404dae88af71 | 46 | 4539, 4383, 4226, 4067, 3907, 3746, 3583, 3420, 3255, |
MartinJohnson | 0:404dae88af71 | 47 | 3090, 2923, 2756, 2588, 2419, 2249, 2079, 1908, 1736, |
MartinJohnson | 0:404dae88af71 | 48 | 1564, 1391, 1218, 1045, 871, 697, 523, 348, 174, |
MartinJohnson | 0:404dae88af71 | 49 | 0, -174, -348, -523, -697, -871, -1045, -1218, -1391, |
MartinJohnson | 0:404dae88af71 | 50 | -1564, -1736, -1908, -2079, -2249, -2419, -2588, -2756, -2923, |
MartinJohnson | 0:404dae88af71 | 51 | -3090, -3255, -3420, -3583, -3746, -3907, -4067, -4226, -4383, |
MartinJohnson | 0:404dae88af71 | 52 | -4539, -4694, -4848, -4999, -5150, -5299, -5446, -5591, -5735, |
MartinJohnson | 0:404dae88af71 | 53 | -5877, -6018, -6156, -6293, -6427, -6560, -6691, -6819, -6946, |
MartinJohnson | 0:404dae88af71 | 54 | -7071, -7193, -7313, -7431, -7547, -7660, -7771, -7880, -7986, |
MartinJohnson | 0:404dae88af71 | 55 | -8090, -8191, -8290, -8386, -8480, -8571, -8660, -8746, -8829, |
MartinJohnson | 0:404dae88af71 | 56 | -8910, -8987, -9063, -9135, -9205, -9271, -9335, -9396, -9455, |
MartinJohnson | 0:404dae88af71 | 57 | -9510, -9563, -9612, -9659, -9702, -9743, -9781, -9816, -9848, |
MartinJohnson | 0:404dae88af71 | 58 | -9876, -9902, -9925, -9945, -9961, -9975, -9986, -9993, -9998, |
MartinJohnson | 0:404dae88af71 | 59 | -10000, -9998, -9993, -9986, -9975, -9961, -9945, -9925, -9902, |
MartinJohnson | 0:404dae88af71 | 60 | -9876, -9848, -9816, -9781, -9743, -9702, -9659, -9612, -9563, |
MartinJohnson | 0:404dae88af71 | 61 | -9510, -9455, -9396, -9335, -9271, -9205, -9135, -9063, -8987, |
MartinJohnson | 0:404dae88af71 | 62 | -8910, -8829, -8746, -8660, -8571, -8480, -8386, -8290, -8191, |
MartinJohnson | 0:404dae88af71 | 63 | -8090, -7986, -7880, -7771, -7660, -7547, -7431, -7313, -7193, |
MartinJohnson | 0:404dae88af71 | 64 | -7071, -6946, -6819, -6691, -6560, -6427, -6293, -6156, -6018, |
MartinJohnson | 0:404dae88af71 | 65 | -5877, -5735, -5591, -5446, -5299, -5150, -5000, -4848, -4694, |
MartinJohnson | 0:404dae88af71 | 66 | -4539, -4383, -4226, -4067, -3907, -3746, -3583, -3420, -3255, |
MartinJohnson | 0:404dae88af71 | 67 | -3090, -2923, -2756, -2588, -2419, -2249, -2079, -1908, -1736, |
MartinJohnson | 0:404dae88af71 | 68 | -1564, -1391, -1218, -1045, -871, -697, -523, -348, -174 |
MartinJohnson | 0:404dae88af71 | 69 | }; |
MartinJohnson | 0:404dae88af71 | 70 | |
MartinJohnson | 0:404dae88af71 | 71 | //***************************************************************************** |
MartinJohnson | 0:404dae88af71 | 72 | // Function mthSine(u16 angle) |
MartinJohnson | 0:404dae88af71 | 73 | // |
MartinJohnson | 0:404dae88af71 | 74 | // Return sine value from 'angle' parameter in degrees. The returned value |
MartinJohnson | 0:404dae88af71 | 75 | // is multiplied by 10000 (-10000..0..10000). The angle must be an integer |
MartinJohnson | 0:404dae88af71 | 76 | // value from 0 to 359. |
MartinJohnson | 0:404dae88af71 | 77 | // |
MartinJohnson | 0:404dae88af71 | 78 | // parameters: |
MartinJohnson | 0:404dae88af71 | 79 | // angle Angle value in degrees |
MartinJohnson | 0:404dae88af71 | 80 | // |
MartinJohnson | 0:404dae88af71 | 81 | // return: Sine |
MartinJohnson | 0:404dae88af71 | 82 | //***************************************************************************** |
MartinJohnson | 0:404dae88af71 | 83 | i16 mthSin(u16 angle) |
MartinJohnson | 0:404dae88af71 | 84 | { |
MartinJohnson | 0:404dae88af71 | 85 | u16 a = (angle % 359); |
MartinJohnson | 0:404dae88af71 | 86 | |
MartinJohnson | 0:404dae88af71 | 87 | return SineTable[a]; |
MartinJohnson | 0:404dae88af71 | 88 | } |
MartinJohnson | 0:404dae88af71 | 89 | |
MartinJohnson | 0:404dae88af71 | 90 | //***************************************************************************** |
MartinJohnson | 0:404dae88af71 | 91 | // Function mthCos(u16 angle) |
MartinJohnson | 0:404dae88af71 | 92 | // |
MartinJohnson | 0:404dae88af71 | 93 | // Return cosine value from 'angle' parameter in degrees. The returned |
MartinJohnson | 0:404dae88af71 | 94 | // value is multiplied by 10000 (-10000..0..10000). The angle must be an |
MartinJohnson | 0:404dae88af71 | 95 | // integer value from 0 to 359 |
MartinJohnson | 0:404dae88af71 | 96 | // |
MartinJohnson | 0:404dae88af71 | 97 | // parameters: |
MartinJohnson | 0:404dae88af71 | 98 | // angle Angle value in degrees |
MartinJohnson | 0:404dae88af71 | 99 | // |
MartinJohnson | 0:404dae88af71 | 100 | // return: Cosine |
MartinJohnson | 0:404dae88af71 | 101 | //***************************************************************************** |
MartinJohnson | 0:404dae88af71 | 102 | i16 mthCos(u16 angle) |
MartinJohnson | 0:404dae88af71 | 103 | { |
MartinJohnson | 0:404dae88af71 | 104 | u16 a = ((angle + 90) % 359); |
MartinJohnson | 0:404dae88af71 | 105 | |
MartinJohnson | 0:404dae88af71 | 106 | return SineTable[a]; |
MartinJohnson | 0:404dae88af71 | 107 | } |
MartinJohnson | 0:404dae88af71 | 108 | |
MartinJohnson | 0:404dae88af71 | 109 |