Prev: B479 Up: Map Next: B4E0
B47D: The unrolled row of a shifted sprite
Entered by the JR in SPRITE_ROW, as many 16-byte units from the end as the sprite is wide. H is the first of the two pages MAKE_TABLES built for this shift. The tables hold complements, so each byte is ANDed with the complement of the mask shifted, and XORed with the complement of the image shifted and complemented again -- which comes to the buffer byte cleared under the shifted mask with the shifted image put in. Page H gives the part of a mask or image byte that stays in the current buffer byte, which is finished and stored; page H + 1 the part that falls into the next, which is begun and left in A for the next unit. The byte the last unit begins is stored after the fifth.
Then, for both runs, BC steps up to the next row by the amount patched into the ADD below, and the loop goes round until A' runs out. The real stack pointer comes back from SAVED_SP, and the RET is the return from DRAW_OBJECT.
Input
A the buffer byte the row starts with
BC its address
H the shift's first table page
SP the sprite's next mask and image bytes
SPRITE_SHIFTED_RUN B47D POP DE the first unit: the buffer byte cleared under the mask and with the image put in, shifted right, and stored
B47E LD L,E
B47F AND (HL)
B480 LD L,D
B481 XOR (HL)
B482 CPL
B483 LD (BC),A
B484 INC BC
B485 INC H the bits that fall out, into the next buffer byte, left in A
B486 LD L,E
B487 LD A,(BC)
B488 AND (HL)
B489 LD L,D
B48A XOR (HL)
B48B CPL
B48C DEC H
B48D POP DE four more units the same
B48E LD L,E
B48F AND (HL)
B490 LD L,D
B491 XOR (HL)
B492 CPL
B493 LD (BC),A
B494 INC BC
B495 INC H
B496 LD L,E
B497 LD A,(BC)
B498 AND (HL)
B499 LD L,D
B49A XOR (HL)
B49B CPL
B49C DEC H
B49D POP DE
B49E LD L,E
B49F AND (HL)
B4A0 LD L,D
B4A1 XOR (HL)
B4A2 CPL
B4A3 LD (BC),A
B4A4 INC BC
B4A5 INC H
B4A6 LD L,E
B4A7 LD A,(BC)
B4A8 AND (HL)
B4A9 LD L,D
B4AA XOR (HL)
B4AB CPL
B4AC DEC H
B4AD POP DE
B4AE LD L,E
B4AF AND (HL)
B4B0 LD L,D
B4B1 XOR (HL)
B4B2 CPL
B4B3 LD (BC),A
B4B4 INC BC
B4B5 INC H
B4B6 LD L,E
B4B7 LD A,(BC)
B4B8 AND (HL)
B4B9 LD L,D
B4BA XOR (HL)
B4BB CPL
B4BC DEC H
B4BD POP DE
B4BE LD L,E
B4BF AND (HL)
B4C0 LD L,D
B4C1 XOR (HL)
B4C2 CPL
B4C3 LD (BC),A
B4C4 INC BC
B4C5 INC H
B4C6 LD L,E
B4C7 LD A,(BC)
B4C8 AND (HL)
B4C9 LD L,D
B4CA XOR (HL)
B4CB CPL
B4CC DEC H
B4CD LD (BC),A store the last spilled byte
This entry point is used by the routine at SPRITE_ALIGNED_RUN.
SPRITE_NEXT_ROW B4CE LD A,C BC up a row: its operand patched by DRAW_OBJECT to 33 less the bytes a row touches
B4CF ADD A,$00
B4D1 LD C,A
B4D2 LD A,B
B4D3 ADC A,$00
B4D5 LD B,A
B4D6 EX AF,AF' the next row, until the height runs out
B4D7 DEC A
B4D8 JP NZ,SPRITE_ROW
B4DB LD SP,(SAVED_SP) the real stack pointer back; return from DRAW_OBJECT
B4DF RET
Prev: B479 Up: Map Next: B4E0