public SimpleAvi toSimpleAvi() {
    SimpleAvi avi = new SimpleAvi();
    avi.dwMicroSecPerFrame = 34296875 / 512;
    avi.dwRate = 65536;
    avi.dwScale = 4389;

    avi.width = WIDTH;
    avi.height = HEIGHT;

    avi.totalFrames = framePixels.length;
    avi.frames = new long[avi.totalFrames][HEIGHT][WIDTH];

    long [] tmpPalettes = framePalettes[0].clone();
    byte[][] tmpPaletteMap = framePaletteMap[0].clone();
    byte[][] tmpPixels = framePixels[0].clone();
    for (int frame = 0; frame < avi.totalFrames; frame++) {
      if (frame > 0) {
        for (int i = TOP_PALETTE_FREEZE; i < BOTTOM_PALETTE_FREEZE; i++)
          tmpPalettes[i] = framePalettes[frame][i - TOP_PALETTE_FREEZE];
        for (int i = FREEZE_TOP; i < HEIGHT / 8 - FREEZE_BOTTOM; i++)
          tmpPaletteMap[i] = framePaletteMap[frame][i - FREEZE_TOP];
        for (int i = 8*FREEZE_TOP; i < HEIGHT - 8*FREEZE_BOTTOM; i++)
          tmpPixels[i] = framePixels[frame][i - 8*FREEZE_TOP];
      }

      for (int y = 0; y < HEIGHT; y++) {
        for (int x = 0; x < WIDTH; x++) {
          int p = tmpPaletteMap[y/8][x/8];
          int paletteIndex = p + (y + (Palette.PALETTE_HEIGHT - 1) - (p / Palette.PALETTES_PER_LINE))/Palette.PALETTE_HEIGHT * Palette.NUM_PALETTES;
          avi.frames[frame][y][x] = Palette.fromGbColor((short) (tmpPalettes[paletteIndex] >> (tmpPixels[y][x] << 4)));
        }
      }
    }

    return avi;
  }