Dynamite Dan | Routines |
Prev: F3A2 | Up: Map | Next: F3D3 |
Used by the routine at F345.
|
||||||||
F3A4 | LD A,R | Load A with the memory refresh register R, which is pseudo-random. | ||||||
F3A6 | AND $3F | Store only the lower 6 bits. | ||||||
F3A8 | CP $30 | Loop until the value is less than or equal to 30 which is the number of rooms | ||||||
F3AA | JR NC,$F3A4 | |||||||
F3AC | LD C,A | Put this value in C. | ||||||
F3AD | LD A,C | Get the randomly generated value. | ||||||
F3AE | ADD A,$11 | Add 0B. | ||||||
F3B0 | CP $30 | If the value is now greater than 30 subtract 30 so the it cycles round from 00 - 30 and always holds a valid room. | ||||||
F3B2 | JR C,$F3B6 | |||||||
F3B4 | SUB $30 | |||||||
F3B6 | LD C,A | Store the new value. | ||||||
F3B7 | ADD A,A | Multiply the value by 4. and put it in HL. | ||||||
F3B8 | ADD A,A | |||||||
F3B9 | LD L,A | |||||||
F3BA | LD H,$00 | |||||||
F3BC | LD E,L | Multiply this by 4 to get an appropriate offset for a room. | ||||||
F3BD | LD D,H | |||||||
F3BE | ADD HL,HL | |||||||
F3BF | ADD HL,DE | |||||||
F3C0 | LD DE,($F3A2) | Get the base rooms object data pointer in DE. (F3A2) | ||||||
F3C4 | ADD HL,DE | Add the offset to get to the desired room. | ||||||
F3C5 | LD DE,($F3A0) | Get the base room's flags in DE. (F3A0) | ||||||
F3C9 | LD A,(HL) | Get the object flags. | ||||||
F3CA | AND D | If the room can't support this object type, discard this and pick another one. | ||||||
F3CB | JR NZ,$F3AD | |||||||
F3CD | LD A,(HL) | Get the object flags, and do a logical or against the allowed flags. | ||||||
F3CE | OR E | |||||||
F3CF | LD (HL),A | |||||||
F3D0 | DJNZ $F3AD | Loop until all the objects are done. | ||||||
F3D2 | RET |
Prev: F3A2 | Up: Map | Next: F3D3 |