'/title Constellations (SIngle)
'/type utility
'====================================================================
' when the constellation is displayed:
'   TAB = show star color / show star brightness
'     C = connect stars with line
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DIM SHARED field$(10), minRA, maxRA
DIM SHARED maxObjects: maxObjects = 500
DIM SHARED RA(maxObjects), Dec(maxObjects), Objects
DIM SHARED AppMag(maxObjects), ObjNames$(maxObjects), Cata$(maxObjects)
DIM SHARED SpecType$(maxObjects)
DIM SHARED pickFromListFile$: pickFromListFile$ = "PikFrmLi.tmp"
DIM SHARED RAhr(1440), RAmin(1440), RAx(1440)
DIM SHARED DecDeg(180), DecY(180)
DIM SHARED ScrnWidth: ScrnWidth = 1200
DIM SHARED ScrnHeight: ScrnHeight = 690
DIM SHARED TotMins, MinSpacing, DecSpacing, minDec, maxDec
DIM SHARED datafile$, ShowObjColor, ConnectObjects
DIM SHARED PgmTitle$: PgmTitle$ = "Constellations (single)"

DIM SHARED configfile$: configfile$ = "constellations-single.ini"
DIM SHARED MaxCircleRad, BrighterThan
GetLabelValue configfile$, "MaxCircleRad", "", MaxCircleRad
GetLabelValue configfile$, "BrighterThan", "", BrighterThan

GetCurrentPath path$
GetLabelValue configfile$, "ConstsFolder", fldr$, 0
DIM SHARED DataPath$: DataPath$ = path$ + "\" + fldr$ + "\"

PickAConst

SUB CheckForFile (f$, found) '############################################################
    found = 0
    IF _FILEEXISTS(f$) THEN found = 1
END SUB

SUB DrawBox (x, y, w, h, Rd, Gr, Bl, fill) '###########################################
    clr& = _RGB32(Rd, Gr, Bl)
    IF fill THEN
        LINE (x, y)-(x + w - 1, y + h - 1), clr&, BF
    ELSE
        LINE (x, y)-(x + w - 1, y + h - 1), clr&, B
    END IF
END SUB

SUB DrawCircle (x, y, r, Rd, Gr, Bl, fill) '###########################################
    clr& = _RGB32(Rd, Gr, Bl)
    IF fill THEN
        CIRCLE (x, y), r, clr&
        PAINT (x, y), clr&, clr&
    ELSE
        CIRCLE (x, y), r, clr&
    END IF
END SUB

SUB DrawDegreeLines '#######################################################
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    '* draw Decs (rows)
    '-------------------------------------------------------------------------
    x = 0
    y = ScrnHeight - 1
    W = ScrnWidth
    H = 1
    fill = 0
    ''PRINT minDec; maxDec

    FOR DecsLoop = minDec TO maxDec
        ''PRINT DecsLoop
        Rd = 0
        x$ = LTRIM$(STR$(DecsLoop))
        IF RIGHT$(x$, 1) = "0" THEN
            Rd = 50
            t$ = LTRIM$(STR$(DecsLoop))
            PrintText x, y, t$
        END IF
        Gr = Rd
        Bl = Rd
        DrawBox x, y, W, H, Rd, Gr, Bl, fill
        i = i + 1
        DecDeg(i) = DecsLoop
        DecY(i) = y
        y = y - DecSpacing
    NEXT

    EXIT SUB


    PRINT DecsLoop; maxDec
    PRINT DecDeg(1); DecDeg(i)
    pauseEnd

END SUB

SUB DrawHourLines '########################################################
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    '* draw hours (columns)
    '-------------------------------------------------------------------------
    x = ScrnWidth - 1
    y = 0
    W = 1
    H = ScrnHeight
    fill = 0
    Rd = 20
    Gr = Rd
    Bl = Rd

    hr = minRA
    min = 0
    ''hour# = minRA
    ''PRINT TotMins: END
    ''PRINT minRA: END

    FOR cols = 1 TO TotMins
        Rd = 0 '20
        IF min = 0 THEN Rd = 50
        Gr = Rd
        Bl = Rd
        DrawBox x, y, W, H, Rd, Gr, Bl, fill
        IF min = 0 THEN
            t$ = LTRIM$(STR$(hr))
            PrintText x, 0, t$
        END IF
        RAhr(cols) = hr
        RAmin(cols) = min
        RAx(cols) = x
        'PRINT x; hr; min
        'IF cols = 10 THEN END
        min = min + 1
        IF min = 60 THEN
            ''pauseEnd
            min = 0
            hr = hr + 1
            IF hr = 24 THEN hr = 0
        END IF
        x = x - MinSpacing
        'hour# = hour# + 1
    NEXT
    cols = cols - 1
    'PRINT RAhr(cols); RAmin(cols): END
    'pauseEnd

END SUB

SUB DrawLine (x, y, x2, y2, Rd, Gr, Bl) '###########################################
    clr& = _RGB32(Rd, Gr, Bl)
    IF fill THEN
        LINE (x, y)-(x2, y2), clr&
    ELSE
        LINE (x, y)-(x2, y2), clr&
    END IF
END SUB

SUB DrawObjectsOnScreen (const$) '@###############################################

    _TITLE PgmTitle$ + " : " + const$

    ''PRINT Objects; "<": END

    FOR i = 1 TO Objects

        ''LOCATE 5, 1: PRINT ObjNames$(i); "<-object"

        GetXpos i, x

        GetYpos i, y

        Rd = 200
        Gr = 255
        Bl = 10
        fill = 1

        '1.46 is the adjustment factor. see subroutine "LoadConstData"
        'adjusting viewable range of -1.46 thru 6.99  to 0 to 8.36
        am = AppMag(i) + 1.46
        ''per = am / 11.46
        per = am / 8.36
        per = per * 100
        per = 100 - per
        per = per * .01
        n = 255 * per
        RemoveDecimal n
        Rd = n
        Gr = n
        Bl = n
        '------------
        IF 1 = 11 THEN
            x$ = LCASE$(ObjNames$(i))
            p = INSTR(x$, "betel")
            IF p > 0 THEN
                'SOUND 3000, .5
                Rd = 0
                Gr = 200
                Bl = 255
            ELSE
                Rd = 0
                Gr = 0
                Bl = 0
            END IF
        END IF
        '-------------

        r = MaxCircleRad * per
        RemoveDecimal r

        DrawTheObject = 1

        IF ShowObjColor THEN
            r = 3 'make all objects same radius
            SELECT CASE UCASE$(Cata$(i))
                CASE "N", "G", "R"
                    lbl$ = "ObjectTypeColor-" + Cata$(i)
                    GetLabelValue configfile$, lbl$, v$, n
                CASE ELSE
                    keyfld$ = LCASE$(LEFT$(SpecType$(i), 1))
                    table$ = "StarColors"
                    GetTableValue configfile$, table$, keyfld$, v$
            END SELECT
            IF v$ <> "" THEN
                GetFields v$, " ", 3
                Rd = VAL(field$(1))
                Gr = VAL(field$(2))
                Bl = VAL(field$(3))
            ELSE
                Rd = 0: Gr = 255: Bl = 0
            END IF
        ELSE
            IF AppMag(i) = 0 THEN
                'An AppMag of Zero is interpretted as missing
                'if object's AppMag is Zero, Do not show when
                'drawing objects based on AppMag mode.
                'assuming no object has an even Zero AppMag
                DrawTheObject = 0
            END IF
        END IF

        IF DrawTheObject THEN
            DrawCircle x, y, r, Rd, Gr, Bl, fill
        END IF

        ''pauseEnd

    NEXT


    ''EXIT SUB

    '-------------------------------------------------------------------
    '** connect objects
    IF ConnectObjects = 0 THEN EXIT SUB

    f$ = DataPath$ + const$ + ".inf"

    CheckForFile f$, found
    IF found = 0 THEN EXIT SUB

    ff = FREEFILE: OPEN f$ FOR INPUT AS #ff
    DO UNTIL EOF(ff)
        LINE INPUT #ff, n$
        n$ = LCASE$(n$)
        IF n$ = "" THEN
            x1 = 0
            y1 = 0
            ''EXIT DO
        ELSE
            FOR i = 1 TO Objects
                o$ = LCASE$(ObjNames$(i))
                p = INSTR(o$, n$)
                IF p > 0 THEN
                    ''LOCATE 1, 1
                    GetXpos i, x
                    GetYpos i, y
                    IF x1 = 0 AND y1 = 0 THEN
                        x1 = x
                        y1 = y
                    ELSE
                        Rd = 255
                        Gr = 0
                        Bl = 0
                        x2 = x
                        y2 = y
                        ''DrawCircle x, y, 5, Rd, Gr, Bl, 0
                        DrawLine x1, y1, x2, y2, Rd, Gr, Bl
                        x1 = x2
                        y1 = y2
                    END IF
                END IF
            NEXT
        END IF
    LOOP
    CLOSE ff

END SUB

SUB FindObject '###########################################################

    LOCATE 1, 1
    INPUT "find what: ", o$
    o$ = LTRIM$(RTRIM$(o$))
    IF o$ = "" THEN EXIT SUB

    FOR i = 1 TO Objects
        p = INSTR(UCASE$(ObjNames$(i)), UCASE$(o$))
        IF p > 0 THEN
            GetXpos i, x
            GetYpos i, y
            r = 5
            Rd = 255
            Gr = 0
            Bl = 0
            DrawCircle x, y, r, Rd, Gr, Bl, 1
            EXIT SUB
        END IF
    NEXT

    LOCATE 1, 1
    PRINT "** not found** "; Objects

END SUB

SUB GetCurrentPath (path$) '###############################################
    tf$ = "~~lkssasjdhf.tmp"
    SHELL "dir >" + tf$
    ''SHELL "notepad.exe " + tf$: END
    do$ = " Directory of "
    OPEN tf$ FOR INPUT AS 10
    DO UNTIL EOF(10)
        LINE INPUT #10, x$
        IF LEFT$(x$, LEN(do$)) = do$ THEN
            path$ = RIGHT$(x$, LEN(x$) - LEN(do$))
            'path$ = RIGHT$(path$, LEN(path$) - 2) 'trim off C:
            'path$ = LEFT$(path$, LEN(path$) - 2) 'trim off \.
            EXIT DO
        END IF
    LOOP
    CLOSE 10
END SUB

SUB GetFields (x$, sep$, max) '############################################
    z$ = x$ + sep$
    FOR i = 1 TO max
        p = INSTR(z$, sep$)
        field$(i) = RTRIM$(LEFT$(z$, p - 1))
        z$ = RIGHT$(z$, LEN(z$) - p)
    NEXT
END SUB

SUB GetLabelValue (lblfile$, lbl$, v$, n) '#######################################################
    v$ = "": n = FREEFILE: OPEN lblfile$ FOR INPUT AS #n
    DO UNTIL EOF(n)
        LINE INPUT #n, dta$: dta$ = RTRIM$(LTRIM$(dta$))
        IF LEFT$(dta$, 1) = "'" THEN dta$ = ""
        P = INSTR(dta$, "=")
        IF P THEN
            l$ = RTRIM$(LEFT$(dta$, P - 1))
            IF LCASE$(l$) = LCASE$(lbl$) THEN
                v$ = LTRIM$(RIGHT$(dta$, LEN(dta$) - P))
                EXIT DO
            END IF
        END IF
    LOOP: CLOSE #n
    n = VAL(v$)
END SUB

SUB GetTableValue (fname$, table$, keyfld$, v$) '######################################
    v$ = ""
    lk4$ = LCASE$("/" + table$)
    ff = FREEFILE: OPEN fname$ FOR INPUT AS #ff
    DO UNTIL EOF(ff)
        LINE INPUT #ff, x$
        x$ = LTRIM$(RTRIM$(x$))
        IF LEFT$(x$, 1) = "'" THEN x$ = ""
        IF x$ <> "" THEN
            IF LEFT$(x$, 1) = "/" THEN
                IF found THEN EXIT DO
                IF LCASE$(x$) = lk4$ THEN
                    found = 1
                    ''PRINT x$
                END IF
            ELSE
                IF found THEN
                    ''PRINT "  "; x$
                    p = INSTR(x$, " ")
                    IF p > 0 THEN
                        z$ = LEFT$(x$, p - 1)
                        IF UCASE$(z$) = UCASE$(keyfld$) THEN
                            v$ = RIGHT$(x$, LEN(x$) - p)
                            EXIT DO
                        END IF
                    END IF
                END IF
            END IF
        END IF
    LOOP
    CLOSE ff
END SUB

SUB GetXpos (i, x) '#######################################################

    'IF i = 7 THEN
    '    CLS
    '    PRINT TotMins
    '    END
    'END IF

    '----------------------------------------------------------------
    '-- get Hour and Minute
    '
    x$ = LTRIM$(STR$(RA(i)))
    ''PRINT i; RA(i): END
    p = INSTR(x$, ".")
    IF p = 0 THEN
        hr = VAL(x$)
        min = 0
    ELSE
        hr = VAL(LEFT$(x$, p - 1))
        m$ = RIGHT$(x$, LEN(x$) - p)
        IF LEN(m$) = 1 THEN m$ = m$ + "0"
        min = VAL(m$)
    END IF

    '' PRINT TotMins: END
    FOR q = 1 TO TotMins
        IF hr = RAhr(q) THEN
            'LOCATE 1, 1
            'PRINT "Hour match!"; q; hr: END
            IF min = RAmin(q) THEN
                a = q
                EXIT FOR
            END IF
        END IF
    NEXT

    IF a = 0 THEN
        LOCATE 1, 1
        PRINT "*** ERROR ****"
        PRINT "X not found for "; RA(i); "("; i; ")"
        PRINT hr; min
        END
    END IF

    'CLS
    'LOCATE 1, 1:
    'PRINT i; RA(i)
    'PRINT hr; min; a; RAx(a)
    'END

    x = RAx(a)

END SUB

SUB GetYpos (i, y) '##########################################################

    deg = Dec(i)
    x$ = LTRIM$(STR$(deg))
    p = INSTR(x$, ".")
    IF p = 0 THEN
        d = VAL(x$)
        m = 0
    ELSE
        d = VAL(LEFT$(x$, p - 1))
        m = VAL(RIGHT$(x$, LEN(x$) - p))
    END IF

    'what is the Y coord. for this degree?
    'minDec = lowest line / maxDec = highest line
    'getting total up/down degrees on screen
    degrees = maxDec - minDec
    a = 0
    ''LOCATE 1, 1: PRINT minDec; maxDec: END
    ForStop = maxDec - minDec + 1
    FOR q = 1 TO ForStop
        'DecDeg() contains the Degree of each Hor. line drawn on screen
        IF DecDeg(q) = d THEN
            a = q
            EXIT FOR
        END IF
    NEXT

    IF a = 0 THEN
        LOCATE 1, 1
        PRINT "*** ERROR ****"
        PRINT "Y not found for "; Dec(i)
        END
    END IF

    y = DecY(a)

    IF 1 = 1 THEN
        'IF i = 4 THEN
        '    LOCATE 1, 1: PRINT Dec(i); d
        '    END
        'END IF
        'make Y more precise
        pct = m / 60
        adjust = DecSpacing * pct
        RemoveDecimal adjust
        ''IF d < 0 THEN adjust = adjust * -1
        IF Dec(i) < 0 THEN adjust = adjust * -1
        y = y - adjust
    END IF

    'LOCATE 1, 1
    'PRINT DecY(a); adjust
    'pauseEnd

END SUB

SUB LoadConstData (const$) '###############################################

    ' load constellation data

    ''SHELL "notepad.exe " + datafile$: END

    OPEN datafile$ FOR INPUT AS #1

    minRA = 99
    maxRA = -1
    minDec = 99
    maxDec = -100

    '----------------------------------------------------------------------------
    'LeftHourLimit : used for constellations that overlap 0hour
    table$ = "LeftHourLimit"
    keyfld$ = LCASE$(const$)
    ''LOCATE 1, 1: PRINT keyfld$; "<": END
    GetTableValue configfile$, table$, keyfld$, v$
    IF v$ <> "" THEN LeftHourLimit = VAL(v$)
    '----------------------------------------------------------------------------

    DO UNTIL EOF(1)

        LINE INPUT #1, x$
        GetFields x$, CHR$(9), 9
        cat$ = UCASE$(field$(1)) 'cataogry
        objname$ = field$(3)
        RA = VAL(field$(4)) 'RA
        Dec = VAL(field$(5)) ' Dec
        AppMag = VAL(field$(6)) 'AppMag

        ok = 1
        IF BrighterThan <> 0 THEN
            IF AppMag >= BrighterThan THEN ok = 0
        END IF
        ''IF AppMag >= 7 THEN ok = 0 'not viewable

        IF ok THEN

            i = i + 1
            Cata$(i) = cat$
            ObjNames$(i) = objname$
            RA(i) = RA
            Dec(i) = Dec
            AppMag(i) = AppMag
            SpecType$(i) = field$(7)

            IF LeftHourLimit > 0 THEN
                IF RA >= LeftHourLimit THEN
                    IF RA(i) < minRA THEN
                        minRA = RA(i)
                        'PRINT objname$; " <largest"
                    END IF
                ELSE
                    IF RA(i) > maxRA THEN
                        maxRA = RA(i)
                        'PRINT objname$; "smallest"
                    END IF
                END IF
            ELSE
                IF RA(i) > maxRA THEN
                    maxRA = RA(i)
                    'PRINT objname$; " <largest"
                END IF
                IF RA(i) < minRA THEN
                    minRA = RA(i)
                    'PRINT objname$; "smallest"
                END IF
            END IF

            IF Dec(i) > maxDec THEN
                maxDec = Dec(i)
                PRINT objname$; " < max Dec"
            END IF
            IF Dec(i) < minDec THEN
                minDec = Dec(i)
                ''PRINT objname$; " < min Dec"
            END IF

            IF i = maxObjects THEN EXIT DO
            ''IF i = 10 THEN EXIT DO
        END IF

    LOOP

    CLOSE 1

    Objects = i

    'FOR i = 1 TO 10 'Objects
    '    PRINT i; RA(i)
    'NEXT
    'END

    GetLabelValue configfile$, "ScreenWidth", "", ScrnWidth
    GetLabelValue configfile$, "ScreenHeight", "", ScrnHeight

    ''PRINT i; minRA; maxRA: END

    RemoveDecimal minRA
    RemoveDecimal maxRA
    IF LeftHourLimit > 0 THEN
        minRA = minRA - 1
    END IF
    maxRA = maxRA + 1
    hours = maxRA - minRA
    IF LeftHourLimit > 0 THEN
        hours = (24 - minRA) + maxRA
    END IF
    TotMins = hours * 60 'hours x 60 mins per hour
    IF TotMins > ScrnWidth THEN
        'screen needs to be wider than "allocated" in the config file
        'more total minutes than pixels across
        ScrnWidth = TotMins
    END IF
    MinSpacing = ScrnWidth / TotMins 'hours
    RemoveDecimal MinSpacing
    ScrnWidth = MinSpacing * TotMins

    'PRINT LeftHourLimit
    'PRINT minRA; maxRA
    'PRINT MinSpacing; TotMins
    'PRINT ScrnWidth; ScrnHeight: END
    SCREEN _NEWIMAGE(ScrnWidth, ScrnHeight, 32)

    'LOCATE 1, 1
    'PRINT "Dec min/max:"; minDec; maxDec
    RemoveDecimal minDec
    RemoveDecimal maxDec
    maxDec = maxDec + 1
    Decs = maxDec - minDec
    'PRINT "Decs:"; Decs
    DecSpacing = ScrnHeight / Decs
    RemoveDecimal DecSpacing
    'PRINT DecSpacing
    'END

END SUB

SUB pauseEnd '##########################################################
    DO
        k$ = INKEY$
        IF k$ <> "" THEN EXIT DO
    LOOP
    CLS
    SYSTEM
END SUB

SUB PickAConst '#######################################################

    _TITLE PgmTitle$

    CLS

    IF 1 = 11 THEN
        PRINT "Loading list..."
        tf$ = "~consts2.tmp"
        q$ = CHR$(34)
        cmd$ = "dir " + q$ + DataPath$ + "*.dat" + q$ + " /b >" + tf$
        SHELL cmd$
    END IF

    DO

        IF skipit = 0 THEN
            SCREEN _NEWIMAGE(300, 300, 32)
            CLS
            PRINT "pick a constellation..."

            '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            ff = FREEFILE: OPEN "~OpenFile.tmp" FOR OUTPUT AS #ff
            WRITE #ff, "pick constellation"
            WRITE #ff, DataPath$
            WRITE #ff, "*.dat"
            ''WRITE #ff, "L" 'view mode : D = detail / L = list
            WRITE #ff, 20 'characters per column (for List mode)
            WRITE #ff, " /hideExtn /list "
            CLOSE ff
            SHELL "$OpenFile.exe"
            OPEN "~OpenFile.tmp" FOR INPUT AS #ff
            INPUT #ff, n, const$
            CLOSE ff
            const$ = LEFT$(const$, LEN(const$) - 4) 'trim off .DAT
            '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

            IF n = 0 THEN
                CLS
                SYSTEM
            END IF

            datafile$ = "~ConstCombo.tmp"

            datafile$ = DataPath$ + const$ + ".dat"

        END IF

        skipit = 0

        LoadConstData const$
        DrawHourLines
        DrawDegreeLines
        DrawObjectsOnScreen const$
        'LOCATE 1, 1
        'PRINT "RA:"; maxRA; "-"; minRA
        'PRINT "Dec:"; maxDec; "-"; minDec

        '----------------------
        IF 1 = 11 THEN
            FOR l = 20 TO 100
                LOCATE l, 1: PRINT l
                DO
                    k$ = INKEY$
                    IF k$ = " " THEN EXIT DO
                    IF k$ = CHR$(27) THEN SYSTEM
                LOOP
            NEXT
        END IF
        '-----------------------

        DO

            DO WHILE _MOUSEINPUT ' get latest mouse information
            LOOP
            x% = _MOUSEX: mx = x%
            y% = _MOUSEY: my = y%
            LeftClick% = _MOUSEBUTTON(1) '                 retrieve left button status
            RightClick% = _MOUSEBUTTON(2) '                retrieve right button status
            IF LeftClick% = -1 THEN
                IF clkd = 0 THEN
                    TestClickPos mx, my
                    ''IF reload THEN GOTO SetTheScreen
                    clkd = 1
                END IF
            ELSE
                clkd = 0
            END IF


            k$ = UCASE$(INKEY$)
            IF k$ = CHR$(27) THEN CLS: SYSTEM
            IF k$ = "F" THEN
                FindObject
                k$ = ""
            END IF
            IF k$ <> "" THEN
                IF k$ = CHR$(9) THEN
                    skipit = 1
                    IF ShowObjColor THEN
                        ShowObjColor = 0
                    ELSE
                        ShowObjColor = 1
                    END IF
                END IF
                IF k$ = "C" THEN
                    'connect objects on/off
                    skipit = 1
                    IF ConnectObjects = 1 THEN
                        ConnectObjects = 0
                    ELSE
                        ConnectObjects = 1
                    END IF
                END IF
                EXIT DO
            END IF
        LOOP

    LOOP

END SUB

SUB PrintText (x, y, t$) '#################################################
    'print as close to X Y as possible
    charW = 8
    charH = 16
    maxAcross = ScrnWidth / charW
    RemoveDecimal maxAcross
    maxLines = ScrnHeight / charH
    RemoveDecimal maxLines
    maxLines = maxLines - 2
    l = y / charH
    p = x / charW
    p2 = p + LEN(t$) - 1
    IF p < 1 THEN p = 1
    IF p2 > maxAcross THEN EXIT SUB
    IF l < 1 THEN l = 1
    IF l > maxLines THEN EXIT SUB
    ''LOCATE 1, 1: PRINT l; p
    LOCATE l, p
    PRINT t$
END SUB

SUB RemoveDecimal (n) '#####################################################
    x$ = LTRIM$(STR$(n))
    p = INSTR(x$, ".")
    IF p > 0 THEN n = VAL(LEFT$(x$, p - 1))
END SUB

SUB TestClickPos (mx, my) '##############################################

    dif = 5

    FOR i = 1 TO Objects

        GetXpos i, x
        GetYpos i, y
        Rd = 0
        Gr = 0
        Bl = 0

        IF mx >= x - dif AND mx <= x + dif THEN
            IF my >= y - dif AND my <= y + dif THEN

                Rd = 255
                LOCATE 1, 1
                PRINT USING "\                            \"; ObjNames$(i)
                PRINT USING "RA ##.##  Dec ###.##"; RA(i); Dec(i)
                PRINT USING "App mag. ##.#"; AppMag(i)
                PRINT USING "Catagory: \ \"; Cata$(i)
                PRINT USING "Spec Type: \       \"; SpecType$(i)

            END IF
        END IF

        DrawCircle x, y, 5, Rd, Gr, Bl, 0

    NEXT

END SUB
