-
Notifications
You must be signed in to change notification settings - Fork 0
/
PALEDIT2.BAS
2432 lines (1990 loc) · 60 KB
/
PALEDIT2.BAS
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
' Palette Editor 2.0
' by Plasma / Jon Petrosky [3-19-2001]
' www.phatcode.net
DEFINT A-Z
'$DYNAMIC
'$INCLUDE: 'QB.BI'
'$LIB: 'QB.LIB'
TYPE PalType
Red AS INTEGER
Green AS INTEGER
Blue AS INTEGER
END TYPE
DECLARE SUB Mouse.Hide ()
DECLARE FUNCTION Mouse.Init ()
DECLARE SUB Mouse.Put (x, y)
DECLARE SUB Mouse.Range (x1, y1, x2, y2)
DECLARE SUB Mouse.Show ()
DECLARE SUB Mouse.Status (ButtonL, ButtonR, MouseX, MouseY)
DECLARE SUB Draw.Screen ()
DECLARE SUB Draw.Grid ()
DECLARE SUB Draw.Select ()
DECLARE SUB Draw.Slider (Attrib, Valu)
DECLARE SUB Pal.Get (Colr, Red, Green, Blue)
DECLARE SUB Pal.Set (Colr, Red, Green, Blue)
DECLARE SUB Pal.Copy ()
DECLARE SUB Pal.Paste ()
DECLARE SUB Multiple.Main ()
DECLARE SUB Multiple.Copy ()
DECLARE SUB Multiple.Paste ()
DECLARE SUB Multiple.Clear ()
DECLARE SUB Gradient.Main ()
DECLARE SUB Gradient.Build (StartColr, EndColr)
DECLARE SUB Gradient.TwoColor ()
DECLARE SUB Gradient.Shade ()
DECLARE SUB About.Main ()
DECLARE SUB Load.Main ()
DECLARE SUB Save.Main ()
DECLARE SUB Load.Load (Filename$, PalFormat)
DECLARE SUB Save.Save (Filename$, PalFormat)
DECLARE FUNCTION Load.DetectFormat (Filename$)
DECLARE SUB Load.MatchColors ()
DECLARE SUB Text.Init ()
DECLARE SUB Text.Set (ForeColr, BackColr)
DECLARE SUB Text.Print (Row, Column, Text$)
DIM SHARED Text.Segment
DIM SHARED Text.Offset
DIM SHARED Text.ForeColr
DIM SHARED Text.BackColr
DECLARE SUB LFN.ChDrive (Drive$)
DECLARE FUNCTION LFN.CurDrive$ ()
DECLARE SUB LFN.MkDir (DirName$)
DECLARE FUNCTION LFN.Error$ (ErrorCode)
DECLARE FUNCTION LFN.CurDir$ (Drive$)
DECLARE SUB LFN.ChDir (DirName$)
DECLARE FUNCTION LFN.ShortName$ (LongFilename$)
DECLARE SUB LFN.Rename (From$, To$)
DECLARE FUNCTION LFN.FileExist (LongFilename$)
DECLARE FUNCTION LFN.Support ()
DECLARE SUB Startup.Main ()
DIM SHARED Regs AS RegTypeX
DIM SHARED LFN.LastError$
DIM SHARED SupportsLFN
DIM SHARED PalBuffer(255) AS PalType
DIM SHARED ColrSelected, ColrOld
DIM SHARED ColrRed, ColrGreen, ColrBlue, CopyRed, CopyGreen, CopyBlue
DIM SHARED GridToggle, Black, White, Hilight
DIM SHARED StartColr, EndColr
DIM SHARED OpenFile$, OpenFormat
CONST REDATTR = 0, GREENATTR = 1, BLUEATTR = 2, FALSE = 0, TRUE = NOT FALSE
Startup.Main
Now! = TIMER
DO
IF TIMER - Now! > 1 THEN
Now! = TIMER
OldBlack = Black
OldWhite = White
OldHilight = Hilight
Load.MatchColors
IF OldBlack <> Black OR OldWhite <> White OR OldHilight <> Hilight THEN
Draw.Screen
END IF
END IF
Mouse.Status ButtonL, ButtonR, MouseX, MouseY
IF ButtonL = TRUE THEN
IF MouseX <= 191 AND MouseY <= 191 THEN
Col = MouseX \ 12
Row = MouseY \ 12
IF Row * 16 + Col <> ColrSelected THEN
ColrOld = ColrSelected
ColrSelected = Row * 16 + Col
Pal.Get ColrSelected, ColrRed, ColrGreen, ColrBlue
Draw.Select
END IF
ELSEIF MouseY >= 24 AND MouseY <= 62 AND MouseX >= 220 AND MouseX <= 291 THEN
Valu = MouseX - 224
IF Valu < 0 THEN Valu = 0
IF Valu > 63 THEN Valu = 63
SELECT CASE MouseY
CASE 24 TO 30
IF ColrRed <> Valu THEN
ColrRed = Valu
Pal.Set ColrSelected, ColrRed, ColrGreen, ColrBlue
Mouse.Hide
Draw.Slider REDATTR, Valu
Mouse.Show
END IF
CASE 40 TO 46
IF ColrGreen <> Valu THEN
ColrGreen = Valu
Pal.Set ColrSelected, ColrRed, ColrGreen, ColrBlue
Mouse.Hide
Draw.Slider GREENATTR, Valu
Mouse.Show
END IF
CASE 56 TO 62
IF ColrBlue <> Valu THEN
ColrBlue = Valu
Pal.Set ColrSelected, ColrRed, ColrGreen, ColrBlue
Mouse.Hide
Draw.Slider BLUEATTR, Valu
Mouse.Show
END IF
END SELECT
ELSEIF MouseX >= 117 AND MouseX <= 314 THEN
DO
Mouse.Status ButtonL, ButtonR, MouseX, MouseY
LOOP UNTIL ButtonL = FALSE
SELECT CASE MouseY
CASE 101 TO 115
IF MouseX <= 254 THEN
Pal.Copy
ELSEIF MouseX >= 256 THEN
Pal.Paste
END IF
CASE 117 TO 131
Multiple.Main
CASE 133 TO 147
Gradient.Main
CASE 149 TO 163
About.Main
CASE 165 TO 179
IF MouseX <= 258 THEN
Load.Main
ELSEIF MouseX >= 260 THEN
Save.Main
END IF
CASE 181 TO 194
IF MouseX <= 258 THEN
IF GridToggle = TRUE THEN
GridToggle = FALSE
ELSE
GridToggle = TRUE
END IF
Draw.Grid
Draw.Select
ELSEIF MouseX >= 260 THEN
'Quit
EXIT DO
END IF
END SELECT
END IF
END IF
LOOP UNTIL INKEY$ = CHR$(27)
SUB About.Main
Mouse.Hide
LINE (202, 4)-(315, 195), Black, BF
LINE (202, 4)-(315, 27), White, B
LINE (202, 27)-(315, 195), White, B
LINE (202, 180)-(315, 180), White
LINE (259, 165)-(259, 179), Black
LINE (259, 181)-(259, 194), Black
Text.Print 2, 31, "About"
Text.Print 3, 28, "PalEdit 2.0"
Text.Print 6, 27, "Programmed by"
Text.Print 7, 27, "Plasma / Jon"
Text.Print 8, 27, "Petrosky"
Text.Print 10, 27, "This program"
Text.Print 11, 27, "is freeware"
Text.Print 12, 27, "and can be"
Text.Print 13, 27, "used and"
Text.Print 14, 27, "distributed"
Text.Print 15, 27, "freely."
Text.Print 17, 27, "For more QB"
Text.Print 18, 27, "utilities and"
Text.Print 19, 27, "games, check"
Text.Print 20, 27, "out:"
Text.Print 22, 27, "phatcode.net"
Text.Print 24, 32, "OK"
Mouse.Range 201, 180, 315, 195
Mouse.Put 258, 187
Draw.Grid
Mouse.Show
DO
Mouse.Status ButtonL, ButtonR, MouseX, MouseY
IF ButtonL = TRUE THEN
DO
Mouse.Status ButtonL, ButtonR, MouseX, MouseY
LOOP UNTIL ButtonL = FALSE
EXIT DO
END IF
LOOP
Mouse.Hide
Draw.Screen
Mouse.Range 0, 0, 319, 199
Mouse.Show
END SUB
SUB Draw.Grid
IF GridToggle = FALSE THEN
FOR y = 0 TO 191 STEP 12
FOR x = 0 TO 191 STEP 12
LINE (x, y)-(x + 11, y + 11), z, BF
z = z + 1
NEXT
NEXT
LINE (192, 0)-(192, 192), Black
LINE (0, 192)-(192, 192), Black
ELSE
FOR x = 0 TO 16
LINE (x * 12, 0)-(x * 12, 192), White
NEXT
FOR y = 0 TO 16
LINE (0, y * 12)-(192, y * 12), White
NEXT
FOR y = 1 TO 192 STEP 12
FOR x = 1 TO 192 STEP 12
LINE (x, y)-(x + 10, y + 10), z, BF
z = z + 1
NEXT
NEXT
END IF
END SUB
SUB Draw.Screen
Mouse.Hide
LINE (0, 0)-(319, 199), Black, BF
Draw.Grid
Draw.Select
LINE (202, 4)-(315, 70), White, B
LINE (202, 70)-(315, 90), White, B
Text.Set White, Black
Text.Print 14, 28, "Copy Paste"
Text.Print 16, 29, "Multiple"
Text.Print 18, 29, "Gradient"
Text.Print 20, 31, "About"
Text.Print 22, 28, "Load Save"
Text.Print 24, 28, "Grid Quit"
LINE (202, 100)-(315, 195), White, B
FOR y = 100 TO 194 STEP 16
LINE (202, y)-(315, y), White
NEXT
LINE (255, 100)-(255, 115), White
LINE (259, 165)-(259, 194), White
Mouse.Show
END SUB
SUB Draw.Select
Mouse.Hide
Text.Set White, Black
Colr$ = LTRIM$(RTRIM$(STR$(ColrSelected)))
Text.Print 2, 29, "Color " + Colr$ + SPACE$(4 - LEN(Colr$))
Text.Print 4, 27, "R"
Text.Print 6, 27, "G"
Text.Print 8, 27, "B"
LINE (203, 71)-(314, 89), ColrSelected, BF
Draw.Slider REDATTR, ColrRed
Draw.Slider GREENATTR, ColrGreen
Draw.Slider BLUEATTR, ColrBlue
RowOld = ColrOld \ 16
ColOld = ColrOld MOD 16
Row = ColrSelected \ 16
Col = ColrSelected MOD 16
IF GridToggle = FALSE THEN
LINE (ColOld * 12, RowOld * 12)-(ColOld * 12 + 11, RowOld * 12 + 11), ColrOld, BF
Row = ColrSelected \ 16
Col = ColrSelected MOD 16
LINE (Col * 12, Row * 12)-(Col * 12 + 11, Row * 12 + 11), Hilight, B
ELSE
LINE (ColOld * 12, RowOld * 12)-(ColOld * 12 + 11, RowOld * 12 + 11), ColrOld, BF
LINE (ColOld * 12, RowOld * 12)-(ColOld * 12 + 12, RowOld * 12 + 12), White, B
Row = ColrSelected \ 16
Col = ColrSelected MOD 16
LINE (Col * 12, Row * 12)-(Col * 12 + 12, Row * 12 + 12), Hilight, B
END IF
Mouse.Show
END SUB
SUB Draw.Slider (Attrib, Valu)
Valu$ = LTRIM$(RTRIM$(STR$(Valu)))
Text.Print Attrib * 2 + 4, 29, " " + Valu$ + SPACE$(2 - LEN(Valu$))
LINE (224, Attrib * 16 + 27)-(287, Attrib * 16 + 27), White
LINE (224 + Valu, Attrib * 16 + 24)-(224 + Valu, Attrib * 16 + 30), White
END SUB
SUB Gradient.Build (StartColr, EndColr)
Range = EndColr - StartColr + 1
Pal.Get StartColr, StartRed, StartGreen, StartBlue
Pal.Get EndColr, EndRed, EndGreen, EndBlue
RedSteps! = (EndRed - StartRed) / Range
GreenSteps! = (EndGreen - StartGreen) / Range
BlueSteps! = (EndBlue - StartBlue) / Range
CurrentRed! = StartRed
CurrentGreen! = StartGreen
CurrentBlue! = StartBlue
FOR x = StartColr + 1 TO EndColr - 1
CurrentRed! = CurrentRed! + RedSteps!
CurrentGreen! = CurrentGreen! + GreenSteps!
CurrentBlue! = CurrentBlue! + BlueSteps!
Pal.Set x, CINT(CurrentRed!), CINT(CurrentGreen!), CINT(CurrentBlue!)
NEXT
END SUB
SUB Gradient.Main
Mouse.Hide
LINE (202, 4)-(315, 90), Black, BF
LINE (202, 4)-(315, 27), White, B
LINE (202, 27)-(315, 90), White, B
LINE (259, 165)-(259, 179), Black
LINE (259, 181)-(259, 194), Black
Text.Print 2, 29, "Gradient"
Text.Print 6, 29, "Choose a"
Text.Print 7, 29, "function"
Text.Print 8, 29, "or cancel"
Text.Set Hilight, Black
Text.Print 18, 29, "Gradient"
Text.Set White, Black
Text.Print 20, 31, "Shade"
Text.Print 22, 28, " Two-Color "
Text.Print 24, 28, " Cancel "
Mouse.Range 201, 148, 315, 195
Mouse.Put 258, 156
Draw.Grid
Mouse.Show
DO
Mouse.Status ButtonL, ButtonR, MouseX, MouseY
IF ButtonL = TRUE AND MouseX >= 117 AND MouseX <= 314 THEN
DO
Mouse.Status ButtonL, ButtonR, MouseX, MouseY
LOOP UNTIL ButtonL = FALSE
SELECT CASE MouseY
CASE 149 TO 163
Gradient.Shade
EXIT DO
CASE 165 TO 179
Gradient.TwoColor
EXIT DO
CASE 181 TO 194
EXIT DO
END SELECT
END IF
LOOP
Mouse.Hide
Draw.Screen
Mouse.Range 0, 0, 319, 199
Mouse.Show
END SUB
SUB Gradient.Shade
Mouse.Hide
Text.Print 2, 29, "Gradient"
Text.Print 3, 30, "(Shade)"
Text.Print 6, 27, "Choose base"
Text.Print 7, 27, "or cancel "
Text.Print 8, 29, " "
Text.Set Hilight, Black
Text.Print 20, 31, "Shade"
Text.Set White, Black
Mouse.Range 0, 0, 319, 199
Mouse.Show
StartColr = -2
DO
Mouse.Status ButtonL, ButtonR, MouseX, MouseY
IF ButtonL = TRUE THEN
IF MouseX <= 191 AND MouseY <= 191 THEN
Mouse.Hide
Col = MouseX \ 12
Row = MouseY \ 12
IF StartColr = -2 THEN
BaseColr = Row * 16 + Col
StartColr = -1
IF GridToggle = FALSE THEN
LINE (Col * 12, Row * 12)-(Col * 12 + 11, Row * 12 + 11), Hilight, B
ELSE
LINE (Col * 12, Row * 12)-(Col * 12 + 12, Row * 12 + 12), Hilight, B
END IF
Text.Print 6, 27, "Choose start"
Text.Print 7, 27, "or cancel"
ELSEIF StartColr = -1 THEN
StartColr = Row * 16 + Col
IF GridToggle = FALSE THEN
LINE (Col * 12, Row * 12)-(Col * 12 + 11, Row * 12 + 11), Hilight, B
ELSE
LINE (Col * 12, Row * 12)-(Col * 12 + 12, Row * 12 + 12), Hilight, B
END IF
Text.Print 6, 27, "Choose end "
Text.Print 7, 27, "or cancel"
ELSE
IF GridToggle = FALSE THEN
LINE (Col * 12, Row * 12)-(Col * 12 + 11, Row * 12 + 11), Hilight, B
ELSE
LINE (Col * 12, Row * 12)-(Col * 12 + 12, Row * 12 + 12), Hilight, B
END IF
EndColr = Row * 16 + Col
IF EndColr < StartColr THEN SWAP StartColr, EndColr
Text.Print 6, 27, "Type in the "
Text.Print 7, 27, "starting "
Text.Print 8, 27, "offset or"
Text.Print 9, 27, "choose cancel"
Text.Print 11, 32, "_"
Mouse.Show
DO
Mouse.Status ButtonL, ButtonR, MouseX, MouseY
LOOP UNTIL ButtonL = FALSE
StartInt$ = ""
DO
Mouse.Status ButtonL, ButtonR, MouseX, MouseY
IF ButtonL = TRUE AND MouseX >= 117 AND MouseX <= 314 AND MouseY >= 181 AND MouseY <= 194 THEN
DO
Mouse.Status ButtonL, ButtonR, MouseX, MouseY
LOOP UNTIL ButtonL = FALSE
EXIT DO
END IF
KeyPress$ = INKEY$
IF KeyPress$ >= "0" AND KeyPress$ <= "9" AND LEN(StartInt$) < 2 THEN
StartInt$ = StartInt$ + KeyPress$
Mouse.Hide
Text.Print 11, 32, StartInt$ + "_ "
Mouse.Show
ELSEIF KeyPress$ = CHR$(8) AND LEN(StartInt$) <> 0 THEN
StartInt$ = LEFT$(StartInt$, LEN(StartInt$) - 1)
Mouse.Hide
Text.Print 11, 32, StartInt$ + "_ "
Mouse.Show
ELSEIF KeyPress$ = CHR$(13) THEN
IF StartInt$ = "" THEN
StartInt$ = "00"
ELSEIF VAL(StartInt$) > 62 THEN
StartInt$ = "62"
END IF
EXIT DO
END IF
LOOP
IF StartInt$ = "" THEN
EXIT DO
ELSE
StartInt = VAL(StartInt$)
END IF
Text.Print 6, 27, "Type in the "
Text.Print 7, 27, "ending "
Text.Print 8, 27, "offset or"
Text.Print 9, 27, "choose cancel"
Text.Print 11, 32, "_ "
Mouse.Show
DO
Mouse.Status ButtonL, ButtonR, MouseX, MouseY
LOOP UNTIL ButtonL = FALSE
EndInt$ = ""
DO
Mouse.Status ButtonL, ButtonR, MouseX, MouseY
IF ButtonL = TRUE AND MouseX >= 117 AND MouseX <= 314 AND MouseY >= 181 AND MouseY <= 194 THEN
DO
Mouse.Status ButtonL, ButtonR, MouseX, MouseY
LOOP UNTIL ButtonL = FALSE
EXIT DO
END IF
KeyPress$ = INKEY$
IF KeyPress$ >= "0" AND KeyPress$ <= "9" AND LEN(EndInt$) < 2 THEN
EndInt$ = EndInt$ + KeyPress$
Mouse.Hide
Text.Print 11, 32, EndInt$ + "_ "
Mouse.Show
ELSEIF KeyPress$ = CHR$(8) AND LEN(EndInt$) <> 0 THEN
EndInt$ = LEFT$(EndInt$, LEN(EndInt$) - 1)
Mouse.Hide
Text.Print 11, 32, EndInt$ + "_ "
Mouse.Show
ELSEIF KeyPress$ = CHR$(13) THEN
IF EndInt$ = "" THEN
EndInt$ = "00"
ELSEIF VAL(EndInt$) > 62 THEN
EndInt$ = "62"
END IF
EXIT DO
END IF
LOOP
IF EndInt$ = "" THEN
EXIT DO
ELSE
EndInt = VAL(EndInt$)
EndInt = 63 - EndInt
END IF
Pal.Get BaseColr, BaseRed, BaseGreen, BaseBlue
IF BaseRed > BaseGreen AND BaseRed > BaseBlue THEN
Divide = BaseRed
ELSEIF BaseGreen > BaseRed AND BaseGreen > BaseBlue THEN
Divide = BaseGreen
ELSEIF BaseBlue > BaseRed AND BaseBlue > BaseGreen THEN
Divide = BaseBlue
ELSEIF BaseRed = BaseGreen AND BaseRed > BaseBlue THEN
Divide = BaseRed
ELSEIF BaseRed = BaseBlue AND BaseRed > BaseGreen THEN
Divide = BaseRed
ELSEIF BaseGreen = BaseBlue AND BaseGreen > BaseRed THEN
Divide = BaseGreen
ELSEIF BaseRed = BaseGreen AND BaseRed = BaseBlue THEN
Divide = BaseBlue
ELSE
Divide = 1
END IF
RedRatio! = BaseRed / Divide
GreenRatio! = BaseGreen / Divide
BlueRatio! = BaseBlue / Divide
NeedRange = EndInt - StartInt
RealRange = EndColr - StartColr
Steps! = NeedRange / RealRange
y! = StartInt
FOR x = StartColr TO EndColr
Pal.Set x, y! * RedRatio!, y! * GreenRatio!, y! * BlueRatio!
y! = y! + Steps!
NEXT
Draw.Screen
Mouse.Show
EXIT DO
END IF
Mouse.Show
DO
Mouse.Status ButtonL, ButtonR, MouseX, MouseY
LOOP UNTIL ButtonL = FALSE
ELSEIF MouseX >= 117 AND MouseX <= 314 AND MouseY >= 181 AND MouseY <= 194 THEN
DO
Mouse.Status ButtonL, ButtonR, MouseX, MouseY
LOOP UNTIL ButtonL = FALSE
EXIT DO
END IF
END IF
LOOP
END SUB
SUB Gradient.TwoColor
Mouse.Hide
Text.Print 2, 29, "Gradient"
Text.Print 3, 29, "(2-Color)"
Text.Print 6, 27, "Choose start"
Text.Print 7, 27, "or cancel "
Text.Print 8, 29, " "
Text.Set Hilight, Black
Text.Print 22, 28, " Two-Color "
Text.Set White, Black
Mouse.Range 0, 0, 319, 199
Mouse.Show
StartColr = -1
DO
Mouse.Status ButtonL, ButtonR, MouseX, MouseY
IF ButtonL = TRUE THEN
IF MouseX <= 191 AND MouseY <= 191 THEN
Mouse.Hide
Col = MouseX \ 12
Row = MouseY \ 12
IF StartColr = -1 THEN
StartColr = Row * 16 + Col
IF GridToggle = FALSE THEN
LINE (Col * 12, Row * 12)-(Col * 12 + 11, Row * 12 + 11), Hilight, B
ELSE
LINE (Col * 12, Row * 12)-(Col * 12 + 12, Row * 12 + 12), Hilight, B
END IF
Text.Print 6, 27, "Choose end "
Text.Print 7, 27, "or cancel"
ELSE
IF GridToggle = FALSE THEN
LINE (Col * 12, Row * 12)-(Col * 12 + 11, Row * 12 + 11), Hilight, B
ELSE
LINE (Col * 12, Row * 12)-(Col * 12 + 12, Row * 12 + 12), Hilight, B
END IF
EndColr = Row * 16 + Col
IF EndColr < StartColr THEN SWAP StartColr, EndColr
Gradient.Build StartColr, EndColr
DO
Mouse.Status ButtonL, ButtonR, MouseX, MouseY
LOOP UNTIL ButtonL = FALSE
Draw.Screen
Mouse.Show
EXIT DO
END IF
Mouse.Show
DO
Mouse.Status ButtonL, ButtonR, MouseX, MouseY
LOOP UNTIL ButtonL = FALSE
ELSEIF MouseX >= 117 AND MouseX <= 314 AND MouseY >= 181 AND MouseY <= 194 THEN
DO
Mouse.Status ButtonL, ButtonR, MouseX, MouseY
LOOP UNTIL ButtonL = FALSE
EXIT DO
END IF
END IF
LOOP
END SUB
SUB LFN.ChDir (DirName$)
AsciiZ$ = DirName$ + CHR$(0)
Regs.ax = &H713B
Regs.ds = VARSEG(AsciiZ$)
Regs.dx = SADD(AsciiZ$)
Regs.flags = 1
INTERRUPTX &H21, Regs, Regs
IF Regs.flags AND 1 AND Regs.ax = &H7100 THEN
'LFN not supported
Regs.ax = &H3B00
Regs.ds = VARSEG(AsciiZ$)
Regs.dx = SADD(AsciiZ$)
INTERRUPTX &H21, Regs, Regs
END IF
IF Regs.flags AND 1 THEN
PRINT LFN.Error$(Regs.ax)
END IF
END SUB
SUB LFN.ChDrive (Drive$)
Regs.ax = &HE00
Regs.dx = ASC(Drive$) - 65
INTERRUPTX &H21, Regs, Regs
END SUB
FUNCTION LFN.CurDir$ (Drive$)
IF Drive$ = "" THEN
DriveNum = 0
ELSE
DriveNum = ASC(Drive$) - 64
END IF
Buffer$ = SPACE$(261)
Regs.ax = &H7147
Regs.dx = DriveNum
Regs.ds = VARSEG(Buffer$)
Regs.si = SADD(Buffer$)
Regs.flags = 1
INTERRUPTX &H21, Regs, Regs
IF Regs.flags AND 1 AND Regs.ax = &H7100 THEN
'LFN not supported
Regs.ax = &H4700
Regs.dx = DriveNum
Regs.ds = VARSEG(Buffer$)
Regs.si = SADD(Buffer$)
INTERRUPTX &H21, Regs, Regs
END IF
IF Regs.flags AND 1 THEN
PRINT LFN.Error$(Regs.ax)
ELSE
LFN.CurDir$ = LEFT$(Buffer$, INSTR(Buffer$, CHR$(0)))
END IF
END FUNCTION
FUNCTION LFN.CurDrive$
Regs.ax = &H1900
INTERRUPTX &H21, Regs, Regs
LFN.CurDrive$ = CHR$((Regs.ax AND 255) + 65)
END FUNCTION
FUNCTION LFN.Error$ (ErrorCode)
SELECT CASE ErrorCode
CASE 0: Msg$ = "No error"
CASE 1: Msg$ = "Function number invalid"
CASE 2: Msg$ = "File not found"
CASE 3: Msg$ = "Path not found"
CASE 4: Msg$ = "Too many open files (no handles available)"
CASE 5: Msg$ = "Access denied"
CASE 6: Msg$ = "Invalid handle"
CASE 7: Msg$ = "Memory control block destroyed"
CASE 8: Msg$ = "Insufficient memory"
CASE 9: Msg$ = "Memory block address invalid"
CASE 10: Msg$ = "Environment invalid (usually >32K in length)"
CASE 11: Msg$ = "Format invalid"
CASE 12: Msg$ = "Access code invalid"
CASE 13: Msg$ = "Data invalid"
CASE 14: Msg$ = "Reserved/Fixup overflow"
CASE 15: Msg$ = "Invalid drive"
CASE 16: Msg$ = "Attempted to remove current directory"
CASE 17: Msg$ = "Not same device"
CASE 18: Msg$ = "No more files"
CASE 19: Msg$ = "Disk write-protected"
CASE 20: Msg$ = "Unknown unit"
CASE 21: Msg$ = "Drive not ready"
CASE 22: Msg$ = "Unknown command"
CASE 23: Msg$ = "Data error (CRC)"
CASE 24: Msg$ = "Bad request structure length"
CASE 25: Msg$ = "Seek error"
CASE 26: Msg$ = "Unknown media type (non-DOS disk)"
CASE 27: Msg$ = "Sector not found"
CASE 28: Msg$ = "Printer out of paper"
CASE 29: Msg$ = "Write fault"
CASE 30: Msg$ = "Read fault"
CASE 31: Msg$ = "General failure"
CASE 32: Msg$ = "Sharing violation"
CASE 33: Msg$ = "Lock violation"
CASE 34: Msg$ = "Disk change invalid"
CASE 35: Msg$ = "FCB unavailable"
CASE 36: Msg$ = "Sharing buffer overflow"
CASE 37: Msg$ = "Code page mismatch"
CASE 38: Msg$ = "Cannot complete file operation (EOF/out of input)"
CASE 39: Msg$ = "Insufficient disk space"
CASE 40 TO 49: Msg$ = "Reserved"
CASE 80: Msg$ = "File exists"
CASE 81: Msg$ = "Duplicated FCB"
CASE 82: Msg$ = "Cannot make directory"
CASE 83: Msg$ = "Fail on INT 24h"
CASE &H7100: Msg$ = "Long filenames not supported"
CASE ELSE: Msg$ = "Unknown error"
END SELECT
LFN.Error$ = Msg$
END FUNCTION
FUNCTION LFN.FileExist (LongFilename$)
Test$ = LFN.ShortName$(LongFilename$)
IF Test$ = "" THEN
IF LFN.LastError$ = "File not found" OR LFN.LastError$ = "Path not found" THEN
LFN.FileExist = FALSE
EXIT FUNCTION
END IF
END IF
LFN.FileExist = TRUE
END FUNCTION
SUB LFN.MkDir (DirName$)
AsciiZ$ = DirName$ + CHR$(0)
Regs.ax = &H7139
Regs.ds = VARSEG(AsciiZ$)
Regs.dx = SADD(AsciiZ$)
Regs.flags = 1
INTERRUPTX &H21, Regs, Regs
IF Regs.flags AND 1 AND Regs.ax = &H7100 THEN
'LFN not supported
Regs.ax = &H3900
Regs.ds = VARSEG(AsciiZ$)
Regs.dx = SADD(AsciiZ$)
INTERRUPTX &H21, Regs, Regs
END IF
IF Regs.flags AND 1 THEN
PRINT LFN.Error$(Regs.ax)
END IF
END SUB
SUB LFN.Rename (From$, To$)
FromZ$ = From$ + CHR$(0)
ToZ$ = To$ + CHR$(0)
Regs.ax = &H7156
Regs.ds = VARSEG(FromZ$)
Regs.dx = SADD(FromZ$)
Regs.es = VARSEG(ToZ$)
Regs.di = SADD(ToZ$)
INTERRUPTX &H21, Regs, Regs
IF Regs.flags AND 1 THEN
LFN.LastError$ = LFN.Error$(Regs.ax)
END IF
END SUB
FUNCTION LFN.ShortName$ (LongFilename$)
LongZ$ = LongFilename$ + CHR$(0)
ShortZ$ = SPACE$(261)
Regs.ax = &H7160
Regs.cx = &H1
Regs.ds = VARSEG(LongZ$)
Regs.si = SADD(LongZ$)
Regs.es = VARSEG(ShortZ$)
Regs.di = SADD(ShortZ$)
INTERRUPTX &H21, Regs, Regs
IF Regs.flags AND 1 THEN
LFN.LastError$ = LFN.Error$(Regs.ax)
LFN.ShortName$ = ""
ELSE
LFN.ShortName$ = LEFT$(RTRIM$(ShortZ$), LEN(RTRIM$(ShortZ$)) - 1)
END IF
END FUNCTION
FUNCTION LFN.Support
Buffer$ = SPACE$(261)
Regs.ax = &H7147
Regs.dx = 0
Regs.ds = VARSEG(Buffer$)
Regs.si = SADD(Buffer$)
Regs.flags = 1
INTERRUPTX &H21, Regs, Regs
IF Regs.flags AND 1 AND Regs.ax = &H7100 THEN
LFN.Support = FALSE
ELSE
LFN.Support = TRUE
END IF
END FUNCTION
FUNCTION Load.DetectFormat (Filename$)
FileHandle = FREEFILE
OPEN Filename$ FOR BINARY AS #FileHandle
IF LOF(FileHandle) = 768 THEN
Load.DetectFormat = 0
CLOSE #FileHandle
EXIT FUNCTION
END IF
IF LOF(FileHandle) = 1536 THEN
Load.DetectFormat = 1
CLOSE #FileHandle
EXIT FUNCTION
END IF
IF LOF(FileHandle) = 3072 THEN
Load.DetectFormat = 2
CLOSE #FileHandle
EXIT FUNCTION
END IF
Header$ = SPACE$(5)
GET #FileHandle, , Header$
IF ASC(Header$) = 253 THEN
GET #FileHandle, , DataLen
IF DataLen = 768 THEN
Load.DetectFormat = 3
CLOSE #FileHandle
EXIT FUNCTION
ELSEIF DataLen = 1536 THEN
Load.DetectFormat = 4
CLOSE #FileHandle
EXIT FUNCTION