![]() |
Routines |
| Prev: 51153 | Up: Map | Next: 51271 |
|
Puts a type 4 bag in the first free slot among ObjectSlot_01, ObjectSlot_02 and ObjectSlot_03. It does this on every fourth frame, copies BagTemplate, sets a random sideways speed from BagSpeeds and Skill, a random downward speed, and a random horizontal start. Then it takes one from TargetsLeft.
|
||||
|
Return unless it is time to make a bag.
|
||||
| MakeBag | 51176 | LD A,(41494) | Fetch FrameCounter. | |
| 51179 | AND %00000011 | Keep the lowest two bits. | ||
| 51181 | RET NZ | Return unless this is every fourth frame. | ||
|
Look for a free slot among the first three.
|
||||
| 51182 | LD HL,41597 | Point HL at ObjectSlot_01. | ||
| 51185 | LD DE,16 | Set the size of an object slot in DE. | ||
| 51188 | LD B,3 | Set a count of 3. | ||
| MakeBag_FindSlot | 51190 | LD A,(HL) | Jump to MakeBag_FillSlot if the slot is free. | |
| 51191 | AND A | |||
| 51192 | JR Z,MakeBag_FillSlot | |||
| 51194 | ADD HL,DE | Move on to the next slot. | ||
| 51195 | DJNZ MakeBag_FindSlot | Jump to MakeBag_FindSlot until all three have been tried. | ||
| 51197 | RET | Return. | ||
|
Copy BagTemplate into the slot.
|
||||
| MakeBag_FillSlot | 51198 | PUSH HL | Copy HL to IY (using the stack). | |
| 51199 | POP IY | |||
| 51201 | EX DE,HL | Point DE at the slot and set BC to its size. | ||
| 51202 | LD C,L | |||
| 51203 | LD B,H | |||
| 51204 | LD HL,51271 | Point HL at BagTemplate. | ||
| 51207 | LDIR | Copy the template into the slot. | ||
|
Work out the sideways speed.
|
||||
| 51209 | LD A,(41569) | Set BC to Skill. | ||
| 51212 | LD C,A | |||
| 51213 | LD B,0 | |||
| 51215 | LD HL,51291 | Point HL at the BagSpeeds entry for Skill. | ||
| 51218 | ADD HL,BC | |||
| 51219 | LD C,(HL) | Fetch the bound for this skill. | ||
| 51220 | LD A,(41496) | Fetch FirstRandomNumber and keep it in B. | ||
| 51223 | LD B,A | |||
| 51224 | AND %01111111 | Keep the lowest seven bits. | ||
| 51226 | ADD A,8 | Add 8. | ||
| 51228 | CALL ReduceNumber | Call ReduceNumber. | ||
| 51231 | BIT 7,B | Jump to MakeBag_SetSpeeds if bit 7 of the random number is not set. | ||
| 51233 | JR Z,MakeBag_SetSpeeds | |||
| 51235 | NEG | Make the sideways speed negative. | ||
| MakeBag_SetSpeeds | 51237 | LD (IY+10),A | Set the sideways speed. | |
|
Work out the downward speed.
|
||||
| 51240 | LD A,(41497) | Fetch 41497. | ||
| 51243 | AND %00001111 | Keep the lowest four bits. | ||
| 51245 | SLA C | Double the bound. | ||
| 51247 | ADD A,C | Add it. | ||
| 51248 | NEG | Make it negative. | ||
| 51250 | LD (IY+11),A | Set the downward speed. | ||
|
Set the horizontal start and take one from TargetsLeft.
|
||||
| 51253 | LD A,(41498) | Fetch SecondRandomNumber. | ||
| 51256 | AND %01111111 | Keep the lowest seven bits. | ||
| 51258 | ADD A,64 | Add 64. | ||
| 51260 | LD (IY+2),A | Set the horizontal position. | ||
| 51263 | LD A,(41572) | Take one from TargetsLeft and return. | ||
| 51266 | DEC A | |||
| 51267 | LD (41572),A | |||
| 51270 | RET | |||
| Prev: 51153 | Up: Map | Next: 51271 |