-
Notifications
You must be signed in to change notification settings - Fork 4
/
led.bmx
2295 lines (1891 loc) · 52.1 KB
/
led.bmx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Rem
****************************************************
Pinlandia - LED.BMX
****************************************************
**************** Details ***********************
- What is it?: MPF LED show script generator
- Language: Blitxmax
- Programmed by: Mark Incitti - 2017, 2018, 2019, 2020
**************** TODO ***********************
- add shape, rot, size display (in progress fall 2020)
- add a repeat/loop button (non-save only)
- FPS selector
- code refactor - move functions into types
- widebody/standard toggle (currently wide only)
**************** Done *************************
- led loading from monitor.yaml
- add a B/W toggle - either 000000 or FFFFFF based on threshold
**************** History *************************
- V3.05 - 2023/06/26
- updated mac build for 64-bit chips
- update to resolve mac issue reading pixels
- update to support linux build
- V3.04 - 2020/10/21
- correct output of non changing leds
- V3.03 - 2020/10/20
- add transparency
- output 'stop' instead of 000000 (or below BW threshold)
- V3.02 - 2020/10/16
- mac build
- move status message to top
- move RGB sliders up 20 pixels
- V3.01 - 2020/09/13
- diamonds
- V3.0 - 2020/08
- revamp the lights loading to handle shape, rotation, size fields
- V2.1 - 2019/04/06
- added a reset segment button
- V2.0 - 2019/03/31
- load light section from user selected yaml file at startup
- load new light layout from menu
- renamed ShowCreator
- V1.9 - 2019/03/10
- add an ESC -> Quit confirm y/n
- B/W toggle with B, B+SHIFT change threshold level (16-240)/256
- V1.8 - 2019/03/09
- add flushmouse and flushkeys to prevent false clicks after file loads
- remove space in #show_version=5
- V1.7 - 2018/01/17
- for mpf version 0.50 change: config version 5, leds->lights
- V1.6 - 2017/08/04
- fade_out devel experiments
- V1.57 - 2017/07/20
- make show version a variable
- V1.56 - 2017/07/10
- hold M key to go slowmo
- V1.55 - 2017/07/07
- corrected playfield width/height scale
- V1.54 - 2017/07/07
- more code cleanup
- added SPC to toggle between start/finish ends
- added L to toggle between showing shapes or LEDs
- V1.53 - 2017/07/07
- code cleanup
- V1.52 - 2017/07/07
- better behaviour when switching segments
- U key plays current segment
- V1.51 - 2017/07/06
- changed to 30 fps (previous are set to 60)
- V1.5 - 2017/07/06 (not released)
- Load/save, etc
- V1.0 - 2017/07/05
- initial release
End Rem
Strict
Framework BRL.GlMax2D
Import BRL.System
Import BRL.pngloader
Import BRL.pixmap
Import BRL.Retro
AppTitle$ = "Pinlandia - V3.05 - 2023-06-26"
SetGraphicsDriver GLMax2DDriver()
Global framerate:Int = 30
Global ms_per_frame:Int = 33
Graphics 800, 800, 0
SetClsColor 0, 0, 0
Const cMAXLEDS = 1024
Const cMAXANIMS = 256
Const cMAXIMAGES = 1000
Const cDURATION = 1023
Const cSTARTX = 50+150
Const cSTARTY = 50+300
Const infodisplayx = 420
Global SHOW_VERSION$ = "#show_version=5"
Global pixColor:appColor = New appColor
Global num_leds = 0
Global ledarray:led[]
ledarray = New led[cMAXLEDS]
'SetUpLeds()
LoadLedsFromMonitor()
Global num_images:Int = 0
Global images:TImage[]
images= New TImage[cMAXIMAGES]
Global image_filename$[cMAXIMAGES]
LoadImages()
Global anim_array:animation[]
anim_array = New animation[cMAXANIMS+1]
animation.CreateAnimations()
Global bufferAnim:animation = New animation
Global anim_index = 0
Global cur_an:animation = anim_array[anim_index]
cur_an.active = 1
Global se:Int = 1
Global g_rot = 0
Global g_sc_x:Float = 0.5
Global g_sc_y:Float = 0.5
Global g_cl_r = 200
Global g_cl_g = 128
Global g_cl_b = 200
Global first_step:Int = 0
Global animate:Int = 0
Global animate_current:Int = 0
Global flash:Int = 0
Global ledsonly:Int = 0
Global slowmo:Int = 0
Global blendit:Int = 1
Global black_white_trans:Int = 0
Global bw_threshold:Int = 32
Global adjust_get_pixel:Int = 0
Global g_fh:TStream
Global g_write_to_file:Int = 0
Local col_start_x = 650
Local col_start_y = 460
Local col_end_x = col_start_x + 80
Global gamedone:Int = 0
Global p_circ#[36]
For Local t = 0 To 17
p_circ[t*2] = Cos(t*20)*8
p_circ[t*2+1] = Sin(t*20)*8
Next
Global p_square#[]=[16.0,16.0, 16.0,-16.0, -16.0,-16.0, -16.0,16.0]
Global p_diamond#[]=[0.0,6.0, 12.0,0.0, 0.0,-6.0, -12.0,0.0]
Global p_triangle#[]=[0.0,8.0, 6.0,-4.0, -6.0,-4.0]
Global p_rectangle#[]=[-10.0,-5.0, 10.0,-5.0, 10.0,5.0, -10.0,5.0]
Global p_arrow#[]=[12.0,12.0, 12.0,-12.0, -12.0,-12.0, -12.0,12.0]
Global p_flipper#[]=[0.0,0.0, -36.0,9.0, -36.0,-9.0]
'-- main loop ---------------------------------------------------------------------------------------------------
FlushKeys()
FlushMouse()
' To work around some issue on Mac we may need to adjust how we read pixels.
' This will test to see if the alternative method is needed and automatically enable it if so.
Cls
SetColor 10,10,10
DrawRect( 400, 400, 1, 1 )
pixColor = GetPixel(400, 400)
If pixColor.red <> 10
adjust_get_pixel = 1
pixColor = GetPixel(400, 400)
If pixColor.red <> 10
adjust_get_pixel = 0
EndIf
EndIf
Repeat
Cls
Local mult:Int = 1
Local shift:Int = 0
If KeyDown(KEY_LCONTROL) Or KeyDown(KEY_RCONTROL)
mult = 10
EndIf
If KeyDown(KEY_LSHIFT) Or KeyDown(KEY_RSHIFT)
shift = 1
EndIf
' If KeyHit(KEY_M)
' slowmo = 1-slowmo
' EndIf
If KeyHit(KEY_I)
flash = 60*4
EndIf
If KeyHit(KEY_L)
ledsonly = 1-ledsonly
EndIf
If KeyHit(KEY_A)
If shift = 1
g_rot = g_rot-2*mult
Else
g_rot = g_rot+2*mult
EndIf
cur_an.set_rotation(g_rot,se)
EndIf
If KeyHit(KEY_S)
If shift = 1
g_sc_x = g_sc_x - 0.025*mult
Else
g_sc_x = g_sc_x + 0.025*mult
EndIf
cur_an.set_scale_x(g_sc_x,se)
EndIf
If KeyHit(KEY_X)
If shift = 1
g_sc_y = g_sc_y - 0.025*mult
Else
g_sc_y = g_sc_y + 0.025*mult
EndIf
cur_an.set_scale_y(g_sc_y,se)
EndIf
If KeyHit(KEY_C)
If shift = 1
g_sc_x = g_sc_x - 0.025*mult
g_sc_y = g_sc_y - 0.025*mult
Else
g_sc_x = g_sc_x + 0.025*mult
g_sc_y = g_sc_y + 0.025*mult
EndIf
cur_an.set_scale_x(g_sc_x,se)
cur_an.set_scale_y(g_sc_y,se)
EndIf
If KeyHit(KEY_B)
If shift
bw_threshold = bw_threshold + 8
If bw_threshold > (256-8) bw_threshold = 8
Else
If black_white_trans = 0
black_white_trans = 1
ElseIf black_white_trans = 1
black_white_trans = 2
Else
black_white_trans = 0
End If
EndIf
EndIf
If KeyHit(KEY_T)
cur_an.cycle_image()
EndIf
'START/END
If KeyHit(KEY_SPACE)
se = 1-se
If se = 1
cur_an.set_cur_to_start()
Else
cur_an.set_cur_to_end()
EndIf
SetGlobalValues()
EndIf
If MouseHit(1)
Local mx = MouseX()
Local my = MouseY()
If mx < 400
cur_an.set_position( MouseX(), MouseY(), se)
Else
'menu stuff
If mx > 650
'ON/OFF
If my > 10 And my < 20
cur_an.active = 1-cur_an.active
EndIf
'START/END
If my > 30 And my < 40
se = 1-se
If se = 1
cur_an.set_cur_to_start()
Else
cur_an.set_cur_to_end()
EndIf
SetGlobalValues()
EndIf
'DELAY
If my > 50 And my < 60
If mx < 690
cur_an.delaysteps = cur_an.delaysteps - 1*mult
If cur_an.delaysteps < 0 Then cur_an.delaysteps = 0
Else
cur_an.delaysteps = cur_an.delaysteps + 1*mult
If cur_an.delaysteps >1000 Then cur_an.delaysteps = 1000
EndIf
EndIf
'TIME
If my > 70 And my < 80
If mx < 690
cur_an.duration = cur_an.duration - ms_per_frame*mult
If cur_an.duration < MS_PER_FRAME Then cur_an.duration = MS_PER_FRAME
Else
cur_an.duration = cur_an.duration + ms_per_frame*mult
If cur_an.duration >30000 Then cur_an.duration = 30000
EndIf
EndIf
'ANIM SEGMENT
If my > 90 And my < 100
If mx < 690
anim_index = anim_index - 1
If anim_index < 0 Then anim_index = cMAXANIMS-1
Else
anim_index = anim_index + 1
If anim_index > cMAXANIMS-1 Then anim_index = 0
EndIf
cur_an = anim_array[anim_index]
SetGlobalValues()
EndIf
'START SHOW
If my > 110 And my < 120
cur_an.startOn = 1-cur_an.startOn
EndIf
'END SHOW
If my > 130 And my < 140
cur_an.EndOn = 1-cur_an.EndOn
EndIf
'concurrent/follows
If my > 150 And my < 150+10
cur_an.followprevious = 1-cur_an.followprevious
EndIf
'COPY
If my > 170 And my < 170+10
CopyToBuffer()
EndIf
'PASTE
If my > 190 And my < 190+10
PasteFromBuffer()
SetGlobalValues()
EndIf
'REVERSE
If my > 210 And my < 210+10
ReverseToFrom()
SetGlobalValues()
EndIf
'COPY SEGMENT
If my > 230 And my < 230+10
CopyToBuffer()
EndIf
'PASTE SEGMENT
If my > 250 And my < 250+10
PasteAllFromBuffer()
SetGlobalValues()
EndIf
'reset SEGMENT
If my > 270 And my < 270+10
ResetSegment()
EndIf
'LOAD SEGMENT
If my > 310 And my < 310+10
LoadSegment(anim_index)
FlushKeys()
FlushMouse()
EndIf
'SAVE SEGMENT
If my > 330 And my < 330+10
SaveSegment(anim_index)
FlushKeys()
FlushMouse()
EndIf
'LOAD SET
If my > 350 And my < 350+10
LoadAllSegments()
SetGlobalValues()
FlushKeys()
FlushMouse()
EndIf
'SAVE SET
If my > 370 And my < 370+10
SaveAllSegments()
FlushKeys()
FlushMouse()
EndIf
'LOAD LIGHTS
If my > 410 And my < 410+10
led.DeleteAllLeds()
LoadLedsFromMonitor()
FlushKeys()
FlushMouse()
EndIf
EndIf
EndIf
EndIf
If MouseDown(1)
Local mx = MouseX()
Local my = MouseY()
If mx < 400
cur_an.set_position( MouseX(), MouseY(), se)
If shift
cur_an.set_position( MouseX(), MouseY(), 1-se)
EndIf
Else
'menu stuff
If mx > 650
'COLOUR BARS
If my >= col_start_y+20-5 And my <= col_start_y+20+255+5
If mx > col_start_x-5 And mx < col_start_x+10+5
g_cl_r = my-col_start_y-20
If g_cl_r < 0 Then g_cl_r = 0
If g_cl_r > 255 Then g_cl_r = 255
cur_an.set_r(g_cl_r,1)
EndIf
If mx > col_start_x+20-5 And mx < col_start_x+30+5
g_cl_g = my-col_start_y-20
If g_cl_g < 0 Then g_cl_g = 0
If g_cl_g > 255 Then g_cl_g = 255
cur_an.set_g(g_cl_g,1)
EndIf
If mx > col_start_x+40-5 And mx < col_start_x+50+5
g_cl_b = my-col_start_y-20
If g_cl_b < 0 Then g_cl_b = 0
If g_cl_b > 255 Then g_cl_b = 255
cur_an.set_b(g_cl_b,1)
EndIf
If mx > col_end_x-5 And mx < col_end_x+10+5
g_cl_r = my-col_start_y-20
If g_cl_r < 0 Then g_cl_r = 0
If g_cl_r > 255 Then g_cl_r = 255
cur_an.set_r(g_cl_r,0)
EndIf
If mx > col_end_x+20-5 And mx < col_end_x+30+5
g_cl_g = my-col_start_y-20
If g_cl_g < 0 Then g_cl_g = 0
If g_cl_g > 255 Then g_cl_g = 255
cur_an.set_g(g_cl_g,0)
EndIf
If mx > col_end_x+40-5 And mx < col_end_x+50+5
g_cl_b = my-col_start_y-20
If g_cl_b < 0 Then g_cl_b = 0
If g_cl_b > 255 Then g_cl_b = 255
cur_an.set_b(g_cl_b,0)
EndIf
EndIf
EndIf
EndIf
EndIf
SetBlend alphablend
SetColor 255,255,255
DrawLine 25-2,50-2,375+2,50-2
DrawLine 25-2,50-2,25-2,750+2
DrawLine 25-2,750+2,375+2,750+2
DrawLine 375+2,50-2,375+2,750+2
SetColor 32,32,32
DrawRect 402,0,400,800
SetColor 200,200,200
DrawRect 401,0,1,800
'highlight the menu
SetColor 60,60,60
DrawRect 650-10,10-2,148,800
If mouseover(650,10)
ShowContext("Toggle animation segment ON/OFF")
SetColor 250,250,250
Else
SetColor 180,180,180
EndIf
If cur_an.active = 0
DrawText "SEGMENT OFF", 650, 10
Else
DrawText "SEGMENT ON", 650, 10
EndIf
If mouseover(650,30)
ShowContext("Toggle START or FINISH of animation segment")
SetColor 250,250,250
Else
SetColor 180,180,180
EndIf
If se = 1
DrawText "START POSITION", 650, 30
Else
DrawText "FINISH POSITION", 650, 30
EndIf
If mouseover(650,50)
ShowContext("Adjust delay time (inactive during delay) for this segment")
SetColor 250,250,250
Else
SetColor 180,180,180
EndIf
DrawText "[-] DELAY [+]", 650, 50
If mouseover(650,70)
ShowContext("Adjust length of animation section (not including delay)")
SetColor 250,250,250
Else
SetColor 180,180,180
EndIf
DrawText "[-] TIME [+]", 650, 70
If mouseover(650,90)
ShowContext("Select current animation segment")
SetColor 250,250,250
Else
SetColor 180,180,180
EndIf
DrawText "[-] SEGMENT [+]", 650, 90
If mouseover(650,110)
ShowContext("Is shape visible before start (during delay time)?")
SetColor 250,250,250
Else
SetColor 180,180,180
EndIf
If cur_an.startOn = 0
DrawText "START HIDDEN", 650, 110
Else
DrawText "START VISIBLE", 650, 110
EndIf
If mouseover(650,130)
ShowContext("Is shape visible after animation?")
SetColor 250,250,250
Else
SetColor 180,180,180
EndIf
If cur_an.EndOn = 0
DrawText "FINISH HIDDEN", 650, 130
Else
DrawText "FINISH VISIBLE", 650, 130
EndIf
If mouseover(650,150)
ShowContext("Does this segment run concurrently or after previous segments?")
SetColor 250,250,250
Else
SetColor 180,180,180
EndIf
If cur_an.followprevious = 1
DrawText "FOLLOWS", 650, 150
Else
DrawText "CONCURRENT", 650, 150
EndIf
If mouseover(650,170)
ShowContext("Copy current segment end parameters (SHAPE, POS, ROT, SCALE, COLOR)")
SetColor 250,250,250
Else
SetColor 180,180,180
EndIf
DrawText "COPY CURRENT", 650, 170
If mouseover(650,190)
ShowContext("Paste copied segment end parameters (SHAPE, POS, ROT, SCALE, COLOR)")
SetColor 250,250,250
Else
SetColor 180,180,180
EndIf
If se = 1
DrawText "PASTE (START)", 650, 190
Else
DrawText "PASTE (FINISH)", 650, 190
EndIf
If mouseover(650,210)
ShowContext("Reverse segment's START/FINISH parameters (POS, ROT, SCALE, COLOR)")
SetColor 250,250,250
Else
SetColor 180,180,180
EndIf
DrawText "REVERSE SEGMENT", 650, 210
If mouseover(650,230)
ShowContext("Copy complete animation segment (START and FINISH)")
SetColor 250,250,250
Else
SetColor 180,180,180
EndIf
DrawText "COPY SEGMENT", 650, 230
If mouseover(650,250)
ShowContext("Paste complete animation segment (START and FINISH)")
SetColor 250,250,250
Else
SetColor 180,180,180
EndIf
DrawText "PASTE SEGMENT", 650, 250
If mouseover(650,270)
ShowContext("Reset animation segment (scale, rotation, position)")
SetColor 250,250,250
Else
SetColor 180,180,180
EndIf
DrawText "RESET SEGMENT", 650, 270
If mouseover(650,310)
ShowContext("Load (from file) complete animation segment (START and FINISH)")
SetColor 250,250,250
Else
SetColor 180,180,180
EndIf
DrawText "LOAD SEGMENT", 650, 310
If mouseover(650,330)
ShowContext("Save (to file) complete animation segment (START and FINISH)")
SetColor 250,250,250
Else
SetColor 180,180,180
EndIf
DrawText "SAVE SEGMENT", 650, 330
If mouseover(650,350)
ShowContext("Load (from file) complete set of segments")
SetColor 250,250,250
Else
SetColor 180,180,180
EndIf
DrawText "LOAD SET", 650, 350
If mouseover(650,370)
ShowContext("Save (to file) complete set of segments")
SetColor 250,250,250
Else
SetColor 180,180,180
EndIf
DrawText "SAVE SET", 650, 370
If mouseover(650,410)
ShowContext("Load a new light set from a monitor.yaml file")
SetColor 250,250,250
Else
SetColor 180,180,180
EndIf
DrawText "LOAD LIGHTS", 650, 410
SetColor 180,180,180
Local blockstarty = 10
DrawText "CURRENT", infodisplayx+40 ,blockstarty
DrawText "cur x "+cur_an.x,infodisplayx ,blockstarty+20
DrawText "cur y "+cur_an.y,infodisplayx ,blockstarty+30
DrawText "cur r "+cur_an.cl_r,infodisplayx ,blockstarty+40
DrawText "cur g "+cur_an.cl_g,infodisplayx ,blockstarty+50
DrawText "cur b "+cur_an.cl_b,infodisplayx ,blockstarty+60
DrawText "cur rt "+cur_an.rot,infodisplayx ,blockstarty+70
DrawText "cur sx "+cur_an.sc_x,infodisplayx ,blockstarty+80
DrawText "cur sy "+cur_an.sc_y,infodisplayx ,blockstarty+90
blockstarty = 120
DrawText "START", infodisplayx+40,blockstarty
DrawText "x "+cur_an.start_x,infodisplayx ,blockstarty+20
DrawText "y "+cur_an.start_y,infodisplayx ,blockstarty+30
DrawText "r "+cur_an.start_cl_r,infodisplayx ,blockstarty+40
DrawText "g "+cur_an.start_cl_g,infodisplayx ,blockstarty+50
DrawText "b "+cur_an.start_cl_b,infodisplayx ,blockstarty+60
DrawText "rt "+cur_an.start_rot,infodisplayx ,blockstarty+70
DrawText "sx "+cur_an.start_sc_x,infodisplayx ,blockstarty+80
DrawText "sy "+cur_an.start_sc_y,infodisplayx ,blockstarty+90
blockstarty = 230
DrawText "FINISH", infodisplayx+40,blockstarty
DrawText "x "+cur_an.end_x,infodisplayx ,blockstarty+20
DrawText "y "+cur_an.end_y,infodisplayx ,blockstarty+30
DrawText "r "+cur_an.end_cl_r,infodisplayx ,blockstarty+40
DrawText "g "+cur_an.end_cl_g,infodisplayx ,blockstarty+50
DrawText "b "+cur_an.end_cl_b,infodisplayx ,blockstarty+60
DrawText "rt "+cur_an.end_rot,infodisplayx ,blockstarty+70
DrawText "sx "+cur_an.end_sc_x,infodisplayx ,blockstarty+80
DrawText "sy "+cur_an.end_sc_y,infodisplayx ,blockstarty+90
blockstarty = 340
DrawText "Animation Segment: "+anim_index,infodisplayx ,blockstarty
DrawText "Shape "+cur_an.image_number,infodisplayx ,blockstarty+22
DrawText image_filename[cur_an.image_number],infodisplayx+10,blockstarty+34
DrawText "Delay ms: "+cur_an.delaysteps*MS_PER_FRAME,infodisplayx ,blockstarty+58
If cur_an.startOn = 1
DrawText "Visible at Start: YES",infodisplayx ,blockstarty+70
Else
DrawText "Visible at Start: NO",infodisplayx ,blockstarty+70
EndIf
If cur_an.EndOn = 1
DrawText "Visible at End: YES",infodisplayx ,blockstarty+82
Else
DrawText "Visible at End: NO",infodisplayx ,blockstarty+82
EndIf
DrawText "Anim Duration ms: "+cur_an.duration,infodisplayx ,blockstarty+94
DrawText "Anim Steps: "+Int(cur_an.duration/MS_PER_FRAME),infodisplayx ,blockstarty+106
DrawText "Total Steps: "+(Int(cur_an.duration/MS_PER_FRAME)+cur_an.delaysteps),infodisplayx ,blockstarty+118
If ledsonly = 1
DrawText "SHOWING LEDs (SHAPES HIDDEN)",infodisplayx ,blockstarty+130
Else
DrawText "SHOWING SHAPES",infodisplayx ,blockstarty+130
EndIf
If black_white_trans = 1
DrawText "BLACK AND WHITE ("+bw_threshold+")",infodisplayx ,blockstarty+142
ElseIf black_white_trans = 2
DrawText "TRANSPARENT ("+bw_threshold+")",infodisplayx ,blockstarty+142
Else
DrawText "FULL COLOUR",infodisplayx ,blockstarty+142
EndIf
blockstarty = 500
DrawText " KEYS",infodisplayx ,blockstarty
DrawText "T - Change Image",infodisplayx ,blockstarty+18
DrawText "A - Adjust Rotation ",infodisplayx ,blockstarty+30
DrawText "S - Adjust Scale X",infodisplayx ,blockstarty+42
DrawText "X - Adjust Scale Y",infodisplayx ,blockstarty+54
DrawText "C - Adjust Scale XY",infodisplayx ,blockstarty+66
DrawText " +SHIFT for Negative",infodisplayx ,blockstarty+78
DrawText " +CTRL for x10",infodisplayx ,blockstarty+90
DrawText "I - FLASH START/FINISH",infodisplayx ,blockstarty+102
DrawText "U - PLAY SEGMENT",infodisplayx ,blockstarty+114
DrawText "L - TOGGLE SHAPES/LEDS",infodisplayx ,blockstarty+126
DrawText "B - BW/COLOUR/TRANS",infodisplayx ,blockstarty+138
DrawText "SPC - TOGGLE START/FINISH",infodisplayx ,blockstarty+150
DrawText "M - HOLD FOR SLOWMO",infodisplayx ,blockstarty+162
DrawText "P - PLAY SET",infodisplayx ,blockstarty+180
DrawText "P+SHIFT - SAVE SCRIPT",infodisplayx ,blockstarty+192
DrawText "ESC - QUIT",infodisplayx ,blockstarty+214
'colour graphs
DrawText " START", col_start_x, col_start_y
DrawText "FINISH", col_end_x, col_start_y
For Local t:Int = 0 To 255
SetColor t,0,0
DrawRect col_start_x,col_start_y+20+t,10,1
SetColor 0,t,0
DrawRect col_start_x+20,col_start_y+20+t,10,1
SetColor 0,0,t
DrawRect col_start_x+40,col_start_y+20+t,10,1
Next
SetColor 128,128,128
DrawRect col_start_x,col_start_y+20+cur_an.start_cl_r,10,1
DrawRect col_start_x+20,col_start_y+20+cur_an.start_cl_g,10,1
DrawRect col_start_x+40,col_start_y+20+cur_an.start_cl_b,10,1
SetColor cur_an.start_cl_r,cur_an.start_cl_g,cur_an.start_cl_b
DrawRect col_start_x,col_start_y+285,50,10
For Local t:Int = 0 To 255
SetColor t,0,0
DrawRect col_end_x,col_start_y+20+t,10,1
SetColor 0,t,0
DrawRect col_end_x+20,col_start_y+20+t,10,1
SetColor 0,0,t
DrawRect col_end_x+40,col_start_y+20+t,10,1
Next
SetColor 128,128,128
DrawRect col_end_x,col_start_y+20+cur_an.end_cl_r,10,1
DrawRect col_end_x+20,col_start_y+20+cur_an.end_cl_g,10,1
DrawRect col_end_x+40,col_start_y+20+cur_an.end_cl_b,10,1
SetColor cur_an.end_cl_r,cur_an.end_cl_g,cur_an.end_cl_b
DrawRect col_end_x,col_start_y+285,50,10
If KeyHit(KEY_P)
If KeyDown(KEY_LSHIFT)
g_write_to_file = 1
openOutputFile()
EndIf
write_a_line(SHOW_VERSION)
write_a_line("- time: 0")
animate = 1
start_animation()
first_step = 1
EndIf
If KeyHit(KEY_U)
animate_current = 1
start_animation()
EndIf
If animate = 1
update_shapes()
If animate = 0
Cls
Else
draw_Shapes()
EndIf
led.updatecolors()
led.dumpstate(1)
first_step = 0
Else
If animate_current = 1
update_Current_shape()
If animate_current = 0
'Cls
Else
draw_Shapes()
EndIf
led.updatecolors()
Else
draw_Shapes()
EndIf
EndIf
If ledsonly
led.updatecolors()
SetBlend solidblend
SetRotation 0
SetScale 1,1
SetAlpha 1
SetLineWidth 1.0
SetColor 0,0,0
DrawRect 25,50,350,700
SetBlend lightblend
EndIf
led.DrawLeds()
Flip
If KeyDown(KEY_M) Delay 500
If KeyHit(KEY_ESCAPE)
gamedone = Conf()
EndIf
Until gamedone
End
'-----------------------------------------------------------------------------------------------------
Function Conf:Int()
Local done:Int = False
Local qt = False
Local tim, cnt
ShowContext("Quit? Y/N")
SetColor 250,250,250
Flip
FlushKeys()
While Not done
tim = MilliSecs()
If KeyHit(KEY_Y) Then qt=True;done=True
If KeyHit(KEY_N) Then qt=False;done=True
cnt:+1
tim = MilliSecs() - tim
If tim < 20 And tim > 0
Delay 20-tim
EndIf
Wend
Return qt
End Function
Function ShowContext(txt$)
SetColor 80,80,80
'DrawRect 20,750,610,40
DrawRect 20,10-4,610,40
SetColor 240,240,240
'DrawText txt, 30,760
DrawText txt, 30,20-4
End Function
Function mouseover:Int(x:Int,y:Int)
Local my:Int, mx:Int
my = MouseY()
mx = MouseX()
If mx > x And my > y And my < y+10
Return 1
Else
Return 0
EndIf
End Function
Function SetGlobalValues()
If se = 1
g_cl_r = cur_an.start_cl_r
g_cl_g = cur_an.start_cl_g
g_cl_b = cur_an.start_cl_b
g_sc_x = cur_an.start_sc_x
g_sc_y = cur_an.start_sc_y
g_rot = cur_an.start_rot
Else
g_cl_r = cur_an.end_cl_r
g_cl_g = cur_an.end_cl_g
g_cl_b = cur_an.end_cl_b
g_sc_x = cur_an.end_sc_x
g_sc_y = cur_an.end_sc_y
g_rot = cur_an.end_rot
EndIf
End Function
Type animation
Field anim_number:Int
Field image_number:Int
Field active:Int
Field delaysteps:Int
Field startOn:Int
Field EndOn:Int
Field followprevious:Int
Field duration:Int
Field total_steps:Int
Field current_step:Int
Field delay_count:Int