massung / r-cade

Retro Game Engine for Racket
https://r-cade.io
Other
273 stars 13 forks source link

draw & draw-ex question #23

Closed elephanter closed 4 years ago

elephanter commented 4 years ago

You used (bitwise-and byte #xff) in draw function for bitmask scanline but in draw-ex function just get bit fields from input sprite and use them in bitmask scanlines

is this an error? I don't understand the need of bitwise-and in draw

massung commented 4 years ago

Technically, there's nothing preventing someone from programming this:

(draw 10 10 '(#x11223344))

Without the bitwise-and, the code would attempt to vector-ref to index #x11223344 of the bitmask-rect vector instead of index #x44, resulting - at the very least - in an index out of bounds error.

Does that help?

elephanter commented 4 years ago

Thank you, now I see. And there is no reason to use bitwise-and in draw-ex method because you pick up bit range and there no chance to out of bounds errors