/* this source implements aMiPEG's interface to CyberGraphX */ #include #include #include #include #include #include #include #include #include #include #include #include "video.h" #include "proto.h" extern int ditherType; struct Library *CyberGfxBase; ULONG cyber_mode; ULONG depth; struct Screen *cyber_screen; struct Window *cyber_window; int original_x, original_y; extern UBYTE Cb_r_tab[2048]; static void Quit(char *why, int failcode) { puts(why); exit(failcode); } static void output_term(void) { if(cyber_window) CloseWindow(cyber_window); if(cyber_screen) CloseScreen(cyber_screen); if (CyberGfxBase) CloseLibrary(CyberGfxBase); if (IntuitionBase) CloseLibrary((struct Library *) IntuitionBase); } void DrawCyberGfxImage(void *data, int x, int y) { int win_x = cyber_window->Width - cyber_window->BorderLeft - cyber_window->BorderRight; int win_y = cyber_window->Height - cyber_window->BorderTop - cyber_window->BorderBottom; if(win_x == x && win_y == y) { if(ditherType == CYBERGFXGRAY_DITHER) WritePixelArray(data, 0, 0, x, cyber_window->RPort, cyber_window->BorderLeft, cyber_window->BorderTop, x, y, RECTFMT_GREY8); else WritePixelArray(data, 0, 0, x * 4, cyber_window->RPort, cyber_window->BorderLeft, cyber_window->BorderTop, x, y, RECTFMT_ARGB); } else { if(ditherType == CYBERGFXGRAY_DITHER) ScalePixelArray(data, x, y, x, cyber_window->RPort, cyber_window->BorderLeft, cyber_window->BorderTop, win_x, win_y, RECTFMT_GREY8); else ScalePixelArray(data, x, y, x * 4, cyber_window->RPort, cyber_window->BorderLeft, cyber_window->BorderTop, win_x, win_y, RECTFMT_ARGB); } } int handle_window(void) { struct IntuiMessage *imsg; struct IntuiMessage msg; static ULONG last_secs, last_micros; if(cyber_window) { while(imsg = (struct IntuiMessage *)GetMsg(cyber_window->UserPort)) { CopyMem((char *)imsg, (char *)&msg, (long)sizeof(struct IntuiMessage)); ReplyMsg((struct Message *)imsg); switch(msg.Class) { case IDCMP_CLOSEWINDOW: return(FALSE); case IDCMP_MOUSEBUTTONS: if(msg.Code == SELECTDOWN) { if(DoubleClick(last_secs, last_micros, msg.Seconds, msg.Micros)) ChangeWindowBox(cyber_window, cyber_window->LeftEdge, cyber_window->TopEdge, original_x, original_y); last_secs = msg.Seconds; last_micros = msg.Micros; } break; default: break; } } } return(TRUE); } BOOL init_cybergfx(void) { if(IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library",37)) if(CyberGfxBase = OpenLibrary("cybergraphics.library", 40)) return(TRUE); else Quit("cybergraphics.library v40+ not present", 25); else Quit("intuition.library is too old,