home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Enigma Amiga Life 106
/
EnigmaAmiga106CD.iso
/
indispensabili
/
grafica
/
amipeg_1.1
/
src
/
pivpip.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-12-06
|
5KB
|
224 lines
/* this source implements aMiPEG's interface to PicassoIVPIP */
#include <string.h>
#include <stdlib.h>
#include <exec/exec.h>
#include <intuition/intuition.h>
#include <intuition/screens.h>
#include <dos/dos.h>
#include <proto/graphics.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/dos.h>
#include <proto/Picasso96.h>
#include <proto/asyncio.h>
#include "video.h"
#include "proto.h"
extern int doneFlag;
extern int fullFlag;
extern int ditherType;
extern int cyber_pub;
extern struct GfxBase *GfxBase;
struct Library *P96Base;
extern ULONG cyber_mode;
extern ULONG depth;
extern struct Screen *cyber_screen;
extern struct Window *cyber_window;
struct RenderInfo RI;
extern int original_x, original_y;
static void Quit(char *why, int failcode)
{
puts(why);
exit(failcode);
}
static void output_term(void)
{
close_timer();
if(input)
{
CloseAsync(input);
input = NULL;
}
if(cyber_window)
p96PIP_Close(cyber_window);
if(!cyber_pub && cyber_screen)
CloseScreen(cyber_screen);
if (GfxBase) CloseLibrary((struct Library *)GfxBase);
if (P96Base) CloseLibrary(P96Base);
if (IntuitionBase) CloseLibrary((struct Library *) IntuitionBase);
}
void DrawP96Image(UWORD *data, int x, int y)
{
LONG lock;
struct BitMap *BM;
UWORD *address;
p96PIP_GetTags(cyber_window, P96PIP_SourceBitMap, (ULONG)&BM, TAG_END);
lock = p96LockBitMap(BM, (UBYTE *)&RI, sizeof(struct RenderInfo));
address = (UWORD *) RI.Memory;
for(; y > 0; y--)
{
memcpy(address, data, x << 1);
address += RI.BytesPerRow/2;
data += ((x + 15) >> 4) << 4;
}
p96UnlockBitMap(BM, lock);
}
int p96_handle_window(void)
{
struct IntuiMessage *imsg;
struct IntuiMessage msg;
static ULONG last_secs, last_micros;
if(cyber_window)
{
while(imsg = p96PIP_GetIMsg(cyber_window->UserPort))
{
CopyMem((char *)imsg, (char *)&msg, (long)sizeof(struct IntuiMessage));
p96PIP_ReplyIMsg(imsg);
switch(msg.Class)
{
case IDCMP_VANILLAKEY:
if(msg.Code == '\x1b' || msg.Code == 'q')
{
doneFlag = DONE_REALLY;
return(FALSE);
}
if(msg.Code == 13 || msg.Code == 32) /* space & return */
return(FALSE);
break;
case IDCMP_CLOSEWINDOW:
{
doneFlag = DONE_NOT_REALLY;
return(FALSE);
}
case IDCMP_MOUSEBUTTONS:
if(!fullFlag && 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_P96(void)
{
if(IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library",37))
if(P96Base = OpenLibrary("Picasso96API.library", 2))
if(P96Base->lib_Revision >= 165)
if(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 39))
return(TRUE);
else
Quit("graphics.library v39+ not present", 25);
else
Quit("Picasso96API.library v2.165 or higher not present", 25);
else
Quit("Picasso96API.library v2+ not present", 25);
else
Quit("intuition.library is too old, <V39", 25);
}
void CheckPIV(void)
{
if(!OpenResource("PicassoIV.resource"))
{
Quit("Sorry, but the option 'dither=pivpip' requires a PicassoIV graphicsboard !\n",25);
}
}
int get_P96_mode(void)
{
return((int)p96RequestModeIDTags(
P96MA_WindowTitle, "Select a screenmode for MPEG window",
P96MA_MinDepth, 8,
TAG_DONE));
}
unsigned long InitP96Display(unsigned long modeid)
{
WORD pens[] = { ~0 };
atexit(output_term);
if(init_P96())
{
if(cyber_pub || (modeid != 0xffffffff) || (modeid = get_P96_mode()) != 0xffffffff)
{
if(cyber_pub)
{
cyber_screen = LockPubScreen(pubname_ptr);
modeid = GetVPModeID(&cyber_screen->ViewPort);
ScreenToFront(cyber_screen);
UnlockPubScreen(NULL, cyber_screen);
}
cyber_mode = modeid;
depth = p96GetModeIDAttr(cyber_mode, P96IDA_DEPTH);
if(depth < 8 )
Quit("aMiPEG: this screen is not deep enough (needed at least 8 bits).", 25);
if(cyber_screen || (cyber_screen = OpenScreenTags(NULL,
SA_DisplayID, cyber_mode,
SA_Title, (UBYTE *)"aMiPEG 1.0 by Michael Rausch and Miloslaw Smyk",
SA_Depth, depth,
SA_Pens, &pens,
SA_SharePens, TRUE,
TAG_DONE)))
{
if(cyber_window = p96PIP_OpenTags(P96PIP_SourceFormat, RGBFB_Y4U2V2,
P96PIP_SourceWidth, 160,
P96PIP_SourceHeight, 128,
(cyber_pub ? WA_PubScreenName : WA_CustomScreen), (cyber_pub ? (ULONG)pubname_ptr : (ULONG)cyber_screen),
WA_Flags, WFLG_ACTIVATE | (fullFlag ? WFLG_BORDERLESS : WFLG_DEPTHGADGET | WFLG_CLOSEGADGET | WFLG_DRAGBAR | WFLG_SIZEGADGET | WFLG_SIZEBBOTTOM),
WA_IDCMP, CLOSEWINDOW | MOUSEBUTTONS | VANILLAKEY | NEWSIZE,
(fullFlag ? WA_Width : TAG_IGNORE), -1,
(fullFlag ? WA_Height : TAG_IGNORE), -1,
(fullFlag ? TAG_SKIP : TAG_IGNORE), 8,
WA_Title, "Playing MPEG animation",
WA_ScreenTitle, (UBYTE *)"aMiPEG 1.0 by Michael Rausch, Miloslaw Smyk and Tobias Seiler",
TAG_DONE))
return(modeid);
}
}
}
Quit("aMiPEG: unable to open screen/window...", 25);
}