Prev: 96D8 Up: Map Next: 97BD
9724: Start Crystal Object
Used by the routine at RunFrame.
Purpose not yet known. Starts an object of type 1E at a fixed map position when the player is in the right place and the value at F601 is not FF.
StartCrystalObject 9724 LD A,($F601) Fetch the value from F601.
9727 INC A Increment it.
9728 RET Z Return if it was FF.
9729 LD A,($C8E9) Fetch the map zone of the player from C8E9.
972C CP $0B Is it 0B or more?
972E RET NC Return if so.
972F LD A,($C8E6) Fetch the map column of the player from C8E6.
9732 CP $52 Is it 52?
9734 RET NZ Return if not.
9735 LD A,($C8E7) Fetch the horizontal position of the player from C8E7.
9738 CP $5C Is it 5C?
973A RET NZ Return if not.
973B LD A,($F601) Fetch the value from F601.
973E CP $06 Jump to StartCrystalObject_Set if it is not six.
9740 JR NZ,StartCrystalObject_Set
9742 LD A,($C905) Fetch the value from StackHeight.
9745 CP $12 Is it 12?
9747 RET NZ Return if not.
9748 LD A,$08 Use 08.
StartCrystalObject_Set 974A OR %10000000 Set bit 7.
974C LD ($C904),A Store the value in C904.
974F CALL FindFreeEnemySlot Find a free slot.
9752 CALL FreeObjectSlot Clear the slot.
9755 LD HL,($C900) Fetch the value from C900.
9758 LD A,L Swap the bytes...
9759 LD L,H
975A LD H,A
975B CALL NegateNumber ...and negate the result.
975E LD (IX+$09),H Set the vertical speed of the object.
9761 LD (IX+$0A),L
9764 LD (IX+$10),$23 Set the flags of the object to 23.
9768 LD (IX+$0F),$1B Set the vertical acceleration of the object.
976C LD (IX+$00),$1E Set the type of the object to 1E.
9770 LD A,($F601) Fetch the value from F601.
9773 LD (IX+$13),A Set the first state byte of the object.
9776 LD B,A Keep a copy in B.
9777 ADD A,A Multiply it by five.
9778 ADD A,A
9779 ADD A,B
977A ADD A,$04 Add four.
977C LD HL,$96B0 Use the table at UpdateCrystalStack_Table.
977F CALL AddAToHL Add the offset to the address.
9782 LD B,(HL) Fetch the value from the table.
9783 LD A,$73 Add 73.
9785 ADD A,B
9786 LD (IX+$16),A Set the third state byte of the object.
9789 LD A,($C8E9) Fetch the map zone of the player from C8E9.
978C LD (IX+$04),A Set the map zone of the object.
978F LD (IX+$01),$52 Set the map column of the object to 52.
9793 LD (IX+$02),$68 Set the horizontal position of the object to 68.
9797 LD A,($C8EA) Fetch the vertical position of the player from C8EA.
979A LD (IX+$05),A Set the vertical position of the object.
979D LD (IX+$0D),$FF Make the attribute of the object FF.
97A1 LD (IX+$15),$0A Set the lifetime of the object to ten.
97A5 LD A,($F601) Fetch the value from F601.
97A8 CP $06 Jump to StartCrystalObject_Done if it is not six.
97AA JR NZ,StartCrystalObject_Done
97AC LD (IX+$13),$08 Set the first state byte of the object to eight.
97B0 XOR A Clear StackHeight.
97B1 LD ($C905),A
97B4 LD ($F600),A Clear F600.
StartCrystalObject_Done 97B7 LD A,$FF Set F601 to FF.
97B9 LD ($F601),A
97BC RET Return.
Prev: 96D8 Up: Map Next: 97BD