Beispiel #1
0
bool InitDisplay(int width, int height, int depth) {
  if (!Display) {
    size_t i, j;

    Display = NewRecord(DisplayT);

    for (i = 0; i < 2; i++)
      Display->Bitmap[i] = AllocBitMap(width, height, depth,
                                       BMF_DISPLAYABLE|BMF_CLEAR, NULL);

    Display->Palette = NewRecord(ScreenPaletteT);
    Display->Palette->Count = 256;

    for (i = 0, j = 0; i < 256; i++) {
      Display->Palette->Colors[j++] = i << 24;
      Display->Palette->Colors[j++] = i << 24;
      Display->Palette->Colors[j++] = i << 24;
    }

    ScreenTags[0].ti_Data = width;
    ScreenTags[1].ti_Data = height;
    ScreenTags[2].ti_Data = depth;
    ScreenTags[3].ti_Data = (ULONG)Display->Bitmap[0];
    ScreenTags[4].ti_Data = (ULONG)Display->Palette;

    if ((Display->Screen = OpenScreenTagList(0L, ScreenTags))) {
      return TRUE;
    } else {
      KillDisplay();
    }
  }

  return FALSE;
}
Beispiel #2
0
static struct Screen *createIntuitionScreen(const ILBM_Image *image, const amiVideo_Long viewportMode)
{
    UWORD pens[] = { ~0 };
    
    struct Rectangle dclip = { 0, 0, image->bitMapHeader->pageWidth, image->bitMapHeader->pageHeight };
    
    struct TagItem screenTags[] = {
        {SA_Width, image->bitMapHeader->w},
        {SA_Height, image->bitMapHeader->h},
        {SA_Depth, image->bitMapHeader->nPlanes},
        {SA_Title, "ILBM viewer"},
        {SA_Pens, pens},
        {SA_FullPalette, TRUE},
        {SA_Type, CUSTOMSCREEN},
        {SA_DisplayID, viewportMode},
        {SA_DClip, &dclip},
        {SA_AutoScroll, TRUE},
        {TAG_DONE, NULL}
    };
    
    return OpenScreenTagList(NULL, screenTags);
}
Beispiel #3
0
int
consinit() {
	struct Screen *s = 0;
	struct Window *w = 0;

	IntuitionBase = OpenLibrary("intuition.library", 36L);
	if (IntuitionBase == 0)
		goto err;

	s = OpenScreenTagList(0, screentags);
	if (!s)
		goto err;

	windowtags[1] = (u_int32_t)s;
	w = OpenWindowTagList(0, windowtags);
	if (!w)
		goto err;

	cnmp = CreateMsgPort();

	if (!cnmp)
		goto err;

	cnior = (struct AmigaIO *)CreateIORequest(cnmp, sizeof(struct AmigaIO));
	if (!cnior)
		goto err;

	cnior->buf = (void *)w;
	if (OpenDevice("console.device", 0, cnior, 0))
		goto err;

	tmior = (struct TimerIO *)CreateIORequest(cnmp, sizeof(struct TimerIO));
	if (!tmior)
		goto err;

	if (OpenDevice("timer.device", 0, (struct AmigaIO*)tmior, 0))
		goto err;

	return 0;

err:
#ifdef notyet
	if (tmior)
		DeleteIORequest(tmior);

	if (cnior)
		DeleteIORequest(cnior);

	if (cnmp)
		DeleteMsgPort(cnmp);

	if (w)
		CloseWindow(w);

	if (s)
		CloseScreen(s);
	if (IntuitionBase)
		CloseLibrary(IntuitionBase);
#endif

	return 1;
}
Beispiel #4
0
int
consinit(void *consptr) {
	struct Console *mc;

	if (consptr != NULL) {
		/* Check magic? */
		ConsoleBase = consptr;		/* Use existing console */
		return (0);
	}

	mc = &myConsole;
	IntuitionBase = OpenLibrary("intuition.library", 36L);
	if (IntuitionBase == 0)
		goto err;

	mc->s = OpenScreenTagList(0, screentags);
	if (!mc->s)
		goto err;

	windowtags[1] = (u_int32_t)mc->s;
	mc->w = OpenWindowTagList(0, windowtags);
	if (!mc->w)
		goto err;

	mc->cnmp = CreateMsgPort();

	if (!mc->cnmp)
		goto err;

	mc->cnior = (struct AmigaIO *)CreateIORequest(mc->cnmp, sizeof(struct AmigaIO));
	if (!mc->cnior)
		goto err;

	mc->cnior->buf = (void *)mc->w;
	if (OpenDevice("console.device", 0, mc->cnior, 0))
		goto err;

	mc->tmior = (struct TimerIO *)CreateIORequest(mc->cnmp, sizeof(struct TimerIO));
	if (!mc->tmior)
		goto err;

	if (OpenDevice("timer.device", 0, (struct AmigaIO*)mc->tmior, 0))
		goto err;

#ifdef SERCONSOLE
	conspreinit();
	if (use_serconsole)
		RawIOInit();
#endif

	ConsoleBase = mc;
	return 0;

err:
#ifdef notyet
	if (mc->tmior)
		DeleteIORequest(mc->tmior);

	if (mc->cnior)
		DeleteIORequest(mc->cnior);

	if (mc->cnmp)
		DeleteMsgPort(mc->cnmp);

	if (mc->w)
		CloseWindow(mc->w);

	if (mc->s)
		CloseScreen(mc->s);
	if (IntuitionBase)
		CloseLibrary(IntuitionBase);
#endif

	return 1;
}
Beispiel #5
0
static Object *bitmap_new(Class *cl, Object *obj, struct pRoot_New *msg)
{
    struct TagItem tags[] = {
                             {aHidd_BitMap_AllocBuffer, FALSE      },
                             {TAG_MORE                , (IPTR) NULL}
                            };

    struct HIDDBitMapAmigaIntuiData *data;
    struct TagItem *tag, *tstate, *newTagList;
    BOOL   ok = FALSE;

    struct pRoot_New               new_msg;
    struct pHidd_BitMap_PrivateSet private_set_msg;

    ULONG width, height, depth, format;
    BOOL  displayable;

    EnterFunc(bug("BitMapAmigaIntui::New()\n"));

    new_msg.mID         = GetMethodID(IID_Root, moRoot_New);
    private_set_msg.mID = GetMethodID(IID_Hidd_BitMap, moHidd_BitMap_PrivateSet);


    displayable = (BOOL) GetTagData(aHidd_BitMap_Displayable, 0, msg->attrList);
    if(!displayable)
    {
        /* let the superclass do all work */

        obj = (Object *) DoSuperMethod(cl, obj, (Msg) msg);
        if(obj) ok = TRUE;
    }
    else
    {
        /*
            aHidd_BitMap_AllocBuffer and aHidd_BitMap_Displayable must be
            FALSE. To make this easy first a copy of the taglist is
            created. In the new list Hidd_BitMap_Displayable is set to
            FALSE. If the taglist contains a "aHidd_BitMap_AllocBuffer"
            tag then ti_Data is set to FALSE else tags(see above) is
            connected with the new list.

            NOTE: If msg.attrList contains more than one
                  "aHidd_BitMap_AllocBuffer" we have a problem.
        */

        newTagList = CloneTagItems(msg->attrList);
        if(newTagList)
        {
            tag = FindTagItem(aHidd_BitMap_Displayable, newTagList);
            if(tag)
            {
                tag->ti_Data     = FALSE;
            }

            tag = FindTagItem(aHidd_BitMap_AllocBuffer, newTagList);
            if(tag)
            {
                tag->ti_Data     = FALSE;
                new_msg.attrList = newTagList;
            }
            else
            {
                tags[1].ti_Data  = (IPTR) newTagList;
                new_msg.attrList = tags;
            }

            obj  = (Object *) DoSuperMethod(cl, obj, (Msg) &new_msg);

            FreeTagItems(newTagList);
        }

        if(obj)
        {
            data = INST_DATA(cl, obj);
        
            /* clear all data and set some default values */
            memset(data, 0, sizeof(struct HIDDBitMapAmigaIntuiData));

            GetAttr(obj, aHidd_BitMap_Width,  &width);
            GetAttr(obj, aHidd_BitMap_Height, &height);
            GetAttr(obj, aHidd_BitMap_Depth,  &depth);
            GetAttr(obj, aHidd_BitMap_Format, &format);

            if(format == vHIDD_BitMap_Format_Planar)
            {
                /* only displayable support for planar format */

                struct TagItem tags[] =
                {
                    {SA_Left     , 0},
                    {SA_Top      , 0},
                    {SA_Width    , width},
                    {SA_Height   , height},
                    {SA_Depth    , depth},
                    {TAG_SKIP    , 1},      /* Use SA_DisplayID only wenn a display mode */
                    {SA_DisplayID, 0},      /* is specified                              */
                    {SA_Title    , (ULONG) "AROS graphics hidd"},
                    {SA_Type     , CUSTOMSCREEN},
            
                    /* Will be use later   */
                    /* SA_Quiet    , TRUE, */
                    /* SA_BitMap   , 0     On V37 double buffering could only
                                           implemented with a custom bitmap */
                    {TAG_DONE,   0}
                };
    
                data->screen = OpenScreenTagList(NULL, tags);
                if(data->screen)
                {
                    struct TagItem set[] =
                    {
                        {aHidd_BitMap_BaseAddress, (IPTR) &data->screen->RastPort.BitMap->Planes[0]},
                        {aHidd_BitMap_Format     , vHIDD_BitMap_Format_Planar},
                        {aHidd_BitMap_Displayable, TRUE                      },
                        {aHidd_BitMap_BytesPerRow, data->screen->RastPort.BitMap->BytesPerRow},
                        {TAG_END                 , 0                         }
                    };

                    private_set_msg.attrList = set;
                    DoSuperMethod(cl, obj, (Msg) &private_set_msg);
                    ok = TRUE;
                } /* if(data->screen) */
            } /* if(format == vHIDD_BitMap_Format_Planar) */
        } /* if(obj) */
    } /* if(!displayable) */

    /* free all on error */
    if(ok == FALSE)
    {
        if(obj) DisposeObject(obj);
        obj = NULL;
    }

    ReturnPtr("BitMapAmigaIntui::New", Object *, obj);
}
Beispiel #6
0
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 */