Prev: C63D Up: Map Next: C6E4
C657: Mark every object the moving object's old or new rectangle touches
Used by the routines at SET_WIPE_AND_DRAW_FLAGS and TOP_FOLLOWS_LEGS.
Called once an object has moved or changed its drawing: by the robot's top (TOP_FOLLOWS_LEGS), and through SET_WIPE_AND_DRAW_FLAGS -- which sets bits 4 and 5 of the object's flags first -- by the legs and most other update routines. It works out the object's new screen rectangle (CALC_2D_INFO), forms the smallest rectangle covering that and the one it had at the start of the turn (+$1C to +$1F, copied there by the main loop, AFTER_GAME), and walks all 56 records setting the draw flag, bit 4 of +$07, on every live object whose rectangle meets it -- the moving object itself included.
Across, the rectangles are measured in byte columns (pixel x over 8); up, in pixel rows from the bottom of the screen. E is the union's first column and D its width in columns; L its lowest row and H its height. Only the moving object's rectangle is used: an object redrawn because it meets it does not in turn mark the objects that meet it. Pentagram's routine, instruction for instruction.
Input
IX the object that has moved
SET_DRAW_OBJS_OVERLAPPED C657 LD IY,OBJECTS IY = the first record; the new rectangle into +$18 to +$1B
C65B CALL CALC_2D_INFO
C65E LD B,$38 56 records
C660 LD A,(IX+$1A) L = the new first column
C663 RRCA
C664 RRCA
C665 RRCA
C666 AND $1F
C668 LD L,A
C669 LD A,(IX+$1E) H = the old first column
C66C RRCA
C66D RRCA
C66E RRCA
C66F AND $1F
C671 LD H,A
C672 CP L E = whichever is further left
C673 JR C,SET_DRAW_OBJS_OVERLAPPED_0
C675 LD A,L
SET_DRAW_OBJS_OVERLAPPED_0 C676 LD E,A
C677 LD A,L D = the further right-hand edge, less E: the width in columns
C678 ADD A,(IX+$18)
C67B LD L,A
C67C LD A,H
C67D ADD A,(IX+$1C)
C680 CP L
C681 JR NC,SET_DRAW_OBJS_OVERLAPPED_1
C683 LD A,L
SET_DRAW_OBJS_OVERLAPPED_1 C684 SUB E
C685 LD D,A
C686 LD A,(IX+$1B) L = the lower of the two bottom rows
C689 CP (IX+$1F)
C68C JR C,SET_DRAW_OBJS_OVERLAPPED_2
C68E LD A,(IX+$1F)
SET_DRAW_OBJS_OVERLAPPED_2 C691 LD L,A
C692 LD A,(IX+$1B) H = the higher of the two tops, less L: the height
C695 ADD A,(IX+$19)
C698 LD H,A
C699 LD A,(IX+$1F)
C69C ADD A,(IX+$1D)
C69F CP H
C6A0 JR NC,SET_DRAW_OBJS_OVERLAPPED_3
C6A2 LD A,H
SET_DRAW_OBJS_OVERLAPPED_3 C6A3 SUB L
C6A4 LD H,A
OVERLAP_TEST_OBJ C6A5 LD A,(IY+$00) An empty record: next
C6A8 AND A
C6A9 JR Z,SET_DRAW_OBJS_OVERLAPPED_6
C6AB BIT 4,(IY+$07) Already to be drawn: next
C6AF JR NZ,SET_DRAW_OBJS_OVERLAPPED_6
C6B1 LD A,(IY+$1A) Its first column, less E; left of the union, see below
C6B4 RRCA
C6B5 RRCA
C6B6 RRCA
C6B7 AND $1F
C6B9 SUB E
C6BA JR C,SET_DRAW_OBJS_OVERLAPPED_7
C6BC CP D Not left of the union: it meets it across if it starts inside
SET_DRAW_OBJS_OVERLAPPED_4 C6BD JR NC,SET_DRAW_OBJS_OVERLAPPED_6
C6BF LD A,(IY+$1B) Its bottom row, less L; below the union, see below
C6C2 SUB L
C6C3 JR C,SET_DRAW_OBJS_OVERLAPPED_8
C6C5 CP H Not below: it meets it up and down if it starts inside
SET_DRAW_OBJS_OVERLAPPED_5 C6C6 JR NC,SET_DRAW_OBJS_OVERLAPPED_6
C6C8 SET 4,(IY+$07) Draw it this turn
SET_DRAW_OBJS_OVERLAPPED_6 C6CC EXX The next record, D and E kept across the step
C6CD LD DE,$0020
C6D0 ADD IY,DE
C6D2 EXX
C6D3 DJNZ OVERLAP_TEST_OBJ
C6D5 RET
SET_DRAW_OBJS_OVERLAPPED_7 C6D6 NEG To the left: it meets the union if the union starts inside its width
C6D8 CP (IY+$18)
C6DB JR SET_DRAW_OBJS_OVERLAPPED_4
SET_DRAW_OBJS_OVERLAPPED_8 C6DD NEG Below: it meets the union if the union starts inside its height
C6DF CP (IY+$19)
C6E2 JR SET_DRAW_OBJS_OVERLAPPED_5
Prev: C63D Up: Map Next: C6E4