![]() |
Routines |
| Prev: 44276 | Up: Map | Next: 44446 |
|
Used by the routine at BuildDrawList.
Converts the position of the entity with ConvertEntityPosition and adds it to the draw list. Entity types 12 and 16 are only appended with AppendEntityItem. Any other type is also given a record in the table of item records, which holds a copy of the rows of the screen buffer (which are 24 bytes wide) that lie under the entity, so that RestoreItemRows can put them back after the entity has been drawn.
|
||||||||||||||
| PrepareEntityItem | 44295 | PUSH HL | Save the item record pointer. | |||||||||||
| 44296 | CALL ConvertEntityPosition | Convert the position of the entity. | ||||||||||||
| 44299 | POP HL | Restore the item record pointer. | ||||||||||||
| 44300 | LD A,(IX+0) | Fetch the type of the entity. | ||||||||||||
| 44303 | CP 12 | Jump to AppendEntityItem if it is type 12. | ||||||||||||
| 44305 | JR Z,AppendEntityItem | |||||||||||||
| 44307 | CP 16 | Jump to AppendEntityItem if it is type 16. | ||||||||||||
| 44309 | JR Z,AppendEntityItem | |||||||||||||
|
This entry point is used by the routine at BuildDrawList.
Entry point used for the extra records, which are passed in IY.
Count the item.
|
||||||||||||||
| PrepareEntityItem_Table | 44311 | LD A,(62720) | Fetch the number of prepared items. | |||||||||||
| 44314 | INC A | Add one. | ||||||||||||
| 44315 | LD (62720),A | Store it again. | ||||||||||||
| 44318 | PUSH HL | Save the item record pointer. | ||||||||||||
| 44319 | CALL TestRecordsAgainstEntity | Check the 20-byte records for any that overlap the entity. | ||||||||||||
|
Check the 20-byte records for any that overlap the entity.
|
||||||||||||||
| 44322 | LD HL,(45164) | Fetch the next free item address. | ||||||||||||
|
Fetch the type.
|
||||||||||||||
| 44325 | LD A,(IX+0) | Fetch the type of the entity. | ||||||||||||
| 44328 | CP 2 | Jump to PrepareEntityItem_Entity if it is not type 2. | ||||||||||||
| 44330 | JR NZ,PrepareEntityItem_Entity | |||||||||||||
| 44332 | LD (HL),A | Use the type as the flag for the item. | ||||||||||||
| 44333 | PUSH IY | IY moves into DE. | ||||||||||||
| 44335 | POP DE | (via the stack). | ||||||||||||
| 44336 | INC HL | Move to the address bytes. | ||||||||||||
| 44337 | LD (HL),E | Store the low byte of the record address. | ||||||||||||
| 44338 | INC HL | Move on. | ||||||||||||
| 44339 | LD (HL),D | Store the high byte of the record address. | ||||||||||||
| 44340 | JR PrepareEntityItem_Header | Jump to PrepareEntityItem_Header. | ||||||||||||
|
Add an entity item (flag 1) to the draw list.
|
||||||||||||||
| PrepareEntityItem_Entity | 44342 | LD (HL),1 | Set the flag of the item to 1. | |||||||||||
| 44344 | INC HL | Move to the address bytes. | ||||||||||||
| 44345 | PUSH IX | IX moves into DE. | ||||||||||||
| 44347 | POP DE | (via the stack). | ||||||||||||
| 44348 | LD (HL),E | Store the low byte of the entity address. | ||||||||||||
| 44349 | INC HL | Move on. | ||||||||||||
| 44350 | LD (HL),D | Store the high byte of the entity address. | ||||||||||||
| PrepareEntityItem_Header | 44351 | INC HL | Move to the next free item. | |||||||||||
| 44352 | LD (45164),HL | Store it. | ||||||||||||
| 44355 | POP HL | Restore the item record pointer. | ||||||||||||
|
Fetch the address in the screen buffer.
|
||||||||||||||
| 44356 | LD E,(IX+24) | Fetch the low byte of the address in the screen buffer. | ||||||||||||
| 44359 | LD D,(IX+25) | Fetch the high byte of the address in the screen buffer. | ||||||||||||
|
Work out how many bytes wide the record is, from field 22 and field 14.
|
||||||||||||||
| 44362 | LD A,(IX+22) | Read field 22. | ||||||||||||
| 44365 | AND %00001111 | Keep the low nibble. | ||||||||||||
| 44367 | LD C,A | Copy it into C. | ||||||||||||
| 44368 | LD A,(IX+14) | Read field 14. | ||||||||||||
| 44371 | AND %00000111 | Use bits 0-2. | ||||||||||||
| 44373 | JR Z,PrepareEntityItem_Width | Jump to PrepareEntityItem_Width if they are all zero. | ||||||||||||
| 44375 | INC C | Otherwise add one to the width. | ||||||||||||
|
Patch the operand of the BC load at 44438 and write the record header: the first byte is the width plus 24 then the address in the screen buffer.
|
||||||||||||||
| PrepareEntityItem_Width | 44376 | LD A,232 | Start from 232. | |||||||||||
| 44378 | SUB C | Subtract the width. | ||||||||||||
| 44379 | LD (44438),A | Patch the operand of the BC load at 44436 with it. | ||||||||||||
| 44382 | NEG | Negate it to give the width plus 24. | ||||||||||||
| 44384 | LD (HL),A | Write it as the first byte of the record. | ||||||||||||
| 44385 | INC HL | Move on. | ||||||||||||
| 44386 | LD (HL),E | Write the low byte of the address in the screen buffer. | ||||||||||||
| 44387 | INC HL | Move on. | ||||||||||||
| 44388 | LD (HL),D | Write the high byte of the address in the screen buffer. | ||||||||||||
| 44389 | INC HL | Move on. | ||||||||||||
|
Patch the jump back into the unrolled copy so that only C bytes of each row are copied.
|
||||||||||||||
| 44390 | SLA C | Double the width. | ||||||||||||
| 44392 | LD A,248 | Start from 248. | ||||||||||||
| 44394 | SUB C | Subtract twice the width. | ||||||||||||
| 44395 | LD (44443),A | Patch the displacement of the DJNZ at PrepareEntityItem_Loop with it (the displacement is the byte at 44443). | ||||||||||||
| 44398 | SUB 2 | Subtract 2. | ||||||||||||
| 44400 | LD (HL),A | Write it as the fourth byte of the record. | ||||||||||||
| 44401 | INC HL | Move on. | ||||||||||||
|
Work out the number of rows from fields 23 and 15 and write it to the header.
|
||||||||||||||
| 44402 | LD A,(IX+23) | Read field 23. | ||||||||||||
| 44405 | AND %00111111 | Use bits 0-5. | ||||||||||||
| 44407 | INC A | Add one. | ||||||||||||
| 44408 | LD B,A | Copy it into B. | ||||||||||||
| 44409 | LD A,(IX+15) | Read field 15. | ||||||||||||
| 44412 | CP B | Compare it with the value in B. | ||||||||||||
| 44413 | JR NC,PrepareEntityItem_Skip | Jump to 44418 if it is not less. | ||||||||||||
| 44415 | ADD A,2 | Otherwise use field 15 plus 2. | ||||||||||||
| 44417 | LD B,A | Copy it into B. | ||||||||||||
| PrepareEntityItem_Skip | 44418 | LD (HL),B | Write the number of rows as the fifth byte of the record. | |||||||||||
| 44419 | INC HL | Move on. | ||||||||||||
|
Swap, ready to copy the rows from the data into the table.
|
||||||||||||||
| 44420 | EX DE,HL | Swap the screen buffer address into HL and the table pointer into DE. | ||||||||||||
| 44421 | JP PrepareEntityItem_Loop | Jump into the copy loop. | ||||||||||||
| PrepareEntityItem_Copy | 44424 | LDI | Copy a byte and move on. | |||||||||||
| 44426 | LDI | Copy a byte and move on. | ||||||||||||
| 44428 | LDI | Copy a byte and move on. | ||||||||||||
| 44430 | LDI | Copy a byte and move on. | ||||||||||||
| 44432 | LDI | Copy a byte and move on. | ||||||||||||
| 44434 | LDI | Copy a byte and move on. | ||||||||||||
| 44436 | LD A,B | Save the row counter. | ||||||||||||
| 44437 | LD BC,65280 | Set up the step back to the start of the next row (the low byte is patched at 44438). | ||||||||||||
| 44440 | ADD HL,BC | Move HL back to the start of the next row of the screen buffer. | ||||||||||||
| 44441 | LD B,A | Restore the row counter. | ||||||||||||
| PrepareEntityItem_Loop | 44442 | DJNZ PrepareEntityItem_Loop | Decrease the row counter and jump back into the copy chain (the displacement is patched at 44443) until all rows are copied. | |||||||||||
| 44444 | EX DE,HL | Swap the pointer to the next free byte back into HL. | ||||||||||||
| 44445 | RET | Return. | ||||||||||||
| Prev: 44276 | Up: Map | Next: 44446 |