60 lines
1.3 KiB
C
60 lines
1.3 KiB
C
#include <avr/io.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "main.h"
|
|
#include "display.h"
|
|
#include "tetris.h"
|
|
|
|
static uint8_t rwth_logo[] = {0x7c, 0x50, 0x2c, 0x00, 0x78, 0x04, 0x18, 0x04, 0x78, 0x40, 0x7c, 0x40, 0x7c, 0x10, 0x7c, 0x00};
|
|
|
|
uint8_t get_seed() {
|
|
uint8_t seed = 0;
|
|
uint8_t *p = (uint8_t *) (RAMEND+1);
|
|
extern uint8_t __heap_start;
|
|
|
|
while (p >= &__heap_start + 1)
|
|
seed ^= * (--p);
|
|
|
|
return seed;
|
|
}
|
|
|
|
int main( void ) {
|
|
display_init();
|
|
srand(get_seed());
|
|
|
|
/* setup gamepad */
|
|
DDRB = 0x00;
|
|
PORTB = 0xff;
|
|
|
|
while ( TRUE ) {
|
|
/* Demo 0: Bitmaps */
|
|
display_buffer = rwth_logo;
|
|
_delay_ms(1500);
|
|
|
|
/* Demo 1: Tetris */
|
|
tetris_start();
|
|
|
|
/* Demo 4: Conways Game of Life */
|
|
conway_start();
|
|
|
|
/* Demo 2: Laufschrift */
|
|
/*char text[] = "'Nobody will ever need more than 640k RAM!' - Bill Gates, 1981 ;-)";
|
|
uint16_t len = 4*strlen(text)+32; // 4 Bytes pro Character + 2 * 16 Bytes Padding
|
|
volatile uint8_t text_buffer[len];
|
|
display_print(text, text_buffer);
|
|
|
|
// Starte Laufschrift
|
|
display_laufschrift(text_buffer, len, 120, 1);*/
|
|
|
|
/* Demo 3: Zufall */
|
|
/*volatile uint8_t random_buffer[16];
|
|
display_buffer = memset(random_buffer, 0, 16);
|
|
srand(get_seed());
|
|
|
|
for (uint16_t i = 0; i < 450; i++) {
|
|
display_toggle(rand()%8, rand()%16);
|
|
display_buffer[0] = i;
|
|
_delay_ms(20);
|
|
}*/
|
|
}
|
|
}
|