Prev: 45490 Up: Map Next: 45772
45567: Add Item Record
Used by the routine at DrawObject.
Adds a 20-byte record to the table at Records, from the entity in IX and the details held at CellPosition, DrawingPosition, RecordDetails and 23797. The operand of the first instruction is the address of the next free record, and is updated each time. The number of records is kept in RecordCount. Kinds 17 and 18 set both sizes to 8 and set bit 2 of bytes 3 and 6.
Input
IX The entity
IY is the new record. Its bytes are filled from the entity and from the cell, the drawing position and the three sizes.
AddItemRecord 45567 LD IY,0 Use the next free record.
45571 LD A,(48118) Count one more record.
45574 INC A
45575 LD (48118),A
45578 LD DE,(23737) Fetch the cell position.
45582 LD A,(IX+0) Read the entity's type.
45585 LD B,A Keep the type aside.
45586 AND %11110000 Use the high nibble of the type.
45588 LD (IY+3),A Keep it as byte 3 of the record.
45591 LD A,B Shift the type up by four and keep it as byte 6.
45592 ADD A,A
45593 ADD A,A
45594 ADD A,A
45595 ADD A,A
45596 LD (IY+6),A
45599 LD (IY+2),E Keep the cell position in bytes 2 and 5.
45602 LD (IY+5),D
45605 LD A,(IX+1) Read the frame.
45608 LD H,A Keep the frame aside.
45609 AND %00001111 Use the frame number.
45611 LD L,A Keep the frame number aside.
45612 LD A,H Bring bit 4 of the frame down beside it.
45613 RRA
45614 RRA
45615 RRA
45616 AND %00010000 Use that bit.
45618 OR L Combine it with the frame number and keep it as byte 10.
45619 LD (IY+10),A
45622 LD HL,(23795) Copy the first two sizes into bytes 11 and 12.
45625 LD (IY+11),L
45628 LD (IY+12),H
45631 LD A,(23797) Copy the third size into byte 13.
45634 LD (IY+13),A
45637 ADD A,10 Make bytes 4 and 7 from that size, the details and 16.
45639 LD B,A
45640 ADD A,H
45641 ADD A,16
45643 LD (IY+7),A
45646 LD A,B
45647 ADD A,L
45648 ADD A,16
45650 LD (IY+4),A
45653 LD DE,(23772) Fetch the drawing position.
45657 LD A,(IX+1) Read the frame again.
45660 AND %01110000 Use bits 4-6 of the frame.
45662 ADD A,E Add them to the position and advance its high byte.
45663 LD E,A
45664 INC D
45665 LD (IY+8),D Keep that position in bytes 8 and 9.
45668 LD (IY+9),E
45671 LD H,(IY+5) Make the address kept in bytes 18 and 19.
45674 LD L,(IY+6)
45677 ADD HL,DE
45678 LD A,B
45679 LD BC,65520
45682 ADD HL,BC
45683 LD B,A
45684 LD (IY+18),H
45687 LD (IY+19),L
45690 LD A,B Add the size to the low byte of the drawing position.
45691 ADD A,E
45692 LD E,A
45693 JR NC,AddItemRecord_Address
45695 INC D Count the carry in the high byte.
AddItemRecord_Address 45696 LD H,(IY+2) Fetch bytes 2 and 3 of the record.
45699 LD L,(IY+3)
45702 AND A Subtract the drawing position.
45703 SBC HL,DE
45705 LD (IY+16),H Keep that address in bytes 16 and 17.
45708 LD (IY+17),L
45711 LD HL,(48031) Fetch the origin.
45714 LD A,(23792) Read the drawing flags.
45717 AND %00000111 Use bits 0-2 of the drawing flags.
45719 OR L Combine them with the low byte of the origin.
45720 LD (IY+0),H Keep the origin in bytes 0 and 1.
45723 LD (IY+1),A
45726 LD HL,(48033) Copy the screen position into bytes 14 and 15.
45729 LD (IY+14),H
45732 LD (IY+15),L
45735 LD A,(IY+10) Kinds 17 and 18 use fixed sizes.
45738 CP 17
45740 JR Z,AddItemRecord_Fixed
45742 CP 18
45744 JR NZ,AddItemRecord_Next
AddItemRecord_Fixed 45746 SET 2,(IY+3) Set bit 2 of bytes 3 and 6.
45750 SET 2,(IY+6)
45754 LD (IY+11),8 Set both sizes to 8.
45758 LD (IY+12),8
AddItemRecord_Next 45762 LD DE,20 Advance to the next free record.
45765 ADD IY,DE
45767 LD (45569),IY
45771 RET Return.
Prev: 45490 Up: Map Next: 45772