struct RastPort *RenderMessage::ObtainDoubleBuffer (ULONG width, ULONG height) { if(BufferRP) { if(width > BufferWidth || height > BufferHeight) { WaitBlit(); FreeBitMap(BufferRP->BitMap); BufferWidth = MAX(BufferWidth, width); BufferHeight = MAX(BufferHeight, height); BufferRP->BitMap = AllocBitMap(BufferWidth, BufferHeight, GetBitMapAttr(RPort->BitMap, BMA_DEPTH), BMF_MINPLANES, RPort->BitMap); } } else { BufferRP = new (std::nothrow) struct RastPort[1]; if (!BufferRP) return NULL; InitRastPort(BufferRP); BufferRP->BitMap = AllocBitMap(width, height, GetBitMapAttr(RPort->BitMap, BMA_DEPTH), BMF_MINPLANES, RPort->BitMap); BufferWidth = width; BufferHeight = height; } return(BufferRP->BitMap ? BufferRP : NULL); }
static VOID clipagainstbitmap(struct BitMap *bm, LONG *x1, LONG *y1, LONG *x2, LONG *y2, struct GfxBase *GfxBase) { ULONG width = GetBitMapAttr(bm, BMA_WIDTH); ULONG height = GetBitMapAttr(bm, BMA_HEIGHT); /* Clip against bitmap bounds */ if (*x1 < 0) *x1 = 0; if (*y1 < 0) *y1 = 0; if (*x2 >= width) *x2 = width - 1; if (*y2 >= height) *y2 = height - 1; return; }
static void getvisual(void) { if (!(scr = LockPubScreen(0))) { cleanup("Can't lock pub screen!"); } if (!(dri = GetScreenDrawInfo(scr))) { cleanup("Can't get screen drawinfo!"); } vp = &scr->ViewPort; cm = vp->ColorMap; pen1 = ObtainPen(cm, -1, 0, 0, 0, PENF_EXCLUSIVE); pen2 = ObtainPen(cm, -1, 0, 0, 0, PENF_EXCLUSIVE); pens[0] = pen1; pens[1] = pen2; if ((pen1 == -1) || (pen2 == -1)) cleanup("Can't obtain 2 pens!"); if (GetBitMapAttr(scr->RastPort.BitMap, BMA_DEPTH) >= 15) truecolor = TRUE; }
void Amiga_SetScreenColors(void){ FILE *file; UWORD depth; int num_colors_on_file; long lokke; int lokke2; long num_colors=1; char temp[100]; ULONG rgb[3]; file=fopen("radium:radiumcolors.conf","r"); if(file==NULL) return; depth=GetBitMapAttr(mainscreen->RastPort.BitMap,BMA_DEPTH); for(lokke=0;lokke<depth;lokke++){ num_colors*=2; } fgets(temp,90,file); num_colors_on_file=atoi(temp); for(lokke=0;lokke<num_colors_on_file;lokke++){ if(lokke>=num_colors || lokke==256) break; for(lokke2=0;lokke2<3;lokke2++){ fgets(temp,90,file); rgb[lokke2]=strtoul(temp,NULL,10); } SetRGB32(&mainscreen->ViewPort,lokke,rgb[0],rgb[1],rgb[2]); } fclose(file); }
static IPTR coolimage_draw(Class *cl, Object *o, struct impDraw *msg) { struct CoolImageData *data; WORD x, y; data = INST_DATA(cl, o); x = IM(o)->LeftEdge + msg->imp_Offset.X; y = IM(o)->TopEdge + msg->imp_Offset.Y; if (CyberGfxBase && (GetBitMapAttr(msg->imp_RPort->BitMap, BMA_DEPTH) >= 15)) { data->pal[0] = data->bgcol; WriteLUTPixelArray((APTR)data->image->data, 0, 0, data->image->width, msg->imp_RPort, data->pal, x, y, data->image->width, data->image->height, CTABFMT_XRGB8); } return 0; }
VOID BltMaskRPort (struct BitMap *source, WORD srcLeft,WORD srcTop, struct RastPort *destination, WORD dstLeft,WORD dstTop,WORD dstWidth,WORD dstHeight, PLANEPTR maskPlane) { if(GetBitMapAttr(source, BMA_FLAGS) & BMF_INTERLEAVED) { struct BitMap mask; InitBitMap(&mask, 8, GetBitMapAttr(source, BMA_WIDTH), GetBitMapAttr(source, BMA_HEIGHT)); for(UWORD i = 0; i < 8; i++) mask.Planes[i] = maskPlane; BltBitMapRastPort(source, srcLeft, srcTop, destination, dstLeft, dstTop, dstWidth, dstHeight, MINTERM_B_EQUALS_C); BltBitMapRastPort(&mask, srcLeft,srcTop, destination, dstLeft, dstTop, dstWidth, dstHeight, MINTERM_B_OR_C); BltBitMapRastPort(source, srcLeft, srcTop, destination, dstLeft, dstTop, dstWidth, dstHeight, MINTERM_B_EQUALS_C); } else { BltMaskBitMapRastPort(source, srcLeft, srcTop, destination, dstLeft, dstTop, dstWidth, dstHeight, (ABC | ABNC | ANBC), maskPlane); } }
/// /// MyBltMaskBitMapRastPort() static void MyBltMaskBitMapRastPort(struct BitMap *srcBitMap, LONG xSrc, LONG ySrc, struct RastPort *destRP, LONG xDest, LONG yDest, LONG xSize, LONG ySize, ULONG minterm, APTR bltMask) { ENTER(); if(GetBitMapAttr(srcBitMap, BMA_FLAGS) & BMF_INTERLEAVED) { LONG src_depth = GetBitMapAttr(srcBitMap, BMA_DEPTH); struct Rectangle rect; struct BltHook hook; // Define the destination rectangle in the rastport rect.MinX = xDest; rect.MinY = yDest; rect.MaxX = xDest + xSize - 1; rect.MaxY = yDest + ySize - 1; // Initialize the hook InitHook(&hook.hook, BltMaskHook, NULL); hook.srcBitMap = srcBitMap; hook.srcx = xSrc; hook.srcy = ySrc; hook.destx = xDest; hook.desty = yDest; // Initialize a bitmap where all plane pointers points to the mask InitBitMap(&hook.maskBitMap, src_depth, GetBitMapAttr(srcBitMap, BMA_WIDTH), GetBitMapAttr(srcBitMap, BMA_HEIGHT)); while(src_depth) { hook.maskBitMap.Planes[--src_depth] = bltMask; } // Blit onto the Rastport */ DoHookClipRects(&hook.hook, destRP, &rect); } else { BltMaskBitMapRastPort(srcBitMap, xSrc, ySrc, destRP, xDest, yDest, xSize, ySize, minterm, bltMask); } LEAVE(); }
static void getvisual(void) { if (!(scr = LockPubScreen(NULL))) { cleanup("Can't lock pub screen!"); } if (GetBitMapAttr(scr->RastPort.BitMap, BMA_DEPTH) <= 8) { cleanup("Need hi or true color screen!"); } }
VOID MyBltMaskBitMapRastPort( struct BitMap *srcBitMap, LONG xSrc, LONG ySrc, struct RastPort *destRP, LONG xDest, LONG yDest, LONG xSize, LONG ySize, ULONG minterm, APTR bltMask) { if (GetBitMapAttr(srcBitMap,BMA_FLAGS)&BMF_INTERLEAVED) { LONG src_depth = GetBitMapAttr(srcBitMap,BMA_DEPTH); struct Rectangle rect; struct BltMaskHook hook; /* Define the destination rectangle in the rastport */ rect.MinX = xDest; rect.MinY = yDest; rect.MaxX = xDest + xSize - 1; rect.MaxY = yDest + ySize - 1; /* Initialize the hook */ #if defined(__AMIGAOS4__) || defined(__MORPHOS__) || defined(__AROS__) hook.hook.h_Entry = (HOOKFUNC)hookEntry; hook.hook.h_SubEntry = (HOOKFUNC)HookFunc_BltMask; #else hook.hook.h_Entry = (HOOKFUNC)HookFunc_BltMask; #endif hook.srcBitMap = srcBitMap; hook.srcx = xSrc; hook.srcy = ySrc; hook.destx = xDest; hook.desty = yDest; /* Initialize a bitmap where all plane pointers points to the mask */ InitBitMap(&hook.maskBitMap,src_depth,GetBitMapAttr(srcBitMap,BMA_WIDTH),GetBitMapAttr(srcBitMap,BMA_HEIGHT)); while (src_depth) hook.maskBitMap.Planes[--src_depth] = (PLANEPTR)bltMask; /* Blit onto the Rastport */ DoHookClipRects(&hook.hook,destRP,&rect); } else { BltMaskBitMapRastPort(srcBitMap, xSrc, ySrc, destRP, xDest, yDest, xSize, ySize, minterm, (PLANEPTR)bltMask); } }
void Amiga_ConfigColors(void){ FILE *file; UWORD depth; long num_colors=1; long lokke; int lokke2; ULONG *table; rtPaletteRequest( "Color Config. Saved as radium:radiumcolors.conf",NULL, RT_Screen,mainscreen, TAG_END ); file=fopen("radium:radiumcolors.conf","w"); if(file==NULL){ RError("Could not save radium:radiumcolors.conf\n"); return; } depth=GetBitMapAttr(mainscreen->RastPort.BitMap,BMA_DEPTH); for(lokke=0;lokke<depth;lokke++){ num_colors*=2; } fprintf(file,"%d\n",num_colors); table=talloc_atomic((size_t)(sizeof(ULONG)*num_colors*3)); GetRGB32(mainscreen->ViewPort.ColorMap,0,num_colors,table); for(lokke=0;lokke<num_colors;lokke++){ if(lokke==256) break; for(lokke2=0;lokke2<3;lokke2++){ fprintf(file,"%lu\n",table[lokke*3+lokke2]); } } fclose(file); }
static void getvisual(void) { if (!(scr = LockPubScreen(NULL))) { cleanup("Can't lock pub screen!"); } if (1) { LONG val; val = GetCyberMapAttr(scr->RastPort.BitMap,CYBRMATTR_PIXFMT); printf("cgfx attribute = %ld\n", val); } if (GetBitMapAttr(scr->RastPort.BitMap, BMA_DEPTH) <= 8) { cleanup("Need hi or true color screen!"); } }
///ImageBackFill__MUIM_IconWindow_BackFill_ProcessBackground() IPTR ImageBackFill__MUIM_IconWindow_BackFill_ProcessBackground ( Class *CLASS, Object *self, struct MUIP_IconWindow_BackFill_ProcessBackground *message ) { LONG Depth = 0; Object *_IconWindows_PrefsObj = NULL, *_IconWindows_WindowObj = NULL; Object *_IconWindows_IconListObj = NULL; BOOL options_changed = FALSE; IPTR prefs_processing = 0; IPTR BackGround_Attrib = 0, BackGround_Base = 0, BackGround_RenderMode = 0, BackGround_TileMode = 0, BackGround_XOffset = 0, BackGround_YOffset = 0; struct BackFillInfo *this_BFI =(struct BackFillInfo *) message->BackFill_Data; UBYTE *this_bgtype; char *this_ImageName; D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground()\n")); GET(_app(self), MUIA_Wanderer_Prefs, &_IconWindows_PrefsObj); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: PrefsObj @ %x\n", _IconWindows_PrefsObj)); GET(self, MUIA_IconWindow_Window, &_IconWindows_WindowObj); GET(self, MUIA_IconWindow_IconList, &_IconWindows_IconListObj); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: MUIA_IconWindow_Window = %x\n", _IconWindows_WindowObj)); if ((_IconWindows_PrefsObj == NULL) || (_IconWindows_WindowObj == NULL) || (_IconWindows_IconListObj == NULL)) return FALSE; GET(_IconWindows_PrefsObj, MUIA_WandererPrefs_Processing, &prefs_processing); #if defined(DEBUG) if (prefs_processing) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Wanderer Prefs (re)loading detected\n")); } #endif GET(_IconWindows_WindowObj, MUIA_IconWindow_BackgroundAttrib, &BackGround_Attrib); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Background Attrib = '%s'\n", BackGround_Attrib)); if (BackGround_Attrib == (IPTR) NULL) return FALSE; if ((BackGround_Base = DoMethod(_IconWindows_PrefsObj, MUIM_WandererPrefs_ViewSettings_GetAttribute, BackGround_Attrib, MUIA_Background)) == -1) return FALSE; if ((BackGround_RenderMode = DoMethod(_IconWindows_PrefsObj, MUIM_WandererPrefs_ViewSettings_GetAttribute, BackGround_Attrib, MUIA_IconWindowExt_ImageBackFill_BGRenderMode)) == -1) BackGround_RenderMode = IconWindowExt_ImageBackFill_RenderMode_Tiled; this_bgtype = (UBYTE *)BackGround_Base; this_ImageName = (char *)(BackGround_Base + 2); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: BackFillInfo @ %x\n", this_BFI)); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Background '%s', mode %d\n", BackGround_Base, BackGround_RenderMode)); if ((this_bgtype[0] - 48) != 5) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Background is NOT an image - letting our windoclass handle it ..\n")); goto pb_cleanup_buffer; } GET(self, MUIA_Window_Screen, &this_BFI->bfi_Screen); GET(_IconWindows_IconListObj, MUIA_IconList_BufferRastport, &this_BFI->bfi_RastPort); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Wanderers Screen @ %x, Using RastPort @ %x\n", this_BFI->bfi_Screen, this_BFI->bfi_RastPort)); if (this_BFI->bfi_Source) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: BackFillInfo has existing source record @ %x\n", this_BFI->bfi_Source)); if ((strcmp(this_BFI->bfi_Source->bfsir_SourceImage, this_ImageName) == 0) && (this_BFI->bfi_Source->bfsir_BackGroundRenderMode == BackGround_RenderMode)) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: existing BackFillInfo Using the same background / mode\n")); goto check_imagebuffer; } else { if (this_BFI->bfi_Buffer) { ImageBackFill_CloseSourceBuffer(this_BFI->bfi_Source, this_BFI->bfi_Buffer); this_BFI->bfi_Buffer = NULL; } ImageBackFill_CloseSourceRecord(this_BFI->bfi_Source); this_BFI->bfi_Source = NULL; } } if (!(this_BFI->bfi_Source)) this_BFI->bfi_Source = ImageBackFill_FindSourceRecord(this_ImageName, BackGround_RenderMode); if (!(this_BFI->bfi_Source)) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Creating NEW ImageSource Record\n")); if (!(this_BFI->bfi_Source = AllocMem(sizeof(struct BackFillSourceImageRecord), MEMF_CLEAR|MEMF_PUBLIC))) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Couldnt allocate enough mem for source record!\n")); return FALSE; } if (!(this_BFI->bfi_Source->bfsir_SourceImage = AllocVec(strlen(this_ImageName) +1, MEMF_CLEAR|MEMF_PUBLIC))) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Couldnt allocate enough mem for source image name store\n")); FreeMem(this_BFI->bfi_Source, sizeof(struct BackFillSourceImageRecord)); return FALSE; } strcpy(this_BFI->bfi_Source->bfsir_SourceImage, this_ImageName); if ((this_BFI->bfi_Source->bfsir_DTPictureObject = NewDTObject(this_BFI->bfi_Source->bfsir_SourceImage, DTA_SourceType, DTST_FILE, DTA_GroupID, GID_PICTURE, PDTA_DestMode, PMODE_V43, PDTA_Remap, TRUE, PDTA_Screen, this_BFI->bfi_Screen, PDTA_FreeSourceBitMap, TRUE, OBP_Precision, PRECISION_IMAGE, TAG_DONE))) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Opened Datatype Object @ %x for image '%s'\n", this_BFI->bfi_Source->bfsir_DTPictureObject, this_BFI->bfi_Source->bfsir_SourceImage)); if (DoMethod(this_BFI->bfi_Source->bfsir_DTPictureObject, DTM_PROCLAYOUT, NULL, 1)) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Caused Datatype Object LAYOUT\n")); GetDTAttrs(this_BFI->bfi_Source->bfsir_DTPictureObject, PDTA_BitMapHeader, &this_BFI->bfi_Source->bfsir_DTBitMapHeader, TAG_DONE); GetDTAttrs(this_BFI->bfi_Source->bfsir_DTPictureObject, PDTA_DestBitMap, &this_BFI->bfi_Source->bfsir_DTBitMap, TAG_DONE); if (!this_BFI->bfi_Source->bfsir_DTBitMap) GetDTAttrs(this_BFI->bfi_Source->bfsir_DTPictureObject, PDTA_BitMap, &this_BFI->bfi_Source->bfsir_DTBitMap, TAG_DONE); if (this_BFI->bfi_Source->bfsir_DTBitMap) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Datatype Object BitMap @ %x\n", this_BFI->bfi_Source->bfsir_DTBitMap)); if ((this_BFI->bfi_Source->bfsir_DTRastPort = CreateRastPort())) { this_BFI->bfi_Source->bfsir_DTRastPort->BitMap = this_BFI->bfi_Source->bfsir_DTBitMap; this_BFI->bfi_Source->bfsir_BackGroundRenderMode = BackGround_RenderMode; this_BFI->bfi_Source->bfsir_OpenerCount = 0x01; NewList(&this_BFI->bfi_Source->bfsir_Buffers); AddTail(&image_backfill_images, &this_BFI->bfi_Source->bfsir_Node); goto check_imagebuffer; } } /* Failed to obtain datatype object's BM */ } /* Failed to Layout datatype object */ } /* Failed to open datatype object */ #if defined(DEBUG) if (!this_BFI->bfi_Source->bfsir_DTRastPort) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Failed to create ImageSource RastPort\n")); } #endif if (this_BFI->bfi_Source->bfsir_DTBitMap) { FreeBitMap(this_BFI->bfi_Source->bfsir_DTBitMap); this_BFI->bfi_Source->bfsir_DTBitMap = NULL; } #if defined(DEBUG) else { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Failed to create ImageSource BitMap\n")); } #endif if (this_BFI->bfi_Source->bfsir_DTPictureObject) { DisposeDTObject(this_BFI->bfi_Source->bfsir_DTPictureObject); this_BFI->bfi_Source->bfsir_DTPictureObject = NULL; } #if defined(DEBUG) else { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Failed to create ImageSource Datatype Object\n")); } #endif D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Failed to create ImageSource Record\n")); if (this_BFI->bfi_Source->bfsir_SourceImage) FreeVec(this_BFI->bfi_Source->bfsir_SourceImage); FreeMem(this_BFI->bfi_Source, sizeof(struct BackFillSourceImageRecord)); this_BFI->bfi_Source = NULL; return FALSE; } else { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Using existing ImageSource Record\n")); this_BFI->bfi_Source->bfsir_OpenerCount += 1; } check_imagebuffer: Depth = GetBitMapAttr(this_BFI->bfi_Source->bfsir_DTBitMap, BMA_DEPTH); this_BFI->bfi_CopyWidth = this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Width; this_BFI->bfi_CopyHeight = this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Height; switch (BackGround_RenderMode) { case IconWindowExt_ImageBackFill_RenderMode_Scale: { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED mode\n")); this_BFI->bfi_Options.bfo_TileMode = IconWindowExt_ImageBackFill_TileMode_Fixed; SET(_IconWindows_IconListObj, MUIA_IconListview_FixedBackground, TRUE); SET(_IconWindows_IconListObj, MUIA_IconListview_ScaledBackground, TRUE); if ((BOOL)XGET(self, MUIA_IconWindow_IsRoot)) { struct BackFillSourceImageBuffer *this_Buffer; D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Root Window = TRUE!\n")); this_BFI->bfi_CopyWidth = GetBitMapAttr(this_BFI->bfi_Screen->RastPort.BitMap, BMA_WIDTH); this_BFI->bfi_CopyHeight = GetBitMapAttr(this_BFI->bfi_Screen->RastPort.BitMap, BMA_HEIGHT); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Base Dimensions (%d x %d)\n", this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight)); if (!((BOOL)XGET(self, MUIA_IconWindow_IsBackdrop))) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Adjusting for window border Dimensions ..\n")); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - WBorTop %d, WBorLeft %d, WBorRight %d, WBorBottom %d\n", this_BFI->bfi_Screen->WBorTop, this_BFI->bfi_Screen->WBorLeft, this_BFI->bfi_Screen->WBorRight, this_BFI->bfi_Screen->WBorBottom)); this_BFI->bfi_CopyWidth -= (this_BFI->bfi_Screen->WBorLeft + this_BFI->bfi_Screen->WBorRight); this_BFI->bfi_CopyHeight -= (this_BFI->bfi_Screen->WBorTop + this_BFI->bfi_Screen->WBorBottom);; } this_BFI->bfi_CopyHeight -= (this_BFI->bfi_Screen->BarHeight + 1); this_Buffer = NULL; if (this_BFI->bfi_Buffer) { if ((this_BFI->bfi_Buffer->bfsib_BitMapWidth == this_BFI->bfi_CopyWidth) && (this_BFI->bfi_Buffer->bfsib_BitMapHeight == this_BFI->bfi_CopyHeight)) { goto pb_backfillsetup_complete; } else { ImageBackFill_CloseSourceBuffer(this_BFI->bfi_Source, this_BFI->bfi_Buffer); this_BFI->bfi_Buffer = NULL; } } if (!(this_Buffer = ImageBackFill_FindBufferRecord(this_BFI->bfi_Source, this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight))) { this_Buffer = AllocMem(sizeof(struct BackFillSourceImageBuffer), MEMF_CLEAR|MEMF_PUBLIC); this_Buffer->bfsib_BitMapWidth = this_BFI->bfi_CopyWidth; this_Buffer->bfsib_BitMapHeight = this_BFI->bfi_CopyHeight; if (!(this_Buffer->bfsib_BitMapRastPort = CreateRastPort())) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Failed to create RastPort for BackFill BitMap\n")); break; } if ((this_Buffer->bfsib_BitMap = AllocBitMap(this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight, Depth, Depth == 8 ? BMF_MINPLANES : 0L, this_BFI->bfi_Screen->RastPort.BitMap))) { struct Rectangle CopyBounds; D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Scale Dimensions (%d x %d)\n", this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight)); this_Buffer->bfsib_BitMapRastPort->BitMap = this_Buffer->bfsib_BitMap; this_BFI->bfi_Buffer = this_Buffer; CopyBounds.MinX = 0; CopyBounds.MinY = 0; CopyBounds.MaxX = this_BFI->bfi_CopyWidth - 1; CopyBounds.MaxY = this_BFI->bfi_CopyHeight - 1; ImageBackFill_CopyScaledBitMap(this_BFI->bfi_Source->bfsir_DTRastPort, 0, 0, this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Width, this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Height, this_Buffer->bfsib_BitMapRastPort, &CopyBounds, &CopyBounds, blit_MODE_Blit); this_Buffer->bfsib_OpenerCount = 0x01; AddTail(&this_BFI->bfi_Source->bfsir_Buffers, &this_Buffer->bfsib_Node); goto pb_backfillsetup_complete; } break; } else { this_BFI->bfi_Buffer = this_Buffer; this_Buffer->bfsib_OpenerCount += 1; goto pb_backfillsetup_complete; } } // We arent the "ROOT" (desktop) window so only tile ... D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Drawer window scaling unsupported ...\n")); } default: { struct BackFillSourceImageBuffer *this_Buffer; D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: TILED mode\n")); if ((BackGround_TileMode = DoMethod(_IconWindows_PrefsObj, MUIM_WandererPrefs_ViewSettings_GetAttribute, BackGround_Attrib, MUIA_IconWindowExt_ImageBackFill_BGTileMode)) == -1) BackGround_TileMode = IconWindowExt_ImageBackFill_TileMode_Float; if ((BackGround_XOffset = DoMethod(_IconWindows_PrefsObj, MUIM_WandererPrefs_ViewSettings_GetAttribute, BackGround_Attrib, MUIA_IconWindowExt_ImageBackFill_BGXOffset)) == -1) BackGround_XOffset = 0; if ((BackGround_YOffset = DoMethod(_IconWindows_PrefsObj, MUIM_WandererPrefs_ViewSettings_GetAttribute, BackGround_Attrib, MUIA_IconWindowExt_ImageBackFill_BGYOffset)) == -1) this_BFI->bfi_Options.bfo_OffsetY = 0; if (this_BFI->bfi_Options.bfo_TileMode != BackGround_TileMode) { this_BFI->bfi_Options.bfo_TileMode = BackGround_TileMode; options_changed = TRUE; } if (this_BFI->bfi_Options.bfo_OffsetX != BackGround_XOffset) { this_BFI->bfi_Options.bfo_OffsetX = BackGround_XOffset; options_changed = TRUE; } if (this_BFI->bfi_Options.bfo_OffsetY != BackGround_YOffset) { this_BFI->bfi_Options.bfo_OffsetY = BackGround_YOffset; options_changed = TRUE; } if (this_BFI->bfi_Options.bfo_TileMode == IconWindowExt_ImageBackFill_TileMode_Float) SET(_IconWindows_IconListObj, MUIA_IconListview_FixedBackground, FALSE); else SET(_IconWindows_IconListObj, MUIA_IconListview_FixedBackground, TRUE); SET(_IconWindows_IconListObj, MUIA_IconListview_ScaledBackground, FALSE); this_Buffer = NULL; if (this_BFI->bfi_Buffer) { if ((this_BFI->bfi_Buffer->bfsib_BitMapWidth == this_BFI->bfi_CopyWidth) && (this_BFI->bfi_Buffer->bfsib_BitMapHeight == this_BFI->bfi_CopyHeight)) { goto pb_backfillsetup_complete; } else { ImageBackFill_CloseSourceBuffer(this_BFI->bfi_Source, this_BFI->bfi_Buffer); this_BFI->bfi_Buffer = NULL; } } D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Dimensions Width %d, Height %d\n", this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight)); if (!(this_Buffer = ImageBackFill_FindBufferRecord(this_BFI->bfi_Source, this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight))) { this_Buffer = AllocMem(sizeof(struct BackFillSourceImageBuffer), MEMF_CLEAR|MEMF_PUBLIC); this_Buffer->bfsib_BitMapWidth = this_BFI->bfi_CopyWidth; this_Buffer->bfsib_BitMapHeight = this_BFI->bfi_CopyHeight; if ((this_Buffer->bfsib_BitMap = AllocBitMap(this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight, Depth, Depth == 8 ? BMF_MINPLANES : 0L, this_BFI->bfi_Screen->RastPort.BitMap))) { struct Rectangle CopyBounds; if (!(this_Buffer->bfsib_BitMapRastPort = CreateRastPort())) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: TILED - Failed to create RastPort for BackFill BitMap\n")); break; } this_Buffer->bfsib_BitMapRastPort->BitMap = this_Buffer->bfsib_BitMap; this_BFI->bfi_Buffer = this_Buffer; CopyBounds.MinX = 0; CopyBounds.MinY = 0; CopyBounds.MaxX = this_BFI->bfi_CopyWidth - 1; CopyBounds.MaxY = this_BFI->bfi_CopyHeight - 1; ImageBackFill_CopyTiledBitMap(this_BFI->bfi_Source->bfsir_DTRastPort, 0, 0, this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Width, this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Height, this_BFI->bfi_Buffer->bfsib_BitMapRastPort, &CopyBounds, &CopyBounds, blit_MODE_Blit); this_Buffer->bfsib_OpenerCount = 0x01; AddTail(&this_BFI->bfi_Source->bfsir_Buffers, &this_BFI->bfi_Buffer->bfsib_Node); goto pb_backfillsetup_complete; } break; } else { this_BFI->bfi_Buffer = this_Buffer; this_Buffer->bfsib_OpenerCount += 1; goto pb_backfillsetup_complete; } } } D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Failed to create image datatype object\n")); return FALSE; pb_cleanup_buffer: if (this_BFI->bfi_Buffer) { ImageBackFill_CloseSourceBuffer(this_BFI->bfi_Source, this_BFI->bfi_Buffer); this_BFI->bfi_Buffer = NULL; } pb_cleanup_source: if (this_BFI->bfi_Source) { ImageBackFill_CloseSourceRecord(this_BFI->bfi_Source); this_BFI->bfi_Source = NULL; } return FALSE; pb_backfillsetup_complete: if ((prefs_processing) && (options_changed)) SET(self, MUIA_IconWindow_Changed, TRUE); return TRUE; }
IPTR PointerClass__OM_NEW(Class *cl, Object *o, struct opSet *msg) { struct IntuitionBase *IntuitionBase = (struct IntuitionBase *)cl->cl_UserData; struct GfxBase *GfxBase = GetPrivIBase(IntuitionBase)->GfxBase; struct Library *UtilityBase = GetPrivIBase(IntuitionBase)->UtilityBase; OOP_MethodID HiddBitMapBase = ((struct IntIntuitionBase *)IntuitionBase)->ib_HiddBitMapBase; D(kprintf("PointerClass: OM_NEW\n")); if (cl) { struct TagItem *tags = msg->ops_AttrList; struct BitMap *bitmap = (struct BitMap *)GetTagData(POINTERA_BitMap, (IPTR)NULL, tags); /* Hack: we accept and pass on to AllocSpriteDataA() these attributes in order to provide code reuse. Applications should not rely on it, this is private! */ BOOL oldbitmap = GetTagData(SPRITEA_OldDataFormat, FALSE, tags); IPTR width = GetTagData(SPRITEA_Width, 16, tags); IPTR height = GetTagData(SPRITEA_OutputHeight, 0, tags); //ULONG xResolution = GetTagData(POINTERA_XResolution, POINTERXRESN_DEFAULT, tags); //ULONG yResolution = GetTagData(POINTERA_YResolution, POINTERYRESN_DEFAULT, tags); D( { struct TagItem *tagscan=tags; while(tagscan->ti_Tag != 0) { kprintf(" 0x%08lx, %08lx\n",tagscan->ti_Tag,tagscan->ti_Data); tagscan++; } } ) if (1) // bitmap { struct TagItem spritetags[] = { {SPRITEA_Width , 0 }, {SPRITEA_OutputHeight , 0 }, {SPRITEA_OldDataFormat, TRUE}, {TAG_DONE } }; struct ExtSprite *sprite; struct BitMap *spritedata=(struct BitMap *)bitmap; if(spritedata != NULL) { if (oldbitmap) { spritetags[0].ti_Data = width; spritetags[1].ti_Data = height; } else { spritetags[0].ti_Data = GetTagData(POINTERA_WordWidth, ((GetBitMapAttr(bitmap, BMA_WIDTH) + 15) & ~15)>>4, tags) * 16; spritetags[1].ti_Tag = TAG_DONE; } } else { D(kprintf("PointerClass: OM_NEW called without bitmap, using dummy sprite !\n")); spritetags[0].ti_Data = 16; spritetags[1].ti_Data = 1; bitmap = (struct BitMap *)posctldata; } sprite = AllocSpriteDataA(bitmap, spritetags); D(kprintf("PointerClass: extSprite 0x%lx\n",sprite)); D(kprintf("MoveSprite data 0x%lx, height %ld, x %ld, y %ld, num %ld, wordwidth, 0x%lx, flags 0x%lx\n", sprite->es_SimpleSprite.posctldata, sprite->es_SimpleSprite.height, sprite->es_SimpleSprite.x, sprite->es_SimpleSprite.y, sprite->es_SimpleSprite.num, sprite->es_wordwidth, sprite->es_flags)); if (sprite) { struct SharedPointer *shared; /* If our pointer doesn't already have a user-supplied colormap, we attach it here. This makes the pointer to always have its own colors on hi- and truecolor screens. In addition it gets an alpha channel. Note that this relies on the fact that AllocSpriteDataA() always generates HIDD bitmap in sprite->es_BitMap. */ if (!HIDD_BM_COLMAP(sprite->es_BitMap)) { ULONG i; HIDDT_Color col[DEF_POINTER_DEPTH] = {{0}}; struct Color32 *q = GetPrivIBase(IntuitionBase)->Colors; for (i = 1; i < DEF_POINTER_DEPTH; i++ ) { col[i].red = q[i + 7].red >> 16; col[i].green = q[i + 7].green >> 16; col[i].blue = q[i + 7].blue >> 16; col[i].alpha = GetPrivIBase(IntuitionBase)->PointerAlpha; } HIDD_BM_SetColors(HIDD_BM_OBJ(sprite->es_BitMap), col, 0, DEF_POINTER_DEPTH); } shared = CreateSharedPointer(sprite, GetTagData(POINTERA_XOffset, 0, tags), GetTagData(POINTERA_YOffset, 0, tags), IntuitionBase); if (shared) { o = (Object *)DoSuperMethodA(cl, o, (Msg)msg); if (o) { struct PointerData *data = INST_DATA(cl, o); data->shared_pointer = shared; //data->xRes = xResolution; //data->yRes = yResolution; D(kprintf("PointerClass: set extSprite 0x%lx and XOffset %ld YOffset %ld\n",shared->sprite,shared->xoffset,shared->yoffset)); } else { D(kprintf("PointerClass: free sprite\n")); ReleaseSharedPointer(shared, IntuitionBase); } } else { D(kprintf("PointerClass: free sprite\n")); FreeSpriteData(sprite); } }
int main(int argc, char **argv) { struct myargs args = {NULL}; struct RDArgs *rda; if ((IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0))) { if ((GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0))) { if ((DOSBase = (struct DosLibrary *) OpenLibrary("dos.library",0))) { rda = ReadArgs("LEFT/K/N,TOP/K/N,WIDTH/N,HEIGHT/N,DEPTH/K/N,MODEID/K,OVERSCAN/K/N,SCROLL/K/N,DRAG/K/N,LIKEWB/K/N", (IPTR *)&args, NULL); if (rda) { struct Screen *screen; struct Window *w1; ULONG oserr = 0; struct TagItem tags[] = { {SA_Width, 640 }, {SA_Height, 480 }, {SA_Depth, 4 }, {TAG_IGNORE, 0 }, {TAG_IGNORE, 0 }, {TAG_IGNORE, 0 }, {TAG_IGNORE, 0 }, {TAG_IGNORE, 0 }, {TAG_IGNORE, 0 }, {TAG_IGNORE, 0 }, {SA_Title, (IPTR)"Screen opening and movement test"}, {SA_ErrorCode, (IPTR)&oserr }, {TAG_DONE, 0 } }; if (args.width) tags[0].ti_Data = *args.width; if (args.height) tags[1].ti_Data = *args.height; if (args.depth) tags[2].ti_Data = *args.depth; printf("Opening screen, size: %lux%lu, depth: %lu\n", tags[0].ti_Data, tags[1].ti_Data, tags[3].ti_Data); if (args.mode) { tags[3].ti_Tag = SA_DisplayID; tags[3].ti_Data = strtoul(args.mode, NULL, 16); printf("ModeID: 0x%08lX\n", tags[3].ti_Data); } if (args.scroll) { tags[4].ti_Tag = SA_AutoScroll; tags[4].ti_Data = *args.scroll; printf("SA_AutoScroll: %ld\n", tags[4].ti_Data); } if (args.drag) { tags[5].ti_Tag = SA_Draggable; tags[5].ti_Data = *args.drag; printf("SA_Draggable: %ld\n", tags[5].ti_Data); } if (args.likewb) { tags[6].ti_Tag = SA_LikeWorkbench; tags[6].ti_Data = *args.likewb; printf("SA_LikeWorkbench: %ld\n", tags[6].ti_Data); } if (args.oscan) { tags[7].ti_Tag = SA_Overscan; tags[7].ti_Data = *args.oscan; printf("SA_Overscan: %ld\n", tags[7].ti_Data); } if (args.left) { tags[8].ti_Tag = SA_Left; tags[8].ti_Data = *args.left; printf("SA_Left: %ld\n", tags[8].ti_Data); } if (args.top) { tags[9].ti_Tag = SA_Top; tags[9].ti_Data = *args.top; printf("SA_Top: %ld\n", tags[9].ti_Data); } screen = OpenScreenTagList(NULL, tags); if (screen) { w1 = openwindow(screen, "Screen data", W1_LEFT, W1_TOP, W1_WIDTH, W1_HEIGHT); if (w1) { WORD x = w1->BorderLeft; WORD y = w1->BorderTop; struct BitMap *bitmap = screen->RastPort.BitMap; y = drawtext(w1, x, y, "Requested size: %lux%lu", tags[0].ti_Data, tags[1].ti_Data); y = drawtext(w1, x, y, "Requested depth: %lu", tags[2].ti_Data); if (args.mode) y = drawtext(w1, x, y, "Requested ModeID: 0x%08lX", tags[3].ti_Data); y = drawtext(w1, x, y, "Actual size: %ux%u", screen->Width, screen->Height); y = drawtext(w1, x, y, "Actual ModeID: 0x%08X", screen->ViewPort.ColorMap->VPModeID); y = drawtext(w1, x, y, "Flags: 0x%04lX", screen->Flags); y = drawtext(w1, x, y, "BitMap size: %ux%u", GetBitMapAttr(bitmap, BMA_WIDTH), GetBitMapAttr(bitmap, BMA_HEIGHT)); y = drawtext(w1, x, y, "BitMap depth: %u", GetBitMapAttr(bitmap, BMA_DEPTH)); handleevents(w1, screen, x, y); CloseWindow(w1); } CloseScreen(screen); } else printf("Failed to open screen, error: %d\n", (int)oserr); FreeArgs(rda); } else printf("Error parsing arguments\n"); CloseLibrary((struct Library *)DOSBase); } CloseLibrary((struct Library *)GfxBase); } CloseLibrary((struct Library *) IntuitionBase); } return 0; } /* main */
struct DragObj * PRIVATE CreateDragObj(struct DragGadget *dg,int x,int y) { struct Screen *scr; struct RastPort *rp; struct DragObj *gdo; ULONG line; int wordwidth; int width,height,depth; int i = 0,xpos,ypos; scr = dg->dg_Window->WScreen; rp = &scr->RastPort; if (dg->dg_Flags & DGF_IMAGES && ((struct ImageNode *)dg->dg_Object.od_Object)->in_Image) dg->dg_Image = ((struct ImageNode *)dg->dg_Object.od_Object)->in_Image; if (!dg->dg_Width || !dg->dg_Height) { if ((dg->dg_Type == LISTVIEW_KIND) && !dg->dg_Image) { dg->dg_Width = dg->dg_Gadget->Width-20; dg->dg_Height = dg->dg_ItemHeight; } else if (!dg->dg_RenderHook && dg->dg_Image) { dg->dg_Width = dg->dg_Image->Width; dg->dg_Height = dg->dg_Image->Height; } else /* be sure width & height are not zero */ { dg->dg_Width = dg->dg_Gadget->Width; dg->dg_Height = dg->dg_Gadget->Height; } } width = dg->dg_Width; height = dg->dg_Height; memset(&dm,0,sizeof(struct DropMessage)); if (dg->dg_Type == LISTVIEW_KIND) { xpos = dg->dg_Gadget->LeftEdge+2; ypos = dg->dg_Gadget->TopEdge+2; dg->dg_Object.od_Object = NULL; if (y < ypos || y > ypos+dg->dg_Gadget->Height-5) return(NULL); line = (y-ypos)/dg->dg_ItemHeight; ypos += line*dg->dg_ItemHeight; GT_GetGadgetAttrs(dg->dg_Gadget,dg->dg_Window,NULL,GTLV_Labels,&dg->dg_List,TAG_END); if (dg->dg_List && !IsListEmpty(dg->dg_List)) { GT_GetGadgetAttrs(dg->dg_Gadget,dg->dg_Window,NULL,GTLV_Top,&i,TAG_END); i += line; if (i < CountNodes(dg->dg_List)) { struct Node *ln; dm.dm_SourceEntry = i; for(ln = dg->dg_List->lh_Head;i;i--,ln = ln->ln_Succ); if (dg->dg_Flags & DGF_TREEVIEW && TREENODE(ln)->tn_Flags & TNF_STATIC) { mx = ~0L; // avoid a following drag return(NULL); } dg->dg_Object.od_Object = ln; if (dg->dg_ObjectFunc) dg->dg_ObjectFunc(dg->dg_Window,dg->dg_Gadget,&dg->dg_Object,dm.dm_SourceEntry); } } } else { if (dg->dg_ObjectFunc) dg->dg_ObjectFunc(dg->dg_Window,dg->dg_Gadget,&dg->dg_Object,0L); dm.dm_SourceEntry = dg->dg_SourceEntry; xpos = x-width/2; ypos = y-height/2; } if (!dg->dg_Object.od_Object) { mx = ~0L; // avoid a following drag return(NULL); } wordwidth = (width + 15) >> 4; depth = GetBitMapAttr(rp->BitMap,BMA_DEPTH); if (dg->dg_Object.od_Object && (gdo = AllocMem(sizeof(struct DragObj), MEMF_CLEAR | MEMF_PUBLIC))) { #ifdef LOCKLAYERS LockLayers(&scr->LayerInfo); UnlockLayer(dg->dg_Window->RPort->Layer); #endif gdo->do_Screen = scr; gdo->do_ScrRPort = rp; gdo->do_BitMap = AllocBitMap(width,height,depth,BMF_CLEAR | BMF_MINPLANES,!(GetBitMapAttr( rp->BitMap, BMA_FLAGS ) & BMF_INTERLEAVED) ? rp->BitMap : NULL); gdo->do_SaveBack = AllocBitMap(width,height,depth,BMF_CLEAR | BMF_MINPLANES,rp->BitMap); gdo->do_RefreshMap = AllocBitMap(width*2,height*2,depth,BMF_CLEAR | BMF_MINPLANES,rp->BitMap); if (GetBitMapAttr(gdo->do_BitMap,BMA_FLAGS) & BMF_STANDARD) i = MEMF_CHIP | MEMF_PUBLIC; else i = 0; gdo->do_FullShadow = AllocMem(2*wordwidth*height,i | MEMF_CLEAR); gdo->do_HalfShadow = AllocMem(2*wordwidth*height,i); if (gdo->do_BitMap && gdo->do_SaveBack && gdo->do_RefreshMap && gdo->do_FullShadow && gdo->do_HalfShadow) { InitRastPort(&gdo->do_RPort); gdo->do_RPort.BitMap = gdo->do_BitMap; InitRastPort(&gdo->do_RefreshRPort); gdo->do_RefreshRPort.BitMap = gdo->do_RefreshMap; gdo->do_DragGadget = dg; CopyMem(&dg->dg_Object,&dm.dm_Object,sizeof(struct ObjectDescription)); dm.dm_Window = dg->dg_Window; dm.dm_Gadget = dg->dg_Gadget; /*** create the drag&drop image ***/ if (dg->dg_RenderHook) { struct LVDrawMsg lvdm; SetFont(&gdo->do_RPort,scr->RastPort.Font); lvdm.lvdm_MethodID = LV_DRAW; lvdm.lvdm_RastPort = &gdo->do_RPort; lvdm.lvdm_DrawInfo = GetScreenDrawInfo(scr); lvdm.lvdm_Bounds.MinX = 0; lvdm.lvdm_Bounds.MinY = 0; lvdm.lvdm_Bounds.MaxX = width-1; lvdm.lvdm_Bounds.MaxY = height-1; lvdm.lvdm_State = LVR_SELECTED; CallHookPkt(dg->dg_RenderHook,dm.dm_Object.od_Object,&lvdm); FreeScreenDrawInfo(scr,lvdm.lvdm_DrawInfo); } else if (dg->dg_Image) DrawImage(&gdo->do_RPort,dg->dg_Image,0,0); else ClipBlit(dg->dg_Window->RPort,xpos,ypos,&gdo->do_RPort,0,0,width,height,0xc0); /*** initialize drag object structure ***/ gdo->do_X = -9999; gdo->do_Y = ypos+dg->dg_Window->TopEdge; gdo->do_PX = -9999; gdo->do_Width = width; gdo->do_Height = height; gdo->do_DeltaX = xpos-x+dg->dg_Window->LeftEdge; gdo->do_DeltaY = ypos-y+dg->dg_Window->TopEdge; gdo->do_Mask = gdo->do_FullShadow; /*** create masks (transparent and full imagery) ***/ if (CyberGfxBase && (GetBitMapAttr(gdo->do_BitMap,BMA_FLAGS) & BMF_STANDARD) == 0L) { struct BitMap tbm; ULONG col; InitBitMap(&tbm,1,width,height); tbm.Planes[0] = (UBYTE *)gdo->do_FullShadow; /* if (!GetCyberMapAttr(gdo->do_BitMap, CYBRMATTR_PIXELFMT)) */ if (GetBitMapAttr(gdo->do_BitMap, BMA_DEPTH) > 8L) { ULONG triplet[3]; GetRGB32(scr->ViewPort.ColorMap,0L,1L,triplet); col = (triplet[0] & 0xff0000) | (triplet[1] & 0xff00) | (triplet[2] & 0xff); } else col = 0; // ExtractColor(rp,&tbm,col,xpos,ypos,width,height); ExtractColor(&gdo->do_RPort,&tbm,col,0,0,width,height); BltBitMap(&tbm,0,0,&tbm,0,0,width,height,0x50,0xff,NULL); // invertieren der Maske } else { UWORD *p = gdo->do_FullShadow; for(ypos = 0;ypos < height;ypos++) { for(xpos = 0;xpos < wordwidth;xpos++,p++) { for(i = 0;i < depth;i++) *p |= *((UWORD *)gdo->do_BitMap->Planes[i]+ypos*(gdo->do_BitMap->BytesPerRow >> 1)+xpos); } } } { UWORD *p = gdo->do_HalfShadow; CopyMem(gdo->do_FullShadow,p,2*wordwidth*height); for(line = 0x5555,ypos = 0;ypos < height;ypos++) { line = ~line; for(xpos = 0;xpos < wordwidth;xpos++,p++) *p &= (UWORD)line; } } if (!boopsigad) FakeInputEvent(); UpdateDragObj(gdo,gdo->do_X,gdo->do_Y); /* show drag object */ return(gdo); }
INTERNALS HISTORY *****************************************************************************/ { AROS_LIBFUNC_INIT /* First allocate a BitMap where the BitMap Data of the RastPort's bitmap will go into. */ struct BitMap * NewBM; NewBM = AllocBitMap(GetBitMapAttr(cr->BitMap, BMA_WIDTH) + 16, GetBitMapAttr(cr->BitMap, BMA_HEIGHT), GetBitMapAttr(cr->BitMap, BMA_DEPTH), 0, rp->BitMap); /* Save the displayed bitmap area to the new BitMap */ BltBitMap(rp->BitMap, cr->bounds.MinX, cr->bounds.MinY, NewBM, ALIGN_OFFSET(cr->bounds.MinX), 0, cr->bounds.MaxX - cr->bounds.MinX + 1,
int GetBitMapInfoA(struct BitMap *bm, UWORD displayID, TAGLIST tags) { int count = 0; if (bm) { BOOL cyberbitmap = FALSE; LONG depth; LONG *p; depth = GetBitMapAttr(bm, BMA_DEPTH); if (CyberGfxBase) { if (GetCyberMapAttr(bm, CYBRMATTR_ISCYBERGFX)) { cyberbitmap = TRUE; depth = GetCyberMapAttr(bm, CYBRMATTR_DEPTH); } } if (p = (LONG *) GetTagData(BMAPATTR_Width, NULL, tags)) { *p = GetBitMapAttr(bm, BMA_WIDTH); count++; } if (p = (LONG *) GetTagData(BMAPATTR_Height, NULL, tags)) { *p = GetBitMapAttr(bm, BMA_HEIGHT); count++; } if (p = (LONG *) GetTagData(BMAPATTR_Depth, NULL, tags)) { *p = depth; count++; } if (p = (LONG *) GetTagData(BMAPATTR_CyberGFX, NULL, tags)) { *p = (LONG) cyberbitmap; count++; } if (p = (LONG *) GetTagData(BMAPATTR_BitMapFormat, NULL, tags)) { if (cyberbitmap) { if (depth > 8) { *p = PIXFMT_BITMAP_RGB; } else { *p = PIXFMT_BITMAP_CLUT; } } else { if ((displayID != INVALID_ID) && (displayID & HAM)) { switch (depth) { case 8: *p = PIXFMT_BITMAP_HAM8; break; case 6: *p = PIXFMT_BITMAP_HAM6; break; default: *p = PIXFMT_BITMAP_CLUT; } } else { *p = PIXFMT_BITMAP_CLUT; } } count++; } if (p = (LONG *) GetTagData(BMAPATTR_PixelFormat, NULL, tags)) { LONG bf; GetBitMapInfo(bm, displayID, BMAPATTR_BitMapFormat, &bf, TAG_DONE); switch (bf) { case PIXFMT_BITMAP_HAM6: case PIXFMT_BITMAP_HAM8: case PIXFMT_BITMAP_RGB: *p = PIXFMT_0RGB_32; break; default: case PIXFMT_BITMAP_CLUT: *p = PIXFMT_CHUNKY_CLUT; break; } count++; } if (p = (LONG *) GetTagData(BMAPATTR_Flags, NULL, tags)) { *p = GetBitMapAttr(bm, BMA_FLAGS); count++; } } return count; }
IPTR Colorfield__OM_SET(struct IClass *cl, Object *obj, struct opSet *msg) { struct Colorfield_DATA *data; const struct TagItem *tags; struct TagItem *tag; ULONG *rgb; BOOL newcol = FALSE; IPTR retval; data = INST_DATA(cl, obj); for (tags = msg->ops_AttrList; (tag = NextTagItem(&tags)); ) { switch (tag->ti_Tag) { case MUIA_Colorfield_Red: data->rgb[0] = (ULONG)tag->ti_Data; newcol = TRUE; break; case MUIA_Colorfield_Green: data->rgb[1] = (ULONG)tag->ti_Data; newcol = TRUE; break; case MUIA_Colorfield_Blue: data->rgb[2] = (ULONG)tag->ti_Data; newcol = TRUE; break; case MUIA_Colorfield_RGB: rgb = (ULONG *)tag->ti_Data; data->rgb[0] = *rgb++; data->rgb[1] = *rgb++; data->rgb[2] = *rgb++; newcol = TRUE; break; case MUIA_Colorfield_Pen: if (data->flags & FLAG_PEN_ALLOCATED) { ReleasePen(_screen(obj)->ViewPort.ColorMap, data->pen); data->flags &= ~(FLAG_PEN_ALLOCATED | FLAG_NO_PEN); } data->pen = (UBYTE)data->pen; data->flags |= FLAG_FIXED_PEN; break; } } retval = DoSuperMethodA(cl, obj, (Msg)msg); if (newcol && (_flags(obj) & MADF_SETUP) && !(data->flags & FLAG_NO_PEN)) { SetRGB32(&_screen(obj)->ViewPort, data->pen, data->rgb[0], data->rgb[1], data->rgb[2]); if (GetBitMapAttr(_rp(obj)->BitMap, BMA_DEPTH) > 8) { MUI_Redraw(obj, MADF_DRAWUPDATE); } } return retval; }
static VOID bltpattern_amiga(struct pattern_info *pi , struct BitMap *dest_bm , LONG x_src, LONG y_src /* offset into layer */ , LONG x_dest, LONG y_dest /* offset into bitmap */ , ULONG xsize, LONG ysize , struct GfxBase *GfxBase ) { /* x_src, y_src is the coordinates int the layer. */ LONG y; struct RastPort *rp = pi->rp; ULONG apen = GetAPen(rp); ULONG bpen = GetBPen(rp); UBYTE *apt = (UBYTE *)rp->AreaPtrn; UBYTE dest_depth = GetBitMapAttr(dest_bm, BMA_DEPTH); for (y = 0; y < ysize; y ++) { LONG x; for (x = 0; x < xsize; x ++) { ULONG set_pixel; ULONG pixval; /* Mask supplied ? */ if (pi->mask) { ULONG idx, mask; idx = COORD_TO_BYTEIDX(x + pi->mask_xmin, y + pi->mask_ymin, pi->mask_bpr); mask = XCOORD_TO_MASK(x + pi->mask_xmin); set_pixel = pi->mask[idx] & mask; } else set_pixel = 1UL; if (set_pixel) { if (apt) { set_pixel = pattern_pen(rp, x + x_src, y + y_src, apen, bpen, &pixval, GfxBase); if (set_pixel) { setbitmappixel(dest_bm, x + x_dest, y + y_dest, pixval, dest_depth, 0xFF); } } } /* if (pixel should be set */ } /* for (each column) */ } /* for (each row) */ return; }
grArosSurface* init_surface( grArosSurface* surface, grBitmap* bitmap ) { printf("init_surface: width = %d height = %d\n", bitmap->width, bitmap->rows); bitmap->width = (bitmap->width + 15) & ~15; surface->bpr = bitmap->width / 8; if (grNewBitmap(bitmap->mode, bitmap->grays, bitmap->width, bitmap->rows, bitmap)) return 0; surface->win = OpenWindowTags(0, WA_Left, 20, WA_Top, 20, WA_InnerWidth, bitmap->width, WA_InnerHeight, bitmap->rows, WA_AutoAdjust, TRUE, WA_Title, "Freetype demo", WA_CloseGadget, TRUE, WA_DepthGadget, TRUE, WA_Activate, TRUE, WA_IDCMP, IDCMP_VANILLAKEY | IDCMP_RAWKEY, TAG_DONE); if (!surface->win) { puts("Could not open window!"); grDoneBitmap(bitmap); return 0; } puts("Window opened."); surface->grays = ( bitmap->mode == gr_pixel_mode_gray && bitmap->grays >= 2 ); if (surface->grays) { WORD i; if (GetBitMapAttr(surface->win->RPort->BitMap, BMA_DEPTH <= 8)) { puts("Need hi/true color screen!"); CloseWindow(surface->win); grDoneBitmap(bitmap); return 0; } for(i = 0; i < bitmap->grays; i++) { LONG red, green, blue; red = green = blue = (bitmap->grays - i) * 255 / bitmap->grays; surface->cgfxcoltab[i] = (red << 16) | (green << 8) | blue; } } surface->root.bitmap = *bitmap; surface->root.done = (grDoneSurfaceFunc) done_surface; surface->root.refresh_rect = (grRefreshRectFunc) refresh_rectangle; surface->root.set_title = (grSetTitleFunc) set_title; surface->root.listen_event = (grListenEventFunc) listen_event; return surface; }
static VOID bltmask_amiga(struct bltmask_info *bmi , LONG x_src, LONG y_src , struct BitMap *destbm , LONG x_dest, LONG y_dest , ULONG xsize, ULONG ysize , ULONG minterm ) { /* x_src, y_src is the coordinates int the layer. */ LONG y; UBYTE src_depth, dest_depth; EnterFunc(bug("bltmask_amiga(%p, %d, %d, %d, %d, %d, %d, %p)\n" , bmi, x_src, y_src, x_dest, y_dest, xsize, ysize)); src_depth = GetBitMapAttr(bmi->srcbm, BMA_DEPTH); dest_depth = GetBitMapAttr(destbm, BMA_DEPTH); for (y = 0; y < ysize; y ++) { LONG x; for (x = 0; x < xsize; x ++) { ULONG set_pixel; ULONG idx, mask; idx = COORD_TO_BYTEIDX(x + bmi->mask_xmin, y + bmi->mask_ymin, bmi->mask_bpr); mask = XCOORD_TO_MASK(x + bmi->mask_xmin); set_pixel = bmi->mask[idx] & mask; if (set_pixel) { ULONG srcpen, destpen, pixval; srcpen = getbitmappixel(bmi->srcbm , x + x_src , y + y_src , src_depth , 0xFF ); /* Could optimize plain copy (0x00C0) here. (does not nead to get dest) and clear (0x0000) (needs neither src or dest)*/ destpen = getbitmappixel(destbm , x + x_dest , y + y_dest , dest_depth , 0xFF ); APPLY_MINTERM(pixval, srcpen, destpen, minterm); setbitmappixel(destbm , x + x_dest , y + y_dest , pixval , dest_depth , 0xFF ); } } /* for (each column) */ } /* for (each row) */ ReturnVoid("bltmask_amiga"); }
static VOID blttemplate_amiga(PLANEPTR source, LONG x_src, LONG modulo, struct BitMap *dest , LONG x_dest, LONG y_dest, ULONG xsize, ULONG ysize, struct RastPort *rp, struct GfxBase *GfxBase) { UBYTE *srcptr; UBYTE dest_depth = GetBitMapAttr(dest, BMA_DEPTH); UWORD drmd = GetDrMd(rp); UBYTE apen = GetAPen(rp); UBYTE bpen = GetBPen(rp); LONG x, y; /* Find the exact startbyte. x_src is max 15 */ srcptr = ((UBYTE *)source) + XCOORD_TO_BYTEIDX(x_src); /* Find the exact startbit */ x_src &= 0x07; /* kprintf("DRMD: %d, APEN: %d, BPEN: %d\n", drmd, apen, bpen); */ for (y = 0; y < ysize; y ++) { UBYTE *byteptr = srcptr; for (x = 0; x < xsize; x ++) { UBYTE pen; UBYTE mask = XCOORD_TO_MASK( x + x_src ); BOOL is_set = ((*byteptr & mask) ? TRUE : FALSE); BOOL set_pixel = FALSE; /*if (is_set) kprintf("X"); else kprintf("0"); */ if (drmd & INVERSVID) { is_set = ((is_set == TRUE) ? FALSE : TRUE); } if (drmd & JAM2) { /* Use apen if pixel is et, bpen otherwise */ if (is_set) pen = apen; else pen = bpen; set_pixel = TRUE; } else if (drmd & COMPLEMENT) { pen = getbitmappixel(dest , x + x_dest , y + y_dest , dest_depth , 0xFF ); pen = ~pen; } else /* JAM 1 */ { /* Only use apen if pixel is set */ if (is_set) { pen = apen; set_pixel = TRUE; } } if (set_pixel) { /* kprintf("X"); */ setbitmappixel(dest , x + x_dest , y + y_dest , pen , dest_depth, 0xFF ); } /* else kprintf("0"); */ /* Last pixel in this byte ? */ if (((x + x_src) & 0x07) == 0x07) byteptr ++; } /* kprintf("\n"); */ srcptr += modulo; } return; }
// Load a backfill pattern; pattern must be locked exclusively void GetPattern(PatternData *pattern,struct Screen *screen,ULONG border_col) { // Initially make invalid pattern->valid=FALSE; pattern->border_pen=0; // Set screen pointer pattern->screen=screen; // Check for invalid data if (!pattern->data) { // Update border pen GetPatternBorder(pattern,screen,border_col); return; } // Bitmap pattern? if (pattern->prefs.wbp_Flags&WBPF_PATTERN) { UWORD *ptr,*planes[MAXDEPTH]; short num,row,col,pen; // Get plane pointers for (num=0;num<pattern->prefs.wbp_Depth;num++) { planes[num]=((UWORD *)pattern->data)+(PAT_HEIGHT*num); } pattern->fill_plane_key=0; // Clear fill initially for (num=0,ptr=pattern->fill[0];num<128;num++,ptr++) *ptr=0; // Under 37 use fill pattern as supplied if (((struct Library *)GfxBase)->lib_Version<39) { for (num=0;num<pattern->prefs.wbp_Depth;num++) { CopyMem( (char *)planes[num], (char *)pattern->fill[num], PAT_HEIGHT*sizeof(UWORD)); } pattern->fill_plane_key=pattern->prefs.wbp_Depth; } // Otherwise, we need to remap else { // Go through pattern rows for (row=0;row<PAT_HEIGHT;row++) { // Go through bits for (col=0;col<PAT_WIDTH;col++) { // Clear pen pen=0; // Calculate pixel colour for (num=0;num<pattern->prefs.wbp_Depth;num++) { // Is bit set in this bitplane? if (planes[num][row]&(1<<col)) pen|=(1<<num); } // Pixel set? if (pen) { // Map pens 4-7 to top four colours if (pen>=4 && screen->RastPort.BitMap->Depth<=8) { pen=(1<<screen->RastPort.BitMap->Depth)-(8-pen); } // Remap for (num=0;num<8;num++) { // Want this bit? if (pen&(1<<num)) { // Set bit pattern->fill[num][row]|=1<<col; if (num>=pattern->fill_plane_key) pattern->fill_plane_key=num+1; } } } } } } // Any data? if (pattern->fill_plane_key>0) { short depth; // Get depth for bitmap if (((struct Library *)GfxBase)->lib_Version>=39) depth=GetBitMapAttr(screen->RastPort.BitMap,BMA_DEPTH); else depth=screen->RastPort.BitMap->Depth; // Check its not too deep if (depth>8) depth=8; // Allocate bitmap for pattern if ((pattern->pattern_bitmap= NewBitMap( PATTILE_SIZE, PATTILE_SIZE, depth, BMF_CLEAR, 0))) { struct RastPort rp; struct BitMap *bitmap; // Initialise dummy rastport InitRastPort(&rp); rp.BitMap=pattern->pattern_bitmap; // Set fill pattern SetAfPt(&rp,pattern->fill[0],-4); // Fill bitmap SetRast(&rp,0); RectFill(&rp,0,0,PATTILE_SIZE-1,PATTILE_SIZE-1); // Is the screen a non-standard bitmap? if (((struct Library *)GfxBase)->lib_Version>=39 && !(GetBitMapAttr(screen->RastPort.BitMap,BMA_FLAGS)&BMF_STANDARD)) { // Try and allocate friend bitmap if ((bitmap= NewBitMap( PATTILE_SIZE, PATTILE_SIZE, depth, BMF_CLEAR, screen->RastPort.BitMap))) { // Copy to friend bitmap BltBitMap( pattern->pattern_bitmap,0,0, bitmap,0,0, PATTILE_SIZE,PATTILE_SIZE, 0xc0,0xff,0); // Free original bitmap DisposeBitMap(pattern->pattern_bitmap); // Use new bitmap pointer pattern->pattern_bitmap=bitmap; } } // Get bitmap pointer pattern->bitmap=pattern->pattern_bitmap; // Get pattern size pattern->width=PATTILE_SIZE; pattern->height=PATTILE_SIZE; } } } // Picture; must have datatypes else if (DataTypesBase) { short len; BOOL remap=1; long precision=PRECISION_IMAGE; char name[256]; long ver=0; struct Library *pdt; #ifdef PATCH_OK APTR patchhandle=0; #endif // Check picture datatype version if ((pdt=OpenLibrary("sys:classes/datatypes/picture.datatype",0)) || (pdt=OpenLibrary("picture.datatype",0))) { // Get version ver=pdt->lib_Version; CloseLibrary(pdt); } // No remap? if ((len=strlen(pattern->data))>8 && stricmp(pattern->data+len-8,".noremap")==0) remap=0; // Precision? if (len>6 && stricmp(pattern->data+len-6,".exact")==0) precision=PRECISION_EXACT; // Specified in prefs? else if (pattern->precision) { if (pattern->precision==-1) remap=0; else if (pattern->precision==1) precision=PRECISION_ICON; else if (pattern->precision==2) precision=PRECISION_GUI; else if (pattern->precision==3) precision=PRECISION_EXACT; } #ifdef PATCH_OK // If we've got v43 of the datatype, we don't need the fastram patch if (ver<43) { // Add this task to the patchlist for allocbitmap patchhandle=AddAllocBitmapPatch(FindTask(0),screen); } #endif // Turn back on requesters ((struct Process *)FindTask(0))->pr_WindowPtr=GUI->window; // Check for random pictures, and then load picture if (pattern_check_random(pattern,name) && (pattern->object= NewDTObject(name, DTA_GroupID,GID_PICTURE, PDTA_Screen,screen, PDTA_FreeSourceBitMap,TRUE, (ver>42)?PDTA_DestMode:TAG_IGNORE,MODE_V43, (ver>42)?PDTA_UseFriendBitMap:TAG_IGNORE,TRUE, TAG_END))) { struct BitMapHeader *header; struct BitMap *bitmap; D_S(struct FileInfoBlock, fib) // Get file information if (GetFileInfo(name,fib) && strnicmp(fib->fib_Comment,"dopus ",6)==0) { char *args=fib->fib_Comment+6; short val; rexx_skip_space(&args); while ((val=rexx_match_keyword(&args,background_key,0))!=-1) { // Tile/center/stretch if (val==3) pattern->flags&=~(PATF_CENTER|PATF_STRETCH); else if (val==4) { pattern->flags|=PATF_CENTER; pattern->flags&=~PATF_STRETCH; } else if (val==5 && pattern->prefs.wbp_Which==0) { pattern->flags|=PATF_STRETCH; pattern->flags&=~PATF_CENTER; } // Precision else if (val==6) { // Get precision rexx_skip_space(&args); if ((val=rexx_match_keyword(&args,precision_key,0))>-1) { if (val==0) remap=0; else if (val==1) precision=PRECISION_GUI; else if (val==2) precision=PRECISION_ICON; else if (val==3) precision=PRECISION_IMAGE; else if (val==4) precision=PRECISION_EXACT; } } // Border else if (val==8) { // Off? rexx_skip_space(&args); if (rexx_match_keyword(&args,on_off_strings2,0)==0) border_col&=~ENVBF_USE_COLOUR; else { border_col=ENVBF_USE_COLOUR; border_col|=Atoh(args,-1)<<8; } } } } // Layout picture (should check for success) SetDTAttrs(pattern->object,0,0, OBP_Precision,precision, PDTA_Remap,remap, TAG_END); DoMethod(pattern->object,DTM_PROCLAYOUT,0,1); // Get bitmap pointer and header GetDTAttrs(pattern->object, PDTA_BitMap,&bitmap, PDTA_DestBitMap,&pattern->bitmap, PDTA_BitMapHeader,&header, TAG_END); // No dest bitmap? if (!pattern->bitmap) pattern->bitmap=bitmap; // Valid bitmap? if (pattern->bitmap) { // Get width and height pattern->width=header->bmh_Width; pattern->height=header->bmh_Height; } } // Turn off requesters ((struct Process *)FindTask(0))->pr_WindowPtr=(APTR)-1; #ifdef PATCH_OK // Remove this task from the patchlist for allocbitmap if (patchhandle) RemAllocBitmapPatch(patchhandle); #endif // Got bitmap? if (pattern->bitmap) { // Stretch? if (pattern->flags&PATF_STRETCH) { // Not the size of the screen? if (pattern->width!=screen->Width || pattern->height!=screen->Height) { // Allocate a bitmap for the stretched picture if ((pattern->pattern_bitmap= NewBitMap( screen->Width, screen->Height, GetBitMapAttr(pattern->bitmap,BMA_DEPTH), BMF_CLEAR, screen->RastPort.BitMap))) { struct BitScaleArgs scale; // Scale bitmap scale.bsa_SrcX=0; scale.bsa_SrcY=0; scale.bsa_SrcWidth=pattern->width; scale.bsa_SrcHeight=pattern->height; scale.bsa_DestX=0; scale.bsa_DestY=0; scale.bsa_DestWidth=screen->Width; scale.bsa_DestHeight=screen->Height; scale.bsa_XSrcFactor=scale.bsa_SrcWidth; scale.bsa_XDestFactor=scale.bsa_DestWidth; scale.bsa_YSrcFactor=scale.bsa_SrcHeight; scale.bsa_YDestFactor=scale.bsa_DestHeight; scale.bsa_SrcBitMap=pattern->bitmap; scale.bsa_DestBitMap=pattern->pattern_bitmap; scale.bsa_Flags=0; BitMapScale(&scale); // Get pointer to scaled bitmap pattern->bitmap=pattern->pattern_bitmap; pattern->width=screen->Width; pattern->height=screen->Height; } } } } // Update border pen GetPatternBorder(pattern,screen,border_col); } // Pattern ok now pattern->valid=TRUE; }
void *Sys_Video_Open(const char *mode, unsigned int width, unsigned int height, int fullscreen, unsigned char *palette) { struct display *d; struct modeinfo modeinfo; char monitorname[128]; char *p; int r; int i; d = AllocVec(sizeof(*d), MEMF_CLEAR); if (d) { if (IntuitionBase->LibNode.lib_Version > 50 || (IntuitionBase->LibNode.lib_Version == 50 && IntuitionBase->LibNode.lib_Revision >= 74)) { d->gammaenabled = 1; } TinyGLBase = OpenLibrary("tinygl.library", 0); if (TinyGLBase) { if (fullscreen) { if (*mode && modeline_to_modeinfo(mode, &modeinfo)) { snprintf(monitorname, sizeof(monitorname), "%s.monitor", modeinfo.monitorname); d->screen = OpenScreenTags(0, SA_Width, modeinfo.width, SA_Height, modeinfo.height, SA_Depth, modeinfo.depth, SA_MonitorName, monitorname, SA_Quiet, TRUE, SA_GammaControl, TRUE, SA_3DSupport, TRUE, TAG_DONE); } else { d->screen = OpenScreenTags(0, SA_Quiet, TRUE, SA_GammaControl, TRUE, SA_3DSupport, TRUE, TAG_DONE); } if (d->screen) { width = d->screen->Width; height = d->screen->Height; strlcpy(monitorname, "Dunno", sizeof(monitorname)); if (IntuitionBase->LibNode.lib_Version > 50 || (IntuitionBase->LibNode.lib_Version == 50 && IntuitionBase->LibNode.lib_Revision >= 53)) { GetAttr(SA_MonitorName, d->screen, &p); if (p) { strlcpy(monitorname, p, sizeof(monitorname)); p = strstr(monitorname, ".monitor"); if (p) *p = 0; } } snprintf(d->used_mode, sizeof(d->used_mode), "%s,%d,%d,%d", monitorname, width, height, GetBitMapAttr(d->screen->RastPort.BitMap, BMA_DEPTH)); if (d->gammaenabled) { d->gammatable = AllocVec(256*3, MEMF_ANY); if (d->gammatable == 0) { CloseScreen(d->screen); d->screen = 0; } } } else fullscreen = 0; } if (d->screen || !fullscreen) { d->window = OpenWindowTags(0, WA_InnerWidth, width, WA_InnerHeight, height, WA_Title, "Fodquake", WA_DragBar, d->screen?FALSE:TRUE, WA_DepthGadget, d->screen?FALSE:TRUE, WA_Borderless, d->screen?TRUE:FALSE, WA_RMBTrap, TRUE, d->screen?WA_PubScreen:TAG_IGNORE, (ULONG)d->screen, WA_Activate, TRUE, TAG_DONE); if (d->window) { __tglContext = GLInit(); if (__tglContext) { if (d->screen && !(TinyGLBase->lib_Version == 0 && TinyGLBase->lib_Revision < 4)) { r = glAInitializeContextScreen(d->screen); } else { r = glAInitializeContextWindowed(d->window); } if (r) { d->pointermem = AllocVec(256, MEMF_ANY|MEMF_CLEAR); if (d->pointermem) { SetPointer(d->window, d->pointermem, 16, 16, 0, 0); d->width = width; d->height = height; d->fullscreen = fullscreen; d->inputdata = Sys_Input_Init(d->screen, d->window); if (d->inputdata) { return d; } FreeVec(d->pointermem); } if (d->screen && !(TinyGLBase->lib_Version == 0 && TinyGLBase->lib_Revision < 4)) glADestroyContextScreen(); else glADestroyContextWindowed(); } GLClose(__tglContext); } CloseWindow(d->window); } if (d->screen) CloseScreen(d->screen); } CloseLibrary(TinyGLBase); } FreeVec(d); } return 0; }