![]() |
Routines |
| Prev: B99B | Up: Map | Next: BA34 |
|
Used by the routines at PLAYER_TOP and HOMER.
Called once an object has moved or changed its sprite: by the player's body (PLAYER_TOP), and by every update routine that ends in the tail of HOMER, which sets bits 4 and 5 of the object's +$07 first. 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), and walks all 54 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.
|
||||||||
| SET_DRAW_OBJS_OVERLAPPED | B9A7 | LD IY,OBJECTS | IY = the first record; the new rectangle into +$18 to +$1B | |||||
| B9AB | CALL CALC_2D_INFO | |||||||
| B9AE | LD B,$36 | 54 records | ||||||
| B9B0 | LD A,(IX+$1A) | L = the new first column | ||||||
| B9B3 | RRCA | |||||||
| B9B4 | RRCA | |||||||
| B9B5 | RRCA | |||||||
| B9B6 | AND $1F | |||||||
| B9B8 | LD L,A | |||||||
| B9B9 | LD A,(IX+$1E) | H = the old first column | ||||||
| B9BC | RRCA | |||||||
| B9BD | RRCA | |||||||
| B9BE | RRCA | |||||||
| B9BF | AND $1F | |||||||
| B9C1 | LD H,A | |||||||
| B9C2 | CP L | E = whichever is further left | ||||||
| B9C3 | JR C,SET_DRAW_OBJS_OVERLAPPED_0 | |||||||
| B9C5 | LD A,L | |||||||
| SET_DRAW_OBJS_OVERLAPPED_0 | B9C6 | LD E,A | ||||||
| B9C7 | LD A,L | D = the further right-hand edge, less E: the width in columns | ||||||
| B9C8 | ADD A,(IX+$18) | |||||||
| B9CB | LD L,A | |||||||
| B9CC | LD A,H | |||||||
| B9CD | ADD A,(IX+$1C) | |||||||
| B9D0 | CP L | |||||||
| B9D1 | JR NC,SET_DRAW_OBJS_OVERLAPPED_1 | |||||||
| B9D3 | LD A,L | |||||||
| SET_DRAW_OBJS_OVERLAPPED_1 | B9D4 | SUB E | ||||||
| B9D5 | LD D,A | |||||||
| B9D6 | LD A,(IX+$1B) | L = the lower of the two bottom rows | ||||||
| B9D9 | CP (IX+$1F) | |||||||
| B9DC | JR C,SET_DRAW_OBJS_OVERLAPPED_2 | |||||||
| B9DE | LD A,(IX+$1F) | |||||||
| SET_DRAW_OBJS_OVERLAPPED_2 | B9E1 | LD L,A | ||||||
| B9E2 | LD A,(IX+$1B) | H = the higher of the two tops, less L: the height | ||||||
| B9E5 | ADD A,(IX+$19) | |||||||
| B9E8 | LD H,A | |||||||
| B9E9 | LD A,(IX+$1F) | |||||||
| B9EC | ADD A,(IX+$1D) | |||||||
| B9EF | CP H | |||||||
| B9F0 | JR NC,SET_DRAW_OBJS_OVERLAPPED_3 | |||||||
| B9F2 | LD A,H | |||||||
| SET_DRAW_OBJS_OVERLAPPED_3 | B9F3 | SUB L | ||||||
| B9F4 | LD H,A | |||||||
| OVERLAP_TEST_OBJ | B9F5 | LD A,(IY+$00) | an empty record: next | |||||
| B9F8 | AND A | |||||||
| B9F9 | JR Z,SET_DRAW_OBJS_OVERLAPPED_6 | |||||||
| B9FB | BIT 4,(IY+$07) | already to be drawn: next | ||||||
| B9FF | JR NZ,SET_DRAW_OBJS_OVERLAPPED_6 | |||||||
| BA01 | LD A,(IY+$1A) | its first column, less E; left of the union, see below | ||||||
| BA04 | RRCA | |||||||
| BA05 | RRCA | |||||||
| BA06 | RRCA | |||||||
| BA07 | AND $1F | |||||||
| BA09 | SUB E | |||||||
| BA0A | JR C,SET_DRAW_OBJS_OVERLAPPED_7 | |||||||
| BA0C | CP D | not left of the union: it meets it across if it starts inside | ||||||
| SET_DRAW_OBJS_OVERLAPPED_4 | BA0D | JR NC,SET_DRAW_OBJS_OVERLAPPED_6 | ||||||
| BA0F | LD A,(IY+$1B) | its bottom row, less L; below the union, see below | ||||||
| BA12 | SUB L | |||||||
| BA13 | JR C,SET_DRAW_OBJS_OVERLAPPED_8 | |||||||
| BA15 | CP H | not below: it meets it up and down if it starts inside | ||||||
| SET_DRAW_OBJS_OVERLAPPED_5 | BA16 | JR NC,SET_DRAW_OBJS_OVERLAPPED_6 | ||||||
| BA18 | SET 4,(IY+$07) | draw it this turn | ||||||
| SET_DRAW_OBJS_OVERLAPPED_6 | BA1C | EXX | the next record, DE kept across the step | |||||
| BA1D | LD DE,$0020 | |||||||
| BA20 | ADD IY,DE | |||||||
| BA22 | EXX | |||||||
| BA23 | DJNZ OVERLAP_TEST_OBJ | |||||||
| BA25 | RET | |||||||
| SET_DRAW_OBJS_OVERLAPPED_7 | BA26 | NEG | to the left: it meets the union if the union starts inside its width | |||||
| BA28 | CP (IY+$18) | |||||||
| BA2B | JR SET_DRAW_OBJS_OVERLAPPED_4 | |||||||
| SET_DRAW_OBJS_OVERLAPPED_8 | BA2D | NEG | below: it meets the union if the union starts inside its height | |||||
| BA2F | CP (IY+$19) | |||||||
| BA32 | JR SET_DRAW_OBJS_OVERLAPPED_5 | |||||||
| Prev: B99B | Up: Map | Next: BA34 |