QB64 Phoenix Edition
Matrix Clock by harixx (from 6-16-2010) - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Programs (https://qb64phoenix.com/forum/forumdisplay.php?fid=7)
+---- Thread: Matrix Clock by harixx (from 6-16-2010) (/showthread.php?tid=2158)



Matrix Clock by harixx (from 6-16-2010) - SMcNeill - 11-13-2023

Code: (Select All)
_TITLE "MATRIX v1.0"
'-----| by harixxx
'-----| 6-16-2010

CONST object = 128
CONST tail = 64
CONST title$ = "  CCNT  "

TYPE Event
    tyme AS STRING * 8
    image AS STRING * 12
    length AS INTEGER
    audio AS STRING * 12
END TYPE

DIM SHARED events(100) AS Event

LoadEvents

MatrixClock


'----------------------
SUB MatrixClock

    SCREEN _NEWIMAGE(640, 480, 256)
    VIEW PRINT 1 TO 30
    RANDOMIZE TIMER

    DIM Char(3, object, tail), CharSet(52) AS STRING * 1
    FOR i = 0 TO 63
        OUT 968, i
        OUT 969, 0
        OUT 969, i
        OUT 969, 0
    NEXT
    FOR i = 0 TO 36
        CharSet(i) = CHR$(i + 129)
    NEXT
    FOR i = 37 TO 52
        CharSet(i) = CHR$(i + 187)
    NEXT
    FOR i = 1 TO object
        Char(0, i, tail) = INT(RND * 80) + 1
        Char(1, i, tail) = INT(RND * 30) + 1
        Char(2, i, tail) = RND * 52
        Char(3, i, tail) = RND + .1
    NEXT

    _FULLSCREEN
    DO
        REDIM bg(80, 30)
        COLOR 1
        LOCATE 1, 1
        PRINT title$

        tm$ = TIME$
        hr% = VAL(LEFT$(tm$, INSTR(tm$, ":") - 1))
        IF hr% > 12 THEN hr% = hr% - 12
        tm$ = LTRIM$(STR$(hr%)) + RIGHT$(tm$, LEN(tm$) - INSTR(tm$, ":") + 1)
        IF LEN(tm$) < 8 THEN tm$ = "0" + tm$
        PRINT " "; tm$; " "

        IF RIGHT$(tm$, 2) = "00" THEN CheckForEvent TIME$

        FOR i = 0 TO 28
            FOR j = 0 TO 78
                IF POINT(j, i) > 0 THEN
                    bg(j + 1, i + 1) = 40
                    bg(j + 2, i + 1) = -20
                    bg(j + 2, i + 2) = -20
                END IF
        NEXT j, i
        FOR i = 1 TO object
            FOR j = 1 TO tail - 1
                FOR k = 0 TO 2
                    Char(k, i, j) = Char(k, i, j + 1)
                NEXT
                IF RND < .1 THEN Char(k, i, j) = (Char(k, i, j) + 1) MOD 53
            NEXT
            Char(1, i, tail) = Char(1, i, tail) + Char(3, i, tail)
            IF Char(1, i, tail) > 30 THEN
                Char(0, i, tail) = INT(RND * 80) + 1
                Char(1, i, tail) = 1
                Char(2, i, tail) = RND * 52
                Char(3, i, tail) = RND + .1
            END IF
            Char(2, i, tail) = (Char(2, i, tail) + 1) MOD 53
        NEXT
        FOR i = 1 TO object
            FOR j = 1 TO tail
                yy = Char(1, i, j)
                xx = Char(0, i, j)
                IF yy > 0 AND yy < 31 AND xx > 0 AND xx < 81 THEN
                    IF j = tail THEN c = 35 ELSE c = INT(j / tail * 30)
                    c = c + bg(xx, yy)
                    c = 1 * -(c < 1) + c * -(c > 0)
                    c = 63 * -(c > 63) + c * -(c < 64)
                    COLOR c
                    LOCATE yy, xx
                    PRINT CharSet(Char(2, i, j));
                END IF
        NEXT j, i
        _DISPLAY
    LOOP UNTIL INKEY$ > ""
    SYSTEM



END SUB

'----------------------
SUB LoadEvents

    DIM eventcount%

    eventcount% = 0
    OPEN "events.txt" FOR INPUT AS #1
    DO
        LINE INPUT #1, event$
        IF LEFT$(event$, 1) <> ";" AND LEFT$(event$, 1) <> "*" THEN
            eventcount% = eventcount% + 1
            events(eventcount%).tyme = event$
            LINE INPUT #1, event$
            events(eventcount%).image = event$ + ".bmp"
            events(eventcount%).audio = event$ + ".wav"
            LINE INPUT #1, event$
            events(eventcount%).length = VAL(event$)
        END IF
    LOOP UNTIL LEFT$(event$, 1) = "*"
    CLOSE #1

END SUB

'----------------------
SUB CheckForEvent (tm$)

END SUB


A Matrx-style clock, from over a dozen years ago, written in QB64 -- and still working!!

Takes the file here, which goes with it:  
.txt   events.txt (Size: 1.18 KB / Downloads: 50)

Be certain to grab the events.txt and place it in the QB64 folder (or wherever you want it and point it to it), and this should compile and run with no issues.


RE: Matrix Clock by harixx (from 6-16-2010) - TerryRitchie - 11-13-2023

This is the version I modified to use in my classroom (CCNT - Computer Communications and Networking Technologies) when I was a teacher. I had a 20" LCD screen hanging on the wall with a mini-ITX computer tucked away above the ceiling tiles running the code. The students loved it.


RE: Matrix Clock by harixx (from 6-16-2010) - bplus - 11-13-2023

What is supposed to be going on in upper right corner?


RE: Matrix Clock by harixx (from 6-16-2010) - TerryRitchie - 11-13-2023

(11-13-2023, 06:03 PM)bplus Wrote: What is supposed to be going on in upper right corner?

CONST title$ = "   CCNT   "

There is supposed to be three spaces preceding and following CCNT in the line above. For some reason there is only 2?

There should also be a:

_LIMIT 30

after the

DO

that follows

_FULLSCREEN


RE: Matrix Clock by harixx (from 6-16-2010) - TerryRitchie - 11-13-2023

Here is another version I found on my NAS from way back:

Code: (Select All)
_TITLE "MATRIX v1.0"
'-----| by harixxx
'-----| 6-16-2010

CONST OBJECT = 256
CONST TAIL = 64
CONST LIMIT = 30

SCREEN _NEWIMAGE(640, 480, 256)
VIEW PRINT 1 TO 30
RANDOMIZE TIMER

DIM Char(3, OBJECT, TAIL), CharSet(52) AS STRING * 1
DIM Count%
DIM Fcount%
DIM Mpos%
DIM Message$
DIM Tfcount%
DIM NewMessage$

FOR Count% = 0 TO 63
    OUT 968, Count%
    OUT 969, 0
    OUT 969, Count%
    OUT 969, 0
NEXT

FOR Count% = 0 TO 36
    CharSet(Count%) = CHR$(Count% + 129)
NEXT
FOR Count% = 37 TO 52
    CharSet(Count%) = CHR$(Count% + 187)
NEXT
FOR Count% = 1 TO OBJECT
    Char(0, Count%, TAIL) = INT(RND * 80) + 1
    Char(1, Count%, TAIL) = INT(RND * 30) + 1
    Char(2, Count%, TAIL) = RND * 52
    Char(3, Count%, TAIL) = RND + .1
NEXT

Fcount% = 0
Tfcount% = 0
Mpos% = 0
Message$ = DayOfWeek$ + CustomMessage$
DO
    _LIMIT LIMIT
    IF Tfcount% = LIMIT * 60 THEN Tfcount% = 0
    IF Tfcount% = 0 THEN NewMessage$ = DayOfWeek$ + CustomMessage$
    Tfcount% = Tfcount% + 1
    Fcount% = Fcount% + 1
    IF Fcount% = LIMIT \ 4 THEN
        Fcount% = 0
        Mpos% = Mpos% + 1
        IF Mpos% > LEN(Message$) THEN
            Mpos% = 1
            IF NewMessage$ <> Message$ THEN Message$ = NewMessage$
        END IF
    END IF
    Title$ = MID$(Message$, Mpos%, 10)
    Title$ = LEFT$(Title$ + "         ", 10)
    SHOWCLOCK Title$
LOOP UNTIL INKEY$ <> ""



'----------------------------------------------------------------------------------------------------------------------

FUNCTION CustomMessage$ ()

    DIM Message$

    IF _FILEEXISTS("mclock.txt") THEN
        OPEN "mclock.txt" FOR INPUT AS #1
        LINE INPUT #1, Message$
        CLOSE #1
    END IF
    CustomMessage$ = Message$

END FUNCTION

'----------------------------------------------------------------------------------------------------------------------

FUNCTION DayOfWeek$ ()

    DIM d%, m%, y%, c%
    DIM WeekDay%
    DIM Month$
    DIM Day$
    DIM DayName$
    DIM DaySuffix$

    d% = VAL(MID$(DATE$, 4, 2))
    m% = VAL(LEFT$(DATE$, 2))
    y% = VAL(RIGHT$(DATE$, 2))
    c% = VAL(MID$(DATE$, 7, 2))

    SELECT CASE m%
        CASE 1: Month$ = "January"
        CASE 2: Month$ = "February"
        CASE 3: Month$ = "March"
        CASE 4: Month$ = "April"
        CASE 5: Month$ = "May"
        CASE 6: Month$ = "June"
        CASE 7: Month$ = "July"
        CASE 8: Month$ = "August"
        CASE 9: Month$ = "September"
        CASE 10: Month$ = "October"
        CASE 11: Month$ = "November"
        CASE 12: Month$ = "December"
    END SELECT
    Day$ = STR$(d%)
    IF d% > 10 AND d% < 20 THEN
        DaySuffix$ = "th, "
    ELSE
        SELECT CASE RIGHT$(Day$, 1)
            CASE "0", "4", "5", "6", "7", "8", "9": DaySuffix$ = "th, "
            CASE "1": DaySuffix$ = "st, "
            CASE "2": DaySuffix$ = "nd, "
            CASE "3": DaySuffix$ = "rd, "
        END SELECT
    END IF
    Day$ = Day$ + DaySuffix$

    IF m% < 3 THEN m% = m% + 12: y% = y% - 1
    WeekDay% = ((c% \ 4 - (2 * c%) - 1) + ((5 * y%) \ 4) + (26 * (m% + 1) \ 10) + d%) MOD 7
    IF WeekDay% < 0 THEN WeekDay% = WeekDay% + 7
    SELECT CASE WeekDay%
        CASE 0: DayName$ = "          Sunday, "
        CASE 1: DayName$ = "          Monday, "
        CASE 2: DayName$ = "          Tuesday, "
        CASE 3: DayName$ = "          Wednesday, "
        CASE 4: DayName$ = "          Thursday, "
        CASE 5: DayName$ = "          Friday,  "
        CASE 6: DayName$ = "          Saturday, "
    END SELECT
    DayOfWeek$ = DayName$ + Month$ + Day$ + RIGHT$(DATE$, 4)

END FUNCTION

'----------------------------------------------------------------------------------------------------------------------

SUB SHOWCLOCK (Title$)

    SHARED Char()
    SHARED CharSet() AS STRING * 1

    REDIM bg(80, 30)
    DIM tm$
    DIM hr%

    COLOR 1
    LOCATE 1, 1
    PRINT Title$

    tm$ = TIME$
    hr% = VAL(LEFT$(tm$, INSTR(tm$, ":") - 1))
    IF hr% > 12 THEN hr% = hr% - 12
    tm$ = LTRIM$(STR$(hr%)) + RIGHT$(tm$, LEN(tm$) - INSTR(tm$, ":") + 1)
    IF LEN(tm$) < 8 THEN tm$ = "0" + tm$
    PRINT " "; tm$; " "

    FOR i = 0 TO 28
        FOR j = 0 TO 78
            IF POINT(j, i) > 0 THEN
                bg(j + 1, i + 1) = 40
                bg(j + 2, i + 1) = -20
                bg(j + 2, i + 2) = -20
            END IF
    NEXT j, i
    FOR i = 1 TO OBJECT
        FOR j = 1 TO TAIL - 1
            FOR k = 0 TO 2
                Char(k, i, j) = Char(k, i, j + 1)
            NEXT
            IF RND < .1 THEN Char(k, i, j) = (Char(k, i, j) + 1) MOD 53
        NEXT
        Char(1, i, TAIL) = Char(1, i, TAIL) + Char(3, i, TAIL)
        IF Char(1, i, TAIL) > 30 THEN
            Char(0, i, TAIL) = INT(RND * 80) + 1
            Char(1, i, TAIL) = 1
            Char(2, i, TAIL) = RND * 52
            Char(3, i, TAIL) = RND + .1
        END IF
        Char(2, i, TAIL) = (Char(2, i, TAIL) + 1) MOD 53
    NEXT
    FOR i = 1 TO OBJECT
        FOR j = 1 TO TAIL
            yy = Char(1, i, j)
            xx = Char(0, i, j)
            IF yy > 0 AND yy < 31 AND xx > 0 AND xx < 81 THEN
                IF j = TAIL THEN c = 35 ELSE c = INT(j / TAIL * 30)
                c = c + bg(xx, yy)
                c = 1 * -(c < 1) + c * -(c > 0)
                c = 63 * -(c > 63) + c * -(c < 64)
                COLOR c
                LOCATE yy, xx
                PRINT CharSet(Char(2, i, j));
            END IF
    NEXT j, i
    _DISPLAY

END SUB



RE: Matrix Clock by harixx (from 6-16-2010) - SMcNeill - 11-14-2023

LOL!  I love how Terry can whip out a completely different version of the code, which appears intended to do completely different things, but which as the same name, version, author, and date!

What I have looks to be an incomplete work in progress of some sort.  It appears that it was intended to allow the user to set an alarm of some type which it then was going to beep and flash a BMP image of some sort -- but it was never fully implemented:

Code: (Select All)
SUB CheckForEvent (tm$)

END SUB

Terry's code seems more complete, but doesn't have the event handling in it. Instead, it allows for a custom message to be used with it...

... which leads me to now wondering, "Just how many MATRIX v1.0 did harixx create on 6-6-2010??? And which one is the v1.0-FINAL one?" LOL!


RE: Matrix Clock by harixx (from 6-16-2010) - TerryRitchie - 11-14-2023

(11-14-2023, 12:27 AM)SMcNeill Wrote: LOL!  I love how Terry can whip out a completely different version of the code, which appears intended to do completely different things, but which as the same name, version, author, and date!

What I have looks to be an incomplete work in progress of some sort.  It appears that it was intended to allow the user to set an alarm of some type which it then was going to beep and flash a BMP image of some sort -- but it was never fully implemented:

Code: (Select All)
SUB CheckForEvent (tm$)

END SUB

Terry's code seems more complete, but doesn't have the event handling in it.  Instead, it allows for a custom message to be used with it...

... which leads me to now wondering, "Just how many MATRIX v1.0 did harixx create on 6-6-2010???  And which one is the v1.0-FINAL one?"  LOL!
Unfortunately I can't find the complete version I used in the classroom. The CheckForEvent SUB worked perfectly letting the students know when open lab started and ended, break time, and other tidbits of knowledge that would show up. There were pictures and audio queues to go along with the events too.

I searched all my NAS' but not there. I must have left the code on my teacher system which stayed at the school when I left.