// ==== fdb2de FUN_fdb2de

byte __jsl FUN_fdb2de(void)

{
  byte bVar1;
  ushort uVar2;
  ushort uVar3;
  
  bVar1 = DAT_7e2989;
  if ((DAT_7e2989 & 0x20) != 0) {
    FUN_fdb33f();
    uVar2 = *(ushort *)(&DAT_fdb99c + (byte)(DAT_7e29ac << 1));
    uVar3 = 0;
    do {
      (&uk__pc__stats[0].power)[uVar3] = 0x23;
      (&uk__pc__stats[0].magic)[uVar3] = 0x23;
      (&uk__pc__stats[0].stamina)[uVar3] = 0x80;
      *(undefined2 *)((int3)&uk__pc__stats[0].hp + (uint3)uVar3) =
           *(undefined2 *)(&DAT_fd0000 + uVar2);
      *(undefined2 *)((int3)&uk__pc__stats[0].hp_max + (uint3)uVar3) =
           *(undefined2 *)(&DAT_fd0000 + (ushort)(uVar2 + 2));
      *(undefined2 *)((int3)&uk__pc__stats[0].mp + (uint3)uVar3) =
           *(undefined2 *)(&DAT_fd0000 + (ushort)(uVar2 + 4));
      *(undefined2 *)((int3)&uk__pc__stats[0].mp_max + (uint3)uVar3) =
           *(undefined2 *)(&DAT_fd0000 + (ushort)(uVar2 + 6));
      uVar3 = uVar3 + 0x50;
      uVar2 = uVar2 + 8;
      bVar1 = 0;
    } while (uVar3 < 0x280);
  }
  return bVar1;
}


// ==== c0ea63 nmi__c0ea63

/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* NMI handler. Installed into the $00:0500 JML stub by C0:0B64 ($0501=$EA63, $0503=$C0). */

void __rti nmi__c0ea63(void)

{
  undefined1 uVar1;
  char cVar2;
  ushort uVar3;
  
  uVar1 = RDNMI;
  HDMAEN = 0;
  NMITIMEN = 0xa1;
  BGMODE = 9;
  if (DAT_7e0152 == '\0') goto LAB_c0ec15;
  if (DAT_7e0147 == 0) {
    if (DAT_7e0146 != 0) {
      if (DAT_7e0146 == 1) {
        _DAT_7e0148 = _DAT_7e1d7c;
        FUN_c07f62();
        DAT_7e0146 = 0;
        DAT_7f14f0 = DAT_7e1d7d | 1;
        FUN_fdc1ee();
        DAT_7e0152 = '\0';
        goto LAB_c0ec15;
      }
      if (DAT_7e0146 == 2) {
        _DAT_7e0148 = _DAT_7e1d7e;
        FUN_c07f62();
        DAT_7e0146 = 0;
        DAT_7f14f0 = DAT_7e1d7d | 1;
        FUN_fdc1ee();
        DAT_7e0152 = '\0';
        goto LAB_c0ec15;
      }
      if (DAT_7e0146 == 3) {
        _DAT_7e0148 = _DAT_7e1d82;
        FUN_c07f62();
        DAT_7e0146 = 0;
        FUN_fdc1ee();
        DAT_7e0152 = '\0';
        goto LAB_c0ec15;
      }
      if (DAT_7e0146 == 4) {
        _DAT_7e0148 = _DAT_7e1d80;
        FUN_c07f62();
        DAT_7e0146 = 0;
        FUN_fdc1ee();
        DAT_7e0152 = '\0';
        goto LAB_c0ec15;
      }
      if ((DAT_7e0146 & 8) != 0) {
        FUN_c07f5d();
        DAT_7e0146 = DAT_7e0146 & 0xf7;
        FUN_fdc1ee();
        DAT_7e0152 = '\0';
        goto LAB_c0ec15;
      }
      if ((DAT_7e0146 & 0x10) != 0) {
        FUN_c07f58();
        DAT_7e0146 = DAT_7e0146 & 0xef;
        FUN_fdc1ee();
        DAT_7e0152 = '\0';
        goto LAB_c0ec15;
      }
      if ((DAT_7e0146 & 0x20) != 0) {
        FUN_c0ec77(0);
        DAT_7e0146 = DAT_7e0146 & 0xdf;
      }
    }
    if (DAT_7e0136 != '\0') {
      if (DAT_7e0136 < '\0') {
        DAT_7e0136 = '\0';
      }
      FUN_c06ecb();
    }
  }
  else if ((DAT_7e0147 & 1) == 0) {
    if ((DAT_7e0147 & 2) == 0) {
      if ((DAT_7e0147 & 4) == 0) {
        if ((DAT_7e0147 & 8) != 0) {
          DAT_7e0147 = DAT_7e0147 & 0xf7;
          FUN_c06f5e();
        }
      }
      else {
        DAT_7e0147 = DAT_7e0147 & 0xfb;
        FUN_c06e5c();
      }
    }
    else {
      DAT_7e0147 = DAT_7e0147 & 0xfd;
      FUN_c06ef1();
    }
  }
  else {
    DAT_7e0147 = DAT_7e0147 & 0xfe;
    FUN_c06eb0();
  }
  FUN_c0712e();
  FUN_c0eca3();
  FUN_c0b1b2();
  uVar3 = CONCAT11(0x1d,DAT_7e1d78);
  if ((_DAT_7e1d78 & 1) != 0) {
    FUN_c08445();
    uVar3 = _DAT_7e1d78 & 0xff;
  }
  if ((uVar3 & 2) != 0) {
    FUN_c084c1();
    uVar3 = _DAT_7e1d78 & 0xff;
  }
  if ((uVar3 & 4) != 0) {
    FUN_c08523();
  }
  if ((_DAT_7e1d78 & 0x100) != 0) {
    FUN_c08585();
  }
  uVar3 = (ushort)DAT_7e1d79;
  if ((DAT_7e1d79 & 2) != 0) {
    FUN_c085e7();
    uVar3 = _DAT_7e1d78 >> 8;
  }
  if ((uVar3 & 4) != 0) {
    FUN_c08649();
  }
  if ((_DAT_7e1d7a & 1) != 0) {
    FUN_c086ab();
  }
  if ((_DAT_7e1d7a & 2) != 0) {
    FUN_c086f7();
  }
  if ((_DAT_7e1d7a & 4) != 0) {
    FUN_c08729();
  }
  if ((_DAT_7e1d7a & 0x100) != 0) {
    FUN_c0875b();
  }
  uVar3 = (ushort)DAT_7e1d7b;
  if ((DAT_7e1d7b & 2) != 0) {
    FUN_c0878d();
    uVar3 = _DAT_7e1d7a >> 8;
  }
  if ((uVar3 & 4) != 0) {
    FUN_c087bf();
  }
  _DAT_7e1d78 = 0;
  _DAT_7e1d7a = 0;
  FUN_fdc1ee(0x100);
  DAT_7e0152 = '\0';
LAB_c0ec15:
  thunk_FUN_c28006();
  W12SEL = DAT_7e0bd9;
  W34SEL = DAT_7e0bda;
  WOBJSEL = DAT_7e0bdb;
  WH2 = DAT_7e0bdc;
  WH3 = DAT_7e0bdd;
  CGWSEL = DAT_7e0bde;
  COLDATA = 0xe0;
  COLDATA = DAT_7e0121;
  HDMAEN = DAT_7e0128;
  cVar2 = DAT_7e0119;
  if (DAT_7e0119 == '\0') {
    cVar2 = -0x80;
  }
  INIDISP = cVar2;
  return;
}


// ==== c25f13 FUN_c25f13

/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */

void FUN_c25f13(void)

{
  ushort uVar1;
  ushort uVar2;
  bool bVar3;
  
  uVar1 = _DAT_7e026e;
  if ((DAT_7e0262 & 1) == 0) {
    uVar2 = CONCAT11(*(undefined1 *)(_DAT_7e0276 + (uint3)_DAT_7e0260),
                     *(undefined1 *)(_DAT_7e0279 + (uint3)_DAT_7e0260)) & 0xfff0;
  }
  else {
    uVar2 = CONCAT11(*(undefined1 *)(_DAT_7e0276 + (uint3)_DAT_7e0260),
                     *(char *)(_DAT_7e0279 + (uint3)_DAT_7e0260) << 4);
  }
  _DAT_7e0263 = 0;
                    /* WARNING: Switch is manually overridden */
  switch(_DAT_7e026a & 0xff) {
  case 0:
    *(char *)(_DAT_7e0273 + (uint3)*(ushort *)(&DAT_c26021 + _DAT_7e026e)) = (char)uVar2;
    *(char *)(_DAT_7e0273 + (uint3)*(ushort *)(&DAT_c2601f + uVar1)) = (char)(uVar2 >> 8);
    return;
  case 4:
    uVar2 = uVar2 >> 1;
  case 3:
    uVar2 = uVar2 >> 1;
  case 2:
    uVar2 = uVar2 >> 1;
  case 1:
    *(char *)(_DAT_7e0273 + (uint3)*(ushort *)(&DAT_c26021 + _DAT_7e026e)) = (char)(uVar2 >> 1);
    *(byte *)(_DAT_7e0273 + (uint3)*(ushort *)(&DAT_c2601f + uVar1)) =
         (byte)(uVar2 >> 9) | *(byte *)(_DAT_7e0273 + (uint3)*(ushort *)(&DAT_c2601f + uVar1));
    return;
  case 5:
    bVar3 = (short)uVar2 < 0;
    uVar2 = uVar2 << 1;
    _DAT_7e0263 = (ushort)bVar3;
  case 6:
    bVar3 = (short)uVar2 < 0;
    uVar2 = uVar2 << 1;
    _DAT_7e0263 = _DAT_7e0263 << 1 | (ushort)bVar3;
  case 7:
    _DAT_7e0263 = _DAT_7e0263 << 1 | (ushort)((short)uVar2 < 0);
    *(char *)(_DAT_7e0273 + (uint3)*(ushort *)(&DAT_c26023 + _DAT_7e026e)) = (char)(uVar2 << 1);
    *(char *)(_DAT_7e0273 + (uint3)*(ushort *)(&DAT_c26021 + uVar1)) =
         (char)((ushort)(uVar2 << 1) >> 8);
    *(byte *)(_DAT_7e0273 + (uint3)*(ushort *)(&DAT_c2601f + uVar1)) =
         DAT_7e0263 | *(byte *)(_DAT_7e0273 + (uint3)*(ushort *)(&DAT_c2601f + uVar1));
    return;
  }
}


// ==== 00ff00 reset__vector_stub

/* Emulation-mode RESET vector target ($00:FFFC=$FF00): SEI/CLC/XCE then JML $FD:C000. */

void reset__vector_stub(void)

{
  reset__entry();
  return;
}


