![]() |
Routines |
| Prev: 48961 | Up: Map | Next: 49377 |
|
Used by the routine at DrawGroupObjects.
Prepares an object of a group for drawing, and then passes it to the routine whose address is the operand of the JP at 49374 which is set by DrawLevelObjects. It works out the screen column and row of the object, and returns without doing anything if the object is not in view. Objects that can be entities are passed to AddObjectEntity first, and an object that has the flag for it in the row of flags of the group is also given an item record with AddItemRecord.
|
||||||||
|
Work out the screen column of the object. This is the depth of the cell plus the sum of the two halves of the first byte of the object, which are its offsets along the x and y axes, less the origin of the view.
|
||||||||
| DrawObject | 49061 | LD H,0 | Set H to the depth of the cell, which is patched in. | |||||
| 49063 | LD A,(IX+0) | Fetch the first byte of the object. | ||||||
| 49066 | ADD A,A | Multiply it by sixteen, to move the offset along the y axis to the top four bits... | ||||||
| 49067 | ADD A,A | |||||||
| 49068 | ADD A,A | |||||||
| 49069 | ADD A,A | |||||||
| 49070 | LD E,A | ...and keep it in E. | ||||||
| 49071 | LD A,(IX+0) | Fetch the first byte of the object again. | ||||||
| 49074 | AND %11110000 | Keep the offset along the x axis in the top four bits. | ||||||
| 49076 | ADD A,E | Add the two offsets to find the low byte of the screen column. | ||||||
| 49077 | JR NC,DrawObject_SetColumn | Jump to DrawObject_SetColumn if there was no carry. | ||||||
| 49079 | INC H | Increase the high byte of the screen column. | ||||||
| DrawObject_SetColumn | 49080 | LD L,A | Put the low byte of the screen column in L. | |||||
| 49081 | LD BC,0 | Set BC to the origin of the view, which is patched in. | ||||||
| 49084 | ADD HL,BC | Add the origin to the screen column. | ||||||
|
Find out whether the object can be an entity. Objects of kind 129 and 143 are passed to AddObjectEntity, and any other kind is drawn straight away.
|
||||||||
| 49085 | LD A,(IX+1) | Fetch the second byte of the object. | ||||||
| 49088 | AND %10001111 | Keep bit 7 and the kind in bits 0-3. | ||||||
| 49090 | CP 129 | Jump to DrawObject_Entity if it is kind 129. | ||||||
| 49092 | JR Z,DrawObject_Entity | |||||||
| 49094 | BIT 7,A | Jump to DrawObject_Position if bit 7 is not set. | ||||||
| 49096 | JP Z,DrawObject_Position | |||||||
| 49099 | INC A | Add one to the kind. | ||||||
| 49100 | AND %00001111 | Keep the kind. | ||||||
| 49102 | JP NZ,DrawObject_Position | Jump to DrawObject_Position unless the kind was 143. | ||||||
| DrawObject_Entity | 49105 | LD B,(IX+2) | Fetch the third byte of the object into B... | |||||
| 49108 | LD C,(IX+1) | ...and the second byte into C. | ||||||
| 49111 | PUSH BC | Save them. | ||||||
| 49112 | PUSH HL | Save the screen column. | ||||||
| 49113 | LD A,C | Copy the second byte into A. | ||||||
| 49114 | AND %10001111 | Keep bit 7 and the kind. | ||||||
| 49116 | CP 143 | Jump to DrawObject_Add if it is kind 143, so that the bytes are used as they are. | ||||||
| 49118 | JR Z,DrawObject_Add | |||||||
|
Change an object of kind 129 into an object of kind 143 that has the size of the object in its third byte, so that it is recorded with that size.
|
||||||||
| 49120 | LD A,B | Fetch the third byte of the object. | ||||||
| 49121 | RRA | Shift the size in bits 4-5 to bits 2-3... | ||||||
| 49122 | RRA | |||||||
| 49123 | AND %00110000 | ...and keep it. | ||||||
| 49125 | ADD A,16 | Add 16. | ||||||
| 49127 | LD B,A | Keep it in B. | ||||||
| 49128 | LD A,C | Fetch the second byte of the object. | ||||||
| 49129 | AND %01110000 | Keep the height in bits 4-6. | ||||||
| 49131 | ADD A,B | Add the size to the height. | ||||||
| 49132 | LD (IX+2),1 | Set the third byte of the object to 1. | ||||||
| 49136 | CP 128 | Jump to DrawObject_SetKind if it is below 128. | ||||||
| 49138 | JR C,DrawObject_SetKind | |||||||
| 49140 | SUB 128 | Take away 128. | ||||||
| 49142 | SET 6,(IX+2) | Set bit 6 of the third byte of the object. | ||||||
| DrawObject_SetKind | 49146 | OR %10001111 | Set bits 0-3 and bit 7, to make it kind 143. | |||||
| 49148 | LD (IX+1),A | Store it as the second byte of the object. | ||||||
| DrawObject_Add | 49151 | CALL AddObjectEntity | Add an entity for the object, if it has one, and record it. | |||||
| 49154 | POP HL | Restore the screen column. | ||||||
| 49155 | POP BC | Restore the second and third bytes of the object... | ||||||
| 49156 | LD (IX+1),C | ...and put them back. | ||||||
| 49159 | LD (IX+2),B | Put the third byte back. | ||||||
| 49162 | LD A,C | Fetch the second byte of the object. | ||||||
| 49163 | AND %10001111 | Keep bit 7 and the kind. | ||||||
| 49165 | CP 143 | Compare it with 143. | ||||||
| 49167 | RET Z | Return if it is kind 143 as it is an entity and is not drawn as a block. | ||||||
| 49168 | LD A,(IX+0) | Fetch the first byte of the object. | ||||||
| 49171 | ADD A,A | Multiply it by sixteen, to move the offset along the y axis to the top four bits... | ||||||
| 49172 | ADD A,A | |||||||
| 49173 | ADD A,A | |||||||
| 49174 | ADD A,A | |||||||
| 49175 | LD E,A | ...and keep it in E. | ||||||
|
Check that the object is not off the left of the view, or off the right of it, using the width of the object.
|
||||||||
| DrawObject_Position | 49176 | LD A,L | Fetch the low byte of the screen column. | |||||
| 49177 | AND %11111000 | Round it down to a multiple of eight. | ||||||
| 49179 | LD L,A | Put it back. | ||||||
| 49180 | PUSH HL | Save the screen column. | ||||||
| 49181 | BIT 7,H | Jump to DrawObject_Far if bit 7 of the high byte of the screen column is set. | ||||||
| 49183 | JR NZ,DrawObject_Far | |||||||
| 49185 | LD B,0 | Clear B. | ||||||
| 49187 | LD C,(IX+2) | Fetch the third byte of the object into C. | ||||||
| 49190 | SLA C | Double it. | ||||||
| 49192 | LD A,C | Copy it into A. | ||||||
| 49193 | AND %01110000 | Keep the width in bits 4-6. | ||||||
| 49195 | LD D,A | Keep it in D. | ||||||
| 49196 | LD A,C | Fetch the doubled byte again. | ||||||
| 49197 | ADD A,A | Shift it left three times, to move the depth to bits 4-6... | ||||||
| 49198 | ADD A,A | |||||||
| 49199 | ADD A,A | |||||||
| 49200 | AND %01110000 | ...and keep it. | ||||||
| 49202 | ADD A,D | Add the width. | ||||||
| 49203 | ADD A,31 | Add 31 to make the distance to the left of the object. | ||||||
| 49205 | LD C,A | Put it in C. | ||||||
| 49206 | ADD HL,BC | Add it to the screen column. | ||||||
| 49207 | INC HL | Move on by one more. | ||||||
| 49208 | RL H | Rotate bit 7 of the high byte into the carry flag. | ||||||
| 49210 | POP HL | Restore the screen column. | ||||||
| 49211 | RET NC | Return if the object is off the left of the view. | ||||||
| 49212 | JR DrawObject_Visible | Jump to DrawObject_Visible. | ||||||
| DrawObject_Far | 49214 | LD BC,32960 | BC is 32960 the right edge of the view. | |||||
| 49217 | SBC HL,BC | Subtract it from the screen column. | ||||||
| 49219 | POP HL | Restore the screen column. | ||||||
| 49220 | RET NC | Return if the object is off the right of the view. | ||||||
|
Work out the screen row of the object. This is half of the difference between its x and y coordinates, plus the offset to the view, less the height of the object.
|
||||||||
| DrawObject_Visible | 49221 | LD (48031),HL | Store the screen column, as the one to draw at. | |||||
| 49224 | LD A,(23738) | Fetch the row of the cell into D. | ||||||
| 49227 | LD D,A | Keep the y coordinate of the cell... | ||||||
| 49228 | LD HL,(23736) | Fetch the column of the cell into H. | ||||||
| 49231 | LD A,(IX+0) | Fetch the first byte of the object. | ||||||
| 49234 | AND %11110000 | Keep the offset along the x axis. | ||||||
| 49236 | LD L,A | Make it the low byte of the x coordinate. | ||||||
| 49237 | SRL D | Halve the y coordinate... | ||||||
| 49239 | RR E | |||||||
| 49241 | SRL H | ...and halve the x coordinate. | ||||||
| 49243 | RR L | |||||||
| 49245 | AND A | Subtract half of the y coordinate from half of the x coordinate. | ||||||
| 49246 | SBC HL,DE | |||||||
| 49248 | LD DE,0 | Set DE to the offset to the view, which is patched in. | ||||||
| 49251 | ADD HL,DE | Add the offset. | ||||||
| 49252 | LD A,(IX+1) | Fetch the second byte of the object. | ||||||
| 49255 | AND %01110000 | Keep the height in bits 4-6. | ||||||
| 49257 | LD E,A | Keep it in E. | ||||||
| 49258 | LD A,(IX+1) | Fetch the second byte of the object again. | ||||||
| 49261 | AND %10001111 | Keep bit 7 and the kind. | ||||||
| 49263 | CP 131 | Jump to DrawObject_AddHeight if it is kind 131. | ||||||
| 49265 | JR Z,DrawObject_AddHeight | |||||||
| 49267 | CP 133 | Jump to DrawObject_SubtractHeight unless it is kind 133. | ||||||
| 49269 | JR NZ,DrawObject_SubtractHeight | |||||||
| DrawObject_AddHeight | 49271 | LD A,16 | A is 16 which is added to the height of these kinds. | |||||
| 49273 | ADD A,E | Add the height. | ||||||
| 49274 | LD E,A | Keep it in E. | ||||||
| DrawObject_SubtractHeight | 49275 | LD D,0 | Clear D. | |||||
| 49277 | AND A | Subtract the height from the screen row. | ||||||
| 49278 | SBC HL,DE | |||||||
| 49280 | PUSH HL | Save the screen row. | ||||||
|
Check that the object is not above the view.
|
||||||||
| 49281 | LD A,(IX+2) | Fetch the third byte of the object. | ||||||
| 49284 | ADD A,A | Shift it left three times, to move the depth to bits 3-5... | ||||||
| 49285 | ADD A,A | |||||||
| 49286 | ADD A,A | |||||||
| 49287 | AND %00111000 | ...and keep it. | ||||||
| 49289 | ADD A,8 | Add 8. | ||||||
| 49291 | LD E,A | Keep it in E. | ||||||
| 49292 | ADD HL,DE | Add it to the screen row. | ||||||
| 49293 | RL H | Rotate bit 7 of the high byte into the carry flag. | ||||||
| 49295 | POP HL | Restore the screen row. | ||||||
| 49296 | RET NC | Return if the object is above the view. | ||||||
|
Check that the object is not below the view, and work out the height of the object.
|
||||||||
| 49297 | PUSH HL | Save the screen row. | ||||||
| 49298 | LD A,(IX+2) | Fetch the third byte of the object and keep it in B. | ||||||
| 49301 | LD B,A | |||||||
| 49302 | AND %00111000 | Keep the depth in bits 3-5. | ||||||
| 49304 | ADD A,8 | Add 8. | ||||||
| 49306 | LD E,A | Keep it in E. | ||||||
| 49307 | LD A,(IX+1) | Fetch the second byte of the object. | ||||||
| 49310 | BIT 7,A | Jump to DrawObject_SizeFromByte if bit 7 is set. | ||||||
| 49312 | JR NZ,DrawObject_SizeFromByte | |||||||
| 49314 | AND %00001111 | Keep the kind. | ||||||
| 49316 | SUB 2 | Take away 2. | ||||||
| 49318 | JR Z,DrawObject_StoreHeight | Jump to DrawObject_StoreHeight if it is kind 2 with zero as the size. | ||||||
| DrawObject_SizeFromByte | 49320 | LD A,B | Fetch the third byte of the object. | |||||
| 49321 | RRA | Shift the size in bits 4-5 to bits 2-3... | ||||||
| 49322 | RRA | |||||||
| 49323 | AND %00110000 | ...and keep it. | ||||||
| 49325 | ADD A,16 | Add 16. | ||||||
| DrawObject_StoreHeight | 49327 | LD (23797),A | Store it as the height of the object, in 23797. | |||||
| 49330 | ADD A,E | Add the depth. | ||||||
| 49331 | LD E,A | Keep it in E. | ||||||
| 49332 | SBC HL,DE | Subtract it from the screen row. | ||||||
| 49334 | LD DE,32896 | DE is 32896 the bottom of the view. | ||||||
| 49337 | SBC HL,DE | Subtract it from the screen row. | ||||||
| 49339 | POP HL | Restore the screen row. | ||||||
| 49340 | RET NC | Return if the object is below the view. | ||||||
| 49341 | LD (48033),HL | Store the screen row, as the one to draw at. | ||||||
|
Work out the depth and the width of the object, and store them.
|
||||||||
| 49344 | LD A,(IX+2) | Fetch the third byte of the object. | ||||||
| 49347 | ADD A,A | Double it... | ||||||
| 49348 | LD B,A | ...and keep it in B. | ||||||
| 49349 | AND %01110000 | Keep the size in bits 4-6. | ||||||
| 49351 | ADD A,16 | Add 16. | ||||||
| 49353 | LD (23796),A | Store it as the depth of the object, in 23796. | ||||||
| 49356 | LD A,B | Fetch the doubled byte again. | ||||||
| 49357 | ADD A,A | Shift it left three times, to move the other size to bits 4-6... | ||||||
| 49358 | ADD A,A | |||||||
| 49359 | ADD A,A | |||||||
| 49360 | AND %01110000 | ...and keep it. | ||||||
| 49362 | ADD A,16 | Add 16. | ||||||
| 49364 | LD (23795),A | Store it as the width of the object, in RecordDetails. | ||||||
|
Give the object an item record if its flag in the row of flags of the group is set, and then pass it to the routine that handles it.
|
||||||||
| 49367 | LD A,(48015) | Fetch the first byte of the row of flags of the group. | ||||||
| 49370 | RLA | Rotate its top bit into the carry flag. | ||||||
| DrawObject_Record | 49371 | CALL C,AddItemRecord | Add an item record for the object if the flag is set. | |||||
| DrawObject_Handle | 49374 | JP DrawObject_Handle | Jump to the routine that handles the object, which is patched in. | |||||
| Prev: 48961 | Up: Map | Next: 49377 |