Rev 1199 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1199 | - | 1 | /**************************************************************************** |
1437 | - | 2 | * Copyright (C) 2011-2012 by Claas Anders "CaScAdE" Rathje * |
1199 | - | 3 | * admiralcascade@gmail.com * |
4 | * Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ * |
||
5 | * * |
||
6 | * This program is free software; you can redistribute it and/or modify * |
||
7 | * it under the terms of the GNU General Public License as published by * |
||
8 | * the Free Software Foundation; either version 2 of the License. * |
||
9 | * * |
||
10 | * This program is distributed in the hope that it will be useful, * |
||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
||
13 | * GNU General Public License for more details. * |
||
14 | * * |
||
15 | * You should have received a copy of the GNU General Public License * |
||
16 | * along with this program; if not, write to the * |
||
17 | * Free Software Foundation, Inc., * |
||
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
||
19 | ****************************************************************************/ |
||
20 | |||
21 | #include "player.h" |
||
22 | |||
23 | const uint8_t SIMPLSESCAN [][8] PROGMEM = { |
||
24 | { 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10}, |
||
25 | { 0b10000000, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10}, |
||
26 | { 0b00000000, 0b10100000, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10}, |
||
27 | { 0b00000000, 0b00000000, 0b10101000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10}, |
||
28 | { 0b00000000, 0b00000000, 0b00000000, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 10}, |
||
29 | { 0b00000000, 0b00000000, 0b00000000, 0b10000000, 0b00001010, 0b00000000, 0b00000000, 10}, |
||
30 | { 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b10100000, 0b00000010, 0b00000000, 10}, |
||
31 | { 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b10101000, 0b00000000, 10}, |
||
32 | { 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010000, 0b00000000, 10}, |
||
33 | { 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00010101, 0b00000000, 10}, |
||
34 | { 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010000, 0b00000001, 0b00000000, 10}, |
||
35 | { 0b00000000, 0b00000000, 0b00000000, 0b01000000, 0b00000101, 0b00000000, 0b00000000, 10}, |
||
36 | { 0b00000000, 0b00000000, 0b00000000, 0b00010101, 0b00000000, 0b00000000, 0b00000000, 10}, |
||
37 | { 0b00000000, 0b00000000, 0b01010100, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10}, |
||
38 | { 0b00000000, 0b01010000, 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10}, |
||
39 | { 0b01000000, 0b00000101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10}, |
||
40 | { 0b00010101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10} |
||
41 | }; |
||
42 | |||
43 | |||
44 | const uint8_t TRIPLEROUND [][8] PROGMEM = { |
||
45 | { 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10}, |
||
46 | { 0b10000000, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10}, |
||
47 | { 0b00000000, 0b10100000, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10}, |
||
48 | { 0b00000000, 0b00000000, 0b10101000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10}, |
||
49 | { 0b00000000, 0b00000000, 0b00000000, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 10}, |
||
50 | { 0b00000000, 0b00000000, 0b00000000, 0b10000000, 0b00001010, 0b00000000, 0b00000000, 10}, |
||
51 | { 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b10100000, 0b00000010, 0b00000000, 10}, |
||
52 | { 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b10101000, 0b00000000, 10} |
||
53 | }; |
||
54 | |||
55 | const uint8_t SOMETHING [][8] PROGMEM = { |
||
56 | { 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
57 | { 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
58 | { 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
59 | { 0b10101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
60 | { 0b10101010, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
61 | { 0b10101010, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
62 | { 0b10101010, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
63 | { 0b10101010, 0b10101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
64 | { 0b10101010, 0b10101010, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
65 | { 0b10101010, 0b10101010, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
66 | { 0b10101010, 0b10101010, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
67 | { 0b10101010, 0b10101010, 0b10101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
68 | { 0b10101010, 0b10101010, 0b10101010, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
69 | { 0b10101010, 0b10101010, 0b10101010, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
70 | { 0b10101010, 0b10101010, 0b10101010, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
71 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
72 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000010, 0b00000000, 0b00000000, 5}, |
||
73 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00001010, 0b00000000, 0b00000000, 5}, |
||
74 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00101010, 0b00000000, 0b00000000, 5}, |
||
75 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000000, 0b00000000, 5}, |
||
76 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000010, 0b00000000, 5}, |
||
77 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00001010, 0b00000000, 5}, |
||
78 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00101010, 0b00000000, 5}, |
||
79 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000000, 5}, |
||
80 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000010, 5}, |
||
81 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00001010, 5}, |
||
82 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00101010, 5}, |
||
83 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 5}, |
||
84 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00101010, 5}, |
||
85 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00001010, 5}, |
||
86 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000010, 5}, |
||
87 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000000, 5}, |
||
88 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00101010, 0b00000000, 5}, |
||
89 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00001010, 0b00000000, 5}, |
||
90 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000010, 0b00000000, 5}, |
||
91 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000000, 0b00000000, 5}, |
||
92 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00101010, 0b00000000, 0b00000000, 5}, |
||
93 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00001010, 0b00000000, 0b00000000, 5}, |
||
94 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000010, 0b00000000, 0b00000000, 5}, |
||
95 | { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
96 | { 0b10101010, 0b10101010, 0b10101010, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
97 | { 0b10101010, 0b10101010, 0b10101010, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
98 | { 0b10101010, 0b10101010, 0b10101010, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
99 | { 0b10101010, 0b10101010, 0b10101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
100 | { 0b10101010, 0b10101010, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
101 | { 0b10101010, 0b10101010, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
102 | { 0b10101010, 0b10101010, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
103 | { 0b10101010, 0b10101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
104 | { 0b10101010, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
105 | { 0b10101010, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
106 | { 0b10101010, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
107 | { 0b10101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
108 | { 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
109 | { 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
110 | { 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
111 | { 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5}, |
||
112 | { 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01000000, 5}, |
||
113 | { 0b00000101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010000, 5}, |
||
114 | { 0b00010101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010100, 5}, |
||
115 | { 0b01010101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010101, 5}, |
||
116 | { 0b01010101, 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b01000000, 0b01010101, 5}, |
||
117 | { 0b01010101, 0b00000101, 0b00000000, 0b00000000, 0b00000000, 0b01010000, 0b01010101, 5}, |
||
118 | { 0b01010101, 0b00010101, 0b00000000, 0b00000000, 0b00000000, 0b01010100, 0b01010101, 5}, |
||
119 | { 0b01010101, 0b01010101, 0b00000000, 0b00000000, 0b00000000, 0b01010101, 0b01010101, 5}, |
||
120 | { 0b01010101, 0b01010101, 0b00000001, 0b00000000, 0b01000000, 0b01010101, 0b01010101, 5}, |
||
121 | { 0b01010101, 0b01010101, 0b00000101, 0b00000000, 0b01010000, 0b01010101, 0b01010101, 5}, |
||
122 | { 0b01010101, 0b01010101, 0b00010101, 0b00000000, 0b01010100, 0b01010101, 0b01010101, 5}, |
||
123 | { 0b01010101, 0b01010101, 0b01010101, 0b00000000, 0b01010101, 0b01010101, 0b01010101, 5}, |
||
124 | { 0b01010101, 0b01010101, 0b01010101, 0b01000001, 0b01010101, 0b01010101, 0b01010101, 5}, |
||
125 | { 0b01010101, 0b01010101, 0b01010101, 0b01010101, 0b01010101, 0b01010101, 0b01010101, 5}, |
||
126 | { 0b01010101, 0b01010101, 0b01010101, 0b01000001, 0b01010101, 0b01010101, 0b01010101, 5}, |
||
127 | { 0b01010101, 0b01010101, 0b01010101, 0b00000000, 0b01010101, 0b01010101, 0b01010101, 5}, |
||
128 | { 0b01010101, 0b01010101, 0b00010101, 0b00000000, 0b01010100, 0b01010101, 0b01010101, 5}, |
||
129 | { 0b01010101, 0b01010101, 0b00000101, 0b00000000, 0b01010000, 0b01010101, 0b01010101, 5}, |
||
130 | { 0b01010101, 0b01010101, 0b00000001, 0b00000000, 0b01000000, 0b01010101, 0b01010101, 5}, |
||
131 | { 0b01010101, 0b01010101, 0b00000000, 0b00000000, 0b00000000, 0b01010101, 0b01010101, 5}, |
||
132 | { 0b01010101, 0b00010101, 0b00000000, 0b00000000, 0b00000000, 0b01010100, 0b01010101, 5}, |
||
133 | { 0b01010101, 0b00000101, 0b00000000, 0b00000000, 0b00000000, 0b01010000, 0b01010101, 5}, |
||
134 | { 0b01010101, 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b01000000, 0b01010101, 5}, |
||
135 | { 0b01010101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010101, 5}, |
||
136 | { 0b00010101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010100, 5}, |
||
137 | { 0b00000101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010000, 5}, |
||
138 | { 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01000000, 5} |
||
139 | }; |
||
140 | |||
141 | |||
142 | |||
143 | volatile uint8_t runtime; |
||
144 | |||
145 | void inline player_timer_callback() { |
||
146 | if (runtime > 0) { |
||
147 | runtime--; |
||
148 | } |
||
149 | } |
||
150 | |||
151 | |||
152 | |||
153 | volatile uint8_t *animbase = (uint8_t*)SIMPLSESCAN; |
||
154 | volatile uint16_t animlength = sizeof (SIMPLSESCAN) / 8; |
||
155 | volatile uint16_t animindex = 0; |
||
156 | |||
157 | void inline player(void) { |
||
158 | if (runtime == 0) { |
||
159 | for (uint8_t i = 0; i <= 6; i++) { |
||
160 | animation[i] = pgm_read_byte(animbase + animindex * 8 + i); |
||
161 | } |
||
162 | runtime = pgm_read_byte(animbase + animindex * 8 + 7); |
||
163 | animindex++; |
||
164 | animindex %= animlength; |
||
165 | } |
||
166 | if (set_pressed()) { |
||
167 | player_changeanim(1); |
||
168 | } |
||
169 | } |
||
170 | |||
171 | typedef struct { |
||
172 | uint8_t* base; |
||
173 | uint16_t length; |
||
174 | } animation_t; |
||
175 | |||
176 | animation_t animations[] = { |
||
177 | {(uint8_t*)SIMPLSESCAN, sizeof (SIMPLSESCAN) / 8}, |
||
178 | {(uint8_t*)TRIPLEROUND, sizeof (TRIPLEROUND) / 8}, |
||
179 | {(uint8_t*)SOMETHING, sizeof (SOMETHING) / 8} |
||
180 | }; |
||
181 | |||
182 | uint8_t player_current_animation = 0; |
||
183 | |||
184 | void player_changeanim(uint8_t increment) { |
||
185 | if (increment) { |
||
186 | player_current_animation = (player_current_animation + 1) % (sizeof (animations) / sizeof (animation_t)); |
||
187 | blinkNumer(animation, player_current_animation + 1, 3); |
||
188 | } |
||
189 | animbase = animations[player_current_animation].base; |
||
190 | animlength = animations[player_current_animation].length; |
||
191 | animindex = 0; |
||
192 | } |