| Routines

38455: Draw Willy to the screen buffer at 24576

Used by the routine at 38344.
Input
B | y-coordinate offset (0, 4, 8 or 12)
38455 | LD A,(34255) | Pick up Willy's y-coordinate from 34255
38458 | ADD A,B | Add the y-coordinate offset (to get Willy's true y-coordinate if he's standing on a ramp)
38459 | LD IXh,130 | Point IX at the entry in the screen buffer address lookup table at 33280 that corresponds to Willy's y-coordinate
38462 | LD IXl,A
38464 | LD A,(34256) | Pick up Willy's direction and movement flags from 34256
38467 | AND 1 | Now E=0 if Willy is facing right, or 128 if he's facing left
38469 | RRCA
38470 | LD E,A
38471 | LD A,(34258) | Pick up Willy's animation frame (0-3) from 34258
38474 | AND 3 | Point DE at the sprite graphic data for Willy's current animation frame (see 40192)
38476 | RRCA
38477 | RRCA
38478 | RRCA
38479 | OR E
38480 | LD E,A
38481 | LD D,157
38483 | LD A,(33824) | Pick up the number of the current room from 33824
38486 | CP 29 | Are we in the The Nightmare Room?
38488 | JR NZ,38496 | Jump if not
38490 | LD D,182 | Point DE at the graphic data for the flying pig sprite (46592+E)
38492 | LD A,E
38493 | XOR 128
38495 | LD E,A
38496 | LD B,16 | There are 16 rows of pixels to copy
38498 | LD A,(34259) | Pick up Willy's screen x-coordinate (0-31) from 34259
38501 | AND 31
38503 | LD C,A | Copy it to C
This entry point is used by the routine at 38298 to draw the toilet in The Bathroom.
38504 | 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
38507 | LD H,(IX+1)
38510 | OR C
38511 | LD L,A
38512 | LD A,(DE) | Pick up a sprite graphic byte
38513 | OR (HL) | Merge it with the background
38514 | LD (HL),A | Save the resultant byte to the screen buffer
38515 | INC HL | Move HL along to the next cell to the right
38516 | INC DE | Point DE at the next sprite graphic byte
38517 | LD A,(DE) | Pick it up in A
38518 | OR (HL) | Merge it with the background
38519 | LD (HL),A | Save the resultant byte to the screen buffer
38520 | INC IX | Point IX at the next entry in the screen buffer address lookup table at 33280
38522 | INC IX
38524 | INC DE | Point DE at the next sprite graphic byte
38525 | DJNZ 38504 | Jump back until all 16 rows of pixels have been drawn
38527 | RET |