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:17:52 2009
19 ****************************************************************************/
20 #include "tkgate.h"
21
22 #define RSHIFT_IN 0
23 #define RSHIFT_OUT 1
24 #define RSHIFT_SHIFT 2
25
26 void Shift_WriteCellDef(FILE *f,GCellSpec *gcs);
27
28 static iconDimensions rshift_iconDims[] = {
29 {0, 21, 75, 20, 36, 9},
30 {76, 0, 20, 75, 10, 37},
31 {0, 0, 75, 20, 36, 9},
32 {97, 0, 20, 75, 10, 37},
33 };
34 static int rshift_iconBoldOffset = 76;
35
36 GPadLoc rshifter_in_loc[] = {
37 {0,-10,0,-10,D_UP},
38 {-11,0,-11,0,D_LEFT},
39 {0,11,0,11,D_DOWN},
40 {10,0,10,0,D_RIGHT}};
41
42 GPadLoc rshifter_out_loc[] = {
43 {0,11,0,11,D_DOWN},
44 {10,0,10,0,D_RIGHT},
45 {0,-10,0,-10,D_UP},
46 {-11,0,-11,0,D_LEFT}};
47
48 GPadLoc rshifter_shift_loc[] = {
49 {-37,0,-37,0,D_LEFT},
50 {0,38,0,38,D_DOWN},
51 {39,0,39,0,D_RIGHT},
52 {0,-38,0,-38,D_UP}};
53
54 static char *psRshifter[] = {
55 "%",
56 "% A Rshifter",
57 "/psrshift {",
58 " 180 sub neg 360 mod neg",
59 " pslshift",
60 "} def",
61 0
62 };
63
64 GGateInfo gate_rshifter_info = {
65 0,
66 "RSHIFT",
67 "rshift",0x0,
68 "psrshift",psRshifter,
69 -1,1,
70
71 {{"S R", {"gm.alu",0}, {"gm.alu.rshift",0,"shift",200}, "gat_make RSHIFT"},
72 {0}},
73
74
75 rshift_iconDims,
76
77 3,{{"I",IN,8,1,rshifter_in_loc},
78 {"Z",OUT,8,1,rshifter_out_loc},
79 {"S",IN,3,1,rshifter_shift_loc}},
80 {{12,-12,LJ},{12,-12,LJ},{12,-12,LJ},{12,-12,LJ}},
81 {1},
82
83 {"Dsz","Diz",0},
84
85 Generic_Make,
86 Shift_WriteCellDef,
87 Generic_Init,
88 Generic_Delete,
89 Generic_GetExtents,
90 Generic_HitDistance,
91 Generic_Draw,
92 Generic_Move,
93 Generic_Copy,
94 Err_AddInput,
95 Err_AddOutput,
96 Err_AddInOut,
97 Generic_Rotate,
98 Err_RemovePort,
99 Err_ChangePin,
100 Nop_SimInitFunc,
101 Nop_SimHitFunc,
102 Generic_PSWrite,
103 Generic_EditProps,
104 Generic_VerSave
105 };
106
init_rshift()107 void init_rshift()
108 {
109 Pixmap P;
110
111 P = Pixmap_find("shift");
112 gateinfo_iconInit(&gate_rshifter_info,P,rshift_iconDims,rshift_iconBoldOffset);
113 RegisterGate(&gate_rshifter_info);
114 }
115