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!
Code: Select all
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
Regards
Sebastian