Fun with hardware acceleration.
#1
One nice effect is you can have 2 font sizes/styles in the same program. Here is a flow-through example with a large and small lucon font.

Code: (Select All)
$COLOR:32
DIM SHARED overlay, ii
f1 = 22 ' Sets font size to 22 and calculates the max screen height and width for your desktop.
h = (_DESKTOPHEIGHT - 60) \ f1
w = _DESKTOPWIDTH \ (f1 / 1.66)
WIDTH w, h
_SCREENMOVE 0, 0
fontpath$ = ENVIRON$("SYSTEMROOT") + "\fonts\lucon.ttf" 'Find Windows Folder Path.
font& = _LOADFONT(fontpath$, f1 - 2, "monospace") ' - 2 to shorten the screen height just a bit.
_FONT font&
_DELAY .25
swtch = 1

DO
    _LIMIT 30
    SELECT CASE swtch
        CASE 1
            CALL prog1
            IF INKEY$ = CHR$(27) THEN SYSTEM
        CASE -1
            CALL prog2
    END SELECT

    swtch = swtch * -1
LOOP

SUB prog1
    ii = ii + 1
    IF i > 300 THEN END ' Safety in case of memory leak.
    IF ABS(TIMER - z1) > .5 THEN LOCATE 2, 2: PRINT LTRIM$(STR$(ii)); "  ";
END SUB

SUB prog2
    STATIC target$, z2, bxx!
    hardware_top = 34
    bxy! = hardware_top

    overlay = _NEWIMAGE(_WIDTH * _FONTWIDTH, _HEIGHT * _FONTHEIGHT, 32)

    _DEST overlay

    font& = _LOADFONT("lucon.ttf", 12, "monospace")
    _FONT font&

    SELECT CASE target$
        CASE ""
            bxx! = RND * 80 + 5
            target$ = "on"
            z2 = TIMER
        CASE "on"
            COLOR Yellow, 0
            t$ = " " + CHR$(218) + STRING$(11, CHR$(196)) + CHR$(191) + " "
            PSL bxy!, bxx! - 1, t$
            FOR i = 1 TO 2
                t$ = " " + CHR$(179) + STRING$(11, CHR$(32)) + CHR$(179) + " "
                PSL bxy! + i, bxx! - 1, t$
            NEXT
            t$ = " " + CHR$(192) + STRING$(11, CHR$(196)) + CHR$(217) + " "
            PSL bxy! + i, bxx! - 1, t$
            t$ = LTRIM$(STR$(ii))
            PSL bxy! + 1.5, bxx! + 7.5 - LEN(LTRIM$(STR$(ii))) \ 2 - 1, t$
            IF ABS(z2 - TIMER) > 4 THEN
                z2 = TIMER
                target$ = "wait"
            ELSE
            END IF
        CASE "wait"
            IF ABS(z2 - TIMER) > 2 THEN
                z2 = TIMER
                target$ = ""
            END IF
    END SELECT

    _DISPLAY
    _FREEIMAGE overlay
    _DEST 0
END SUB

SUB PSL (y!, x, t$)
    _PRINTSTRING ((x - 1) * _FONTWIDTH, (y! - 1) * _FONTHEIGHT), t$
    Overlay_Hardware = _COPYIMAGE(overlay, 33)
    _PUTIMAGE (0, 0), Overlay_Hardware
    _FREEIMAGE Overlay_Hardware
END SUB

It's more fun and versatile than the old way of using PCOPY, because the screen properties like font size can be separated.

Pete
Reply




Users browsing this thread: 1 Guest(s)