VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "SGB Color Picker"
   ClientHeight    =   4215
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4695
   LinkTopic       =   "Form1"
   ScaleHeight     =   4215
   ScaleWidth      =   4695
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton cmdCopyBGBINIString 
      Caption         =   "Copy"
      Height          =   255
      Left            =   120
      TabIndex        =   30
      Top             =   3720
      Width           =   615
   End
   Begin VB.TextBox txtBGBINIEntry 
      Height          =   375
      Left            =   720
      TabIndex        =   29
      Top             =   3720
      Width           =   3855
   End
   Begin VB.TextBox txtColorCode 
      Height          =   375
      Left            =   1800
      TabIndex        =   0
      Top             =   3000
      Width           =   1455
   End
   Begin VB.ComboBox cmbPalettes 
      Height          =   315
      ItemData        =   "SGB_Colors.frx":0000
      Left            =   1800
      List            =   "SGB_Colors.frx":0064
      TabIndex        =   1
      Top             =   1920
      Width           =   1455
   End
   Begin VB.OptionButton optBrightness 
      Caption         =   "Darkest"
      Height          =   255
      Index           =   6
      Left            =   120
      TabIndex        =   9
      Top             =   1680
      Width           =   975
   End
   Begin VB.OptionButton optBrightness 
      Caption         =   "Darker"
      Height          =   255
      Index           =   5
      Left            =   120
      TabIndex        =   8
      Top             =   1440
      Width           =   975
   End
   Begin VB.OptionButton optBrightness 
      Caption         =   "Dark"
      Height          =   255
      Index           =   4
      Left            =   120
      TabIndex        =   7
      Top             =   1200
      Width           =   975
   End
   Begin VB.OptionButton optBrightness 
      Caption         =   "Default"
      Height          =   255
      Index           =   3
      Left            =   120
      TabIndex        =   6
      Top             =   960
      Value           =   -1  'True
      Width           =   975
   End
   Begin VB.OptionButton optBrightness 
      Caption         =   "Bright"
      Height          =   255
      Index           =   2
      Left            =   120
      TabIndex        =   5
      Top             =   720
      Width           =   975
   End
   Begin VB.OptionButton optBrightness 
      Caption         =   "Brighter"
      Height          =   255
      Index           =   1
      Left            =   120
      TabIndex        =   4
      Top             =   480
      Width           =   975
   End
   Begin VB.OptionButton optBrightness 
      Caption         =   "Brightest"
      Height          =   255
      Index           =   0
      Left            =   120
      TabIndex        =   3
      Top             =   240
      Width           =   975
   End
   Begin VB.HScrollBar hslColorPicker 
      Height          =   255
      LargeChange     =   3
      Left            =   1200
      Max             =   4
      TabIndex        =   2
      Top             =   1560
      Width           =   2655
   End
   Begin VB.Label Label3 
      Caption         =   "BGB.ini Palette String"
      Height          =   255
      Left            =   600
      TabIndex        =   31
      Top             =   3480
      Width           =   1575
   End
   Begin VB.Label lblSGBCode 
      Height          =   495
      Left            =   3360
      TabIndex        =   28
      Top             =   3000
      Width           =   1215
   End
   Begin VB.Label Label2 
      Caption         =   "Color Code:"
      Height          =   255
      Left            =   960
      TabIndex        =   27
      Top             =   3000
      Width           =   855
   End
   Begin VB.Label Label1 
      Caption         =   "Palettes:"
      Height          =   255
      Left            =   1200
      TabIndex        =   26
      Top             =   1920
      Width           =   615
   End
   Begin VB.Label lblPickColorB 
      BackColor       =   &H004890D8&
      Height          =   360
      Left            =   1440
      MousePointer    =   10  'Up Arrow
      TabIndex        =   25
      Top             =   1200
      Width           =   360
   End
   Begin VB.Label lblPickColor 
      BackColor       =   &H00C8E8F8&
      Height          =   360
      Index           =   9
      Left            =   3240
      MousePointer    =   10  'Up Arrow
      TabIndex        =   24
      Top             =   1200
      Width           =   360
   End
   Begin VB.Label lblPickColor 
      BackColor       =   &H004890D8&
      Height          =   360
      Index           =   8
      Left            =   2880
      MousePointer    =   10  'Up Arrow
      TabIndex        =   23
      Top             =   1200
      Width           =   360
   End
   Begin VB.Label lblPickColor 
      BackColor       =   &H00C8E8F8&
      Height          =   360
      Index           =   7
      Left            =   2520
      MousePointer    =   10  'Up Arrow
      TabIndex        =   22
      Top             =   1200
      Width           =   360
   End
   Begin VB.Label lblPickColor 
      BackColor       =   &H004890D8&
      Height          =   360
      Index           =   6
      Left            =   2160
      MousePointer    =   10  'Up Arrow
      TabIndex        =   21
      Top             =   1200
      Width           =   360
   End
   Begin VB.Label lblPickColor 
      BackColor       =   &H00C8E8F8&
      Height          =   360
      Index           =   5
      Left            =   1800
      MousePointer    =   10  'Up Arrow
      TabIndex        =   20
      Top             =   1200
      Width           =   360
   End
   Begin VB.Label lblPickColor 
      BackColor       =   &H004890D8&
      Height          =   360
      Index           =   4
      Left            =   3240
      MousePointer    =   10  'Up Arrow
      TabIndex        =   19
      Top             =   840
      Width           =   360
   End
   Begin VB.Label lblPickColor 
      BackColor       =   &H00C8E8F8&
      Height          =   360
      Index           =   3
      Left            =   2880
      MousePointer    =   10  'Up Arrow
      TabIndex        =   18
      Top             =   840
      Width           =   360
   End
   Begin VB.Label lblPickColor 
      BackColor       =   &H004890D8&
      Height          =   360
      Index           =   2
      Left            =   2520
      MousePointer    =   10  'Up Arrow
      TabIndex        =   17
      Top             =   840
      Width           =   360
   End
   Begin VB.Label lblPickColor 
      BackColor       =   &H00C8E8F8&
      Height          =   360
      Index           =   1
      Left            =   2160
      MousePointer    =   10  'Up Arrow
      TabIndex        =   16
      Top             =   840
      Width           =   360
   End
   Begin VB.Label lblPickColor 
      BackColor       =   &H004890D8&
      Height          =   360
      Index           =   0
      Left            =   1800
      MousePointer    =   10  'Up Arrow
      TabIndex        =   15
      Top             =   840
      Width           =   360
   End
   Begin VB.Label lblPickColorA 
      BackColor       =   &H00C8E8F8&
      Height          =   360
      Left            =   1440
      MousePointer    =   10  'Up Arrow
      TabIndex        =   14
      Top             =   840
      Width           =   360
   End
   Begin VB.Label lblScreenColors 
      BackColor       =   &H00501830&
      Height          =   615
      Index           =   3
      Left            =   3240
      MousePointer    =   2  'Cross
      TabIndex        =   13
      Top             =   2280
      Width           =   735
   End
   Begin VB.Label lblScreenColors 
      BackColor       =   &H002028A8&
      Height          =   615
      Index           =   2
      Left            =   2520
      MousePointer    =   2  'Cross
      TabIndex        =   12
      Top             =   2280
      Width           =   735
   End
   Begin VB.Label lblScreenColors 
      BackColor       =   &H004890D8&
      Height          =   615
      Index           =   1
      Left            =   1800
      MousePointer    =   2  'Cross
      TabIndex        =   11
      Top             =   2280
      Width           =   735
   End
   Begin VB.Label lblScreenColors 
      BackColor       =   &H00C8E8F8&
      Height          =   615
      Index           =   0
      Left            =   1080
      MousePointer    =   2  'Cross
      TabIndex        =   10
      Top             =   2280
      Width           =   735
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim ColorSetup(0 To 52) As Long
Dim PaletteColors(0 To 31, 1 To 4)

Dim ColorCodes(0 To 3) As String
Dim ColorSetupNumber(0 To 3) As Integer
Dim ColorSetupBright(0 To 3) As Byte

Dim PickColorCode As String
Dim PickSetupNumber As Integer
Dim PickSetupBright As Byte

Dim PaletteBrightness As Byte

Dim EditingColors As Boolean

Private Sub cmbPalettes_Click()

'704 + listindex
'PaletteColors
SetExistingPalette cmbPalettes.ListIndex

txtColorCode.Text = (704 + cmbPalettes.ListIndex) & (704 + cmbPalettes.ListIndex) & (704 + cmbPalettes.ListIndex) & (704 + cmbPalettes.ListIndex)

End Sub

Private Sub SetExistingPalette(PaletteNum As Byte, Optional SelectNumber As Byte = 0)


If (SelectNumber = 1) Or (SelectNumber = 0) Then
lblScreenColors(0).BackColor = "&H" & GetSGBColors(PaletteColors(PaletteNum, 1), 3)
lblScreenColors(0).ToolTipText = "0x" & Right$("000000" & Hex$(lblScreenColors(0).BackColor), 6)
ColorSetupNumber(0) = PaletteNum + 704
End If

If (SelectNumber = 2) Or (SelectNumber = 0) Then
lblScreenColors(1).BackColor = "&H" & GetSGBColors(PaletteColors(PaletteNum, 2), 3)
lblScreenColors(1).ToolTipText = "0x" & Right$("000000" & Hex$(lblScreenColors(1).BackColor), 6)
ColorSetupNumber(1) = PaletteNum + 704
End If

If (SelectNumber = 3) Or (SelectNumber = 0) Then
lblScreenColors(2).BackColor = "&H" & GetSGBColors(PaletteColors(PaletteNum, 3), 3)
lblScreenColors(2).ToolTipText = "0x" & Right$("000000" & Hex$(lblScreenColors(2).BackColor), 6)
ColorSetupNumber(2) = PaletteNum + 704
End If

If (SelectNumber = 4) Or (SelectNumber = 0) Then
lblScreenColors(3).BackColor = "&H" & GetSGBColors(PaletteColors(PaletteNum, 4), 3)
lblScreenColors(3).ToolTipText = "0x" & Right$("000000" & Hex$(lblScreenColors(3).BackColor), 6)
ColorSetupNumber(3) = PaletteNum + 704
End If

End Sub

Private Sub cmdCopyBGBINIString_Click()

Clipboard.SetText txtBGBINIEntry.Text

End Sub

Private Sub Form_Load()

PaletteBrightness = 3

DoColorSetup

cmbPalettes.ListIndex = 0

PickColors 0

lblPickColorB_Click

End Sub

Private Function GetSGBColors(ByVal OriginalColor As Long, Optional ByVal Brightness As Byte = 3) As String

'Defined at 7ECC00

Dim NewColor As Long

Dim Blue As Byte
Dim Green As Byte
Dim Red As Byte

Blue = CByte(Int(OriginalColor / 1024) And 31)
Blue = ApplyShading(Blue, Brightness)
OriginalColor = ((Blue * 1024) Or (OriginalColor And 1023))
Green = CByte(Int(OriginalColor / 32) And 31)
Green = ApplyShading(Green, Brightness)
OriginalColor = ((Blue * 32) Or (OriginalColor And 31))
Red = CByte(Int(OriginalColor And 31))
Red = ApplyShading(Red, Brightness)
OriginalColor = (OriginalColor And 31775)

GetSGBColors = GetHex(Blue * 8) & GetHex(Green * 8) & GetHex(Red * 8)

End Function

Private Function ApplyShading(ByVal OriginalByte As Byte, ByVal Brightness As Byte) As Byte

'(Divide by 4 for level 6, darkest)
'(Divide by 2, AND 0xFFFE for level 5)
'(int(Divide by 4), multiply by 3 for level 4)
'(Do nothing for Level 3)
'(Subtract code from 31, (int(Divide by 4), multiply by 3), subtract result from 31)
'(Subtract code from 31, (Divide by 2, AND 0xFFFE), subtract result from 31)
'(Subtract code from 31, (Divide by 4), subtract result from 31)

Dim SetDarker As Boolean

SetDarker = CBool((Brightness) And 4)

If Brightness = 3 Then
ApplyShading = OriginalByte
Exit Function
End If

'If OriginalByte = 31 Then
'ApplyShading = OriginalByte
'Exit Function
'End If

If SetDarker Then
Brightness = ((Brightness) And 3)
Else
Brightness = (((Brightness) And 3) Xor 3) - 1
OriginalByte = 31 - OriginalByte
End If

Select Case Brightness
Case 0
OriginalByte = Int(OriginalByte / 4) * 3
Case 1
OriginalByte = (Int(OriginalByte / 2) And 65534)
Case 2
OriginalByte = Int(OriginalByte / 4)
End Select

If Not SetDarker Then
OriginalByte = 31 - OriginalByte
End If

ApplyShading = OriginalByte

End Function

Private Function GetHex(Number As Integer) As String

GetHex = Right$("00" & Hex(Number), 2)

End Function

Private Sub PickColors(ColorSet As Integer)

Dim I As Long

lblPickColorA.BackColor = "&H" & GetSGBColors(ColorSetup(51), PaletteBrightness)
lblPickColorA.ToolTipText = "0x" & Right$("000000" & Hex$(lblPickColorA.BackColor), 6)
lblPickColorB.BackColor = "&H" & GetSGBColors(ColorSetup(50), PaletteBrightness)
lblPickColorB.ToolTipText = "0x" & Right$("000000" & Hex$(lblPickColorB.BackColor), 6)

For I = 0 To 9
lblPickColor(I).BackColor = "&H" & GetSGBColors(ColorSetup(I + (ColorSet * 10)), PaletteBrightness)
lblPickColor(I).ToolTipText = "0x" & Right$("000000" & Hex$(lblPickColor(I).BackColor), 6)
Next I

End Sub

Private Sub hslColorPicker_Change()

PickColors hslColorPicker.Value

End Sub

Private Sub hslColorPicker_Scroll()

PickColors hslColorPicker.Value

End Sub

Private Sub lblPickColor_Click(Index As Integer)

PickColorCode = Mid$(lblPickColor(Index).ToolTipText, 3)
PickSetupNumber = (hslColorPicker.Value * 10) + Index
PickSetupBright = PaletteBrightness

End Sub

Private Sub lblPickColorA_Click()

PickColorCode = Mid$(lblPickColorA.ToolTipText, 3)
PickSetupNumber = 51
PickSetupBright = PaletteBrightness

End Sub

Private Sub lblPickColorB_Click()

PickColorCode = Mid$(lblPickColorB.ToolTipText, 3)
PickSetupNumber = 50
PickSetupBright = PaletteBrightness

End Sub

Private Sub lblScreenColors_Click(Index As Integer)

lblScreenColors(Index).BackColor = "&H" & PickColorCode
lblScreenColors(Index).ToolTipText = "0x" & PickColorCode

ColorCodes(Index) = PickColorCode
ColorSetupNumber(Index) = PickSetupNumber
ColorSetupBright(Index) = PickSetupBright

EditingColors = True
txtColorCode.Text = EncodeColorPassword
EditingColors = False

End Sub

Private Function EncodeColorPassword() As String

Dim I As Integer

For I = 0 To 3

If ColorSetupNumber(I) >= 704 Then
EncodeColorPassword = EncodeColorPassword & ColorSetupNumber(I)
Else
'ColorSetupNumber(I) = (Segments(I) And 63)
'ColorSetupBright(I) = (Int(Segments(I) / 40) And 7)
EncodeColorPassword = EncodeColorPassword & Right$("000" & ColorSetupNumber(I) + (ColorSetupBright(I) * 64), 3)
End If

Next I

End Function

Private Sub optBrightness_Click(Index As Integer)

PaletteBrightness = Index

PickColors hslColorPicker.Value

End Sub

Private Function DecodeColorPassword(InputNumber As String) As String

'Divide the number segment by 0x40, AND 0x07 = brightness. If Brightness = 7, set it to 0x03.
'If it's >= 512, goto BuiltinPalettes, otherwise goto next step
'And value with 0x3F. If it's >= 0x35, it uses the Randomizer routine
'If not randomized, uses the value as an index of the color selected.
'BuiltinPalettes:
'And value with 0x3F. If it's >= 0x21, it uses the Randomizer routine
'If not randomized, uses the value as an index of the color selected.
'RandomizerRoutine: it uses the index of the group being edited(00-03, at 7E0C01) as a color number index, with a brightness of 3
'CC = (_1_ * 0x64) + (_2_ * 0x0A) + (_3_)
'This just converts the numbers to Hex Code.

Dim UseRandom As Boolean
Dim Segments(0 To 3) As Integer
Dim I As Byte

'InputNumber = Replace$(InputNumber, "-", "")
'InputNumber = Replace$(InputNumber, " ", "")

If Len(InputNumber) < 12 Then
DecodeColorPassword = ""
Exit Function
End If

If Len(InputNumber) > 12 Then
DecodeColorPassword = "Invalid Length"
Exit Function
End If

Segments(0) = Val(Mid$(InputNumber, 1, 3))
Segments(1) = Val(Mid$(InputNumber, 4, 3))
Segments(2) = Val(Mid$(InputNumber, 7, 3))
Segments(3) = Val(Mid$(InputNumber, 10, 3))

For I = 0 To 3
If Segments(I) >= 512 Then
If (Segments(I) And 63) <= 32 Then
SetExistingPalette (Segments(I) And 63), I + 1
Else
UseRandom = True
End If

Else

'Always do this, so numbers don't 'magically' change,
'when a different color is edited than the invalid one
ColorSetupNumber(I) = (Segments(I) And 63)
ColorSetupBright(I) = (Int(Segments(I) / 64) And 7)

If (Segments(I) And 63) <= 52 Then
lblScreenColors(I).BackColor = "&H" & GetSGBColors(ColorSetup(Segments(I) And 63), (Int(Segments(I) / 64) And 7))
lblScreenColors(I).ToolTipText = "0x" & Right$("000000" & Hex$(lblScreenColors(I).BackColor), 6)
ColorCodes(I) = Right$("000000" & Hex$(lblScreenColors(I).BackColor), 6)
Else
UseRandom = True
End If

End If

If UseRandom Then
ColorSetupNumber(I) = Segments(I)
lblScreenColors(I).BackColor = "&H" & GetSGBColors(PaletteColors(0, I + 1), 3)
lblScreenColors(I).ToolTipText = "0x" & Right$("000000" & Hex$(lblScreenColors(I).BackColor), 6)
End If

UseRandom = False

Next I

End Function

Private Sub DoColorSetup()

'Setup Base Colors
ColorSetup(0) = 31
ColorSetup(1) = 29983
ColorSetup(2) = 24792
ColorSetup(3) = 17855
ColorSetup(4) = 543
ColorSetup(5) = 1023
ColorSetup(6) = 1008
ColorSetup(7) = 608
ColorSetup(8) = 32736
ColorSetup(9) = 31744
ColorSetup(10) = 32363
ColorSetup(11) = 32134
ColorSetup(12) = 24063
ColorSetup(13) = 27295
ColorSetup(14) = 12863
ColorSetup(15) = 17183
ColorSetup(16) = 4991
ColorSetup(17) = 12277
ColorSetup(18) = 32468
ColorSetup(19) = 20454
ColorSetup(20) = 32687
ColorSetup(21) = 32176
ColorSetup(22) = 31157
ColorSetup(23) = 4376
ColorSetup(24) = 15826
ColorSetup(25) = 400
ColorSetup(26) = 2679
ColorSetup(27) = 1648
ColorSetup(28) = 5802
ColorSetup(29) = 14912
ColorSetup(30) = 11847
ColorSetup(31) = 20906
ColorSetup(32) = 24875
ColorSetup(33) = 20846
ColorSetup(34) = 13554
ColorSetup(35) = 13874
ColorSetup(36) = 10674
ColorSetup(37) = 19161
ColorSetup(38) = 9779
ColorSetup(39) = 8624
ColorSetup(40) = 21208
ColorSetup(41) = 5781
ColorSetup(42) = 7695
ColorSetup(43) = 13839
ColorSetup(44) = 7722
ColorSetup(45) = 16815
ColorSetup(46) = 14800
ColorSetup(47) = 26425
ColorSetup(48) = 17969
ColorSetup(49) = 11627
ColorSetup(50) = 32767
ColorSetup(51) = 0
ColorSetup(52) = 0

PaletteColors(0, 1) = 26559
PaletteColors(0, 2) = 9819
PaletteColors(0, 3) = 4277
PaletteColors(0, 4) = 10342
PaletteColors(1, 1) = 25467
PaletteColors(1, 2) = 15065
PaletteColors(1, 3) = 2390
PaletteColors(1, 4) = 0
PaletteColors(2, 1) = 32543
PaletteColors(2, 2) = 10877
PaletteColors(2, 3) = 12531
PaletteColors(2, 4) = 19687
PaletteColors(3, 1) = 22527
PaletteColors(3, 2) = 9752
PaletteColors(3, 3) = 31
PaletteColors(3, 4) = 106
PaletteColors(4, 1) = 23423
PaletteColors(4, 2) = 16143
PaletteColors(4, 3) = 8749
PaletteColors(4, 4) = 4331
PaletteColors(5, 1) = 32699
PaletteColors(5, 2) = 10812
PaletteColors(5, 3) = 21
PaletteColors(5, 4) = 2304
PaletteColors(6, 1) = 10240
PaletteColors(6, 2) = 30336
PaletteColors(6, 3) = 495
PaletteColors(6, 4) = 12287
PaletteColors(7, 1) = 29631
PaletteColors(7, 2) = 18175
PaletteColors(7, 3) = 272
PaletteColors(7, 4) = 102
PaletteColors(8, 1) = 21310
PaletteColors(8, 2) = 9784
PaletteColors(8, 3) = 485
PaletteColors(8, 4) = 0
PaletteColors(9, 1) = 32767
PaletteColors(9, 2) = 11199
PaletteColors(9, 3) = 223
PaletteColors(9, 4) = 11274
PaletteColors(10, 1) = 32543
PaletteColors(10, 2) = 17981
PaletteColors(10, 3) = 29903
PaletteColors(10, 4) = 19621
PaletteColors(11, 1) = 21503
PaletteColors(11, 2) = 992
PaletteColors(11, 3) = 223
PaletteColors(11, 4) = 10240
PaletteColors(12, 1) = 17215
PaletteColors(12, 2) = 29394
PaletteColors(12, 3) = 12357
PaletteColors(12, 4) = 2082
PaletteColors(13, 1) = 32762
PaletteColors(13, 2) = 10847
PaletteColors(13, 3) = 20
PaletteColors(13, 4) = 3
PaletteColors(14, 1) = 7917
PaletteColors(14, 2) = 8540
PaletteColors(14, 3) = 17148
PaletteColors(14, 4) = 96
PaletteColors(15, 1) = 32767
PaletteColors(15, 2) = 24311
PaletteColors(15, 3) = 14798
PaletteColors(15, 4) = 0
PaletteColors(16, 1) = 20319
PaletteColors(16, 2) = 25358
PaletteColors(16, 3) = 5535
PaletteColors(16, 4) = 12582
PaletteColors(17, 1) = 25467
PaletteColors(17, 2) = 4636
PaletteColors(17, 3) = 320
PaletteColors(17, 4) = 2112
PaletteColors(18, 1) = 26300
PaletteColors(18, 2) = 16383
PaletteColors(18, 3) = 32480
PaletteColors(18, 4) = 11396
PaletteColors(19, 1) = 24574
PaletteColors(19, 2) = 16060
PaletteColors(19, 3) = 801
PaletteColors(19, 4) = 0
PaletteColors(20, 1) = 25599
PaletteColors(20, 2) = 14044
PaletteColors(20, 3) = 4598
PaletteColors(20, 4) = 14634
PaletteColors(21, 1) = 26095
PaletteColors(21, 2) = 32191
PaletteColors(21, 3) = 863
PaletteColors(21, 4) = 8456
PaletteColors(22, 1) = 11116
PaletteColors(22, 2) = 32767
PaletteColors(22, 3) = 7385
PaletteColors(22, 4) = 7
PaletteColors(23, 1) = 21500
PaletteColors(23, 2) = 7983
PaletteColors(23, 3) = 3625
PaletteColors(23, 4) = 97
PaletteColors(24, 1) = 14014
PaletteColors(24, 2) = 32431
PaletteColors(24, 3) = 26650
PaletteColors(24, 4) = 15360
PaletteColors(25, 1) = 31678
PaletteColors(25, 2) = 12957
PaletteColors(25, 3) = 7656
PaletteColors(25, 4) = 1059
PaletteColors(26, 1) = 29599
PaletteColors(26, 2) = 27291
PaletteColors(26, 3) = 29331
PaletteColors(26, 4) = 1
PaletteColors(27, 1) = 24575
PaletteColors(27, 2) = 26418
PaletteColors(27, 3) = 15785
PaletteColors(27, 4) = 9345
PaletteColors(28, 1) = 22399
PaletteColors(28, 2) = 16060
PaletteColors(28, 3) = 17775
PaletteColors(28, 4) = 6272
PaletteColors(29, 1) = 27479
PaletteColors(29, 2) = 28187
PaletteColors(29, 3) = 20496
PaletteColors(29, 4) = 7
PaletteColors(30, 1) = 3990
PaletteColors(30, 2) = 11415
PaletteColors(30, 3) = 69
PaletteColors(30, 4) = 12800
PaletteColors(31, 1) = 26623
PaletteColors(31, 2) = 12055
PaletteColors(31, 3) = 8752
PaletteColors(31, 4) = 5448

End Sub

Private Sub BuildPaletteBuilder()

Dim I As Long
Dim J As Long

Dim TempInt As Integer
Dim PaletteCounter As Byte
Dim EntryCounter As Byte

Dim Results As String

Open "D:\!why_d\!!vb\SGB_Colors\PaletteExtract" For Binary As #1
For I = 1 To LOF(1) Step 8
For J = I To I + 6 Step 2
EntryCounter = EntryCounter + 1

Get #1, J, TempInt
Results = Results & "PaletteColors(" & PaletteCounter & "," & EntryCounter & ") = " & TempInt & vbNewLine

Next J
EntryCounter = 0
PaletteCounter = PaletteCounter + 1
Next I
Close #1

End Sub

Private Sub txtColorCode_Change()

txtColorCode.Text = Replace$(txtColorCode.Text, "-", "")
txtColorCode.Text = Replace$(txtColorCode.Text, " ", "")

If Len(txtColorCode.Text) = 12 Then

lblSGBCode.Caption = "SGB Code:" & vbNewLine & Mid$(txtColorCode.Text, 1, 4) & "-" & Mid$(txtColorCode.Text, 5, 4) & "-" & Mid$(txtColorCode.Text, 9, 4)
txtBGBINIEntry.Text = Mid$(lblScreenColors(0).ToolTipText, 3) & "." & Mid$(lblScreenColors(1).ToolTipText, 3) & "." & Mid$(lblScreenColors(2).ToolTipText, 3) & "." & Mid$(lblScreenColors(3).ToolTipText, 3) & "."
txtBGBINIEntry.Text = txtBGBINIEntry.Text & txtBGBINIEntry.Text & txtBGBINIEntry.Text & txtBGBINIEntry.Text
txtBGBINIEntry.Text = "ColorScheme=" & txtBGBINIEntry.Text & "SGB Color " & txtColorCode.Text

If Not EditingColors Then
DecodeColorPassword txtColorCode.Text
End If
End If

End Sub

