Beispiel #1
0
HBITMAP WINAPI
CreateCompatibleBitmap(HDC hdc, int nWidth, int nHeight)
{
	MWBITMAPOBJ *	hbitmap;
	int		size;
	int		linelen;

	if(!hdc)
		return NULL;

	nWidth = MWMAX(nWidth, 1);
	nHeight = MWMAX(nHeight, 1);

	/* calc memory allocation size and linelen from width and height*/
	if(!GdCalcMemGCAlloc(hdc->psd, nWidth, nHeight, 0, 0, &size, &linelen))
		return NULL;

	/* allocate gdi object*/
	hbitmap = (MWBITMAPOBJ *)GdItemAlloc(sizeof(MWBITMAPOBJ)-1+size);
	if(!hbitmap)
		return NULL;
	hbitmap->hdr.type = OBJ_BITMAP;
	hbitmap->hdr.stockobj = FALSE;
	hbitmap->width = nWidth;
	hbitmap->height = nHeight;

	/* create compatible with hdc*/
	hbitmap->planes = hdc->psd->planes;
	hbitmap->bpp = hdc->psd->bpp;
	hbitmap->linelen = linelen;
	hbitmap->size = size;

	return (HBRUSH)hbitmap;
}
Beispiel #2
0
/* init framebuffer*/
static PSD
fb_open(PSD psd)
{
	PSUBDRIVER subdriver;
	char *env;

	/* set statically in struct definition, may be overridden before calling fb_open*/
	//psd->xres = psd->xvirtres = SCREEN_WIDTH;
	//psd->yres = psd->yvirtres = SCREEN_HEIGHT;

	/* use pixel format to set bpp*/
	psd->pixtype = MWPIXEL_FORMAT;
	switch (psd->pixtype) {
	case MWPF_TRUECOLORARGB:
	case MWPF_TRUECOLORABGR:
	default:
		psd->bpp = 32;
		break;

	case MWPF_TRUECOLORRGB:
		psd->bpp = 24;
		break;

	case MWPF_TRUECOLOR565:
	case MWPF_TRUECOLOR555:
		psd->bpp = 16;
		break;

	case MWPF_TRUECOLOR332:
		psd->bpp = 8;
		break;

#if MWPIXEL_FORMAT == MWPF_PALETTE
	case MWPF_PALETTE:
		psd->bpp = SCREEN_DEPTH;
		break;
#endif
	}
	psd->planes = 1;

	/* set standard data format from bpp and pixtype*/
	psd->data_format = set_data_format(psd);

	/* Calculate the correct size and pitch from xres, yres and bpp*/
	GdCalcMemGCAlloc(psd, psd->xres, psd->yres, psd->planes, psd->bpp, &psd->size, &psd->pitch);

	psd->ncolors = (psd->bpp >= 24)? (1 << 24): (1 << psd->bpp);
	psd->flags = PSF_SCREEN;
	psd->portrait = MWPORTRAIT_NONE;

	/* select an fb subdriver matching our planes and bpp for backing store*/
	subdriver = select_fb_subdriver(psd);
	psd->orgsubdriver = subdriver;
	if (!subdriver)
		return NULL;

	/* set subdriver into screen driver*/
	set_subdriver(psd, subdriver);

#ifdef PATH_FRAMEBUFFER
	/* try opening framebuffer file for mmap*/
	if((env = getenv("FRAMEBUFFER")) == NULL)
		env = PATH_FRAMEBUFFER;
	fb = open(env, O_RDWR);
#endif
	if (fb >= 0) {
		/* mmap framebuffer into this address space*/
		psd->size = (psd->size + getpagesize() - 1) / getpagesize() * getpagesize();
		psd->addr = mmap(NULL, psd->size, PROT_READ|PROT_WRITE, MAP_SHARED, fb, 0);
		if (psd->addr == NULL || psd->addr == (unsigned char *)-1) {
			EPRINTF("Error mmaping shared framebuffer %s: %m\n", env);
			close(fb);
			return NULL;
		}
	} else {
		/* allocate framebuffer*/
		if ((psd->addr = malloc(psd->size)) == NULL)
			return NULL;
		psd->flags |= PSF_ADDRMALLOC;
	}

	/* allocate update region*/
	fb_updateregion = GdAllocRegion();

	return psd;	/* success*/
}
Beispiel #3
0
/*
**	Open graphics
*/
static PSD
DJGR_open(PSD psd)
{
	PSUBDRIVER subdriver;

	GrVideoMode	*md_info;
	
	int vwidth,vheight,vbpp;
	
	vwidth = SCREEN_WIDTH;
	vheight = SCREEN_HEIGHT;
	if(SCREEN_PIXTYPE == MWPF_TRUECOLOR8888) {
		vbpp=32;
	} else if(SCREEN_PIXTYPE == MWPF_TRUECOLOR888) {
		vbpp=24;
	} else if(SCREEN_PIXTYPE == MWPF_TRUECOLOR565)  {
		vbpp=16;
	} else {
		vbpp=8; //palette
	}

    GrSetMode(GR_width_height_bpp_graphics,vwidth,vheight,vbpp);

    md_info = (GrVideoMode *) GrCurrentVideoMode();

	psd->xres = psd->xvirtres = GrScreenX();
	psd->yres = psd->yvirtres = GrScreenY();
	psd->planes = 1;
	psd->bpp = md_info->bpp;
	psd->ncolors = psd->bpp >= 24 ? (1 << 24) : (1 << psd->bpp);
	psd->flags = PSF_SCREEN | PSF_ADDRMALLOC;
	/* Calculate the correct size and linelen here */
	GdCalcMemGCAlloc(psd, psd->xres, psd->yres, psd->planes, psd->bpp,
		&psd->size, &psd->pitch);

    if(psd->bpp == 32) {
		psd->pixtype = MWPF_TRUECOLOR8888;	
	} else if(psd->bpp == 16) {
		psd->pixtype = MWPF_TRUECOLOR565; 
	} else if(psd->bpp == 24)  {
		psd->pixtype = MWPF_TRUECOLOR888;
	} else {
		psd->pixtype = MWPF_PALETTE;
	}
		  
  psd->portrait = MWPORTRAIT_NONE;
  psd->data_format = set_data_format(psd);

  /*
   * set and initialize subdriver into screen driver
   * psd->size is calculated by subdriver init
   */
  subdriver = select_fb_subdriver(psd);
  
  psd->orgsubdriver = subdriver;

  set_subdriver(psd, subdriver);

  if ((psd->addr = malloc(psd->size)) == NULL)
		return NULL;

  return psd;

}
Beispiel #4
0
static PSD
n3ds888_open(PSD psd)
{
  PSUBDRIVER subdriver;

  /* init driver variables depending on ega/vga mode*/
  psd->xres = psd->xvirtres = 240;
  psd->yres = psd->yvirtres = 340;
  psd->planes = 1;
  psd->bpp = 24;
  psd->ncolors = psd->bpp >= 24? (1 << 24): (1 << psd->bpp);
  psd->pixtype = MWPF_TRUECOLOR888;
  psd->portrait = MWPORTRAIT_NONE;
  psd->data_format = set_data_format(psd);

  /* Calculate the correct size and pitch from xres, yres and bpp*/
  GdCalcMemGCAlloc(psd, psd->xres, psd->yres, psd->planes, psd->bpp,
		   &psd->size, &psd->pitch);

  psd->flags = PSF_SCREEN;

  /*
   * set and initialize subdriver into screen driver
   * psd->size is calculated by subdriver init
   */
  
  // Currently attempting to use FB16 subdriver
  subdriver = select_fb_subdriver(psd);

  // Check that a valid subdriver exists
  if (!subdriver) 
    {
      EPRINTF("No driver for screen bpp %d\n", psd->bpp);
      return NULL;
    }
 
  psd->orgsubdriver = subdriver;

  set_subdriver(psd, subdriver);

//FB_BOT_1
//  psd->addr = (void*) 0x0008CA00//launcher 0x202118E0;

	srvInit();			// mandatory
	aptInit();			// mandatory
	hidInit(NULL);	// input (buttons, screen)

  gfxInit();
//  screenBottom=0x48F000;
//  screenBottom=gfxGetFramebuffer(GFX_BOTTOM, GFX_BOTTOM, NULL, NULL);

  psd->addr = (void*) gfxGetFramebuffer(GFX_BOTTOM, GFX_BOTTOM, NULL, NULL);
  printf('nano-x --> n3ds888_open \n');
  gfxFlushBuffers();


//    0x1E6000-0x22C500 -- top screen 3D left framebuffer 0(240x400x3) (The "3D right first-framebuf" addr stored in the LCD register is set to this, when the 3D is set to "off")
//    0x22C800-0x272D00 -- top screen 3D left framebuffer 1(240x400x3)
//    0x273000-0x2B9500 -- top screen 3D right framebuffer 0(240x400x3)
//    0x2B9800-0x2FFD00 -- top screen 3D right framebuffer 1(240x400x3)
//    0x48F000-0x4C7400 -- bottom screen framebuffer 0(240x320x3)
//    0x4C7800-0x4FF800 -- bottom screen framebuffer 1(240x320x3) 

  return psd;
}