Prev: 874E Up: Map Next: 8866
8751: Move all the nasties on the screen
Used by the routines at 92DF and 940C.
8751 LD HL,$C596 Point HL at the start of the nasty buffer. (C596)
8754 LD B,$06 Maximum of six characters on screen.
8756 NOP
8757 PUSH BC Remember character count.
8758 PUSH HL Swap HL for IX so the buffer can be indexed.
8759 POP IX
875B LD A,(IX+$00) Get the type flag.
875E OR A If the type is not 0, skip forward.
875F JP NZ,$887D
Move a simple nasty. This entry point is used by the routine at 8964.
8762 LD L,(IX+$0C) Put the current X co-ordinate in L.
8765 LD H,(IX+$0D) Put the current Y co-ordinate in H.
8768 LD ($8962),HL Store this in 8962.
876B LD A,(IX+$0B) Get the current direction.
876E OR A Is it down?
876F JR NZ,$87A6 No, so jump forward.
Moving up.
8771 LD B,(IX+$11) Increment the Y co-ordinate by the speed.
8774 LD A,(IX+$0D)
8777 ADD A,B
8778 LD (IX+$0D),A
877B LD L,(IX+$01) Put the "up" graphic in HL.
877E LD H,(IX+$02)
8781 LD A,(IX+$10) Decrement the distance to travel.
8784 DEC A
8785 JR NZ,$8797 Skip the next code if it is not zero.
8787 LD L,(IX+$03) Put the "down" graphic in HL.
878A LD H,(IX+$04)
878D LD A,(IX+$0B) Change the direction to "down".
8790 INC A
8791 LD (IX+$0B),A
8794 LD A,(IX+$0E) Set the distance to travel back to the default.
8797 LD (IX+$10),A
879A LD A,(IX+$0F) Increment the animation frame, looping from 0 - 7.
879D INC A
879E AND $07
87A0 LD (IX+$0F),A
87A3 JP $8827 Move forward to draw the nasty.
Moving down.
87A6 CP $01 Is the direction up?
87A8 JR NZ,$87D2 No, so jump forward.
87AA LD A,(IX+$0D) Decrement the Y co-ordinate by the speed.
87AD LD B,(IX+$11)
87B0 SUB B
87B1 LD (IX+$0D),A
87B4 LD A,(IX+$10) Get the distance to travel.
87B7 LD L,(IX+$03) Put the "down" graphic in HL.
87BA LD H,(IX+$04)
87BD DEC A Decrement the distance to travel.
87BE JR NZ,$8797 Skip the next code if it is not zero.
87C0 LD L,(IX+$01) Put the "up" graphic in HL.
87C3 LD H,(IX+$02)
87C6 LD A,(IX+$0B) Change the direction to "up".
87C9 DEC A
87CA LD (IX+$0B),A
87CD LD A,(IX+$0E) Set the distance to travel back to the default
87D0 JR $8797 Jump back to draw the nasty.
Moving left.
87D2 CP $02 Is the direction left?
87D4 JR NZ,$87FE No, so jump forward.
87D6 LD A,(IX+$0C) Decrement the X co-ordinate by the speed.
87D9 LD B,(IX+$11)
87DC SUB B
87DD LD (IX+$0C),A
87E0 LD A,(IX+$10) Get the distance to travel.
87E3 LD L,(IX+$05) Put the "left" graphic in HL.
87E6 LD H,(IX+$06)
87E9 DEC A Decrement the distance to travel.
87EA JR NZ,$8797 Skip the next code if it is not zero.
87EC LD L,(IX+$07) Put the "right" graphic in HL.
87EF LD H,(IX+$08)
87F2 LD A,(IX+$0B) Change the direction to "right".
87F5 INC A
87F6 LD (IX+$0B),A
87F9 LD A,(IX+$0E) Set the distance to travel back to default.
87FC JR $8797 Jump back to draw the nasty.
Moving right.
87FE LD A,(IX+$0C) Increment the X co-ordinate by the speed.
8801 LD B,(IX+$11)
8804 ADD A,B
8805 LD (IX+$0C),A
8808 LD L,(IX+$07) Put the "right" graphic in HL.
880B LD H,(IX+$08)
880E LD A,(IX+$10) Decrement the distance to travel.
8811 DEC A
8812 JR NZ,$8797 Skip the next code if it is not zero.
8814 LD L,(IX+$05) Put the "left" graphic in HL.
8817 LD H,(IX+$06)
881A LD A,(IX+$0B) Change the direction to "left".
881D DEC A
881E LD (IX+$0B),A
8821 LD A,(IX+$0E) Set the distance to travel back to the default.
8824 JP $8797 Jump back to draw the nasty.
After updating the position, the nasty can be drawn.
8827 EX DE,HL Swap DE and HL over.
8828 RRA Get the top 3 bits of animation to determine the frame to draw.
8829 AND $03
882B LD L,A Put this in HL.
882C LD H,$00
882E ADD HL,HL Multiply by 32 to get a address of graphics.
882F ADD HL,HL
8830 ADD HL,HL
8831 ADD HL,HL
8832 ADD HL,HL
8833 ADD HL,DE Add the basic address of the graphics to get the right one.
8834 LD ($ECE0),HL Set the graphics to draw.
8837 LD L,(IX+$0C) Set the co-ordinates.
883A LD H,(IX+$0D)
883D LD ($ECDE),HL
8840 CALL $EBE0 Draw the graphic.
8843 LD A,(IX+$00) Is the status 0?
8846 OR A
8847 JR NZ,$8857 Move on if not.
The nasty's attributes needs to be drawn.
8849 LD HL,($8962) Get the old position.
884C LD C,$47 Use bright white to erase the old attribute.
884E NOP
884F NOP
8850 NOP
8851 CALL $886F Draw these specific attributes.
8854 CALL $8866 Draw the new attributes from the actual nasty data.
All done with this nasty, move to the next. This entry point is used by the routine at 8964.
8857 PUSH IX Add 14 bytes to point to the next nasty data.
8859 POP HL
885A LD DE,$0014
885D ADD HL,DE
885E POP BC Restore BC.
885F DJNZ $8863 Loop back if there are more nasties to look at.
8861 EI Otherwise re-enable interrupts and return.
8862 RET
8863 JP $8757
Prev: 874E Up: Map Next: 8866