@majikeyric: I scale the pointer by a factor of 4, so 4 sprites can be on the same line. Plus, the code checks if these four "slots" in spritebuffer are already occupied before writing coords. In yes-case, the code does a litte search for the best available slot; in most cases by adding y+1 and skipping the uppermost line of the sprite in the drawing code.
Also, the code reminds itself of the uppermost and lowermost sprite coords, and searches the buffer only within these y-coordinates / y-slots. Therefore not the whole buffer needs to be searched through every time; only the area between the lowest and highest sprite. This saves a lot of memory access.
|