Prev: 38815 Up: Map Next: 38944
38830: Create Spawned Entity
Used by the routine at UpdateSpawnPoints.
Makes an entity from a spawn point, provided that the random number is odd. When it is created the spawn point is made to wait for 7 frames before it may create another entity. The entity which is made depends on its type: the code for types 0 8 and 14 is different.
Input
IX The free entity
IY The entry of the table of kinds (see SpawnKinds)
CreateSpawnedEntity 38830 CALL GetRandomNumber Call GetRandomNumber to get a random number.
38833 LD A,(24474) Fetch the low byte of the seed.
38836 AND %00000001 Keep only bit 0.
38838 JP Z,UpdateSpawnPoints_Next Jump to UpdateSpawnPoints_Next if it is zero, to leave this spawn point for now.
38841 CALL ClearEntity Call ClearEntity to clear the entity.
38844 LD A,(IY+3) Fetch the type from the kind.
38847 LD (IX+0),A Set the type of the entity.
38850 LD A,(IY+4) Fetch the first size from the kind.
38853 LD (IX+11),A Set the x extent.
38856 LD A,(IY+5) Fetch the second size from the kind.
38859 LD (IX+12),A Set the y extent.
38862 LD A,(IY+6) Fetch the third size from the kind.
38865 LD (IX+13),A Set the z extent.
38868 POP IY Restore the address of the spawn point from the stack.
38870 LD (IY+5),7 Set the delay of the spawn point to 7.
38874 LD A,(IY+0) Fetch the first byte of the position from the spawn point.
38877 LD (IX+3),A Set the low byte of the x coordinate.
38880 LD A,(IY+1) Fetch the second byte of the position from the spawn point.
38883 LD (IX+2),A Set the high byte of the x coordinate.
38886 LD A,(IY+2) Fetch the third byte of the position from the spawn point.
38889 LD (IX+6),A Set the low byte of the y coordinate.
38892 LD A,(IY+3) Fetch the fourth byte of the position from the spawn point.
38895 LD (IX+5),A Set the high byte of the y coordinate.
38898 LD A,(IY+4) Fetch the fifth byte of the position from the spawn point.
38901 LD (IX+9),A Set the middle byte of the z coordinate.
38904 LD (IX+8),1 Set the top byte of the z coordinate to 1.
38908 LD A,(IX+0) Fetch the type of the entity.
38911 AND A Test it.
38912 JR Z,CreateSpawnedEntity_Creature Jump to CreateSpawnedEntity_Creature if the type is 0.
38914 CP 8 Jump to CreateSpawnedEntity_GrowingBubble if the type is 8.
38916 JR Z,CreateSpawnedEntity_GrowingBubble
38918 CP 14 Jump to CreateShot if the type is 14.
38920 JR Z,CreateShot
38922 LD (IX+35),0 Set field 35 of the entity to 0.
38926 LD (IX+28),4 Set field 28 of the entity to 4.
38930 LD (IX+29),16 Set field 29 of the entity to 16.
38934 CALL SetEntitySize Call SetEntitySize to set the sprite of the entity.
38937 SET 4,(IX+22) Set bit 4 of field 22 of the entity.
38941 JP UpdateSpawnPoints_Advance Jump to UpdateSpawnPoints_Advance to go on to the next spawn point.
Prev: 38815 Up: Map Next: 38944