Prev: B1B2 Up: Map Next: B2CC
B1FF: Add Item Record
Used by the routine at DrawObject.
Adds a 14-byte record to the table at Records, from the entity in IX and the details held at CellPosition, DrawingPosition, RecordDetails and 5CF5. 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 11 and 12 set both sizes to 08 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 B1FF LD IY,$0000 Use the next free record.
B203 LD A,($BBF6) Count one more record.
B206 INC A
B207 LD ($BBF6),A
B20A LD DE,($5CB9) Fetch the cell position.
B20E LD A,(IX+$00) Read the entity's type.
B211 LD B,A Keep the type aside.
B212 AND %11110000 Use the high nibble of the type.
B214 LD (IY+$03),A Keep it as byte 3 of the record.
B217 LD A,B Shift the type up by four and keep it as byte 6.
B218 ADD A,A
B219 ADD A,A
B21A ADD A,A
B21B ADD A,A
B21C LD (IY+$06),A
B21F LD (IY+$02),E Keep the cell position in bytes 2 and 5.
B222 LD (IY+$05),D
B225 LD A,(IX+$01) Read the frame.
B228 LD H,A Keep the frame aside.
B229 AND %00001111 Use the frame number.
B22B LD L,A Keep the frame number aside.
B22C LD A,H Bring bit 4 of the frame down beside it.
B22D RRA
B22E RRA
B22F RRA
B230 AND %00010000 Use that bit.
B232 OR L Combine it with the frame number and keep it as byte 0A.
B233 LD (IY+$0A),A
B236 LD HL,($5CF3) Copy the first two sizes into bytes 0B and 0C.
B239 LD (IY+$0B),L
B23C LD (IY+$0C),H
B23F LD A,($5CF5) Copy the third size into byte 0D.
B242 LD (IY+$0D),A
B245 ADD A,$0A Make bytes 4 and 7 from that size, the details and 10.
B247 LD B,A
B248 ADD A,H
B249 ADD A,$10
B24B LD (IY+$07),A
B24E LD A,B
B24F ADD A,L
B250 ADD A,$10
B252 LD (IY+$04),A
B255 LD DE,($5CDC) Fetch the drawing position.
B259 LD A,(IX+$01) Read the frame again.
B25C AND %01110000 Use bits 4-6 of the frame.
B25E ADD A,E Add them to the position and advance its high byte.
B25F LD E,A
B260 INC D
B261 LD (IY+$08),D Keep that position in bytes 8 and 9.
B264 LD (IY+$09),E
B267 LD H,(IY+$05) Make the address kept in bytes 12 and 13.
B26A LD L,(IY+$06)
B26D ADD HL,DE
B26E LD A,B
B26F LD BC,$FFF0
B272 ADD HL,BC
B273 LD B,A
B274 LD (IY+$12),H
B277 LD (IY+$13),L
B27A LD A,B Add the size to the low byte of the drawing position.
B27B ADD A,E
B27C LD E,A
B27D JR NC,AddItemRecord_Address
B27F INC D Count the carry in the high byte.
AddItemRecord_Address B280 LD H,(IY+$02) Fetch bytes 2 and 3 of the record.
B283 LD L,(IY+$03)
B286 AND A Subtract the drawing position.
B287 SBC HL,DE
B289 LD (IY+$10),H Keep that address in bytes 10 and 11.
B28C LD (IY+$11),L
B28F LD HL,($BB9F) Fetch the origin.
B292 LD A,($5CF0) Read the drawing flags.
B295 AND %00000111 Use bits 0-2 of the drawing flags.
B297 OR L Combine them with the low byte of the origin.
B298 LD (IY+$00),H Keep the origin in bytes 0 and 1.
B29B LD (IY+$01),A
B29E LD HL,($BBA1) Copy the screen position into bytes 0E and 0F.
B2A1 LD (IY+$0E),H
B2A4 LD (IY+$0F),L
B2A7 LD A,(IY+$0A) Kinds 11 and 12 use fixed sizes.
B2AA CP $11
B2AC JR Z,AddItemRecord_Fixed
B2AE CP $12
B2B0 JR NZ,AddItemRecord_Next
AddItemRecord_Fixed B2B2 SET 2,(IY+$03) Set bit 2 of bytes 3 and 6.
B2B6 SET 2,(IY+$06)
B2BA LD (IY+$0B),$08 Set both sizes to 08.
B2BE LD (IY+$0C),$08
AddItemRecord_Next B2C2 LD DE,$0014 Advance to the next free record.
B2C5 ADD IY,DE
B2C7 LD ($B201),IY
B2CB RET Return.
Prev: B1B2 Up: Map Next: B2CC