g_error rdhandle(void **p,unsigned char reqtype,int owner,handle h) { void **x; g_error e; e = rdhandlep(&x,reqtype,owner,h); #ifdef DEBUG_MEMORY if (iserror(e)) printf("rdhandle error (0x%08X)\n",h); #endif errorcheck; if (x) *p = *x; else *p = NULL; return success; }
g_error cursor_set_theme(struct cursor *crsr, int thobj) { hwrbitmap *bitmap,*mask; s16 w,h; bool redisplay; g_error e; crsr->thobj = thobj; /* Read the cursor bitmap and bitmask. Note that if the cursor is rectangular * or it uses an alpha channel the mask will be NULL. */ e = rdhandlep((void***)&bitmap,PG_TYPE_BITMAP,-1,theme_lookup(thobj,PGTH_P_CURSORBITMAP)); errorcheck; mask = NULL; e = rdhandlep((void***)&mask,PG_TYPE_BITMAP,-1,theme_lookup(thobj,PGTH_P_CURSORBITMASK)); errorcheck; if (crsr->sprite && bitmap==crsr->sprite->bitmap && mask==crsr->sprite->mask) return success; /* If there's no bitmap yet, it's early in init and the default cursor * hasn't been created yet. Skip this all. */ if (!bitmap) return success; VID(bitmap_getsize) (*bitmap,&w,&h); /* Insert the new bitmaps, resize/create the sprite if necessary */ redisplay = crsr->sprite && crsr->sprite->onscreen; if (redisplay) VID(sprite_hide) (crsr->sprite); /* Update the hotspot before cursor_move */ crsr->hotspot_x = theme_lookup(thobj,PGTH_P_CRSRHOTSPOT_X); crsr->hotspot_y = theme_lookup(thobj,PGTH_P_CRSRHOTSPOT_Y); if (!crsr->sprite) { int x,y; struct divtree *dt; /* Get the default position */ cursor_getposition(crsr,&x,&y,&dt); /* Create a new sprite (default hidden, as per description in input.h) */ e = new_sprite(&crsr->sprite,dt,w,h); errorcheck; crsr->sprite->visible = 0; /* Set the bitmap up, and move it */ crsr->sprite->bitmap = bitmap; crsr->sprite->mask = mask; cursor_move(crsr, x,y, dt); } else { /* Since we're not creating a new sprite, we might need to move the hotspot */ crsr->sprite->x = crsr->x - crsr->hotspot_x; crsr->sprite->y = crsr->y - crsr->hotspot_y; if ( (w!=crsr->sprite->w) || (h!=crsr->sprite->h) ) { /* Resize an existing sprite */ VID(bitmap_free) (crsr->sprite->backbuffer); e = VID(bitmap_new) (&crsr->sprite->backbuffer,w,h,vid->bpp); errorcheck; crsr->sprite->w = w; crsr->sprite->h = h; } crsr->sprite->bitmap = bitmap; crsr->sprite->mask = mask; } /* If the cursor has an alpha channel, set the LGOP accordingly */ if (w && h && (VID(getpixel)(*bitmap,0,0) & PGCF_ALPHA)) crsr->sprite->lgop = PG_LGOP_ALPHA; else crsr->sprite->lgop = PG_LGOP_NONE; if (redisplay) VID(sprite_show)(crsr->sprite); /* Whether it was onscreen or not, show it at the next convenient opportunity */ crsr->sprite->visible = 1; return success; }