public static boolean extractFromEmulator(CHREditorModel newModelRef, NES nes){
        try {

        	MemoryInterface mem = nes._memoryManager;
        	// copy the nametable
            int len = newModelRef.getCHRModel().nameTableIndexes[0].length;
            byte nt[] = new byte[len];
            for(int i=0;i<len;i++){
            	nt[i] = mem.getCHRMemory(0x2000 + i);
            }
            System.arraycopy(nt, 0, newModelRef.getCHRModel().nameTableIndexes[0],0,len);
     
            // copy the oam
            len = newModelRef.getCHRModel().oamValues[0].length;
            byte oam[] = new byte[len];
            for(int i=0;i<len;i++){
            	oam[i] = mem.getCHRMemory(0x2400-len + i);
            }
            System.arraycopy(oam,0,newModelRef.getCHRModel().oamValues[0],0,len);
            
            // copy the palettes
            len = newModelRef.getCHRModel().imagePalette.length;
            byte pal[] = new byte[len];
            for(int i=0;i<len;i++){
            	pal[i] = mem.getCHRMemory(0x3F00 + i);
            }
            
            System.arraycopy(pal, 0, newModelRef.getCHRModel().imagePalette,0,len);
            len = newModelRef.getCHRModel().spritePalette.length;
            pal = new byte[len];
            for(int i=0;i<len;i++){
            	pal[i] = mem.getCHRMemory(0x3F10 + i);
            }
            System.arraycopy(pal, 0, newModelRef.getCHRModel().spritePalette,0,len);

            
            byte ctrlByte = nes._ppu.getPPUCTRLDirect();
            boolean switchTiles = ((ctrlByte & 0x10) == 0x10);
            
            
            // copy the tiles
            len = newModelRef.getCHRModel().patternTable[0].length;
            byte tiles[] = new byte[len];
            for(int i=0;i<len;i++){
            	tiles[i] = mem.getCHRMemory(0x0000 + i);
            }
            
            if(switchTiles)
            	System.arraycopy(tiles,0,newModelRef.getCHRModel().patternTable[1],0,len);
            else
            	System.arraycopy(tiles,0,newModelRef.getCHRModel().patternTable[0],0,len);
            	
            len = newModelRef.getCHRModel().patternTable[1].length;
            tiles = new byte[len];
            for(int i=0;i<len;i++){
            	tiles[i] = mem.getCHRMemory(0x1000 + i);
            }
            if(switchTiles)
            	System.arraycopy(tiles,0,newModelRef.getCHRModel().patternTable[0],0,len);
            else
            	System.arraycopy(tiles,0,newModelRef.getCHRModel().patternTable[1],0,len);
        } catch(Exception ex){
            ex.printStackTrace();
        }
        return true;
    }