main.c
void switchMode(char newmode){
    PORTA.OUT = 0b11111111; //set LED sink pins to high to turn off LEDs
    mode = newmode;
    if(mode < 14 && mode > 0){//not in a game or boot mode
        if(flashenabled){
            if(eeprom_is_ready()){
                eeprom_write_byte(0,mode);//address,value
                asm("NOP");//almost certainly not needed but whatever
                asm("NOP");
            }
        }
    }
    loop = 255;
    loop2 = 255;
    counter = 0; //reset the counter value
    lastled = 100; //initial invalid value for random modes
    if(mode < 5){
        //precalculate loop ranges to save space:
        term0 = 51 / (mode*mode);
        term1 = 102 / (mode*mode);
        term2 = 153 / (mode*mode);
        term3 = 204 / (mode*mode);
        term4 = 255 / (mode*mode);
    }
    //react game
    reactblackouttime = 0x3F | rand();//rand time between 63-255, this is roughly 2-7 seconds
    reacttimer = 0;//reset the amount of time it took to react (score), before entering game
}
//used to know if we should switch to the new unlocked mode, or if they've beat this game previously
used to know if we should switch to the new unlocked mode, or if they've beat this game previously
used to know if we should switch to the new unlocked mode or if they ' ve beat this game previously
void switchMode(char newmode){
    PORTA.OUT = 0b11111111; 
    mode = newmode;
    if(mode < 14 && mode > 0){
        if(flashenabled){
            if(eeprom_is_ready()){
                eeprom_write_byte(0,mode);
                asm("NOP");
                asm("NOP");
            }
        }
    }
    loop = 255;
    loop2 = 255;
    counter = 0; 
    lastled = 100; 
    if(mode < 5){
        term0 = 51 / (mode*mode);
        term1 = 102 / (mode*mode);
        term2 = 153 / (mode*mode);
        term3 = 204 / (mode*mode);
        term4 = 255 / (mode*mode);
    }
    reactblackouttime = 0x3F | rand();
    reacttimer = 0;
}
void switchMode ( char newmode ) { PORTA . OUT = 0b11111111 ; mode = newmode ; if ( mode < 14 && mode > 0 ) { if ( flashenabled ) { if ( eeprom_is_ready ( ) ) { eeprom_write_byte ( 0 , mode ) ; asm ( " " ) ; asm ( " " ) ; } } } loop = 255 ; loop2 = 255 ; counter = 0 ; lastled = 100 ; if ( mode < 5 ) { term0 = 51 / ( mode * mode ) ; term1 = 102 / ( mode * mode ) ; term2 = 153 / ( mode * mode ) ; term3 = 204 / ( mode * mode ) ; term4 = 255 / ( mode * mode ) ; } reactblackouttime = 0x3F | rand ( ) ; reacttimer = 0 ; }
used to know if we should switch to the new unlocked mode, or if they've beat this game previously
used to know if we should switch to the new unlocked mode or if they ' ve beat this game previously
//set LED sink pins to high to turn off LEDs //not in a game or boot mode //address,value //almost certainly not needed but whatever //reset the counter value //initial invalid value for random modes //precalculate loop ranges to save space: //react game //rand time between 63-255, this is roughly 2-7 seconds //reset the amount of time it took to react (score), before entering game