Prev: 44589 Up: Map Next: 44752
44647: Update Robot Marker
Used by the routines at StartRobot and MoveRobotHorizontally.
Shows the position of the robot on the map of the sectors. The marker is drawn with XOR, so the old marker is removed by drawing it again. Nothing is done if the robot has not moved to a different cell.
Draws a marker of three pixels by three on the map of the sectors, using XOR. Each cell of the map is one pixel on the screen.
Input
D X cell
H Y cell
UpdateRobotMarker 44647 LD DE,(38545) Fetch the X position of the robot...
44651 LD HL,(38547) ...and the Y position.
44654 LD A,(38473) Fetch the X cell where the marker was drawn last.
44657 CP D Jump if the robot is in a different X cell.
44658 JR NZ,UpdateRobotMarker_NewCell
44660 LD A,(38475) Fetch the Y cell where the marker was drawn last.
44663 CP H Return if the robot has not moved to a different cell.
44664 RET Z
UpdateRobotMarker_NewCell 44665 PUSH DE Save the X position...
44666 PUSH HL ...and the Y position.
44667 CALL ToggleMarker Draw the marker at the new position using ToggleMarker.
44670 POP HL Restore the Y position.
44671 LD DE,(38474) Fetch the old Y position...
44675 LD (38474),HL ...and store the new one.
44678 EX DE,HL Put the old one in HL.
44679 POP BC Restore the new X position...
44680 LD DE,(38472) ...fetch the old one...
44684 LD (38472),BC ...and store the new one.
44688 LD A,D Combine the cells of the old position...
44689 OR H ...and return if there was no marker.
44690 RET Z
This entry point is used by the routine at UpdatePacketMarker.
This entry point draws, or removes, a marker.
ToggleMarker 44691 LD A,D Fetch the X cell...
44692 OR 192 ...and find the X coordinate of the marker, which is 190 plus the cell.
44694 SUB 2
44696 LD L,A Keep the X coordinate of the marker.
44697 AND 7 Use the lowest three bits...
44699 ADD A,A ...to find the pre-shifted data...
44700 OR 224 ...in the table of shifted bytes.
44702 LD B,A Keep the shifted graphic.
44703 LD A,H Fetch the Y cell...
44704 XOR 63 Turn the Y cell upside down...
44706 ADD A,57 ...and find the Y coordinate of the marker.
44708 LD H,A Keep the Y coordinate of the marker.
44709 CALL ScreenAddress Find the screen address using ScreenAddress.
44712 LD A,3 There are three rows to draw.
44714 LD DE,44752 Point DE at MarkerPattern.
ToggleMarker_Row 44717 EX AF,AF' Save the counter.
44718 LD A,(DE) Fetch the pattern for the row...
44719 LD C,A ...to use as the offset into the shifted data.
44720 LD A,(BC) Fetch the shifted byte...
44721 XOR (HL) ...combine it with the screen...
44722 LD (HL),A ...and write it back.
44723 INC L Move on to the next byte of the screen.
44724 INC B Move on to the second table of shifted bytes.
44725 LD A,(BC) Fetch the byte that has spilled over...
44726 XOR (HL) ...combine it with the screen...
44727 LD (HL),A ...and write it back.
44728 DEC B Go back to the first table...
44729 DEC L ...and the first byte of the screen.
44730 LD A,H Fetch the high byte of the screen address...
44731 DEC H ...and move up one line.
44732 AND 7 Jump if that has not moved into the character above.
44734 JR NZ,ToggleMarker_Next
44736 LD A,L Fetch the low byte of the screen address...
44737 SUB 32 ...take one row of characters off it...
44739 LD L,A ...and store it.
44740 JR C,ToggleMarker_Next Jump if there is no row of characters above, in this third of the screen...
44742 LD A,H Otherwise fetch the high byte...
44743 ADD A,8 ...add eight to it...
44745 LD H,A ...and store it.
ToggleMarker_Next 44746 EX AF,AF' Restore the counter.
44747 INC DE Move on to the next pattern.
44748 DEC A Count down the rows.
44749 JR NZ,ToggleMarker_Row Loop back until all three rows have been drawn.
44751 RET Return.
Prev: 44589 Up: Map Next: 44752