Prev: AC64 Up: Map Next: AD87
AD34: 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 (06), or 00 for a blank
Output
A The entry that was pushed out of the queue (00 if it was blank)
QueueProgram AD34 PUSH HL Save the registers.
AD35 PUSH DE
AD36 PUSH BC
AD37 LD DE,$9645 Point DE at the end of the queue...
AD3A LD HL,$9644 ...and HL at the entry before it.
AD3D LD BC,$0004 There are four entries to move along.
AD40 LDDR Move the entries along.
AD42 INC HL Put the new entry at the start of the queue.
AD43 LD (HL),A
AD44 LD HL,$5778 Point HL at the screen address of the first icon.
AD47 LD DE,$9641 Point DE at ProgramQueue.
AD4A LD C,$02 There are two rows of icons...
QueueProgram_Row AD4C LD B,$02 ...with two icons in each.
QueueProgram_Icon AD4E CALL ClearIconArea Clear the area of the screen for the icon using ClearIconArea.
AD51 LD A,(DE) Fetch the entry of the queue.
AD52 AND A Jump if it is blank.
AD53 JR Z,SkipBlankIcon
AD55 PUSH DE Save the address in the queue...
AD56 PUSH HL ...and the screen address.
AD57 DEC A Take one off the type...
AD58 AND $0F ...and keep it within the range of cell types.
AD5A ADD A,A Multiply it by sixteen, which is the size of an entry in the table of cell templates.
AD5B ADD A,A
AD5C ADD A,A
AD5D ADD A,A
AD5E LD HL,$97C0 Point HL at CellTemplates.
AD61 CALL AddAToHL Add the offset of the entry.
AD64 LD A,(HL) Fetch the number of the sprite for the cell.
AD65 LD HL,$60A3 Point HL at SpritePointers.
AD68 ADD A,A Double the number of the sprite...
AD69 CALL AddAToHL ...and add it to find the address of the sprite.
AD6C LD E,(HL) Fetch the low byte of the address of the sprite...
AD6D INC HL ...move on...
AD6E LD D,(HL) ...and fetch the high byte.
AD6F INC DE Move on to the byte after the height of the sprite.
AD70 POP HL Restore the screen address.
AD71 PUSH BC Save the counters.
AD72 CALL DrawIcon Draw the icon using DrawIcon.
AD75 POP BC Restore the counters.
AD76 POP DE Restore the address in the queue.
This entry point is used by the routine at SkipBlankIcon.
QueueProgram_Next AD77 INC DE Move on to the next entry.
AD78 DJNZ QueueProgram_Icon Loop back until both icons of the row have been drawn.
AD7A LD HL,$57F8 Point HL at the screen address of the second row.
AD7D DEC C Loop back until both rows have been drawn.
AD7E JR NZ,QueueProgram_Row
AD80 POP BC Restore the registers.
AD81 POP DE
AD82 POP HL
AD83 LD A,($9645) Return the entry that was pushed out of the queue.
AD86 RET Return.
Prev: AC64 Up: Map Next: AD87