1 /****************************************************************************
2     Copyright (C) 1987-2015 by Jeffery P. Hansen
3 
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8 
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13 
14     You should have received a copy of the GNU General Public License along
15     with this program; if not, write to the Free Software Foundation, Inc.,
16     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 
18     Last edit by hansen on Mon Jan 19 18:16:29 2009
19 ****************************************************************************/
20 #include "tkgate.h"
21 
22 #define LSHIFT_IN 0
23 #define LSHIFT_OUT 1
24 #define LSHIFT_SHIFT 2
25 
26 void Shift_WriteCellDef(FILE *f,GCellSpec *gcs);
27 
28 static iconDimensions lshift_iconDims[] = {
29   {0,  0, 75, 20, 36, 9},
30   {97, 0, 20, 75, 10, 37},
31   {0, 21, 75, 20, 36, 9},
32   {76, 0, 20, 75, 10, 37},
33 };
34 static int lshift_iconBoldOffset = 76;
35 
36 
37 GPadLoc lshifter_in_loc[] = {
38 	{0,-10,0,-10,D_UP},
39 	{-11,0,-11,0,D_LEFT},
40 	{0,11,0,11,D_DOWN},
41 	{10,0,10,0,D_RIGHT}};
42 
43 GPadLoc lshifter_out_loc[] = {
44 	{0,11,0,11,D_DOWN},
45 	{10,0,10,0,D_RIGHT},
46 	{0,-10,0,-10,D_UP},
47 	{-11,0,-11,0,D_LEFT}};
48 
49 GPadLoc lshifter_shift_loc[] = {
50 	{-37,0,-37,0,D_LEFT},
51 	{0,38,0,38,D_DOWN},
52 	{39,0,39,0,D_RIGHT},
53 	{0,-38,0,-38,D_UP}};
54 
55 static char *psLshifter[] = {
56   "%",
57   "% A Lshift",
58   "/pslshift {",
59   "  [[0 .5][-.5 .5][2 0.5][0 -.5]] adjstartgate",
60   "  -31 -10.5 moveto",
61   "  -37.5 -5 lineto",
62   "  -37.5 4 lineto",
63   "  -31 10.5 lineto",
64   "  31 10.5 lineto",
65   "  37.5 4 lineto",
66   "  37.5 -5 lineto",
67   "  31 -10.5 lineto",
68   "  closepath stroke",
69   "  7 2 moveto",
70   "  -3 2 lineto",
71   "  -3 5 lineto",
72   "  -9 0 lineto",
73   "  -3 -5 lineto",
74   "  -3 -2 lineto",
75   "  7 -2 lineto",
76   "  closepath fill",
77   "  grestore",
78   "} def",
79   0
80 };
81 
82 GGateInfo gate_lshifter_info = {
83   0,
84   "LSHIFT",
85   "lshift",0x0,
86   "pslshift",psLshifter,
87   -1,1,
88 
89   {{"S L",	{"gm.alu",0},		{"gm.alu.lshift",0,"shift",100},	"gat_make LSHIFT"},
90    {0}},
91 
92 
93   lshift_iconDims,
94 
95   3,{{"I",IN,8,1,lshifter_in_loc},
96        {"Z",OUT,8,1,lshifter_out_loc},
97        {"S",IN,3,1,lshifter_shift_loc}},
98   {{12,-12,LJ},{12,-12,LJ},{12,-12,LJ},{12,-12,LJ}},
99   {1},
100 
101   {"Dsz","Diz",0},
102 
103   Generic_Make,
104   Shift_WriteCellDef,
105   Generic_Init,
106   Generic_Delete,
107   Generic_GetExtents,
108   Generic_HitDistance,
109   Generic_Draw,
110   Generic_Move,
111   Generic_Copy,
112   Err_AddInput,
113   Err_AddOutput,
114   Err_AddInOut,
115   Generic_Rotate,
116   Err_RemovePort,
117   Err_ChangePin,
118   Nop_SimInitFunc,
119   Nop_SimHitFunc,
120   Generic_PSWrite,
121   Generic_EditProps,
122   Generic_VerSave
123 };
124 
init_lshift()125 void init_lshift()
126 {
127   Pixmap P;
128 
129   P = Pixmap_registerFromFile("shift","shift.b");
130   gateinfo_iconInit(&gate_lshifter_info,P,lshift_iconDims,lshift_iconBoldOffset);
131   RegisterGate(&gate_lshifter_info);
132 }
133