Prev: B538 Up: Map Next: B566
B544: Shuffle Required Objects
Used by the routine at InitialiseGame.
Changes the order in which the special objects have to be taken to the cauldron. The list of 0E objects at RequiredObjects is rotated by four to seven places, depending on the first random seed.
Work out how many times to rotate the list.
ShuffleRequiredObjects B544 LD A,($5BA0) Fetch RandomSeed1.
B547 AND %00000011 Keep the lowest two bits.
B549 OR %00000100 Make it four to seven.
B54B LD C,A Use it as the number of times to rotate the list.
Rotate the list one place.
ShuffleRequiredObjects_Loop B54C LD B,$0D Set the number of objects to move.
B54E LD IY,$C27D Point IY at RequiredObjects.
B552 LD E,(IY+$00) Keep the first object in E.
ShuffleRequiredObjects_Move B555 LD A,(IY+$01) Fetch the next object in the list.
B558 LD (IY+$00),A Store it one place earlier.
B55B INC IY Move on to the next object.
B55D DJNZ ShuffleRequiredObjects_Move Decrease the object counter and loop back to ShuffleRequiredObjects_Move until all of them have moved.
B55F LD (IY+$00),E Put the first object at the end of the list.
B562 DEC C Decrease the rotation counter and loop back to ShuffleRequiredObjects_Loop until the list has been rotated enough.
B563 JR NZ,ShuffleRequiredObjects_Loop
B565 RET Return.
Prev: B538 Up: Map Next: B566