Prev: 32631 Up: Map Next: 33361
32632: Drawing Routine
Used by the routine at YouSeeEntry.
Drawing 32632 PUSH AF Store AF on the stack.
32633 LD A,(46855) If 46855 is not $00 then jump to DrawingCheck.
32636 AND A
32637 JR NZ,DrawingCheck
32639 LD A,255 Write $FF to LocationID.
32641 LD (32631),A
32644 POP AF Restore AF from the stack.
32645 RET Return.
Drawing Check
DrawingCheck 32646 POP AF Retrieve the location ID from the stack.
32647 PUSH AF Ensure that it's still on the stack for later.
32648 PUSH HL Store HL, BC, DE and IX on the stack for later.
32649 PUSH BC
32650 PUSH DE
32651 PUSH IX
32653 LD IX,52224 IX=LocGFXTable.
32657 CALL IndexIdTable Call IndexIdTable - the Z flag is set if no data is found (A=$FF).
32660 LD (32631),A Store the location ID at LocationID.
32663 LD L,(IX+1) HL=Location graphics data address.
32666 LD H,(IX+2)
32669 CALL NZ,DrawingSetup If there is graphics data for this location then call DrawingSetup.
32672 POP IX Restore IX, DE, BC, HL and AF off the stack.
32674 POP DE
32675 POP BC
32676 POP HL
32677 POP AF
32678 RET Return.
Drawing routines.
DrawingSetup 32679 PUSH IY Store IY and HL on the stack.
32681 PUSH HL
32682 PUSH HL IY=pointer to graphics data addresses.
32683 POP IY
32685 PUSH DE Store DE and BC on the stack.
32686 PUSH BC
32687 CALL DrawingClear Call DrawingClear.
32690 LD D,127 D=$7F.
32692 LD E,63 E=$3F.
32694 LD B,1 B=$01.
32696 LD C,1 C=$01.
32698 LD L,1 L=$01.
DrawingLoop 32700 LD A,(IY+0) Fetch the next drawing instruction.
32703 AND A If the value is zero, jump to DrawingEnd.
32704 JP Z,DrawingEnd
32707 INC IY Increment the graphics data pointer by one.
32709 CP 8 If the graphics data value which was fetched is not $08 (move to X/Y) jump to Drawing_0.
32711 JR NZ,Drawing_0
Moves the "pen" held in DE to a screen location.
32713 LD D,(IY+0) Populate DE with two values from the graphics data and increment the pointer by two.
32716 INC IY
32718 LD E,(IY+0)
32721 INC IY
32723 JR DrawingLoop Jump back to DrawingLoop to fetch the next drawing instruction.
Drawing_0 32725 BIT 7,A If bit 7 is set, jump to Drawing_1.
32727 JR Z,Drawing_1
32729 LD B,A Temporarily store A in B.
32730 AND %00000111 Keep only bits 0-2.
32732 LD C,A Store this in C.
32733 LD A,B Restore the old value of A (from B).
32734 RRCA Rotate A right one bit.
32735 AND %00111100 Keep only bits 2-5.
32737 LD B,A Store this in B.
32738 LD A,(IY+0) Fetch the next drawing instruction.
32741 AND %00111111 Keep only bits 0-5.
32743 LD L,A Store this in L.
32744 INC L Increment L by one.
32745 LD A,(IY+0) Fetch the previous drawing instruction again in A.
32748 INC IY Increment the graphics data pointer by one.
32750 RLCA Rotate A left two bits.
32751 RLCA
32752 AND %00000011 Keep only bits 0-1.
32754 OR B
32755 LD B,A
32756 INC B
32757 CALL Drawing_30 Call Drawing_30.
32760 JR DrawingLoop Jump back to DrawingLoop to fetch the next drawing instruction.
Drawing_1 32762 BIT 6,A
32764 JR Z,Drawing_2
32766 AND %00000111 Keep only bits 0-2.
32768 PUSH DE
32769 LD D,(IY+0)
32772 INC IY
32774 LD E,(IY+0)
32777 INC IY
32779 CALL Drawing_7
32782 POP DE
32783 JP DrawingLoop Jump back to DrawingLoop to fetch the next drawing instruction.
Drawing_2 32786 BIT 5,A If bit 5 is set then jump back to DrawingLoop to fetch the next drawing instruction.
32788 JP Z,DrawingLoop
32791 AND %00000111 Keep only bits 0-2.
32793 RLCA
32794 RLCA
32795 RLCA
32796 PUSH HL
32797 PUSH DE
32798 PUSH BC
32799 LD C,A
32800 LD H,(IY+0)
32803 INC IY
32805 LD L,(IY+0)
32808 INC IY
Drawing_3 32810 LD A,(IY+0)
32813 INC IY
32815 CP 255
32817 JR Z,Drawing_6
32819 LD B,A
32820 AND %00000011 Keep only bits 0-1.
32822 LD E,A
32823 LD A,B
32824 RRCA
32825 RRCA
32826 AND %00111111 Keep only bits 0-5.
32828 INC A
32829 LD B,A
Drawing_4 32830 LD A,(HL)
32831 AND %00000111 Keep only bits 0-2.
32833 RLCA
32834 RLCA
32835 RLCA
32836 CP C
32837 JR NZ,Drawing_5
32839 XOR 56
Drawing_5 32841 RRCA
32842 RRCA
32843 RRCA
32844 OR C
32845 LD (HL),A
32846 LD A,E
32847 AND A
32848 CALL Z,Drawing_18
32851 DEC A
32852 CALL Z,Drawing_23
32855 DEC A
32856 CALL Z,Drawing_20
32859 DEC A
32860 CALL Z,Drawing_21
32863 DJNZ Drawing_4
32865 JR Drawing_3
Drawing_6 32867 POP BC
32868 POP DE
32869 POP HL
32870 JP DrawingLoop Jump back to DrawingLoop to fetch the next drawing instruction.
DrawingEnd 32873 POP BC Restore BC, DE, HL and IY from the stack.
32874 POP DE
32875 POP HL
32876 POP IY
32878 RET Return.
32879 DEFB 0,0
Drawing_7 32881 LD (33358),A
32884 PUSH DE
32885 PUSH HL
32886 LD HL,128
32889 PUSH HL
Drawing_8 32890 CALL Drawing_17
32893 JR NZ,Drawing_9
32895 CALL Drawing_29
32898 JR NZ,Drawing_8
32900 JR Drawing_10
Drawing_9 32902 CALL Drawing_46
32905 CALL Drawing_28
Drawing_10 32908 LD HL,0
32911 LD (32879),HL
Drawing_11 32914 CALL Drawing_25
32917 LD A,0
32919 JR Z,Drawing_13
32921 CALL Drawing_17
32924 LD A,0
32926 JR NZ,Drawing_12
32928 LD A,(32879)
32931 AND A
32932 JR NZ,Drawing_12
32934 PUSH DE
32935 LD A,1
Drawing_12 32937 PUSH AF
32938 CALL Drawing_27
32941 POP AF
Drawing_13 32942 LD (32879),A
32945 CALL Drawing_27
32948 LD A,0
32950 JR Z,Drawing_15
32952 CALL Drawing_17
32955 LD A,0
32957 JR NZ,Drawing_14
32959 LD A,(32880)
32962 AND A
32963 JR NZ,Drawing_14
32965 PUSH DE
32966 LD A,1
Drawing_14 32968 PUSH AF
32969 CALL Drawing_25
32972 POP AF
Drawing_15 32973 LD (32880),A
32976 CALL Drawing_46
32979 CALL Drawing_28
32982 JR Z,Drawing_16
32984 CALL Drawing_17
32987 JR Z,Drawing_11
32989 CALL Drawing_46
Drawing_16 32992 POP DE
32993 LD A,E
32994 CP 128
32996 JR NZ,Drawing_8
32998 LD A,0
33000 LD (33358),A
33003 POP HL Restore HL and DE from the stack.
33004 POP DE
33005 RET Return.
Drawing_17 33006 PUSH HL Stash HL on the stack.
33007 CALL Drawing_48 Call Drawing_48.
33010 AND (HL)
33011 POP HL Restore HL from the stack.
33012 RET Return.
Drawing_18 33013 PUSH AF Stash AF and DE on the stack.
33014 PUSH DE
33015 LD DE,32
33018 AND A
33019 SBC HL,DE
33021 LD A,H
33022 CP 87
33024 JR NZ,Drawing_19
33026 ADD HL,DE
Drawing_19 33027 POP DE Restore DE and AF from the stack.
33028 POP AF
33029 RET Return.
Drawing_20 33030 PUSH AF Stash AF and DE on the stack.
33031 PUSH DE
33032 LD DE,32 HL=HL+$0020.
33035 ADD HL,DE
33036 LD A,H
33037 CP 90
33039 JR NZ,33043
33041 AND A
33042 SBC HL,DE
33044 POP DE Restore DE and AF from the stack.
33045 POP AF
33046 RET Return.
Drawing_21 33047 PUSH AF
33048 DEC HL
33049 LD A,H
33050 CP 87
33052 JR NZ,Drawing_22
33054 INC HL
Drawing_22 33055 POP AF
33056 RET Return.
Drawing_23 33057 PUSH AF
33058 INC HL
33059 LD A,H
33060 CP 90
33062 JR NZ,Drawing_24
33064 DEC HL
Drawing_24 33065 POP AF
33066 RET Return.
Drawing_25 33067 INC E
33068 BIT 7,E
33070 JR Z,Drawing_26
33072 DEC E
33073 LD H,A
33074 XOR A
33075 LD A,H
33076 RET Return.
Drawing_26 33077 LD H,A Set bit 0 of A (using H).
33078 OR 1
33080 LD A,H
33081 RET Return.
Drawing_27 33082 DEC E
33083 BIT 7,E
33085 JR Z,Drawing_26
33087 INC E
33088 RET Return.
Drawing_28 33089 INC D
33090 RET NZ
33091 DEC D
33092 LD H,A
33093 XOR A
33094 LD A,H
33095 RET Return.
Drawing_29 33096 DEC D
33097 LD H,A
33098 LD A,D
33099 CP 255
33101 LD A,H
33102 RET NZ
33103 INC D
33104 RET Return.
Drawing_30 33105 BIT 0,C If bit 0 of C is not set then jump to Drawing_38.
33107 JR NZ,Drawing_38
33109 PUSH HL Stash HL and BC on the stack.
33110 PUSH BC
Drawing_31 33111 CALL Drawing_46 Call Drawing_46.
33114 BIT 2,C If bit 2 of C is set then jump to Drawing_32.
33116 JR Z,Drawing_32
33118 CALL Drawing_29 Call Drawing_29.
33121 JR Z,Drawing_37
33123 JR Drawing_33 Jump to Drawing_33.
Drawing_32 33125 CALL Drawing_28 Call Drawing_28.
33128 JR Z,Drawing_37
Drawing_33 33130 DEC B Decrease B by one.
33131 JR NZ,Drawing_36 Jump to Drawing_36 if it is not zero.
33133 BIT 1,C If bit 1 of C is set then jump to Drawing_34.
33135 JR Z,Drawing_34
33137 CALL Drawing_27 Call Drawing_27.
33140 JR Z,Drawing_37
33142 JR Drawing_35
Drawing_34 33144 CALL Drawing_25
33147 JR Z,Drawing_37
Drawing_35 33149 POP BC
33150 PUSH BC
Drawing_36 33151 DEC L
33152 JR NZ,Drawing_31
Drawing_37 33154 POP BC Restore BC and HL from the stack.
33155 POP HL
33156 RET Return.
Drawing_38 33157 PUSH HL Stash HL and BC on the stack.
33158 PUSH BC
Drawing_39 33159 CALL Drawing_46 Call Drawing_46.
33162 BIT 1,C
33164 JR Z,Drawing_40
33166 CALL Drawing_27
33169 JR Z,Drawing_45
33171 JR Drawing_41
Drawing_40 33173 CALL Drawing_25
33176 JR Z,Drawing_45
Drawing_41 33178 DEC B
33179 JR NZ,Drawing_44
33181 BIT 2,C
33183 JR Z,Drawing_42
33185 CALL Drawing_29
33188 JR Z,Drawing_45
33190 JR Drawing_43
Drawing_42 33192 CALL Drawing_28
33195 JR Z,Drawing_45
Drawing_43 33197 POP BC
33198 PUSH BC
Drawing_44 33199 DEC L
33200 JR NZ,Drawing_39
Drawing_45 33202 POP BC Restore BC and HL from the stack.
33203 POP HL
33204 RET Return.
Drawing_46 33205 PUSH HL
33206 CALL Drawing_48
33209 PUSH AF
33210 PUSH HL
33211 LD A,H
33212 AND %00011000 Keep only bits 3-4.
33214 RRCA
33215 RRCA
33216 RRCA
33217 ADD A,88
33219 LD H,A
33220 LD A,(HL)
33221 AND %00111000 Keep only bits 3-5.
33223 LD (HL),A
33224 LD A,(33358)
33227 RLCA
33228 RLCA
33229 RLCA
33230 CP (HL)
33231 JR NZ,Drawing_47
33233 XOR 56
Drawing_47 33235 RRCA
33236 RRCA
33237 RRCA
33238 OR (HL)
33239 LD (HL),A
33240 POP HL
33241 POP AF
33242 OR (HL)
33243 LD (HL),A
33244 POP HL
33245 RET Return.
Drawing_48 33246 LD A,127
33248 SUB E
33249 LD L,A
33250 AND %00000111 Keep only bits 0-2.
33252 OR 64
33254 LD H,A
33255 LD A,L
33256 AND %11000000 Keep only bits 6-7.
33258 RRCA
33259 RRCA
33260 RRCA
33261 OR H
33262 LD H,A
33263 LD A,L
33264 AND %00111000 Keep only bits 3-5.
33266 RLCA
33267 RLCA
33268 LD L,A
33269 LD A,D
33270 RRCA
33271 RRCA
33272 RRCA
33273 AND %00011111 Keep only bits 0-4.
33275 OR L
33276 LD L,A
33277 LD A,D
33278 AND %00000111 Keep only bits 0-2.
33280 PUSH BC Stash BC on the stack temporarily.
33281 LD B,A Copy A to B used as a counter for the rotate command.
33282 INC B
33283 LD A,1 A=00000001.
Drawing_49 33285 RRC A Rotate A right once.
33287 DJNZ Drawing_49 Decrease counter by one and loop back to Drawing_49 until counter is zero.
33289 POP BC Restore BC from the stack.
33290 RET Return.
DrawingClear 33291 CALL LocationLit Call LocationLit.
33294 EX AF,AF' Store the first byte of the graphic data in the shadow AF register.
33295 LD A,(IY+0)
33298 INC IY Increment the graphic data pointer to the next byte.
33300 EX AF,AF' Switch back to the "normal" AF register to check the result of the call to LocationLit.
33301 JR NC,DrawingBorder Jump to DrawingBorder if LocationLit did not set the carry flag (so, it is LIGHT).
33303 EX AF,AF' Overwrite the graphic data in the shadow AF register to $00 (black).
33304 XOR A
33305 EX AF,AF' Switch back to the "normal" AF register simply to accomodate the jump from 33301.
DrawingBorder 33306 EX AF,AF' Switch to the shadow AF register containing the first byte of the graphic data (or $00 if it's dark).
33307 OUT (254),A Set the border colour to the value in A.
33309 PUSH HL Store HL, DE and BC on the stack.
33310 PUSH DE
33311 PUSH BC
33312 LD HL,16384 Write $00 to $4000-$4FFF (the screen buffer).
33315 LD DE,16385
33318 LD BC,4095
33321 LD (HL),0
33323 LDIR
33325 LD HL,22528 Set up copying to the attribute buffer (start=$5800, length=$01FF).
33328 LD DE,22529
33331 LD BC,511
33334 LD A,(IY+0) A=The next byte (second) of the graphic data.
33337 INC IY Increment the graphic data pointer to the next byte.
33339 EX AF,AF' Switch back to the "normal" AF register which contains the LIGHT/ DARK carry flag.
33340 JR NC,DrawingPaper Jump to DrawingPaper if LocationLit did not set the carry flag (so, it is LIGHT).
33342 EX AF,AF' Overwrite the graphic data in the shadow AF register to $00 (black).
33343 XOR A
33344 EX AF,AF' Switch back to the "normal" AF register simply to accomodate the jump from 33340.
DrawingPaper 33345 EX AF,AF' Switch to the shadow AF register containing the second byte of the graphic data (or $00 if it's dark).
33346 LD (HL),A Write this to the attribute buffer using the target/ length specified previously.
33347 LDIR
33349 POP BC Restore BC, DE and HL from the stack.
33350 POP DE
33351 POP HL
33352 EX AF,AF' Switch back to the "normal" AF register which contains the LIGHT/ DARK carry flag.
33353 RET NC Return if it is LIGHT.
33354 POP HL Else, restore HL from the stack and jump to DrawingEnd to finish.
33355 JP DrawingEnd
33358 DEFB 56,0,0
Prev: 32631 Up: Map Next: 33361