IPTR mDraw(Class *cl, Object *obj, struct MUIP_Draw *msg) { mybug(0, ("mDraw gets called\n")); struct InstData *data = INST_DATA(cl, obj); WORD y; IPTR retval; static ULONG sec=0, mic=0, lastTick=0, currTick=0; retval = DoSuperMethodA(cl, obj, (Msg)msg); if (!(msg->flags & (MADF_DRAWOBJECT | MADF_DRAWUPDATE))) return 0; if(data->ps3eye_ep1pipe) { for(y= 0; y < _mheight(obj); y++) { WORD col; col = ((y + data->pos) / 8) % 2; SetAPen(_rp(obj), _pens(obj)[col ? MPEN_SHADOW : MPEN_SHINE]); RectFill(_rp(obj), _mleft(obj), _mtop(obj) + y, _mright(obj), _mtop(obj) + y); } data->pos++; } else { /* Add static distortion or old crt-monitor effect */ if(data->resolutionvga) { DoEffect(kitty640_pure, kitty, 640, 480); WritePixelArray(kitty, 0, 0, 640*4, _rp(obj), _mleft(obj), _mtop(obj), _mwidth(obj), _mheight(obj), RECTFMT_RGB032); // WritePixelArray(kitty640_pure, 0, 0, 640*4, _rp(obj), _mleft(obj), _mtop(obj), _mwidth(obj), _mheight(obj), RECTFMT_RGB032); //+(rand() % (10)) } else { DoEffect(kitty320_pure, kitty, 320, 240); WritePixelArray(kitty, 0, 0, 320*4, _rp(obj), _mleft(obj), _mtop(obj), _mwidth(obj), _mheight(obj), RECTFMT_RGB032); } } //lastTick = currTick; //CurrentTime(&sec, &mic); //currTick = ((sec * 1000) + (mic / 1000)); //mybug(-1, ("Delta %d mS\n", currTick-lastTick)); return retval; }
static void action(void) { UBYTE *buf = AllocVec(SCREENWIDTH * SCREENHEIGHT * sizeof(ULONG), MEMF_PUBLIC); ULONG i; if (buf) { ReadPixelArray(buf, 0, 0, SCREENWIDTH * sizeof(ULONG), win->RPort, win->BorderLeft, win->BorderTop, SCREENWIDTH, SCREENHEIGHT, RECTFMT_ARGB); for(i = 0; i < SCREENWIDTH * SCREENHEIGHT * 4; i += 4) { buf[i + 1] /= 2; buf[i + 2] /= 2; buf[i + 3] /= 2; } WritePixelArray(buf, 0, 0, SCREENWIDTH * sizeof(ULONG), win->RPort, win->BorderLeft, win->BorderTop, SCREENWIDTH, SCREENHEIGHT, RECTFMT_ARGB); } while (!Keys[KC_ESC]) { WaitPort(win->UserPort); getevents(); } /* while(!Keys[KC_ESC]) */ if (buf) FreeVec(buf); }
VOID METHOD(VC4Gallium, Hidd_Gallium, DisplayResource) { struct RastPort * rp; #if (0) OOP_GetAttr(o, aHidd_Gallium_WinSys, &vc4_ws); if (vc4_ws) { if ((data == NULL) && (spr->dt != NULL)) data = vc4_ws->displaytarget_map(vc4_ws, spr->dt, 0); if (data) { rp = CreateRastPort(); rp->BitMap = msg->bitmap; WritePixelArray( data, msg->srcx, msg->srcy, spr->stride[0], rp, msg->dstx, msg->dsty, msg->width, msg->height, AROS_PIXFMT); FreeRastPort(rp); } if ((spr->data == NULL) && (data != NULL)) vc4_ws->displaytarget_unmap(vc4_ws, spr->dt); } #endif }
int main(int argc, char **argv) { ULONG DisplayID,Depth; struct Screen *CyberScreen; struct Window *WriteWindow; LONG done; struct IntuiMessage *IntMsg; IMAGE image; LONG src_x,src_y, old_src_x,old_src_y; ULONG argarray[2]; struct RDArgs *rdargs; char *file; rdargs = ReadArgs((STRPTR)arg_template, (LONG*)argarray, NULL); if(!rdargs) return 20; file = (char*)argarray[0]; IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",39L); if(!IntuitionBase) return 20; CyberGfxBase = OpenLibrary(CYBERGFXNAME,CYBERGFXVERSION); if(!CyberGfxBase) { ErrorF ("Can't open \"%s\" version %ld or newer.", CYBERGFXNAME,CYBERGFXVERSION); CloseLibrary (&IntuitionBase->LibNode); return 10; } if(!Load(file, &image)) { ErrorF ("Can't load image."); FreeArgs(rdargs); CloseLibrary (CyberGfxBase); CloseLibrary (&IntuitionBase->LibNode); return 10; } /* Let CyberGraphX search a display mode for us! */ if(argarray[1]) Depth = 16; else Depth = 24; FreeArgs(rdargs); while (Depth) { DisplayID = BestCModeIDTags(CYBRBIDTG_NominalWidth, image.width, CYBRBIDTG_NominalHeight, image.height, CYBRBIDTG_Depth, Depth, TAG_DONE); if(DisplayID != INVALID_ID) { /* Because older version of the "cybergraphics.library" don't handle */ /* CYBRBIDTG_Depth properly we query the real depth of the mode. */ Depth = GetCyberIDAttr(CYBRIDATTR_DEPTH,DisplayID); break; } /* retry with less bits per pixel */ Depth = NextDepth(Depth); } if (Depth < SCREEN_MIN_DEPTH) { ErrorF ("Can't find suitable display mode for %ldx%ldx.", image.width, image.height); CloseLibrary (CyberGfxBase); CloseLibrary (&IntuitionBase->LibNode); Cleanup(&image); return 5; } /* open screen, but let Intuition choose the actual dimensions */ CyberScreen = OpenScreenTags( NULL, SA_Title,"RayStorm Image Viewer (C) 1998 Andreas Heumann", SA_DisplayID,DisplayID, SA_Depth,Depth, TAG_DONE); if(!CyberScreen) { ErrorF ("Can't open screen."); CloseLibrary (CyberGfxBase); CloseLibrary (&IntuitionBase->LibNode); Cleanup(&image); return 5; } /* create Write window */ WriteWindow = OpenWindowTags( NULL, WA_Title,"Viewer", WA_Flags, WFLG_ACTIVATE|WFLG_SIMPLE_REFRESH|WFLG_RMBTRAP, WA_IDCMP, IDCMP_REFRESHWINDOW|IDCMP_VANILLAKEY|IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS, WA_Borderless, TRUE, WA_Left, 0, WA_Top, 0, WA_Width, image.width, WA_Height, image.height, WA_CustomScreen,CyberScreen, TAG_DONE); if(!WriteWindow) { ErrorF ("Can't open write window."); CloseScreen (CyberScreen); CloseLibrary (CyberGfxBase); CloseLibrary (&IntuitionBase->LibNode); Cleanup(&image); return 5; } src_x = 0; src_y = 0; WritePixelArray( image.colormap, src_x, src_y, image.width*sizeof(SMALL_COLOR), WriteWindow->RPort, 0, 0, image.width, image.height, RECTFMT_RGBA); /* event loop */ done = FALSE; while (!done) { (void)Wait(SIGMASK(WriteWindow)); while (IntMsg=GETIMSG(WriteWindow)) { switch (IntMsg->Class) { case IDCMP_REFRESHWINDOW: BeginRefresh(WriteWindow); WritePixelArray( image.colormap, src_x, src_y, image.width*sizeof(SMALL_COLOR), WriteWindow->RPort, 0, 0, image.width, image.height, RECTFMT_RGBA); EndRefresh(WriteWindow,TRUE); break; case IDCMP_VANILLAKEY: switch(IntMsg->Qualifier & 0x7fff) { case 0: switch (IntMsg->Code) { case 27: done = TRUE; break; } break; } break; case IDCMP_RAWKEY: old_src_x = src_x; old_src_y = src_y; switch(IntMsg->Code) { case CURSORRIGHT: if(src_x + WriteWindow->Width + WriteWindow->LeftEdge < image.width) { src_x += 8; if(src_x + WriteWindow->Width + WriteWindow->LeftEdge > image.width) src_x = image.width - WriteWindow->Width - WriteWindow->LeftEdge; } break; case CURSORLEFT: if(src_x > 0) { src_x -= 8; if(src_x < 0) src_x = 0; } break; case CURSORDOWN: if(src_y + WriteWindow->Height + WriteWindow->TopEdge < image.height) { src_y += 8; if(src_y + WriteWindow->Height + WriteWindow->TopEdge > image.height) src_y = image.height - WriteWindow->Height - WriteWindow->TopEdge; } break; case CURSORUP: if(src_y > 0) { src_y -= 8; if(src_y < 0) src_y = 0; } break; } if((old_src_x != src_x) || (old_src_y != src_y)) { if(old_src_x < src_x) { ClipBlit( WriteWindow->RPort, src_x - old_src_x, 0, WriteWindow->RPort, 0, 0, WriteWindow->Width + WriteWindow->LeftEdge - (src_x - old_src_x), WriteWindow->Height + WriteWindow->TopEdge, 0xc0); WritePixelArray( image.colormap, old_src_x + WriteWindow->Width + WriteWindow->LeftEdge, src_y, image.width*sizeof(SMALL_COLOR), WriteWindow->RPort, WriteWindow->Width + WriteWindow->LeftEdge - (src_x - old_src_x), 0, src_x - old_src_x, WriteWindow->Height + WriteWindow->TopEdge, RECTFMT_RGBA); } else if(old_src_x > src_x) { ClipBlit( WriteWindow->RPort, 0, 0, WriteWindow->RPort, old_src_x - src_x, 0, WriteWindow->Width + WriteWindow->LeftEdge - (old_src_x - src_x), WriteWindow->Height + WriteWindow->TopEdge, 0xc0); WritePixelArray( image.colormap, src_x, src_y, image.width*sizeof(SMALL_COLOR), WriteWindow->RPort, 0, 0, old_src_x - src_x, WriteWindow->Height + WriteWindow->TopEdge, RECTFMT_RGBA); } else if(old_src_y < src_y) { ClipBlit( WriteWindow->RPort, 0, src_y - old_src_y, WriteWindow->RPort, 0, 0, WriteWindow->Width + WriteWindow->LeftEdge, WriteWindow->Height + WriteWindow->TopEdge - (src_y - old_src_y), 0xc0); WritePixelArray( image.colormap, src_x, old_src_y + WriteWindow->Height + WriteWindow->TopEdge, image.width*sizeof(SMALL_COLOR), WriteWindow->RPort, 0, WriteWindow->Height + WriteWindow->TopEdge - (src_y - old_src_y), WriteWindow->Width + WriteWindow->LeftEdge, src_y - old_src_y, RECTFMT_RGBA); } else if(old_src_y > src_y) { ClipBlit( WriteWindow->RPort, 0, 0, WriteWindow->RPort, 0, old_src_y - src_y, WriteWindow->Width + WriteWindow->LeftEdge, WriteWindow->Height + WriteWindow->TopEdge - (old_src_y - src_y), 0xc0); WritePixelArray( image.colormap, src_x, src_y, image.width*sizeof(SMALL_COLOR), WriteWindow->RPort, 0, 0, WriteWindow->Width + WriteWindow->LeftEdge, old_src_y - src_y, RECTFMT_RGBA); } } break; case IDCMP_MOUSEBUTTONS: done = TRUE; break; } ReplyMsg (&IntMsg->ExecMessage); } } /* cleanup */ CloseWindow(WriteWindow); CloseScreen(CyberScreen); CloseLibrary(CyberGfxBase); CloseLibrary(&IntuitionBase->LibNode); Cleanup(&image); return 0; }