home *** CD-ROM | disk | FTP | other *** search
Wrap
/* init --- stuff a zillion strucks, grab extra chip real-estate */ /* good code is beautiful code */ #include <exec/memory.h> #include <graphics/gfxbase.h> #include <libraries/dosextens.h> #include "stuff.h" #ifdef POPLITE #include "chip2.h" #else #include "chip.h" #endif extern struct SUPERwindow SuperWindows [] ; extern struct Image vop ; extern UWORD mrQ ; extern int CurrentWindow ; extern int curOnion ; extern int togOnion ; extern int Enable_Abort ; struct RastPort *reep ; struct ViewPort *veep ; struct IntuitionBase *IntuitionBase ; struct GfxBase *GfxBase ; struct Screen *scr ; struct Window *win ; USHORT *myBitOfChip ; USHORT *fillerChip ; struct Process *OurTask ; APTR old_pr_WindowPtr ; UWORD ni_colCMAP[]={ 0x522,0xfe0,0x606,0x4d0,0x00f,0xf0f,0x0ff,0xfff,0x620,0xe50,0x9f1,0xeb0, 0x55f,0x92f,0x0f8,0xccc,0x000,0xbef,0x442,0x189,0x444,0x555,0x666,0x777, 0x888,0x999,0xaaa,0xbbb,0xccc,0xddd,0x44b,0xcc5, }; /* end of ni_col9CMAP */ UWORD actionmap [32]; UBYTE flubb [12] = { "ni_" }; SHORT vecks2 [10] = { 0,0, 86,0, 86,13, 0,13, 0,0 }; struct Border bored2 = { -3, -3, 16, 0, JAM1, 5, vecks2, NL }; SHORT vecks [10] = { 0,0, 84,0, 84,11, 0,11, 0,0 }; struct Border bored = { -2, -2, 23, 0, JAM1, 5, vecks, &bored2 }; struct StringInfo nameinfo = { flubb, NL, 1, 10, 0, 0, }; struct Gadget namegad = { NL,229,148,80,12, GADGHCOMP,STRINGCENTER|RELVERIFY,STRGADGET,(APTR)&bored, NL,NL,NL, (APTR) &nameinfo,SAVEG,NL}; #define ImGAD(x,y,len,hite,rn,hit,id,nx) \ { nx, x, y,len,hite, GADGHNONE | GADGIMAGE, hit, BOOLGADGET, (APTR)\ rn,NL,NL,NL,NL, id, NL} #define ZzGAD(x,y,len,hite,hit,id,nx) \ { nx, x, y,len,hite, GADGHNONE, hit, BOOLGADGET, (APTR)\ NL,NL,NL,NL,NL,id,NL} #define IxGAD(x,y,len,hite,rn,rd,hit,id,nx) \ { nx, x, y,len,hite, GADGHIMAGE | GADGIMAGE, hit, BOOLGADGET, (APTR)\ rn,(APTR) rd,NL,NL,NL, id, NL} #define AnGAD(x,y,len,hite,rn,hit,id,nx) \ { nx, x, y,len,hite,GADGHNONE|GADGIMAGE, hit|RELVERIFY, BOOLGADGET, (APTR)\ rn,NL,NL,NL,NL, id, NL} #ifdef POPLITE #define IM(x,y) { 0, 0, x, y, 1, NL, 1, 0, NL } #else #define IM(x,y) { 0, 0, x, y, 5, NL, 0x1f, 0, NL } #endif struct Image hatchI = IM (ni_htofWIDT, ni_htofHITE), unhtcI = IM (ni_unhtofWIDT, ni_unhtofHITE), hato_I = IM (ni_htonWIDT, ni_htonHITE), hatf_I = IM (ni_unhtonWIDT, ni_unhtonHITE), pick_I = IM (ni_pickWIDT, ni_pickHITE), save_I = IM (ni_saveWIDT, ni_saveHITE), load_I = IM (ni_loadWIDT, ni_loadHITE), new__I = IM (32, 24), svsz_I = IM (ni_allQWIDT, ni_allQHITE), svsz_X = IM (ni_allQWIDT, ni_allQHITE), clon_I = IM (ni_clon1WIDT, ni_clon1HITE), inc_I = IM (ni_incWIDT, ni_incHITE), ins_I = IM (ni_insWIDT, ni_insHITE), fillI = IM (ni_fillWIDT, ni_fillHITE), nocmI = IM (ni_cmWIDT, ni_cmHITE), nocmX = IM (ni_cmWIDT, ni_cmHITE), dec_I = IM (ni_decWIDT, ni_decHITE), hex_I = IM (ni_decWIDT, ni_decHITE), ; struct Gadget TGads [] = { ZzGAD ( 4,144,38,26, RELVERIFY, BLOKG, &namegad ), IxGAD ( 4,161,38,26, &hatchI,&hato_I,TOGGLESELECT, HATCG, &TGads [0]), IxGAD ( 42,161,38,26, &unhtcI,&hatf_I,TOGGLESELECT, UNHTG, &TGads [1]), AnGAD (281,162,38,26, &new__I, NL, NEW_G, &TGads [2]), ImGAD ( 80,161,38,26, &pick_I, RELVERIFY, PICKG, &TGads [3]), AnGAD (204,161,38,26, &save_I, 0, SAVEG, &TGads [4]), ImGAD (242,161,38,26, &load_I, RELVERIFY, LOADG, &TGads [5]), AnGAD (277,121,2*16,20,&clon_I, NL, CLONG, &TGads [6]), IxGAD (156,144, ni_allQWIDT, ni_allQHITE, &svsz_I, &svsz_X, TOGGLESELECT, SVSZG, &TGads[7]), ZzGAD (232,121, ni_rollWIDT, ni_rollHITE, RELVERIFY,ROLLG,&TGads[ 8]), AnGAD (156,161, ni_incWIDT, ni_incHITE, &inc_I,RELVERIFY,INC_G,&TGads[ 9]), AnGAD (194,161, ni_insWIDT, ni_insHITE, &ins_I,RELVERIFY,INS_G,&TGads[10]), AnGAD (118,161, ni_fillWIDT, ni_fillHITE,&fillI,RELVERIFY,FILLG,&TGads[11]), ZzGAD (231, 81, ni_copyWIDT, ni_copyHITE,RELVERIFY,COPYG,&TGads[12]), ZzGAD (231,100, ni_undoWIDT, ni_undoHITE,RELVERIFY,UNDOG,&TGads[13]), ZzGAD (267,121,ni_stackWIDT,ni_stackHITE,RELVERIFY,STAKG,&TGads[14]), ZzGAD (229,121, ni_seqWIDT, ni_seqHITE,RELVERIFY,SEQ_G,&TGads[15]), ZzGAD (118,144, ni_cnlWIDT, ni_cnlHITE,RELVERIFY,CNL_G,&TGads[16]), IxGAD (80,144,ni_cmWIDT,ni_cmHITE, &nocmI,&nocmX,TOGGLESELECT,NOCMG,&TGads[17]), ZzGAD (201, 10, ni_onionWIDT, ni_onionHITE,RELVERIFY,ONIOG,&TGads[18]), ZzGAD (169, 10, ni_poponWIDT, ni_poponHITE,RELVERIFY,POP_G,&TGads[19]), ZzGAD (137, 10, ni_xwbWIDT, ni_xwbHITE,RELVERIFY,XWB_G,&TGads[20]), ZzGAD ( 2,128,ni_colorsWIDT,ni_colorsHITE,RELVERIFY,TWEKG,&TGads[21]), IxGAD (105,10,ni_decWIDT,ni_decHITE, &hex_I,&dec_I,TOGGLESELECT,HEX_G,&TGads[22]), }; #define ColGAD(x,y,id,nx) \ {nx,x,y,10,7,GADGHCOMP,RELVERIFY,BOOLGADGET,NL,NL,NL,NL,NL,id,NL} struct Gadget CGads [ 32 ] = { ColGAD( 2, 15, COL0, &TGads[23]), ColGAD( 2, 22, COL1, &CGads[ 0]), ColGAD( 2, 29,COL2, &CGads[ 1]), ColGAD( 2, 36, COL3, &CGads[ 2]), ColGAD( 2, 43,COL4, &CGads[ 3]), ColGAD( 2, 50, COL5, &CGads[ 4]), ColGAD( 2, 57,COL6, &CGads[ 5]), ColGAD( 2, 64, COL7, &CGads[ 6]), ColGAD( 2, 71,COL8, &CGads[ 7]), ColGAD( 2, 78, COL9, &CGads[ 8]), ColGAD( 2, 85,COL10,&CGads[ 9]), ColGAD( 2, 92, COL11,&CGads[10]), ColGAD( 2, 99,COL12,&CGads[11]), ColGAD( 2,106, COL13,&CGads[12]), ColGAD( 2,113,COL14,&CGads[13]), ColGAD( 2,120, COL15,&CGads[14]), ColGAD(22, 15,COL16,&CGads[15]), ColGAD(22, 22, COL17,&CGads[16]), ColGAD(22, 29,COL18,&CGads[17]), ColGAD(22, 36, COL19,&CGads[18]), ColGAD(22, 43,COL20,&CGads[19]), ColGAD(22, 50, COL21,&CGads[20]), ColGAD(22, 57,COL22,&CGads[21]), ColGAD(22, 64, COL23,&CGads[22]), ColGAD(22, 71,COL24,&CGads[23]), ColGAD(22, 78, COL25,&CGads[24]), ColGAD(22, 85,COL26,&CGads[25]), ColGAD(22, 92, COL27,&CGads[26]), ColGAD(22, 99,COL28,&CGads[27]), ColGAD(22,106, COL29,&CGads[28]), ColGAD(22,113,COL30,&CGads[29]), ColGAD(22,120, COL31,&CGads[30]), }; /* HALLELLULLIA Sing Hail and Praise Unto the Cosmos! N O F**KING M E N U S ! ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ struct NewScreen scrdef = { 0,0, 320,200, 5,1,0,NL, CUSTOMSCREEN|SCREENBEHIND,NL,NL,NL,NL }; struct NewWindow windef = { 0,1, 320,199, 0,1, CLOSEWINDOW | MOUSEMOVE | MOUSEBUTTONS | GADGETUP | RAWKEY | INACTIVEWINDOW, /* IDCMP */ WINDOWCLOSE | WINDOWDEPTH | REPORTMOUSE | BORDERLESS | ACTIVATE | RMBTRAP, /* Flags */ &CGads [31], NL,NL,NL,NL, 0,0,0,0, CUSTOMSCREEN }; void openstuff () { USHORT *grabChip (); #define SIP (struct InuitionBase *) #define SGP (struct GfxBase *) #define ILB "intuition.library",33L #define GLB "graphics.library",33L #define OLB OpenLibrary #define OAM AllocMem #define QUIT(x) quit ("Abort - " x " \n") Enable_Abort = 0; IFN (IntuitionBase = SIP OpenLibrary (ILB)) QUIT ("No Intuition"); IFN ( GfxBase = SGP OpenLibrary (GLB)) QUIT ("No Graphics"); IFN ( scr = OpenScreen (&scrdef)) QUIT ("No Screen "); LoadRGB4 (&(scr->ViewPort), actionmap, 32L); new____Chip = grabChip (new____, new____SIZE, &TGads [3]); ni_pickChip = grabChip (ni_pick, ni_pickSIZE, &TGads [4]); ni_saveChip = grabChip (ni_save, ni_saveSIZE, &TGads [5]); ni_loadChip = grabChip (ni_load, ni_loadSIZE, &TGads [6]); ni_clon1Chip = grabChip (ni_clon1, ni_clon1SIZE, &TGads [7]); ni_allQChip = grabChip (ni_allQ, ni_allQSIZE, &TGads [8]); ni_oneQChip = grabChip (ni_oneQ, ni_oneQSIZE, &TGads [8]); svsz_I.ImageData = ni_allQChip; svsz_X.ImageData = ni_oneQChip; ni_htonChip = grabChip (ni_hton, ni_htonSIZE, &TGads [1]); ni_htofChip = grabChip (ni_htof, ni_htofSIZE, &TGads [1]); ni_unhtonChip = grabChip (ni_unhton, ni_unhtonSIZE, &TGads [2]); ni_unhtofChip = grabChip (ni_unhtof, ni_unhtofSIZE, &TGads [2]); hato_I.ImageData = ni_htonChip; hatf_I.ImageData = ni_unhtonChip; hatchI.ImageData = ni_htofChip; unhtcI.ImageData = ni_unhtofChip; ni_nocmChip = grabChip (ni_nocm, ni_nocmSIZE, &TGads [18]); ni_cmChip = grabChip (ni_cm, ni_cmSIZE, &TGads [18]); nocmI.ImageData = ni_nocmChip; nocmX.ImageData = ni_cmChip; ni_hexChip = grabChip (ni_hex, ni_decSIZE, &TGads [23]); ni_decChip = grabChip (ni_dec, ni_decSIZE, &TGads [23]); hex_I.ImageData = ni_hexChip; dec_I.ImageData = ni_decChip; #ifndef POPLITE hex_I.Depth = dec_I.Depth = 2; dec_I.PlanePick = hex_I.PlanePick = 3; #endif ni_incChip = grabChip (ni_inc, ni_incSIZE, &TGads [10]); ni_fillChip = grabChip (ni_fill, ni_fillSIZE, &TGads [12]); windef.Screen = scr; IFN (win = OpenWindow (&windef)) QUIT ("No Window"); IFN ( myBitOfChip = (USHORT *) AllocMem (PICKSIZE, MEMF_CHIP)) quit ("Abort - No Fashionable, Expensive Chips Left!"); CopyMem (pickmousepoints, myBitOfChip, PICKSIZE); IFN ( fillerChip = (USHORT *) AllocMem (FILLSIZE, MEMF_CHIP)) quit ("Abort - Hey, free up some graphics memory, huh?"); CopyMem (fillerpoints, fillerChip, FILLSIZE); NewSuperWindow (); reep = win->RPort; DOni_cnl (118, 144); DOni_roll (232, 121); DOni_ins (194, 161); popChip (ni_namer, ni_namerSIZE, 32, 16, 194, 145); vop.PlanePick = 0x09; DOni_copy (231, 81); DOni_undo (231,100); vop.PlanePick = ni_xwbPLAN; DOni_xwb (137, 10), vop.PlanePick = ni_whatPLAN; vop.PlaneOnOff = ni_whatONOF; DOni_what (42, 144); vop.PlanePick = 0x0f; vop.PlaneOnOff = 0x010; DOni_ubuff (UbfOver, UbfDown); vop.PlanePick = 0x05; vop.PlaneOnOff = 0x0; DOni_stack (267, 121); vop.PlanePick = ni_seqPlanePick; DOni_seq (229,121); vop.PlanePick = 0x01f; onionOn (); DOni_blokof (4,144); popOnOff (); Mess ("Welcome to PopArt!!!"); DOni_colors (2, 128); } /* give me the WHOLE F**KING AMIGA!!! (or at least my pink half of the drain pipe) */ void onionOn () { vop.Depth = 2; vop.PlanePick = 0x03; DOni_onion (201, 10); vop.PlanePick = 0x01f; vop.Depth = 5; Mess ("See-Thru Enabled"); } int bloking = 0; void blokOnOff () { ifn (bloking) { bloking = izCtrl (mrQ)? 5: 2; Mess ("Block Mode Enabled"); DOni_blokon (4,144); } else { bloking = 0; Mess ("Block Mode Disabled (computerese...)"); DOni_blokof (4,144); } } int popping = 1; void popOnOff () { popping = !popping; vop.PlanePick = ni_poponPLAN; if (popping) { Mess ("Pop Mode Started"); DOni_popon (169, 10); } else { Mess ("Bye-Bye Pop Mode (Disabled)"); DOni_popoff (169, 10); } vop.PlanePick = 0x01f; } void onionOff () { vop.Depth = 2; vop.PlanePick = 0x03; DOni_onnoff (201, 10); vop.PlanePick = 0x01f; vop.Depth = 5; Mess ("See-Thru Disabled"); if (curOnion != CurrentWindow) redrawWorkArea (1); } void pickmouse () { long eno = 0; ClearPointer (win); loop (; eno < 85; eno += 2) SetPointer (win, myBitOfChip, eno, 16L, 0L, -1L); } /* end of pickmouse */ fillermouse () { ClearPointer (win); SetPointer (win, fillerChip, 66L, 16L, -7L, 1L); } void fade (hot) { int sex; loop (sex = 32; sex--;) { int r, g, b; r = ni_colCMAP [sex] >> 8; g = (ni_colCMAP [sex] >> 4) & 0x0f; b = (ni_colCMAP [sex] ) & 0x0f; if (r > hot) r = hot; if (g > hot) g = hot; if (b > hot) b = hot; actionmap [sex] = (r << 8) | (g << 4) | b; } Delay (1L); LoadRGB4 (&(scr->ViewPort), actionmap, 32L); } void init () { REG unsigned int z = 32; void openstuff (); struct Preferences Polly; /* if (!gargc) exit (1); /* ain't big enough to go off the training wheels yet...*/ openstuff (); OurTask = (struct Process *)FindTask(0L); old_pr_WindowPtr = OurTask->pr_WindowPtr; OurTask->pr_WindowPtr = (APTR) win; SetDrMd (( reep ), JAM2); while (z--) { SetAPen (reep, (long) z); RectFill (reep, (long) CGads [z].LeftEdge, (long) CGads [z].TopEdge, (long) (CGads [z].LeftEdge + CGads [z].Width - 1), (long) (CGads [z].TopEdge + CGads [z].Height - 1)); } new_color (1L); GetPrefs (&Polly, (long) sizeof (struct Preferences)); ni_colCMAP [0] = Polly.color0; ni_colCMAP [1] = Polly.color1; ni_colCMAP [2] = Polly.color2; onInput (); ScreenToFront (scr); loop (z = 0; z < 16; ++z) fade (z); /* letting_The_Days_Go_By (); */ } /* end of init */ USHORT * grabChip (array, size, gadz) USHORT *array; long size; struct Gadget *gadz; { REG USHORT *myChip; IFN ( myChip = (USHORT *) AllocMem (size, MEMF_CHIP | MEMF_CLEAR)) quit ("Abort - No Fashionable, Expensive Chips Left!"); CopyMem (array, myChip, size); ((struct Image *)(gadz->GadgetRender))->ImageData = myChip; return myChip; } void new_color (wheat) ULONG wheat; /* how're the comments so far? */ { extern ULONG thisCol; ULONG thatCol; REG int z = maxsupwin; #define SCALE(i) ( (long) ( 21 + 7 * ((i) % 16) ) ) #define POINT(i) ( (i) > 15 ) ? ">": "<", 1L thatCol = thisCol; thisCol = wheat; SetAPen (reep, 0L ); RectFill (reep, 13L, 15L, 20L, 126L ); /* saturation bombing... */ SetAPen (reep, 1L ); Move (reep, 13L, SCALE (wheat) ); Text (reep, POINT (wheat) ); SetAPen (reep, wheat ); while (z--) if swin (z) SetAPen (zreep (z), (long) thisCol); if izCtrl (mrQ) SchRep ((int) thatCol); } /* end of new_color */ void clozeWB () { if (CloseWorkBench ()) Mess ("WorkBench Blown Away!"); else Mess ("No Effect!!!"); } void quit ( why ) char *why; /* give up - toss in the towel, on top of all the chips we've grabbed, scribbled upon, and now are casting aside like the chaff of our labors, back into the pool from whence the screens of the tasks of the Amiga lie. It just makes one want to stare at that space-amoeba the Enterprise once encountered for a few billenia. */ /* lagunas mentalis, no? */ { ifn (strcmp (why, "bye!")) { int hot; loop (hot = 15; hot >= 0; --hot) fade (hot); } ScreenToBack (scr); /* polished to the last */ OurTask->pr_WindowPtr = old_pr_WindowPtr; /* if ( gargc ) puts ( why ); */ if ( myBitOfChip ) FreeMem ( myBitOfChip, PICKSIZE ); if ( ni_htofChip ) FreeMem ( ni_htofChip, ni_htofSIZE ); if ( ni_unhtofChip ) FreeMem ( ni_unhtofChip, ni_unhtofSIZE ); if ( ni_htonChip ) FreeMem ( ni_htonChip, ni_htonSIZE ); if ( ni_unhtonChip ) FreeMem ( ni_unhtonChip, ni_unhtonSIZE ); if ( new____Chip ) FreeMem ( new____Chip, new____SIZE ); if ( ni_pickChip ) FreeMem ( ni_pickChip, ni_pickSIZE ); if ( ni_saveChip ) FreeMem ( ni_saveChip, ni_saveSIZE ); if ( ni_loadChip ) FreeMem ( ni_loadChip, ni_loadSIZE ); if ( ni_allQChip ) FreeMem ( ni_allQChip, ni_allQSIZE ); if ( ni_oneQChip ) FreeMem ( ni_oneQChip, ni_oneQSIZE ); if (ni_clon1Chip ) FreeMem (ni_clon1Chip,ni_clon1SIZE ); if ( ni_incChip) FreeMem ( ni_incChip, ni_incSIZE); if ( ni_fillChip) FreeMem ( ni_fillChip, ni_fillSIZE); if ( fillerChip) FreeMem ( fillerChip, FILLSIZE); if ( ni_nocmChip) FreeMem ( ni_nocmChip, ni_nocmSIZE); if ( ni_cmChip) FreeMem ( ni_cmChip, ni_cmSIZE); if ( ni_hexChip) FreeMem ( ni_hexChip, ni_decSIZE); if ( ni_decChip) FreeMem ( ni_decChip, ni_decSIZE); zapAllWindows (); closeSeqWin (); clozeClipWin (); if ( win ) CloseWindow ( win ); OpenWorkBench (); if ( scr ) CloseScreen ( scr ); if ( GfxBase ) CloseLibrary ( GfxBase ); if (IntuitionBase) CloseLibrary ( IntuitionBase ); exit ( strcmp (why, "bye!") != 0 ); } /* "It's like," Radar peered into Henry's ear, "A little nativity scene" */