Prev: 44132 Up: Map Next: 44423
44340: Queue Program
Used by the routine at UseActionKey_Up.
Adds a program to the queue of programs that the robot is carrying (or adds a blank, if the robot is not picking one up), and then draws the four icons of the queue in the panel. The queue holds five entries, and the oldest one is pushed out of the end.
Input
A Program to add (6), or 0 for a blank
Output
A The entry that was pushed out of the queue (0 if it was blank)
QueueProgram 44340 PUSH HL Save the registers.
44341 PUSH DE
44342 PUSH BC
44343 LD DE,38469 Point DE at the end of the queue...
44346 LD HL,38468 ...and HL at the entry before it.
44349 LD BC,4 There are four entries to move along.
44352 LDDR Move the entries along.
44354 INC HL Put the new entry at the start of the queue.
44355 LD (HL),A
44356 LD HL,22392 Point HL at the screen address of the first icon.
44359 LD DE,38465 Point DE at ProgramQueue.
44362 LD C,2 There are two rows of icons...
QueueProgram_Row 44364 LD B,2 ...with two icons in each.
QueueProgram_Icon 44366 CALL ClearIconArea Clear the area of the screen for the icon using ClearIconArea.
44369 LD A,(DE) Fetch the entry of the queue.
44370 AND A Jump if it is blank.
44371 JR Z,SkipBlankIcon
44373 PUSH DE Save the address in the queue...
44374 PUSH HL ...and the screen address.
44375 DEC A Take one off the type...
44376 AND 15 ...and keep it within the range of cell types.
44378 ADD A,A Multiply it by sixteen, which is the size of an entry in the table of cell templates.
44379 ADD A,A
44380 ADD A,A
44381 ADD A,A
44382 LD HL,38848 Point HL at CellTemplates.
44385 CALL AddAToHL Add the offset of the entry.
44388 LD A,(HL) Fetch the number of the sprite for the cell.
44389 LD HL,24739 Point HL at SpritePointers.
44392 ADD A,A Double the number of the sprite...
44393 CALL AddAToHL ...and add it to find the address of the sprite.
44396 LD E,(HL) Fetch the low byte of the address of the sprite...
44397 INC HL ...move on...
44398 LD D,(HL) ...and fetch the high byte.
44399 INC DE Move on to the byte after the height of the sprite.
44400 POP HL Restore the screen address.
44401 PUSH BC Save the counters.
44402 CALL DrawIcon Draw the icon using DrawIcon.
44405 POP BC Restore the counters.
44406 POP DE Restore the address in the queue.
This entry point is used by the routine at SkipBlankIcon.
QueueProgram_Next 44407 INC DE Move on to the next entry.
44408 DJNZ QueueProgram_Icon Loop back until both icons of the row have been drawn.
44410 LD HL,22520 Point HL at the screen address of the second row.
44413 DEC C Loop back until both rows have been drawn.
44414 JR NZ,QueueProgram_Row
44416 POP BC Restore the registers.
44417 POP DE
44418 POP HL
44419 LD A,(38469) Return the entry that was pushed out of the queue.
44422 RET Return.
Prev: 44132 Up: Map Next: 44423