home *** CD-ROM | disk | FTP | other *** search
- #include "precognition3d.h"
- #include "precognition_utils.h"
- #ifndef __GNUC__
- #include <clib/exec_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/graphics_protos.h>
- #endif
- #ifdef __GNUC__
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/graphics.h>
- #endif
- #ifdef __SASC
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/graphics.h>
- #endif
-
- #include "amigamem.h"
- /* Additions for prototypes -- EDB */
- #include "Intuition_utils.h"
- #include <stdlib.h> /* for memory functions -- EDB */
-
- /* PENS to use for 3d drawing */
- /* Foreground, Background, Highlight, Shadow */
-
- /* 1 bitplane = 2 colors */
- pcg_3DPens Std_mono_pens = { 1, 0, 1, 1 }; /* good for both 1.3 and 2.x */
-
- /* 2 bitplane and above >= 4 colors */
- pcg_3DPens Std_v20_pens = { 1, 0, 2, 1 }; /* correct */
- pcg_3DPens Std_v13_pens = { 1, 0, 1, 2 }; /* correct */
-
-
- pcg_3DPens StandardPens( void )
- {
- return (is_Workbench_v2()) ? Std_v20_pens : Std_v13_pens;
- }
-
- pcg_3DPens StandardScreenPens( struct Screen *whichscreen )
- {
- /*
- * Purpose: to get proper pens for a given screen
- *
- * mostly to change 3D look to 2D style under monochrome screens
- * Later we might want to have more standard pens for fancier gadgets
- *
- */
-
- struct Screen *testme = NULL;
- int Depth = 0;
-
- if( whichscreen == NULL )
- {
- if( is_Workbench_v2() )
- {
- testme = LockPubScreen( NULL );
- /* Lock default publicscreen here */
- /* testme = default publicscreen */
- }
- else
- {
- /* Lock Workbench Screen here */
- /* testme = Workbench screen */
- testme = malloc( sizeof(struct Screen) );
- GetScreenData(testme, sizeof(struct Screen), WBENCHSCREEN, NULL);
- }
- }
- else /* We have a valid pointer */
- {
- testme = whichscreen;
- }
- /* Lock Screen */
- /* Get Screen Depth here */
- Depth = testme->RastPort.BitMap->Depth;
-
- /* Unlock screen or free resources */
- if( is_Workbench_v2() )
- {
- UnlockPubScreen( NULL, testme );
- }
- else /* 1.3 Amiga OS */
- {
- /* UnLock Workbench Screen here */
- free( testme );
- }
-
- /* If Screen Depth = 1 (monochrome) */ /* Use standard 2D pens */
- if( Depth == 1 )
- return Std_mono_pens;
-
- else /* 4 color 3D style is OK */
- return (is_Workbench_v2()) ? Std_v20_pens : Std_v13_pens;
-
- }
-
- void pcg_Init3DBox( pcg_3DBox *Box,
- SHORT LeftEdge,
- SHORT TopEdge,
- USHORT Width,
- USHORT Height,
- UBYTE TopLeftPen,
- UBYTE BottomRightPen,
- Border *NextBorder )
- {
- SHORT Wm1, Wm2, Hm1, Hm2;
-
- Box->TopLeft.LeftEdge = LeftEdge;
- Box->TopLeft.TopEdge = TopEdge;
- Box->TopLeft.FrontPen = TopLeftPen;
- Box->TopLeft.DrawMode = JAM1;
- Box->TopLeft.NextBorder = &Box->BottomRight;
-
- Box->BottomRight.LeftEdge = LeftEdge;
- Box->BottomRight.TopEdge = TopEdge;
- Box->BottomRight.FrontPen = BottomRightPen;
- Box->BottomRight.DrawMode = JAM1;
- Box->BottomRight.NextBorder = NextBorder;
-
- Wm1 = Width-1;
- Wm2 = Width-2;
- Hm1 = Height-1;
- Hm2 = Height-2;
-
- Box->Points[ 0] = Wm1;
- Box->Points[ 1] = 0;
- Box->Points[ 2] = 0;
- Box->Points[ 3] = 0;
- Box->Points[ 4] = 0;
- Box->Points[ 5] = Hm1;
- Box->Points[ 6] = 1;
- Box->Points[ 7] = Hm2;
- Box->Points[ 8] = 1;
- Box->Points[ 9] = 1;
-
- Box->Points[10] = 1;
- Box->Points[11] = Hm1;
- Box->Points[12] = Wm1;
- Box->Points[13] = Hm1;
- Box->Points[14] = Wm1;
- Box->Points[15] = 0;
- Box->Points[16] = Wm2;
- Box->Points[17] = 1;
- Box->Points[18] = Wm2;
- Box->Points[19] = Hm2;
-
- Box->TopLeft.Count = 5;
- Box->TopLeft.XY = (SHORT *) &Box->Points[0];
- Box->BottomRight.Count = 5;
- Box->BottomRight.XY = (SHORT *) &Box->Points[10];
- }
-
- void pcg_Init3DBevel( pcg_3DBevel *Bevel,
- SHORT LeftEdge,
- SHORT TopEdge,
- USHORT Width,
- USHORT Height,
- USHORT BevelWidth,
- UBYTE TopLeftPen,
- UBYTE BottomRightPen,
- Border *NextBorder )
- {
- pcg_Init3DBox( &Bevel->Outer,
- LeftEdge, TopEdge,
- Width, Height,
- TopLeftPen, BottomRightPen,
- &Bevel->Inner.TopLeft );
-
- pcg_Init3DBox( &Bevel->Inner,
- LeftEdge+2, TopEdge+1,
- Width-4-BevelWidth, Height-2-BevelWidth,
- BottomRightPen, TopLeftPen,
- NextBorder );
- }
-
- typedef struct pcg_DoubleBorder
- {
- Border b1, b2;
- } pcg_DoubleBorder;
-
- void pcg_Init3DThinBox( pcg_DoubleBorder *db,
- SHORT LeftEdge,
- SHORT TopEdge,
- USHORT Width,
- USHORT Height,
- SHORT *Points,
- UBYTE TopLeftPen,
- UBYTE BottomRightPen,
- Border *NextBorder )
- {
- SHORT Wm1, Hm1;
-
- db->b1.LeftEdge = db->b2.LeftEdge = LeftEdge;
- db->b1.TopEdge = db->b2.TopEdge = TopEdge;
- db->b1.DrawMode = db->b2.DrawMode = JAM1;
- db->b1.FrontPen = TopLeftPen;
- db->b2.FrontPen = BottomRightPen;
- db->b1.NextBorder = &db->b2;
- db->b2.NextBorder = NextBorder;
- db->b1.XY = &Points[0];
- db->b1.Count = 3;
- db->b2.XY = &Points[4];
- db->b2.Count = 3;
-
- Wm1 = Width-1;
- Hm1 = Height-1;
-
- Points[ 0] = Wm1;
- Points[ 1] = 0;
- Points[ 2] = 0;
- Points[ 3] = 0;
- Points[ 4] = 0;
- Points[ 5] = Hm1;
- Points[ 6] = Wm1;
- Points[ 7] = Hm1;
- Points[ 8] = Wm1;
- Points[ 9] = 0;
-
- }
-
-
- void pcg_Init3DThinBevel( pcg_3DThinBevel *Bevel,
- SHORT LeftEdge,
- SHORT TopEdge,
- USHORT Width,
- USHORT Height,
- USHORT BevelWidth,
- UBYTE TopLeftPen,
- UBYTE BottomRightPen,
- Border *NextBorder )
- {
- pcg_Init3DThinBox( (pcg_DoubleBorder*) &Bevel->b[0],
- LeftEdge, TopEdge,
- Width, Height,
- &Bevel->Points[0],
- TopLeftPen, BottomRightPen,
- &Bevel->b[2] );
-
- pcg_Init3DThinBox( (pcg_DoubleBorder*) &Bevel->b[2],
- LeftEdge+1, TopEdge+1,
- Width-2-BevelWidth, Height-2-BevelWidth,
- &Bevel->Points[10],
- BottomRightPen, TopLeftPen,
- NextBorder );
-
- }
-
-