SHARE
TWEET

Ancilla_CheckForAvailableSlot

LilPinkus Jun 19th, 2019 175 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Ancilla_CheckForAvailableSlot:
  2. {
  3.     SLOT = $0C4A
  4.     ancilla_type = A
  5.     arg_num_ancilla = Y ; num allowed - 1
  6.  
  7.     ; 1. Make sure number of same-type ancillae in slot 0-4 is not equal the limit
  8.     ; Note, this ignores slot 5-9
  9.     {
  10.         for (y = 0, x = 4; x >= 0; --x) {
  11.             if (SLOT[x] == 0) {
  12.                 y += 1;
  13.             }
  14.         }
  15.  
  16.         if (y == (arg_num_ancilla + 1)) {
  17.             return -1;
  18.         }
  19.     }
  20.    
  21.     ; 2. Define slot range
  22.     ; Bombs & some wall rock thing can only be put in slot 0-1.
  23.     ; Anything else can be put in 0-4.
  24.     {
  25.         if (ancilla_type in [Bomb, WallExplosionRock]) {
  26.             y = 1
  27.         } else {
  28.             y = 4
  29.         }
  30.     }
  31.    
  32.     ; 3. Search slot range for open spot
  33.     ; If a slot between 0-1 or 0-4 is empty, return it
  34.     {
  35.         for (; y >= 0; --y) {
  36.             if (SLOT[y] == 0) {
  37.                 return y
  38.             }
  39.         }
  40.     }
  41.  
  42.     ; 4. Wider search.
  43.     ; It's supposed to remove unimportant things (sparks, wall arrows) in place of the new ancilla in the
  44.     ; case where there's no slot open.
  45.     ; Note that 03C4 persists. It's set to 6 after revival from fairy, which means it's possible to get
  46.     ; a bomb, somaria, arrow etc. in slot 5, which is outside of the normal range.
  47.     {
  48.         if (03C4 < 0) {
  49.             03C4 = arg_num_ancilla
  50.         }
  51.  
  52.         for (; 03C4 >= 0; --03C4) {
  53.             if (SLOT[03C4] in [SwordChargeSpark, IceRodSpark, WallArrow]) {
  54.                 return 03C4
  55.             }
  56.         }
  57.     }
  58.  
  59.     ; We found no slots anywhere.
  60.     return -1
  61. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top