Prev: D4AF Up: Map Next: D550
D4B5: Move Dan right
Used by the routines at CFD9, D08A, D0DC, D123 and D2F0.
D4B5 EXX Exchange all main registers.
D4B6 LD A,($C875) Put Dan's current animation frame (C875) in H.
D4B9 LD H,A
D4BA LD A,($C873) Put Dan's X co-ordinate in L.
D4BD LD L,A
D4BE LD A,($C874) Get some flags. (C874)
D4C1 BIT 1,A Is Dan facing right?
D4C3 JR NZ,$D4DF Jump forward if he is.
Dan needs to be turned the right way round.
D4C5 SET 1,A Otherwise set that Dan is facing right.
D4C7 LD ($C874),A
D4CA LD A,H Is Dan on frame 6 or below?
D4CB CP $06
D4CD JR NC,$D4D4 Jump forward if so.
D4CF DEC H Otherwise move back 2 frames.
D4D0 DEC H
D4D1 JP $D546 Jump forward to update the position.
D4D4 SUB $06
D4D6 LD H,A
D4D7 INC L
D4D8 LD A,L
D4D9 CP $1E
D4DB JR Z,$D505
D4DD JR $D52C
Dan is facing the right way, so move.
D4DF LD A,H Is the current frame 2?
D4E0 CP $02
D4E2 JR NZ,$D4FC Jump if not.
D4E4 LD D,L
D4E5 INC D
D4E6 INC D
D4E7 PUSH HL Move to a new cell and see what is there.
D4E8 CALL $D951
D4EB POP HL
D4EC JR NZ,$D520
D4EE EXX
D4EF RES 3,B
D4F1 RES 4,B
D4F3 BIT 0,B
D4F5 JR NZ,$D4F9
D4F7 LD L,$00
D4F9 EXX
D4FA JR $D546
D4FC CP $03
D4FE JR NZ,$D520
D500 LD A,L
D501 CP $1D
D503 JR NZ,$D529
D505 XOR A
D506 LD ($C875),A
D509 LD ($C873),A
D50C LD A,($CFCA) Get the current room. (CFCA)
D50F LD B,A
D510 AND $07
D512 JR NZ,$D519
D514 LD A,B
D515 ADD A,$07
D517 JR $D51B
D519 LD A,B
D51A DEC A
D51B CALL $CBBD
D51E EXX
D51F RET
D520 INC H
D521 LD BC,$00EF
D524 CALL $D4AF
D527 JR $D546
D529 INC L
D52A LD H,$00
D52C PUSH HL
D52D LD HL,$62D6
D530 LD E,L
D531 LD D,H
D532 INC HL
D533 PUSH HL
D534 LD BC,$0053
D537 LDIR
D539 POP HL
D53A INC HL
D53B LD DE,($C872)
D53F INC D
D540 INC D
D541 INC D
D542 CALL $D550
D545 POP HL
D546 LD A,H
D547 LD ($C875),A
D54A LD A,L
D54B LD ($C873),A
D54E EXX
D54F RET
Prev: D4AF Up: Map Next: D550