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 /* 19 Declarations for Gate operations. 20 */ 21 #ifndef __gates_h 22 #define __gates_h 23 24 /* 25 * Codes for i/o direction arrow types 26 */ 27 #define IODT_PORT 0 /* Plain arrows on block ports */ 28 #define IODT_PLAIN 1 /* Plain arrows on concat */ 29 #define IODT_BOXED 2 /* Boxed arrows on concat */ 30 31 /* 32 * Code numbers for gate types which require special handling. 33 */ 34 #define GC_BLOCK 0x1001 35 #define GC_JOINT 0x1002 36 #define GC_SWITCH 0x1003 37 #define GC_DIP 0x1004 38 #define GC_TAP 0x1005 39 #define GC_LOGICIN 0x1006 40 #define GC_LOGICOUT 0x1007 41 #define GC_LOGICTRI 0x1008 42 #define GC_REGISTER 0x1009 43 #define GC_COMMENT 0x100a 44 #define GC_LED 0x100b 45 #define GC_FLIPFLOP 0x100c 46 #define GC_SYMBLOCK 0x100d 47 #define GC_CLOCK 0x100e 48 #define GC_CONCAT 0x100f 49 #define GC_ROM 0x1010 50 #define GC_RAM 0x1011 51 #define GC_KEYPAD 0x1012 52 53 /* 54 Gate pad numbers for some of the gates. 55 */ 56 #define BLOCK_TIN 0 57 #define BLOCK_LIN 1 58 #define BLOCK_BIN 2 59 #define BLOCK_RIN 3 60 #define BLOCK_TOUT 4 61 #define BLOCK_LOUT 5 62 #define BLOCK_BOUT 6 63 #define BLOCK_ROUT 7 64 #define BLOCK_TTRI 8 65 #define BLOCK_LTRI 9 66 #define BLOCK_BTRI 10 67 #define BLOCK_RTRI 11 68 69 #define REGISTER_OUT 0 70 #define REGISTER_IN 1 71 #define REGISTER_EN 2 72 #define REGISTER_CLR 3 73 #define REGISTER_CK 4 74 75 #define FLIPFLOP_Q 0 76 #define FLIPFLOP_NQ 1 77 #define FLIPFLOP_IN 2 78 #define FLIPFLOP_EN 3 79 #define FLIPFLOP_CLR 4 80 #define FLIPFLOP_CK 5 81 82 #define LOGICIN_OUT 0 83 #define LOGICOUT_IN 0 84 85 #define TRI_OUT 0 86 87 #define DIP_OUT 0 88 89 #define TAP_TAP 0 90 #define TAP_IN 1 91 #define TAP_OUT 2 92 93 #define CONCAT_IN 0 94 #define CONCAT_OUT 1 95 96 void gate_add(GModuleDef*,GCElement *); 97 void gate_remove(GModuleDef*,GCElement *); 98 GCElement *gate_new(int x,int y,int rot,int type); 99 int gate_delete(GCElement *g,GModuleDef *env,int drawp); 100 GCElement *gate_hit(GModuleDef*,int,int); 101 void gate_displayall(GModuleDef *mdef); 102 void gate_draw(GCElement *g,int md); 103 void gate_drawgatename(GCElement *g,const char*); 104 void gate_namegate(GCElement *g,EditState *es); 105 void gate_move(GCElement *g,int x,int y); 106 void gate_mark(GCElement *g,int select); 107 void gate_getbbx(GCElement *g,TargetDev_e,int *minx,int *miny,int *maxx,int *maxy); 108 void gate_doReplication(EditState *es); 109 void gate_repgate(EditState *es,GCElement *g,int x,int y); 110 void gate_setinvertwirelist(GWire *nw,GWire *w); 111 void gate_hashrepline(EditState *es,int x,int y); 112 GCElement *gate_lookup(const char *name,GModuleDef *mdef); 113 void gate_moveTo(GCElement *g,int x,int y); 114 void gate_setName(GCElement *g,const char *name,GModuleDef *mdef); 115 void gate_cutOffWires(GCElement *g,GModuleDef *M,int drawp); 116 void gate_transmute(GCElement *g,GGateInfo *ngi); 117 void gate_moveObject(GCElement *g,int dx,int dy); 118 void gate_drawWires(GCElement *g,int md); 119 void gate_unattachwirelist(GWire *w,GModuleDef *env,int drawp); 120 121 void block_setWireEnd(GCElement *g,GWire *w,int pad); 122 GWire *block_hitPort(GCElement *g,int x,int y); 123 int Block_HitComponent(GCElement *g,int x,int y); 124 int Block_HitEdge(GCElement *g,int x,int y); 125 126 void block_updateInterface(GCElement *g,GModuleDef *m); 127 128 int GGateInfo_getPadNum(GGateInfo *gi,const char *pname); 129 130 void gateinfo_iconInit(GGateInfo *gi,Pixmap P,iconDimensions *id,int boldOffset); 131 void gateinfo_1iconInit(GGateInfo *gi,Pixmap P,iconDimensions *id,int boldOffset); 132 void gateinfo_altIconInit(GGateInfo *gi,Pixmap P,iconDimensions *id,int boldOffset); 133 134 void GGateInfo_encodeTypeName(char *buf,GCElement *g); 135 int GGateInfo_decodeTypeName(const char *name,GCellSpec *gcs); 136 137 void RegisterGate(GGateInfo *gi); 138 139 void GetPinIOMark(GWire *w,int d,int iod,int atype,int *x,int *y,Icon **arrow); 140 void DrawPinIOMark(GWire *w,int d,int iod,int atype); 141 void init_gateHashTables(void); 142 void init_specials(void); 143 144 /* 145 * Extra memory required for allocating a GCElement object with n ports. 146 */ 147 #define requiredPortMemory(n) (imax((n)-DEFAULT_PADMAX,0)*sizeof(GWire*)) 148 149 150 #endif 151