Prev: 27464 Up: Map Next: 27644
27468: Handler: Player Movement
Used by the routine at Game_Loop.
Input
A Input state
Handler_PlayerMovement 27468 LD (30760),A Store the current player input state in *PlayerInput.
Set up the directional indicator colors based on the input combination. The indicators show which direction the player will move on slopes.
Note that the middle body section is shared between the "UP" and "DOWN" arrows, this is why the logic controls three colour variables.
27471 LD C,0 Initialise the "UP" indicator colour in C to BLACK (OFF).
27473 LD DE,1542 Set YELLOW (ON) for both D ("DOWN" indicator) and E (the middle body section of the indicators).
27476 BIT 2,A Jump to UpdateIndicatorDisplay if "DOWN" is being pressed.
27478 JR NZ,UpdateIndicatorDisplay
A "DOWN" key is not being pressed, so activate the "UP" indicator.
27480 LD C,E Change the "UP" indicator colour in C to YELLOW (ON).
27481 LD E,0 Clear the "DOWN" indicator colour in E to BLACK (OFF).
27483 BIT 3,A Jump to UpdateIndicatorDisplay if "UP" is being pressed.
27485 JR NZ,UpdateIndicatorDisplay
Neither "UP" or "DOWN" are being pressed, so clear both indicators.
27487 LD C,E Clear the "UP" indicator colour in C to BLACK (OFF).
27488 LD D,E Clear the middle body section colour in D to BLACK (OFF).
Paint the indicators.
First paint the "UP" section.
UpdateIndicatorDisplay 27489 LD HL,23123 Set the attribute buffer location of the top of the indicators in HL to 23123 to paint the "UP" section.
27492 LD (HL),C Write C containing the "UP" indicator colour value to the top left and right of the "UP" indicator.
27493 INC L
27494 LD (HL),C
The body of the indicator is shared between both "UP" and "DOWN" indicator arrows.
27495 LD L,115 Alter the attribute buffer location to point to the body of the indicator.
27497 LD (HL),D Write D containing the middle section of the indicator colour value to the middle left and right of the indicator body.
27498 INC L
27499 LD (HL),D
Finally, paint the "DOWN" section.
27500 LD L,147 Alter the attribute buffer location to point to the bottom of the indicators to paint the "DOWN" section.
27502 LD (HL),E Write E containing the "DOWN" indicator colour value to the bottom left and right of the "DOWN" indicator.
27503 INC L
27504 LD (HL),E
27505 NOP No operation.
27506 NOP
27507 NOP
27508 LD HL,30755 HL=30755.
27511 AND %00000011 Keep only bits 0-1.
27513 JR Z,Handler_PlayerMovement_2 Jump to Handler_PlayerMovement_2 if L is equal to 147.
27515 RRCA RRCA.
27516 LD A,(HL) A=*HL.
27517 JR NC,Handler_PlayerMovement_0 Jump to Handler_PlayerMovement_0 if L is greater than or equal to 147.
27519 CP 150 Compare A with 150.
27521 LD A,0 A=0.
27523 JR Z,Handler_PlayerMovement_2 Jump to Handler_PlayerMovement_2 if A was equal to 150 on line 27519.
27525 INC (HL) Increment *HL by one.
27526 BIT 7,(HL) Test bit 7 of *HL.
27528 JR NZ,Handler_PlayerMovement_2 Jump to Handler_PlayerMovement_2 if *HL is not equal to 0.
27530 JR Handler_PlayerMovement_1 Jump to Handler_PlayerMovement_1.
Handler_PlayerMovement_0 27532 CP 105 Compare A with 105.
27534 LD A,0 A=0.
27536 JR Z,Handler_PlayerMovement_2 Jump to Handler_PlayerMovement_2 if A was equal to 105 on line Handler_PlayerMovement_0.
27538 DEC (HL) Decrease *HL by one.
27539 BIT 7,(HL) Test bit 7 of *HL.
27541 JR Z,Handler_PlayerMovement_2 Jump to Handler_PlayerMovement_2 if *HL is equal to 0.
Handler_PlayerMovement_1 27543 LD A,2 Write 2 to *30761.
Handler_PlayerMovement_2 27545 LD (30761),A
27548 LD L,39 L=39.
27550 LD A,(HL) Jump to Handler_PlayerMovement_3 if *HL is zero.
27551 AND A
27552 JR Z,Handler_PlayerMovement_3
27554 DEC (HL) Decrease *HL by one.
Handler_PlayerMovement_3 27555 DEC L Decrease L by one.
27556 LD A,(HL) Jump to Handler_PlayerMovement_5 if *HL is not zero.
27557 AND A
27558 JR NZ,Handler_PlayerMovement_5
27560 LD L,35 L=35.
27562 LD A,(HL) A=*HL.
27563 DEC L Decrease L by one.
27564 CP (HL) Jump to Handler_PlayerMovement_5 if A is equal to *HL.
27565 JR Z,Handler_PlayerMovement_5
27567 LD A,(HL) A=*HL.
27568 JR C,Handler_PlayerMovement_4 Jump to Handler_PlayerMovement_4 if A is less than *HL.
27570 INC (HL) Increment *HL by two.
27571 INC (HL)
Handler_PlayerMovement_4 27572 DEC (HL) Decrease *HL by one.
27573 OR (HL) Set the bits from *HL.
27574 INC A Increment A by one.
27575 JR NZ,Handler_PlayerMovement_5 Jump to Handler_PlayerMovement_5 if A is not equal to *HL.
27577 LD A,(HL) A=*HL.
27578 DEC L Decrease L by one.
27579 LD (HL),A Write A to *HL.
27580 RLCA RLCA.
27581 JP NC,27337 Jump to 27337 if L is greater than *HL.
27584 JP 27408 Jump to 27408.
Handler_PlayerMovement_5 27587 LD L,34 L=34.
27589 LD A,(HL) A=*HL.
27590 DEC L Decrease L by one.
27591 CP (HL) Jump to Handler_PlayerMovement_9 if A is equal to *HL.
27592 JR Z,Handler_PlayerMovement_9
27594 JR C,Handler_PlayerMovement_6 Jump to Handler_PlayerMovement_6 if A is less than *HL.
27596 INC (HL) Increment *HL by one.
27597 RLCA RLCA.
27598 JR NC,Handler_PlayerMovement_8 Jump to Handler_PlayerMovement_8 if *HL is greater than or equal to *HL.
27600 LD A,(30759) Jump to Handler_PlayerMovement_7 if *30759 is zero.
27603 AND A
27604 JR Z,Handler_PlayerMovement_7
27606 DEC (HL) Decrease *HL by one.
27607 JR Handler_PlayerMovement_8 Jump to Handler_PlayerMovement_8.
Handler_PlayerMovement_6 27609 DEC (HL) Decrease *HL by one.
27610 RLCA RLCA.
27611 JR C,Handler_PlayerMovement_8 Jump to Handler_PlayerMovement_8 if *HL is less than A.
27613 INC (HL) Increment *HL by one.
27614 LD A,(30759) Jump to Handler_PlayerMovement_8 if *30759 is not zero.
27617 AND A
27618 JR NZ,Handler_PlayerMovement_8
27620 DEC (HL) Decrease *HL by one.
Handler_PlayerMovement_7 27621 LD A,3 Write 3 to *30759.
27623 LD (30759),A
Handler_PlayerMovement_8 27626 NOP No operation.
Handler_PlayerMovement_9 27627 LD L,34 L=34.
27629 LD A,(HL) A=*HL.
27630 LD DE,23109 DE=23109 (attribute buffer location).
27633 CALL DisplaySpeedometer Call DisplaySpeedometer.
27636 LD A,(30755) A=*30755.
27639 LD E,133 E=133.
27641 JP 27944 Jump to 27944.
Prev: 27464 Up: Map Next: 27644