Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - SMcNeill

Pages: [1] 2 3 ... 16
1
QB64 Discussion / QB64 Bounty List
« on: April 08, 2022, 10:29:06 am »
Just a few days ago, I had the misfortune of having to fill up my tractor's fuel tank from being almost empty.  400 gallons @ almost $5.00 per gallon...  And then a sinking feeling hit the core of my gut as I realized I was going to have to repeat such an experience dozens of times this year.  /cry

By the time this harvest season comes around in fall, I'm predicting that we're going to see increases in the price of staple foods by everything doubling, if not more at that time!

"And how's this ever rising inflating relate to QB64 and its development?", you guys ask.

It's all because I realize the Devs are people too!  They're going to be facing the exact same financial crunch as everybody else in the world, and QB64 is nothing more than a hobby project.  Who's going to have time to spend on hobbies, when they're working their ass off just to try and keep food on the table?!!

So, that's when an idea came to me that sounds like a Win-Win for everyone involved:  A QB64 Bounty List!

Got some extra cash laying around?  Are you, like me, one of those whose prepared no matter what the future brings?  I've had a lifetime to save and put aside for hard times, so I can comfortably coast through the next several years of my life and weather the increasing inflation.  Others aren't as fortunate -- such as some student struggling to make ends meet while working their way through college.  They might have skills to work on QB64 in places which I don't, but they simply don't have time to devote to working on things due to having to take a part-time job at McDonalds just to keep the bills paid.

So here's my proposal -- A "Bounty System", where people can pledge to donate $$$ for whatever fix, enhancement, or addition they wish to see for the QB64 language.  It'll give Devs a little extra cash for small projects, keep the development of QB64 going, and gives the user-base a chance to help guide what/where the language should go next.  It's a win-win for everyone!

To start us out, I'd like to place a bounty on the following issues:

1) $100 Bounty for a fix to each of the input commands we use.  As they currently exist, each of them is flawed in various ways.  For instance here's one to illustrate the problem with _KEYHIT:

DO
    k = _KEYHIT
    IF k <> 0 THEN PRINT k
    _LIMIT 30
LOOP

Run the above in the IDE, and hold down CTRL and press TAB.  The Tab key is a keycode 9 key.  When it goes down, it should print 9, when it comes up, it should print -9.  Instead, what we see is:  NO keycode for the down press.  Nada.  Zip.  QB64 simply does not report that tab key being depressed at all.  For the key release, it reports a value of -105 -- which is the I key!   CTRL-TAB is *both* unmapped AND mismapped. and it's an excellent example of the problem the command has.

I'll pay $100.00 to whoever wants to go in and fix _KEYHIT so that it maps all the possible keystrokes correctly -- for both up and down states, in the various operating systems we compile to.  I'll also offer $100.00 for the exact same fix to INKEY$ and _DEVICES, making a total of $300 for the three commands to be repaired fully.  From my memory, Inkey$ does the same mismapping of values and _DEVICES is completely screwed up with codes being nothing as they should be to maintain backwards compatibility  with older versions of QB64 (prior to version 1.0 when the glitch was introduced), and it doesn't read various keys at all.

2)  I'll also offer a $100.00 bounty for whomever wants to go in and fix our fonts for us.  The issue here is with various fonts being cut-off and not rendering properly.  I don't have an example ready at the top of my hand, but I'll dig one up of someone wants to tackle the issue.  Basically, with various fonts, letters get truncated off.  The bottom of the "g" might lose several pixels, or the top of an embellished T is completely cut off...   Fix that, earn $100.00

3) I'll also offer another $25.00 bounty for whomever wants to go in and fix our _LOADIMAGE command.  At the moment, it's impossible to load 256-color images -- they automatically convert over to 32-bit images.  It'd be nice for loadimage to work fully like its supposed to.  I think this should be a small fix (as we apparently load the image first and then convert them to 32-bit somewhere automatically), so it's a smaller bounty.

That's all my poor wallet can afford to place a bounty on at the moment, and as for me personally, I'm rather content with what QB64 can already do for me.  I'm not really pushing for any sort of "future development"  (besides a desire for someone to import a video playback library for us via a _LOADVIDEO command, or for someone to fully integrate a text-to-speech system for us), but I encourage any with a little extra cash to post their own "bounties" here for the Devs to look over and work on. 

QB64 is free.  Users don't pay anything for it; yet there's always a large list of things which people want added to it.  I see nothing wrong with offering a few $$$ towards enhancing or promoting development of the project.  The more people who are willing to donate and place bounties on things, the more Devs can treat QB64 as more than just an occasional hobby-project.

Is there anyone else out there willing to donate for a "fix" to something that's been bugging them?  Or willing to donate to have a feature added you've been dying for?  Is there anyone willing to pick up these Bounties and earn a little extra cash on the side, while helping the language grow and expand over time?

I guess only time will tell!

2
QB64 Discussion / Repo renaming compiler folders
« on: March 10, 2022, 08:25:55 am »
But what happened to the development builds? - 145MB 7z, with nearly 30000 files each (32/64)?

Oh, after a closer look, it seems both archives deliver both compiler versions (mingw32/64), one of it is renamed to c_compiler (according to version), but instead deleting the other one, it remains in place. Is this intended or a glitch in the build process?

I mean I could live with it in the development builds, but later in the release archives it should definitly strip out the unused compiler distibution.

PS - talking about the windows archives...

These two folders have been there forever (or at least for several versions now) with windows, and they've always been kind of a PITA with github.  If you clone the repo with github, you get both directories.  Once you decide to "setup_win.bat". the setup determines if you have a 32-bit or 64-bit OS and then moves and renames the proper folder to become the c_compiler.

The problem with this is if you now open github, it tells you that thousands of files have changed and it wants to sync those changes into the repo.  The only way to eliminate this glitch is to copy the folder and place it back so that github will see those files where it expects to see them, and then it won't consider them to be deleted and altered from the current repo version.

I've mentioned the fix to this before -- and simply adding the files to the .gitignore won't help as they're already in there.

.gitignore:
Code: [Select]
internal/c/c_compiler
internal/temp*
*.o
*.a
*.exe
*.bas
internal/config*.txt
internal/config.ini
internal/help
internal/version.txt
tempfoldersearch.bin
internal/c/mingw32
internal/c/mingw64
internal/c/qbx[2-9].cpp
*.ttf
/run_qb64.sh
/qb64

The files were archived and become part of the repo BEFORE the gitignore file was created.  From reading up on various documentation across the web, this is what needs to happen:

1) remove those references from gitignore
2) remove those directories completely from the repo
3) push the changes to the repo
4) add those ignore references back into the gitignore, so the repo will ignore tracking changes to them.
5) push that change into the repo
6) add those directories back into the repo. 
7) Push that change back to the repo.

This will fix the issues with the files/directories being in the archive before the ignore, and fix the issue with gitignore not actually ignoring the files as the folder won't have existed prior to the addition to the ignore list.  The ignore  list needs to exist before whatever it's ignoring does.

Here -- screenshots of what I'm talking about:

A fresh clone of the repo
  [ You are not allowed to view this attachment ]  

Going through the build process
  [ You are not allowed to view this attachment ]  

Loading Github Desktop once more
  [ You are not allowed to view this attachment ]  



As you can see, gitignore isn't ignoring the loss of those files at all.  The only way to make git happy is to copy the c_compiler back into place as a mingw64 folder that just takes up room and is never used for anything -- which is a complete PITA.

If you guys DO decide to change the setup script so that it deletes the unused folder, PLEASE take the time to fix the gitignore issue as I mentioned above, or else it's going to be a complete and utter PITA to have github redownload those missing files every time someone syncs to an updated version of the repo after having ran the setup script.

3
QB64 Discussion / &H calculation logic??
« on: March 06, 2022, 09:33:01 am »
A brief example of what's going wrong with the CONST issue that bplus pointed out in the other topic:

Code: QB64: [Select]
  1. i = &HFF '255
  2. Print i, "should be 255"
  3.  
  4. i = &HFFFF '65535
  5. Print i, "should be 65535"
  6.  
  7. i = &HFFFFFF '16777215
  8. Print i, "should be 16777215"
  9.  
  10. i = &HFFFFFFFF '4294967295
  11. Print i, "should be 4294967295"
  12.  
  13.  

Without any sort of forced type specified for &H, shouldn't the value always be unsigned?  What's with this deal of it giving signed byte, then signed integer, then signed long, then signed integer64 results?  If you look close &HFFFF is the exact same value as &HFFFFFFFF -- that can't be right!  Can it??

If this is working as intended for &H values, can someone write us up an explanation to document this behavior?  The variable type that we're assigning values to doesn't change from start to finish above, but the values we get from our &H numbers certainly jumps from one extreme to the other.

I just can't sort out why &HFFFF would become 18-quad-zillion-and-2, rather than a simple 65535.

4
QB64 Discussion / The QB64 Bible (Work In Progress)
« on: February 01, 2022, 03:48:46 pm »
As you guys might know (if you don't, what the heck have you been doing -- hiding your head under a rock somewhere??), I've transitioned into a writer/novelist now that I've more or less officially retired here at the farm.  October to January still keeps me busy with farm life, but otherwise I've got the rest of the year free to indulge my hobbies however I want.

For ages, I've been promising, "Some day, I'm going to sit down and end up writing up some sort of overly complex and wordy manual for QB64 that everyone can laugh at and nobody will probably ever use!"

Well, I just so happen to be snowed in -- and have been snowed in for the last few weeks -- and my boredom and restlessness has now gotten to the point where I finally decided to sit down and start on this little project:  The QB64 Bible.

For now, all I've got is basically a write up about SCREEN 0 -- (and it's only about 14 pages long) -- but I hope it shows the style and format I'm shooting for here, and the information which I want to try and gather up into one easy to find and reference area.

Feel free to download it.  Study it.  Point out anything that seems unclear or imprecise, or that you just don't like, and offer any ideas of what you guys think should go into this little project.  I'm just starting on this, but if all works out, I can probably churn out a few hundred pages of nonsense by the end of the month (provided I stick with this project exclusively during that time), so at that point it might actually have enough information in it to become something that somebody, somewhere, might want to make use of sometime in the future.

Just remember:  This is a work in progress and is subject to any and all revisions, edits, changes, additions, and deletions -- at my whim and whimsey -- for the foreseeable future.

5
Programs / Windows Text To Speech Library
« on: January 27, 2022, 06:52:50 am »
I turned the powershell stuff into a simple little library for people to make use of in their projects, and here it is: 

Code: QB64: [Select]
  1. _Title "Steve's Powershell Speech Library"
  2.  
  3. Speech_IoR 'initialize or reset speech options
  4. Speech_SaP "Hello World, This is a normal speed demo of David's voice" 'speak and print
  5. Speech_Speaker "Ziva"
  6. Speech_Say "Hello again.  This is a normal speed demo of Ziva's voice." 'just speak this one
  7. Speech_Speaker "David"
  8. Speech_Speed -10
  9. Speech_SaP "And now I'm speaking as David, but I'm speaking veeery slow."
  10. Speech_Speaker "Ziva"
  11. Speech_Speed 5
  12. Speech_SaP "And now I'm a very hyper Ziva!"
  13. Speech_Speed 0
  14. Speech_Volume 30
  15. Speech_SaP "And now I'm whispering to you that I'm done with my demo!"
  16.  
  17.  
  18. '$INCLUDE:'TextToSpeech.BM'

 

As you can see, all the commands are preceeded by "Speech_", to try and help keep the sub names unique, associative, and not interfere with any user variable names and such.

Routines in this little package are:

Speech_IoR -- Init or Reset.  Call this first to initialize the settings (and turn volume up to 100, or else you'll be speaking on a MUTE channel)

Speech_Speaker -- Change the default speaker.  Currently I only support "David" and "Ziva", but feel free to change or add to this if your system has other voices installed via language/voice packs.

Speech_Speed -- Set a value from -10 to 10 to adjust the speed of the speaker.  0 id default, -10 is sloooow, and 10 is faaaast.

Speech_Volume -- Set a value from 0 to 100 to adjust how loud you're going to be speaking with the voices.

Speech_OutTo -- Use this to change where you want the speech to go.  Only options now are your speakers or a file.  Since it's not currently in the demo, as I didn't want to randomly save junk to folks drives, an example looks like:

        Speech_OutTo "MyTextToFile.wav"
        Speech_OutTo "Speaker"
        Speech_OutTo "" 'defaults/resets to speaker

Speech_Say -- Just says the text you specify with the settings you gave it previously.

Speech_SaP -- Says and Prints the text you specify to the screen as a quick print and speak shortcut.  Uses previous settings.

Speech_ToWav -- Converts text to a wav file and saves it to the disk where you specify.  Since it's not in the short demo above, usage would be as:

       Speech_ToWav "Hello World.  This is the text I'm saving to a file!", "MyFile.wav"

speak -- This is the master command with all the options built into it.  You can skip everything else, if you want to use this as a stand alone command to do everything all at once.  Everything else ends up calling this command at the end of the day, so you can bypass some processes if you call this directly.



And that's basically it for now.  Windows Speech Synthesizer is quite a powerful little tool, with a ton of options which we can utilize with it, but I figure this is the basics of what someone would need to be able to do with it for a program.  It seems to handle what I need from it for now.

If you guys need it to do more, feel free to ask and I'll see about adding extra functionality as people need it.  Or, feel free to make the changes necessary yourself and then share them here with us so everybody else can enjoy any extra tweaks you guys add into the code.



To make use of this:

1) Download the library: 
2) Move it to your QB64 folder.
3) '$INCLUDE:'TextToSpeech.BM' at the end of your program.
4) Speech_IoR inside your code to initialize everything
5) Call the other subs as you want to make use of them and alter the settings to your specific needs.

It's that simple!  ;D

6
Programs / Powershell Text To Speech
« on: January 25, 2022, 05:04:08 pm »
Code: QB64: [Select]
  1. _Title "Steve's Powershell Speech Script"
  2.  
  3.  
  4. SaP "Hello World. This is a normal speed demo of David's voice", "David", 0
  5. SaP "Hello again.  This is a normal speed demo of Ziva's voice.", "Ziva", 0
  6. SaP "And now I'm speaking as David, but I'm speaking veeery slow.", "David", -10
  7. SaP "And now I'm a very hyper Ziva!", "Ziva", 5
  8. SaP "And now I'm done with my demo!", "", 0
  9.  
  10. Sub SaP (text$, who$, speed)
  11.     Print text$
  12.     If UCase$(who$) = "ZIVA" Then Speaker = 1
  13.     speak text$, Speaker, speed
  14.  
  15. Sub speak (text As String, Speaker As Integer, Speed)
  16.     Dim message As String
  17.     message = text
  18.     'some symbols and such can't be used with Powershell like this, as they're command symbols
  19.     'we need to strip them out of our text.  (Like apostrophes!)
  20.     remove$ = "'" + Chr$(34) 'add to remove$ here, if more symbols need to be removed as future testing showcases problems
  21.     For j = 1 To Len(remove$)
  22.         Do
  23.             i = InStr(message, Mid$(remove$, j, 1))
  24.             If i Then message = Left$(message, i - 1) + Mid$(message, i + 1)
  25.         Loop Until i = 0
  26.     Next
  27.     out$ = "Powershell -Command " + Chr$(34)
  28.     out$ = out$ + "Add-Type -AssemblyName System.Speech; "
  29.     out$ = out$ + "$Speech = New-Object System.Speech.Synthesis.SpeechSynthesizer; "
  30.     If Speaker = 0 Then out$ = out$ + "$Speech.SelectVoice('Microsoft David Desktop'); "
  31.     If Speaker = 1 Then out$ = out$ + "$Speech.SelectVoice('Microsoft Zira Desktop'); "
  32.     If Speed Then out$ = out$ + "$Speech.Rate =" + Str$(Speed) + "; "
  33.     out$ = out$ + "$Speech.Speak('" + message + "');" + Chr$(34)
  34.     Shell _Hide out$
  35.  

I've shared a few examples of this before in the past, but the project I was working on today was one which I thought could benefit from some decent Text-to-Speech capabilities, so I wrote up this little routine to give me a little more command over the output.

Choose from the voice you like -- male or female.  Set a speed for how fast they talk (valid range is -10 for slowest to 10 for fastest).  Send it some text and let it do it's thing.  It's that simple!

There's also a lazy man's SaP sub included for those who want to Speak And Print both at the same time. :P

Enjoy!

7
QB64 Discussion / A useful audio resource site
« on: January 25, 2022, 03:36:32 am »
For everyone who likes to add little tidbits of sound and such to their programs, I thought I'd share this little website for you guys:  https://evolution.voxeo.com/library/audio/prompts/

It's a collection of pre-recorded, royalty-free, open-license sound files which cover a whole lot of the things which I personally tend to make use of in various programs.  Letters, numbers, dates, currency, math, ect...   

With these, I've written spelling programs for children before, which toss an image of something onto the screen and then ask the child to Spell It!  (Example, a picture of a CAT appears on screen.)  If right, it praises the child.  If wrong, the program then goes on to specify.  "C"... "A"... "T"...   "This is a" "C"... "A"... "T"...  <pause for 2 seconds>...  "C"... "A"... "T"...   

Clocks can tell time with these (as illustrated above).  You can have currency amounts read out to you.  You can set up a calculator to read things back to you...   Lots of small little plug-in uses, and honestly, I think everyone should have this little archive somewhere on their computer. 

Only one issue which I've found with it -- and it's not with it, in particular, but with QB64 -- and that's with the fact that these are WAV files which we *should* be able to work with, but we can't.  You'll need to convert them to OGG or MP3 to fully make use of them in QB64 projects, but there's a ton of tools available out there to do so.  (Hint... Hint... VLC can convert file formats, last time I checked, and it's free, and almost everyone has a copy of it already...)



EDIT:  For those folks who can't be bothered to convert files as needed, I went ahead and did so here for everyone:   [ You are not allowed to view this attachment ]  

Note that I left the original WAV files in the archive as well, so if you end up deciding you don't need those, that'll reduce the size of your resource files by half.  (From 4 MB to 2... Woooo!!!   If 2 MB storage is an issue for you on modern systems, you need an upgrade! :P )

8
QB64 Discussion / A lesson on how to break QB64
« on: January 24, 2022, 01:31:18 pm »
A glitch which I learned about which basically just kills QB64 completely.... Can't save a file.  Can't compile a file.  Can't do anything until you close QB64 completely and restart it.

Step 1:  Make a directory.  I'll call mine "/foo"
Step 2:  Write a program and save it in that directory.   Mine is PRINT "Hello World", and I saved it as "HW.bas" inside "/foo".
Step 3:  Go to Windows Explorer and rename the "/foo" directory to "/whatever".

Congrats!!  QB64 will now explode and smoke and cry and refuse to do anything.  The IDE wants to save to "/foo", but there is no "/foo" on the drive anymore..  The linker wants to link to "/foo", but there is no "/foo"...  As far as I could tell, there was absolutely nothing that I could do with QB64 once "foo" became "whatever"...

The only solution to the issue is to completely shut down QB64 and restart it.  Once its got an invalid directory locked into memory, QB64 seems to refuse to let it go!

Just a funny quirk which I thought I'd share, and its not something which isn't easily worked around:  Simply don't rename the folder you're working from while working from it!  If you do, Qb64 goes, "Ummmm?????"

9
QB64 Discussion / Impossible Expanding Graphics
« on: January 23, 2022, 06:04:03 am »
@bplus and several other folks all like playing around with graphics a lot, so I thought I'd have a little fun and write a simple little graphic program to see who can sort out how the magic here works.

Here's the program:
Code: QB64: [Select]
  1. Screen _NewImage(1000, 1000, 32)
  2. Cls , -1
  3.  
  4. Circle (400, 400), 80, &HFF000000
  5. Paint (400, 400), &HFF000000
  6. Circle (400, 600), 80, &HFF000000
  7. Paint (400, 600), &HFF000000
  8. Circle (600, 600), 80, &HFF000000
  9. Paint (600, 600), &HFF000000
  10. Circle (600, 400), 80, &HFF000000
  11. Paint (600, 400), &HFF000000
  12. Circle (400, 400), 80, &HFF000000
  13. Paint (400, 400), &HFF000000
  14. Line (499, 300)-(501, 700), &HFF000000, B
  15. Line (400, 400)-(600, 600), -1, BF
  16.  
  17.     _PutImage (1000, 1000)-(0, 0) 'flip the bottom to the top
  18.     _Display
  19.     _Limit 30
  20.  

What this does is draw a simple little pattern on the screen for us, and then the DO...LOOP flips that pattern repeatedly from bottom to top, basically mirroring it for us.

And yet...

Something *magical* happens with this simple little patch of mirror code!!

Who wants to explain how it's doing what it's doing here?  I'm not giving any hints, and I encourage folks not to read anyone else's responses until they have a chance to try this out and see if they can sort out what's happening here on their own.

10
QB64 Discussion / InKey Codes vs KeyHit codes
« on: December 31, 2021, 02:18:51 am »
As I was discussing over at the Discord channels, here's a little tidbit about our key codes which a lot of people seem unaware of -- INKEY$ and _KEYHIT are the EXACT same codes!  The only difference is INKEY converts the codes to string format, while _KEYHIT keeps them as integer values.

To illustrate this, have fun pressing and holding keys down on your keyboard with the following code:

Code: QB64: [Select]
  1.     Cls
  2.     i$ = InKey$
  3.     k = _KeyHit
  4.     If Len(i$) > 1 Then '2 digit code
  5.         Print "INKEY$ = 0 + "; Asc(i$, 2); " or "; CVI(i$)
  6.     ElseIf i$ <> "" Then
  7.         Print "INKEY$ = "; Asc(i$); " or "; CVI(i$ + "0")
  8.     Else
  9.         Print "INKEY$ = NULL"; " or ERROR"
  10.     End If
  11.     Print "_KEYHIT = "; k; " or "; k Mod 256; k \ 256
  12.     _Limit 30
  13.     _Display
  14.  

If we use CVI (the QB64 command to convert a 2-byte string to an integer value) on INKEY$, we can see what values it gives us for any key pressed.

We can then compare those values to what KEYHIT gives us...

And, you guys might not believe this....

They're the *EXACT* same values.

There's no difference between INKEY$ and _KEYHIT except for the rather obvious one -- one returns the value as a 2-byte string while the other returns the value as a 2-byte integer. 

At their root, the only real difference between them is one is basically STR$(keycode) while the other is simply the VAL(keycode). 

NOTE:  (Actually it's a MKI$(keycode), but a lot of people are unfamiliar with converting numbers to strings with the MK$ commands, so I used STR$ in the previous sentence as *EVEYONE* tends to learn STR and VAL as some of their first commands with the language to help them highlight the difference between the INKEY$ values and KEYHIT values.)

11
QB64 Discussion / DECLARE LIBRARY adding extra slashes to paths
« on: December 15, 2021, 08:50:17 am »
  [ You are not allowed to view this attachment ]  

12
QB64 Discussion / Steve's Quick Lesson on Number TYPEs and Colors
« on: December 14, 2021, 12:53:47 am »
Code: QB64: [Select]
  1. Screen _NewImage(640, 640, 32)
  2. _Title "Number Types and Colors"
  3. Print "Welcome to Steve's Qucik Lesson on Number Types and Colors."
  4. Print "The most important thing to keep in mind in this lesson is that we're going to be talking exclusively about 32-bit color values here.  For all other screen modes, this lesson holds much less importance."
  5. Print "Press <ANY KEY> to begin!"
  6. Cls , 0
  7. Print "First, let's talk about how SINGLE variable types work (or DON'T work), in regards to 32-bit colors."
  8. Print "Let's choose a nice color and use it to draw a box on the screen."
  9. Print "How about we choose a BLUE box?  _RGB32(0, 0, 255)"
  10. Line (50, 90)-(250, 250), _RGB32(0, 0, 255), BF
  11. Locate 18, 1: Print "Looks like a nice BLUE box.  Right?"
  12. Print "Press <ANY KEY> to continue!"
  13. Cls , 0
  14. Print "Now, let's store that BLUE value inside a SINGLE tyoe variable."
  15. Print "BLUE = _RGB32(0, 0, 255)"
  16. Print "Once we've did that, let's draw the exact same box on the screen again with the variable."
  17. BLUE = _RGB32(0, 0, 256)
  18. Line (50, 90)-(250, 250), BLUE, BF
  19. Locate 18, 1: Print "Looks like a nice BLUE box.  Right?"
  20. Print "Press <ANY KEY> to continue!"
  21. Cls , 0
  22. Print "What do you guys mean, 'What box?'??"
  23. Print "Do you mean to tell me you nice folks DIDN'T see a pretty BLUE box on the last screen??"
  24. Print "Just what the hell happened to it?!!"
  25. Print "For the answer to that, let's print out two values to the screen:"
  26. Print "BLUE = "; BLUE
  27. Print "_RGB32(0, 0, 255) = "; _RGB32(0, 0, 255)
  28. Print "At first glance, those APPEAR to be the same numbers, but let's expand the      scientific notation fully:"
  29. Blue&& = BLUE
  30. Print "BLUE = "; Blue&&
  31. Print "_RGB32(0, 0, 255) = "; _RGB32(0, 0, 255)
  32. Print "Press <ANY KEY> to continue!"
  33. Cls , 0
  34. Print "HOLY COW, BATMAN!!  Was those two numbers DIFFERENT?!!"
  35. Print "BLUE = "; Blue&&; "vs"; _RGB32(0, 0, 255)
  36. Print "Well... They're only a LITTLE different...  Right?"
  37. Print "I mean, how bad can one little number difference be?  Right??"
  38. Print "For the answer to that, let's look at the HEX values of those numbers:"
  39. Print "BLUE = "; Hex$(Blue&&)
  40. Print "_RGB32(0, 0, 255) - "; Hex$(_RGB32(0, 0, 255))
  41. Print "And to help understand what we're seeing in HEX, break those values down into   groups of 2 in your mind."
  42. Print "(I'm too lazy to do it for you..)"
  43. Print "The first two values are ALPHA, followed by RED, followed by GREEN, followed by BLUE."
  44. Print "So  BLUE = FF alpha, 00 red 01 green, 00 blue"
  45. Print "_RGB32(0, 0, 0) = FF alpha, 00 red, 00 green, FF blue"
  46. Print "And keep in mine that FF is HEX for the decimal value of 255."
  47. Print "Press <ANY KEY> to continue!"
  48. Cls , 0
  49. Print "Since SINGLE values lose precision after numbers get so large, our variable BLUE"
  50. Print "has to round to the nearest scientific notation point and try for the closest"
  51. Print "possible match."
  52. Print "And even though "; Blue&&; " is only one number off from "; _RGB32(0, 0, 255); ","
  53. Print "that number still greatly changes the color value."
  54. Print "It changes it from FF 00 00 FF (255 alpha, 0 red, 0 green, 255 blue) to"
  55. Print "FF 00 01 00 (255 alpha, 0 red, 1 green, 0 blue)."
  56. Print "Our BLUE has become a GREEN, simply by using a SINGLE variable type!!"
  57. Print "(And, it's such a low shade green, my poor eyes can't make it out at all."
  58. Print "To me, the damn 'green box' was just as black as my black screen."
  59. Print "I didn't see it at all!)"
  60. Print "Press <ANY KEY> to continue!"
  61. Cls , 0
  62. Print "So, at this point, I think it should be obvious WHY we don't want to store"
  63. Print "color values inside SINGLE variables."
  64. Print "But what about using a normal LONG to hold the values??"
  65. Print "Let's look and see!"
  66. Print "For this, let's draw our box again:"
  67. Line (50, 150)-(250, 250), _RGB32(0, 0, 255), BF
  68. Locate 18, 1: Print "Looks like a nice BLUE box.  Right?"
  69. Print "But let's get the POINT value from that box, and store it in a LONG variable."
  70. BLUE& = Point(100, 200)
  71. Print "BLUE& = "; BLUE&
  72. p&& = Point(100, 200)
  73. Print "POINT(100, 200) = "; Point(100, 200)
  74. Print "Again, we're looking at two numbers that don't match!"
  75. Print "FOR THE LOVE OF GOD, WHYYYY??!!!!"
  76. Print "Press <ANY KEY> to continue!"
  77. Cls , 0
  78. Print BLUE&; "<>"; p&&
  79. Print "Why are those two numbers so different??"
  80. Print "For that answer, let's look at their HEX values again:"
  81. Print "BLUE& = "; Hex$(BLUE&)
  82. Print "POINT(100, 200) = "; Hex$(p&&)
  83. Print "."
  84. Print "..."
  85. Print "......"
  86. Print "WHAT THE HEX??  Those two values are EXACTLY the same??"
  87. Print "They are.  It's just that one of them is stored as a SIGNED LONG, while the     other is an UNSIGNED LONG."
  88. Print "HEX wise, they're the same value..."
  89. Print "BUT, can you see where the two numbers might not match if we use them in an IF  statement?"
  90. Print "IF "; BLUE&; "="; p&&; "THEN...."
  91. Print "Ummm...  That might not work as intended!"
  92. Print "Press <ANY KEY> to continue!"
  93. Cls , 0
  94. Print "Even thought the HEX values for "; BLUE&; "and"; p&&;
  95. Print "are EXACTLY the same, the values themselves are quite different."
  96. Print "A LONG will, indeed, hold the proper value for a 32-bit color, as it stores"
  97. Print "all four HEX values properly for us."
  98. Print "As long as our program uses NOTHING but LONG values, you'll never have a"
  99. Print "problem with using LONG as a variable type..."
  100. Print "BUT...."
  101. Print "The moment you start to compare LONG values directly against POINT values,"
  102. Print "your program is going to run into serious issues!"
  103. Print "Because at the end of the day,"; BLUE&; "is not the same as "; p&&
  104. Print "Press <ANY KEY> to continue!"
  105. Cls , 0
  106. Print "So, with all those examples, and all that said, let's answer"
  107. Print "the most important question:"
  108. Print "'What TYPE works best for 32-bit colors??"
  109. Print "DOUBLE, _FLOAT, _UNSIGNED LONG, _INTEGER64, _UNSIGNED _INTEGER64"
  110. Print "Of all the types which QB64 offers, only the above are TRULY viable"
  111. Print "to hold a 32-bit color value."
  112. Print "Any type not listed above is going to be problematic at one time or"
  113. Print "another for us!"
  114. Print "And of those suitable types, I personally prefer to keep integer values"
  115. Print "as integers, so I recommend: _UNSIGNED LONG or _INTEGER64."
  116. Print "Press <ANY KEY> to continue!"
  117. Cls , 0
  118. Print "And WHY _UNSIGNED LONG??"
  119. Print "Simply because it's only 4 bytes of memory (the minimal we can possibly use for"
  120. Print "32-bit color values), and it's what QB64 uses internally with POINT and such."
  121. Print "So, if _UNSIGNED LONG works so well, WHY would I *ever* use _INTEGER64??"
  122. Print "Becauses sometimes I like to code command values into my colors."
  123. Print "(Such as: NoColor = -1)"
  124. Print "_UNSIGNED LONG *only* holds the values for the colors themselves."
  125. Print "EVERY number from 0 to FFFFFFFF is accounted for as part of our color spectrum."
  126. Print "If I need *special* or unique values for my program, I usually just use _INTEGER64s"
  127. Print "for my variable types and then I can assign negative numbers for those unique values."
  128. Print "Press <ANY KEY> to continue!"
  129. Cls , 0
  130. Print "At the end of the day though, when all is said and done, you're still the"
  131. Print "one responsible for your own code!"
  132. Print "Use whichever type works for you, and works best for your needs."
  133. Print "Just keep in mind:  Various TYPEs come with various limitations on your code."
  134. Print "_BYTE, INTEGER, (both signed and unsigned) are insane to use..."
  135. Print "SINLGE loses precision.  Expect to lose whole shades of blue...."
  136. Print "LONG may cause issues with POINT, if compared directly...."
  137. Print "_UNSIGNED LONG works fine, any ONLY stores 32-bit color values...."
  138. Print "_INTEGER64 works fine, and can store extra values if necessary...."
  139. Print "DOUBLE and _FLOAT both work, but are floating point values...."
  140. Print "And with all that said and summed up, it's now up to YOU guys to decide what"
  141. Print "works best in your own programs."
  142. Print "As I said, I personally recommend _UNSIGNED LONG or _INTEGER64 in special cases."
  143. Print "But the choice, and the debugging, is entirely up to YOU.   :D"
  144.  

Copy.  Paste.  Compile.  I'll let the code speak for itself and hopefully it'll help folks learn a bit more about WHY certain variables are more suitable for use with 32-bit color values than others.  ;)









13
QB64 Discussion / What's your digital signature look like?
« on: November 30, 2021, 06:27:35 pm »
Just something I was playing around with, which I thought about adding to my little X-Mas program for folks who like to save their colored pictures and stuff -- a digital style "signature" which I'd post down in the corner of the page as a sort of little watermark for them. 

Code: QB64: [Select]
  1. Screen _NewImage(640, 480, 256)
  2.  
  3.     Cls
  4.     Input "Input your own name to make a signature!"; user$
  5.     If user$ = "" Then System
  6.     Signature user$, 320, 240
  7.     Do: _Limit 10: Loop Until _KeyDown(32)
  8.  
  9.  
  10. Sub Signature (user$, x, y)
  11.     PSet (x, y), Asc(user$, 1)
  12.     For i = 1 To Len(user$)
  13.         angle = _D2R((Asc(user$, i) - 65) * 360 / 57)
  14.         x1 = 25 * Sin(angle)
  15.         angle = _D2R((Asc(user$, i) - 65) * 360 / 57)
  16.         y1 = 25 * Cos(angle)
  17.         Line -Step(x1, y1), Asc(user$, i) ', BF
  18.     Next

  [ You are not allowed to view this attachment ]  

A pretty little scribble unique for each user!  ;)

14
Programs / Black and White Image Converter
« on: November 28, 2021, 01:30:59 am »
So, as you guys may have noticed in the discussion forum, I'm currently playing around and working with a little Xmas program which should have several little games in it.  The first "game" which I'm working on is a simple coloring book style program which lets you have fun and color, save, or print some Christmas pictures.  One glitch which I was hit with right off the bat is the problem with PAINT failing and coloring the whole dang screen at once.   The reason?? 

The images are grayscale and have multiple shades of black in them, which doesn't form a nice single color for either coloring or a border.   (It's always something to distract a person when trying to program, now ain't it!)

My solution:

Code: QB64: [Select]
  1.  WS = _NewImage(600, 360, 32)
  2.  
  3. ReDim As String D(0), F(0)
  4. GetLists "Coloring Sheets", D(), F()
  5.  
  6. For i = 1 To UBound(f)
  7.     image = _LoadImage("Coloring Sheets/" + F(i), 32)
  8.     _PutImage , image: _FreeImage image
  9.     _Dest CS: _Source WS
  10.     Sleep
  11.     For x = 0 To 599
  12.         For y = 0 To 359
  13.             r = _Red32(Point(x, y))
  14.             g = _Green32(Point(x, y))
  15.             b = _Blue32(Point(x, y))
  16.             If r > 200 Or g > 200 Or b > 200 Then PSet (x, y), &HFFFFFFFF Else PSet (x, y), &HFF000000
  17.         Next
  18.     Next
  19.     Sleep
  20.  
  21.  
  22.  
  23.  
  24. Sub GetLists (SearchDirectory As String, DirList() As String, FileList() As String)
  25.     Declare CustomType Library ".\direntry"
  26.         Function load_dir& (s As String)
  27.         Function has_next_entry& ()
  28.         Sub close_dir ()
  29.         Sub get_next_entry (s As String, flags As Long, file_size As Long)
  30.     End Declare
  31.  
  32.     Dim flags As Long, file_size As Long, DirCount As Long, FileCount As Long, length As Long
  33.     Dim nam$, slash$
  34.     ReDim _Preserve DirList(1000), FileList(1000)
  35.     DirCount = 0: FileCount = 0
  36.     $If WIN Then
  37.         slash$ = "\"
  38.     $Else
  39.         slash$ = "/"
  40.     $End If
  41.     If Right$(SearchDirectory$, 1) <> "/" And Right$(SearchDirectory$, 1) <> "\" Then SearchDirectory$ = SearchDirectory$ + slash$
  42.  
  43.     If load_dir(SearchDirectory + Chr$(0)) Then
  44.         Do
  45.             length = has_next_entry
  46.             If length > -1 Then
  47.                 nam$ = Space$(length)
  48.                 get_next_entry nam$, flags, file_size
  49.                 If _DirExists(SearchDirectory + nam$) Then
  50.                     DirCount = DirCount + 1
  51.                     If DirCount > UBound(DirList) Then ReDim _Preserve DirList(UBound(DirList) + 100)
  52.                     DirList(DirCount) = nam$
  53.                 ElseIf _FileExists(SearchDirectory + nam$) Then
  54.                     FileCount = FileCount + 1
  55.                     If FileCount > UBound(FileList) Then ReDim _Preserve FileList(UBound(FileList) + 100)
  56.                     FileList(FileCount) = nam$
  57.                 Else 'This else should never actually trigger
  58.                     Print: Print: Print "zzz...  Unknown file found: "; SearchDirectory; slash$; nam$, _DirExists(nam$)
  59.                     Beep: Sleep ' alert the user to
  60.                 End If
  61.             End If
  62.         Loop Until length = -1
  63.     End If
  64.     close_dir
  65.  
  66.     ReDim _Preserve DirList(DirCount)
  67.     ReDim _Preserve FileList(FileCount)
  68.  

Now, I can either SaveImage these into the world's smallest JPG/PNG (I can't imagine they'd be very large at all once compression hits with only 2 colors involved in each image), or I can just use the converter as is in my main program and transform those into two color images on the fly for my coloring app. 

With the two SLEEP statements in there, you can see the subtle difference as our almost-whites and almost-blacks end up turning into solid-whites and solid-blacks. 

I don't imagine there'll be any issues now with PAINT being able to find the proper borders for the images fill areas.  ;)

15
Code: [Select]
Declare Library ".\falcon"
    Sub uprint_extra (ByVal x&, Byval y&, Byval chars%&, Byval length%&, Byval kern&, Byval do_render&, txt_width&, Byval charpos%&, charcount&, Byval colour~&, Byval max_width&)
    Function uprint (ByVal x&, Byval y&, chars$, Byval txt_len&, Byval colour~&, Byval max_width&)
    Function uprintwidth (chars$, Byval txt_len&, Byval max_width&)
    Function uheight& ()
    Function uspacing& ()
    Function uascension& ()
End Declare

Simpy toss falcon.h into your QB64 folder, and download a fresh copy of the repo, and compile the above.  What I'm getting is the following set of error messages:

C:\Users\the_r\AppData\Local\Temp\ccjqRJ4V.o:qbx.cpp:(.text+0x838): undefined reference to `FT_Get_Char_Index'
C:\Users\the_r\AppData\Local\Temp\ccjqRJ4V.o:qbx.cpp:(.text+0x86c): undefined reference to `FT_Get_Kerning'
C:\Users\the_r\AppData\Local\Temp\ccjqRJ4V.o:qbx.cpp:(.text+0x88e): undefined reference to `FT_Load_Glyph'
C:\Users\the_r\AppData\Local\Temp\ccjqRJ4V.o:qbx.cpp:(.text+0x8b0): undefined reference to `FT_Render_Glyph'
C:\Users\the_r\AppData\Local\Temp\ccjqRJ4V.o:qbx.cpp:(.rdata$.refptr.fonts[.refptr.fonts]+0x0): undefined reference to `fonts'
collect2.exe: error: ld returned 1 exit status

It looks as if QB64 is now trying to get our Temp system folder and work with things from there, but it's failing to do so.  Is someone pushing changes to move the qb64 temp folders into the system Temp folders?  If they are, it appears as if they've missed a few links or some such somewhere.

Pages: [1] 2 3 ... 16