OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [stable_0_2_0_rc2/] [or1ksim/] [peripheral/] [fb.c] - Diff between revs 970 and 997

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 970 Rev 997
Line 108... Line 108...
  FILE *fo;
  FILE *fo;
 
 
  unsigned short int u16;
  unsigned short int u16;
  unsigned long int u32;
  unsigned long int u32;
 
 
  if (config.sim.verbose) printf ("Creating %s...", filename);
  if (config.sim.verbose) PRINTF ("Creating %s...", filename);
  fo = fopen (filename, "wb+");
  fo = fopen (filename, "wb+");
  u16 = CNV16(19778); /* BM */
  u16 = CNV16(19778); /* BM */
  if (!fwrite (&u16, 2, 1, fo)) return 1;
  if (!fwrite (&u16, 2, 1, fo)) return 1;
  u32 = CNV32(14 + 40 + sx * sy + 1024); /* size */
  u32 = CNV32(14 + 40 + sx * sy + 1024); /* size */
  if (!fwrite (&u32, 4, 1, fo)) return 1;
  if (!fwrite (&u32, 4, 1, fo)) return 1;
Line 155... Line 155...
    val = CNV32(pal[i]);
    val = CNV32(pal[i]);
#endif
#endif
    if (!fwrite (&val, 4, 1, fo)) return 1;
    if (!fwrite (&val, 4, 1, fo)) return 1;
  }
  }
 
 
  if (config.sim.verbose) printf ("(%i,%i)", sx, sy);
  if (config.sim.verbose) PRINTF ("(%i,%i)", sx, sy);
  /* Data is stored upside down */
  /* Data is stored upside down */
  for (y = sy - 1; y >= 0; y--) {
  for (y = sy - 1; y >= 0; y--) {
    int align = (4 - sx) % 4;
    int align = (4 - sx) % 4;
    int zero = CNV32(0);
    int zero = CNV32(0);
    int add;
    int add;
Line 169... Line 169...
      fputc (evalsim_mem8 (add), fo);
      fputc (evalsim_mem8 (add), fo);
    }
    }
    if (align && !fwrite (&zero, align, 1, fo)) return 1;
    if (align && !fwrite (&zero, align, 1, fo)) return 1;
  }
  }
 
 
  if (config.sim.verbose) printf ("DONE\n");
  if (config.sim.verbose) PRINTF ("DONE\n");
  fclose (fo);
  fclose (fo);
  return 0;
  return 0;
}
}
 
 
/* Dumps a bmp file, based on current image */
/* Dumps a bmp file, based on current image */
Line 185... Line 185...
  FILE *fo;
  FILE *fo;
 
 
  unsigned short int u16;
  unsigned short int u16;
  unsigned long int u32;
  unsigned long int u32;
 
 
  if (config.sim.verbose) printf ("Creating %s...", filename);
  if (config.sim.verbose) PRINTF ("Creating %s...", filename);
  fo = fopen (filename, "wb+");
  fo = fopen (filename, "wb+");
  u16 = CNV16(19778); /* BM */
  u16 = CNV16(19778); /* BM */
  if (!fwrite (&u16, 2, 1, fo)) return 1;
  if (!fwrite (&u16, 2, 1, fo)) return 1;
  u32 = CNV32(14 + 40 + sx * sy * 3); /* size */
  u32 = CNV32(14 + 40 + sx * sy * 3); /* size */
  if (!fwrite (&u32, 4, 1, fo)) return 1;
  if (!fwrite (&u32, 4, 1, fo)) return 1;
Line 219... Line 219...
  u32 = CNV32(0);  /* ncolours = 0; should be generated */
  u32 = CNV32(0);  /* ncolours = 0; should be generated */
  if (!fwrite (&u32, 4, 1, fo)) return 1;
  if (!fwrite (&u32, 4, 1, fo)) return 1;
  u32 = CNV32(0);  /* important colours; all are important */
  u32 = CNV32(0);  /* important colours; all are important */
  if (!fwrite (&u32, 4, 1, fo)) return 1;
  if (!fwrite (&u32, 4, 1, fo)) return 1;
 
 
  if (config.sim.verbose) printf ("(%i,%i)", sx, sy);
  if (config.sim.verbose) PRINTF ("(%i,%i)", sx, sy);
  /* Data is stored upside down */
  /* Data is stored upside down */
  for (y = sy - 1; y >= 0; y--) {
  for (y = sy - 1; y >= 0; y--) {
    unsigned char line[FB_SIZEX][3];
    unsigned char line[FB_SIZEX][3];
    for (x = 0; x < sx; x++)
    for (x = 0; x < sx; x++)
      if (y >= cameray && x >= camerax && y < cameray + CAM_SIZEY && x < camerax + CAM_SIZEX) {
      if (y >= cameray && x >= camerax && y < cameray + CAM_SIZEY && x < camerax + CAM_SIZEX) {
Line 240... Line 240...
        line[x][2] = ((d >> 11) & 0x1f) << 3; /* Red */
        line[x][2] = ((d >> 11) & 0x1f) << 3; /* Red */
      }
      }
    if(!fwrite (line, sizeof(line), 1, fo)) return 1;
    if(!fwrite (line, sizeof(line), 1, fo)) return 1;
  }
  }
 
 
  if (config.sim.verbose) printf ("DONE\n");
  if (config.sim.verbose) PRINTF ("DONE\n");
  fclose (fo);
  fclose (fo);
  return 0;
  return 0;
}
}
 
 
void fb_job (int param)
void fb_job (int param)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.