![]() |
Routines |
| Prev: BFE3 | Up: Map | Next: C0E6 |
|
Used by the routine at draw_stars.
One layer of draw_stars. For each star: if it was drawn last pass (bit 0 of its x in the table is the 'drawn' flag) its old place is its position plus the layer's old offsets, and the erase is set up there. Its new place is tested by star_in_sight and, if it is inside the play area, the drawing is set up too. draw_sprite_pair, the sprite compositor, then erases and draws in one go, and the new attribute cell is made white.
A star's image is a graphic number kept in the layer's frame slot: the layer's base number (7, 9 or 11, at +1 of the slot) plus bit 0 of the star's x, since x is held in 2-pixel steps and an odd x takes a copy of the image one pixel further right (see star_offsets).
|
||||||||
| draw_star_layer | C032 | PUSH IX | Keep the frame slot; six stars. | |||||
| C034 | LD B,$06 | |||||||
| draw_star_layer_0 | C036 | CALL clear_sprite_pair | Reset the mover (clear_sprite_pair) and the 'anything to do' flag at star_drawn. | |||||
| C039 | LD (star_drawn),A | |||||||
| C03C | PUSH BC | Not drawn last pass: nothing to erase. | ||||||
| C03D | PUSH IX | |||||||
| C03F | LD HL,(star_pointer) | |||||||
| C042 | BIT 0,(HL) | |||||||
| C044 | JR Z,draw_star_layer_1 | |||||||
| C046 | LD BC,$0006 | Its old place: the star's x (flag off) and y plus the layer's old offsets (six bytes on from the new ones), into the mover's old position at old_sprite_x. | ||||||
| C049 | LD HL,(star_layer_pointer) | |||||||
| C04C | ADD HL,BC | |||||||
| C04D | LD DE,(star_pointer) | |||||||
| C051 | LD A,(DE) | |||||||
| C052 | AND $FE | |||||||
| C054 | ADD A,(HL) | |||||||
| C055 | LD (old_sprite_x),A | |||||||
| C058 | INC HL | |||||||
| C059 | INC DE | |||||||
| C05A | LD A,(DE) | |||||||
| C05B | ADD A,(HL) | |||||||
| C05C | LD (old_sprite_y),A | |||||||
| C05F | LD A,(star_drawn) | There is something to do. | ||||||
| C062 | OR $01 | |||||||
| C064 | LD (star_drawn),A | |||||||
| C067 | JR draw_star_layer_2 | |||||||
| draw_star_layer_1 | C069 | JR draw_star_layer_3 | A jump to a jump: the way round for 'not drawn'. | |||||
| draw_star_layer_2 | C06B | LD A,(old_sprite_x) | The old image: the layer's base number plus bit 0 of x; then x made even for the screen address. | |||||
| C06E | AND $01 | |||||||
| C070 | ADD A,(IX+$01) | |||||||
| C073 | LD (IX+$00),A | |||||||
| C076 | LD A,(old_sprite_x) | |||||||
| C079 | AND $FE | |||||||
| C07B | LD (old_sprite_x),A | |||||||
| C07E | CALL graphic_frame_list | Set up the erase: the image's address (graphic_frame_list), its height clipped to the play area, and the eraser for its width. | ||||||
| C081 | CALL old_sprite_header | |||||||
| C084 | CALL set_old_sprite | |||||||
| draw_star_layer_3 | C087 | EXX | Work out the new place (the code at star_in_sight); out of sight, clear the 'drawn' flag. | |||||
| C088 | CALL star_in_sight | |||||||
| C08B | JR NZ,draw_star_layer_4 | |||||||
| C08D | LD HL,(star_pointer) | |||||||
| C090 | RES 0,(HL) | |||||||
| C092 | JR draw_star_layer_5 | |||||||
| draw_star_layer_4 | C094 | LD HL,(star_pointer) | In sight: set the flag, choose the image for the new x, and set up the drawing the same way. | |||||
| C097 | SET 0,(HL) | |||||||
| C099 | LD A,(new_sprite_x) | |||||||
| C09C | AND $01 | |||||||
| C09E | ADD A,(IX+$01) | |||||||
| C0A1 | LD (IX+$00),A | |||||||
| C0A4 | LD A,(new_sprite_x) | |||||||
| C0A7 | AND $FE | |||||||
| C0A9 | LD (new_sprite_x),A | |||||||
| C0AC | CALL graphic_frame_list | |||||||
| C0AF | CALL new_sprite_header | |||||||
| C0B2 | CALL set_new_sprite | |||||||
| draw_star_layer_5 | C0B5 | LD A,(star_drawn) | Anything to erase or draw: do it, and make the star's new attribute cell white ($47). | |||||
| C0B8 | AND A | |||||||
| C0B9 | JR Z,draw_star_layer_6 | |||||||
| C0BB | CALL draw_sprite_pair | |||||||
| C0BE | LD HL,(new_sprite_x) | |||||||
| C0C1 | CALL pixel_to_attribute | |||||||
| C0C4 | LD (HL),$47 | |||||||
| draw_star_layer_6 | C0C6 | LD DE,(star_pointer) | On to the next star's two bytes. | |||||
| C0CA | INC DE | |||||||
| C0CB | INC DE | |||||||
| C0CC | LD (star_pointer),DE | |||||||
| C0D0 | POP IX | Six stars. | ||||||
| C0D2 | POP BC | |||||||
| C0D3 | DEC B | |||||||
| C0D4 | JP NZ,draw_star_layer_0 | |||||||
| C0D7 | POP IX | The next layer's frame slot and offsets are two bytes on. | ||||||
| C0D9 | INC IX | |||||||
| C0DB | INC IX | |||||||
| C0DD | LD HL,(star_layer_pointer) | |||||||
| C0E0 | INC HL | |||||||
| C0E1 | INC HL | |||||||
| C0E2 | LD (star_layer_pointer),HL | |||||||
| C0E5 | RET | |||||||
| Prev: BFE3 | Up: Map | Next: C0E6 |