Subversion Repositories Projects

Rev

Rev 1199 | Blame | Compare with Previous | Last modification | View Log | RSS feed

/****************************************************************************
 *   Copyright (C) 2011-2012 by Claas Anders "CaScAdE" Rathje               *
 *   admiralcascade@gmail.com                                               *
 *   Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/                 *
 *                                                                          *
 *   This program is free software; you can redistribute it and/or modify   *
 *   it under the terms of the GNU General Public License as published by   *
 *   the Free Software Foundation; either version 2 of the License.         *
 *                                                                          *
 *   This program is distributed in the hope that it will be useful,        *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 *   GNU General Public License for more details.                           *
 *                                                                          *
 *   You should have received a copy of the GNU General Public License      *
 *   along with this program; if not, write to the                          *
 *   Free Software Foundation, Inc.,                                        *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.              *
 ****************************************************************************/


#include "player.h"

const uint8_t SIMPLSESCAN [][8] PROGMEM = {
    { 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
    { 0b10000000, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
    { 0b00000000, 0b10100000, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
    { 0b00000000, 0b00000000, 0b10101000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
    { 0b00000000, 0b00000000, 0b00000000, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 10},
    { 0b00000000, 0b00000000, 0b00000000, 0b10000000, 0b00001010, 0b00000000, 0b00000000, 10},
    { 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b10100000, 0b00000010, 0b00000000, 10},
    { 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b10101000, 0b00000000, 10},
    { 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010000, 0b00000000, 10},
    { 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00010101, 0b00000000, 10},
    { 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010000, 0b00000001, 0b00000000, 10},
    { 0b00000000, 0b00000000, 0b00000000, 0b01000000, 0b00000101, 0b00000000, 0b00000000, 10},
    { 0b00000000, 0b00000000, 0b00000000, 0b00010101, 0b00000000, 0b00000000, 0b00000000, 10},
    { 0b00000000, 0b00000000, 0b01010100, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
    { 0b00000000, 0b01010000, 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
    { 0b01000000, 0b00000101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
    { 0b00010101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10}
};


const uint8_t TRIPLEROUND [][8] PROGMEM = {
    { 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
    { 0b10000000, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
    { 0b00000000, 0b10100000, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
    { 0b00000000, 0b00000000, 0b10101000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
    { 0b00000000, 0b00000000, 0b00000000, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 10},
    { 0b00000000, 0b00000000, 0b00000000, 0b10000000, 0b00001010, 0b00000000, 0b00000000, 10},
    { 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b10100000, 0b00000010, 0b00000000, 10},
    { 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b10101000, 0b00000000, 10}
};

const uint8_t SOMETHING [][8] PROGMEM = {
    { 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000010, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00001010, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00101010, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000010, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00001010, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00101010, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000010, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00001010, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00101010, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00101010, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00001010, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000010, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00101010, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00001010, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000010, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00101010, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00001010, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000010, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b10101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b10101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b10101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
    { 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01000000, 5},
    { 0b00000101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010000, 5},
    { 0b00010101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010100, 5},
    { 0b01010101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010101, 5},
    { 0b01010101, 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b01000000, 0b01010101, 5},
    { 0b01010101, 0b00000101, 0b00000000, 0b00000000, 0b00000000, 0b01010000, 0b01010101, 5},
    { 0b01010101, 0b00010101, 0b00000000, 0b00000000, 0b00000000, 0b01010100, 0b01010101, 5},
    { 0b01010101, 0b01010101, 0b00000000, 0b00000000, 0b00000000, 0b01010101, 0b01010101, 5},
    { 0b01010101, 0b01010101, 0b00000001, 0b00000000, 0b01000000, 0b01010101, 0b01010101, 5},
    { 0b01010101, 0b01010101, 0b00000101, 0b00000000, 0b01010000, 0b01010101, 0b01010101, 5},
    { 0b01010101, 0b01010101, 0b00010101, 0b00000000, 0b01010100, 0b01010101, 0b01010101, 5},
    { 0b01010101, 0b01010101, 0b01010101, 0b00000000, 0b01010101, 0b01010101, 0b01010101, 5},
    { 0b01010101, 0b01010101, 0b01010101, 0b01000001, 0b01010101, 0b01010101, 0b01010101, 5},
    { 0b01010101, 0b01010101, 0b01010101, 0b01010101, 0b01010101, 0b01010101, 0b01010101, 5},
    { 0b01010101, 0b01010101, 0b01010101, 0b01000001, 0b01010101, 0b01010101, 0b01010101, 5},
    { 0b01010101, 0b01010101, 0b01010101, 0b00000000, 0b01010101, 0b01010101, 0b01010101, 5},
    { 0b01010101, 0b01010101, 0b00010101, 0b00000000, 0b01010100, 0b01010101, 0b01010101, 5},
    { 0b01010101, 0b01010101, 0b00000101, 0b00000000, 0b01010000, 0b01010101, 0b01010101, 5},
    { 0b01010101, 0b01010101, 0b00000001, 0b00000000, 0b01000000, 0b01010101, 0b01010101, 5},
    { 0b01010101, 0b01010101, 0b00000000, 0b00000000, 0b00000000, 0b01010101, 0b01010101, 5},
    { 0b01010101, 0b00010101, 0b00000000, 0b00000000, 0b00000000, 0b01010100, 0b01010101, 5},
    { 0b01010101, 0b00000101, 0b00000000, 0b00000000, 0b00000000, 0b01010000, 0b01010101, 5},
    { 0b01010101, 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b01000000, 0b01010101, 5},
    { 0b01010101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010101, 5},
    { 0b00010101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010100, 5},
    { 0b00000101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010000, 5},
    { 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01000000, 5}
};



volatile uint8_t runtime;

void inline player_timer_callback() {
    if (runtime > 0) {
        runtime--;
    }
}



volatile uint8_t *animbase = (uint8_t*)SIMPLSESCAN;
volatile uint16_t animlength = sizeof (SIMPLSESCAN) / 8;
volatile uint16_t animindex = 0;

void inline player(void) {
    if (runtime == 0) {
        for (uint8_t i = 0; i <= 6; i++) {
            animation[i] = pgm_read_byte(animbase + animindex * 8 + i);
        }
        runtime = pgm_read_byte(animbase + animindex * 8 + 7);
        animindex++;
        animindex %= animlength;
    }
    if (set_pressed()) {
        player_changeanim(1);
    }
}

typedef struct {
    uint8_t* base;
    uint16_t length;
} animation_t;

animation_t animations[] = {
    {(uint8_t*)SIMPLSESCAN, sizeof (SIMPLSESCAN) / 8},
    {(uint8_t*)TRIPLEROUND, sizeof (TRIPLEROUND) / 8},
    {(uint8_t*)SOMETHING, sizeof (SOMETHING) / 8}
};

uint8_t player_current_animation = 0;

void player_changeanim(uint8_t increment) {
    if (increment) {
        player_current_animation = (player_current_animation + 1) % (sizeof (animations) / sizeof (animation_t));
        blinkNumer(animation, player_current_animation + 1, 3);
    }
    animbase = animations[player_current_animation].base;
    animlength = animations[player_current_animation].length;
    animindex = 0;
}