gbJoymask = 0;
gbJoymask[0] = gbJoymask[1] = gbJoymask[2] = gbJoymask[3] = 0;
void gbReset(){  SP.W = 0xfffe;  AF.W = 0x01b0;  BC.W = 0x0013;  DE.W = 0x00d8;  HL.W = 0x014d;  PC.W = 0x0100;  IFF = 0;  gbInterrupt = 1;  gbInterruptWait = 0;    register_DIV = 0;  register_TIMA = 0;  register_TMA = 0;  register_TAC = 0;  register_IF = 1;  register_LCDC = 0x91;  register_STAT = 0;  register_SCY = 0;  register_SCX = 0;    register_LY = 0;    register_LYC = 0;  register_DMA = 0;  register_WY = 0;  register_WX = 0;  register_VBK = 0;  register_HDMA1 = 0;  register_HDMA2 = 0;  register_HDMA3 = 0;  register_HDMA4 = 0;  register_HDMA5 = 0;  register_SVBK = 0;  register_IE = 0;    if(gbCgbMode) {    if(gbSgbMode) {      if(gbEmulatorType == 5)        AF.W = 0xffb0;      else        AF.W = 0x01b0;      BC.W = 0x0013;      DE.W = 0x00d8;      HL.W = 0x014d;      for(int i = 0; i < 8; i++)        gbPalette[i] = systemGbPalette[gbPaletteOption*8+i];    } else {      AF.W = 0x11b0;      BC.W = 0x0000;      DE.W = 0xff56;      HL.W = 0x000d;    }    if(gbEmulatorType == 4)      BC.B.B1 |= 0x01;       register_HDMA5 = 0xff;    gbMemory[0xff68] = 0xc0;    gbMemory[0xff6a] = 0xc0;      } else {    for(int i = 0; i < 8; i++)      gbPalette[i] = systemGbPalette[gbPaletteOption*8+i];  }  if(gbSpeed) {    gbSpeedSwitch();    gbMemory[0xff4d] = 0;  }    gbDivTicks = GBDIV_CLOCK_TICKS;  gbLcdMode = 2;  gbLcdTicks = GBLCD_MODE_2_CLOCK_TICKS;  gbLcdLYIncrementTicks = 0;  gbTimerTicks = 0;  gbTimerClockTicks = 0;  gbSerialTicks = 0;  gbSerialBits = 0;  gbSerialOn = 0;  gbWindowLine = -1;  gbTimerOn = 0;  gbTimerMode = 0;  //  gbSynchronizeTicks = GBSYNCHRONIZE_CLOCK_TICKS;  gbSpeed = 0;  gbJoymask = 0;    if(gbCgbMode) {    gbSpeed = 0;    gbHdmaOn = 0;    gbHdmaSource = 0x0000;    gbHdmaDestination = 0x8000;    gbVramBank = 0;    gbWramBank = 1;    register_LY = 0x90;    gbLcdMode = 1;  }  if(gbSgbMode) {    gbSgbReset();  }  for(int i =0; i < 4; i++)    gbBgp[i] = gbObp0[i] = gbObp1[i] = i;  memset(&gbDataMBC1,0, sizeof(gbDataMBC1));  gbDataMBC1.mapperROMBank = 1;  gbDataMBC2.mapperRAMEnable = 0;  gbDataMBC2.mapperROMBank = 1;  memset(&gbDataMBC3,0, 6 * sizeof(int));  gbDataMBC3.mapperROMBank = 1;  memset(&gbDataMBC5, 0, sizeof(gbDataMBC5));  gbDataMBC5.mapperROMBank = 1;  memset(&gbDataHuC1, 0, sizeof(gbDataHuC1));  gbDataHuC1.mapperROMBank = 1;  memset(&gbDataHuC3, 0, sizeof(gbDataHuC3));  gbDataHuC3.mapperROMBank = 1;  gbMemoryMap[0x00] = &gbRom[0x0000];  gbMemoryMap[0x01] = &gbRom[0x1000];  gbMemoryMap[0x02] = &gbRom[0x2000];  gbMemoryMap[0x03] = &gbRom[0x3000];  gbMemoryMap[0x04] = &gbRom[0x4000];  gbMemoryMap[0x05] = &gbRom[0x5000];  gbMemoryMap[0x06] = &gbRom[0x6000];  gbMemoryMap[0x07] = &gbRom[0x7000];  if(gbCgbMode) {    gbMemoryMap[0x08] = &gbVram[0x0000];    gbMemoryMap[0x09] = &gbVram[0x1000];    gbMemoryMap[0x0a] = &gbMemory[0xa000];    gbMemoryMap[0x0b] = &gbMemory[0xb000];    gbMemoryMap[0x0c] = &gbMemory[0xc000];    gbMemoryMap[0x0d] = &gbWram[0x1000];    gbMemoryMap[0x0e] = &gbMemory[0xe000];    gbMemoryMap[0x0f] = &gbMemory[0xf000];          } else {    gbMemoryMap[0x08] = &gbMemory[0x8000];    gbMemoryMap[0x09] = &gbMemory[0x9000];    gbMemoryMap[0x0a] = &gbMemory[0xa000];    gbMemoryMap[0x0b] = &gbMemory[0xb000];    gbMemoryMap[0x0c] = &gbMemory[0xc000];    gbMemoryMap[0x0d] = &gbMemory[0xd000];    gbMemoryMap[0x0e] = &gbMemory[0xe000];    gbMemoryMap[0x0f] = &gbMemory[0xf000];      }  if(gbRam) {    gbMemoryMap[0x0a] = &gbRam[0x0000];    gbMemoryMap[0x0b] = &gbRam[0x1000];  }  gbSoundReset();  gbLastTime = systemGetClock();  gbFrameCount = 0;}