Routines 
Prev: 36564  Up: Map  Next: 37046 
36796  LD A,(34256)  Pick up Willy's direction and movement flags from 34256  
36799  AND 2  Is Willy moving left or right?  
36801  RET Z  Return if not  
36802  LD A,(34262)  Pick up the rope status indicator from 34262  
36805  DEC A  Is Willy on a rope?  
36806  BIT 7,A  
36808  RET Z  Return if so (Willy's movement along a rope is handled at 37726)  
36809  LD A,(34256)  Pick up Willy's direction and movement flags from 34256  
36812  AND 1  Is Willy facing right?  
36814  JP Z,36930  Jump if so  
Willy is moving left.


36817  LD A,(34258)  Pick up Willy's animation frame from 34258  
36820  OR A  Is it 0?  
36821  JR Z,36828  If so, jump to move Willy's sprite left across a cell boundary  
36823  DEC A  Decrement Willy's animation frame at 34258  
36824  LD (34258),A  
36827  RET  
Willy's sprite is moving left across a cell boundary. In the comments that follow, (x,y) refers to the coordinates of the topleft cell currently occupied by Willy's sprite.


36828  LD A,(34257)  Pick up the airborne status indicator from 34257  
36831  LD BC,0  Prepare BC for later addition  
36834  CP 0  Is Willy jumping?  
36836  JR NZ,36874  Jump if so  
36838  LD HL,(34259)  Collect Willy's attribute buffer coordinates from 34259  
36841  LD BC,0  Prepare BC for later addition (again, redundantly)  
36844  LD A,(32986)  Pick up the direction byte of the ramp definition for the current room from 32986  
36847  DEC A  Now A=31 if the ramp goes up to the left, or 65 if it goes up to the right  
36848  OR 161  
36850  XOR 224  
36852  LD E,A  Point HL at the cell at (x1,y+1) if the ramp goes up to the left, or at the cell at (x+1,y+2) if the ramp goes up to the right  
36853  LD D,0  
36855  ADD HL,DE  
36856  LD A,(32964)  Pick up the attribute byte of the ramp tile for the current room from 32964  
36859  CP (HL)  Is there a ramp tile in the cell pointed to by HL?  
36860  JR NZ,36874  Jump if not  
36862  LD BC,32  Prepare BC for later addition  
36865  LD A,(32986)  Pick up the direction byte of the ramp definition for the current room from 32986  
36868  OR A  Does the ramp go up to the right?  
36869  JR NZ,36874  Jump if so  
36871  LD BC,65504  BC=32 (the ramp goes up to the left)  
36874  LD HL,(34259)  Collect Willy's attribute buffer coordinates from 34259  
36877  LD A,L  Is Willy's screen xcoordinate 0 (on the far left)?  
36878  AND 31  
36880  JP Z,38026  If so, move Willy into the room to the left  
36883  ADD HL,BC  Point HL at the cell at (x1,y+1), or at the cell at (x1,y) if Willy is on or about to step onto a ramp that goes up to the left, or at the cell at (x1,y+2) if Willy is walking down a ramp  
36884  DEC HL  
36885  LD DE,32  
36888  ADD HL,DE  
36889  LD A,(32946)  Pick up the attribute byte of the wall tile for the current room from 32946  
36892  CP (HL)  Is there a wall tile in the cell pointed to by HL?  
36893  RET Z  Return if so without moving Willy (his path is blocked)  
36894  LD A,(34255)  Pick up Willy's ycoordinate (Y) from 34255  
36897  SRA C  Now B=Y (if Willy is neither on nor about to step onto a ramp), or Y+16 (if Willy is walking down a ramp), or Y16 (if Willy is on or about to step onto a ramp that goes up to the left); this will be Willy's new ycoordinate  
36899  ADD A,C  
36900  LD B,A  
36901  AND 15  Is Willy at a point in a jump (left) where his sprite occupies three rows of cells?  
36903  JR Z,36914  Jump if not (Willy's sprite is cellaligned)  
36905  LD A,(32946)  Pick up the attribute byte of the wall tile for the current room from 32946  
36908  ADD HL,DE  Point HL at the cell at (x1,y+2)  
36909  CP (HL)  Is there a wall tile there?  
36910  RET Z  Return if so without moving Willy (his path is blocked)  
36911  OR A  Point HL at the cell at (x1,y+1)  
36912  SBC HL,DE  
36914  OR A  Point HL at the cell at (x1,y), or at the cell at (x1,y1) if Willy is on or about to step onto a ramp that goes up to the left, or at the cell at (x1,y+1) if Willy is walking down a ramp  
36915  SBC HL,DE  
36917  LD (34259),HL  Save Willy's new attribute buffer coordinates (in HL) at 34259  
36920  LD A,B  Save Willy's new ycoordinate at 34255  
36921  LD (34255),A  
36924  LD A,3  Change Willy's animation frame at 34258 from 0 to 3  
36926  LD (34258),A  
36929  RET  
Willy is moving right.


36930  LD A,(34258)  Pick up Willy's animation frame from 34258  
36933  CP 3  Is it 3?  
36935  JR Z,36942  If so, jump to move Willy's sprite right across a cell boundary  
36937  INC A  Increment Willy's animation frame at 34258  
36938  LD (34258),A  
36941  RET  
Willy's sprite is moving right across a cell boundary. In the comments that follow, (x,y) refers to the coordinates of the topleft cell currently occupied by Willy's sprite.


36942  LD A,(34257)  Pick up the airborne status indicator from 34257  
36945  LD BC,0  Prepare BC for later addition  
36948  OR A  Is Willy jumping?  
36949  JR NZ,36984  Jump if so  
36951  LD HL,(34259)  Collect Willy's attribute buffer coordinates from 34259  
36954  LD A,(32986)  Pick up the direction byte of the ramp definition for the current room from 32986  
36957  DEC A  Now A=64 if the ramp goes up to the left, or 34 if it goes up to the right  
36958  OR 157  
36960  XOR 191  
36962  LD E,A  Point HL at the cell at (x,y+2) if the ramp goes up to the left, or at the cell at (x+2,y+1) if the ramp goes up to the right  
36963  LD D,0  
36965  ADD HL,DE  
36966  LD A,(32964)  Pick up the attribute byte of the ramp tile for the current room from 32964  
36969  CP (HL)  Is there a ramp tile in the cell pointed to by HL?  
36970  JR NZ,36984  Jump if not  
36972  LD BC,32  Prepare BC for later addition  
36975  LD A,(32986)  Pick up the direction byte of the ramp definition for the current room from 32986  
36978  OR A  Does the ramp go up to the left?  
36979  JR Z,36984  Jump if so  
36981  LD BC,65504  BC=32 (the ramp goes up to the right)  
36984  LD HL,(34259)  Collect Willy's attribute buffer coordinates from 34259  
36987  ADD HL,BC  Point HL at the cell at (x+2,y), or at the cell at (x+2,y+1) if Willy is walking down a ramp, or at the cell at (x+2,y1) if Willy is on or about to step onto a ramp that goes up to the right  
36988  INC HL  
36989  INC HL  
36990  LD A,L  Is Willy's screen xcoordinate 30 (on the far right)?  
36991  AND 31  
36993  JP Z,38046  If so, move Willy into the room on the right  
36996  LD DE,32  Prepare DE for addition  
36999  LD A,(32946)  Pick up the attribute byte of the wall tile for the current room from 32946  
37002  ADD HL,DE  Point HL at the cell at (x+2,y+1), or at the cell at (x+2,y+2) if Willy is walking down a ramp, or at the cell at (x+2,y) if Willy is on or about to step onto a ramp that goes up to the right  
37003  CP (HL)  Is there a wall tile in the cell pointed to by HL?  
37004  RET Z  Return if so without moving Willy (his path is blocked)  
37005  LD A,(34255)  Pick up Willy's ycoordinate (Y) from 34255  
37008  SRA C  Now B=Y (if Willy is neither on nor about to step onto a ramp), or Y+16 (if Willy is walking down a ramp), or Y16 (if Willy is on or about to step onto a ramp that goes up to the right); this will be Willy's new ycoordinate  
37010  ADD A,C  
37011  LD B,A  
37012  AND 15  Is Willy at a point in a jump (right) where his sprite occupies three rows of cells?  
37014  JR Z,37025  Jump if not (Willy's sprite is cellaligned)  
37016  LD A,(32946)  Pick up the attribute byte of the wall tile for the current room from 32946  
37019  ADD HL,DE  Point HL at the cell at (x+2,y+2)  
37020  CP (HL)  Is there a wall tile there?  
37021  RET Z  Return if so without moving Willy (his path is blocked)  
37022  OR A  Point HL at the cell at (x+2,y+1)  
37023  SBC HL,DE  
37025  LD A,(32946)  Pick up the attribute byte of the wall tile for the current room from 32946  
37028  OR A  Point HL at the cell at (x+2,y), or at the cell at (x+2,y+1) if Willy is walking down a ramp, or at the cell at (x+2,y1) if Willy is on or about to step onto a ramp that goes up to the right  
37029  SBC HL,DE  
37031  CP (HL)  Is there a wall tile in the cell pointed to by HL?  
37032  RET Z  Return if so without moving Willy (his path is blocked)  
37033  DEC HL  Point HL at the cell at (x+1,y), or at the cell at (x+1,y+1) if Willy is walking down a ramp, or at the cell at (x+1,y1) if Willy is on or about to step onto a ramp that goes up to the right  
37034  LD (34259),HL  Save Willy's new attribute buffer coordinates (in HL) at 34259  
37037  XOR A  Change Willy's animation frame at 34258 from 3 to 0  
37038  LD (34258),A  
37041  LD A,B  Save Willy's new ycoordinate at 34255  
37042  LD (34255),A  
37045  RET 
Prev: 36564  Up: Map  Next: 37046 