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

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 308
» Latest member: Donaldvem
» Forum threads: 1,741
» Forum posts: 17,901

Full Statistics

Latest Threads
The QB64 IDE shell
Forum: Utilities
Last Post: JasonPag
09-16-2024, 05:37 PM
» Replies: 9
» Views: 762
Importance regarding Ches...
Forum: Utilities
Last Post: JasonPag
09-01-2024, 06:34 PM
» Replies: 0
» Views: 31
Chess and Analysis and En...
Forum: Utilities
Last Post: JasonPag
08-28-2024, 02:37 PM
» Replies: 0
» Views: 32
DAY 009:_PutImage
Forum: Keyword of the Day!
Last Post: grymmjack
09-02-2023, 02:57 PM
» Replies: 54
» Views: 2,034
Fall Banner Contest?
Forum: Site Suggestions
Last Post: grymmjack
08-31-2023, 11:50 PM
» Replies: 36
» Views: 1,261
ColorPicker - Function th...
Forum: Dav
Last Post: Dav
08-31-2023, 11:04 PM
» Replies: 3
» Views: 315
Goals(1) = New Tile()
Forum: Works in Progress
Last Post: RhoSigma
08-31-2023, 09:45 PM
» Replies: 3
» Views: 127
micro(A)v11
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:14 PM
» Replies: 90
» Views: 3,589
Updating The Single Most ...
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:13 PM
» Replies: 7
» Views: 254
QBJS Image Question
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 05:49 PM
» Replies: 5
» Views: 155

 
  How can I change editor font size in Linux
Posted by: bigriverguy - 06-22-2022, 04:49 PM - Forum: General Discussion - Replies (1)

The font size dialog is very Windows oriented.  It even fills in the path to the font as a Windows path.

Print this item

Question QB Phoenix Edition name?
Posted by: Fifi - 06-19-2022, 01:11 PM - Forum: Announcements - Replies (30)

Hello all.

You are doing an amazing and fabulous job bringing new life to QB64 by editing QB64 Phoenix Edition.

But just a suggestion/question: why continue to call it QB64 when simply QBPE would seem more appropriate and accurate to me?

Moreover, as I’ve read all the threads that talk about the various misadventures of the end of the QB64 project as such, calling this new fork by its new name including the name of its executable would:

  • on the one hand avoid any new potential conflict with the alleged ‘’CEO’’,
  • and on the other hand would also allow QBPE and QB64 to coexist on the same machine.

Moreover, this would avoid any possible future confusion for the users.

On my Linux boxes I did a test by changing only one line (line #90 EXE ?= qbpe) in the makefile and the two coexist very well, each in its own directory.

What do you think?

Cheers.
Fifi

Print this item

  code to generate wav files specifying waveform, pitch, ADSR, etc.?
Posted by: madscijr - 06-18-2022, 06:35 PM - Forum: General Discussion - Replies (5)

Does anyone have any QB64 / QuickBasic / QBasic code to generate a WAV file, specifying various sound synthesis parameters like waveform (sine, triangle, square, sawtooth, white noise, etc.), ADSR (attack / decay / sustain / release), as well as pitch/frequency and volume, (bonus would be generating a stereo sound file, controlling the pan position), and then play back 2 or more of the sound files simultaneously? 

Also it would be useful to append one WAV file to the end of another. 

This would be useful for sound effects for games as well as music applications. 

I've found the WAV file specification (still digesting) but it is a little daunting!

http://www.topherlee.com/software/pcm-tu...ormat.html
 
https://docs.fileformat.com/audio/wav/
 
https://m.youtube.com/watch?v=udbA7u1zYfc
 
https://www.videoproc.com/resource/wav-file.htm
 
https://www.fastmetrics.com/support/wav-file/amp/
 
http://www.thescarms.com/vbasic/tone.aspx
 
https://www.vbforums.com/showthread.php?...e-wav-file
 
https://www.vbforums.com/showthread.php?...a-wav-file
 
https://docs.microsoft.com/en-us/previou...0(v=vs.85)
 
https://www.vbforums.com/showthread.php?...a-wav-file
 
https://forums.codeguru.com/showthread.p...g-wav-file
 
https://forums.codeguru.com/showthread.p...-WAV-Files
 
https://rochars.github.io/wavefile/
 
https://gist.github.com/asanoboy/3979747
 
https://morioh.com/p/bced3b76866e
 
https://codereview.stackexchange.com/que...script-es6
 
https://blog.logrocket.com/audio-visuali...avascript/
 
https://www.tutorialspoint.com/read-and-...thon-wave#
 
https://ourcodeworld.com/articles/read/1...javascript
 
https://learningsolutionsmag.com/article...er-s-guide
 
https://onestepcode.com/modifying-wav-files-c/
 
https://codingdiksha.com/build-a-wav-fil...avascript/

Print this item

  text drawing
Posted by: James D Jarvis - 06-18-2022, 04:03 PM - Forum: Programs - Replies (2)

This simple little demo shows how to take advantage of qb64 to implement "mixed mode graphics" in an otherwise text mode program.   It uses a tiny graphics buffer to print pixels as characters in regular text mode. 
There is also a means provided to use any graphics commands you wish and output that as regular text.
No silly trek animation this time, this is serious stuff.  ;-)

Code: (Select All)
'text draw
'mixed mode screen 0
'"draw" with ascii characters in screen mode 0
'
Dim Shared dspace& 'this is the drawing space/canvas that allows mixed mode graphics routines to function
Randomize Timer
Screen 0
Dim Shared stwd, stht 'screen text width , screen text height
stwd = 80: stht = 50 'you can change these to the other appropriate sizes the demo wouldn't display the same however
Width stwd, stht
dspace& = _NewImage(stwd + 1, stht + 1, 256) 'this is tiny keep that in mind when writign to it directly
Color 4, 3
Tdraw "rect 1,1,80,3", "@"
Color 15, 0
Locate 2, 2: Print "Text Draw"
Locate 5, 2: Print "This is a text screen set to a width of 80 and height of 50"
Locate 7, 2: Print " Tdraw is a sub that allows you to do mixed-mode graphics."
Locate 9, 2: Print "Here's a circle (limited by text size of course)"
Tdraw "circle 40,25,10", "*"
Color 18, 0
Locate 40, 2: Print "Press any key to continue"
Do
    _Limit 60
    A$ = InKey$
Loop Until A$ <> ""
A$ = ""
Color 15, 0
Locate 9, 2: Print "Redrew the circle with a new character and color attributes"
Color 21, 2
Tdraw "circle 40,25,10", "."
Color 18, 0
Locate 40, 2: Print "Press any key to continue"
Do
    _Limit 60
    A$ = InKey$
Loop Until A$ <> ""
A$ = ""
Cls
Color 7, 2
Tdraw "rect 1,1,80,3", "@"
Color 15, 0
Locate 2, 2: Print "Text Draw"
Locate 5, 2: Print "This is a text screen set to a width of 80 and height of 50"
Locate 7, 2: Print " Tdraw is a sub that allows you to do mixed-mode graphics."
Locate 9, 2: Print "Here's a Rectangle"
Color 15, 0
Tdraw "rect 11,11,40,30", Chr$(178)
Color 18, 0
Locate 40, 2: Print "Press any key to continue"
Do
    _Limit 60
    A$ = InKey$
Loop Until A$ <> ""
A$ = ""
Color 15, 0
Locate 9, 2: Print "We just filled it."
Color 8, 0
Tdraw "fbox 12,12,39,29", Chr$(178)
Color 15, 0
Locate 9, 2: Print "Now a line of '+' was added "
Color 5, 0
Tdraw "line 12,12,39,29", "+"
Do
    _Limit 60
    A$ = InKey$
Loop Until A$ <> ""
A$ = ""
Cls
Color 27, 0
Tdraw "rect 1,1,80,3", "@"
Color 15, 0
Locate 2, 2: Print "Text Draw"
Locate 5, 2: Print "This is a text screen set to a width of 80 and height of 50"
Locate 7, 2: Print " Tdraw is a sub that allows you to do mixed-mode graphics."
Locate 9, 2: Print "the standard Draw command can be used."
Color 15, 0
Locate 1, 25
Tdraw "draw bm1,25r3u5r3d5r3u5r3d5r3u5r3d5r3u5r3d5r3u5r3d5r3u5r3d5r3u5r3d5r3u5r3d5r3u5r3d5r3u5r3d5r3u5r3d5r3u5r3d5r3u5r3d5r3u5r3d5", "*"
Locate 40, 1: Print "You can use any drawing command ..."
Do
    _Limit 60
    A$ = InKey$
Loop Until A$ <> ""
A$ = ""
Cls
cleardraw
'using standard graphics commands
_Dest dspace& 'don't forget to set the destination to dpace& when doing this
For dot = 1 To 1000
    PSet (Int(Rnd * 80), Int(Rnd * 50)), Int(Rnd * 32)
Next dot
_PrintMode _KeepBackground
Locate 1, 1: Print "GIANT TEXT"
_PrintMode _FillBackground
showdraw 1, 1, 80, 50, "#" 'this will scan and read the pixels dspace& and print them as the character defined
'showdraw resets the text and graphics control to the text screen
Color 15, 0
_Delay 2
For r = 1 To 20
    _Limit 5
    For x = 1 + r To 80 - r
        For y = 0 + r To 51 - r
            showdraw x, y, 80 - x, 50 - y, Chr$(33 + r)
        Next y
    Next x
Next r
Cls
_Delay 0.5
Color 4, 3
Tdraw "rect 1,1,80,3", "@"
Color 15, 0
Locate 2, 2: Print " Text Draw"
Locate 5, 2: Print "In Summary"
Locate 7, 2: Print "This is a text screen set to a width of 80 and height of 50"
Locate 9, 2: Print " Tdraw is a sub that allows you to do mixed-mode graphics."
Locate 11, 2: Print "Tdraw " + Chr$(34) + "circle 10,10,4" + Chr$(34) + "," + Chr$(34) + "#" + Chr$(34) + " 'draws a circle at 10,10 to radius 4"
Locate 13, 2: Print "Tdraw " + Chr$(34) + "line 2,2,35,10" + Chr$(34) + "," + Chr$(34) + "#" + Chr$(34) + " 'draws a line form 2,2 to 35,10"
Locate 15, 2: Print "Tdraw " + Chr$(34) + "rect 2,2,35,10" + Chr$(34) + "," + Chr$(34) + "#" + Chr$(34) + " 'draws an unfilled rectangle from 2,2 to 35,10"
Locate 17, 2: Print "Tdraw " + Chr$(34) + "fbox 2,2,35,10" + Chr$(34) + "," + Chr$(34) + "#" + Chr$(34) + " 'draws an filled rectangle from 2,2 to 35,10"
Locate 19, 2: Print "Tdraw " + Chr$(34) + "draw r4u2r4" + Chr$(34) + "," + Chr$(34) + "#" + Chr$(34) + "' allows use of the normal draw command, drawing r4u2r4  in the example here"
Locate 21, 2: Print "Tdraw " + Chr$(34) + "Pset 20,20" + Chr$(34) + "," + Chr$(34) + "*" + Chr$(34) + "'puts the character * at coordiate x,y"
Locate 23, 2: Print "To use standard graphic commands use '_dest dspace&' to draw in the graphical layer directly"
Locate 25, 2: Print "Showdraw 1,1,80,50," + Chr$(34) + "*" + Chr$(34) + "' renders dspace& to the screen for 1 to 80 by 1 to 50 using character * to show the results of writign directly to dspace&"
Locate 27, 2: Print "cleardraw               'cls in dspace& and returning graphics/text output to screen 0 in one command"


Sub Tdraw (dd$, c$)
    'let's draw that text
    'dd$ is the command c$ is the output character
    '"circle x,y,r" "rect x1,y1,x2,y2" "line x1,y1,x2,y2" "fbox x1,y1,x2,y2" "draw <string>" "pset x,y"  all valid to tdraw
    dd$ = LCase$(dd$)
    If Left$(dd$, 6) = "circle" Then

        ch = 6
        Do
            ch = ch + 1
            A$ = Mid$(dd$, ch, 1)
        Loop Until A$ = ","
        comma1 = ch - 1
        Do
            ch = ch + 1
            A$ = Mid$(dd$, ch, 1)
        Loop Until A$ = ","
        comma2 = ch - 1
        For ch = 7 To comma1
            ta1$ = ta1$ + Mid$(dd$, ch, 1)
        Next ch
        For ch = comma1 + 2 To comma2
            ta2$ = ta2$ + Mid$(dd$, ch, 1)
        Next ch
        For ch = comma2 + 2 To Len(dd$)
            ta3$ = ta3$ + Mid$(dd$, ch, 1)
        Next ch
        tc1 = Val(ta1$)
        tc2 = Val(ta2$)
        tc3 = Val(ta3$)
        _Dest dspace&
        Cls
        Circle (tc1, tc2), tc3, 15
        _Source dspace&
        _Dest 0
        For x = 1 To stwd
            For y = 1 To stht
                tk = Point(x, y)
                If tk > 0 Then
                    Locate y, x 'i still want to move the  cursor positon
                    _PrintString (x, y), c$ ' using printstring so the screen doesn't scroll for text graphics
                End If
            Next y
        Next x
        _Source 0
    End If
    If Left$(dd$, 4) = "line" Then
        ch = 4
        Do
            ch = ch + 1
            A$ = Mid$(dd$, ch, 1)
        Loop Until A$ = ","
        comma1 = ch - 1
        Do
            ch = ch + 1
            A$ = Mid$(dd$, ch, 1)
        Loop Until A$ = ","
        comma2 = ch - 1
        Do
            ch = ch + 1
            A$ = Mid$(dd$, ch, 1)
        Loop Until A$ = ","
        comma3 = ch - 1

        For ch = 5 To comma1
            ta1$ = ta1$ + Mid$(dd$, ch, 1)
        Next ch
        For ch = comma1 + 2 To comma2
            ta2$ = ta2$ + Mid$(dd$, ch, 1)
        Next ch
        For ch = comma2 + 2 To comma3
            ta3$ = ta3$ + Mid$(dd$, ch, 1)
        Next ch
        For ch = comma3 + 2 To Len(dd$)
            ta4$ = ta4$ + Mid$(dd$, ch, 1)
        Next ch

        tc1 = Val(ta1$)
        tc2 = Val(ta2$)
        tc3 = Val(ta3$)
        tc4 = Val(ta4$)
        _Dest dspace&
        Cls
        Line (tc1, tc2)-(tc3, tc4), 15
        _Source dspace&
        _Dest 0
        For x = 1 To stwd
            For y = 1 To stht
                tk = Point(x, y)
                If tk > 0 Then
                    Locate y, x
                    _PrintString (x, y), c$ ' using printstring so the screen doesn't scroll for text graphics
                End If
            Next y
        Next x
        _Source 0
    End If
    If Left$(dd$, 4) = "rect" Then
        ch = 4
        Do
            ch = ch + 1
            A$ = Mid$(dd$, ch, 1)
        Loop Until A$ = ","
        comma1 = ch - 1
        Do
            ch = ch + 1
            A$ = Mid$(dd$, ch, 1)
        Loop Until A$ = ","
        comma2 = ch - 1
        Do
            ch = ch + 1
            A$ = Mid$(dd$, ch, 1)
        Loop Until A$ = ","
        comma3 = ch - 1

        For ch = 5 To comma1
            ta1$ = ta1$ + Mid$(dd$, ch, 1)
        Next ch
        For ch = comma1 + 2 To comma2
            ta2$ = ta2$ + Mid$(dd$, ch, 1)
        Next ch
        For ch = comma2 + 2 To comma3
            ta3$ = ta3$ + Mid$(dd$, ch, 1)
        Next ch
        For ch = comma3 + 2 To Len(dd$)
            ta4$ = ta4$ + Mid$(dd$, ch, 1)
        Next ch

        tc1 = Val(ta1$)
        tc2 = Val(ta2$)
        tc3 = Val(ta3$)
        tc4 = Val(ta4$)
        _Dest dspace&
        Cls
        Line (tc1, tc2)-(tc3, tc4), 15, B
        _Source dspace&
        _Dest 0
        For x = 1 To stwd
            For y = 1 To stht
                tk = Point(x, y)
                If tk > 0 Then

                    Locate y, x
                    _PrintString (x, y), c$ ' using printstring so the screen doesn't scroll for text graphics
                End If
            Next y
        Next x
        _Source 0
    End If

    If Left$(dd$, 4) = "fbox" Then
        ch = 4
        Do
            ch = ch + 1
            A$ = Mid$(dd$, ch, 1)
        Loop Until A$ = ","
        comma1 = ch - 1
        Do
            ch = ch + 1
            A$ = Mid$(dd$, ch, 1)
        Loop Until A$ = ","
        comma2 = ch - 1
        Do
            ch = ch + 1
            A$ = Mid$(dd$, ch, 1)
        Loop Until A$ = ","
        comma3 = ch - 1

        For ch = 5 To comma1
            ta1$ = ta1$ + Mid$(dd$, ch, 1)
        Next ch
        For ch = comma1 + 2 To comma2
            ta2$ = ta2$ + Mid$(dd$, ch, 1)
        Next ch
        For ch = comma2 + 2 To comma3
            ta3$ = ta3$ + Mid$(dd$, ch, 1)
        Next ch
        For ch = comma3 + 2 To Len(dd$)
            ta4$ = ta4$ + Mid$(dd$, ch, 1)
        Next ch

        tc1 = Val(ta1$)
        tc2 = Val(ta2$)
        tc3 = Val(ta3$)
        tc4 = Val(ta4$)
        _Dest dspace&
        Cls
        Line (tc1, tc2)-(tc3, tc4), 15, BF
        _Source dspace&
        _Dest 0
        For x = 1 To stwd
            For y = 1 To stht
                tk = Point(x, y)
                If tk > 0 Then

                    Locate y, x
                    _PrintString (x, y), c$ ' using printstring so the screen doesn't scroll for text graphics
                End If
            Next y
        Next x
        _Source 0
    End If
    If Left$(dd$, 4) = "draw" Then
        td$ = Right$(dd$, Len(dd$) - 4)
        _Dest dspace&
        Cls
        Draw td$
        _Source dspace&
        _Dest 0
        For x = 0 To stwd
            For y = 0 To stht
                tk = Point(x, y)
                If tk > 0 Then
                    Locate y, x
                    _PrintString (x, y), c$
                End If
            Next y
        Next x
        _Source 0
    End If

    If Left$(dd$, 4) = "pset" Then

        ch = 4
        Do
            ch = ch + 1
            A$ = Mid$(dd$, ch, 1)
        Loop Until A$ = ","
        comma1 = ch - 1
        For ch = 5 To comma1
            ta1$ = ta1$ + Mid$(dd$, ch, 1)
        Next ch
        For ch = comma1 + 2 To Len(dd$)
            ta2$ = ta2$ + Mid$(dd$, ch, 1)
        Next ch
        tc1 = Val(ta1$)
        tc2 = Val(ta2$)
        _Dest dspace&
        Cls
        PSet (tc1, tc2), 15
        _Source dspace&
        _Dest 0
        For x = 1 To stwd
            For y = 1 To stht
                tk = Point(x, y)
                If tk > 0 Then
                    Locate y, x
                    _PrintString (x, y), c$ ' using printstring so the screen doesn't scroll for text graphics
                End If
            Next y
        Next x
        _Source 0
    End If

End Sub
Sub cleardraw
    'clear dspace& and reset output to text screen"
    _Dest dspace&
    Cls
    _Dest 0
End Sub
Sub showdraw (x1, y1, x2, y2, c$)
    'render from x1,y1 to x2,y2 from dspace& to the textscreen  using c$ as the displayed character
    _Source dspace&
    _Dest 0
    If x1 < 1 Then x1 = 1
    If y1 < 1 Then x1 = 1
    If y2 > stht Then y2 = stht
    If x2 > stwd Then x2 = stwd
    For x = x1 To x2
        For y = y1 To y2
            tk = Point(x, y)
            Color tk, 0
            Locate y, x
            _PrintString (x, y), c$ ' using printstring so the screen doesn't scroll for text graphics
        Next y
    Next x
    _Source 0
End Sub

Print this item

  Wrappers raylib for QB64
Posted by: Coolman - 06-18-2022, 08:36 AM - Forum: General Discussion - Replies (4)

Hello. Does raylib work under windows with this Wrappers for QB64 ?

https://github.com/gAndy50/Qb64Wrappers

Print this item

  Another issue: Changing one variable instantly changes the value of another variable
Posted by: hanness - 06-17-2022, 02:03 AM - Forum: General Discussion - Replies (14)

I have a short subroutine that takes a path and removes the quotes if the path is enclosed in quotes. It then removes any trailing backslash from the path if one exists.

I was getting some unexpected results, so into debug mode I went to find the problem. As I step through the code one line at a time, I find this problem:

As soon as I execute the line that reads Temp$ = "" not only does Temp$ get set to "" but in that very moment Path$ also gets set to "" (an empty string). For the life of me, I cannot make sense of why this happens.

A few notes:

1) Path$ is not defined outside of this subroutine, so it is local to the subroutine only.

2) Temp$ is DIMed at the start of my program as a SHARED string, so that variable should be available globally.

I apologize for not supplying the full code. The problem is that this is a part of a program almost 15,000 lines long now.

Can anyone give me anything to look for here? I simply cannot see how changing one variable would instantly change another variable as well.



Code: (Select All)
Sub CleanPath (Path$)

    ' Remove quotes and trailing backslash from a path

    ' To use this subroutine: Pass the path to this sub, the sub will return the path
    ' without quotes and a trailing backslash in Temp$.

    Dim x As Integer

    ' start by stripping the quotes

    Temp$ = ""

    For x = 1 To Len(Path$)
        If Mid$(Path$, x, 1) <> Chr$(34) Then
            Temp$ = Temp$ + Mid$(Path$, x, 1)
        End If
    Next x

    ' Remove the trailing backslash, if present

    If Right$(Temp$, 1) = "\" Then
        Temp$ = Left$(Temp$, (Len(Temp$) - 1))
    End If

End Sub

Print this item

  Confusion over passing by reference vs passing by value
Posted by: hanness - 06-16-2022, 11:21 PM - Forum: General Discussion - Replies (12)

Let's say that I have the following code:

Code: (Select All)
Option _Explicit

Dim x As Integer
Dim a As String

Print "Passing a numerical variable by reference:"
x = 1
Test1 x
Print "Value of x after subroutine:"; x

Print

Print "Passing a numerical variable by value:"
x = 1
Test1 (x)
Print "Value of x after subroutine:"; x

Print

Print "Passing a string variable by reference:"
a$ = "String1"
Test2 a$
Print "Value of a$ after subroutine:"; a$

Print

Print "Passing a string variable by value:"
a$ = "String1"
Test2 (a$)
Print "Value of a$ after subroutine:"; a$

End


Sub Test1 (y As Integer)
    y = y + 1
End Sub

Sub Test2 (b As String)
    b$ = b$ + " and string 2"
End Sub


This code has 4 main sections:

Section 1: We set as variable "x" to 1 and pass it to a subroutine by reference to the variable "y". The subroutine adds one to the value of y. As expected, when we come out of the subroutine we find that the original variable "x" is now equal to 2.

Section 2: We set as variable "x" to 1 and pass it to a subroutine by value to the variable "y". The subroutine adds one to the value of y. As expected, when we come out of the subroutine we find that the original variable "x" is unchanged because we passed the variable by value rather than by reference.

But what about strings?

In section 3 and 4, I'm doing the same thing but with a string. I pass it to a subroutine both by reference and by value but in both cases the original string variable is changed.

Is this expected behavior? Is it possible to pass a string variable without affecting the original?

I know that I could work around it by assigning the variable to another variable within the subroutine like this:

Code: (Select All)
Sub Test2 (b As String)
dim c as string
c$=b$   
c$ = c$ + " and string 2"
End Sub


This way, I'm not modifying the original string. I just wanted to make sure I'm not missing something obvious.

Print this item

  PLAYMID.BAS and MIDI file.
Posted by: Robert Claypool - 06-16-2022, 04:02 AM - Forum: Works in Progress - Replies (18)

I wrote this and compiled it on 0.8.2 but the MIDI file won't play for me.

Code: (Select All)
Print "Press any key to start"
Do: Loop Until InKey$ <> ""
Filename$ = "TONOWH~2.MID"
LoadSound& = _SndOpen(Filename$)

MySound& = _SndCopy(LoadSound&)
_SndPlay MySound&
Do: Loop Until InKey$ <> ""
_SndClose MySound&
_SndClose LoadSound&



Attached Files
.7z   playmid.7z (Size: 1.67 KB / Downloads: 76)
Print this item

  BLOCKMODE demo
Posted by: James D Jarvis - 06-15-2022, 08:51 PM - Forum: Programs - Replies (3)

In a world where high resolution graphics dominate the microcomputing industry and hobby programming it only seemed fitting to develop a display mode that was certainly not high-res. 
Blockmode uses 4 traditional character codes to create graphics along with 256 colors in a massive display of low-res splendor of 160 x 98(ish) boxels. With block printing that allows 26 characters per line of text on 12 whole lines !
It's a marvel of mixed mode graphics that I couldn't think of a better name for.

I'd like to thank dcromley for developing and sharing microfont, without his contribution you might be seeing less block letters in the demo.

Code: (Select All)
'blockmodedemo
'lower-res graphics demo fun
'by James D. Jarvis
' uses microfont by dcromley
Dim Shared drawspace&, s&
drawspace& = _NewImage(161, 100, 256)
s& = _NewImage(1280, 1600, 256)
Screen s&
_FullScreen
_Scrolllock On
Randomize Timer
Dim Shared blk$(0 To 3), BSCR_klr, BSCR_bkg, Bgrid(160, 100, 3)
Dim Shared bfont$
Dim Shared b96$
blk$(0) = " ": blk$(1) = Chr$(176): blk$(2) = Chr$(177): blk$(3) = Chr$(178)
BSCR_klr = 15: BSCR_bkg = 0
Const bgblk = 1, bgklr = 2, bgbkg = 8
bstart
For x = 1 To 160
    For y = 1 To 98
        If y Mod 2 > 0 Then
            If x Mod 2 > 0 Then
                BSET x, y, 2, 3, 0
            Else
                BSET x, y, 1, 3, 9
            End If
        Else
            If x Mod 2 > 0 Then
                BSET x, y, 1, 3, 9
            Else
                BSET x, y, 2, 3, 0
            End If

        End If
    Next y
Next x
drawblocks 1, 160, 1, 98

bat 1, 1, "BLOCKMODE"
bat 1, 2, "160 x 98 bloxels"
bat 1, 3, "Block Print 26 c by 12 r "
bat 1, 4, "abcdefghijklmnopqrstuvwxyz"
bat 1, 5, "Can use draw commands"
blat 80, 50, " ", 15, 0
bdraw "r5d7l5u7"
bdraw "br7c11r5d1c7l5d1c8r5"
bcircle 50, 60, 9, 5
barc 50, 60, 9, 12, 0, 360
bat 1, 11, "press any key"

Do
    _Limit 60
    A$ = InKey$
Loop Until A$ <> ""


'oh yeah ...
Cls
bat 1, 1, "To Boldy Block"
_Delay 0.3
bat 1, 2, "Where No Block"
_Delay 0.3
bat 1, 3, "Has Blocked Before"
_Delay 0.3
For x = 1 To 30
    _Limit 10
    blat 1, 99, " ", 15, 0
Next x
_Dest drawspace&
Cls
_Dest s&
For px = 1 To 22
    _Limit 20
    _Dest drawspace&: Cls
    _Dest s&: Cls
    drawplayership px, 50
    _Display
Next px
For kx = 160 To 100 Step -1
    _Limit 20
    _Dest drawspace&: Cls
    _Dest s&: Cls
    drawplayership px, 50

    drawkremulan kx, 60, 180
    If kx < 140 Then
        drawkremulan kx + 20, 70, 180
    End If
    If kx < 120 Then
        drawkremulan kx + 40, 50, 180
    End If
    _Display
Next kx
bat 1, 1, "This Is Capt. Peek"
_Delay 0.5
_Display
bat 1, 2, " We"
_Delay 0.6
_Display
bat 5, 2, "Come"
_Delay 0.7
_Display
bat 10, 2, "In"
_Delay 0.8
_Display
bat 13, 4, "Peace"
_Display
_Delay 2

_Dest drawspace&: Cls
_Dest s&: Cls
drawplayership px, 50
drawkremulan kx, 60, 180
drawkremulan kx + 20, 70, 180
drawkremulan kx + 40, 50, 180
_Display

BSCR_klr = 6: BSCR_bkg = 0
bat 5, 2, "More FEDERATION LIES !"
_Display
_Delay 0.5
bat 5, 3, "The Real Question is "
_Display
_Delay 0.2
bat 6, 4, "To Block,": bat 7, 5, " Or Not To Block!"
_Display
_Delay 0.4

BSCR_klr = 15: BSCR_bkg = 0
bat 1, 11, "press any key..."
_Display
Do
    A$ = InKey$
Loop Until A$ <> ""
_Dest drawspace&: Cls
_Dest s&: Cls
drawplayership px, 50
drawkremulan kx, 60, 180
drawkremulan kx + 20, 70, 180
drawkremulan kx + 40, 50, 180
_Display
kbx1 = kx - 4: kby1 = 60
kbx2 = kx + 16: kby2 = 70
kbx3 = kx + 36: kby3 = 50
fbx1 = px + 4: fby1 = 48
fbx2 = px + 4: fby2 = 52
For n = 1 To 100
    _Limit 20
    _Dest drawspace&: Cls
    _Dest s&: Cls
    If n > 60 Then px = px + 1
    If n < 90 Then drawkremulan kx, 60, 180
    drawkremulan kx + 20, 70, 180
    If n < 95 Then drawkremulan kx + 40, 50, 180
    drawplayership px, 50
    If n < 20 Then
        ' blat kbx1 - n, 6, blk$(1), 4, 8
        dburst kbx1 - n * 3, kby1 - (n * .8), 2, 4
    End If
    If n > 23 And n < 44 Then
        ' blat kbx1 - n, 6, blk$(1), 4, 8

        dburst fbx1 + (n - 23) * 3, fby1 + n / 8, 2, 11
    End If
    If n > 25 And n < 46 Then
        ' blat kbx1 - n, 6, blk$(1), 4, 8
        dburst fbx2 + (n - 25) * 3, fby2 + n / 10, 2, 11
    End If
    If n > 15 And n < 30 Then
        dburst kbx2 - n * 3, kby2 - (n * .8), 2, 4
    End If
    If n > 12 And n < 27 Then
        dburst kbx3 - n * 3, kby3 + (n * .8), 2, 4
    End If
    If n > 25 And n < 45 Then
        dburst kbx3 - n * 3, kby3 + (n * .8), 2, 4
    End If
    If n > 52 And n < 90 Then
        _Dest drawspace&
        Select Case Int(Rnd * 8)
            Case 0:
                Line (px + 1, fby1)-(kbx1, kby1), 11
                Line (px + 1, fby2)-(kbx3, kby3), 11
            Case 1:
                Line (px + 1, fby1)-(kbx1, kby1), 11
                Line (px + 1, fby2)-(kbx2, kby2), 11
            Case 2:
                Line (px + 1, fby2)-(kbx3, kby3), 11
            Case 3:
                Line (px + 1, fby2)-(kbx2, kby2), 11
            Case 4:
                Line (px + 1, fby1)-(kbx1, kby1), 3
            Case 5:
                Line (px + 1, fby1)-(kbx1, kby1), 3
                Line (px + 1, fby2)-(kbx3, kby3), 11
            Case 6:
                Line (px + 1, fby2)-(kbx3, kby3), 3
                Line (px + 1, fby2)-(kbx2, kby2), 11
                Line (px + 1, fby1)-(kbx1, kby1), 11
            Case 7:
                Line (px + 1, fby1)-(kbx1, kby1), 11
                Line (px + 1, fby2)-(kbx2, kby2), 3
        End Select
        _Source drawspace&
        For x = 1 To 160
            For y = 1 To 98
                b = Point(x, y)
                If b > 0 Then
                    _Dest s&
                    blat x, y, blk$(3), b, b
                End If
            Next y
        Next x
        If n > 65 And n < 90 Then
            dburst kbx1, kby1, Int(Rnd * 4) + 2, 12
            If Int(Rnd * 9) < 7 Then dburst kbx1 + Int(Rnd * 4) + 2, kby1, Int(Rnd * 5), 14
            If Int(Rnd * 9) < 7 Then dburst kbx1 + Int(Rnd * 6) + 2, kby1, Int(Rnd * 4), 4
        End If
        If n > 69 And n < 95 Then
            dburst kbx2, kby2, Int(Rnd * 4) + 2, 12
            If Int(Rnd * 9) < 7 And n < 93 Then dburst kbx2 + Int(Rnd * 4) + 2, kby2, Int(Rnd * 5), 14
            If Int(Rnd * 9) < 7 Then dburst kbx2 + Int(Rnd * 6) + 2, kby2, Int(Rnd * 4), 4
        End If
        If n > 70 Then
            dburst kbx3, kby3, Int(Rnd * 4) + 2, 12
            If Int(Rnd * 9) < 7 And n < 98 Then dburst kbx3 + Int(Rnd * 4) + 2, kby3, Int(Rnd * 5), 14
            If Int(Rnd * 9) < 7 Then dburst kbx3 + Int(Rnd * 6) + 2, kby3, Int(Rnd * 4), 4
        End If
        If n > 80 Then kx1 = kx1 + 2
        If n > 90 Then kx3 = kb3 + 1

        _Dest s&

    End If
    _Display
Next n
For n = 1 To 30
    _Limit 20
    _Dest drawspace&: Cls
    _Dest s&: Cls
    px = px + 2
    drawplayership px, 50
    If k < 25 Then
        dburst kbx2, kby2, Int(Rnd * n) + 2, 12
        If n < 23 Then drawkremulan kx + 20, 70, 180
        _Dest drawspace&
        Select Case Int(Rnd * 8)
            Case 0:
                Line (px + 1, fby1)-(kbx2, kby2), 3
                Line (px + 1, fby2)-(kbx2, kby2), 11
            Case 1:
                Line (px + 1, fby1)-(kbx2, kby2), 11
                Line (px + 1, fby2)-(kbx2, kby2), 3
            Case 2:
                Line (px + 1, fby1)-(kbx2, kby2), 11
            Case 3:
                Line (px + 1, fby2)-(kbx2, kby2), 3
        End Select
        _Source drawspace&
        For x = 1 To 160
            For y = 1 To 98
                b = Point(x, y)
                If b > 0 Then
                    _Dest s&
                    blat x, y, blk$(3), b, b
                End If
            Next y
        Next x
    End If

    _Display
Next n
For n = 1 To 30
    _Limit 20
    _Dest drawspace&: Cls
    _Dest s&: Cls
    bat 1, 1, "It would seem that the"
    bat 2, 2, " Kremulans decided to .."
    If n > 15 Then bat 3, 3, " leave in PIECES"
    px = px + 1
    drawplayership px, 50
    _Display
Next n
'the blockmode subs
bat 1, 11, "press any key"
_Display
A$ = ""
Do
    _Limit 60
    A$ = InKey$
Loop Until A$ <> ""


System

Sub bstart
    For r = 1 To 30
        _Limit 60
        For b = 1 To 50
            blat Int(Rnd * 160) + 1, Int(Rnd * 98) + 1, blk$(Int(Rnd * 4)), Int(Rnd * 16), Int(Rnd * 16)
        Next b
    Next r
    _Delay 0.2
    Cls
    For r = 1 To 50
        For c = 1 To 151
            Bgrid(c, r, 1) = 0
            Bgrid(c, r, 2) = BSCR_klr
            Bgrid(c, r, 2) = BSCR_bkg
        Next c
    Next r
    bfont$ = bfont$ + "€€€€€€€û€€€à€à€”¾”¾”ªÿª„¢„ˆ¢†¹Í²…€€ð€€€œ¢Á€€Á¢œ€ˆªœªˆˆˆ¾ˆˆ"
    bfont$ = bfont$ + "€‡†€€ˆˆˆˆˆ€ƒƒ€€‚„ˆ ¾ÅÉѾ€¡ÿ¡ÃÅɱ¢ÉÉɶŒ”¤ÿ„úÉÉÉƾÉÉɦÃÄÈÐà"
    bfont$ = bfont$ + "¶ÉÉɶ²ÉÉɾ€€¶€€€¶€€€ˆ”¢€€”””€€¢”ˆ€ ÀÅÈ°¾ÁÝż¿ÈÈÈ¿ÿÉÉɶ¾ÁÁÁ¢"
    bfont$ = bfont$ + "ÿÁÁÁ¾ÿÉÉÉÁÿÈÈÈÀ¾ÁÁŦÿˆˆˆÿ€ÁÿÁ€‚ÁþÀÿˆ”¢Áÿÿ  ÿÿ ˜„ÿ¾ÁÁÁ¾"
    bfont$ = bfont$ + "ÿÄÄĸ¸ÄÄÄÿÿÈÌʱ²ÉÉɦÀÀÿÀÀþþü‚‚üþ†þÁ¶ˆ¶ÁÀ°°ÀÃÅÉÑကÿÁ€"
    bfont$ = bfont$ + " ˆ„‚€Áÿ€€„ˆˆ„€Àà €‚•••þ‘‘‘ŽŽ‘‘‘‘Ž‘‘‘þŽ•••Œ€ˆ¿È ˆ•••Ž"
    bfont$ = bfont$ + "ÿ€€Þ€€Þ€€ÿ„Š‘‘€€þŸŸŸˆŸŽ‘‘‘Ž’’’ŒŒ’’’Ÿˆˆˆ•••‚"
    bfont$ = bfont$ + "€þ‘ž‚Ÿœ‚‚œž†ž‘Š„Š“™……‚œ‘“•™‘€ˆ¶Á€€€÷€€€Á¶ˆ€ˆˆ„ˆˆ„ˆ"

    b96$ = b96$ + " !" + Chr$(34) + "#$%&'()*+,-./0123456789:;<=>?"
    b96$ = b96$ + "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_"
    b96$ = b96$ + "`abcdefghijklmnopqrstuvwxyz{|}~"

End Sub
Sub bat (bcol, brow, B$)
    'print block charcters into fixed spots)
    bb = 0: br = brow
    For bc = 1 To Len(B$)
        bb = bb + 1
        If bb = 27 Then
            bb = 1
            br = br + 1
        End If
        bchar Mid$(B$, bc, 1), (bcol + bb) * 6 - 11, (br * 8) - 7
    Next bc
End Sub

Sub blat (bcol, brow, B$, Bklr, Bbkg)
    'color print specific blocks
    Color Bklr, Bbkg
    Locate brow, bcol
    Print B$
    Color BSCR_klr, BSCR_bkg
End Sub

Sub BSET (bcol, brow, BK, Bklr, Bbkg)
    'sets characters and colors on the BGRID
    Bgrid(bcol, brow, 1) = BK
    Bgrid(bcol, brow, 2) = Bklr
    Bgrid(bcol, brow, 3) = Bbkg
End Sub

Sub drawblocks (bc1, bc2, br1, br2)
    'show the bgrid
    'drawing after row 98 will scroll the screen...ooops
    For bc = bc1 To bc2
        For br = br1 To br2
            blat bc, br, blk$(Bgrid(bc, br, bgblk)), Bgrid(bc, br, bgklr), Bgrid(bc, br, bbkg)
        Next br
    Next bc
End Sub


Sub bchar (bstr$, bx, by) ' ==== THIS IS a modified MicroFont ROUTINE ====
    ' -- prints string bstr at position ixx0 and iy0 --
    ixx0 = bx
    iyy0 = by + 8

    Dim ipobstr, ipob96, ipos480, ix0, iy0, ix, iy, imask, ich
    ix0 = ixx0 - 1: iy0 = iyy0 + 1 ' byValue
    For ipobstr = 1 To Len(bstr$) ' one character at a time
        ipob96 = InStr(1, b96$, Mid$(bstr$, ipobstr, 1))
        If ipob96 = 0 Then ipob96 = 4 ' invalid character -> #
        ipos480 = (ipob96 - 1) * 5 ' index to bfont$
        For ix = 0 To 6: imask = 1 ' OxxxxxO 5 columns in character
            If 1 <= ix And ix <= 5 Then ich = Asc(Mid$(bfont$, ipos480 + ix, 1))
            For iy = 0 To 8 ' OxxxxxxxO 7 rows in character
                If ix < 1 Or ix > 5 Or iy < 1 Or iy > 7 Then
                    ' blat ix0 + ix, iy0 - iy, blk$(0), BSCR_klr, BSCR_bkg
                Else ' choose FG or BG
                    If ich And imask Then ' ck bit
                        blat ix0 + ix, iy0 - iy, blk$(3), BSCR_klr, BSCR_klr
                    Else
                        ' blat ix0 + ix, iy0 - iy, blk$(0), BSCR_klr, BSCR_bkg
                    End If
                    imask = imask + imask ' next bit in column
                End If
            Next iy
        Next ix
        ix0 = ix0 + 6 ' next char output
    Next ipobstr
    ' could modify ix here
End Sub
Sub bdraw (BD$)
    _Dest drawspace&
    If LCase$(BD$) = "CLR" Then
        Cls
        BD$ = ""
    Else
        Draw BD$
    End If
    _Source drawspace&
    For x = 1 To 160

        For y = 1 To 98
            b = Point(x, y)
            If b > 0 Then
                _Dest s&
                blat x, y, blk$(3), b, b
            End If
        Next y
    Next x
End Sub
Sub bcircle (xx, yy, r, klr)
    'draw a circle
    _Dest drawspace&
    PSet (xx, yy), 0
    Draw "c" + Str$(klr)
    For d = 0 To 360 Step 1
        Draw "ta " + Str$(d) + " r" + Str$(r) + " bl" + Str$(r)
    Next d
    _Source drawspace&
    For x = 1 To 160

        For y = 1 To 98
            b = Point(x, y)
            If b > 0 Then
                _Dest s&
                blat x, y, blk$(3), b, b
            End If
        Next y
    Next x
End Sub
Sub barc (xx, yy, r, klr, arc1, arc2)
    'draws an arc, will draw an unfilled circle if the arc goes from 0 to 360
    _Dest drawspace&
    t = Point(xx, yy)
    PSet (xx, yy), t
    Draw "c" + Str$(klr)
    For d = arc1 To arc2 Step 1
        Draw "ta " + Str$(d) + " br" + Str$(r - 1) + "r  bl" + Str$(r)
    Next d
    _Source drawspace&
    For x = 1 To 160
        For y = 1 To 98
            b = Point(x, y)
            If b > 0 Then
                _Dest s&
                blat x, y, blk$(3), b, b
            End If
        Next y
    Next x
End Sub

'these subs are used in the blocktrek portion of the demo
' showing how even low-res graphics can be fun
Sub drawplayership (xx, yy)
    _Dest drawspace&
    PSet (xx, yy), 0
    Color 15
    Circle (xx, yy), 5, 15
    Draw " bm -10,0 r10 bm -10,-4 d8 l3 br3 bu8 l3"
    sc = 10
    If shieldstr < shieldmax * .8 Then sc = 2
    If shieldstr < shieldmax * .6 Then sc = 14
    If shieldstr < shieldmax * .4 Then sc = 12
    If shieldstr < shieldmax * .2 Then sc = 4
    If shieldstr > 0 Then Circle (xx, yy), 20, sc, 0, (2 * _Pi) * (shieldstr / shieldmax)
    Draw "ta0"
    _Source drawspace&
    For x = 1 To 160
        For y = 1 To 98
            b = Point(x, y)
            If b > 0 Then
                _Dest s&
                blat x, y, blk$(3), b, b
            End If
        Next y
    Next x

End Sub
Sub drawkremulan (xx, yy, aa)
    _Dest drawspace&
    PSet (xx, yy), 0
    kk = 6
    Color kk
    Circle (xx, yy + 2), 2, kk
    Draw "ta" + Str$(aa) + "r2l1u3d6u3l10 e3 l5 r5 g3 f3 l5 "
    sc = 10
    If kshieldstr < kshieldmax * .8 Then sc = 2
    If kshieldstr < kshieldmax * .6 Then sc = 14
    If kshieldstr < kshieldmax * .4 Then sc = 12
    If kshieldstr < kshieldmax * .2 Then sc = 4

    If kshieldstr > 0 Then Circle (xx, yy), 20, sc, 0, (2 * _Pi) * (kshieldstr / kshieldmax)
    Draw "ta0"
    _Source drawspace&
    For x = 1 To 160
        For y = 1 To 98
            b = Point(x, y)
            If b > 0 Then
                _Dest s&
                blat x, y, blk$(3), b, b
            End If
        Next y
    Next x

End Sub
Sub dburst (xx, yy, r, klr)
    _Dest drawspace&
    PSet (xx, yy), klr
    For d = 0 To 360 Step (1 + Rnd * 10)
        rv = Int(r \ 1.9 + Rnd * (r / 2))
        Draw "ta " + Str$(d) + "c" + Str$(klr) + " r" + Str$(rv) + " bl" + Str$(rv)
    Next d
    _Source drawspace&
    For x = 1 To 160
        For y = 1 To 98
            b = Point(x, y)
            If b > 0 Then
                _Dest s&
                blat x, y, blk$(3), b, b
            End If
        Next y
    Next x

End Sub

Print this item

  Possible bug? Unable to enter a comma in response to INPUT
Posted by: hanness - 06-15-2022, 06:14 AM - Forum: General Discussion - Replies (4)

In QB64pe 0.8.2 take a look at this code:

Code: (Select All)
a$ = "This is a string, with a comma"
Input b$

Print a$
Print b$

Notice that the first line simply set a string and that the string contains a comma.
The second line is asking for input from a user. Start typing in a string of characters, and somewhere along the line, try to type a comma. The comma will not be accepted.

When it gets to the print statements, it prints the string of text that includes a comma, so clearly a comma is a valid character in a string. Since a comma is a valid character, an INPUT should allow a user to input a comma as part of the string.

Print this item