← BA8B Blit an object's sprite shifted N pixels, over three columns Map BB38 → Recompose flagged cells into the back buffer
BB11: Compute an object's back-buffer address from its pixel position
Computes the back-buffer address of an object's top-left pixel, and the sub-byte shift its X leaves.
Input
IX the object's sprite record
Output
BC back-buffer address of its top-left pixel
A the sub-byte shift, 0 when byte-aligned
IX unchanged
object_backbuf_addr BB11 LD A,(IX+$00) Turn X into the object's character column, in C.
BB14 RRCA
BB15 RRCA
BB16 RRCA
BB17 AND $1F
BB19 LD C,A
BB1A LD L,(IX+$01) Take the Y pixel coordinate.
BB1D LD A,L Take the pixel row within the character cell from the low bits of Y.
BB1E AND $07
BB20 LD B,A
BB21 LD A,L Build the high byte from the back-buffer's base page, the screen third and the pixel row.
BB22 AND $C0
BB24 RRCA
BB25 RRCA
BB26 RRCA
BB27 ADD A,B
BB28 ADD A,BACKBUF_BASE/$100
BB2A LD B,A
BB2B LD A,L Build the low byte from the character row within the third and the column.
BB2C AND $38
BB2E RLCA
BB2F RLCA
BB30 ADD A,C
BB31 LD C,A
BB32 LD A,(IX+$00) Return the pixel offset into the byte as the shift, 0 when X is byte-aligned.
BB35 AND $07
BB37 RET
← BA8B Blit an object's sprite shifted N pixels, over three columns Map BB38 → Recompose flagged cells into the back buffer
Fork me on GitHub