Prev: D3D4 Up: Map Next: D4AF
D3EC: Move Dan left
Used by the routines at CFD9, D08A, D0DC, D123 and D2F0.
D3EC EXX Exchange all main registers.
D3ED LD A,($C875) Put Dan's current animation frame (C875) in H.
D3F0 LD H,A
D3F1 LD A,($C873) Put Dan's X co-ordinate in L.
D3F4 LD L,A
D3F5 LD A,($C874) Get some flags. (C874)
D3F8 BIT 1,A Is Dan facing right?
D3FA JR Z,$D417 Jump if not.
Dan needs to be turned the right way round.
D3FC RES 1,A Otherwise reset bit 1 ie: Dan is facing left.
D3FE LD ($C874),A
D401 LD A,H Is Dan on frame 3 or above?
D402 CP $02
D404 JR C,$D40B Jump forward if so.
D406 INC H Otherwise move forward 2 frames.
D407 INC H
D408 JP $D4A5 Jump forward to update the position.
D40B ADD A,$06 Add 6 frames.
D40D LD H,A
D40E DEC L Decrement the X co-ordinate.
D40F LD A,L Is it FF? (ie: overflowed)
D410 CP $FF
D412 JR Z,$D43A Jump forward if so.
D414 JP $D48E Otherwise jump ???.
Dan is facing left, so move.
D417 LD A,H Is the current frame 5?
D418 CP $05
D41A JR NZ,$D432 Jump if not.
D41C PUSH HL Move to a new cell and see what is there.
D41D LD D,L
D41E CALL $D951
D421 POP HL
D422 JR NZ,$D482
D424 EXX
D425 RES 3,B
D427 RES 4,B
D429 BIT 0,B
D42B JR NZ,$D42F
D42D LD L,$00
D42F EXX
D430 JR $D4A5
D432 CP $04
D434 JR NZ,$D482
D436 LD A,L
D437 AND A
D438 JR NZ,$D48B
D43A LD A,$1D
D43C LD ($C873),A
D43F LD A,$07
D441 LD ($C875),A
D444 LD A,($CFCA) Get the current room. (CFCA)
D447 LD B,A
D448 AND $07
D44A CP $07
D44C JR NZ,$D453
D44E LD A,B
D44F SUB $07
D451 JR $D455
D453 LD A,B
D454 INC A
D455 PUSH AF
D456 CALL $CBBD
D459 LD A,($D9EA)
D45C INC A
D45D CP $08
D45F JR NZ,$D462
D461 XOR A
D462 POP BC
D463 CP B
D464 JR NZ,$D478
D466 LD A,($D9E9)
D469 ADD A,$03
D46B CP $05
D46D JR NC,$D478
D46F ADD A,$1B
D471 LD ($D9E9),A
D474 LD A,B
D475 LD ($D9EA),A
D478 LD A,$01
D47A LD ($D9EB),A
D47D CALL $D9EC
D480 EXX
D481 RET
D482 DEC H
D483 LD BC,$00EF
D486 CALL $D4AF
D489 JR $D4A5
D48B DEC L
D48C LD H,$07
D48E PUSH HL
D48F LD HL,$62D6
D492 LD BC,$0053
D495 ADD HL,BC
D496 LD E,L
D497 LD D,H
D498 DEC HL
D499 LDDR
D49B INC HL
D49C LD DE,($C872)
D4A0 DEC D
D4A1 CALL $D550
D4A4 POP HL
D4A5 LD A,H
D4A6 LD ($C875),A
D4A9 LD A,L
D4AA LD ($C873),A
D4AD EXX
D4AE RET
Prev: D3D4 Up: Map Next: D4AF