| Dun Darach | Routines |
| Prev: 9689 | Up: Map |
|
Used by the routines at BG_ScrollInDirection and Bg_DrawAll.
|
|||||||||||
| Bg_DrawColumn | 969A | LD (Ptr_Offscreen),HL | |||||||||
| 969D | LD DE,$0022 | Clear column of offscreen starting at supplied address in HL. | |||||||||
| 96A0 | AND A | ||||||||||
| 96A1 | SBC HL,DE | ||||||||||
| 96A3 | LD B,$51 | ||||||||||
| 96A5 | XOR A | ||||||||||
| Bg_DrawColumn_0 | 96A6 | LD (HL),A | |||||||||
| 96A7 | ADD HL,DE | ||||||||||
| 96A8 | DJNZ Bg_DrawColumn_0 | ||||||||||
| 96AA | LD HL,(Ptr_Offscreen) | ||||||||||
|
The addresses here point to where in the data doors can be inserted.
|
|||||||||||
| 96AD | LD DE,$0044 | ||||||||||
| 96B0 | AND A | ||||||||||
| 96B1 | SBC HL,DE | ||||||||||
| 96B3 | LD A,(CurrentRoom_AreaColour) | ||||||||||
| 96B6 | LD (HL),A | ||||||||||
| 96B7 | LD A,(Camera_Compass) | Get offset based on camera compass value. | |||||||||
| 96BA | AND A | ||||||||||
| 96BB | RLA | ||||||||||
| 96BC | RLA | ||||||||||
| 96BD | LD C,A | ||||||||||
| 96BE | LD B,$00 | ||||||||||
| 96C0 | ADD IX,BC | ||||||||||
| 96C2 | LD DE,(Coords_EW) | Calculate which coordinate we need to work on. | |||||||||
| 96C6 | LD HL,(Coords_NS) | ||||||||||
| 96C9 | LD A,(Camera_Compass) | ||||||||||
| 96CC | BIT 0,A | ||||||||||
| 96CE | JR NZ,Bg_DrawColumn_1 | ||||||||||
| 96D0 | EX DE,HL | ||||||||||
| Bg_DrawColumn_1 | 96D1 | PUSH HL | Calculate correct position based on camera position offset to the correct end column of the stage. | ||||||||
| 96D2 | LD E,(IX+$00) | ||||||||||
| 96D5 | LD D,(IX+$01) | ||||||||||
| 96D8 | ADD HL,DE | ||||||||||
| 96D9 | LD (_9689_coordsA),HL | ||||||||||
| 96DC | POP HL | ||||||||||
| 96DD | LD E,(IX+$02) | ||||||||||
| 96E0 | LD D,(IX+$03) | ||||||||||
| 96E3 | ADD HL,DE | ||||||||||
| 96E4 | LD (_968b_coordsB),HL | ||||||||||
|
Search for junctions.
|
|||||||||||
| _969a_data | 96E7 | DEFW $FFFC | This bit gets modified by code later on... | ||||||||
| _969a_VectorMargin | 96E9 | DEFW $0004 | Size of the margin when checking if the man is on a path's vector. | ||||||||
| 96EB | DEFW $0000 | ||||||||||
| 96ED | XOR A | ||||||||||
| 96EE | LD (_9692),A | ||||||||||
| 96F1 | LD A,$CA | Set junction to draw bitmap index 'leading in'. | |||||||||
| 96F3 | LD (Bmp_IndexJunction),A | ||||||||||
| 96F6 | LD HL,$0004 | Set values to search for paths connecting from above current path. | |||||||||
| 96F9 | LD DE,$0002 | ||||||||||
| 96FC | LD BC,$0010 | ||||||||||
| 96FF | LD A,$02 | ||||||||||
| Bg_DrawColumn_2 | 9701 | PUSH AF | |||||||||
| 9702 | LD (_969a_data),HL | ||||||||||
| 9705 | LD (_969a_VectorMargin),DE | ||||||||||
| 9709 | LD ($96EB),BC | ||||||||||
| 970D | LD A,(_9692) | ||||||||||
| 9710 | LD ($9691),A | ||||||||||
| 9713 | XOR A | ||||||||||
| 9714 | LD (_9692),A | ||||||||||
| 9717 | LD A,(Camera_Compass) | Get correct path information based on camera compass. | |||||||||
| 971A | BIT 0,A | ||||||||||
| 971C | JR Z,Bg_DrawColumn_3 | ||||||||||
| 971E | LD IX,(CurrentRoom_Ptr_Path_EW) | Information for E/W path. | |||||||||
| 9722 | LD BC,(_9689_coordsA) | ||||||||||
| 9726 | LD DE,(Coords_EW) | ||||||||||
| 972A | JR Bg_DrawColumn_4 | ||||||||||
| Bg_DrawColumn_3 | 972C | LD IX,(CurrentRoom_Ptr_Path_NS) | Information for N/S path. | ||||||||
| 9730 | LD BC,(_9689_coordsA) | ||||||||||
| 9734 | LD DE,(Coords_NS) | ||||||||||
| Bg_DrawColumn_4 | 9738 | INC BC | |||||||||
| 9739 | INC BC | ||||||||||
| 973A | LD HL,(_969a_data) | ||||||||||
| 973D | CP $01 | Check camera compass. | |||||||||
| 973F | JR Z,Bg_DrawColumn_5 | ||||||||||
| 9741 | CP $02 | ||||||||||
| 9743 | JR Z,Bg_DrawColumn_5 | ||||||||||
| 9745 | EX DE,HL | Offset position. | |||||||||
| 9746 | AND A | ||||||||||
| 9747 | SBC HL,DE | ||||||||||
| 9749 | JR Bg_DrawColumn_6 | ||||||||||
| Bg_DrawColumn_5 | 974B | ADD HL,DE | |||||||||
| Bg_DrawColumn_6 | 974C | EX DE,HL | |||||||||
|
Find path crossing position.
|
|||||||||||
| Bg_DrawColumn_7 | 974D | PUSH BC | |||||||||
| 974E | PUSH DE | ||||||||||
| 974F | LD L,(IX+$00) | Get coordinate of path's axis. | |||||||||
| 9752 | LD H,(IX+$01) | ||||||||||
| 9755 | AND A | See if person is on the same vector within a margin. | |||||||||
| 9756 | SBC HL,BC | ||||||||||
| 9758 | LD BC,(_969a_VectorMargin) | ||||||||||
| 975C | JR NC,Bg_DrawColumn_8 | ||||||||||
| 975E | AND A | Path is to the left of position, see if within margin. | |||||||||
| 975F | ADC HL,BC | ||||||||||
| 9761 | JP M,Bg_DrawColumn_10 | ||||||||||
| 9764 | JR Bg_DrawColumn_9 | Path is within position and its margin. | |||||||||
|
Path found?
|
|||||||||||
| Bg_DrawColumn_8 | 9766 | AND A | Path is either same position or further on. | ||||||||
| 9767 | SBC HL,BC | Check to see if further on... | |||||||||
| 9769 | JR NC,Bg_DrawColumn_11 | ||||||||||
| Bg_DrawColumn_9 | 976B | LD L,(IX+$02) | Get coordinates of right hand end of path and see if camera is within range. | ||||||||
| 976E | LD H,(IX+$03) | ||||||||||
| 9771 | AND A | ||||||||||
| 9772 | SBC HL,DE | ||||||||||
| 9774 | JR NC,Bg_DrawColumn_10 | ||||||||||
| 9776 | LD L,(IX+$04) | ||||||||||
| 9779 | LD H,(IX+$05) | ||||||||||
| 977C | SCF | ||||||||||
| 977D | SBC HL,DE | ||||||||||
| 977F | JR C,Bg_DrawColumn_10 | ||||||||||
|
Found path crossing position.
|
|||||||||||
| 9781 | LD L,(IX+$00) | ||||||||||
| 9784 | LD H,(IX+$01) | ||||||||||
| 9787 | LD (_9694),HL | ||||||||||
| 978A | LD A,$01 | ||||||||||
| 978C | LD (_9692),A | ||||||||||
| 978F | LD IX,_9694 | ||||||||||
| 9793 | LD HL,($96EB) | ||||||||||
| 9796 | CALL Bg_DrawItemColumn | Draw junction bitmap. | |||||||||
| 9799 | JR Bg_DrawColumn_11 | ||||||||||
|
Next Path
|
|||||||||||
| Bg_DrawColumn_10 | 979B | LD BC,$000C | |||||||||
| 979E | ADD IX,BC | ||||||||||
| 97A0 | POP DE | ||||||||||
| 97A1 | POP BC | ||||||||||
| 97A2 | JR Bg_DrawColumn_7 | ||||||||||
|
Search for junctions below path.
|
|||||||||||
| Bg_DrawColumn_11 | 97A4 | POP DE | |||||||||
| 97A5 | POP BC | ||||||||||
| 97A6 | LD A,$CC | Set junction bitmap index to 'leading out' | |||||||||
| 97A8 | LD (Bmp_IndexJunction),A | ||||||||||
| 97AB | LD HL,$FFFC | Set values in order to seach paths conneting just below the current path. | |||||||||
| 97AE | LD DE,$0004 | ||||||||||
| 97B1 | LD BC,$0000 | ||||||||||
| 97B4 | POP AF | ||||||||||
| 97B5 | DEC A | ||||||||||
| 97B6 | JP NZ,Bg_DrawColumn_2 | ||||||||||
| 97B9 | LD A,(Camera_Compass) | ||||||||||
| 97BC | BIT 0,A | ||||||||||
| 97BE | JR NZ,Bg_DrawColumn_12 | ||||||||||
| 97C0 | LD DE,(Coords_NS) | ||||||||||
| 97C4 | LD IX,(Hero_PathPtr) | ||||||||||
| 97C8 | JR Bg_DrawColumn_13 | ||||||||||
| Bg_DrawColumn_12 | 97CA | LD DE,(Coords_EW) | |||||||||
| 97CE | LD IX,(Hero_PathPtr) | ||||||||||
| Bg_DrawColumn_13 | 97D2 | LD L,(IX+$00) | |||||||||
| 97D5 | LD H,(IX+$01) | ||||||||||
| 97D8 | AND A | ||||||||||
| 97D9 | SBC HL,DE | ||||||||||
| 97DB | JR Z,Bg_DrawColumn_15 | ||||||||||
| 97DD | JP NC,Bg_DrawColumn_19 | ||||||||||
| Bg_DrawColumn_14 | 97E0 | LD BC,$000C | |||||||||
| 97E3 | ADD IX,BC | ||||||||||
| 97E5 | JR Bg_DrawColumn_13 | ||||||||||
|
Draw bottom road edge.
|
|||||||||||
| Bg_DrawColumn_15 | 97E7 | LD BC,(_9689_coordsA) | |||||||||
| 97EB | INC BC | ||||||||||
| 97EC | LD L,(IX+$02) | ||||||||||
| 97EF | LD H,(IX+$03) | ||||||||||
| 97F2 | AND A | ||||||||||
| 97F3 | SBC HL,BC | ||||||||||
| 97F5 | JR NC,Bg_DrawColumn_14 | ||||||||||
| 97F7 | LD A,L | ABS(hl) | |||||||||
| 97F8 | CPL | ||||||||||
| 97F9 | LD L,A | ||||||||||
| 97FA | LD A,H | ||||||||||
| 97FB | CPL | ||||||||||
| 97FC | LD H,A | ||||||||||
| 97FD | INC HL | ||||||||||
| 97FE | LD (TempAl),HL | ||||||||||
| 9801 | LD L,(IX+$04) | ||||||||||
| 9804 | LD H,(IX+$05) | ||||||||||
| 9807 | AND A | ||||||||||
| 9808 | SBC HL,BC | ||||||||||
| 980A | JR C,Bg_DrawColumn_14 | ||||||||||
| 980C | LD (TempBl),HL | ||||||||||
| 980F | LD A,C | Using odd/even of the offset, decide which column of the path image is drawn. | |||||||||
| 9810 | RRA | ||||||||||
| 9811 | AND $01 | ||||||||||
| 9813 | LD C,A | ||||||||||
| 9814 | LD B,$00 | ||||||||||
| 9816 | LD A,(_9692) | ||||||||||
| 9819 | AND A | ||||||||||
| 981A | JR NZ,Bg_DrawColumn_17 | ||||||||||
| 981C | PUSH BC | ||||||||||
| 981D | LD HL,(BmpPtr_RoadEdgeBottom) | Get the ptr to the bitmap of the road edge. | |||||||||
| 9820 | ADD HL,BC | Offset to correct column to draw. | |||||||||
| 9821 | EX DE,HL | ||||||||||
| 9822 | LD HL,(Ptr_Offscreen) | ||||||||||
| 9825 | LD BC,$0990 | ||||||||||
| 9828 | ADD HL,BC | ||||||||||
| 9829 | LD BC,$0022 | ||||||||||
| 982C | LD A,$08 | ||||||||||
| Bg_DrawColumn_16 | 982E | EX AF,AF' | |||||||||
| 982F | LD A,(DE) | ||||||||||
| 9830 | XOR (HL) | ||||||||||
| 9831 | LD (HL),A | ||||||||||
| 9832 | ADD HL,BC | ||||||||||
| 9833 | INC DE | ||||||||||
| 9834 | INC DE | ||||||||||
| 9835 | EX AF,AF' | ||||||||||
| 9836 | DEC A | ||||||||||
| 9837 | JR NZ,Bg_DrawColumn_16 | ||||||||||
| 9839 | POP BC | ||||||||||
| Bg_DrawColumn_17 | 983A | LD A,($9691) | |||||||||
| 983D | AND A | ||||||||||
| 983E | JR NZ,Bg_DrawColumn_20 | ||||||||||
| 9840 | LD HL,(TempBl) | ||||||||||
| 9843 | LD DE,$0002 | ||||||||||
| 9846 | SBC HL,DE | ||||||||||
| 9848 | JR C,Bg_DrawColumn_20 | ||||||||||
| 984A | LD HL,(TempAl) | ||||||||||
| 984D | SBC HL,DE | ||||||||||
| 984F | JR C,Bg_DrawColumn_20 | ||||||||||
|
Draw top road edge.
|
|||||||||||
| 9851 | LD HL,(BmpPtr_RoadEdgeTop) | ||||||||||
| 9854 | ADD HL,BC | ||||||||||
| 9855 | EX DE,HL | ||||||||||
| 9856 | LD HL,(Ptr_Offscreen) | ||||||||||
| 9859 | LD BC,$0770 | ||||||||||
| 985C | ADD HL,BC | ||||||||||
| 985D | LD BC,$0022 | ||||||||||
| 9860 | LD A,$08 | ||||||||||
| Bg_DrawColumn_18 | 9862 | EX AF,AF' | |||||||||
| 9863 | LD A,(DE) | ||||||||||
| 9864 | XOR (HL) | ||||||||||
| 9865 | LD (HL),A | ||||||||||
| 9866 | ADD HL,BC | ||||||||||
| 9867 | INC DE | ||||||||||
| 9868 | INC DE | ||||||||||
| 9869 | EX AF,AF' | ||||||||||
| 986A | DEC A | ||||||||||
| 986B | JR NZ,Bg_DrawColumn_18 | ||||||||||
| 986D | JR Bg_DrawColumn_20 | ||||||||||
| Bg_DrawColumn_19 | 986F | LD A,(_9692) | |||||||||
| 9872 | AND A | ||||||||||
| 9873 | JR NZ,Bg_DrawColumn_23 | ||||||||||
| 9875 | LD A,($9691) | ||||||||||
| 9878 | AND A | ||||||||||
| 9879 | JR NZ,Bg_DrawColumn_23 | ||||||||||
| 987B | JR Bg_DrawColumn_24 | ||||||||||
|
Draw the road leading in and out of screen.
|
|||||||||||
| Bg_DrawColumn_20 | 987D | LD HL,(TempBl) | |||||||||
| 9880 | LD DE,$0004 | ||||||||||
| 9883 | AND A | ||||||||||
| 9884 | SBC HL,DE | ||||||||||
| 9886 | JR C,Bg_DrawColumn_21 | ||||||||||
| 9888 | LD DE,(TempAl) | ||||||||||
| 988C | LD HL,$0004 | ||||||||||
| 988F | SBC HL,DE | ||||||||||
| 9891 | JR C,Bg_DrawColumn_24 | ||||||||||
| Bg_DrawColumn_21 | 9893 | LD DE,(_9689_coordsA) | |||||||||
| 9897 | LD BC,(Coords_NS) | ||||||||||
| 989B | LD A,(Camera_Compass) | ||||||||||
| 989E | BIT 0,A | ||||||||||
| 98A0 | JR Z,Bg_DrawColumn_22 | ||||||||||
| 98A2 | LD DE,(_9689_coordsA) | ||||||||||
| 98A6 | LD BC,(Coords_EW) | ||||||||||
| Bg_DrawColumn_22 | 98AA | INC DE | |||||||||
| 98AB | ADD HL,DE | ||||||||||
| 98AC | LD (_9694),HL | ||||||||||
| Bg_DrawColumn_23 | 98AF | LD IX,_9694 | |||||||||
| 98B3 | LD (IX+$02),$CB | Bitmap index for road leading in. | |||||||||
| 98B7 | LD HL,$0008 | ||||||||||
| 98BA | CALL Bg_DrawItemColumn | ||||||||||
| Bg_DrawColumn_24 | 98BD | LD IX,(PathFound_BackgroundPtr) | |||||||||
| Bg_DrawColumn_25 | 98C1 | LD A,(IX+$00) | |||||||||
| 98C4 | OR (IX+$01) | ||||||||||
| 98C7 | JR Z,Bg_DrawColumn_26 | ||||||||||
| 98C9 | LD A,(IX+$02) | ||||||||||
| 98CC | CALL Bg_DrawItemColumn_4 | ||||||||||
| 98CF | JR NC,Bg_DrawColumn_27 | ||||||||||
| 98D1 | LD E,(IX+$03) | ||||||||||
| 98D4 | LD D,$00 | ||||||||||
| 98D6 | ADD IX,DE | ||||||||||
| 98D8 | JR Bg_DrawColumn_25 | ||||||||||
| Bg_DrawColumn_26 | 98DA | LD IX,PathFound_StartMargin | |||||||||
| 98DE | LD A,(IX+$02) | ||||||||||
| 98E1 | CALL Bg_DrawItemColumn_4 | ||||||||||
| 98E4 | JR NC,Bg_DrawColumn_27 | ||||||||||
| 98E6 | LD IX,PathFound_EndMargin | ||||||||||
| 98EA | LD A,(IX+$02) | ||||||||||
| 98ED | CALL Bg_DrawItemColumn_4 | ||||||||||
| 98F0 | JR NC,Bg_DrawColumn_27 | ||||||||||
| 98F2 | JR Bg_DrawColumn_28 | ||||||||||
| Bg_DrawColumn_27 | 98F4 | CALL Bg_CalcAndDraw | |||||||||
|
Draw object.
|
|||||||||||
| Bg_DrawColumn_28 | 98F7 | LD HL,(Ptr_Offscreen) | Check column buffer to see if the column can hold an object (1-15) | ||||||||
| 98FA | LD DE,$0022 | ||||||||||
| 98FD | AND A | ||||||||||
| 98FE | SBC HL,DE | ||||||||||
| 9900 | LD A,(HL) | ||||||||||
| 9901 | AND $0F | ||||||||||
| 9903 | RET Z | ||||||||||
| 9904 | LD E,A | ||||||||||
| 9905 | LD D,$00 | ||||||||||
| 9907 | LD HL,(Room_CurrentInfoDataPtr) | Get the next object stored in room (0 - None) | |||||||||
| 990A | ADD HL,DE | ||||||||||
| 990B | LD A,(HL) | ||||||||||
| 990C | AND A | ||||||||||
| 990D | RET Z | ||||||||||
| 990E | CALL Obj_GetBmpIndex | Get the object's bitmap value and store it. | |||||||||
| 9911 | LD A,(HL) | ||||||||||
| 9912 | LD (Draw_RoomObjectBmpIndex),A | ||||||||||
| 9915 | LD L,A | Get the bitmap's information. | |||||||||
| 9916 | CALL Bitmap_CopyFrame | ||||||||||
| 9919 | LD A,(HL) | Bitmap's width. | |||||||||
|
Calculate which column to draw and if it is on screen.
|
|||||||||||
| 991A | AND $7F | ||||||||||
| 991C | LD C,A | ||||||||||
| 991D | NEG | ||||||||||
| 991F | ADD A,$05 | ||||||||||
| 9921 | SRL A | ||||||||||
| 9923 | NEG | ||||||||||
| 9925 | LD HL,($92E3) | Which table column has been drawn. | |||||||||
| 9928 | ADD A,L | Is any column of the object on that column? | |||||||||
| 9929 | CP C | ||||||||||
| 992A | RET NC | ||||||||||
| 992B | LD (Bg_ColumnsLeft),A | ||||||||||
| 992E | LD A,(Bitmap_InfoCache_Height) | Work out Y position of object based on height. | |||||||||
| 9931 | AND $7F | ||||||||||
| 9933 | LD B,A | ||||||||||
| 9934 | LD HL,$0550 | ||||||||||
| 9937 | LD DE,$0110 | ||||||||||
| Bg_DrawColumn_29 | 993A | AND A | |||||||||
| 993B | SBC HL,DE | ||||||||||
| 993D | DJNZ Bg_DrawColumn_29 | ||||||||||
| 993F | LD DE,(Ptr_Offscreen) | Blit correct column of object. | |||||||||
| 9943 | ADD HL,DE | ||||||||||
| 9944 | LD (Temp_BlitTo),HL | ||||||||||
| 9947 | LD DE,(Bg_ColumnsLeft) | ||||||||||
| 994B | LD D,$00 | ||||||||||
| 994D | LD HL,(Draw_RoomObjectBmpIndex) | ||||||||||
| 9950 | LD H,D | ||||||||||
| 9951 | JP Bitmap_DrawColumn | ||||||||||
| 9954 | RET | ||||||||||
| Prev: 9689 | Up: Map |