/[gxemul]/trunk/src/devices/dev_fb.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/devices/dev_fb.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 6 by dpavlin, Mon Oct 8 16:18:11 2007 UTC revision 10 by dpavlin, Mon Oct 8 16:18:27 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *     *  
27   *   *
28   *  $Id: dev_fb.c,v 1.94 2005/05/23 14:22:02 debug Exp $   *  $Id: dev_fb.c,v 1.99 2005/06/26 13:49:06 debug Exp $
29   *     *  
30   *  Generic framebuffer device.   *  Generic framebuffer device.
31   *   *
# Line 65  Line 65 
65  #endif  #endif
66    
67    
68  #define FB_TICK_SHIFT           17  #define FB_TICK_SHIFT           18
69    
70  #define LOGO_XSIZE              256  #define LOGO_XSIZE              256
71  #define LOGO_YSIZE              256  #define LOGO_YSIZE              256
# Line 445  void update_framebuffer(struct vfb_data Line 445  void update_framebuffer(struct vfb_data
445                                                          r = r & 31;                                                          r = r & 31;
446                                                          g = (g & 31) * 2;                                                          g = (g & 31) * 2;
447                                                          b = b & 31;                                                          b = b & 31;
448                                                    } else if (d->psp_15bit) {
449                                                            int tmp;
450                                                            r = (b >> 10) & 0x1f;
451                                                            g = (b >>  5) & 0x1f;
452                                                            b = b & 0x1f;
453                                                            g <<= 1;
454                                                            tmp = r; r = b; b = tmp;
455                                                  } else {                                                  } else {
456                                                          r = (b >> 11) & 0x1f;                                                          r = (b >> 11) & 0x1f;
457                                                          g = (b >>  5) & 0x3f;                                                          g = (b >>  5) & 0x3f;
# Line 901  int dev_fb_access(struct cpu *cpu, struc Line 908  int dev_fb_access(struct cpu *cpu, struc
908  /*  /*
909   *  dev_fb_init():   *  dev_fb_init():
910   *   *
911   *  xsize and ysize are ignored if vfb_type is VFB_DEC_VFB01 or 02.   *  This function is big and ugly, but the point is to initialize a framebuffer
912     *  device. :-)
913     *
914     *  visible_xsize and visible_ysize are the sizes of the visible display area.
915     *  xsize and ysize tell how much memory is actually allocated (for example
916     *  visible_xsize could be 640, but xsize could be 1024, for better alignment).
917     *
918     *  vfb_type is useful for selecting special features.
919     *
920     *  type = VFB_GENERIC is the most useful type, especially when bit_depth = 24.
921     *
922     *  VFB_DEC_VFB01, _VFB02, and VFB_DEC_MAXINE are DECstation specific.
923     *
924     *  If type is VFB_HPCMIPS, then color encoding differs from the generic case.
925     *
926     *  If bit_depth = -15 (note the minus sign), then a special hack is used for
927     *  the Playstation Portable's 5-bit R, 5-bit G, 5-bit B.
928   */   */
929  struct vfb_data *dev_fb_init(struct machine *machine, struct memory *mem,  struct vfb_data *dev_fb_init(struct machine *machine, struct memory *mem,
930          uint64_t baseaddr, int vfb_type, int visible_xsize, int visible_ysize,          uint64_t baseaddr, int vfb_type, int visible_xsize, int visible_ysize,
931          int xsize, int ysize, int bit_depth, char *name, int logo)          int xsize, int ysize, int bit_depth, char *name, int logo)
932  {  {
933          struct vfb_data *d;          struct vfb_data *d;
934          size_t size;          size_t size, nlen;
935          int x, y;          int x, y, flags;
936          char title[400];          char title[400];
937          char *name2;          char *name2;
         int flags;  
938    
939          d = malloc(sizeof(struct vfb_data));          d = malloc(sizeof(struct vfb_data));
940          if (d == NULL) {          if (d == NULL) {
# Line 932  struct vfb_data *dev_fb_init(struct mach Line 954  struct vfb_data *dev_fb_init(struct mach
954          if (bit_depth == 15) {          if (bit_depth == 15) {
955                  d->color32k = 1;                  d->color32k = 1;
956                  bit_depth = d->bit_depth = 16;                  bit_depth = d->bit_depth = 16;
957            } else if (bit_depth == -15) {
958                    d->psp_15bit = 1;
959                    bit_depth = d->bit_depth = 16;
960          }          }
961    
962          /*  Specific types:  */          /*  Specific types:  */
# Line 1007  struct vfb_data *dev_fb_init(struct mach Line 1032  struct vfb_data *dev_fb_init(struct mach
1032                                  int b = fb_logo[(y*LOGO_XSIZE+x) / 8] &                                  int b = fb_logo[(y*LOGO_XSIZE+x) / 8] &
1033                                      (128 >> (x&7));                                      (128 >> (x&7));
1034                                  for (s=0; s<d->bit_depth / 8; s++)                                  for (s=0; s<d->bit_depth / 8; s++)
1035                                          d->framebuffer[a+s] = b? 0 : 255;                                          if (a+s >= 0 && a+s < size)
1036                                                    d->framebuffer[a+s] = b? 0:255;
1037                          }                          }
1038          }          }
1039    
# Line 1028  struct vfb_data *dev_fb_init(struct mach Line 1054  struct vfb_data *dev_fb_init(struct mach
1054  #endif  #endif
1055                  d->fb_window = NULL;                  d->fb_window = NULL;
1056    
1057          name2 = malloc(strlen(name) + 10);          nlen = strlen(name) + 10;
1058            name2 = malloc(nlen);
1059          if (name2 == NULL) {          if (name2 == NULL) {
1060                  fprintf(stderr, "out of memory in dev_fb_init()\n");                  fprintf(stderr, "out of memory in dev_fb_init()\n");
1061                  exit(1);                  exit(1);
1062          }          }
1063          sprintf(name2, "fb [%s]", name);          snprintf(name2, nlen, "fb [%s]", name);
1064    
1065          flags = MEM_DEFAULT;          flags = MEM_DEFAULT;
1066          if ((baseaddr & 0xfff) == 0)          if ((baseaddr & 0xfff) == 0)

Legend:
Removed from v.6  
changed lines
  Added in v.10

  ViewVC Help
Powered by ViewVC 1.1.26