![]() |
Routines |
| Prev: 50749 | Up: Map | Next: 50916 |
|
Used by the routines at SetWipeAndDrawFlags and HandlePlayerTop.
Flags every object that overlaps the area of the screen covered by an object to be drawn again. The area is the one that is covered by the old and the new position of the sprite of the object together, so that the whole of it is redrawn.
|
||||||||
|
The left edge, in bytes, is the lower of the old and new positions. It is kept in E.
|
||||||||
| FlagOverlappingObjects | 50775 | LD IY,23432 | Point IY at PlayerBottomObject. | |||||
| 50779 | CALL CalculateSpriteSize | Call CalculateSpriteSize. | ||||||
| 50782 | LD B,56 | Set B to 56. | ||||||
| 50784 | LD A,(IX+26) | Fetch the new pixel x position. | ||||||
| 50787 | RRCA | Divide it by eight. | ||||||
| 50788 | RRCA | |||||||
| 50789 | RRCA | |||||||
| 50790 | AND %00011111 | Keep only bits 0-4. | ||||||
| 50792 | LD L,A | Copy it to L. | ||||||
| 50793 | LD A,(IX+30) | Fetch the old pixel x position. | ||||||
| 50796 | RRCA | Divide it by eight. | ||||||
| 50797 | RRCA | |||||||
| 50798 | RRCA | |||||||
| 50799 | AND %00011111 | Keep only bits 0-4. | ||||||
| 50801 | LD H,A | Copy it to H. | ||||||
| 50802 | CP L | Jump to FlagOverlappingObjects_RightEdge if the old is lower. | ||||||
| 50803 | JR C,FlagOverlappingObjects_RightEdge | |||||||
| 50805 | LD A,L | Copy L to A. | ||||||
| FlagOverlappingObjects_RightEdge | 50806 | LD E,A | Copy it to E. | |||||
|
The width is the higher right edge less the left edge. It is kept in D.
|
||||||||
| 50807 | LD A,L | Copy L to A. | ||||||
| 50808 | ADD A,(IX+24) | Add the new width. | ||||||
| 50811 | LD L,A | Copy it to L. | ||||||
| 50812 | LD A,H | Copy H to A. | ||||||
| 50813 | ADD A,(IX+28) | Add the old width. | ||||||
| 50816 | CP L | Jump to FlagOverlappingObjects_AreaWidth if it is higher. | ||||||
| 50817 | JR NC,FlagOverlappingObjects_AreaWidth | |||||||
| 50819 | LD A,L | Copy L to A. | ||||||
| FlagOverlappingObjects_AreaWidth | 50820 | SUB E | Subtract E. | |||||
| 50821 | LD D,A | Copy it to D. | ||||||
|
The bottom edge is the lower of the old and new pixel y. It is kept in L.
|
||||||||
| 50822 | LD A,(IX+27) | Fetch the new pixel y position. | ||||||
| 50825 | CP (IX+31) | Compare it with the old one. | ||||||
| 50828 | JR C,FlagOverlappingObjects_TopEdge | Jump to FlagOverlappingObjects_TopEdge if the new one is lower. | ||||||
| 50830 | LD A,(IX+31) | Fetch the old pixel y position. | ||||||
| FlagOverlappingObjects_TopEdge | 50833 | LD L,A | Copy it to L. | |||||
|
The height is the higher top edge less the bottom edge. It is kept in H.
|
||||||||
| 50834 | LD A,(IX+27) | Fetch the new pixel y position. | ||||||
| 50837 | ADD A,(IX+25) | Add the new height. | ||||||
| 50840 | LD H,A | Copy it to H. | ||||||
| 50841 | LD A,(IX+31) | Fetch the old pixel y position. | ||||||
| 50844 | ADD A,(IX+29) | Add the old height. | ||||||
| 50847 | CP H | Jump to FlagOverlappingObjects_AreaHeight if it is higher. | ||||||
| 50848 | JR NC,FlagOverlappingObjects_AreaHeight | |||||||
| 50850 | LD A,H | Copy H to A. | ||||||
| FlagOverlappingObjects_AreaHeight | 50851 | SUB L | Subtract L. | |||||
| 50852 | LD H,A | Copy it to H. | ||||||
|
Flag any object that overlaps the area.
|
||||||||
| FlagOverlappingObjects_Next | 50853 | LD A,(IY+0) | Fetch the sprite number of the other object. | |||||
| 50856 | AND A | Jump to FlagOverlappingObjects_Advance if it is zero. | ||||||
| 50857 | JR Z,FlagOverlappingObjects_Advance | |||||||
| 50859 | BIT 4,(IY+7) | Jump to FlagOverlappingObjects_Advance if the object is already flagged to be drawn. | ||||||
| 50863 | JR NZ,FlagOverlappingObjects_Advance | |||||||
| 50865 | LD A,(IY+26) | Fetch the pixel x position of the other object. | ||||||
| 50868 | RRCA | Divide it by eight. | ||||||
| 50869 | RRCA | |||||||
| 50870 | RRCA | |||||||
| 50871 | AND %00011111 | Keep only bits 0-4. | ||||||
| 50873 | SUB E | Subtract E. | ||||||
| 50874 | JR C,FlagOverlappingObjects_Left | Jump to FlagOverlappingObjects_Left if carry is set. | ||||||
| 50876 | CP D | Compare it with D. | ||||||
| FlagOverlappingObjects_Right | 50877 | JR NC,FlagOverlappingObjects_Advance | Jump to FlagOverlappingObjects_Advance if carry is not set. | |||||
| 50879 | LD A,(IY+27) | Fetch the pixel y position of the other object. | ||||||
| 50882 | SUB L | Subtract L. | ||||||
| 50883 | JR C,FlagOverlappingObjects_Below | Jump to FlagOverlappingObjects_Below if carry is set. | ||||||
| 50885 | CP H | Compare it with H. | ||||||
| FlagOverlappingObjects_Top | 50886 | JR NC,FlagOverlappingObjects_Advance | Jump to FlagOverlappingObjects_Advance if carry is not set. | |||||
| 50888 | SET 4,(IY+7) | Set bit 4 of the flags. | ||||||
| FlagOverlappingObjects_Advance | 50892 | EXX | Switch to the shadow registers. | |||||
| 50893 | LD DE,32 | Set DE' to 0032. | ||||||
| 50896 | ADD IY,DE | Add DE' to IY. | ||||||
| 50898 | EXX | Switch to the main registers. | ||||||
| 50899 | DJNZ FlagOverlappingObjects_Next | Jump to FlagOverlappingObjects_Next until B is zero. | ||||||
| 50901 | RET | Return. | ||||||
|
The object starts to the left of the area, so it overlaps only if it is wide enough to reach the area.
|
||||||||
| FlagOverlappingObjects_Left | 50902 | NEG | Negate A. | |||||
| 50904 | CP (IY+24) | Compare it with the width of the other object. | ||||||
| 50907 | JR FlagOverlappingObjects_Right | Jump to FlagOverlappingObjects_Right. | ||||||
|
The object starts below the area, so it overlaps only if it is tall enough to reach the area.
|
||||||||
| FlagOverlappingObjects_Below | 50909 | NEG | Negate A. | |||||
| 50911 | CP (IY+25) | Compare it with the height of the other object. | ||||||
| 50914 | JR FlagOverlappingObjects_Top | Jump to FlagOverlappingObjects_Top. | ||||||
|
View the equivalent code in;
|
||||||||
| Prev: 50749 | Up: Map | Next: 50916 |