Attribute VB_Name = "StartUp"
Option Explicit

Private lBuff As Long
Private iBuff As Integer

Public Sub Main()
    If RunProcess("subspace.bin") = False Then
        If RunProcess("subspace.exe") = False Then
            UnloadHandles
            End
        End If
    End If
    Randomize Timer

    Do While Err.LastDllError = 0
        DoEvents
            
'            FireGuns

'            BaseAddy1 = Peek4(4702840) + 150
'        If BaseAddy1 > 150 Then
'            BaseAddy2 = Peek4(4702844) + 150

'            x1 = Peek4(BaseAddy1)
'            y1 = Peek4(BaseAddy1 + 4)
'            x2 = Peek4(BaseAddy2)
'            y2 = Peek4(BaseAddy2 + 4)

'            If Abs(x1 - x2) > 2000000 Or Abs(y1 - y2) > 2000000 Then
'                Call Poke4(BaseAddy1, Peek4(BaseAddy2))
'                Call Poke4(BaseAddy1 + 4, Peek4(BaseAddy2 + 4))
'                Call Poke4(BaseAddy1 + 16, Peek4(BaseAddy2 + 16))
'                Call Poke4(BaseAddy1 + 20, Peek4(BaseAddy2 + 20))
'                Call Poke4(BaseAddy1 + 24, Peek4(BaseAddy2 + 24))
'            ElseIf Abs(x1 - x2) < 20000 Then
'            If Abs(x1 - x2) < 40000 Then
'               If Abs(y1 - y2) < 40000 Then
'                    Call Poke4(BaseAddy1 + 16, Peek4(BaseAddy2 + 16))
'                    Call Poke4(BaseAddy1 + 20, Peek4(BaseAddy2 + 20))
'                    Call Poke4(BaseAddy1 + 24, Peek4(BaseAddy2 + 24))
'                    CurDir = -1
'                ElseIf y1 < y2 Then
'                    CurDir = 5
'                Else
'                    CurDir = 1
'                End If
'            ElseIf Abs(y1 - y2) < 40000 Then
'                If x1 < x2 Then
'                    CurDir = 3
'                Else
'                    CurDir = 7
'                End If
'            Else
'                If x1 < x2 Then
'                    If y1 < y2 Then
'                        CurDir = 4
'                    Else
'                        CurDir = 2
'                    End If
'                Else
'                    If y1 < y2 Then
'                        CurDir = 6
'                    Else
'                        CurDir = 8
'                    End If
'                End If
'            End If
            
            'Call Poke4(BaseAddy1, Peek4(BaseAddy2))
            'Call Poke4(BaseAddy1 + 4, Peek4(BaseAddy2 + 4))
            'Call Poke4(BaseAddy1 + 16, Peek4(BaseAddy2 + 16))
            'Call Poke4(BaseAddy1 + 20, Peek4(BaseAddy2 + 20))
            'Call Poke4(BaseAddy1 + 24, Peek4(BaseAddy2 + 24))

            'Select Case PeekS(4738624 + 24 + 2)
            '    Case "8": CurDir = 1
            '    Case "6": CurDir = 2
            '    Case "2": CurDir = 3
            '    Case "4": CurDir = 4
            'End Select

'            ChangeDirection CurDir
'        End If

        'Permission ID
        lBuff = CLng(Rnd * 2147483647)
        Call Poke4(4914080, lBuff)
        Call Poke4(4915000, lBuff)
        'Machine ID
        Call Poke4(4923356, lBuff)
        'TimeZoneBias
        Call Poke2(4911604, 0)
        'Supervisor
        Call Poke2(4923764, 1)
    Loop

    UnloadHandles
    End
End Sub

'Y-minimum = 14001
'X-minimum = 14005
'Y-limit = 16369995
'X-limit = 16369891

'        Call PokeS(4814872, "test" + Chr(0) + Chr(13))
'        Call Poke(4857236, Peek(4702844))
'        Call Poke(4857232, Peek(4702840))

'            Call Poke4(BaseAddy, x * 8192)
'            Call Poke4(BaseAddy + 4, y * 8192)

'Public Sub ChangeDirection(NewHeading As Long)
'    Select Case NewHeading
'        Case 0
'            Call Poke4(BaseAddy1 + 16, 0)
'            Call Poke4(BaseAddy1 + 20, 0)
'        Case 1
'            Call Poke4(BaseAddy1 + 16, 0)
'            Call Poke4(BaseAddy1 + 20, -5000)
'        Case 2
'            Call Poke4(BaseAddy1 + 16, 5000)
'            Call Poke4(BaseAddy1 + 20, -5000)
'        Case 3
'            Call Poke4(BaseAddy1 + 16, 5000)
'            Call Poke4(BaseAddy1 + 20, 0)
'        Case 4
'            Call Poke4(BaseAddy1 + 16, 5000)
'            Call Poke4(BaseAddy1 + 20, 5000)
'        Case 5
'            Call Poke4(BaseAddy1 + 16, 0)
'            Call Poke4(BaseAddy1 + 20, 5000)
'        Case 6
'            Call Poke4(BaseAddy1 + 16, -5000)
'            Call Poke4(BaseAddy1 + 20, 5000)
'        Case 7
'            Call Poke4(BaseAddy1 + 16, -5000)
'            Call Poke4(BaseAddy1 + 20, 0)
'        Case 8
'            Call Poke4(BaseAddy1 + 16, -5000)
'            Call Poke4(BaseAddy1 + 20, -5000)
'    End Select
'    If NewHeading > 0 Then Call Poke4(BaseAddy1 + 24, (NewHeading - 1) * 5000)
'End Sub
