Prev: 37100 Up: Map Next: 37187
37130: 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 37130 LD A,(IX+19) Fetch the first state byte and keep a copy in B.
37133 LD B,A
37134 AND %00110000 Only bits 4 and 5.
37136 SUB 16 Subtract 16.
37138 LD D,A Keep the result in D.
37139 JR NZ,StepObjectState_Finish Jump to StepObjectState_Finish if bits 4 and 5 were not equal to one.
37141 LD A,B Fetch the first state byte again.
37142 AND %00001111 Keep the bottom four bits.
37144 INC A Add one.
37145 LD E,A Keep it in E.
37146 LD A,(IX+20) Fetch the second state byte.
37149 AND %00001111 Keep the bottom four bits.
37151 INC A Add one.
37152 CP E Compare it with the first.
37153 JR NZ,StepObjectState_Store Jump to StepObjectState_Store if they are not the same.
37155 LD E,(IX+20) Fetch the second state byte.
37158 SRL E Shift the top four bits into the bottom four bits to use as the new count.
37160 SRL E
37162 SRL E
37164 SRL E
StepObjectState_Store 37166 LD A,B Fetch the first state byte.
37167 AND %11110000 Keep the top four bits.
37169 OR E Combine them with the new count.
37170 LD B,A Keep the result in B.
37171 LD A,B Copy it into A.
37172 AND %11000000 Only bits 6 and 7.
37174 SRL A Shift them right twice.
37176 SRL A
37178 LD D,A Keep the result in D.
StepObjectState_Finish 37179 LD A,B Fetch the first state byte.
37180 AND %11001111 Clear bits 4 and 5.
37182 OR D Combine them with the new bits.
37183 LD (IX+19),A Store it.
37186 RET Return.
Prev: 37100 Up: Map Next: 37187