@@ -9,13 +9,9 @@ namespace DLS.Game
99 public static class BuiltinChipCreator
1010 {
1111 static readonly Color ChipCol_SplitMerge = new ( 0.1f , 0.1f , 0.1f ) ; //new(0.8f, 0.8f, 0.8f);
12- static bool AllBlack ;
13- static Color AllBlackColor = Color . black ;
1412
15- public static ChipDescription [ ] CreateAllBuiltinChipDescriptions ( ProjectDescription description )
13+ public static ChipDescription [ ] CreateAllBuiltinChipDescriptions ( )
1614 {
17- AllBlack = description . ProjectName . Contains ( "ahic" ) ;
18-
1915 return new [ ]
2016 {
2117 // ---- I/O Pins ----
@@ -26,21 +22,14 @@ public static ChipDescription[] CreateAllBuiltinChipDescriptions(ProjectDescript
2622 CreateInputOrOutputPin ( ChipType . In_8Bit ) ,
2723 CreateInputOrOutputPin ( ChipType . Out_8Bit ) ,
2824 CreateInputKeyChip ( ) ,
29- CreateInputButtonChip ( ) ,
30- CreateInputToggleChip ( ) ,
31-
3225 // ---- Basic Chips ----
3326 CreateNand ( ) ,
3427 CreateTristateBuffer ( ) ,
3528 CreateClock ( ) ,
3629 CreatePulse ( ) ,
37- CreateConstant_8 ( ) ,
38-
3930 // ---- Memory ----
4031 dev_CreateRAM_8 ( ) ,
4132 CreateROM_8 ( ) ,
42- CreateEEPROM_8 ( ) ,
43-
4433 // ---- Merge / Split ----
4534 CreateBitConversionChip ( ChipType . Split_4To1Bit , PinBitCount . Bit4 , PinBitCount . Bit1 , 1 , 4 ) ,
4635 CreateBitConversionChip ( ChipType . Split_8To4Bit , PinBitCount . Bit8 , PinBitCount . Bit4 , 1 , 2 ) ,
@@ -70,7 +59,7 @@ public static ChipDescription[] CreateAllBuiltinChipDescriptions(ProjectDescript
7059
7160 static ChipDescription CreateNand ( )
7261 {
73- Color col = GetColor ( new ( 0.73f , 0.26f , 0.26f ) ) ;
62+ Color col = new ( 0.73f , 0.26f , 0.26f ) ;
7463 Vector2 size = new ( CalculateGridSnappedWidth ( GridSize * 8 ) , GridSize * 4 ) ;
7564
7665 PinDescription [ ] inputPins = { CreatePinDescription ( "IN B" , 0 ) , CreatePinDescription ( "IN A" , 1 ) } ;
@@ -81,7 +70,7 @@ static ChipDescription CreateNand()
8170
8271 static ChipDescription CreateBuzzer ( )
8372 {
84- Color col = GetColor ( new ( 0 , 0 , 0 ) ) ;
73+ Color col = new ( 0 , 0 , 0 ) ;
8574
8675 PinDescription [ ] inputPins =
8776 {
@@ -115,7 +104,7 @@ static ChipDescription CreateRTC()
115104
116105 static ChipDescription dev_CreateRAM_8 ( )
117106 {
118- Color col = GetColor ( new ( 0.85f , 0.45f , 0.3f ) ) ;
107+ Color col = new ( 0.85f , 0.45f , 0.3f ) ;
119108
120109 PinDescription [ ] inputPins =
121110 {
@@ -143,12 +132,17 @@ static ChipDescription CreateROM_8()
143132 CreatePinDescription ( "OUT A" , 2 , PinBitCount . Bit8 )
144133 } ;
145134
146- Color col = GetColor ( new ( 0.25f , 0.35f , 0.5f ) ) ;
135+ Color col = new ( 0.25f , 0.35f , 0.5f ) ;
147136 Vector2 size = new ( GridSize * 12 , SubChipInstance . MinChipHeightForPins ( inputPins , outputPins ) ) ;
148137
149138 return CreateBuiltinChipDescription ( ChipType . Rom_256x16 , size , col , inputPins , outputPins ) ;
150139 }
151140
141+ < << << << HEAD
142+ static ChipDescription CreateInputKeyChip( )
143+ {
144+ Color col = new ( 0.1f , 0.1f , 0.1f ) ;
145+ = == == ==
152146 static ChipDescription CreateEEPROM_8 ( )
153147 {
154148 PinDescription [ ] inputPins =
@@ -171,74 +165,21 @@ static ChipDescription CreateEEPROM_8()
171165 return CreateBuiltinChipDescription ( ChipType . EEPROM_256x16 , size , col , inputPins , outputPins ) ;
172166 }
173167
174- static ChipDescription CreateConstant_8 ( )
175- {
176- PinDescription [ ] outputPins =
177- {
178- CreatePinDescription ( "VALUE OUT" , 0 , PinBitCount . Bit8 ) ,
179- } ;
180-
181- Color col = new ( 0.1f , 0.1f , 0.1f ) ;
182- Vector2 size = Vector2 . one * GridSize * 6 ;
183-
184- return CreateBuiltinChipDescription ( ChipType . Constant_8Bit , size , col , null , outputPins ) ;
185- }
186-
187-
188168 static ChipDescription CreateInputKeyChip ( )
189169 {
190170 Color col = GetColor ( new ( 0.1f , 0.1f , 0.1f ) ) ;
171+ > >>> >>> parent of dbecdc9 ( Merge pull request #8 from firecerne / constant )
191172 Vector2 size = new Vector2 ( GridSize , GridSize ) * 3 ;
192173
193174 PinDescription [ ] outputPins = { CreatePinDescription ( "OUT" , 0 ) } ;
194175
195176 return CreateBuiltinChipDescription ( ChipType . Key , size , col , null , outputPins , null , NameDisplayLocation . Hidden ) ;
196177 }
197178
198- static ChipDescription CreateInputButtonChip ( )
199- {
200- Color col = GetColor ( new ( 0.1f , 0.1f , 0.1f ) ) ;
201- Vector2 size = new Vector2 ( GridSize , GridSize ) * 3 ;
202- float displayWidth = size . x - GridSize * 0.5f ;
203-
204- PinDescription [ ] outputPins = { CreatePinDescription ( "OUT" , 0 ) } ;
205- DisplayDescription [ ] displays =
206- {
207- new ( )
208- {
209- Position = Vector2 . zero ,
210- Scale = displayWidth ,
211- SubChipID = - 1
212- }
213- } ;
214-
215- return CreateBuiltinChipDescription ( ChipType . Button , size , col , null , outputPins , displays , NameDisplayLocation . Hidden ) ;
216- }
217179
218- static ChipDescription CreateInputToggleChip ( )
219- {
220- Color col = GetColor ( new ( 70 , 130 , 180 ) ) ;
221- Vector2 size = new Vector2 ( 1f , 2f ) * GridSize ;
222- float displayWidth = size . x ;
223-
224- PinDescription [ ] outputPins = { CreatePinDescription ( "OUT" , 0 ) } ;
225- DisplayDescription [ ] displays =
226- {
227- new ( )
228- {
229- Position = Vector2 . zero ,
230- Scale = displayWidth ,
231- SubChipID = - 1
232- }
233- } ;
234-
235- return CreateBuiltinChipDescription ( ChipType . Toggle , size , col , null , outputPins , displays , NameDisplayLocation . Hidden ) ;
236- }
237-
238-
239- static ChipDescription CreateTristateBuffer ( )
180+ static ChipDescription CreateTristateBuffer ( )
240181 {
241- Color col = GetColor ( new ( 0.1f , 0.1f , 0.1f ) ) ;
182+ Color col = new ( 0.1f , 0.1f , 0.1f ) ;
242183 Vector2 size = new ( CalculateGridSnappedWidth ( 1.5f ) , GridSize * 5 ) ;
243184
244185 PinDescription [ ] inputPins = { CreatePinDescription ( "IN" , 0 ) , CreatePinDescription ( "ENABLE" , 1 ) } ;
@@ -250,7 +191,7 @@ static ChipDescription CreateTristateBuffer()
250191 static ChipDescription CreateClock ( )
251192 {
252193 Vector2 size = new ( GridHelper . SnapToGrid ( 1 ) , GridSize * 3 ) ;
253- Color col = GetColor ( new ( 0.1f , 0.1f , 0.1f ) ) ;
194+ Color col = new ( 0.1f , 0.1f , 0.1f ) ;
254195 PinDescription [ ] outputPins = { CreatePinDescription ( "CLK" , 0 ) } ;
255196
256197 return CreateBuiltinChipDescription ( ChipType . Clock , size , col , null , outputPins ) ;
@@ -259,7 +200,7 @@ static ChipDescription CreateClock()
259200 static ChipDescription CreatePulse ( )
260201 {
261202 Vector2 size = new ( GridHelper . SnapToGrid ( 1 ) , GridSize * 3 ) ;
262- Color col = GetColor ( new ( 0.1f , 0.1f , 0.1f ) ) ;
203+ Color col = new ( 0.1f , 0.1f , 0.1f ) ;
263204 PinDescription [ ] inputPins = { CreatePinDescription ( "IN" , 0 ) } ;
264205 PinDescription [ ] outputPins = { CreatePinDescription ( "PULSE" , 1 ) } ;
265206
@@ -286,7 +227,7 @@ static ChipDescription CreateBitConversionChip(ChipType chipType, PinBitCount bi
286227 float height = SubChipInstance . MinChipHeightForPins ( inputPins , outputPins ) ;
287228 Vector2 size = new ( GridSize * 9 , height ) ;
288229
289- return CreateBuiltinChipDescription ( chipType , size , GetColor ( ChipCol_SplitMerge ) , inputPins , outputPins ) ;
230+ return CreateBuiltinChipDescription ( chipType , size , ChipCol_SplitMerge , inputPins , outputPins ) ;
290231 }
291232
292233 static string GetPinName ( int pinIndex , int pinCount , bool isInput )
@@ -310,7 +251,7 @@ static ChipDescription CreateDisplay7Seg()
310251 CreatePinDescription ( "COL" , 7 )
311252 } ;
312253
313- Color col = GetColor ( new ( 0.1f , 0.1f , 0.1f ) ) ;
254+ Color col = new ( 0.1f , 0.1f , 0.1f ) ;
314255 float height = SubChipInstance . MinChipHeightForPins ( inputPins , null ) ;
315256 Vector2 size = new ( GridSize * 10 , height ) ;
316257 float displayWidth = size . x - GridSize * 2 ;
@@ -333,7 +274,7 @@ static ChipDescription CreateDisplayRGB()
333274 float width = height ;
334275 float displayWidth = height - GridSize * 2 ;
335276
336- Color col = GetColor ( new ( 0.1f , 0.1f , 0.1f ) ) ;
277+ Color col = new ( 0.1f , 0.1f , 0.1f ) ;
337278 Vector2 size = new ( width , height ) ;
338279
339280 PinDescription [ ] inputPins =
@@ -389,7 +330,7 @@ static ChipDescription CreateDisplayDot()
389330 float width = height ;
390331 float displayWidth = height - GridSize * 2 ;
391332
392- Color col = GetColor ( new ( 0.1f , 0.1f , 0.1f ) ) ;
333+ Color col = new ( 0.1f , 0.1f , 0.1f ) ;
393334 Vector2 size = new ( width , height ) ;
394335
395336
@@ -445,7 +386,7 @@ static ChipDescription CreateBus(PinBitCount bitCount)
445386 PinDescription [ ] inputs = { CreatePinDescription ( name + " (Hidden)" , 0 , bitCount ) } ;
446387 PinDescription [ ] outputs = { CreatePinDescription ( name , 1 , bitCount ) } ;
447388
448- Color col = GetColor ( new ( 0.1f , 0.1f , 0.1f ) ) ;
389+ Color col = new ( 0.1f , 0.1f , 0.1f ) ;
449390
450391 return CreateBuiltinChipDescription ( type , BusChipSize ( bitCount ) , col , inputs , outputs , null , NameDisplayLocation . Hidden ) ;
451392 }
@@ -461,7 +402,7 @@ static ChipDescription CreateDisplayLED()
461402 float width = height ;
462403 float displayWidth = height - GridSize * 0.5f ;
463404
464- Color col = GetColor ( new ( 0.1f , 0.1f , 0.1f ) ) ;
405+ Color col = new ( 0.1f , 0.1f , 0.1f ) ;
465406 Vector2 size = new ( width , height ) ;
466407
467408
@@ -550,10 +491,5 @@ void AddPins(PinDescription[] pins)
550491 }
551492 }
552493 }
553-
554- static Color GetColor ( Color color )
555- {
556- return AllBlack ? AllBlackColor : color ;
557- }
558494 }
559495}
0 commit comments