Hi all (At the begining sorry for ma fatal English but foreign languages are not my strong side.)
I finishing engine core for my first game and have one problem with update screen (background) - to put one char without flicking. I use cc65 with Shiru neslib. In example Shiru - game Chase this element is very confusing and I don't understand how calculate adress of memory. I tried to adjust many examples from internet but without success.
Can you help me to write universal function? In my example backgroud was change under hero sprite (similarly as DigDug):
I try this, but I know that something was wrong (change of character = background creazy flicking):
EFFECT:
PS: please don't send me to hell because I have trivial issue for You
I finishing engine core for my first game and have one problem with update screen (background) - to put one char without flicking. I use cc65 with Shiru neslib. In example Shiru - game Chase this element is very confusing and I don't understand how calculate adress of memory. I tried to adjust many examples from internet but without success.
Can you help me to write universal function? In my example backgroud was change under hero sprite (similarly as DigDug):
Code:
//position of sprite hero on screen
static unsigned char hero_x = 160;
static unsigned char hero_y = 136;
//calc for position of char of background
unsigned char x = hero_x>>3;
unsigned char y = hero_y>>3;
//number of destination tile
unsigned char c = 0x10;
update_char(x,y,c); // here I need change background char to 'c' on position (x,y)
static unsigned char hero_x = 160;
static unsigned char hero_y = 136;
//calc for position of char of background
unsigned char x = hero_x>>3;
unsigned char y = hero_y>>3;
//number of destination tile
unsigned char c = 0x10;
update_char(x,y,c); // here I need change background char to 'c' on position (x,y)
I try this, but I know that something was wrong (change of character = background creazy flicking):
Code:
void update_char(unsigned char x, unsigned char y, unsigned char c)
{
static unsigned char update_list[3];
const unsigned char list_init[3]={0x00,0x00,0x00};
unsigned int adr = 0x2000; //This is probably
adr = adr + 0x20 * y + x; // totally f**ked up
update_list[0]=MSB(adr);
update_list[1]=LSB(adr);
update_list[2]=c;
memcpy(update_list,list_init,sizeof(list_init));
set_vram_update(update_list);
}
{
static unsigned char update_list[3];
const unsigned char list_init[3]={0x00,0x00,0x00};
unsigned int adr = 0x2000; //This is probably
adr = adr + 0x20 * y + x; // totally f**ked up
update_list[0]=MSB(adr);
update_list[1]=LSB(adr);
update_list[2]=c;
memcpy(update_list,list_init,sizeof(list_init));
set_vram_update(update_list);
}
EFFECT:
PS: please don't send me to hell because I have trivial issue for You