#54282 - Ultima2876 - Sat Sep 17, 2005 6:38 pm
Code: |
int *map_write_x = 0;
map_write_x = &columnx1; for(loop = 0; loop < 18; loop++) //update the tiles at the edge of the screen { ((u16*)map_vram)[(32 * loop) + columnx1] = ((u16*)map)[(map_width * loop) + *map_position_x]; } |
That does exactly what I want it to do.
Code: |
int *map_write_x = 0;
map_write_x = &columnx1; for(loop = 0; loop < 18; loop++) //update the tiles at the edge of the screen { ((u16*)map_vram)[(32 * loop) + *map_write_x] = ((u16*)map)[(map_width * loop) + *map_position_x]; } |
But this doesn't. I want to have a pointer to columnx1, and reference the pointer instead of the variable itself. (This is because I'll have different columnx's and would rather just change the pointer than have multiple copies of the code). This is only the bit of the code with problems - the rest of the code is pretty big and would just clutter stuff if I put it in this post. The pointer is referenced in the rest of the code too - for example:
Code: |
*map_write_x += 1;
*map_write_x = *map_write_x & 0x1F; |
That actually does its job - adds 1 to columnx1, and if columnx1 goes above 31 it wraps it to 0.
But why can't I use the pointer to the variable in my for loop? Is there something I'm missing?
Thanks in advance =P