Prev: 9DA7 Up: Map Next: 9E4F
9DFE: Send Program Packet
Used by the routine at MainLoop.
Starts a program packet flying from a program transmitter, unless one is already on its way. It queues the messages "PROGRAM SENT FROM" and "SECTOR n".
Input
HL Address of the program transmitter in the map
SendProgramPacket 9DFE LD A,($9770) Fetch the type of the program packet (entity 0E).
9E01 AND A Return if it is already in use.
9E02 RET NZ
9E03 PUSH HL Save the address of the transmitter...
9E04 PUSH HL ...twice.
9E05 LD HL,$9770 Point HL at ProgramPacketEntity.
9E08 LD B,$10 Clear all 10 bytes of the entity.
SendProgramPacket_ClearEntity 9E0A LD (HL),$00 Zero a byte.
9E0C INC HL Move on to the next byte.
9E0D DJNZ SendProgramPacket_ClearEntity Loop back until the entity has been cleared.
9E0F POP HL Restore the address of the transmitter.
9E10 LD IX,$9770 Point IX at ProgramPacketEntity.
9E14 LD (IX+$00),$6E Set the type of the entity to 6E, the first sprite of the program packet.
9E18 LD DE,$C515 Point DE at Map.
9E1B SBC HL,DE Subtract it to find the offset of the transmitter.
9E1D LD A,L Fetch the low byte of the offset.
9E1E AND $3F The column is in the low six bits.
9E20 ADD HL,HL Multiply the offset by four...
9E21 ADD HL,HL
9E22 LD L,A ...and keep the column in L.
9E23 LD A,H The row is in the high byte, in the low six bits.
9E24 AND $3F Limit the row to 00-3F...
9E26 LD H,A ...and keep it in H.
9E27 LD A,($9617) Fetch the random number...
9E2A AND $3F ...limited to 00-3F...
9E2C LD (IX+$07),A ...as a timer for the program packet.
9E2F LD (IX+$02),L Set the X cell of the packet to that of the transmitter.
9E32 LD (IX+$04),H Set the Y cell of the packet to that of the transmitter.
9E35 PUSH DE Save the registers.
9E36 PUSH BC Save the registers.
9E37 LD DE,$0002 Queue message 02, "PROGRAM SENT FROM"...
9E3A CALL QueueMessage ...using QueueMessage.
9E3D CALL FindSector Find the sector that the packet is in using FindSector.
9E40 LD E,$01 Queue message 01, "SECTOR n"...
9E42 CALL QueueMessage ...using QueueMessage.
9E45 LD HL,$0105 Start effect 01 (five tones).
9E48 LD ($9688),HL Store the length and the effect number for PlaySoundStep.
9E4B POP BC Restore the registers.
9E4C POP DE Restore the registers.
9E4D POP HL Restore the address of the transmitter.
9E4E RET Return.
Prev: 9DA7 Up: Map Next: 9E4F