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:59 2009
19 ****************************************************************************/
20 #include "tkgate.h"
21
22 GCElement *AOX_Make(EditState **,GModuleDef *,int,int,int,int,const char *,int,const char**,int);
23 void AOX_Draw(GCElement *g,int md);
24 void AOX_AddInput(EditState *es,GCElement*);
25 void AOX_VerSave(FILE*,GCElement*);
26 void AOX_SetProp(GCElement*,const char*,const void*);
27 int AOX_EditProps(GCElement *g,int isLoadDialog);
28 void AOX_PSWrite(GPrint *P,GModLayout*,GCElement *g);
29 void AOX_RemovePort(EditState *es,GCElement *g,GWire *);
30 GCElement *AOX_Copy(GModuleDef *M,GCElement *g,int x,int y,unsigned flags);
31 void AOX_WriteCellDef(FILE *f,GCellSpec *gcs);
32
33 static iconDimensions or_iconDims[] = {
34 {0, 0, 21, 15, 11, 7},
35 {22, 0, 15, 21, 7, 9},
36 {16, 22, 21, 15, 9, 7},
37 {0, 16, 15, 21, 7, 11},
38 };
39 static int or_iconBoldOffset = 38;
40
41 extern GPadLoc and_out_loc[];
42 extern GPadLoc and_in_loc[];
43
44 static char *psOr[] = {
45 "%",
46 "% An OR gate",
47 "%",
48 "/psor {",
49 " startgate",
50 " -10 -7 moveto",
51 " -2 7 14 -90 -30 arc",
52 " -2 -7 14 30 90 arc",
53 " 14 theight neg 11 sub 0 14 30 -30 arcn",
54 " closepath",
55 " stroke",
56 " grestore",
57 "} bind def",
58 0
59 };
60
61 GGateInfo gate_or_info = {
62 0,
63 "OR",
64 "or:nor",0x2,
65 "psor",psOr,
66 0,0,
67
68 {{"o", {"gm.gate",0}, {"gm.gate.or",0,0,200}, "gat_make OR"},
69 {"O", {"gm.gate",0}, {"gm.gate.nor",0,0,201}, "gat_make OR -invert Z"},
70 {"Ctl-r o", {"gm.rgate",0}, {"gm.rgate.or",0,0,200}, "gat_make OR -pins I=1"},
71 {"Ctl-r O", {"gm.rgate",0}, {"gm.rgate.nor",0,0,201}, "gat_make OR -pins I=1 -invert Z"},
72 {0}},
73
74 or_iconDims,
75
76 2,{{"I",IN,1,2,and_in_loc,1},{"Z",OUT,1,1,and_out_loc,0}},
77 {{0,-12,CT},{12,0,LJ},{0,-12,CT},{12,0,LJ}},
78 {1},
79 {"Diz",0},
80
81 AOX_Make,
82 AOX_WriteCellDef,
83 Generic_Init,
84 Generic_Delete,
85 Generic_GetExtents,
86 Generic_HitDistance,
87 AOX_Draw,
88 Generic_Move,
89 AOX_Copy,
90 AOX_AddInput,
91 Err_AddOutput,
92 Err_AddInOut,
93 Generic_Rotate,
94 AOX_RemovePort,
95 Err_ChangePin,
96 Nop_SimInitFunc,
97 Nop_SimHitFunc,
98 AOX_PSWrite,
99 AOX_EditProps,
100 AOX_VerSave,
101 AOX_SetProp
102 };
103
init_or()104 void init_or()
105 {
106 Pixmap P;
107
108 P = Pixmap_registerFromFile("or","or.b");
109 gateinfo_iconInit(&gate_or_info,P,or_iconDims,or_iconBoldOffset);
110 RegisterGate(&gate_or_info);
111 }
112