Prev: D21B Up: Map Next: D26E
D23B: Tunnels - check if Maroc has hit a left/right boundary wall
Used by the routine at D1D2.
Maroc loses a very small amount of energy (1) if he collides with a tunnel boundary.
This routine checks Maroc's position against that of either the left (D250) or right (D23B) boundary (determined at D1D9).
RIGHT boundary wall check - compare boundary wall position against Maroc's position
Vertical position check:
D23B LD A,($EB4A) Boundary wall's vertical (pixel) position
D23E SUB $50 Subtract 80 (pixels) from this value
D240 CP $10
D242 JP NC,$D27D If the difference is >=16, it's NOT within Maroc's vertical 'hit box' area (jump out here)
Horizontal position check:
D245 LD A,($EB48) Boundary wall's horizontal (half-character/4-pixel) position
D248 CP $20 Check vs 32 (= 16 character squares = the right hand side of Maroc's sprite graphic)
D24A JR NC,$D26B If no carry (NC), Maroc ISN'T beyond the tunnel boundary, so can jump out here
D24C LD A,$20 Maroc has hit/passed the boundary wall.
Pre-load the value to assign to Maroc's speed to +32 = full speed left, as Maroc bounces off the wall
D24E JR $D263
LEFT boundary wall check - compare boundary wall position against Maroc's position
Vertical position check:
D250 LD A,($EB4A) Boundary wall's vertical (pixel) position
D253 SUB $50 Subtract 80 (pixels) from this value
D255 CP $10
D257 JP NC,$D27D If the difference is >=16, it's not within Maroc's vertical 'hit box' area (jump out here)
Horizontal position check:
D25A LD A,($EB48) Boundary wall's horizontal (half-character/4-pixel) position
D25D CP $18 Check vs 24 ( = 12 character squares = the left hand side of Maroc's sprite graphic)
D25F JR C,$D26B If there's a carry, Maroc ISN'T beyond the tunnel boundary, so jump out here
D261 LD A,$E0 Maroc has hit/passed the boundary wall.
Pre-load the value to assign to Maroc's speed to 224 (-32) = full speed right, as Maroc bounces off the wall
Maroc has hit a boundary wall
D263 LD ($EB04),A Store Maroc's adjusted speed (after bouncing off either wall)
D266 LD A,$01 Set energy drain amount to 1
D268 CALL $E3CC Decrease Maroc's energy
D26B JP $D27D
Prev: D21B Up: Map Next: D26E