Prev: C965 Up: Map Next: C9CA
C978: Generate train parts: front, middle or rear wagon
Used by the routines at 947A and A915.
C978 LD A,($A045) Return if not generating train in current room
C97B OR A
C97C RET Z
C97D LD A,($A048) Decrement train appareance counter
C980 DEC A
C981 LD ($A048),A
C984 OR A Return if counter is not zero
C985 RET NZ
C986 LD HL,$5E72 Set HL to the base address for entity definition - visibility of entity
C989 LD A,($A092) Set B to the max number of entities on screen
C98C LD B,A
C98D LD A,(HL) if entity not visible jump configure the new train-part (front, rear or wagon)
C98E OR A
C98F JP Z,$C99D
C992 LD DE,$0018 Increment to the next slot for entity definition and jump back
C995 ADD HL,DE
C996 DJNZ $C98D
C998 XOR A Stop generating the train if no slots available
C999 LD ($A045),A
C99C RET
Generate a new train part
C99D LD DE,$000C Point HL to the base address of the corresponent entity configuration
C9A0 AND A
C9A1 SBC HL,DE
C9A3 PUSH HL Save HL
C9A4 POP IX Restore IX
C9A6 LD IY,($A046) Set A to the entity type for the wagon
C9AA LD A,(IY+$00)
C9AD CP $FF if end of train jump forward and stop generating train parts
C9AF JP Z,$C9C5
C9B2 CALL $CB88 Configure entity type wagon
C9B5 LD A,(IY+$03) Set A048 to the next train appearance counter
C9B8 LD ($A048),A
C9BB LD DE,$0004 Point A046 to the address for the next train wagon
C9BE ADD IY,DE
C9C0 LD ($A046),IY
C9C4 RET
C9C5 XOR A Stop generating the train - no more wagons left
C9C6 LD ($A045),A
C9C9 RET
Prev: C965 Up: Map Next: C9CA