Prev: D9EB Up: Map Next: DA87
D9EC: Update the raft
Used by the routines at C800 and D3EC.
D9EC LD A,($D9EA) Put the room the raft is in (D9EA) in B.
D9EF LD B,A
D9F0 LD A,($CFCA) Put the current room (CFCA) in C.
D9F3 LD C,A
D9F4 LD DE,($D9E8) Get the raft x-cordinate and frame (D9E8, D9E9) in DE.
D9F8 LD HL,$D9EB Decrement the tick count and jump forward until it reaches 0.
D9FB DEC (HL)
D9FC JR NZ,$DA1B
D9FE LD (HL),$03 Reset the tick count to 3.
DA00 INC E Move to the next animation frame.
DA01 LD A,E Has it reached 4?
DA02 CP $04
DA04 JR NZ,$DA37 No, so move forward.
The raft needs moving.
DA06 LD E,$00 Otherwise set it back to 0.
DA08 DEC D Move left one column.
DA09 LD A,D Has the raft reached the edge of the screen?
DA0A CP $FC
DA0C JR NZ,$DA37 Jump forward if it hasn't.
DA0E LD D,$1C Put the raft on the right of the screen.
DA10 INC B Put the raft in the room to the left.
DA11 LD A,B Ensure the room cycles between 0 - 7.
DA12 AND $07
DA14 LD B,A
DA15 LD A,C Is the raft in this room?
DA16 CP B
DA17 JR NZ,$DA1B Jump forward if it's not.
The raft is in this room.
DA19 LD D,$1F
DA1B LD A,C
DA1C CP $08
DA1E JR NC,$DA33
DA20 INC A
DA21 CP B
DA22 JR C,$DA2E
DA24 LD A,B
DA25 CP $02
DA27 JR C,$DA33
DA29 LD A,C
DA2A DEC A
DA2B CP B
DA2C JR C,$DA33
DA2E LD A,C
DA2F DEC A
DA30 AND $07
DA32 LD B,A
DA33 LD A,B
DA34 LD ($D9EA),A
DA37 LD ($D9E8),DE
DA3B LD A,C
DA3C CP B
DA3D RET NZ
The raft is in the current room, so draw it
DA3E LD A,E Get the X co-ordinate of the raft graphic.
DA3F ADD A,A Multiply by 32 to get an appropriate offset.
DA40 ADD A,A
DA41 ADD A,A
DA42 ADD A,A
DA43 ADD A,A
DA44 LD C,A Put this in BC.
DA45 LD B,$00
DA47 LD HL,$6899 Add the offset of the raft graphic. (6899)
DA4A ADD HL,BC
DA4B LD C,D Get the y co-ordinate of the raft.
DA4C LD DE,$5040 Get the basic y screen position of the raft.
DA4F EX DE,HL
DA50 LD A,C
DA51 CP $20
DA53 JR NC,$DA56
DA55 ADD HL,BC Add the offset to get the current graphic.
DA56 LD B,$04 Draw 4 columns.
DA58 LD A,C
DA59 CP $20
DA5B JR C,$DA66
DA5D PUSH HL
DA5E LD HL,$0008
DA61 ADD HL,DE
DA62 EX DE,HL
DA63 POP HL
DA64 JR $DA7A
DA66 PUSH BC
DA67 PUSH HL
DA68 LD B,$08
DA6A LD A,(DE)
DA6B LD (HL),A
DA6C INC H
DA6D INC DE
DA6E DJNZ $DA6A
DA70 POP HL
DA71 POP BC
DA72 LD H,$5A Set to the next to bottom row of the screen.
DA74 LD A,$02 Fill with red on black.
DA76 LD (HL),A
DA77 LD H,$50
DA79 INC L
DA7A INC C Move to the next column.
DA7B DJNZ $DA58 Loop until all columns drawn.
DA7D LD A,C
DA7E CP $20
DA80 RET NC
DA81 LD H,$5A
DA83 LD A,$45
DA85 LD (HL),A
DA86 RET
Prev: D9EB Up: Map Next: DA87