![]() |
Routines |
Prev: 25764 | Up: Map | Next: 25853 |
Used by the routine at InitialiseLevel.
|
|||||||||||||||||||||||||||||||
Search the level buffer for special terrain markers (50) and replace with objects/ terrain.
|
|||||||||||||||||||||||||||||||
ObjectPlacement_SpecialTerrain | 25770 | LD HL,40448 | Load HL with LevelBuffer. | ||||||||||||||||||||||||||||
25773 | LD BC,2560 | Set the length of the level buffer in BC (2560 bytes). | |||||||||||||||||||||||||||||
ObjectPlacement_SpecialTerrain_Loop | 25776 | LD A,50 | Search for the next 50 marker in the level buffer. | ||||||||||||||||||||||||||||
25778 | CPIR | ||||||||||||||||||||||||||||||
25780 | LD A,B | Return if no more markers were found. | |||||||||||||||||||||||||||||
25781 | OR C | ||||||||||||||||||||||||||||||
25782 | RET Z | ||||||||||||||||||||||||||||||
A marker was found.
|
|||||||||||||||||||||||||||||||
25783 | PUSH HL | Stash the level buffer position and buffer counter on the stack. | |||||||||||||||||||||||||||||
25784 | PUSH BC | ||||||||||||||||||||||||||||||
25785 | XOR A | Clear A. | |||||||||||||||||||||||||||||
25786 | NOP | No operation. | |||||||||||||||||||||||||||||
25787 | NOP | ||||||||||||||||||||||||||||||
25788 | LD B,4 | Set a counter in B for 4 bytes to process. | |||||||||||||||||||||||||||||
25790 | LD E,A | E=A. | |||||||||||||||||||||||||||||
25791 | DEC L | Decrease L by one. | |||||||||||||||||||||||||||||
Determine what to place based on a random number.
|
|||||||||||||||||||||||||||||||
25792 | CALL GetRandomNumber | Call GetRandomNumber. | |||||||||||||||||||||||||||||
25795 | AND %00000111 | A=random number between 0 and 7. | |||||||||||||||||||||||||||||
25797 | CP E | Jump to PlaceSimpleTerrain_Loop if A is lower than E. | |||||||||||||||||||||||||||||
25798 | JR C,PlaceSimpleTerrain_Loop | ||||||||||||||||||||||||||||||
Generate terrain/ object from the data table.
This part of the routine takes a random number between 0-7 and uses it to fetch terrain data:
|
|||||||||||||||||||||||||||||||
25800 | CALL ContextualRandomNumber | Call ContextualRandomNumber. | |||||||||||||||||||||||||||||
25803 | AND %00000111 | Ensure the random number is between 0-7. | |||||||||||||||||||||||||||||
Calculate the low-byte of the object data table address.
|
|||||||||||||||||||||||||||||||
25805 | ADD A,A | E=(A*6)+108. | |||||||||||||||||||||||||||||
25806 | LD E,A | ||||||||||||||||||||||||||||||
25807 | ADD A,A | ||||||||||||||||||||||||||||||
25808 | ADD A,E | ||||||||||||||||||||||||||||||
25809 | ADD A,108 | ||||||||||||||||||||||||||||||
25811 | LD E,A | ||||||||||||||||||||||||||||||
25812 | LD D,180 | Set the high-byte in D to 180. | |||||||||||||||||||||||||||||
Copy a byte of the 4 bytes of object data into the level buffer.
|
|||||||||||||||||||||||||||||||
PlaceObjectData | 25814 | LD A,(DE) | Fetch an object data byte. | ||||||||||||||||||||||||||||
25815 | LD (HL),A | Write the object data byte into the level buffer. | |||||||||||||||||||||||||||||
25816 | INC E | Move to the next object data byte. | |||||||||||||||||||||||||||||
25817 | INC L | Move to the next position in the level buffer. | |||||||||||||||||||||||||||||
25818 | DJNZ PlaceObjectData | Decrease the byte counter by one and loop back to PlaceObjectData until all the object data bytes have been written into the level buffer. | |||||||||||||||||||||||||||||
Check if the object has a vertical component.
|
|||||||||||||||||||||||||||||||
25820 | LD A,(DE) | Jump to ObjectPlacement_SpecialTerrain_Next if the current data byte is zero (no vertical component). | |||||||||||||||||||||||||||||
25821 | AND A | ||||||||||||||||||||||||||||||
25822 | JR Z,ObjectPlacement_SpecialTerrain_Next | ||||||||||||||||||||||||||||||
Place the vertical component of the object.
|
|||||||||||||||||||||||||||||||
25824 | DEC L | Decrease L by three. | |||||||||||||||||||||||||||||
25825 | DEC L | ||||||||||||||||||||||||||||||
25826 | DEC L | ||||||||||||||||||||||||||||||
25827 | INC H | Increment H by one. | |||||||||||||||||||||||||||||
25828 | LD B,2 | B=2. | |||||||||||||||||||||||||||||
PlaceVerticalComponent | 25830 | LD A,(HL) | A=*HL. | ||||||||||||||||||||||||||||
25831 | AND A | Set flags. | |||||||||||||||||||||||||||||
25832 | LD A,(DE) | A=*DE. | |||||||||||||||||||||||||||||
25833 | JR Z,PlaceVerticalByte | Jump to PlaceVerticalByte if *HL is zero. | |||||||||||||||||||||||||||||
25835 | INC A | Increment A by two. | |||||||||||||||||||||||||||||
25836 | INC A | ||||||||||||||||||||||||||||||
PlaceVerticalByte | 25837 | LD (HL),A | Write A to *HL. | ||||||||||||||||||||||||||||
25838 | INC L | Increment L by one. | |||||||||||||||||||||||||||||
25839 | INC E | Increment E by one. | |||||||||||||||||||||||||||||
25840 | DJNZ PlaceVerticalComponent | Decrease counter by one and loop back to PlaceVerticalComponent until counter is zero. | |||||||||||||||||||||||||||||
25842 | JR ObjectPlacement_SpecialTerrain_Next | Jump to ObjectPlacement_SpecialTerrain_Next. | |||||||||||||||||||||||||||||
Place a simple terrain block (block type: 1).
|
|||||||||||||||||||||||||||||||
PlaceSimpleTerrain_Loop | 25844 | LD (HL),1 | Write block type 1 to the level buffer pointer. | ||||||||||||||||||||||||||||
25846 | INC L | Move to the next buffer position. | |||||||||||||||||||||||||||||
25847 | DJNZ PlaceSimpleTerrain_Loop | Decrease the byte counter by one and loop back to PlaceSimpleTerrain_Loop until all bytes have been written into the buffer. | |||||||||||||||||||||||||||||
Continue searching for the next terrain markers.
|
|||||||||||||||||||||||||||||||
ObjectPlacement_SpecialTerrain_Next | 25849 | POP BC | Restore the buffer counter and level buffer position from the stack. | ||||||||||||||||||||||||||||
25850 | POP HL | ||||||||||||||||||||||||||||||
25851 | JR ObjectPlacement_SpecialTerrain_Loop | Jump to ObjectPlacement_SpecialTerrain_Loop. |
Prev: 25764 | Up: Map | Next: 25853 |