Prev: 43019 Up: Map Next: 43225
43173: Add To Stack
Used by the routine at DrawShot.
Adds one or two units to the height of the stack at StackHeight (which hangs below the ship) if the item that is carried at 62977 is item number 6. The limit is 18. The screen is cleared where the new units will be drawn. This is a best reading of the code. An object with a state of zero does not add anything.
Input
IX Address of the object
AddToStack 43173 LD A,(IX+19) Fetch the state of the object.
43176 AND A Return if it is zero.
43177 RET Z
This entry point is used by the routine at CheckShotCollisions.
The routine is entered here with a state in A when the number of units is random.
AddToStack_Units 43178 AND %00000010 Keep bit 1 of the state...
43180 SRL A ...move it to bit 0...
43182 INC A ...and add one to get one or two units.
43183 LD B,A Store the number of units in B.
43184 LD A,(62977) Fetch the item that is carried.
43187 CP 6 Return if it is not item number 6.
43189 RET NZ
43190 LD A,(51461) Fetch the height of the stack and keep the old height in E.
43193 LD E,A
43194 ADD A,B Add the new units.
43195 CP 18 Jump to AddToStack_Store if the height is below the limit of 18.
43197 JR C,AddToStack_Store
43199 LD A,18 Use the limit.
AddToStack_Store 43201 LD (51461),A Store the new height of the stack.
43204 LD A,(51459) Fetch the vertical position of the ship.
43207 SUB E Subtract the old height to find the first new row.
43208 LD H,A Store it in H.
43209 LD L,112 Use the horizontal position of the stack.
43211 CALL GetScreenAddress Find the screen address.
AddToStack_Clear 43214 LD (HL),0 Clear the left byte of the row.
43216 INC L Move on to the right.
43217 LD (HL),0 Clear the right byte of the row.
43219 DEC L Move back to the left.
43220 CALL MoveUpARowDE Move up a row.
43223 DJNZ AddToStack_Clear Loop back to AddToStack_Clear for each new unit.
Continue on to BuildStackGraphic.
Prev: 43019 Up: Map Next: 43225