Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Ancilla_CheckForAvailableSlot:
- {
- SLOT = $0C4A
- ancilla_type = A
- arg_num_ancilla = Y ; num allowed - 1
- ; 1. Make sure number of same-type ancillae in slot 0-4 is not equal the limit
- ; Note, this ignores slot 5-9
- {
- for (y = 0, x = 4; x >= 0; --x) {
- if (SLOT[x] == 0) {
- y += 1;
- }
- }
- if (y == (arg_num_ancilla + 1)) {
- return -1;
- }
- }
- ; 2. Define slot range
- ; Bombs & some wall rock thing can only be put in slot 0-1.
- ; Anything else can be put in 0-4.
- {
- if (ancilla_type in [Bomb, WallExplosionRock]) {
- y = 1
- } else {
- y = 4
- }
- }
- ; 3. Search slot range for open spot
- ; If a slot between 0-1 or 0-4 is empty, return it
- {
- for (; y >= 0; --y) {
- if (SLOT[y] == 0) {
- return y
- }
- }
- }
- ; 4. Wider search.
- ; It's supposed to remove unimportant things (sparks, wall arrows) in place of the new ancilla in the
- ; case where there's no slot open.
- ; Note that 03C4 persists. It's set to 6 after revival from fairy, which means it's possible to get
- ; a bomb, somaria, arrow etc. in slot 5, which is outside of the normal range.
- {
- if (03C4 < 0) {
- 03C4 = arg_num_ancilla
- }
- for (; 03C4 >= 0; --03C4) {
- if (SLOT[03C4] in [SwordChargeSpark, IceRodSpark, WallArrow]) {
- return 03C4
- }
- }
- }
- ; We found no slots anywhere.
- return -1
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement