From ae24a0c6fabd13678c2def53b2074b0a8bf690ef Mon Sep 17 00:00:00 2001 From: "Christian A. Weber" Date: Tue, 2 Jun 1992 16:44:18 +0000 Subject: Initial checkin --- Examples/AnimExample.c | 129 +++++++++++++++++++++++++++++++++++++++++++++++++ Examples/Grabber.S | 66 +++++++++++++++++++++++++ Examples/Makefile | 69 ++++++++++++++++++++++++++ 3 files changed, 264 insertions(+) create mode 100644 Examples/AnimExample.c create mode 100644 Examples/Grabber.S create mode 100644 Examples/Makefile (limited to 'Examples') diff --git a/Examples/AnimExample.c b/Examples/AnimExample.c new file mode 100644 index 0000000..28d5357 --- /dev/null +++ b/Examples/AnimExample.c @@ -0,0 +1,129 @@ +/* + AnimExample.c - A simple DPaint animation player by Christian A. Weber. + This program is in the public domain, use and abuse at your own risk. + Requires the iff.library in the LIBS: dircetory. Compiles with + Lattice C V5.04 (LC -v -L AnimExample), should also work with Manx. +*/ + +#include +#include +#include +#include /* Our iff header file */ + +struct Library *IntuitionBase,*IFFBase, *OpenLibrary(); +struct GfxBase *GfxBase; + +struct NewScreen ns = +{ + 0,0,0,0,0,0,0, NULL, CUSTOMSCREEN|SCREENBEHIND|SCREENQUIET, NULL, + (STRPTR)"Anim Player Example by Christian A. Weber", NULL, NULL +}; + +struct Screen *screen1,*screen2, *OpenScreen(); +ULONG *ifffile; + +void SetOverscan(screen) /* Adjust the screen position for overscan */ +register struct Screen *screen; +{ + register WORD cols,rows,x=screen->Width,y=screen->Height; + register struct ViewPort *vp=&(screen->ViewPort); + + cols = GfxBase->NormalDisplayColumns>>1; + rows = GfxBase->NormalDisplayRows; if(rows>300) rows>>=1; + x -= cols; if(vp->Modes & HIRES) x -= cols; + y -= rows; if(vp->Modes & LACE) y -= rows; + x >>=1; if(x<0) x=0; y >>=1; if(y<0) y=0; if(y>32) y=32; + + if(vp->Modes & HAM) /* Correct overscan HAM color distortions */ + { + if(GfxBase->ActiView->DxOffset-x < 96) + x=GfxBase->ActiView->DxOffset-96; + } + vp->DxOffset = -x; vp->DyOffset = -y; + MakeScreen(screen); RethinkDisplay(); +} + +void Fail(text) /* Print error message, free resources and exit */ +char *text; +{ + printf("%s, IFFError = %ld\n",text,IFFError()); + + if(ifffile) CloseIFF(ifffile); + if(screen1) CloseScreen(screen1); + if(screen2) CloseScreen(screen2); + + if(IFFBase) CloseLibrary(IFFBase); /* MUST ALWAYS BE CLOSED !! */ + CloseLibrary(IntuitionBase); + CloseLibrary(GfxBase); + exit(0); +} + +void main(argc,argv) +int argc; +char **argv; +{ + register LONG count,i,delay; + register ULONG *form,*loopform; + struct BitMapHeader *bmhd; + UWORD colortable[128]; + + if((argc != 4) || !strcmp(argv[1],"?")) { + printf("Format: %s filename <# of loops>\n",argv[0]); + exit(20); + } + + GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0L); + IntuitionBase = OpenLibrary("intuition.library",0L); + + if(!(IFFBase = OpenLibrary(IFFNAME,IFFVERSION))) { + printf("Copy the iff.library to your LIBS: directory!\n"); + exit(10); + } + + if(!(ifffile=OpenIFF(argv[1]))) Fail("Error opening file"); + form=ifffile+3; /* Skip FORM....ANIM */ + + if(ifffile[2] != ID_ANIM) Fail("Not an ANIM file"); + if(!(bmhd=GetBMHD(form))) Fail("BitMapHeader not found"); + + ns.Width = bmhd->w; + ns.Height = bmhd->h; + ns.Depth = bmhd->nPlanes; + ns.ViewModes = GetViewModes(form); + + if(!(screen1 = OpenScreen(&ns))) Fail("Can't open screen 1!"); + if(!(screen2 = OpenScreen(&ns))) Fail("Can't open screen 2!"); + SetOverscan(screen1); SetOverscan(screen2); + + count = GetColorTab(form,colortable); + if(count>32L) count = 32L; /* Some HAM pictures have 64 colors ?! */ + LoadRGB4(&(screen1->ViewPort),colortable,count); + LoadRGB4(&(screen2->ViewPort),colortable,count); + + /* Decode and display the first frame: */ + if(!DecodePic(form,&screen1->BitMap)) Fail("Can't decode picture"); + DecodePic(form,&screen2->BitMap); + ScreenToFront(screen2); + if((delay=atol(argv[2])) > 1) Delay(delay); + + /* Decode and display the second frame: copy and modify the first one */ + form=FindChunk(ifffile+3,0L); /* First FORM containing a DLTA */ + if(!ModifyFrame(form,&screen1->BitMap)) Fail("Can't decode frame"); + ScreenToFront(screen1); + if(delay>1) Delay(delay); + + loopform=FindChunk(form,0L); /* FORM to start loop at */ + for(i=0; iBitMap)) Fail("Can't decode frame"); + dummy=screen1; screen1=screen2; screen2=dummy; /* Flip screens */ + ScreenToFront(screen1); + if(delay>1) Delay(delay); + } + } + Fail("done"); /* Normal termination */ +} + diff --git a/Examples/Grabber.S b/Examples/Grabber.S new file mode 100644 index 0000000..1a7faa1 --- /dev/null +++ b/Examples/Grabber.S @@ -0,0 +1,66 @@ +** +** $Id: Grabber.S,v 21.1 92/05/28 17:09:27 chris Exp $ +** $Revision: 21.1 $ +** +** $Filename: Examples/Grabber.S $ +** $Authors: Christian Haller, CHW $ +** $Release: 21.1 $ +** $Date: 92/05/28 17:09:27 $ +** +** Example for low level Assembler hackers :-) +** +** This program saves the contents of the first screen as an IFF file +** with filename 'RAM:grabber.pic'. The iff.library is required. +** If you use the DevPac assembler, type 'Genim2 Grabber' to assemble. +** For simplicity, this program uses hard coded constants. You may wish +** to use the appropriate standard header files instead. +** +** THIS IS PD. NO WARRANTY. USE AT YOUR OWN RISK. +** + +Main: move.l 4,a6 ; AbsExecBase + lea IFFName(PC),a1 ; Library Name + moveq #16,d0 ; Required library version + jsr -552(a6) ; OpenLibrary() + move.l d0,a4 ; A4 : IFF Library Base + tst.l d0 ; Did we get it ? + bne.s IFFOpen ; Yes ---> + moveq #20,d0 ; Return-code RETURN_FAIL + rts ; Return to CLI +IFFOpen: + lea IntuiName(PC),a1 ; Intuition Library Name + jsr -408(a6) ; OldOpenLibrary() + move.l d0,a5 ; A5 : IntuitionBase + + move.l 60(a5),a0 ; IntuitionBase->FirstScreen + move.l 88(a0),d6 ; Screen.BitMap + + move.l 48(a0),a1 ; struct Colormap + move.l 4(a1),d7 ; struct ColorTable + lea 44(a0),a1 ; sc_ViewPort + move.w 32(a1),d1 ; vp_Modes + moveq #1,d0 ; Set cruncher-flag + btst #11,d1 ; Hold And Modify ? + beq.s NoHam ; no ---> + bset #7,d0 ; Set HAM-Flag for IFF.lib +NoHam: + move.l a4,a6 ; IFFBase + lea FileName(PC),a0 ; Name of file to save + move.l d6,a1 ; Pointer to BitMap + move.l d7,a2 ; Pointer to ColorMap + jsr -66(a6) ; SaveBitMap() + + move.l 4,a6 ; AbsExecBase + move.l a4,a1 ; IFFBase + jsr -414(a6) ; CloseLibrary() (IMPORTANT!) + + move.l a5,a1 ; IntuitionBase + jsr -414(a6) ; CloseLibrary() + + moveq #0,d0 ; DOS return code + rts + +IFFName: dc.b "iff.library",0 +IntuiName: dc.b "intuition.library",0 +FileName: dc.b "RAM:grabber.pic",0 + diff --git a/Examples/Makefile b/Examples/Makefile new file mode 100644 index 0000000..3343a0d --- /dev/null +++ b/Examples/Makefile @@ -0,0 +1,69 @@ +## +## $Id: $ +## $Revision: $ +## +## $Filename: Examples/Makefile $ +## $Author: Christian A. Weber $ +## $Release: 21.1 $ +## $Date: 92/05/17 03:09:18 $ +## +## Makefile to build iff.library examples +## +## COPYRIGHT (C) 1987-1993 BY CHRISTIAN A. WEBER, BRUGGERWEG 2, +## CH-8037 ZUERICH, SWITZERLAND. +## THIS FILE MAY BE FREELY DISTRIBUTED. USE AT YOUR OWN RISK. +## + +ALL: EasyExample AnimExample GrabScreen + + +############################################################################# +## Flags + +CFLAGS = -cfustq -fid -ms -v -rr -s -O +AFLAGS = -l -iINCLUDE: +LFLAGS = ADDSYM + + +############################################################################# +## Rules + +.s.o: + Genam $(AFLAGS) $*.S + +.c.o: + LC $(CFLAGS) $*.c + + +############################################################################# +## EasyExample + +EX_STARTUP = LIB:c.o +EX_MODULES = EasyExample.o +EX_LIBS = LIB:lcr.lib + +EasyExample: $(EX_STARTUP) $(EX_MODULES) $(EX_LIBS) + BLINK FROM $(EX_STARTUP) $(EX_MODULES) TO $* LIB $(EX_LIBS) + + +############################################################################# +## AnimEXample + +AX_STARTUP = LIB:c.o +AX_MODULES = AnimExample.o +AX_LIBS = LIB:lcr.lib + +AnimExample: $(AX_STARTUP) $(AX_MODULES) $(AX_LIBS) + BLINK FROM $(AX_STARTUP) $(AX_MODULES) TO $* LIB $(AX_LIBS) + + +############################################################################# +## GrabScreen + +GS_STARTUP = LIB:c.o +GS_MODULES = GrabScreen.o +GS_LIBS = LIB:lcr.lib + +GrabScreen: $(GS_STARTUP) $(GS_MODULES) $(GS_LIBS) + BLINK FROM $(GS_STARTUP) $(GS_MODULES) TO $* LIB $(GS_LIBS) + -- cgit v1.2.3