Manic Miner: Routine at 37503

| Routines

37503: Draw Willy to the screen buffer at 24576

Used by the routine at 37434.
37503 | LD A,(32872) | Pick up Willy's y-coordinate from 32872
37506 | LD IXh,131 | Point IX at the entry in the screen buffer address lookup table at 33536 that corresponds to Willy's y-coordinate
37509 | LD IXl,A
37511 | LD A,(32874) | Pick up Willy's direction and movement flags from 32874
37514 | AND 1 | Now E=0 if Willy is facing right, or 128 if he's facing left
37516 | RRCA
37517 | LD E,A
37518 | LD A,(32873) | Pick up Willy's animation frame (0-3) from 32873
37521 | AND 3 | Point DE at the sprite graphic data for Willy's current animation frame (see 33280)
37523 | RRCA
37524 | RRCA
37525 | RRCA
37526 | OR E
37527 | LD E,A
37528 | LD D,130
37530 | LD B,16 | There are 16 rows of pixels to copy
37532 | LD A,(32876) | Pick up Willy's screen x-coordinate (0-31) from 32876
37535 | AND 31
37537 | LD C,A | Copy it to C
37538 | LD A,(IX+0) | Set HL to the address in the screen buffer at 24576 that corresponds to where we are going to draw the next pixel row of the sprite graphic
37541 | LD H,(IX+1)
37544 | OR C
37545 | LD L,A
37546 | LD A,(DE) | Pick up a sprite graphic byte
37547 | OR (HL) | Merge it with the background
37548 | LD (HL),A | Save the resultant byte to the screen buffer
37549 | INC HL | Move HL along to the next cell to the right
37550 | INC DE | Point DE at the next sprite graphic byte
37551 | LD A,(DE) | Pick it up in A
37552 | OR (HL) | Merge it with the background
37553 | LD (HL),A | Save the resultant byte to the screen buffer
37554 | INC IX | Point IX at the next entry in the screen buffer address lookup table at 33536
37556 | INC IX
37558 | INC DE | Point DE at the next sprite graphic byte
37559 | DJNZ 37538 | Jump back until all 16 rows of pixels have been drawn
37561 | RET |