Welcome, Guest
You have to register before you can post on our site.

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 416
» Latest member: MikeCook
» Forum threads: 2,446
» Forum posts: 23,766

Full Statistics

Latest Threads
Threading in QB64pe (agai...
Forum: Works in Progress
Last Post: SMcNeill
26 minutes ago
» Replies: 19
» Views: 349
3.13.1 bug report - keybo...
Forum: General Discussion
Last Post: SMcNeill
2 hours ago
» Replies: 2
» Views: 43
Extended Kotd #15.1: _UP...
Forum: Keyword of the Day!
Last Post: Dav
Today, 02:08 AM
» Replies: 5
» Views: 66
Mandelbrot (Threaded)
Forum: Programs
Last Post: justsomeguy
Yesterday, 10:19 PM
» Replies: 0
» Views: 33
tables in forums editor?
Forum: General Discussion
Last Post: SMcNeill
Yesterday, 05:41 PM
» Replies: 38
» Views: 346
Find the ball - classic s...
Forum: Games
Last Post: bplus
Yesterday, 05:37 PM
» Replies: 2
» Views: 59
MazeBall - A tilt-like ma...
Forum: Dav
Last Post: Dav
Yesterday, 11:44 AM
» Replies: 7
» Views: 117
C++ types > QB64 types: d...
Forum: General Discussion
Last Post: grymmjack
Yesterday, 03:44 AM
» Replies: 5
» Views: 75
Tutorial Home (Forum Test...
Forum: Terry Ritchie's Tutorial
Last Post: TerryRitchie
Yesterday, 03:27 AM
» Replies: 3
» Views: 62
APIs from QB64PE and para...
Forum: Help Me!
Last Post: madscijr
Yesterday, 03:26 AM
» Replies: 9
» Views: 141

 
  Help with Select Case
Posted by: PhilOfPerth - 04-24-2022, 05:26 AM - Forum: Help Me! - Replies (5)

Anyone help with a Select Case problem I have?
I want to select from text, using their ASCII codes, all the letters (A-Z and a-z) in two cases, and all other chars (spaces, punctuation etc.) in another case.
I've tried Case is >=65,<=90 (for the capitals) and Case is >=97, <=122 (for lower case) but it doesn't work - I think it sees all chars above and including A, then adds all letters below and including Z, so it grabs everything.
I think it needs an AND in there somewhere but I can't find a way.

Print this item

  Steve, your chicken got loose again!
Posted by: Pete - 04-24-2022, 03:18 AM - Forum: Programs - Replies (5)

It ended up at TheBOB's place...

Code: (Select All)
'*****************************************************
'
'------------------- EGGTIMER.BAS --------------------
'
'----- Freeware by Bob Seguin Copyright (C) 2004 -----
'
'*****************************************************
DEFINT A-Z
DECLARE SUB Interval (Length!)
DECLARE SUB SetPALETTE (OnOFF)
DECLARE SUB Lay ()

DIM SHARED Box(1 TO 1900)

SCREEN 12

SetPALETTE 0
GOSUB GetSPRITES

'Borders
LINE (100, 100)-(539, 379), 8, B
LINE (110, 110)-(529, 369), 8, B
SetPALETTE 1

COLOR 8: LOCATE 20, 34: PRINT "PRESS ANY KEY..."
a$ = INPUT$(1)
Lay
COLOR 8: LOCATE 20, 30: PRINT "PRESS ANY KEY TO EXIT..."
a$ = INPUT$(1)
SYSTEM

GetSPRITES:
'Draw sprites using compressed data
MaxWIDTH = 54
MaxDEPTH = 120
x = 0: y = 0
DO
    READ Count, Colr
    FOR Reps = 1 TO Count
        PSET (x, y), Colr
        x = x + 1
        IF x > MaxWIDTH THEN
            x = 0
            y = y + 1
        END IF
    NEXT Reps
LOOP UNTIL y > MaxDEPTH

'Get sprite images to array
GET (0, 54)-(54, 120), Box()
GET (0, 0)-(13, 14), Box(941)
GET (20, 1)-(34, 11), Box(1003)
GET (40, 0)-(53, 14), Box(1049)
GET (0, 15)-(32, 50), Box(1111)
LINE (0, 0)-(54, 120), 0, BF
PUT (290, 200), Box()
GET (280, 200)-(315, 234), Box(1500) 'Neck in
PUT (280, 200), Box(1111), PSET
PUT (280, 200), Box(1500), PSET
RETURN

DATA 1,15,1,7,3,15,1,7,5,15,29,0,1,15,1,7,3,15,1,7,3,15,1,7
DATA 5,0,7,15,1,7,3,15,1,8,11,0,1,8,2,3,3,7,2,3,1,8,8,0
DATA 6,15,1,7,2,15,1,7,5,0,5,15,1,7,4,15,1,7,1,8,10,0,1,3
DATA 3,7,5,15,1,7,1,3,7,0,5,15,1,7,3,15,1,7,5,0,3,15,3,7
DATA 4,15,2,3,9,0,1,3,2,7,9,15,1,3,6,0,3,15,3,7,3,15,1,7
DATA 5,0,2,7,2,15,2,7,3,15,2,3,1,7,1,15,1,8,6,0,1,8,2,7
DATA 11,15,1,8,5,0,2,7,2,15,2,7,3,15,1,3,5,0,1,15,3,7,1,15
DATA 1,7,3,15,2,3,2,15,1,3,6,0,1,3,2,7,11,15,1,3,5,0,1,15
DATA 3,7,1,15,1,7,2,15,1,7,1,8,5,0,5,7,3,15,2,3,1,7,2,15
DATA 1,7,6,0,1,3,2,7,11,15,1,3,5,0,5,7,3,15,1,7,6,0,4,7
DATA 3,15,2,3,1,7,4,15,6,0,1,3,3,7,10,15,1,3,5,0,4,7,3,15
DATA 1,7,7,0,3,7,4,15,2,3,3,15,1,7,1,3,6,0,1,8,4,7,8,15
DATA 1,7,1,8,5,0,3,7,3,15,1,7,8,0,3,7,3,15,2,3,4,7,1,3
DATA 8,0,1,3,5,7,4,15,2,7,1,3,6,0,3,7,3,15,1,8,8,0,2,7
DATA 3,15,2,3,4,7,1,3,10,0,1,3,9,7,1,3,7,0,2,7,3,15,1,7
DATA 9,0,4,15,2,3,2,7,2,3,1,8,12,0,1,8,2,3,3,7,2,3,1,8
DATA 8,0,3,15,1,7,1,8,10,0,3,15,1,3,36,0,1,15,2,7,12,0,1,7
DATA 1,15,1,3,37,0,1,7,1,8,13,0,1,7,1,8,175,0,1,4,2,0,1,4
DATA 4,0,1,4,45,0,2,4,1,0,2,4,3,0,2,4,45,0,5,4,2,0,3,4
DATA 42,0,2,4,1,0,5,4,1,0,4,4,42,0,17,4,39,0,17,4,39,0,13,4
DATA 42,0,5,15,6,4,43,0,7,15,3,4,37,0,1,14,6,0,9,15,1,4,39,0
DATA 3,14,2,0,3,15,1,4,7,15,1,8,38,0,6,14,1,15,1,4,1,0,1,4
DATA 7,15,1,8,38,0,5,14,2,15,1,4,9,15,1,8,37,0,6,14,12,15,1,8
DATA 37,0,5,14,13,15,1,8,37,0,4,14,14,15,1,8,36,0,3,14,1,7,16,15
DATA 1,8,33,0,3,14,1,6,2,7,17,15,1,8,30,0,3,14,2,0,1,4,1,3
DATA 1,7,18,15,1,7,1,3,1,8,26,0,2,14,3,0,2,4,1,3,1,7,21,15
DATA 25,0,1,14,4,0,4,4,1,7,20,15,24,0,1,14,5,0,5,4,1,7,19,15
DATA 30,0,6,4,1,7,18,15,30,0,6,4,1,8,1,7,17,15,30,0,2,4,1,0
DATA 3,4,1,0,1,8,1,7,16,15,31,0,1,4,1,0,3,4,2,0,1,8,16,15
DATA 33,0,2,4,4,0,1,7,15,15,39,0,1,8,1,7,14,15,40,0,1,8,1,7
DATA 13,15,41,0,1,7,13,15,41,0,1,8,1,7,12,15,42,0,2,7,2,15,1,7
DATA 8,15,42,0,1,3,1,7,2,15,1,7,8,15,42,0,1,8,1,7,2,15,1,7
DATA 8,15,198,0,1,4,3,0,1,4,47,0,2,4,2,0,1,4,2,0,2,4,47,0
DATA 2,4,1,0,2,4,1,0,3,4,46,0,5,4,1,0,3,4,43,0,2,4,1,0
DATA 9,4,43,0,13,4,43,0,12,4,44,0,10,4,44,0,1,8,5,15,1,3,4,4
DATA 43,0,1,8,7,15,1,3,2,4,43,0,1,8,9,15,1,3,44,0,3,15,1,4
DATA 7,15,1,8,42,0,2,14,1,15,1,4,1,0,1,4,6,15,1,7,40,0,4,14
DATA 2,15,1,4,8,15,1,8,38,0,6,14,10,15,1,7,37,0,7,14,11,15,1,8
DATA 28,0,6,8,3,0,6,14,11,15,1,7,26,0,1,8,8,15,1,8,3,0,3,14
DATA 1,7,12,15,1,8,23,0,1,8,3,15,1,7,2,15,1,7,4,15,5,0,1,14
DATA 2,7,11,15,1,7,21,0,1,8,4,15,2,7,1,15,1,7,4,15,1,8,6,0
DATA 1,4,2,7,11,15,1,7,5,0,2,7,5,15,1,7,1,3,1,8,1,0,1,8
DATA 3,7,4,15,1,7,2,15,1,7,4,15,1,8,7,0,2,4,2,7,11,15,1,7
DATA 1,3,1,0,1,7,18,15,2,7,2,15,1,7,5,15,8,0,4,4,1,7,31,15
DATA 1,7,3,15,1,7,5,15,1,8,8,0,5,4,34,15,1,7,5,15,1,3,9,0
DATA 5,4,32,15,2,7,6,15,1,8,9,0,5,4,31,15,1,7,7,15,1,3,10,0
DATA 2,4,1,0,2,4,30,15,1,7,2,15,1,7,5,15,12,0,4,4,35,15,1,7
DATA 2,15,1,3,12,0,3,4,35,15,1,7,3,15,1,8,13,0,1,4,35,15,1,7
DATA 4,15,15,0,1,7,5,15,1,7,27,15,1,7,2,15,1,7,2,15,1,8,14,0
DATA 1,7,5,15,1,7,26,15,1,7,2,15,1,7,3,15,1,3,15,0,1,7,4,15
DATA 1,7,25,15,1,7,8,15,15,0,2,7,2,15,1,7,25,15,1,7,3,15,2,7
DATA 4,15,15,0,1,3,1,7,2,15,1,7,27,15,1,7,2,15,1,7,4,15,15,0
DATA 1,8,1,7,2,15,1,7,26,15,1,7,3,15,1,7,3,15,1,7,15,0,1,8
DATA 1,7,2,15,1,7,19,15,3,7,1,15,2,7,6,15,1,7,2,15,1,7,16,0
DATA 2,7,1,15,3,7,28,15,1,7,3,15,1,7,16,0,1,3,1,7,2,15,3,7
DATA 25,15,3,7,3,15,1,7,16,0,1,8,1,7,2,15,6,7,14,15,2,7,1,15
DATA 4,7,2,15,2,7,3,15,1,3,16,0,1,8,1,7,2,15,9,7,14,15,1,7
DATA 2,15,3,7,1,15,1,7,2,15,1,7,1,8,17,0,1,3,1,7,2,15,11,7
DATA 11,15,7,7,3,15,1,7,19,0,2,7,2,15,27,7,3,15,1,7,21,0,1,7
DATA 3,15,25,7,3,15,1,7,23,0,1,7,2,15,25,7,3,15,1,8,24,0,1,7
DATA 2,15,23,7,3,15,1,7,26,0,1,7,4,15,17,7,4,15,1,7,1,8,28,0
DATA 2,7,4,15,9,7,3,14,1,7,4,15,2,7,31,0,1,3,2,7,5,15,4,7
DATA 6,14,1,15,3,7,1,8,34,0,1,3,4,7,6,15,6,14,2,7,38,0,1,8
DATA 2,3,7,7,6,14,42,0,5,14,4,0,5,14,42,0,3,14,6,0,5,14,40,0
DATA 3,14,8,0,4,14,39,0,3,14,9,0,3,14,39,0,3,14,9,0,3,14,39,0
DATA 3,14,9,0,3,14,39,0,3,14,9,0,3,14,37,0,5,14,9,0,3,14,34,0
DATA 8,14,9,0,3,14,33,0,13,14,2,0,6,14,33,0,1,14,7,0,13,14,41,0
DATA 2,14,2,0,13,14,37,0,2,14,2,0,1,14,7,0,8,14,34,0,1,14,11,0
DATA 2,14,40,0,1,14,11,0,2,14,52,0,1,14,53,0,1,14,28,0

PaletteDATA:
DATA 0,0,12,0,0,42,0,42,0,45,42,42
DATA 63,0,0,42,0,42,42,21,0,56,56,52
DATA 21,21,21,21,21,63,21,63,21,21,63,63
DATA 63,21,21,63,21,63,63,40,0,63,63,63

DropDATA:
DATA 342,236,344,237,346,238,348,239
DATA 350,241,351,244,352,248,352,252

SUB Interval (Length!)

    StartTIME# = TIMER
    DO
    LOOP WHILE TIMER < StartTIME# + Length!

END SUB

SUB Lay

    FOR Reps = 1 TO 3
        PUT (280, 200), Box(1111), PSET
        PLAY "MBT255O1L64cde"
        Interval .1
        PUT (280, 200), Box(1500), PSET
        Interval .1
    NEXT Reps

    PUT (330, 234), Box(941), PSET
    WAIT &H3DA, 8
    PUT (330, 234), Box(1049), PSET
    WAIT &H3DA, 8

    RESTORE DropDATA
    FOR Reps = 1 TO 8
        READ x, y
        PUT (x, y), Box(1003), PSET
        WAIT &H3DA, 8
        PAINT STEP(5, 3), 0
    NEXT Reps
    PUT (x, y), Box(1003), PSET
    PLAY "MBT255L64O3a"
    Interval .4
    PUT (280, 200), Box(1111), PSET
    PLAY "MBT255O1L64cde"
    Interval .1
    PUT (280, 200), Box(1500), PSET
    Interval .5

END SUB

SUB SetPALETTE (OnOFF)

    SELECT CASE OnOFF
        CASE 0
            OUT &H3C8, 0
            FOR n = 1 TO 48
                OUT &H3C9, 0
            NEXT n
        CASE 1
            RESTORE PaletteDATA
            OUT &H3C8, 0
            FOR n = 1 TO 48
                READ Intensity
                OUT &H3C9, Intensity
            NEXT n
    END SELECT

END SUB


Pete

Print this item

  Pentacle Flux Capaciter Mod 2: Dancing Man
Posted by: bplus - 04-23-2022, 11:01 PM - Forum: Programs - Replies (4)

Code: (Select All)
'Pentacle Flux Capacitor 2.bas for QB64 fork 2017-08-23
'translated from: Pentacle Flux Capacitor 2.txt for JB (B+=MGA) 2017-08-23
' updated 2019-09-05 with cleaner more random blackouts, er..., ah, drama!

Randomize Timer
Const xmax = 800
Const ymax = 600
Screen _NewImage(xmax, ymax, 32)
_Title "Pentacle Flux Capacitor #2: Dancing Man"

Common Shared xc, yc, dist, tp(), tp2()
xc = xmax / 2
yc = ymax / 2 + 20
Dim tp(4, 1), tp2(4, 1)
blackout& = _NewImage(xmax, ymax, 32)
_Dest blackout&
Line (0, 0)-(xmax, ymax), &H99000000, BF
PFC& = _NewImage(xmax, ymax, 32)
_Dest PFC&
drawPFC
_Dest 0
While 1
    _PutImage , PFC&, 0
    _Display
    _PutImage , blackout&, 0
    _Display
    _Delay Rnd * 80 / 1000
    Lightning xc, yc - 90, xc, yc + 10, 135
    For i = 0 To 4
        xe = tp2(i, 0)
        ye = tp2(i, 1)
        d = rand(.1 * dist, .7 * dist)
        Select Case i
            Case 0
                Lightning xc, yc - 90, xe, ye, d
                Lightning xc, yc - 90, xe, ye, d
            Case 1, 4
                Lightning xc, yc - 70, xe, ye, d
            Case 2, 3
                Lightning xc, yc + 10, xe, ye, d
        End Select
    Next
    _Display
    _Delay Rnd * 40 / 1000 + 20 / 1000
Wend


Sub drawPFC
    '3 main points for array tp()
    pRadius = 40: cRadius = 1.5 * pRadius
    a3 = _Pi(2 / 5): r = ymax / 2 - cRadius
    ao = _Pi(-1 / 2): a = ao
    For rr = r To 0 Step -10
        midInk 255, 255, 255, 0, 0, 128, rr / r
        CircleFill xc, yc, rr
    Next
    For i = 0 To 4
        tp(i, 0) = xc + r * Cos(a)
        tp(i, 1) = yc + r * Sin(a)
        For rr = cRadius To pRadius Step -1
            Color _RGB((rr - pRadius) / (cRadius - pRadius) * 255 * (cRadius - rr + pRadius) / cRadius, 0, 0)
            xx = tp(i, 0): yy = tp(i, 1)
            CircleFill xx, yy, rr
        Next
        a = a + a3
    Next
    xx = tp(0, 0): yy = tp(0, 1)
    dist = distance##(xx, yy, xc, yc)
    For pnt = 0 To 4
        For dis = 0 To .5 * dist Step 10
            dGray = 255 * dis / dist
            xx = tp(pnt, 0): yy = tp(pnt, 1)
            midpoint xx, yy, xc, yc, dis / dist, midx, midy
            For r = pRadius * (dist - dis) / dist To 0 Step -1
                midInk dGray, dGray, dGray, 255, 255, 255, (pRadius - r) / pRadius
                CircleFill midx, midy, r
            Next
        Next
        tp2(pnt, 0) = midx
        tp2(pnt, 1) = midy
    Next
End Sub


Sub Lightning (x1, y1, x2, y2, d)
    If d < 5 Then
        Color _RGB(225, 225, 245)
        Line (x1, y1)-(x2, y2)
    Else
        mx = (x2 + x1) / 2
        my = (y2 + y1) / 2
        mx = mx + -.5 * Rnd * d * .4 * rand&&(-2, 2)
        my = my + -.5 * Rnd * d * .4 * rand&&(-2, 2)
        Lightning x1, y1, mx, my, d / 2
        Lightning x2, y2, mx, my, d / 2
    End If
End Sub

'Steve McNeil's
Sub CircleFill (CX As Long, CY As Long, R As Long)
    Dim Radius As Long, RadiusError As Long
    Dim X As Long, Y As Long

    Radius = Abs(R)
    RadiusError = -Radius
    X = Radius
    Y = 0

    If Radius = 0 Then PSet (CX, CY): Exit Sub

    ' Draw the middle span here so we don't draw it twice in the main loop,
    ' which would be a problem with blending turned on.
    Line (CX - X, CY)-(CX + X, CY), , BF

    While X > Y
        RadiusError = RadiusError + Y * 2 + 1
        If RadiusError >= 0 Then
            If X <> Y + 1 Then
                Line (CX - Y, CY - X)-(CX + Y, CY - X), , BF
                Line (CX - Y, CY + X)-(CX + Y, CY + X), , BF
            End If
            X = X - 1
            RadiusError = RadiusError - X * 2
        End If
        Y = Y + 1
        Line (CX - X, CY - Y)-(CX + X, CY - Y), , BF
        Line (CX - X, CY + Y)-(CX + X, CY + Y), , BF
    Wend
End Sub

Sub midpoint (x1, y1, x2, y2, fraction, midx, midy)
    midx = (x2 - x1) * fraction + x1
    midy = (y2 - y1) * fraction + y1
End Sub

Sub midInk (r1, g1, b1, r2, g2, b2, fr)
    Color _RGB(r1 + (r2 - r1) * fr, g1 + (g2 - g1) * fr, b1 + (b2 - b1) * fr)
End Sub

Function distance## (x1##, y1##, x2##, y2##)
    distance## = ((x1## - x2##) ^ 2 + (y1## - y2##) ^ 2) ^ .5
End Function

Function rand&& (lo&&, hi&&)
    rand&& = Int(Rnd * (hi&& - lo&& + 1)) + lo&&
End Function

Print this item

  QB64-lite
Posted by: Keybone - 04-23-2022, 10:57 PM - Forum: Works in Progress - Replies (16)

QB64-lite:

For the past 7-8 hours or so I have been working at creating a minimal version of qb64.
I can't even count how many recompiles ive done. It recompiles itself, so it works.

45644 lines of code (down from 52662).

It only works on linux. no mac or windows support.
it has no debug, or wiki, or help system.
it has none of the built in tools.

it may still have traces left of those things but they will be deleted.

this is all one big .bas file. put it in your qb64/sources folder along side qb64.bas, and compile.
It might be a little faster since there is less in it, i cant back that up though.

Well enjoy. and give me feedback!  Smile



Attached Files
.bas   qb64o2.bas (Size: 1.82 MB / Downloads: 72)
Print this item

  Pipes Puzzle - Maze connect game
Posted by: Dav - 04-23-2022, 10:35 PM - Forum: Dav - Replies (7)

PIPES PUZZLE is a maze connect game.  Click on the pipes to rotate & connect them all and to make the water flow.  The top left pipe is where the water starts, so go from there.  When the board is all connected then the level is complete.  Complete all levels to win the game.

- Dav


.zip   PipesPuzzle-v1.0.zip (Size: 105.76 KB / Downloads: 67)

   

Print this item

  Pipes Puzzle - Maze connect game
Posted by: Dav - 04-23-2022, 10:35 PM - Forum: Games - Replies (7)

PIPES PUZZLE is a maze connect game.  Click on the pipes to rotate & connect them all and to make the water flow.  The top left pipe is where the water starts, so go from there.  When the board is all connected then the level is complete.  Complete all levels to win the game.

- Dav


.zip   PipesPuzzle-v1.0.zip (Size: 105.76 KB / Downloads: 97)

   

Print this item

  Vote on the default theme!
Posted by: admin - 04-23-2022, 10:25 PM - Forum: General Discussion - Replies (29)

Down at the bottom right corner of a page, you'll see a little box and a GO button.  Those are all the themes available for the forums here, and are all I ever plan to have for the forums here.  There's plenty for folks to choose from to choose one that suits them best.  The question is:  Which one does everyone like best?  Let me know in the poll, and I'll set the most popular as the default, while everyone else can set their personal theme to whatever they like the most.

Print this item

  XE - Simple file viewer & editor
Posted by: Dav - 04-23-2022, 09:59 PM - Forum: Dav - Replies (9)

XE is a simple Binary File Editor (also called a HEX editor) that lets you view and edit raw data bytes of a file.  With XE you can peek inside EXE/DLL files and see what information they may contain.  XE also has the capacity to change bytes by either typing in ASCII characters or entering the HEX value for each byte.  XE was first coded in Qbasic - now in QB64PE.   Since the very nature of XE is to alter file data you should always use EXTREME caution when editing a file - AND ALWAYS MAKE A BACKUP FIRST!

This code will work in Windows & Linux.

- Dav

Code: (Select All)
'============
'XE.BAS v1.15
'============
'A simple File editor/viewer.
'Coded by Dav, MAY/2024 with QB64-PE v3.13.0
'
' * ADDED: Now starts with CHDIR _STARTDIR$ so program looks for file in
'          directory program was started from.  This is needed in certain
'          situations, like when running XE in the system path and calling
'          it from any directory.  This way it will find the filename in
'          the directory you called it from without have to provide the
'          complete path with the filename.  Otherwise it would only look
'          in the system directory and say file not found.
'
' * ADDED: Made it more friendly by using dialog boxes for information.
'
' * ADDED: New info message appears when starting XE with no filename.
'
' * ADDED: Press L to load a new file. Added L to Menu.
'
' * FIXED: Changed menu options: B goes to Byte #, H goes to Hex #.
'
' * FIXED: Now always shows full path + filename in TITLE area.
'
'==========================================================================
'* * * *          USE THIS PROGRAM AT YOUR OWN RISK ONLY!!          * * * *
'==========================================================================
'
'
' ABOUT:
' ~~~~~
'
' XE is a simple Binary File Editor (also called a HEX editor) that lets
' you view and edit raw data bytes of a file.  With XE you can peek inside
' EXE/DLL files and see what information they may contain.  XE also has the
' capacity to change bytes by either typing in ASCII characters or entering
' the HEX value for each byte.  XE was first coded in Qbasic - now in QB64.
'
' Since the very nature of XE is to alter file data you should always use
' EXTREME caution when editing any file - AND ALWAYS MAKE A BACKUP FIRST!
'
'==========================================================================
'
' HOW TO USE:
' ~~~~~~~~~~
'
' XE accepts command line arguments.  You can drag/drop a file onto XE.
' If you don't specify a filename on startup, XE will ask you for one.
'
' There are TWO ways to View & Edit files - in HEX (default) or ASCII mode.
'
' Files are first opened in HEX mode displaying 2 windows of data.  The
' right window shows the characters while the larger left window shows HEX
' values for them. HEX mode is best for patching and is the only way to
' edit the HEX values of bytes.
'
'
' Pressing ENTER switches to ASCII (non-HEX) mode, showing a larger page
' of raw data bytes - the ASCII chracter data only.  This mode is best for
' skimming through files faster.  ENTER toggles view modes back and forth.
'
' While viewing a file you can browse through the file using the ARROWS,
' PAGEUP/DOWN, HOME and the END keys.
'
' The currently opened filename is shown with full path in the title bar.
' and just filename is displayed in the FILE: area just below title bar.
'
' While viewing a file, press E to enter into EDIT mode and begin editing
' bytes at the current position. If you're in HEX mode (2 windows), you can
' edit bytes either by typing characters on the right side or entering HEX
' values on the left window.  Press TAB to switch windows to edit in.
' Press ESC to save or disgard changes and to exit editing mode.
'
' Press M for a complete MENU listing all of the Key COMMANDS.
'
'==========================================================================
'
' COMMAND:
' ~~~~~~~~
'
'         E  =  Enters EDIT MODE. Only the displayed bytes can be edited.
'
'       TAB  =  Switchs panes (the cursor) while editing in HEX mode.
'
'         S  =  Searches file for a string starting at the current byte.
'               A Match-Case option is available.  A high beep alerts you
'               when match is found. A Low beep sounds when EOF reached.
'
'         N  =  Finds NEXT Match after a do a string search.
'
'         F  =  Toggles FILTERING of all non-standard-text characters.
'               A flashing "F" is at the top-left corner when FILTER ON.
'
'         G  =  GOTO a certain byte position (number) in the file.
'
'         L  =  GOTO a specified location (Hex value) of the file.
'
'     ENTER  =  Toggles HEX and ASCII view modes.  The ASCII mode lets
'               you browse more data per page.  You can EDIT in both
'               modes but can only enter in HEX vaules in HEX mode.
'
'       ESC  =  EXITS out of editing mode, and also EXITS the program.
'
' ALT+ENTER  =  Toggle FULLSCREEN/WINDOWED mode of the XE program.
'
'==========================================================================
'==========================================================================


'==========================================================================
'HIDE SCREEN, INIT...
'====================

_ScreenMove _Middle: _ScreenHide

ChDir _StartDir$ 'do this so program looks for file in directory called from.

_ControlChr Off 'Printing all 255 characters on screen, so this is needed.

Screen Pete: Width 80, 25 'Use Screen mode 0, aka the Pete (Come back Pete!)

'Font size based on desktop resolution - it expands SCREEN 0 nicely.
'You may have to adjust it a bit to look the best on your screen res
BIGFONT (Int(_DesktopHeight / 25) * .85)

_Delay .25

'==========================================================================
'LOAD FILE
'=========

'if none given from command line....
If Command$ = "" Then

    cr$ = Chr$(13)
    m$ = "XE v1.15 - Simple Binary file editor." + cr$ + cr$
    m$ = m$ + "This program can view/edit bytes in files." + cr$
    m$ = m$ + "Make backups of files before you edit them." + cr$ + cr$
    m$ = m$ + "XE will now ask you for filename to open." + cr$ + cr$
    m$ = m$ + "Proceed?"

    If _MessageBox("XE v1.15", m$, "yesno", "question") = 0 Then System

    File$ = _OpenFileDialog$("XE v1.15: Select File for XE to Open...", , , "Files", 0)
    If File$ = "" Then
        _MessageBox "XE v1.15", "No file selected.  XE will close.", "info"
        System
    End If
Else
    File$ = Command$
    If _FileExists(File$) = 0 Then
        _MessageBox "XE v1.15", File$ + " not found!" + Chr$(13) + Chr$(13) + "XE will close.", "info"
        System
    End If
End If

File$ = LTrim$(RTrim$(File$)) 'trim off any spaces, if any...
FullFileName$ = _FullPath$(File$) 'make a copy For TITLE/OPEN to use...

'If filename+path too long for display, strip off path
If Len(File$) > 70 Then
    ts$ = ""
    For q = Len(File$) To 1 Step -1
        t$ = Mid$(File$, q, 1)
        If t$ = "/" Or t$ = "\" Then Exit For
        ts$ = t$ + ts$
    Next
    File$ = ts$
    'If filename too long, shorten it for display
    If Len(File$) > 70 Then
        File$ = Mid$(File$, 1, 67) + "..."
    End If
End If

_ScreenShow ' finally turn on main screen


'==========================================================================
OpenFile: 'open the file
'======================================

_Title "XE: " + FullFileName$

Open FullFileName$ For Binary As 7

DisplayView% = 1 'Default to 2-PANE view

ByteLocation& = 1
If DisplayView% = 1 Then
    BufferSize% = (16 * 23)
Else
    BufferSize% = (79 * 23)
End If
If BufferSize% > LOF(7) Then BufferSize% = LOF(7)


'==========================================================================
'DISPLAY FILE
'============

Color 15, 1: Cls: Locate 1, 1, 0

Do
    Seek #7, ByteLocation&

    PageOfData$ = Input$(BufferSize%, 7)

    'If dual pane mode....
    If DisplayView% = 1 Then
        If Len(PageOfData$) < (16 * 23) Then
            PageFlag% = 1: PageLimit% = Len(PageOfData$)
            PageOfData$ = PageOfData$ + String$(16 * 23 - Len(PageOfData$), Chr$(0))
        End If
        'show right side
        y% = 3: x% = 63
        For c% = 1 To Len(PageOfData$)
            CurrentByte% = Asc(Mid$(PageOfData$, c%, 1))
            'show a . instead of a null (looks better to me)
            If CurrentByte% = 0 Then CurrentByte% = 46
            If Filter% = 1 Then
                Select Case CurrentByte%
                    Case 0 To 31, 123 To 255: CurrentByte% = 32
                End Select
            End If
            Locate y%, x%: Print Chr$(CurrentByte%);
            x% = x% + 1: If x% = 79 Then x% = 63: y% = y% + 1
        Next
        'show left side
        y% = 3: x% = 15
        For c% = 1 To Len(PageOfData$)
            CurrentByte% = Asc(Mid$(PageOfData$, c%, 1))
            CurrentByte$ = Hex$(CurrentByte%): If Len(CurrentByte$) = 1 Then CurrentByte$ = "0" + CurrentByte$
            Locate y%, x%: Print CurrentByte$; " ";
            x% = x% + 3: If x% >= 62 Then x% = 15: y% = y% + 1
        Next
    Else
        'One page display, Full view
        'Adjust data size used
        If Len(PageOfData$) < (79 * 23) Then 'Enough to fill screen?
            PageFlag% = 1: PageLimit% = Len(PageOfData$) 'No? Mark this and pad
            PageOfData$ = PageOfData$ + Space$(79 * 23 - Len(PageOfData$)) 'data with spaces.
        End If
        y% = 3: x% = 1 'Screen location where data begins displaying
        For c% = 1 To Len(PageOfData$) 'Show all the bytes.
            CurrentByte% = Asc(Mid$(PageOfData$, c%, 1)) 'Check the ASCII value.
            If Filter% = 1 Then 'If Filter is turned on,
                Select Case CurrentByte% 'changes these values to spaces
                    Case 0 To 32, 123 To 255: CurrentByte% = 32
                End Select
            End If
            Locate y%, x%: Print Chr$(CurrentByte%);
            'This line calculates when to go to next row.
            x% = x% + 1: If x% = 80 Then x% = 1: y% = y% + 1
        Next
    End If

    GoSub DrawTopBar 'update viewing info at top

    'Get user input
    Do

        Do Until L$ <> "": L$ = InKey$: Loop
        K$ = L$: L$ = ""

        GoSub DrawTopBar
        Select Case UCase$(K$)
            Case Chr$(27): Exit Do
            Case "M": GoSub Menu:
            Case "N"
                If s$ <> "" Then
                    GoSub Search
                    GoSub DrawTopBar
                End If
            Case "E"
                If DisplayView% = 1 Then
                    GoSub EditRightSide
                Else
                    GoSub EditFullView
                End If
                GoSub DrawTopBar
            Case "F"
                If Filter% = 0 Then Filter% = 1 Else Filter% = 0
            Case "B"
                Locate 1, 1: Print String$(80 * 3, 32);
                Locate 1, 3: Print "TOTAL BYTES>"; LOF(7)
                Input "  GOTO BYTE# > ", GotoByte$
                If GotoByte$ <> "" Then
                    TMP$ = ""
                    For m% = 1 To Len(GotoByte$)
                        G$ = Mid$(GotoByte$, m%, 1) 'to numerical vales
                        Select Case Asc(G$)
                            Case 48 To 57: TMP$ = TMP$ + G$
                        End Select
                    Next: GotoByte$ = TMP$
                    If Val(GotoByte$) < 1 Then GotoByte$ = "1"
                    If Val(GotoByte$) > LOF(7) Then GotoByte$ = Str$(LOF(7))
                    If GotoByte$ <> "" Then ByteLocation& = 0 + Val(GotoByte$)
                End If
            Case "H"
                Locate 1, 1: Print String$(80 * 3, 32);
                Locate 1, 3: 'PRINT "TOTAL BYTES>"; LOF(7)
                Input "  GOTO HEX LOCATION-> ", GotoByte$
                If GotoByte$ <> "" Then
                    GotoByte$ = "&H" + GotoByte$
                    If Val(GotoByte$) < 1 Then GotoByte$ = "1"
                    If Val(GotoByte$) > LOF(7) Then GotoByte$ = Str$(LOF(7))
                    If GotoByte$ <> "" Then ByteLocation& = 0 + Val(GotoByte$)
                End If
            Case "L"
                NewFile$ = _OpenFileDialog$("XE v1.15: Select File for XE to Open...", , , "Files", 0)
                If NewFile$ = "" Then
                    _MessageBox "XE v1.15", "No file selected.", "info"
                Else
                    Close #7
                    File$ = LTrim$(RTrim$(NewFile$)) 'trim off any spaces, if any...
                    FullFileName$ = _FullPath$(NewFile$) 'make a copy For TITLE/OPEN to use...

                    'If filename+path too long for display, strip off path
                    If Len(File$) > 70 Then
                        ts$ = ""
                        For q = Len(File$) To 1 Step -1
                            t$ = Mid$(File$, q, 1)
                            If t$ = "/" Or t$ = "\" Then Exit For
                            ts$ = t$ + ts$
                        Next
                        File$ = ts$
                        'If filename too long, shorten it for display
                        If Len(File$) > 70 Then
                            File$ = Mid$(File$, 1, 67) + "..."
                        End If
                    End If
                    GoTo OpenFile
                End If
            Case "S": s$ = ""
                Locate 1, 1: Print String$(80 * 3, 32);
                Locate 1, 3: Input "Search for> ", s$
                If s$ <> "" Then
                    Print "  CASE sensitive (Y/N)? ";
                    I$ = Input$(1): I$ = UCase$(I$)
                    If I$ = "Y" Then CaseOn% = 1 Else CaseOn% = 0
                    GoSub Search
                End If
                GoSub DrawTopBar
            Case Chr$(13)
                If DisplayView% = 1 Then
                    DisplayView% = 0
                    BufferSize% = (79 * 23)
                Else
                    DisplayView% = 1
                    BufferSize% = (16 * 23)
                End If
                GoSub DrawTopBar
            Case Chr$(0) + Chr$(72)
                If DisplayView% = 1 Then
                    If ByteLocation& > 15 Then ByteLocation& = ByteLocation& - 16
                Else
                    If ByteLocation& > 78 Then ByteLocation& = ByteLocation& - 79
                End If
            Case Chr$(0) + Chr$(80)
                If DisplayView% = 1 Then
                    If ByteLocation& < LOF(7) - 15 Then ByteLocation& = ByteLocation& + 16
                Else
                    If ByteLocation& < LOF(7) - 78 Then ByteLocation& = ByteLocation& + 79
                End If
            Case Chr$(0) + Chr$(73): ByteLocation& = ByteLocation& - BufferSize%: If ByteLocation& < 1 Then ByteLocation& = 1
            Case Chr$(0) + Chr$(81): If ByteLocation& < LOF(7) - BufferSize% Then ByteLocation& = ByteLocation& + BufferSize%
            Case Chr$(0) + Chr$(71): ByteLocation& = 1
            Case Chr$(0) + Chr$(79): If Not EOF(7) Then ByteLocation& = LOF(7) - BufferSize%
        End Select
    Loop Until K$ <> ""
Loop Until K$ = Chr$(27)

Close 7

System

'==========================================================================
'                              GOSUB ROUTINES
'==========================================================================


'==========================================================================
Search:
'======

If Not EOF(7) Then
    Do
        B$ = Input$(BufferSize%, 7): ByteLocation& = ByteLocation& + BufferSize%
        If CaseOn% = 0 Then B$ = UCase$(B$): s$ = UCase$(s$)
        d$ = InKey$: If d$ <> "" Then Exit Do
        If InStr(1, B$, s$) Then Sound 4000, .5: Exit Do
    Loop Until InStr(1, B$, s$) Or EOF(7)
    If EOF(7) Then Sound 2000, 1: Sound 1000, 1
    ByteLocation& = ByteLocation& - Len(s$)
End If
Return


'==========================================================================
EditRightSide: 'Editing Right side info in dual pane mode
'============

Pane% = 1

x% = 63: If rightx% Then y% = CsrLin Else y% = 3
leftx% = 15

test% = Pos(0)

If test% = 15 Or test% = 16 Then x% = 63: leftx% = 15
If test% = 18 Or test% = 19 Then x% = 64: leftx% = 18
If test% = 21 Or test% = 22 Then x% = 65: leftx% = 21
If test% = 24 Or test% = 25 Then x% = 66: leftx% = 24
If test% = 27 Or test% = 28 Then x% = 67: leftx% = 27
If test% = 30 Or test% = 31 Then x% = 68: leftx% = 30
If test% = 33 Or test% = 34 Then x% = 69: leftx% = 33
If test% = 36 Or test% = 37 Then x% = 70: leftx% = 36
If test% = 39 Or test% = 40 Then x% = 71: leftx% = 39
If test% = 42 Or test% = 43 Then x% = 72: leftx% = 42
If test% = 45 Or test% = 46 Then x% = 73: leftx% = 45
If test% = 48 Or test% = 49 Then x% = 74: leftx% = 48
If test% = 51 Or test% = 52 Then x% = 75: leftx% = 51
If test% = 54 Or test% = 55 Then x% = 76: leftx% = 54
If test% = 57 Or test% = 58 Then x% = 77: leftx% = 57
If test% = 60 Or test% = 61 Then x% = 78: leftx% = 60

GoSub DrawEditBar:

Locate y%, x%, 1, 1, 30

Do
    Do
        E$ = InKey$
        If E$ <> "" Then
            Select Case E$
                Case Chr$(9)
                    If Pane% = 1 Then
                        Pane% = 2: GoTo EditLeftSide
                    Else
                        Pane% = 1: GoTo EditRightSide
                    End If
                Case Chr$(27): Exit Do
                Case Chr$(0) + Chr$(72): If y% > 3 Then y% = y% - 1
                Case Chr$(0) + Chr$(80): If y% < 25 Then y% = y% + 1
                Case Chr$(0) + Chr$(75): If x% > 63 Then x% = x% - 1: leftx% = leftx% - 3
                Case Chr$(0) + Chr$(77): If x% < 78 Then x% = x% + 1: leftx% = leftx% + 3
                Case Chr$(0) + Chr$(73), Chr$(0) + Chr$(71): y% = 3
                Case Chr$(0) + Chr$(81), Chr$(0) + Chr$(79): y% = 25
                Case Else
                    If (ByteLocation& + ((y% - 3) * 16 + x% - 1) - 62) <= LOF(7) And E$ <> Chr$(8) Then
                        changes% = 1
                        'new color for changed bytes...
                        Color 1, 15: Locate y%, x%: Print " ";
                        Locate y%, leftx%
                        CurrentByte$ = Hex$(Asc(E$)): If Len(CurrentByte$) = 1 Then CurrentByte$ = "0" + CurrentByte$
                        Print CurrentByte$;
                        Locate y%, x%: Print E$;
                        Mid$(PageOfData$, ((y% - 3) * 16 + x% * 1) - 62) = E$
                        If x% < 78 Then x% = x% + 1: leftx% = leftx% + 3 'skip space
                    End If
            End Select
        End If
    Loop Until E$ <> ""
    Locate y%, x%
Loop Until E$ = Chr$(27)

'==========================================================================
SaveChanges:
'===========

If changes% = 1 Then
    Sound 4500, .2: Color 15, 4: Locate , , 0
    Locate 10, 29: Print Chr$(201); String$(21, 205); Chr$(187);
    Locate 11, 29: Print Chr$(186); " Save Changes (Y/N)? "; Chr$(186);
    Locate 12, 29: Print Chr$(200); String$(21, 205); Chr$(188);
    N$ = Input$(1): Color 15, 1
    If UCase$(N$) = "Y" Then
        If PageFlag% = 1 Then PageOfData$ = Left$(PageOfData$, PageLimit%)
        Put #7, ByteLocation&, PageOfData$:
    End If
End If
Color 15, 1: Cls: Locate 1, 1, 0
Return


'==========================================================================
EditLeftSide: 'Editing Left side info in dual pane mode
'===========

Color 1, 7
x% = 15: 'y% = 3
rightx% = 63

test% = Pos(0)
If test% = 63 Then x% = 15: rightx% = 63
If test% = 64 Then x% = 18: rightx% = 64
If test% = 65 Then x% = 21: rightx% = 65
If test% = 66 Then x% = 24: rightx% = 66
If test% = 67 Then x% = 27: rightx% = 67
If test% = 68 Then x% = 30: rightx% = 68
If test% = 69 Then x% = 33: rightx% = 69
If test% = 70 Then x% = 36: rightx% = 70
If test% = 71 Then x% = 39: rightx% = 71
If test% = 72 Then x% = 42: rightx% = 72
If test% = 73 Then x% = 45: rightx% = 73
If test% = 74 Then x% = 48: rightx% = 74
If test% = 75 Then x% = 51: rightx% = 75
If test% = 76 Then x% = 54: rightx% = 76
If test% = 77 Then x% = 57: rightx% = 77
If test% = 78 Then x% = 60: rightx% = 78

GoSub DrawEditBar:

Locate y%, x%, 1, 1, 30

Do
    Do
        E$ = InKey$
        If E$ <> "" Then
            Select Case E$
                Case Chr$(9)
                    If Pane% = 1 Then
                        Pane% = 2: GoTo EditLeftSide
                    Else
                        Pane% = 1: GoTo EditRightSide
                    End If
                Case Chr$(27): Exit Do
                Case Chr$(0) + Chr$(72): If y% > 3 Then y% = y% - 1
                Case Chr$(0) + Chr$(80): If y% < 25 Then y% = y% + 1
                Case Chr$(0) + Chr$(75) 'right arrow....
                    If x% > 15 Then
                        Select Case x%
                            Case 17, 18, 20, 21, 23, 24, 26, 27, 29, 30, 32, 33, 35, 36, 38, 39, 41, 42, 44, 45, 47, 48, 50, 51, 53, 54, 56, 57, 59, 60, 62, 63
                                x% = x% - 2
                                rightx% = rightx% - 1
                            Case Else: x% = x% - 1
                        End Select
                    End If

                Case Chr$(0) + Chr$(77)
                    If x% < 61 Then
                        Select Case x%
                            Case 16, 17, 19, 20, 22, 23, 25, 26, 28, 29, 31, 32, 34, 35, 37, 38, 40, 41, 43, 44, 46, 47, 49, 50, 52, 53, 55, 56, 58, 59, 61, 62
                                x% = x% + 2
                                rightx% = rightx% + 1
                            Case Else: x% = x% + 1
                        End Select
                    End If

                Case Chr$(0) + Chr$(73), Chr$(0) + Chr$(71): y% = 3
                Case Chr$(0) + Chr$(81), Chr$(0) + Chr$(79): y% = 25
                Case Else
                    If (ByteLocation& + ((y% - 3) * 16 + rightx% - 1) - 62) <= LOF(7) And E$ <> Chr$(8) Then
                        Select Case UCase$(E$)
                            Case "A", "B", "C", "D", "E", "F", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"
                                E$ = UCase$(E$)
                                changes% = 1
                                Color 1, 15: Locate y%, x%: Print " ";
                                Locate y%, x%: Print E$;
                                If x% < 62 Then

                                    Select Case x%
                                        Case 16, 17, 19, 20, 22, 23, 25, 26, 28, 29, 31, 32, 34, 35, 37, 38, 40, 41, 43, 44, 46, 47, 49, 50, 52, 53, 55, 56, 58, 59, 61, 62
                                            e2$ = Chr$(Val("&H" + Chr$(Screen(y%, x% - 1)) + Chr$(Screen(y%, x%))))
                                            'reflect changes on right panel
                                            Color 1, 15: Locate y%, rightx%: Print " ";
                                            Locate y%, rightx%: Print e2$;
                                            Mid$(PageOfData$, ((y% - 3) * 16 + rightx% * 1) - 62) = e2$
                                            'dont advance cursor if at last place
                                            If x% < 61 Then
                                                rightx% = rightx% + 1
                                                x% = x% + 2
                                            End If
                                        Case Else: x% = x% + 1
                                    End Select
                                End If
                        End Select

                    End If
            End Select
        End If
    Loop Until E$ <> ""
    Locate y%, x%
Loop Until E$ = Chr$(27)

GoTo SaveChanges:


'==========================================================================
EditFullView: 'Editing file in full display mode (one pane)
'===========

Color 1, 7
x% = 1: y% = 3
changes% = 0

GoSub DrawEditBar

Locate 3, 1, 1, 1, 30

Do
    Do
        E$ = InKey$
        If E$ <> "" Then
            Select Case E$
                Case Chr$(27): Exit Do
                Case Chr$(0) + Chr$(72): If y% > 3 Then y% = y% - 1
                Case Chr$(0) + Chr$(80): If y% < 25 Then y% = y% + 1
                Case Chr$(0) + Chr$(75): If x% > 1 Then x% = x% - 1
                Case Chr$(0) + Chr$(77): If x% < 79 Then x% = x% + 1
                Case Chr$(0) + Chr$(73), Chr$(0) + Chr$(71): y% = 3
                Case Chr$(0) + Chr$(81), Chr$(0) + Chr$(79): y% = 25
                Case Else
                    If (ByteLocation& + (y% - 3) * 79 + x% - 1) <= LOF(7) And E$ <> Chr$(8) Then
                        changes% = 1
                        'new color for changed bytes
                        Color 1, 15: Locate y%, x%: Print " ";
                        Locate y%, x%: Print E$;
                        Mid$(PageOfData$, (y% - 3) * 79 + x% * 1) = E$
                        If x% < 79 Then x% = x% + 1
                    End If
            End Select
        End If
    Loop Until E$ <> ""
    GoSub DrawEditBar
    Locate y%, x%
Loop Until E$ = Chr$(27)

GoTo SaveChanges:

'==========================================================================
DrawEditBar:
'===========

If DisplayView% = 1 Then
    Locate 1, 1:
    Color 31, 4: Print "  EDIT MODE: ";
    Color 15, 4
    Print " Press TAB to switch editing sides "; Chr$(179); " Arrows move cursor "; Chr$(179); " ESC=Exit ";
Else
    Locate 1, 1
    Color 31, 4: Print " EDIT MODE ";
    Color 15, 4
    Print Chr$(179); " Arrows move cursor "; Chr$(179); " ESC=Exit "; Chr$(179);
    Locate 1, 45: Print String$(35, " ");

    Locate 1, 46
    CurrentByte& = ByteLocation& + (y% - 3) * 79 + x% - 1
    CurrentValue% = Asc(Mid$(PageOfData$, (y% - 3) * 79 + x% * 1, 1))
    If CurrentByte& > LOF(7) Then
        Print Space$(9); "PAST END OF FILE";
    Else
        Print "Byte:"; LTrim$(Str$(CurrentByte&));
        Print ", ASC:"; LTrim$(Str$(CurrentValue%));
        Print ", HEX:"; RTrim$(Hex$(CurrentValue%));
    End If
End If
Return

'==========================================================================
DrawTopBar:
'============

Color 1, 15
Locate 1, 1: Print String$(80, 32);
Locate 2, 1: Print String$(80, 32);

Locate 1, 1
If Filter% = 1 Then
    Color 30, 4: Print "F";: Color 1, 15
Else
    Print " ";
End If

Print "FILE: "; File$;

Locate 2, 2:
Print "Total Bytes:"; LOF(7);
EC& = ByteLocation& + BufferSize%: If EC& > LOF(7) Then EC& = LOF(7)
Print Chr$(179); " Viewing Bytes:"; RTrim$(Str$(ByteLocation&)); "-"; LTrim$(Str$(EC&));
Locate 1, 71: Print " M = Menu";
Color 15, 1
'Draw bar on right side of screen
For d% = 3 To 25
    Locate d%, 80: Print Chr$(176);
Next

If DisplayView% = 1 Then
    'Draw lines down screen
    For d% = 3 To 25
        Locate d%, 79: Print Chr$(179);
        Locate d%, 62: Print Chr$(179);
        'add space around numbers...
        '(full screen messes it...)
        Locate d%, 13: Print " " + Chr$(179);
        Locate d%, 1: Print Chr$(179) + " ";
    Next

    'Draw location
    For d% = 3 To 25
        Locate d%, 3
        nm$ = Hex$(ByteLocation& - 32 + (d% * 16))
        If Len(nm$) = 9 Then nm$ = "0" + nm$
        If Len(nm$) = 8 Then nm$ = "00" + nm$
        If Len(nm$) = 7 Then nm$ = "000" + nm$
        If Len(nm$) = 6 Then nm$ = "0000" + nm$
        If Len(nm$) = 5 Then nm$ = "00000" + nm$
        If Len(nm$) = 4 Then nm$ = "000000" + nm$
        If Len(nm$) = 3 Then nm$ = "0000000" + nm$
        If Len(nm$) = 2 Then nm$ = "00000000" + nm$
        If Len(nm$) = 1 Then nm$ = "000000000" + nm$
        Print nm$;
    Next
End If

Marker% = CInt(ByteLocation& / LOF(7) * 22)
Locate Marker% + 3, 80: Print Chr$(178);
Return

'==========================================================================
Menu:
'========

Sound 4500, .2: Color 15, 0: Locate , , 0
Locate 5, 24: Print Chr$(201); String$(34, 205); Chr$(187);
For m = 6 To 21
    Locate m, 24: Print Chr$(186); Space$(34); Chr$(186);
Next
Locate 22, 24: Print Chr$(200); String$(34, 205); Chr$(188);

Locate 6, 26: Print "Use the arrow keys, page up/down";
Locate 7, 26: Print "and Home/End keys to navigate.";

Locate 9, 26: Print "E = Enter into file editing mode";
Locate 10, 26: Print "F = Toggles the filter ON or OFF";
Locate 11, 26: Print "B = Goto a certain Byte position";
Locate 12, 26: Print "H = Goto a certain HEX location";
Locate 13, 26: Print "S = Searches for string in file";
Locate 14, 26: Print "N = Find next match after search";
Locate 15, 26: Print "L = Load another file to display";

Locate 17, 26: Print "ENTER = Toggle HEX/ASCII modes";
Locate 18, 26: Print "TAB   = switch window (HEX mode)";
Locate 19, 26: Print "ESC   = EXITS this program";
Locate 21, 26: Print "ALT+ENTER for full screen window";
Pause$ = Input$(1)
Color 15, 1: Cls: Locate 1, 1, 0

Return


'==========================================================================
'                           FUNCTIONS/SUBS
'==========================================================================


Sub BIGFONT (size)
    'loads a custom size CP437 font (like QB64's built-in one)'
    'You can make/use any size now.
    A$ = ""
    A$ = A$ + "haIgm]0MLEMMXkS^ST\\T]lHiaboe<Nl8c71HYa3f0VPiWa9H07n5a_0bn:K"
    A$ = A$ + ";#FB8;c773hBD8T42E_#C:=QBC39PSQB=DB2UhdhVBB^9=_D2EQ#Ala?JFmi"
    A$ = A$ + "ejeGKNiYTV4\UNkOWcmL791Y0Iefg<NdmNWiLfWmIoO_?WkeP10H6`NP0HS["
    A$ = A$ + "KMGj5l9Nf7lH0HC;3of5MAGb9ef>>V6V60Vfa[_^=_m>j[Y]NOC7PDY`?kKc"
    A$ = A$ + "gd0IQB1o20VfnaO?eFkH7m=nh8TP=]8ljY]e^_e]DhRj<;0CoG1`5>lfj\S`"
    A$ = A$ + "IOn5Z6o]G6oLbK3oRZONcW6QoL`[Gfffn0gBQ5]P_=NmC3#5__^kMcMlg=[o"
    A$ = A$ + "a=RPjY`[?W]ga]dWICVEPonZafW]W>fNWObWOGk3P[h7POg7[_Nga07oM<8f"
    A$ = A$ + "f[2agZnF0=g`?kjkmmOT[]nel;PVZJ]hg0?OKcLadaGiKoLOB06[_P\Y8lOJ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 + "?^>iH[jhgZ>^]ZSK[jhfZ>^]ZSK[jhfZ>^]ZSK[jhfZ>^]ZSK[jhfZ>oJE7o"
    A$ = A$ + "FeaOEjacDaScZ]:?_>fnfkXb;MKM>#7EN9M]e]gA`6gFGl_Fl<?U:kXknfF7"
    A$ = A$ + "E6fIg3dAeMfg>jZkNkYbM`]JP>fI#OK[[JjlFfLgM\m`=e=eWf`AXZnjL78`"
    A$ = A$ + "ZYSnk_gK^k>gb0EcW]cnV>O\o^fjf6#na`N_iNTcfD_3\]JdV5fCM^cfd>jT"
    A$ = A$ + "1KK]N:C_gn7HKm^eNkYS^[[[N60]XdiV70=ZDKWgh>kjVjXk>kIcMFifjMWk"
    A$ = A$ + "XcIdOWgDgm^e^fL7MgC_3<MZaK]o>jNPnLW^Y1VfU\^F9aQE#WdZNb:LWDdN"
    A$ = A$ + "BKfCFYmTEK?iD\WLbfCFUmTBj9[d2Wf\M_TM8:IQLA;LJcn=]IKCKFhDbRZ["
    A$ = A$ + "dfhRFdX=g9fA_=;nDdMRmWFYM8Je=XF8gV5EGY[aF8_B;n\Bglb2iEJkN9g4"
    A$ = A$ + "d1WE:ZKm]Y^kMcg#e8_T>FYLEgKA>fo0je3\S]eAHWEbo]j`KP?FcFjZk^k<"
    A$ = A$ + "LCmN;CG>[OTSGm0mgE7KMWm97kG_>\7iHgKYZ=gEoK^k>[Y[N^Y=]C\C3#WY"
    A$ = A$ + "Og>fNGXlH7K^CD0jVLG4\SMfCEKYc]SR#YXoDi>j37lDK^kM^Y:gFWMP3AHG"
    A$ = A$ + "M\mNk9\f]_cMX2EM>C_cAIOa=ehScNbHoGSl3nVg6Mdooo4noEAM%%h1"
    btemp$ = ""
    For i& = 1 To Len(A$) Step 4: B$ = Mid$(A$, i&, 4)
        If InStr(1, B$, "%") Then
            For C% = 1 To Len(B$): F$ = Mid$(B$, C%, 1)
                If F$ <> "%" Then C$ = C$ + F$
            Next: B$ = C$: End If: For j = 1 To Len(B$)
            If Mid$(B$, j, 1) = "#" Then
        Mid$(B$, j) = "@": End If: Next
        For t% = Len(B$) To 1 Step -1
            B& = B& * 64 + Asc(Mid$(B$, t%)) - 48
            Next: X$ = "": For t% = 1 To Len(B$) - 1
            X$ = X$ + Chr$(B& And 255): B& = B& \ 256
    Next: btemp$ = btemp$ + X$: Next
    BASFILE$ = _Inflate$(btemp$, 25152): btemp$ = ""
    _Font _LoadFont(BASFILE$, size, "memory, monospace")
End Sub

   

Print this item

  Just a silly C Pentatonic random notes player
Posted by: CharlieJV - 04-23-2022, 09:33 PM - Forum: Programs - Replies (2)

Code: (Select All)
dim c_pentatonic(0 to 4) as single
c_pentatonic(0) = 130.81
c_pentatonic(1) = 146.83
c_pentatonic(2) = 164.81
c_pentatonic(3) = 196.0
c_pentatonic(4) = 220.00
duration = 6
while inkey$ <> chr$(27)
  i = int(5 * rnd + 1) - 1
  print i,
  freq = c_pentatonic(i)
  sound freq, duration
  _delay 0.5
wend

Print this item

  Simple Joystick Detection and Interaction
Posted by: SMcNeill - 04-23-2022, 05:42 PM - Forum: SMcNeill - No Replies

A small little demo to help highlight how one would work with the joystick in QB64:

Code: (Select All)
D = _DEVICES 'Find the number of devices on someone's system
'1 is the keyboard
'2 is the mouse
'3 is the joystick
'unless someone has a strange setup with multiple mice/keyboards/ect...
'In that case, you can use _DEVICE$(i) to look for "KEYBOARD", "MOUSE", "JOYSTICK", if necessary.
'I've never actually found it necessary, but I figure it's worth mentioning, just in case...


DIM Button(_LASTBUTTON(3)) ' number of buttons on the joystick
DIM Axis(_LASTAXIS(3)) 'number of axis on the joystick

DO


    DO

        'This following little segment of code gets the joystick status for us
        'The reason this is inside a DO...LOOP structure as I've created it,
        'is so that my joystick's axis won't generate any form of lag for
        'my program as I scroll them around to generate positive/negative values.

        IF _DEVICEINPUT = 3 THEN 'this says we only care about joystick input values
            FOR i = 1 TO _LASTBUTTON(3) 'this is a loop to check all the buttons
                IF _BUTTONCHANGE(i) THEN Button(i) = NOT Button(i) 'and this changes my button array to indicate if a button is up or down currently.
            NEXT
            FOR i = 1 TO _LASTAXIS(3) 'this loop checks all my axis
                'I like to give a little "jiggle" resistance to my controls, as I have an old joystick
                'which is prone to always give minute values and never really center on true 0.
                'A value of 1 means my axis is pushed fully in one direction.
                'A value greater than 0.1 means it's been partially pushed in a direction (such as at a 45 degree diagional angle).
                'A value of less than 0.1 means we count it as being centered. (As if it was 0.)
                IF ABS(_AXIS(i)) <= 1 AND ABS(_AXIS(i)) >= .1 THEN Axis(i) = _AXIS(i) ELSE Axis(i) = 0
            NEXT
        ELSE EXIT DO
        END IF
    LOOP

    'And below here is just the simple display routine which displays our values.
    'If this was for a game, I'd choose something like Axis(1) = -1 for a left arrow style input,
    'Axis(1) = 1 for a right arrow style input, rather than just using _KEYHIT or INKEY$.


    CLS
    FOR i = 1 TO _LASTBUTTON(3) 'A loop for each button
        PRINT "BUTTON "; i; ": "; Button(i) 'display their status to the screen
    NEXT
    FOR i = 1 TO _LASTAXIS(3) 'A loop for each axis
        PRINT "Axis "; i; ": "; Axis(i) 'display their status to the screen
    NEXT

    _LIMIT 30
LOOP UNTIL _KEYHIT = 27 'ESCAPE to quit

SYSTEM 'And that's all it is to it!

Print this item