![]() |
Routines |
| Prev: ADD8 | Up: Map | Next: AF01 |
|
The last step of drawing an object's sprite (move_missile, update_attacker, draw_rocket, update_ground_objects call it after draw_object_images has drawn it): works out the rectangle of character cells the sprite covers in the play area, and fills it with the attribute in colour_patch's third byte, set by prepare_draw from the record's two colours. The rectangle's width goes into colour_patch, its height into the next byte, and fill_attributes paints it, bottom row first.
The sprite's position is the third and fourth bytes of old_sprite_x (its x in pixels, its bottom line), its width in pixels is sprite_width_drawn (the width in bytes, multiplied by 8 in draw_sprite_pair) and its height in lines in the last byte of old_sprite_x, as set_new_sprite left them after clipping. The play area runs across from x 8 to x $E7 and down from line $18 to line $B7; the cells are clipped to it. A cell holding only the sprite's top line (the top line being the last of its cell) is not counted: (bottom OR 7 less (top - 7)) / 8 rounds that one away.
Two more entries: draw_shot comes in at the instruction that takes the width from B, with L, H, D and B already set (the special beam), and colour_carried_parts at the height's working, with the width already in colour_patch.
|
||||
| colour_sprite | AE98 | LD A,(new_sprite_rows) | D = the height less one; nothing drawn, nothing to colour | |
| AE9B | DEC A | |||
| AE9C | RET M | |||
| AE9D | LD D,A | HL = the position (L x, H the bottom line); B = the width in pixels | ||
| AE9E | LD HL,(new_sprite_x) | |||
| AEA1 | LD A,(sprite_width_drawn) | |||
| AEA4 | LD B,A | |||
| AEA5 | LD A,(sprite_left_clip) | cut by the play area's left edge (sprite_left_clip, the record's +10 bit 6): the visible width is taken as x + width - $A4, from x 8 | ||
| AEA8 | AND A | |||
| AEA9 | JR Z,colour_sprite_0 | |||
| AEAB | LD A,L | |||
| AEAC | ADD A,B | |||
| AEAD | SUB $A4 | |||
| AEAF | LD L,$08 | |||
| AEB1 | JR colour_sprite_4 | |||
| colour_sprite_0 | AEB3 | LD A,L | starting in the left border column: start a cell in, a cell narrower | |
| AEB4 | CP $08 | |||
| AEB6 | JR NC,colour_sprite_1 | |||
| AEB8 | ADD A,$08 | |||
| AEBA | LD L,A | |||
| AEBB | LD A,B | |||
| AEBC | SUB $08 | |||
| AEBE | LD B,A | |||
| colour_sprite_1 | AEBF | LD A,L | running past the right edge (x + width over $E8): only up to it | |
| AEC0 | ADD A,$17 | |||
| AEC2 | ADD A,B | |||
| AEC3 | JR NC,colour_sprite_2 | |||
| AEC5 | LD A,$EE | |||
| AEC7 | SUB L | |||
| AEC8 | JR colour_sprite_4 | |||
| colour_sprite_2 | AECA | LD A,L | not on a cell boundary: it spans one cell more | |
| AECB | AND $07 | |||
| AECD | JR Z,colour_sprite_3 | |||
| AECF | LD A,B | |||
| AED0 | ADD A,$08 | |||
| AED2 | LD B,A | |||
|
This entry point is used by the routine at draw_shot.
|
||||
| colour_sprite_3 | AED3 | LD A,L | A = B (the special beam joins here with B its width in pixels) | |
| AED4 | ADD A,B | |||
| AED5 | SUB L | |||
| colour_sprite_4 | AED6 | SRL A | the width in cells; none, nothing to do | |
| AED8 | SRL A | |||
| AEDA | SRL A | |||
| AEDC | LD (colour_patch),A | |||
| AEDF | DEC A | |||
| AEE0 | RET M | |||
|
This entry point is used by the routine at colour_carried_parts.
|
||||
| colour_sprite_5 | AEE1 | LD A,H | E = the top line less 7, but not above line $17 (the play area's top) | |
| AEE2 | SUB D | |||
| AEE3 | SUB $07 | |||
| AEE5 | LD E,A | |||
| AEE6 | CP $17 | |||
| AEE8 | JR NC,colour_sprite_6 | |||
| AEEA | LD E,$17 | |||
| colour_sprite_6 | AEEC | LD A,H | the height in cells; none, nothing to do | |
| AEED | OR $07 | |||
| AEEF | SUB E | |||
| AEF0 | SRL A | |||
| AEF2 | SRL A | |||
| AEF4 | SRL A | |||
| AEF6 | LD ($AF02),A | |||
| AEF9 | DEC A | |||
| AEFA | RET M | |||
| AEFB | LD DE,colour_patch | paint it with fill_attributes, from the cell under the bottom line upwards | ||
| AEFE | JP fill_attributes | |||
| Prev: ADD8 | Up: Map | Next: AF01 |