X+Y is constant for all tiles in a column, and X-Y is constant for all tiles in a row. In your current screenshot, it seems like your screen is centered at (X=15,Y=15) or alternatively, at (X+Y=30,X-Y=0)
- 20 <= X+Y < 40 (vertical axis)
- -8 <= X-Y < 10 (horizontal axis)
Your loop should be based on X+Y, and X-Y, not precisely X and Y.
// current viewport is x+y=20to40 by x-y=-8to10
for(a=20;a<40;a++) {
for(b=-8;b<10;b++) {
if ((b&1) != (a&1)) continue;
x = (a+b)/2;
y = (a-b)/2;
// do stuff with X and Y here
}
}