Hi,

I am wondering if I am facing a known CC65 bug: I am using a simple macro to calculate, in which 32x30 tile the given x/y coordinates a placed.

The calculation is as follows: (((y/8)*32)+(x/8)). To calculate this more efficiently, I am transforming this formula, using bit operators like follows:

I rebuild each version using Java and here all versions produce the same result. Here is the Java code:

int x = 110;

int y = 50;

int result1 = (((y/8)*32)+(x/8));

int result2 = (((y>>3)<<5)|(x>>3));

int result3 = ((y<<2)|(x>>3));

System.out.println(result1); //output: 205

System.out.println(result2); //output: 205

System.out.println(result3); //output: 205

I guess there is something special with CC65 bit shifting? The problem obviously lies in the part when combining two shifts into one.

Regards

Sebastian

I am wondering if I am facing a known CC65 bug: I am using a simple macro to calculate, in which 32x30 tile the given x/y coordinates a placed.

The calculation is as follows: (((y/8)*32)+(x/8)). To calculate this more efficiently, I am transforming this formula, using bit operators like follows:

- step 0: (((y/8)*32)+(x/8)) --> working

step 1: (((y/8)*32)|(x>>3)) --> working

step 2: (((y>>3)*32)|(x>>3)) --> working

step 3: (((y>>3)<<5)|(x>>3)) --> working

step 4: ((y<<2)|(x>>3)) --> not working!

I rebuild each version using Java and here all versions produce the same result. Here is the Java code:

**Code:**

int x = 110;

int y = 50;

int result1 = (((y/8)*32)+(x/8));

int result2 = (((y>>3)<<5)|(x>>3));

int result3 = ((y<<2)|(x>>3));

System.out.println(result1); //output: 205

System.out.println(result2); //output: 205

System.out.println(result3); //output: 205

I guess there is something special with CC65 bit shifting? The problem obviously lies in the part when combining two shifts into one.

Regards

Sebastian