![]() |
Routines |
| Prev: 39229 | Up: Map | Next: 39367 |
|
Used by the routine at CreateRandomCreature.
Sets up an entity as one of four kinds of creature, using the templates at CreatureTemplates. The first level has only two kinds of creature and the second level has no kind 3.
|
||||||||||||
| SetUpCreature | 39263 | LD B,A | Copy the kind of creature into B. | |||||||||
| 39264 | LD A,(57055) | Fetch the number of the level from LevelNumber. | ||||||||||
| 39267 | AND A | Test it. | ||||||||||
| 39268 | JR NZ,SetUpCreature_Level | Jump to SetUpCreature_Level unless this is the first level. | ||||||||||
| 39270 | RES 1,B | Reset bit 1 of the kind, so that only the kinds 0 and 1 are used. | ||||||||||
| SetUpCreature_Level | 39272 | DEC A | Decrease the level by one. | |||||||||
| 39273 | JR NZ,SetUpCreature_Template | Jump to SetUpCreature_Template unless this is the second level. | ||||||||||
| 39275 | LD A,B | Fetch the kind of creature. | ||||||||||
| 39276 | CP 3 | Jump to SetUpCreature_Template unless it is 3. | ||||||||||
| 39278 | JR NZ,SetUpCreature_Template | |||||||||||
| 39280 | LD B,2 | Use the kind 2 instead. | ||||||||||
| SetUpCreature_Template | 39282 | LD A,B | Fetch the kind of creature. | |||||||||
| 39283 | ADD A,A | Multiply it by four... | ||||||||||
| 39284 | ADD A,A | |||||||||||
| 39285 | LD B,A | ...and keep it in B. | ||||||||||
| 39286 | ADD A,A | Multiply it by eight... | ||||||||||
| 39287 | ADD A,B | ...and add the four times to make twelve times the kind, the size of a template. | ||||||||||
| 39288 | LD HL,39367 | Point HL at CreatureTemplates. | ||||||||||
| 39291 | CALL AddToAddress | Add the offset of the kind to find its template. | ||||||||||
| 39294 | LD A,(HL) | Fetch the type of the creature. | ||||||||||
| 39295 | LD (IX+0),A | Set the type of the entity. | ||||||||||
| 39298 | INC HL | Move onto the next byte of the template. | ||||||||||
| 39299 | LD A,(HL) | Fetch the frame of the creature. | ||||||||||
| 39300 | LD (IX+1),A | Set field 1 of the entity. | ||||||||||
| 39303 | INC HL | Move onto the next byte of the template. | ||||||||||
| 39304 | LD A,(HL) | Fetch the third byte of the template. | ||||||||||
| 39305 | LD (IX+16),A | Set the speed. | ||||||||||
| 39308 | INC HL | Move onto the next byte of the template. | ||||||||||
| 39309 | LD A,(HL) | Fetch the fourth byte of the template. | ||||||||||
| 39310 | LD (IX+20),A | Set field 20 of the entity. | ||||||||||
| 39313 | INC HL | Move onto the next byte of the template. | ||||||||||
| 39314 | LD A,(HL) | Fetch the fifth byte of the template. | ||||||||||
| 39315 | LD (IX+21),A | Set field 21 of the entity. | ||||||||||
| 39318 | INC HL | Move onto the next byte of the template. | ||||||||||
| 39319 | LD A,(HL) | Fetch the sixth byte of the template. | ||||||||||
| 39320 | LD (IX+28),A | Set field 28 of the entity. | ||||||||||
| 39323 | INC HL | Move onto the next byte of the template. | ||||||||||
| 39324 | LD A,(HL) | Fetch the seventh byte of the template. | ||||||||||
| 39325 | LD (IX+29),A | Set field 29 of the entity. | ||||||||||
| 39328 | INC HL | Move onto the next byte of the template. | ||||||||||
| 39329 | LD A,(HL) | Fetch the eighth byte of the template. | ||||||||||
| 39330 | LD (IX+35),A | Set field 35 of the entity. | ||||||||||
| 39333 | INC HL | Move onto the next byte of the template. | ||||||||||
| 39334 | LD A,(HL) | Fetch the ninth byte of the template. | ||||||||||
| 39335 | LD (IX+11),A | Set the x extent. | ||||||||||
| 39338 | INC HL | Move onto the next byte of the template. | ||||||||||
| 39339 | LD A,(HL) | Fetch the tenth byte of the template. | ||||||||||
| 39340 | LD (IX+12),A | Set the y extent. | ||||||||||
| 39343 | INC HL | Move onto the next byte of the template. | ||||||||||
| 39344 | LD A,(HL) | Fetch the eleventh byte of the template. | ||||||||||
| 39345 | LD (IX+13),A | Set the z extent. | ||||||||||
| 39348 | INC HL | Move onto the next byte of the template. | ||||||||||
| 39349 | LD A,(HL) | Fetch the twelfth byte of the template. | ||||||||||
| 39350 | LD (IX+27),A | Set field 27 of the entity. | ||||||||||
| 39353 | LD (IX+19),0 | Set field 19 of the entity to 0. | ||||||||||
| 39357 | LD A,(24475) | Fetch the random number from 24475. | ||||||||||
| 39360 | AND C | Mask it with the heading mask. | ||||||||||
| 39361 | LD (IX+17),A | Set the heading. | ||||||||||
| 39364 | JP SetEntitySize | Jump to SetEntitySize to set the sprite of the entity. | ||||||||||
| Prev: 39229 | Up: Map | Next: 39367 |