Prev: 6B48 Up: Map Next: 6BFC
6B4C: Handler: Player Movement
Used by the routine at Game_Loop.
Input
A Input state
Handler_PlayerMovement 6B4C LD ($7828),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.
6B4F LD C,$00 Initialise the "UP" indicator colour in C to BLACK (OFF).
6B51 LD DE,$0606 Set YELLOW (ON) for both D ("DOWN" indicator) and E (the middle body section of the indicators).
6B54 BIT 2,A Jump to UpdateIndicatorDisplay if "DOWN" is being pressed.
6B56 JR NZ,UpdateIndicatorDisplay
A "DOWN" key is not being pressed, so activate the "UP" indicator.
6B58 LD C,E Change the "UP" indicator colour in C to YELLOW (ON).
6B59 LD E,$00 Clear the "DOWN" indicator colour in E to BLACK (OFF).
6B5B BIT 3,A Jump to UpdateIndicatorDisplay if "UP" is being pressed.
6B5D JR NZ,UpdateIndicatorDisplay
Neither "UP" or "DOWN" are being pressed, so clear both indicators.
6B5F LD C,E Clear the "UP" indicator colour in C to BLACK (OFF).
6B60 LD D,E Clear the middle body section colour in D to BLACK (OFF).
Paint the indicators.
First paint the "UP" section.
UpdateIndicatorDisplay 6B61 LD HL,$5A53 Set the attribute buffer location of the top of the indicators in HL to 5A53 to paint the "UP" section.
6B64 LD (HL),C Write C containing the "UP" indicator colour value to the top left and right of the "UP" indicator.
6B65 INC L
6B66 LD (HL),C
The body of the indicator is shared between both "UP" and "DOWN" indicator arrows.
6B67 LD L,$73 Alter the attribute buffer location to point to the body of the indicator.
6B69 LD (HL),D Write D containing the middle section of the indicator colour value to the middle left and right of the indicator body.
6B6A INC L
6B6B LD (HL),D
Finally, paint the "DOWN" section.
6B6C LD L,$93 Alter the attribute buffer location to point to the bottom of the indicators to paint the "DOWN" section.
6B6E LD (HL),E Write E containing the "DOWN" indicator colour value to the bottom left and right of the "DOWN" indicator.
6B6F INC L
6B70 LD (HL),E
6B71 NOP No operation.
6B72 NOP
6B73 NOP
6B74 LD HL,$7823 HL=7823.
6B77 AND %00000011 Keep only bits 0-1.
6B79 JR Z,Handler_PlayerMovement_2 Jump to Handler_PlayerMovement_2 if L is equal to 93.
6B7B RRCA RRCA.
6B7C LD A,(HL) A=*HL.
6B7D JR NC,Handler_PlayerMovement_0 Jump to Handler_PlayerMovement_0 if L is greater than or equal to 93.
6B7F CP $96 Compare A with 96.
6B81 LD A,$00 A=00.
6B83 JR Z,Handler_PlayerMovement_2 Jump to Handler_PlayerMovement_2 if A was equal to 96 on line 6B7F.
6B85 INC (HL) Increment *HL by one.
6B86 BIT 7,(HL) Test bit 7 of *HL.
6B88 JR NZ,Handler_PlayerMovement_2 Jump to Handler_PlayerMovement_2 if *HL is not equal to 00.
6B8A JR Handler_PlayerMovement_1 Jump to Handler_PlayerMovement_1.
Handler_PlayerMovement_0 6B8C CP $69 Compare A with 69.
6B8E LD A,$00 A=00.
6B90 JR Z,Handler_PlayerMovement_2 Jump to Handler_PlayerMovement_2 if A was equal to 69 on line Handler_PlayerMovement_0.
6B92 DEC (HL) Decrease *HL by one.
6B93 BIT 7,(HL) Test bit 7 of *HL.
6B95 JR Z,Handler_PlayerMovement_2 Jump to Handler_PlayerMovement_2 if *HL is equal to 00.
Handler_PlayerMovement_1 6B97 LD A,$02 Write 02 to *7829.
Handler_PlayerMovement_2 6B99 LD ($7829),A
6B9C LD L,$27 L=27.
6B9E LD A,(HL) Jump to Handler_PlayerMovement_3 if *HL is zero.
6B9F AND A
6BA0 JR Z,Handler_PlayerMovement_3
6BA2 DEC (HL) Decrease *HL by one.
Handler_PlayerMovement_3 6BA3 DEC L Decrease L by one.
6BA4 LD A,(HL) Jump to Handler_PlayerMovement_5 if *HL is not zero.
6BA5 AND A
6BA6 JR NZ,Handler_PlayerMovement_5
6BA8 LD L,$23 L=23.
6BAA LD A,(HL) A=*HL.
6BAB DEC L Decrease L by one.
6BAC CP (HL) Jump to Handler_PlayerMovement_5 if A is equal to *HL.
6BAD JR Z,Handler_PlayerMovement_5
6BAF LD A,(HL) A=*HL.
6BB0 JR C,Handler_PlayerMovement_4 Jump to Handler_PlayerMovement_4 if A is less than *HL.
6BB2 INC (HL) Increment *HL by two.
6BB3 INC (HL)
Handler_PlayerMovement_4 6BB4 DEC (HL) Decrease *HL by one.
6BB5 OR (HL) Set the bits from *HL.
6BB6 INC A Increment A by one.
6BB7 JR NZ,Handler_PlayerMovement_5 Jump to Handler_PlayerMovement_5 if A is not equal to *HL.
6BB9 LD A,(HL) A=*HL.
6BBA DEC L Decrease L by one.
6BBB LD (HL),A Write A to *HL.
6BBC RLCA RLCA.
6BBD JP NC,$6AC9 Jump to 6AC9 if L is greater than *HL.
6BC0 JP $6B10 Jump to 6B10.
Handler_PlayerMovement_5 6BC3 LD L,$22 L=22.
6BC5 LD A,(HL) A=*HL.
6BC6 DEC L Decrease L by one.
6BC7 CP (HL) Jump to Handler_PlayerMovement_9 if A is equal to *HL.
6BC8 JR Z,Handler_PlayerMovement_9
6BCA JR C,Handler_PlayerMovement_6 Jump to Handler_PlayerMovement_6 if A is less than *HL.
6BCC INC (HL) Increment *HL by one.
6BCD RLCA RLCA.
6BCE JR NC,Handler_PlayerMovement_8 Jump to Handler_PlayerMovement_8 if *HL is greater than or equal to *HL.
6BD0 LD A,($7827) Jump to Handler_PlayerMovement_7 if *7827 is zero.
6BD3 AND A
6BD4 JR Z,Handler_PlayerMovement_7
6BD6 DEC (HL) Decrease *HL by one.
6BD7 JR Handler_PlayerMovement_8 Jump to Handler_PlayerMovement_8.
Handler_PlayerMovement_6 6BD9 DEC (HL) Decrease *HL by one.
6BDA RLCA RLCA.
6BDB JR C,Handler_PlayerMovement_8 Jump to Handler_PlayerMovement_8 if *HL is less than A.
6BDD INC (HL) Increment *HL by one.
6BDE LD A,($7827) Jump to Handler_PlayerMovement_8 if *7827 is not zero.
6BE1 AND A
6BE2 JR NZ,Handler_PlayerMovement_8
6BE4 DEC (HL) Decrease *HL by one.
Handler_PlayerMovement_7 6BE5 LD A,$03 Write 03 to *7827.
6BE7 LD ($7827),A
Handler_PlayerMovement_8 6BEA NOP No operation.
Handler_PlayerMovement_9 6BEB LD L,$22 L=22.
6BED LD A,(HL) A=*HL.
6BEE LD DE,$5A45 DE=5A45 (attribute buffer location).
6BF1 CALL DisplaySpeedometer Call DisplaySpeedometer.
6BF4 LD A,($7823) A=*7823.
6BF7 LD E,$85 E=85.
6BF9 JP $6D28 Jump to 6D28.
Prev: 6B48 Up: Map Next: 6BFC