Prev: 7F77 Up: Map Next: 8251
7F78: Drawing Routine
Used by the routine at YouSeeEntry.
Drawing 7F78 PUSH AF Store AF on the stack.
7F79 LD A,($B707) If B707 is not $00 then jump to DrawingCheck.
7F7C AND A
7F7D JR NZ,DrawingCheck
7F7F LD A,$FF Write $FF to LocationID.
7F81 LD ($7F77),A
7F84 POP AF Restore AF from the stack.
7F85 RET Return.
Drawing Check
DrawingCheck 7F86 POP AF Retrieve the location ID from the stack.
7F87 PUSH AF Ensure that it's still on the stack for later.
7F88 PUSH HL Store HL, BC, DE and IX on the stack for later.
7F89 PUSH BC
7F8A PUSH DE
7F8B PUSH IX
7F8D LD IX,$CC00 IX=LocGFXTable.
7F91 CALL IndexIdTable Call IndexIdTable - the Z flag is set if no data is found (A=$FF).
7F94 LD ($7F77),A Store the location ID at LocationID.
7F97 LD L,(IX+$01) HL=Location graphics data address.
7F9A LD H,(IX+$02)
7F9D CALL NZ,DrawingSetup If there is graphics data for this location then call DrawingSetup.
7FA0 POP IX Restore IX, DE, BC, HL and AF off the stack.
7FA2 POP DE
7FA3 POP BC
7FA4 POP HL
7FA5 POP AF
7FA6 RET Return.
Drawing routines.
DrawingSetup 7FA7 PUSH IY Store IY and HL on the stack.
7FA9 PUSH HL
7FAA PUSH HL IY=pointer to graphics data addresses.
7FAB POP IY
7FAD PUSH DE Store DE and BC on the stack.
7FAE PUSH BC
7FAF CALL DrawingClear Call DrawingClear.
7FB2 LD D,$7F D=$7F.
7FB4 LD E,$3F E=$3F.
7FB6 LD B,$01 B=$01.
7FB8 LD C,$01 C=$01.
7FBA LD L,$01 L=$01.
DrawingLoop 7FBC LD A,(IY+$00) Fetch the next drawing instruction.
7FBF AND A If the value is zero, jump to DrawingEnd.
7FC0 JP Z,DrawingEnd
7FC3 INC IY Increment the graphics data pointer by one.
7FC5 CP $08 If the graphics data value which was fetched is not $08 (move to X/Y) jump to Drawing_0.
7FC7 JR NZ,Drawing_0
Moves the "pen" held in DE to a screen location.
7FC9 LD D,(IY+$00) Populate DE with two values from the graphics data and increment the pointer by two.
7FCC INC IY
7FCE LD E,(IY+$00)
7FD1 INC IY
7FD3 JR DrawingLoop Jump back to DrawingLoop to fetch the next drawing instruction.
Drawing_0 7FD5 BIT 7,A If bit 7 is set, jump to Drawing_1.
7FD7 JR Z,Drawing_1
7FD9 LD B,A Temporarily store A in B.
7FDA AND %00000111 Keep only bits 0-2.
7FDC LD C,A Store this in C.
7FDD LD A,B Restore the old value of A (from B).
7FDE RRCA Rotate A right one bit.
7FDF AND %00111100 Keep only bits 2-5.
7FE1 LD B,A Store this in B.
7FE2 LD A,(IY+$00) Fetch the next drawing instruction.
7FE5 AND %00111111 Keep only bits 0-5.
7FE7 LD L,A Store this in L.
7FE8 INC L Increment L by one.
7FE9 LD A,(IY+$00) Fetch the previous drawing instruction again in A.
7FEC INC IY Increment the graphics data pointer by one.
7FEE RLCA Rotate A left two bits.
7FEF RLCA
7FF0 AND %00000011 Keep only bits 0-1.
7FF2 OR B
7FF3 LD B,A
7FF4 INC B
7FF5 CALL Drawing_30 Call Drawing_30.
7FF8 JR DrawingLoop Jump back to DrawingLoop to fetch the next drawing instruction.
Drawing_1 7FFA BIT 6,A
7FFC JR Z,Drawing_2
7FFE AND %00000111 Keep only bits 0-2.
8000 PUSH DE
8001 LD D,(IY+$00)
8004 INC IY
8006 LD E,(IY+$00)
8009 INC IY
800B CALL Drawing_7
800E POP DE
800F JP DrawingLoop Jump back to DrawingLoop to fetch the next drawing instruction.
Drawing_2 8012 BIT 5,A If bit 5 is set then jump back to DrawingLoop to fetch the next drawing instruction.
8014 JP Z,DrawingLoop
8017 AND %00000111 Keep only bits 0-2.
8019 RLCA
801A RLCA
801B RLCA
801C PUSH HL
801D PUSH DE
801E PUSH BC
801F LD C,A
8020 LD H,(IY+$00)
8023 INC IY
8025 LD L,(IY+$00)
8028 INC IY
Drawing_3 802A LD A,(IY+$00)
802D INC IY
802F CP $FF
8031 JR Z,Drawing_6
8033 LD B,A
8034 AND %00000011 Keep only bits 0-1.
8036 LD E,A
8037 LD A,B
8038 RRCA
8039 RRCA
803A AND %00111111 Keep only bits 0-5.
803C INC A
803D LD B,A
Drawing_4 803E LD A,(HL)
803F AND %00000111 Keep only bits 0-2.
8041 RLCA
8042 RLCA
8043 RLCA
8044 CP C
8045 JR NZ,Drawing_5
8047 XOR $38
Drawing_5 8049 RRCA
804A RRCA
804B RRCA
804C OR C
804D LD (HL),A
804E LD A,E
804F AND A
8050 CALL Z,Drawing_18
8053 DEC A
8054 CALL Z,Drawing_23
8057 DEC A
8058 CALL Z,Drawing_20
805B DEC A
805C CALL Z,Drawing_21
805F DJNZ Drawing_4
8061 JR Drawing_3
Drawing_6 8063 POP BC
8064 POP DE
8065 POP HL
8066 JP DrawingLoop Jump back to DrawingLoop to fetch the next drawing instruction.
DrawingEnd 8069 POP BC Restore BC, DE, HL and IY from the stack.
806A POP DE
806B POP HL
806C POP IY
806E RET Return.
806F DEFB $00,$00
Drawing_7 8071 LD ($824E),A
8074 PUSH DE
8075 PUSH HL
8076 LD HL,$0080
8079 PUSH HL
Drawing_8 807A CALL Drawing_17
807D JR NZ,Drawing_9
807F CALL Drawing_29
8082 JR NZ,Drawing_8
8084 JR Drawing_10
Drawing_9 8086 CALL Drawing_46
8089 CALL Drawing_28
Drawing_10 808C LD HL,$0000
808F LD ($806F),HL
Drawing_11 8092 CALL Drawing_25
8095 LD A,$00
8097 JR Z,Drawing_13
8099 CALL Drawing_17
809C LD A,$00
809E JR NZ,Drawing_12
80A0 LD A,($806F)
80A3 AND A
80A4 JR NZ,Drawing_12
80A6 PUSH DE
80A7 LD A,$01
Drawing_12 80A9 PUSH AF
80AA CALL Drawing_27
80AD POP AF
Drawing_13 80AE LD ($806F),A
80B1 CALL Drawing_27
80B4 LD A,$00
80B6 JR Z,Drawing_15
80B8 CALL Drawing_17
80BB LD A,$00
80BD JR NZ,Drawing_14
80BF LD A,($8070)
80C2 AND A
80C3 JR NZ,Drawing_14
80C5 PUSH DE
80C6 LD A,$01
Drawing_14 80C8 PUSH AF
80C9 CALL Drawing_25
80CC POP AF
Drawing_15 80CD LD ($8070),A
80D0 CALL Drawing_46
80D3 CALL Drawing_28
80D6 JR Z,Drawing_16
80D8 CALL Drawing_17
80DB JR Z,Drawing_11
80DD CALL Drawing_46
Drawing_16 80E0 POP DE
80E1 LD A,E
80E2 CP $80
80E4 JR NZ,Drawing_8
80E6 LD A,$00
80E8 LD ($824E),A
80EB POP HL Restore HL and DE from the stack.
80EC POP DE
80ED RET Return.
Drawing_17 80EE PUSH HL Stash HL on the stack.
80EF CALL Drawing_48 Call Drawing_48.
80F2 AND (HL)
80F3 POP HL Restore HL from the stack.
80F4 RET Return.
Drawing_18 80F5 PUSH AF Stash AF and DE on the stack.
80F6 PUSH DE
80F7 LD DE,$0020
80FA AND A
80FB SBC HL,DE
80FD LD A,H
80FE CP $57
8100 JR NZ,Drawing_19
8102 ADD HL,DE
Drawing_19 8103 POP DE Restore DE and AF from the stack.
8104 POP AF
8105 RET Return.
Drawing_20 8106 PUSH AF Stash AF and DE on the stack.
8107 PUSH DE
8108 LD DE,$0020 HL=HL+$0020.
810B ADD HL,DE
810C LD A,H
810D CP $5A
810F JR NZ,$8113
8111 AND A
8112 SBC HL,DE
8114 POP DE Restore DE and AF from the stack.
8115 POP AF
8116 RET Return.
Drawing_21 8117 PUSH AF
8118 DEC HL
8119 LD A,H
811A CP $57
811C JR NZ,Drawing_22
811E INC HL
Drawing_22 811F POP AF
8120 RET Return.
Drawing_23 8121 PUSH AF
8122 INC HL
8123 LD A,H
8124 CP $5A
8126 JR NZ,Drawing_24
8128 DEC HL
Drawing_24 8129 POP AF
812A RET Return.
Drawing_25 812B INC E
812C BIT 7,E
812E JR Z,Drawing_26
8130 DEC E
8131 LD H,A
8132 XOR A
8133 LD A,H
8134 RET Return.
Drawing_26 8135 LD H,A Set bit 0 of A (using H).
8136 OR $01
8138 LD A,H
8139 RET Return.
Drawing_27 813A DEC E
813B BIT 7,E
813D JR Z,Drawing_26
813F INC E
8140 RET Return.
Drawing_28 8141 INC D
8142 RET NZ
8143 DEC D
8144 LD H,A
8145 XOR A
8146 LD A,H
8147 RET Return.
Drawing_29 8148 DEC D
8149 LD H,A
814A LD A,D
814B CP $FF
814D LD A,H
814E RET NZ
814F INC D
8150 RET Return.
Drawing_30 8151 BIT 0,C If bit 0 of C is not set then jump to Drawing_38.
8153 JR NZ,Drawing_38
8155 PUSH HL Stash HL and BC on the stack.
8156 PUSH BC
Drawing_31 8157 CALL Drawing_46 Call Drawing_46.
815A BIT 2,C If bit 2 of C is set then jump to Drawing_32.
815C JR Z,Drawing_32
815E CALL Drawing_29 Call Drawing_29.
8161 JR Z,Drawing_37
8163 JR Drawing_33 Jump to Drawing_33.
Drawing_32 8165 CALL Drawing_28 Call Drawing_28.
8168 JR Z,Drawing_37
Drawing_33 816A DEC B Decrease B by one.
816B JR NZ,Drawing_36 Jump to Drawing_36 if it is not zero.
816D BIT 1,C If bit 1 of C is set then jump to Drawing_34.
816F JR Z,Drawing_34
8171 CALL Drawing_27 Call Drawing_27.
8174 JR Z,Drawing_37
8176 JR Drawing_35
Drawing_34 8178 CALL Drawing_25
817B JR Z,Drawing_37
Drawing_35 817D POP BC
817E PUSH BC
Drawing_36 817F DEC L
8180 JR NZ,Drawing_31
Drawing_37 8182 POP BC Restore BC and HL from the stack.
8183 POP HL
8184 RET Return.
Drawing_38 8185 PUSH HL Stash HL and BC on the stack.
8186 PUSH BC
Drawing_39 8187 CALL Drawing_46 Call Drawing_46.
818A BIT 1,C
818C JR Z,Drawing_40
818E CALL Drawing_27
8191 JR Z,Drawing_45
8193 JR Drawing_41
Drawing_40 8195 CALL Drawing_25
8198 JR Z,Drawing_45
Drawing_41 819A DEC B
819B JR NZ,Drawing_44
819D BIT 2,C
819F JR Z,Drawing_42
81A1 CALL Drawing_29
81A4 JR Z,Drawing_45
81A6 JR Drawing_43
Drawing_42 81A8 CALL Drawing_28
81AB JR Z,Drawing_45
Drawing_43 81AD POP BC
81AE PUSH BC
Drawing_44 81AF DEC L
81B0 JR NZ,Drawing_39
Drawing_45 81B2 POP BC Restore BC and HL from the stack.
81B3 POP HL
81B4 RET Return.
Drawing_46 81B5 PUSH HL
81B6 CALL Drawing_48
81B9 PUSH AF
81BA PUSH HL
81BB LD A,H
81BC AND %00011000 Keep only bits 3-4.
81BE RRCA
81BF RRCA
81C0 RRCA
81C1 ADD A,$58
81C3 LD H,A
81C4 LD A,(HL)
81C5 AND %00111000 Keep only bits 3-5.
81C7 LD (HL),A
81C8 LD A,($824E)
81CB RLCA
81CC RLCA
81CD RLCA
81CE CP (HL)
81CF JR NZ,Drawing_47
81D1 XOR $38
Drawing_47 81D3 RRCA
81D4 RRCA
81D5 RRCA
81D6 OR (HL)
81D7 LD (HL),A
81D8 POP HL
81D9 POP AF
81DA OR (HL)
81DB LD (HL),A
81DC POP HL
81DD RET Return.
Drawing_48 81DE LD A,$7F
81E0 SUB E
81E1 LD L,A
81E2 AND %00000111 Keep only bits 0-2.
81E4 OR $40
81E6 LD H,A
81E7 LD A,L
81E8 AND %11000000 Keep only bits 6-7.
81EA RRCA
81EB RRCA
81EC RRCA
81ED OR H
81EE LD H,A
81EF LD A,L
81F0 AND %00111000 Keep only bits 3-5.
81F2 RLCA
81F3 RLCA
81F4 LD L,A
81F5 LD A,D
81F6 RRCA
81F7 RRCA
81F8 RRCA
81F9 AND %00011111 Keep only bits 0-4.
81FB OR L
81FC LD L,A
81FD LD A,D
81FE AND %00000111 Keep only bits 0-2.
8200 PUSH BC Stash BC on the stack temporarily.
8201 LD B,A Copy A to B used as a counter for the rotate command.
8202 INC B
8203 LD A,$01 A=00000001.
Drawing_49 8205 RRC A Rotate A right once.
8207 DJNZ Drawing_49 Decrease counter by one and loop back to Drawing_49 until counter is zero.
8209 POP BC Restore BC from the stack.
820A RET Return.
DrawingClear 820B CALL LocationLit Call LocationLit.
820E EX AF,AF' Store the first byte of the graphic data in the shadow AF register.
820F LD A,(IY+$00)
8212 INC IY Increment the graphic data pointer to the next byte.
8214 EX AF,AF' Switch back to the "normal" AF register to check the result of the call to LocationLit.
8215 JR NC,DrawingBorder Jump to DrawingBorder if LocationLit did not set the carry flag (so, it is LIGHT).
8217 EX AF,AF' Overwrite the graphic data in the shadow AF register to $00 (black).
8218 XOR A
8219 EX AF,AF' Switch back to the "normal" AF register simply to accomodate the jump from 8215.
DrawingBorder 821A EX AF,AF' Switch to the shadow AF register containing the first byte of the graphic data (or $00 if it's dark).
821B OUT ($FE),A Set the border colour to the value in A.
821D PUSH HL Store HL, DE and BC on the stack.
821E PUSH DE
821F PUSH BC
8220 LD HL,$4000 Write $00 to $4000-$4FFF (the screen buffer).
8223 LD DE,$4001
8226 LD BC,$0FFF
8229 LD (HL),$00
822B LDIR
822D LD HL,$5800 Set up copying to the attribute buffer (start=$5800, length=$01FF).
8230 LD DE,$5801
8233 LD BC,$01FF
8236 LD A,(IY+$00) A=The next byte (second) of the graphic data.
8239 INC IY Increment the graphic data pointer to the next byte.
823B EX AF,AF' Switch back to the "normal" AF register which contains the LIGHT/ DARK carry flag.
823C JR NC,DrawingPaper Jump to DrawingPaper if LocationLit did not set the carry flag (so, it is LIGHT).
823E EX AF,AF' Overwrite the graphic data in the shadow AF register to $00 (black).
823F XOR A
8240 EX AF,AF' Switch back to the "normal" AF register simply to accomodate the jump from 823C.
DrawingPaper 8241 EX AF,AF' Switch to the shadow AF register containing the second byte of the graphic data (or $00 if it's dark).
8242 LD (HL),A Write this to the attribute buffer using the target/ length specified previously.
8243 LDIR
8245 POP BC Restore BC, DE and HL from the stack.
8246 POP DE
8247 POP HL
8248 EX AF,AF' Switch back to the "normal" AF register which contains the LIGHT/ DARK carry flag.
8249 RET NC Return if it is LIGHT.
824A POP HL Else, restore HL from the stack and jump to DrawingEnd to finish.
824B JP DrawingEnd
824E DEFB $38,$00,$00
Prev: 7F77 Up: Map Next: 8251