Author Topic: Steve's Video Tutorials  (Read 21325 times)

0 Members and 1 Guest are viewing this topic.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Steve's Video Tutorials
« Reply #75 on: November 07, 2019, 10:02:31 am »
Thank you for the sample code, it's getting dawn. My brain is slowly beginning to understand...

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Steve's Video Tutorials
« Reply #76 on: November 08, 2019, 03:24:21 am »
Video Tutorial #4 is now being uploaded into YouTube at:


This video now covers both REDIM _PRESERVE and mulit-dimensional offsets for use with _MEM, and like the last one, it comes in at about an hour and a half total view time.  I know these are rather longish view times, but I'm afraid that's just how long it takes for me to ramble and feel like I've properly covered the subject and illustrated the concepts involved in them.  For folks who just want the basic "Cliff Note" version of things, what you'll want to take home at the end of the day is these simple concepts:

Quote
'FINAL RULE:
'**ONLY** redim the right-most index when using REDIM _PRESERVE!!
'IF you need to redim **ANY** other index; you'll have to do it manually!!

Code: [Select]
FUNCTION Offset& (x, y)
    xsize = UBOUND(A, 1) - LBOUND(A, 1) + 1 'the number of elements in X
    Offset& = (y * xsize + x) 'Y * number of elements in X + X
END FUNCTION

FUNCTION ScreenOffset& (x, y)
    ScreenOffset& = (y * _WIDTH + x)
END FUNCTION

To understand WHY those are the important keynotes to remember and use, WATCH the video.  If you're not interested in WHY, then just remember and use those as they're presented and know, "that's just the way it is".  Either way, I hope what's here will help somebody, somewhere, understand and develop better habits to work with memory more efficiently in the future.



Future videos will be:

Covering the power of M.TYPE

Covering some of the other mem commands such as _MEMFILL and _MEMCOPY

Optimizing code to work more efficiently with _MEM, to make the most of its power

Maybe one of how I wish the makes of Reese's Pieces would go to Hell.  We have Halloween candy left over, and their damn wrappings are the type which I can't open EVEN WITH A KNIFE!!  I've never seen such a stupidly packaged product in all my life!  GRRRR!! *Somebody* needs to do a video on how stupid the things are!

But, until then:  Enjoy guys!

Note: Video is currently in processing with Youtube as still has an estimated 9 minutes left before it's available to view.  This is a HELLUVA difference from the 8-12 hours which I was faced with, with the last video (which was a comparable size and resolution).  My upload speed has went from 0.78MBS to almost 100MBS max speed.  (This comes in as a 1.8GB video, so you can see how big of a difference that makes for me!)

Once again, grab the popcorn, have a seat, and listen to me ramble.  Watch as  I baffle myself and wonder just where the BLEEP I screwed up once more, with the most basic of illustrationing...  And hopefully, at the end of the day, you'll end up understanding things more than I ended up confusing things...

All feedback, questions, and other such things are more than welcome below, or via personal email at: smcneill@swva.net (or the email button on the left of this post area).
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Steve's Video Tutorials
« Reply #77 on: November 09, 2019, 11:04:39 am »
And an image comparing my internet speeds, and why I waited for the swap before continuing my tutorials.

From 14mbs download to 150mbs+.

And from 0.78mbs upload to 150mbs+.

Over 10x faster download and 200x faster upload speeds!
7A0B6A09-1839-41D8-8A36-5D8024EEDEDA.png
* 7A0B6A09-1839-41D8-8A36-5D8024EEDEDA.png (Filesize: 308.8 KB, Dimensions: 1536x2048, Views: 460)
« Last Edit: November 09, 2019, 11:07:07 am by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: Steve's Video Tutorials
« Reply #78 on: November 19, 2019, 12:46:06 pm »
Thank you for the work you're doing on this. I'm getting a much better understanding of what seemed a very arcane subject when viewed in the wiki.

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Steve's Video Tutorials
« Reply #79 on: December 04, 2019, 08:06:00 am »
Steve, I've been distracted and not got around to #4, yet.  Will do so as soon as possible.

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Steve's Video Tutorials
« Reply #80 on: December 11, 2019, 07:50:20 am »
Steve, at last, I've got around to video #4.  Thank goodness that I'm never going to use REDIM _PRESERVE.  It's difficult enough trying to remember to count from the right without the difficulty of _MEM order being completey scrambled by non-righthand dimension increases.  Good luck to anybody having to change (increase) array dimension size.  If ever I had to do it, I'd use the cack-handed: ExistingArray(N%,M%), DIM TempArray(N%+1,M%), Copy all elements from Existing to Temp, REDIM ExistingArray(N%+1,M%), Copy all elements from Temp to Existing.  And that is precisely Steve's default manual method.  So, only those who have a regular need for redimming with increase of size will use REDIM _PRESERVE.  Will watch second half of video soon.  Keep them coming.
« Last Edit: December 12, 2019, 06:16:35 am by Qwerkey »

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Steve's Video Tutorials
« Reply #81 on: December 12, 2019, 07:15:45 am »
At last I've done #4.  Thanks Steve.  I had not previously considered the optimisations of FOR loops for _MEM processing.  I did not view #4 promptly as I was working on my Pi-in-the-Sky graphics program.  That program uses a great amount of _MEM processing of images.  I had to change R/G/B/Alpha values.  Fortunately I stumbled across the Offset = 4*(x+y*_WIDTH) formula, and am relieved to see that this is the correct form.

Incidentally, Steve, the reason why you ended up with 1 to 19 instead of 1 to 20 in your tutorial was that you typed two 8's before the 9.  A simple typo error.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Steve's Video Tutorials
« Reply #82 on: December 12, 2019, 08:10:28 am »
Incidentally, Steve, the reason why you ended up with 1 to 19 instead of 1 to 20 in your tutorial was that you typed two 8's before the 9.  A simple typo error.

Sometimes, it amazes me the way my poor brain works.  Often, I have absolutely no issues with the complicated stuff when programming, but it’s the simple things I just can’t seem to recognize.  I went over the code, and the video, several times, and never noticed the double 8’s.  My brain seems to know what things should be, and somehow does an automatic substitution for it mentally, and I’ll overlook a typo like that 100 times before smacking myself upside the head once I finally notice it.  I honestly had no idea why those damn comments didn’t count from 1 to 20!!  Many thanks for pointing out the solution to that mystery for me!  ;D

Just curious, but did the video help explain what REDIM _PRESERVE does, so that it makes sense?  A lot of people end up having problems with the command when working with multidimensional arrays, and I’m hoping the video helps clear up what it actually does for us, rather than just muddle the water and complicate things more for people.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Steve's Video Tutorials
« Reply #83 on: December 12, 2019, 10:21:47 am »
Sometimes, it amazes me the way my poor brain works.

Steve, I think that that is something common to us all.  When you expect something to be a certain way, you can look at the error many times and still not see it.  I had many such moments on my Pi-in-the-Sky coding: it wouldn't work properly and no matter how long I stared at the faulty line, it wouldn't click as to what was wrong.  I expect that the psychologists have a term for this: many students will have got PhD's on the subject.

As for the REDIM _PRESERVE explanation, yes that was all very clear (with the outputs of columns/rows and linear MEM positions).  But as you say, an occasional user of this will easily forget the precise behaviours in converting from Array to MEM.  That's why I will never use REDIM _PRESERVE.  My sort of work is highly unlikely to use changing arrays.

Offline EricE

  • Forum Regular
  • Posts: 114
    • View Profile
Re: Steve's Video Tutorials
« Reply #84 on: April 02, 2020, 06:19:56 pm »
Steve,
QB64 v1.4 is giving your tutorial #2 program a "Name already in use" error on line 44.

Code: QB64: [Select]

What has happened?
Has "White" become a reserved word now in version 1.4?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Steve's Video Tutorials
« Reply #85 on: April 02, 2020, 10:18:13 pm »
Maybe, if you have $COLOR set for your programs.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Steve's Video Tutorials
« Reply #86 on: April 02, 2020, 10:25:19 pm »
Maybe, if you have $COLOR set for your programs.  ;)

It is:

Code: [Select]
DIM White AS _UNSIGNED LONG
White = _RGBA32(255, 255, 255, 255)
PRINT "Hello World"
SLEEP
_MEMFREE m
m = _MEMIMAGE(0) '0 is the display screen.
$COLOR:32

With the latest versions of QB64, $COLOR:32 takes precedence for CONST values, causing the issue.  Originally, it allowed for custom values to be predefined first, as you see above, but it no longer does that.  The code needs a little tweaking to reflect the current version vs what the development build originally offered.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!