Ejemplo n.º 1
0
int lib_graphics_f_AllocRaster_3(emumsg_syscall_t *msg)
{
	cpu_t *cpu;
	uint32_t vaddr;

	DEBUG(4) dprintf("graphics.library: lib_graphics_f_AllocRaster_3() called\n");

        cpu = msg->proc->cpu;

	DEBUG(5) dprintf("  Raster ptr (native): %p\n",msg->arg[0]._aptr);

	if(msg->arg[0]._aptr == NULL) {
		cpu->d[0] = 0;
		DEBUG(5) dprintf("  Raster ptr (D0): 0x%x\n",0);
		return HOOK_DONE;
	}

	vaddr = vallocmem_ram((uint8_t *)msg->arg[0]._aptr,RASSIZE(cpu->d[0],cpu->d[1]),"lib.graphics.AllocRaster");
	if(vaddr == 0) {
		DEBUG(1) dprintf("Error: graphics.library: lib_graphics_f_AllocRaster_3: Could not map allocated data into vmem\n");
		return HOOK_END_PROC;
	}

	cpu->d[0] = vaddr;

	DEBUG(5) dprintf("  Raster ptr (D0): 0x%x\n",cpu->d[0]);

	return HOOK_DONE;
}
Ejemplo n.º 2
0
struct BitMap *MyAllocBitMap (ULONG w, ULONG h, ULONG d, ULONG flags, struct BitMap *friend_bitmap)
{
//	struct BitMap *res = (BitMap *)AllocVec(sizeof(BitMap), MEMF_ANY);
	struct BitMap *res = new BitMap;
	res->Planes[0] = (PLANEPTR)AllocVec(RASSIZE(w, h) * d, MEMF_ANY);
	return res;
}
Ejemplo n.º 3
0
VOID test_flood(struct Window *w)
{

    struct TmpRas tmpras;
    BYTE *buffer;
    
D(bug("Window layer: %p\n", w->WLayer));    

    buffer = AllocRaster(w->WLayer->Width, w->WLayer->Height);
D(bug("buffer: %p\n", buffer));    
    if (!buffer)
    	return;
	
    InitTmpRas(&tmpras, buffer, RASSIZE(w->WLayer->Width, w->WLayer->Height));
    w->RPort->TmpRas = &tmpras;
    
    SetOutlinePen(w->RPort, 1);
    SetAPen(w->RPort, 1);
    
    SetDrPt(w->RPort, ~0L);
    
    Move(w->RPort, 50, 50);
    Draw(w->RPort, 100, 100);
    Draw(w->RPort, 50,  100);
    Draw(w->RPort, 50, 50);
    
D(bug("Calling Flood()\n"));    
    Flood(w->RPort, 0, 70, 80);   /* outline mode */

    w->RPort->TmpRas = NULL;
    
}
Ejemplo n.º 4
0
STATIC struct Image *ImageDupPooled(APTR pool, struct Image *src)
{
    struct Image *dest;

    if (!src) return NULL;

    dest = (struct Image*)AllocPooled(pool,sizeof(struct Image));
    if (dest)
    {
	int data_size = 0;
	int plane_size;
	int i;
	int plane_pick = src->PlanePick;

	*dest = *src;
	dest->NextImage = NULL;

	/* Calc the size all used planes */
	plane_size = RASSIZE(src->Width,src->Height);
	for (i=0;i<8;i++)
	{
	    if (plane_pick & 1) data_size += plane_size;
	    plane_pick >>= 1;
	}

	if ((dest->ImageData = AllocPooled(pool,data_size)))
	{
	    memcpy(dest->ImageData,src->ImageData,data_size);
#ifdef OUTPUT_DATA
	    kprintf("plane_pick = %ld\n",src->PlanePick);
	    kprintf("width = %ld\n",src->Width);
	    kprintf("height = %ld\n",src->Height);

	    for (i=0;i<data_size;i++)
	    {
		kprintf("0x%02lx,",((unsigned char*)src->ImageData)[i]);
		if (i%16 == 15) kprintf("\n");
	    }
	     kprintf("\n");
#endif
	    return dest;
	}

	/* Something failed so we fail also */
	FreePooled(pool,dest,sizeof(struct Image));
    }
    return NULL;
}
Ejemplo n.º 5
0
int CGX_SetHWColorKey(_THIS,SDL_Surface *surface, Uint32 key)
{
	if(surface->hwdata)
	{
		if(surface->hwdata->mask)
			SDL_free(surface->hwdata->mask);

		if(surface->hwdata->mask=SDL_malloc(RASSIZE(surface->w,surface->h)))
		{
			Uint32 pitch,ok=0;
			APTR lock;

			SDL_memset(surface->hwdata->mask,255,RASSIZE(surface->w,surface->h));

			D(bug("Building colorkey mask: color: %ld, size: %ld x %ld, %ld bytes...Bpp:%ld\n",key,surface->w,surface->h,RASSIZE(surface->w,surface->h),surface->format->BytesPerPixel));

			if(lock=LockBitMapTags(surface->hwdata->bmap,LBMI_BASEADDRESS,(ULONG)&surface->pixels,
					LBMI_BYTESPERROW,(ULONG)&pitch,TAG_DONE))
			{
				switch(surface->format->BytesPerPixel)
				{
					case 1:
					{
						unsigned char k=key;
						register int i,j,t;
						register unsigned char *dest=surface->hwdata->mask,*map=surface->pixels;

						pitch-=surface->w;

						for(i=0;i<surface->h;i++)
						{
							for(t=128,j=0;j<surface->w;j++)
							{
								if(*map==k)
									*dest&=~t;	

								t>>=1;

								if(t==0)
								{
									dest++;
									t=128;
								}
								map++;
							}
							map+=pitch;
						}
					}
					break;
					case 2:
					{
						Uint16 k=key,*mapw;
						register int i,j,t;
						register unsigned char *dest=surface->hwdata->mask,*map=surface->pixels;

						for(i=surface->h;i;--i)
						{
							mapw=(Uint16 *)map;

							for(t=128,j=surface->w;j;--j)
							{
								if(*mapw==k)
									*dest&=~t;

								t>>=1;

								if(t==0)
								{
									dest++;
									t=128;
								}
								mapw++;
							}
							map+=pitch;
						}
					}
					break;
					case 4:
					{
						Uint32 *mapl;
						register int i,j,t;
						register unsigned char *dest=surface->hwdata->mask,*map=surface->pixels;

						for(i=surface->h;i;--i)
						{
							mapl=(Uint32 *)map;

							for(t=128,j=surface->w;j;--j)
							{
								if(*mapl==key)
									*dest&=~t;

								t>>=1;

								if(t==0)
								{
									dest++;
									t=128;
								}
								mapl++;
							}
							map+=pitch;
						}

					}
					break;
					default:
						D(bug("Pixel mode non supported for color key..."));
						SDL_free(surface->hwdata->mask);
						surface->hwdata->mask=NULL;
						ok=-1;
				}
				UnLockBitMap(lock);
				D(bug("...Colorkey built!\n"));
				return ok;
			}
		}
	}