gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > Wierd problem.

#586 - Lord Graga - Wed Jan 08, 2003 10:06 pm

Code:

void ReadMap (u8 *map)
{
   int x,y;
   for(y=0;y<32;y+=2)
   {
      for(x=0;x<16;x+=2)
      {
         ScreenMem8[x+(y*32)]         ==(map[x+(y*16)])*4+1;
         ScreenMem8[x+(y*32)+1]       ==(map[x+(y*16)])*4+2;
         ScreenMem8[x+(y*32)+32]    ==(map[x+(y*16)])*4+3;
         ScreenMem8[x+(y*32)+33]      ==(map[x+(y*16)])*4+4;
      }
   }
}


This should make a 16*16 map, but it doesn't! to all the screenmem lines it says:

Warning no side effect in void context: <expr> = <expr>

Help!

#593 - tutifruti - Wed Jan 08, 2003 10:28 pm

Hi! You are doing a comparison, not an assignment:

Change all the '==' :

ScreenMem8[x+(y*32)] == (map[x+(y*16)])*4+1;

to '=':
ScreenMem8[x+(y*32)] = (map[x+(y*16)])*4+1;

Also your code is wrong, video memory is 16bits, not 8bits.

#594 - Touchstone - Wed Jan 08, 2003 10:28 pm

Well, you are using the compare operator '==', not the assignment operator '='. :)
_________________
You can't beat our meat

#643 - Lord Graga - Thu Jan 09, 2003 10:09 am

Damn, i have been idiotic. :P

#654 - Burre - Thu Jan 09, 2003 1:46 pm

Lord Graga wrote:
Damn, i have been idiotic. :P


It happens even to the best sometimes. ;)
_________________
"The best optimizer is between your ears..."