![]() |
Routines |
| Prev: C7D1 | Up: Map | Next: C847 |
|
Puts a type 04 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 | C7E8 | LD A,($A216) | Fetch FrameCounter. | |
| C7EB | AND %00000011 | Keep the lowest two bits. | ||
| C7ED | RET NZ | Return unless this is every fourth frame. | ||
|
Look for a free slot among the first three.
|
||||
| C7EE | LD HL,$A27D | Point HL at ObjectSlot_01. | ||
| C7F1 | LD DE,$0010 | Set the size of an object slot in DE. | ||
| C7F4 | LD B,$03 | Set a count of 03. | ||
| MakeBag_FindSlot | C7F6 | LD A,(HL) | Jump to MakeBag_FillSlot if the slot is free. | |
| C7F7 | AND A | |||
| C7F8 | JR Z,MakeBag_FillSlot | |||
| C7FA | ADD HL,DE | Move on to the next slot. | ||
| C7FB | DJNZ MakeBag_FindSlot | Jump to MakeBag_FindSlot until all three have been tried. | ||
| C7FD | RET | Return. | ||
|
Copy BagTemplate into the slot.
|
||||
| MakeBag_FillSlot | C7FE | PUSH HL | Copy HL to IY (using the stack). | |
| C7FF | POP IY | |||
| C801 | EX DE,HL | Point DE at the slot and set BC to its size. | ||
| C802 | LD C,L | |||
| C803 | LD B,H | |||
| C804 | LD HL,$C847 | Point HL at BagTemplate. | ||
| C807 | LDIR | Copy the template into the slot. | ||
|
Work out the sideways speed.
|
||||
| C809 | LD A,($A261) | Set BC to Skill. | ||
| C80C | LD C,A | |||
| C80D | LD B,$00 | |||
| C80F | LD HL,$C85B | Point HL at the BagSpeeds entry for Skill. | ||
| C812 | ADD HL,BC | |||
| C813 | LD C,(HL) | Fetch the bound for this skill. | ||
| C814 | LD A,($A218) | Fetch FirstRandomNumber and keep it in B. | ||
| C817 | LD B,A | |||
| C818 | AND %01111111 | Keep the lowest seven bits. | ||
| C81A | ADD A,$08 | Add 08. | ||
| C81C | CALL ReduceNumber | Call ReduceNumber. | ||
| C81F | BIT 7,B | Jump to MakeBag_SetSpeeds if bit 7 of the random number is not set. | ||
| C821 | JR Z,MakeBag_SetSpeeds | |||
| C823 | NEG | Make the sideways speed negative. | ||
| MakeBag_SetSpeeds | C825 | LD (IY+$0A),A | Set the sideways speed. | |
|
Work out the downward speed.
|
||||
| C828 | LD A,($A219) | Fetch A219. | ||
| C82B | AND %00001111 | Keep the lowest four bits. | ||
| C82D | SLA C | Double the bound. | ||
| C82F | ADD A,C | Add it. | ||
| C830 | NEG | Make it negative. | ||
| C832 | LD (IY+$0B),A | Set the downward speed. | ||
|
Set the horizontal start and take one from TargetsLeft.
|
||||
| C835 | LD A,($A21A) | Fetch SecondRandomNumber. | ||
| C838 | AND %01111111 | Keep the lowest seven bits. | ||
| C83A | ADD A,$40 | Add 40. | ||
| C83C | LD (IY+$02),A | Set the horizontal position. | ||
| C83F | LD A,($A264) | Take one from TargetsLeft and return. | ||
| C842 | DEC A | |||
| C843 | LD ($A264),A | |||
| C846 | RET | |||
| Prev: C7D1 | Up: Map | Next: C847 |