public function returnFromState($returnedFrom)
{
$address = 0;
$state = $returnedFrom->slice(0);
$this->ROM = $this->toTypedArray($state[$address++], false, false);
$this->inBootstrap = $state[$address++];
$this->registerA = $state[$address++];
$this->FZero = $state[$address++];
$this->FSubtract = $state[$address++];
$this->FHalfCarry = $state[$address++];
$this->FCarry = $state[$address++];
$this->registerB = $state[$address++];
$this->registerC = $state[$address++];
$this->registerD = $state[$address++];
$this->registerE = $state[$address++];
$this->registersHL = $state[$address++];
$this->stackPointer = $state[$address++];
$this->programCounter = $state[$address++];
$this->halt = $state[$address++];
$this->IME = $state[$address++];
$this->hdmaRunning = $state[$address++];
$this->CPUTicks = $state[$address++];
$this->multiplier = $state[$address++];
$this->memory = $this->toTypedArray($state[$address++], false, false);
$this->MBCRam = $this->toTypedArray($state[$address++], false, false);
$this->VRAM = $this->toTypedArray($state[$address++], false, false);
$this->currVRAMBank = $state[$address++];
$this->GBCMemory = $this->toTypedArray($state[$address++], false, false);
$this->MBC1Mode = $state[$address++];
$this->MBCRAMBanksEnabled = $state[$address++];
$this->currMBCRAMBank = $state[$address++];
$this->currMBCRAMBankPosition = $state[$address++];
$this->cGBC = $state[$address++];
$this->gbcRamBank = $state[$address++];
$this->gbcRamBankPosition = $state[$address++];
$this->ROMBank1offs = $state[$address++];
$this->currentROMBank = $state[$address++];
$this->cartridgeType = $state[$address++];
$this->name = $state[$address++];
$this->gameCode = $state[$address++];
$this->lcdController->modeSTAT = $state[$address++];
$this->lcdController->LYCMatchTriggerSTAT = $state[$address++];
$this->lcdController->mode2TriggerSTAT = $state[$address++];
$this->lcdController->mode1TriggerSTAT = $state[$address++];
$this->lcdController->mode0TriggerSTAT = $state[$address++];
$this->lcdController->LCDisOn = $state[$address++];
$this->gfxWindowY = $state[$address++];
$this->gfxWindowDisplay = $state[$address++];
$this->gfxSpriteShow = $state[$address++];
$this->gfxSpriteDouble = $state[$address++];
$this->gfxBackgroundY = $state[$address++];
$this->gfxBackgroundX = $state[$address++];
$this->TIMAEnabled = $state[$address++];
$this->DIVTicks = $state[$address++];
$this->LCDTicks = $state[$address++];
$this->timerTicks = $state[$address++];
$this->TACClocker = $state[$address++];
$this->untilEnable = $state[$address++];
$this->lastIteration = $state[$address++];
$this->cMBC1 = $state[$address++];
$this->cMBC2 = $state[$address++];
$this->cMBC3 = $state[$address++];
$this->cMBC5 = $state[$address++];
$this->cSRAM = $state[$address++];
$this->cMMMO1 = $state[$address++];
$this->cRUMBLE = $state[$address++];
$this->cCamera = $state[$address++];
$this->cTAMA5 = $state[$address++];
$this->cHuC3 = $state[$address++];
$this->cHuC1 = $state[$address++];
$this->drewBlank = $state[$address++];
$this->tileData = $state[$address++];
$this->frameBuffer = $this->toTypedArray($state[$address++], true, false);
$this->tileCount = $state[$address++];
$this->colorCount = $state[$address++];
$this->gbPalette = $state[$address++];
$this->gbcRawPalette = $state[$address++];
$this->gbcPalette = $state[$address++];
$this->transparentCutoff = $state[$address++];
$this->bgEnabled = $state[$address++];
$this->spritePriorityEnabled = $state[$address++];
$this->tileReadState = $this->toTypedArray($state[$address++], false, false);
$this->windowSourceLine = $state[$address++];
$this->lcdController->actualScanLine = $state[$address++];
$this->RTCisLatched = $state[$address++];
$this->latchedSeconds = $state[$address++];
$this->latchedMinutes = $state[$address++];
$this->latchedHours = $state[$address++];
$this->latchedLDays = $state[$address++];
$this->latchedHDays = $state[$address++];
$this->RTCSeconds = $state[$address++];
$this->RTCMinutes = $state[$address++];
$this->RTCHours = $state[$address++];
$this->RTCDays = $state[$address++];
$this->RTCDayOverFlow = $state[$address++];
$this->RTCHALT = $state[$address++];
$this->gbColorizedPalette = $state[$address++];
$this->skipPCIncrement = $state[$address++];
$this->lcdController->STATTracker = $state[$address++];
$this->gbcRamBankPositionECHO = $state[$address++];
$this->numRAMBanks = $state[$address];
$this->tileCountInvalidator = $this->tileCount * 4;
$this->fromSaveState = true;
$this->checkPaletteType();
$this->initLCD();
$this->drawToCanvas();
}