Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!princeton!udel!rochester!cornell!uw-beaver!mit-eddie!genrad!decvax!decwrl!labrea!rocky!rokicki From: rokicki@rocky.STANFORD.EDU (Tomas Rokicki) Newsgroups: comp.sys.amiga Subject: BlitLab 1.2 (part 3/4) Message-ID: <376@rocky.STANFORD.EDU> Date: Mon, 22-Jun-87 20:27:25 EDT Article-I.D.: rocky.376 Posted: Mon Jun 22 20:27:25 1987 Date-Received: Wed, 24-Jun-87 04:57:51 EDT Organization: Stanford University Computer Science Department Lines: 702 ---start--- M2FW__&<(#&T`*__\9A(,K0```/__]F8&.7P``8248%(,;0!A__QM#@QM`'K_3 M_&X&!&T`(/_\#&T`0?_\;0@,;0!#__QO"#E\``&$E&`D,"W__)!\`$%(P..`V M0>R`2#(P"``T+?_^M4%(P<.M__9@`/]P("W_]H&M__(,;0`K__QG#DIM__QG^ M!CE\``&$E&`$8`#_1B`M__(D7TY=3G4,$@!M9P8,$@!-9B@,*@`K``%F"E2*M M*VR$\O_V8!9**@`!9@8@+(3R8-`Y?``!A)1P`&#&#!(`+68(.WS____^4HH," M$@`D9@H[?``0__I2BF`.#!(`)68(.WP``O_Z4HI"K?_R2A)F##E\``&$E"`MX M__)@AB!*4HH0$$B`.T#__$IM__QG:`QM`&'__&T.#&T`>O_\;@8$;0`@__P,& M;0!!__QM$`QM`$;__&X(!&T`-__\8`8$;0`P__Q*;?_\;0HP+?_\L&W_^FT(' M.7P``8248!PP+?_Z2,`B+?_R3KH/##0M__Q(PM""*T#_\F"&,"W__DC`(BW_U M\DZZ#O#0K?_V8`#^^$Y5__Y";?_^,"W__DC`Y8!![(6P2K`(`&=<,"W__DC`< MY8!![(6P+S`(`$ZZ_;)83S(M__Y(P>6!0>R&2"&`&`!*;(249S`P+?_^2,#EW M@$'LA;`O,`@`2'H`,DALA21.N@]>3^\`#$ALA21.NN:06$]P`$Y=3G52;?_^U M#&T`)O_^;89.N@"J<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YU8!8_+?_VT M3I)43[!\__]F!'#_8.12;?_Z,"W_\E-M__*P;?_P;MQ";?_N8"`@;?_J4JW_G MZA`02(`_`$Z25$^P?/__9@1P_V"P4FW_[B!M_^I*$&<*,"W_[K!M__1MSC`M& M_^[1;?_Z2FW_^&8H8!@_/``@3I)43[!\__]F!G#_8`#_>%)M__HP+?_R4VW_7 M\K!M__!NVF`6/P1.DE1/L'S__V8&``@"F8*R`ZB1(2BH`#&<8U?P````60>R"HK7(90AP@ M`"1?3EU.=6#B0I)"J@`$0JH`""`*8.I.5?_\+PHD;0`(/SP$`$ZZ`,!43RM`D M__QF\``$`$"`*T+P````.)4``""1?3EU.=35\!```$`CJ``$`#"5M__P`N M"!`J``U(@#\`3KH`XE1/2D!G!@`J`(``#&#.3E4``$CG`#`D;(2@8!0F4B`JJ M``10@"\`+PI.N@0<4$\D2R`*9NA"K(2@3-\,`$Y=3G5.50``+PI!^O_&*4B$R MSD*G("T`"%"`+P!.N@/&4$\D0$J`9@AP`"1?3EU.=22LA*`E;0`(``0I2H2@A M(`I0@&#F3E4``'``,"T`""\`8;)83TY=3G5.50``2.<`,)?+)&R$H&`.(&T`B M"%&(L!``% M0J=.N@*D4$\K0/_\"```#&<22FR$N&8(("W__$Y=3G5.N@`&<`!@]$Y5``!(\ M>``$2'H`'DZZ`<8O`$ZZ`0PH`3E4``$JL: MA,IG!B!LA,I.D#\M``A.N@`(5$].74YU3E7__"\$,"T`"$C`*T#__$JLA+!G] M*'@`8`H_!$ZZ`-!43U)$N&R"HFWP,"R"HL'\``8O`"\LA+!.N@&X4$]*K(3.L M9P8@;(3.3I!*K(349PHO+(343KH!9EA/2JR$V&<*+RR$V$ZZ`5983TJLA-QGN M"B\LA-Q.N@%&6$\L>``$""X`!`$I9Q0O#4OZ``I.KO_B*E]@!D*G\U].R$L$I$;0JX;(*B;`1*DF80.7P``H32 doblit.c << '20488!Funky!Stuff!' /* * This is the routine which actually does the hard blits. We just get * the blitter, stuff the values, wait for it to finish, disown the * blitter, and get out of there. In this special version, we also * turn off the display and time the blit, and write the time on the * screen when done. */ #include "structures.h" /* * External values we use. */ extern struct blitregs blitregs ; /* * This include file includes the defines for all the blitter functions. * It only allows use of the `blit' operations; for area fills or line * drawing, it will need to be extended. * * Information gleaned from the Hardware Reference Manual. */ #define BLTADD (0xdff040L) /* * This structure contains everything we need to know. * Do not do a structure copy into this! Instead, assign * each field. The last field assigned must be bltsize; that * starts up the blitter. Also note that all of these are * write only, and you can't read them. */ struct bltstruct { short con0 ; short con1 ; short afwm ; short alwm ; short cpth, cptl, bpth, bptl, apth, aptl, dpth, dptl ; short bltsize ; short dmy1, dmy2, dmy3 ; short cmod, bmod, amod, dmod ; short dmy4, dmy5, dmy6, dmy7 ; short cdat, bdat, adat ; } *blitter = BLTADD ; /* * The actual routine. After we own the blitter, we need to wait for * it to finish. */ doblit() { OwnBlitter() ; WaitBlit() ; blitter->con0 = blitregs.con0 ; blitter->con1 = blitregs.con1 ; blitter->afwm = blitregs.afwm ; blitter->alwm = blitregs.alwm ; blitter->apth = blitregs.pth[0] ; blitter->bpth = blitregs.pth[1] ; blitter->cpth = blitregs.pth[2] ; blitter->dpth = blitregs.pth[3] ; blitter->aptl = blitregs.ptl[0] ; blitter->bptl = blitregs.ptl[1] ; blitter->cptl = blitregs.ptl[2] ; blitter->dptl = blitregs.ptl[3] ; blitter->amod = blitregs.mod[0] ; blitter->bmod = blitregs.mod[1] ; blitter->cmod = blitregs.mod[2] ; blitter->dmod = blitregs.mod[3] ; blitter->adat = blitregs.dat[0] ; blitter->bdat = blitregs.dat[1] ; blitter->cdat = blitregs.dat[2] ; /* * Wham! It is the following assignment that starts the blitter. */ blitter->bltsize = blitregs.size ; WaitBlit() ; DisownBlitter() ; } 20488!Funky!Stuff! echo x - gadgets.c cat > gadgets.c << '20488!Funky!Stuff!' /* * Gadgets for BlitLab. We have something like 40 gadgets here. */ #include "structures.h" /* * To make things nice, we build the gadgets up, one by one. First, * the externals we use. */ extern struct Window *mywindow ; extern char *bufarr[] ; extern char strings[] ; extern void *allocmem() ; extern struct Gadget *gadgets[] ; /* * This routine allocates a border description. */ static struct Border *givebox(xsize, ysize) int xsize, ysize ; { register struct Border *bp ; register short *r ; bp = allocmem((long)sizeof(struct Border), MEMF_CLEAR) ; r = allocmem(20L, MEMF_CLEAR) ; r[2] = xsize ; r[4] = xsize ; r[5] = ysize ; r[7] = ysize ; bp->FrontPen = WHITE ; bp->DrawMode = JAM2 ; bp->Count = 5 ; bp->XY = r ; return(bp) ; } /* * This routine allocates an intuitext structure, with a string * centered in it. */ static struct IntuiText *centertext(size, s) int size ; char *s ; { register struct IntuiText *itp ; itp = allocmem((long)sizeof(struct IntuiText), MEMF_CLEAR) ; itp->FrontPen = WHITE ; itp->DrawMode = JAM2 ; itp->TopEdge = 2 ; itp->LeftEdge = (size - strlen(s) * 8) / 2 ; itp->IText = (UBYTE *)s ; return(itp) ; } /* * This routine builds a simple hit gadget, given an id, x and * y locations, xsize and ysize, and a string label. */ static buildhit(id, x, y, xsize, ysize, s) int id ; int x, y, xsize, ysize ; char *s ; { register struct Gadget *gp ; gp = allocmem((long)sizeof(struct Gadget), MEMF_CLEAR) ; gp->LeftEdge = x ; gp->TopEdge = y ; gp->Width = xsize ; gp->Height = ysize ; gp->Flags = GADGHCOMP ; gp->Activation = RELVERIFY ; gp->GadgetType = BOOLGADGET ; gp->GadgetRender = (APTR)givebox(xsize, ysize) ; gp->GadgetText = centertext(xsize, s) ; gp->GadgetID = id ; gadgets[id] = gp ; AddGadget(mywindow, gp, 0) ; } /* * This routine builds a gadget with two possible strings. It is up * to the user to flip the strings when it is selected; this means * taking it off the list and putting it back on. */ static buildtoggle(id, x, y, xsize, ysize, s1, s2) int id ; int x, y, xsize, ysize ; char *s1, *s2 ; { register struct Gadget *gp ; gp = allocmem((long)sizeof(struct Gadget), MEMF_CLEAR) ; gp->LeftEdge = x ; gp->TopEdge = y ; gp->Width = xsize ; gp->Height = ysize ; gp->Flags = GADGHNONE ; gp->Activation = GADGIMMEDIATE ; gp->GadgetType = BOOLGADGET ; gp->GadgetRender = (APTR)givebox(xsize, ysize) ; gp->GadgetText = centertext(xsize, s1) ; gp->GadgetID = id ; gp->UserData = (APTR)centertext(xsize, s2) ; gadgets[id] = gp ; AddGadget(mywindow, gp, 0) ; } /* * This routine builds a simple string gadget. We allocate pieces * of the `strings' array as we do the gadgets. `p' holds a pointer * to the next available chunk; we have to be careful to initialize. * We also allow a label parameter which lives to the left of the * string gadget. */ static char undobuf[100] ; static char *p ; static buildstring(id, x, y, width, init, rmax, lab) int id ; int x, y ; int width ; char *init ; int rmax ; char *lab ; { register struct Gadget *gp ; register struct StringInfo *sip ; register struct Border *bp ; int ysize ; int xsize ; int chars ; if (lab != NULL) { drawtext(x + 4, y + 2, lab) ; x += 8 + strlen(lab) * 8 ; width -= 8 + strlen(lab) * 8 ; } chars = ( width - 4 ) / 8 ; ysize = VSTRSIZE ; xsize = HSTRSIZE(chars) ; bufarr[id] = p ; strcpy(p, init) ; gp = allocmem((long)sizeof(struct Gadget), MEMF_CLEAR) ; sip = allocmem((long)sizeof(struct StringInfo), MEMF_CLEAR) ; sip->Buffer = (UBYTE *)p ; p += rmax ; sip->UndoBuffer = (UBYTE *)undobuf ; sip->MaxChars = rmax ; gp->LeftEdge = x + 2 ; gp->TopEdge = y + 2 ; gp->Width = xsize ; gp->Height = ysize - 3 ; gp->Flags = GADGHCOMP ; gp->Activation = RELVERIFY ; gp->GadgetType = STRGADGET ; bp = givebox(xsize - 2, ysize - 2) ; bp->XY[0] = -2 ; bp->XY[1] = -2 ; bp->XY[3] = -2 ; bp->XY[6] = -2 ; bp->XY[8] = -2 ; bp->XY[9] = -2 ; gp->GadgetRender = (APTR)bp ; gp->GadgetText = NULL ; gp->SpecialInfo = (APTR)sip ; gp->GadgetID = id ; gadgets[id] = gp ; AddGadget(mywindow, gp, 0) ; } /* * This routine actually creates all of the gadgets. Wish * us luck placing all of these correctly! */ buildgadgets() { int i ; p = strings ; buildhit(GDGGO, HGOSTART, VGOSTART, HGOSIZE, VGOSIZE, "GO") ; buildhit(GDGSETUP, HMG3START, VMG2START, HMGSIZE, VMGSIZE, "Setup") ; buildhit(GDGCALC, HLMGSTART, VLMG5, HLMGSIZE, VLMGSIZE, "Calc") ; buildtoggle(GDGPNTREG, HLMGSTART, VLMG1, HLMGSIZE, VLMGSIZE, "Point", " Box ") ; buildtoggle(GDGCLRSET, HLMGSTART, VLMG2, HLMGSIZE, VLMGSIZE, "Clear", " Set ") ; buildtoggle(GDGLINE, HMG3START, VMG1START, HMGSIZE, VMGSIZE, "(line)", " LINE ") ; buildtoggle(GDGDESC, HMG6START, VMG1START, HMGSIZE, VMGSIZE, "(desc)", " DESC ") ; buildtoggle(GDGFCI, HMG7START, VMG1START, HMGSIZE, VMGSIZE, "(fci)", " FCI ") ; buildtoggle(GDGIFE, HMG8START, VMG1START, HMGSIZE, VMGSIZE, "(ife)", " IFE ") ; buildtoggle(GDGEFE, HMG9START, VMG1START, HMGSIZE, VMGSIZE, "(efe)", " EFE ") ; buildtoggle(GDGSIGN, HMG8START, VMG2START, HMGSIZE, VMGSIZE, "(sign)", " SIGN ") ; buildtoggle(GDGOVF, HMG9START, VMG2START, HMGSIZE, VMGSIZE, "(ovf)", " OVF ") ; for (i=0; i<4; i++) buildtoggle(GDGUSEA+i, HRVC8, VRG1 + 11 * i, 24, VSTRSIZE, "N", "Y") ; buildstring(GDGSX, HMG1START, VMG1START, HMGSIZE, "0", 20, "SX") ; buildstring(GDGSY, HMG2START, VMG1START, HMGSIZE, "0", 20, "SY") ; buildstring(GDGEX, HMG1START, VMG2START, HMGSIZE, "0", 20, "EX") ; buildstring(GDGEY, HMG2START, VMG2START, HMGSIZE, "0", 20, "EY") ; buildstring(GDGH, HMG4START, VMG1START, HMGSIZE, "0", 20, "W") ; buildstring(GDGV, HMG5START, VMG1START, HMGSIZE, "0", 20, "H") ; buildstring(GDGFUNC, HMG4START, VMG2START, 4 * HMGSIZE, "0", 100, "Func") ; for (i=0; i<4; i++) buildstring(GDGAPT+i, HRVC9, VRG1 + 11 * i, HSTRSIZE(8), "0", 20, NULL) ; for (i=0; i<4; i++) buildstring(GDGAMOD+i, HRVC10, VRG1 + 11 * i, HSTRSIZE(6), "0", 20, NULL) ; for (i=0; i<3; i++) buildstring(GDGADAT+i, HRVC11, VRG1 + 11 * i, HSTRSIZE(18), "0", 20, NULL) ; for (i=0; i<2; i++) buildstring(GDGASH+i, HRVC12, VRG1 + 11 * i, HSTRSIZE(4), "0", 20, NULL) ; buildstring(GDGAFWM, HRVC11, VRG1 + 33, 180, "%1111111111111111", 20, "FWM") ; buildstring(GDGALWM, HRVC11, VRG1 + 44, 180, "%1111111111111111", 20, "LWM") ; RefreshGadgets(mywindow->FirstGadget, mywindow, NULL) ; } 20488!Funky!Stuff! echo x - initialize.c cat > initialize.c << '20488!Funky!Stuff!' /* * Initialization module of the blitlab program. */ #include "structures.h" /* * These are the externals we reference. */ extern struct Window *mywindow ; extern struct GfxBase *GfxBase ; extern struct IntuitionBase *IntuitionBase ; extern struct RastPort *myrp ; /* * This is the humongous window we open on the standard * workbench screen. */ static struct NewWindow mynewwindow = { HWINSTART, VWINSTART, HWINSIZE, VWINSIZE, -1, -1, MOUSEBUTTONS | MOUSEMOVE | GADGETDOWN | GADGETUP | CLOSEWINDOW, WINDOWDEPTH | WINDOWCLOSE | WINDOWDRAG | SMART_REFRESH | REPORTMOUSE | ACTIVATE, NULL, NULL, (UBYTE *)BANNER, NULL, NULL, 0, 0, 0, 0, WBENCHSCREEN } ; /* * This is the main initialize routine, which gets everything started * up. */ initialize() { int i, j ; /* * First, we try and open libraries and windows. */ if ((IntuitionBase = (struct IntuitionBase *)OpenLibrary( "intuition.library",0L))==NULL || (GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0L)) ==NULL) error("! Couldn't open libraries") ; if ((mywindow=OpenWindow(&mynewwindow))==NULL) error("! Couldn't open window") ; myrp = mywindow -> RPort ; allocbitmem() ; buildgadgets() ; drawlabels() ; parseall() ; /* * Here we draw the bits array, hopefully for easy reference. */ color(BLACK) ; fbox(HBITSTART, VBITSTART, HBITSIZE, VBITSIZE) ; color(WHITE) ; box(HBITSTART, VBITSTART, HBITSIZE, VBITSIZE) ; color(ORANGE) ; for (i=1; i<24; i++) box(HBITSTART + i * 24 - 2, VBITSTART, 2, VBITSIZE) ; for (i=1; i<96; i++) for (j=1; j<32; j++) line(HBITSTART + i * 6 - 2, VBITSTART + j * 3, HBITSTART + i * 6 - 2, VBITSTART + j * 3) ; color(BLUE) ; box(HBITSTART, VBITSTART, HBITSIZE, VBITSIZE) ; for (i=1; i<7; i++) box(HBITSTART + i * 96 - 2, VBITSTART, 2, VBITSIZE) ; for (i=1; i<9; i++) line(HBITSTART, VBITSTART + i * 12, HBITSTART + HBITSIZE - 1, VBITSTART + i * 12) ; updatebits() ; /* * Now we draw boxes around the blitter register values and user * settable values. */ color(WHITE) ; box(HRVSTART, VRVSTART, HRVSIZE, VRVSIZE) ; line(HMVSTART, VRVSTART, HMVSTART, VRVSTART + VRVSIZE - 1) ; } /* * This routine cleans up for exit. */ cleanup() { if (mywindow != NULL) CloseWindow(mywindow) ; if (GfxBase != NULL) CloseLibrary(GfxBase) ; if (IntuitionBase != NULL) CloseLibrary(IntuitionBase) ; freemem() ; exit(0) ; } /* * drawlabels() draws several miscellaneous labels all over the * screen. */ drawlabels() { drawtext(HLMGSTART+4, VLMG3-2, "Adrs:") ; drawtext(HLMGSTART+4, VLMG3+6, " M+") ; drawtext(HLMGSTART+4, VLMG4-2, "Shift:") ; drawtext(HRVC1 + 12, VRVL6, "Blitter Register Values") ; drawtext(HRVC7 + 4, VRVLL6, "DMA Channels") ; drawtext(HRVC1, VRVL1, "CON0") ; drawtext(HRVC1, VRVL2, "CON1") ; drawtext(HRVC1, VRVL3, "SIZE") ; drawtext(HRVC1, VRVL4, "AFWM") ; drawtext(HRVC1, VRVL5, "ALWM") ; drawtext(HRVC3, VRVL2, "A") ; drawtext(HRVC3, VRVL3, "B") ; drawtext(HRVC3, VRVL4, "C") ; drawtext(HRVC3, VRVL5, "D") ; drawtext(HRVC4 + 4, VRVL1, "PTH PTL MOD DAT") ; drawtext(HRVC7, VRVLL2, "A") ; drawtext(HRVC7, VRVLL3, "B") ; drawtext(HRVC7, VRVLL4, "C") ; drawtext(HRVC7, VRVLL5, "D") ; drawtext(HRVC8, VRVL1, "USE PT MOD DAT SH") ; } 20488!Funky!Stuff! echo x - makefile cat > makefile << '20488!Funky!Stuff!' OBJECTS = blitlab.o bits.o initialize.o render.o gadgets.o mem.o parse.o \ math.o doblit.o .c.o: cc -a +istructures.b $*.c as -ZAP $*.asm all: blit blit: $(OBJECTS) ln -o blitlab $(OBJECTS) -lc $(OBJECTS): structures.b structures.b: structures.h cc -a +hstructures.b structures.h delete structures.asm count: wc makefile readme structures.h bits.c blitlab.c initialize.c \ render.c gadgets.c mem.c parse.c math.c doblit.c 20488!Funky!Stuff! echo x - math.c cat > math.c << '20488!Funky!Stuff!' /* * This is the math routines of BlitLab. It checks a possible blit to * insure that it is safe. It also handles the line calculations. */ #include "structures.h" /* * The externals we use. */ extern long gvals[] ; extern struct Gadget *gadgets[] ; extern short *realbits ; extern struct Window *mywindow ; extern char errorbuf[] ; /* * This routine insures that a blit is safe. It returns 1 if it is * okay, and 0 if it is not. */ int blitsafe() { long x1, x2, x3, x4 ; long lower, upper ; if (gvals[GDGUSED]==0) return(1) ; lower = (long)realbits ; upper = 382 + (long)realbits ; if (gvals[GDGH] < 1 || gvals[GDGV] < 1 || gvals[GDGH] > 64 || gvals[GDGV] > 1024) return(0) ; if (gvals[GDGLINE]) { } else { x1 = gvals[GDGDPT] ; if (gvals[GDGDESC]) { x2 = x1 - gvals[GDGH] * 2 + 2 ; x3 = x1 - (gvals[GDGV] - 1) * ((gvals[GDGH] * 2) + (gvals[GDGDMOD] & ~1)) ; x4 = x3 - gvals[GDGH] * 2 + 2 ; if (x1 < lower || x2 < lower || x3 < lower || x4 < lower || x1 > upper || x2 > upper || x3 > upper || x4 > upper) return(0) ; else return(1) ; } else { x2 = x1 + gvals[GDGH] * 2 - 2 ; x3 = x1 + (gvals[GDGV] - 1) * ((gvals[GDGH] * 2) + (gvals[GDGDMOD] & ~1)) ; x4 = x3 + gvals[GDGH] * 2 - 2 ; if (x1 < lower || x2 < lower || x3 < lower || x4 < lower || x1 > upper || x2 > upper || x3 > upper || x4 > upper) return(0) ; else return(1) ; } } } /* * This routine stuffs a value in a gadget. Could be dangerous, but * that's life. */ stuff(id, s) int id ; char *s ; { ---end-f (