Prev: 90EC Up: Map Next: 9143
910A: Step Object State
Used by the routines at UpdateType1C, UpdateType1D, UpdateType14 and UpdateMapObjects.
Steps through a sequence held in the two state bytes of an object. If bits 4 and 5 of the first state byte are equal to one, the bottom four bits of the first state byte count up and wrap round when they reach the value in the bottom four bits of the second state byte. Otherwise, bits 4 and 5 of the first state byte are adjusted. Purpose not yet known.
Input
IX Address of the object
StepObjectState 910A LD A,(IX+$13) Fetch the first state byte and keep a copy in B.
910D LD B,A
910E AND %00110000 Only bits 4 and 5.
9110 SUB $10 Subtract 10.
9112 LD D,A Keep the result in D.
9113 JR NZ,StepObjectState_Finish Jump to StepObjectState_Finish if bits 4 and 5 were not equal to one.
9115 LD A,B Fetch the first state byte again.
9116 AND %00001111 Keep the bottom four bits.
9118 INC A Add one.
9119 LD E,A Keep it in E.
911A LD A,(IX+$14) Fetch the second state byte.
911D AND %00001111 Keep the bottom four bits.
911F INC A Add one.
9120 CP E Compare it with the first.
9121 JR NZ,StepObjectState_Store Jump to StepObjectState_Store if they are not the same.
9123 LD E,(IX+$14) Fetch the second state byte.
9126 SRL E Shift the top four bits into the bottom four bits to use as the new count.
9128 SRL E
912A SRL E
912C SRL E
StepObjectState_Store 912E LD A,B Fetch the first state byte.
912F AND %11110000 Keep the top four bits.
9131 OR E Combine them with the new count.
9132 LD B,A Keep the result in B.
9133 LD A,B Copy it into A.
9134 AND %11000000 Only bits 6 and 7.
9136 SRL A Shift them right twice.
9138 SRL A
913A LD D,A Keep the result in D.
StepObjectState_Finish 913B LD A,B Fetch the first state byte.
913C AND %11001111 Clear bits 4 and 5.
913E OR D Combine them with the new bits.
913F LD (IX+$13),A Store it.
9142 RET Return.
Prev: 90EC Up: Map Next: 9143