Create a Game in C language with the 8051 IDE MCU

3

I am trying to develop a game within the microprocessor curriculum, so the game is a doll that has to dodge bombs, so I have to create the doll, the bombs and get them to play. I already have a lot of code but I think it gets stuck in a while loop and I do not understand why. Is exposing here a piece of my code are able to help me ??

void main (void)
{   
unsigned char i,counter=1;

start=0;
end=0;
IE=0b10000101;
En=1;
LCD_init ();
while(start!=0);
while(end==1);
Inicio();
CriarBonecoBomba();
x=0;
y=0;
score=0;

for(i=0;i<16;i++)
{
    var[0][i]=' ';
    var[1][i]=' ';
}
while(end==0) // salta da 1a interrupção la ao fundo para aqui e não sai daqui
{
    while (start==1)
    {
        MovBoneco();
        desloca_esq();
        if((counter+3)%6==0)
            cria_bomba(1);
        else
            if(counter%6==0)
                cria_bomba(2);
            else
                cria_bomba(0);
        if(var[y][x]==1|| 1==var[y][x-1])
        {
            LCD_comando(0b10000000);
            LCD_date(' ');
            LCD_date(' ');
            LCD_date(' ');
            LCD_date('G');
            LCD_date('A');  
            LCD_date('M');
            LCD_date('E');
            LCD_date(' ');
            LCD_date('O');
            LCD_date('V');
            LCD_date('E');
            LCD_date('R');
            while(1);
        }
    MovBoneco();
    AtualizarLCD();
    counter++;
    if(var[0][0]==1||var[1][0]==1)
        score=score+5;
    display7segmentos();
}
}
}

void RSIEXT0(void)__interrupt (0)
{
start=1;
}

void RSIEXT1(void)__interrupt (2)
{
end==1;
}
    
asked by anonymous 23.12.2014 / 22:58

1 answer

2

Both start and end are initialized with the value zero (0) at the start of its main function. They were not declared with a type (the compiler you use does not generate any warning of this?) Or else you declared them out of the scope of the function and did not put that code in the question.

If it is case 1, even the compiler (possibly) not claiming the scope of variables is local (that is, it belongs only to the main function). And so, any external change actually changes different variables (from another scope).

If it is case 2 (which I think is most likely), the variables are global and everything should work correctly (assuming their "interrupts" are actually being called). However, there is a little bit in the RSIEXT1 function where you use the equality operator (two equal signs: == ) instead of the assignment operator (a single equal sign: = ). :)

    
24.12.2014 / 01:28