![]() |
Routines |
| Prev: CB89 | Up: Map | Next: CC09 |
|
Used by the routine at START.
Once a turn, from the main loop. When DROP_TIMER runs out it stays at 1, so from then on there is a one-in-four chance each turn (two bits of RANDOM). A drop resets the timer (RESET_DROP_TIMER) whether or not it comes to anything, then takes a free one of the two records at FLYERS, copies FLYER_TEMPLATE into it, and gives it a U and a V at random and one of the eight graphics at DROP_GRAPHICS. If the new thing overlaps anything already in the room it is taken away again.
The random U and V are 104 plus a number masked with $2F: 104 to 119 or 136 to 151, never within 8 of the room's middle line. It falls from Z 216.
|
||||
| SKY_DROP | CBAB | LD A,(DROP_BAN) | Nothing falls in this room | |
| CBAE | AND A | |||
| CBAF | RET NZ | |||
| CBB0 | LD HL,DROP_TIMER | Count the timer down | ||
| CBB3 | DEC (HL) | |||
| CBB4 | RET NZ | |||
| CBB5 | LD (HL),$01 | Then try every turn | ||
| CBB7 | LD A,(RANDOM) | One chance in four | ||
| CBBA | AND $03 | |||
| CBBC | RET NZ | |||
| CBBD | CALL RESET_DROP_TIMER | The timer starts again | ||
| CBC0 | LD HL,FLYERS | The first of the two records, and the template | ||
| CBC3 | LD BC,$0020 | |||
| CBC6 | LD DE,FLYER_TEMPLATE | |||
| CBC9 | LD A,(HL) | Both in use: nothing falls | ||
| CBCA | AND A | |||
| CBCB | JR Z,SKY_DROP_0 | |||
| CBCD | ADD HL,BC | |||
| CBCE | LD A,(HL) | |||
| CBCF | AND A | |||
| CBD0 | RET NZ | |||
| SKY_DROP_0 | CBD1 | EX DE,HL | IX = the free record, filled from the template | |
| CBD2 | PUSH HL | |||
| CBD3 | POP IX | |||
| CBD5 | LDIR | |||
| CBD7 | LD A,(RANDOM) | U at random | ||
| CBDA | AND $2F | |||
| CBDC | ADD A,$68 | |||
| CBDE | LD (IX+$01),A | |||
| CBE1 | LD A,R | V from the refresh register | ||
| CBE3 | AND $2F | |||
| CBE5 | ADD A,$68 | |||
| CBE7 | LD (IX+$02),A | |||
| CBEA | LD A,(RANDOM) | One of the eight graphics, by bits 3-5 of the random number | ||
| CBED | RRA | |||
| CBEE | RRA | |||
| CBEF | RRA | |||
| CBF0 | AND $07 | |||
| CBF2 | LD L,A | |||
| CBF3 | LD H,$00 | |||
| CBF5 | LD DE,DROP_GRAPHICS | |||
| CBF8 | ADD HL,DE | |||
| CBF9 | LD A,(HL) | |||
| CBFA | LD (IX+$00),A | |||
| CBFD | CALL CALC_PIXEL_XY | Its place on the screen (CALC_PIXEL_XY) | ||
| CC00 | CALL DO_ANY_OBJS_INTERSECT | Nothing in the way: it falls (DO_ANY_OBJS_INTERSECT) | ||
| CC03 | RET NC | |||
| CC04 | LD (IX+$00),$00 | Something there: no drop after all | ||
| CC08 | RET | |||
| Prev: CB89 | Up: Map | Next: CC09 |