if( sorted ) {
double maxY = ( yy + 1 ) * cellHeight;
while( true ) {
double minY = 0;
int storedX = 0;
Sprite storedSprite = null;
for( int xx = 0; xx <= mapX2 - mapX1; xx++ ) {
int maskedX = xx & yMask;
int n = xN[ xx ];
if( n >= listSize[ maskedY ][ maskedX ] ) continue;
Sprite sprite = lists[ maskedY ][ maskedX ][ n ];
double y0 = sprite.getY();
if( y0 >= maxY ) continue;
if( storedSprite == null || y0 < minY ) {
minY = y0;
storedX = xx;
storedSprite = sprite;
}
}
if( storedSprite == null ) break;
if( storedSprite.checkValue != Sprite.checkNum ) {
if( vis != null ) {
vis.drawUsingSprite( storedSprite, storedSprite, drawingColor );
} else {
storedSprite.draw( drawingColor );
}
storedSprite.checkValue = Sprite.checkNum;
}
xN[ storedX ] += 1;
}
} else {
for( int xx = mapX1; xx <= mapX2; xx++ ) {
int maskedX = xx & xMask;
Sprite array[] = lists[ maskedY ][ maskedX ];
for( int n = 0; n < listSize[ maskedY ][ maskedX ]; n++ ) {
Sprite sprite = array[ n ];
if( sprite.checkValue != Sprite.checkNum ) {
if( vis != null ) {
sprite.drawUsingVisualizer( vis, drawingColor );
} else {
sprite.draw( drawingColor );
}
sprite.checkValue = Sprite.checkNum;
}
}
}