Author |
Topic: Card graphics not sticking (Read 160 times) |
|
Turtleman
New Member
member is offline


Gender: 
Posts: 29
|
 |
Re: Card graphics not sticking
« Reply #8 on: May 14th, 2016, 6:47pm » |
|
I can't believe I didn't know about hiding the GUI using stylebits and a show statement. (Didn't need to use a timer.) I've been doing crazy things in LB such as initially positioning off screen. This is a whole lot easier! Anyway, I got one of the windows behaving under LBB and will start on another. Or on second thought, maybe I'll postpone that and see if I can get the main program running faster. Oh, and changing the icon is a heck of a lot simpler. Thanks again and have a great weekend!
|
| « Last Edit: May 14th, 2016, 6:48pm by Turtleman » |
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Card graphics not sticking
« Reply #9 on: May 14th, 2016, 8:06pm » |
|
on May 14th, 2016, 6:47pm, Turtleman wrote:| Didn't need to use a timer. |
|
The delay was just to show that something out-of-the-ordinary was happening.
Quote:| Oh, and changing the icon is a heck of a lot simpler. |
|
Unlike LB, LBB supports multi-format icons (where the .ICO file contains several icons in different sizes and color depths) which can for example result in a high quality 256x256 image being used on a high-DPI screen.
Richard.
|
|
Logged
|
|
|
|
Turtleman
New Member
member is offline


Gender: 
Posts: 29
|
 |
Re: Card graphics not sticking
« Reply #10 on: May 15th, 2016, 11:21am » |
|
Good morning - and time for my stupid questions of the day!
Going back to the simple QCard example (minus the playwave and pause statements to speed things up), is there a way of using "call BlitBack hBox, 700, 440" instead of flush statements in LB to restore the screen after its been minimized? Without flush statements, the graphics disappear, unlike in LBB.
The 700 and 440 parameters evidently correspond to the graphicbox's dimensions, but larger numbers seem to work as well. It's not a big deal, but is there a downside for using larger numbers so the same call BlitBack statement can be kept consistent throughout the program when used with different size graphicbox's?
I've been using the LB Workstation for development for its ease of use and line statements. Unfortunately, I can't seem to redirect the paths under Preferences to send the program to LBB instead of LB. Is there a trick for doing that? It would be great to at least have line numbers on LBB. I see there are numbers on the LBB pane, but it doesn't display the exact same code.
Whoops - false alarm! I just saw the 09/18/2013 post "Using Liberty BASIC Workshop with LBB" and must have goofed before. It's now working with Workshop.
Sorry if my other questions are confusing. Thanks!
|
| « Last Edit: May 15th, 2016, 3:09pm by Turtleman » |
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Card graphics not sticking
« Reply #11 on: May 15th, 2016, 3:25pm » |
|
on May 15th, 2016, 11:21am, Turtleman wrote:| Without flush statements, the graphics disappear, unlike in LBB. |
|
Why would you want to do it a "different way"? FLUSH is the method LB uses to cause graphics to 'stick'; a rather unsatisfactory method in my opinion, but there it is. So if you want to retain compatibility with LB keep the FLUSH statements, LBB won't mind.
Quote:| It's not a big deal, but is there a downside for using larger numbers so the same call BlitBack statement can be kept consistent throughout the program when used with different size graphicbox's? |
|
Only Microsoft could answer that question. There may be a cost in 'clipping' the rectangle to the size of the window, or there may not. You could try profiling it!
Quote:| Whoops - false alarm! I just saw the 09/18/2013 post "Using Liberty BASIC Workshop with LBB" |
|
There's also this Wiki article.
Richard.
|
|
Logged
|
|
|
|
Turtleman
New Member
member is offline


Gender: 
Posts: 29
|
 |
Re: Card graphics not sticking
« Reply #12 on: May 15th, 2016, 3:37pm » |
|
Thanks Richard. May I safely assume that LBB totally ignores flush statements? I love that LBB doesn't need them, but is there any downside to keeping them in the code to retain compatibility with LB?
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Card graphics not sticking
« Reply #13 on: May 15th, 2016, 5:06pm » |
|
on May 15th, 2016, 3:37pm, Turtleman wrote:| May I safely assume that LBB totally ignores flush statements? |
|
No. I explained previously that FLUSH still has a function in LBB when paired with REDRAW; it is not ignored. The LBB Help file describes what each statement does, including FLUSH.
Richard.
|
|
Logged
|
|
|
|
Turtleman
New Member
member is offline


Gender: 
Posts: 29
|
 |
Re: Card graphics not sticking
« Reply #14 on: May 15th, 2016, 5:19pm » |
|
I probably shouldn't have said "totally ignores." However, it's my understanding that an abundance of flush statements consume memory in LB and was wondering if keeping them in the code when using LBB (only to maintain compatibility) also consumes resources. In other words, will it make any difference if the flush statements are left in or removed?
And I'm still unsure if there's a good way of restoring a graphics screen using LB after the window has been minimized if flush statements are removed. I'm obviously a confused code writer, but am slowly figuring it out. Thanks!
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Card graphics not sticking
« Reply #15 on: May 15th, 2016, 6:58pm » |
|
on May 15th, 2016, 5:19pm, Turtleman wrote:| it's my understanding that an abundance of flush statements consume memory in LB and was wondering if keeping them in the code when using LBB (only to maintain compatibility) also consumes resources. |
|
Cumulative resources, no. There's no requirement, as there is in LB, to use CLS or DELSEGMENT to avoid a constantly increasing use of memory.
Quote:| And I'm still unsure if there's a good way of restoring a graphics screen using LB after the window has been minimized if flush statements are removed. |
|
A question for an LB expert, which isn't me (and arguably questions about LB are off-topic here).
Richard.
|
|
Logged
|
|
|
|
Turtleman
New Member
member is offline


Gender: 
Posts: 29
|
 |
Re: Card graphics not sticking
« Reply #16 on: May 15th, 2016, 7:04pm » |
|
Got it! So for now, I might as well keep the flushes just to maintain compatibility until I get everything working in LBB. It's a lot easier dealing with single versions of code.
I'm now trying to figure out why the program is running much slower in LBB than LB even when the graphic windows aren't opened. Way too much code to post, but will get to the bottom of it eventually. Appreciate all your help.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Card graphics not sticking
« Reply #17 on: May 15th, 2016, 8:15pm » |
|
on May 15th, 2016, 7:04pm, Turtleman wrote:| I'm now trying to figure out why the program is running much slower in LBB than LB even when the graphic windows aren't opened. |
|
I've never suggested that LBB is suitable for all programs; it clearly isn't. Some programs rely on features that LBB doesn't have (e.g. arbitrary precision integer arithmetic or graphics segments), others rely on undocumented features of LB that I either don't know about or can't easily emulate, and some make heavy use of non-standard features that have to be emulated at run-time and are therefore very slow.
It sounds as though your program falls into that last category, so - especially considering what you have said about FLUSH - this is probably one of those rare occasions when it would be more sensible to stick with LB.
Richard.
|
|
|
|
Turtleman
New Member
member is offline


Gender: 
Posts: 29
|
 |
Re: Card graphics not sticking
« Reply #18 on: May 15th, 2016, 8:24pm » |
|
I appreciate your input. Slower is just one of the problems. There are 8 selectable windows in addition to the main one, and when I try to open a particular one, I get an error "Couldn't create bitmap at line 0" Line zero? I don't have a clue what that means, especially since that particular window doesn't even use any bitmaps! Maybe that's a clue, but I don't have the foggiest what's going on. I hate to give up this early in the LB to LBB game, and I'll report back if I ever figure it out. All the other windows and overall program runs normally, albeit very slowly. Very confusing.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Card graphics not sticking
« Reply #19 on: May 16th, 2016, 08:39am » |
|
on May 15th, 2016, 8:24pm, Turtleman wrote:| I get an error "Couldn't create bitmap at line 0" Line zero? |
|
Line zero simply means that the error isn't occurring in your BASIC program but (probably) in the LBLIB emulation library. In an ideal world that code ought not to raise such errors, but I know there are circumstances when it can.
What version of Windows are you running? A "Couldn't create bitmap" error used to be more common in Windows XP because all DCBs (Device Compatible Bitmaps) are allocated from quite a small pool on that version, and it wasn't that difficult to use up all the available memory. But on Windows Vista and later much more memory is available for DCBs.
If you're running a machine that is infrequently rebooted (such as a laptop) that can also increase the likelihood of running out of bitmap memory, because crashed programs that don't correctly clean up after themselves can gobble it up. So try rebooting the PC and running the program again.
I assume the windows you are referring to don't create ridiculously big bitmaps (as they might if you specified large limits in a HORIZSCROLLBAR or VERTSCROLLBAR command). Remember that LBB is double-buffered, so makes much heavier use of bitmaps than LB.
Clearly it would be worth tracing the cause of this error, in the unlikely event that it's a bug in LBB. But if your program runs slowly that's another matter - where does the Profiler say the time is primarily being spent?
Richard.
|
|
|
|
Turtleman
New Member
member is offline


Gender: 
Posts: 29
|
 |
Re: Card graphics not sticking
« Reply #20 on: May 16th, 2016, 12:58pm » |
|
Richard: I've (almost) concluded that the main reason I'm having difficulties running my LB program in LBB is, for lack of a better explanation, sloppy coding! When I started the project several years ago, I didn't have a clue how to program. And while I got the program to run, it was pure unadulterated spaghetti code. I did a major rewrite a couple years ago, broke things into more manageable subroutines, and improved speed and reliability significantly. But now that I'm troubleshooting to get it to play nicely with LBB, I'm seeing that the code is still heavily convoluted in many areas. Hopefully, I know a lot more about programming now than I did a couple years ago (and even a couple days ago), so once again I'm going to try rewriting the entire program using more standalone modules. Being able to test as I go in LB and LBB should reveal any incompatibilities and result in a cleaner program.
Eventually, I'd like it to run on Apple and Android devices, and looked into using a more compatible language. I even began playing with Python and just stumbled across BBC Basic, but I'm afraid the learning curve could exceed my life expectancy. So while LB may not be the ideal language, at least I'm more familiar with it than anything else. Any suggestions besides giving up would be welcome!
Thanks again for your help and I'll be sure to post the results of the "new and improved" LBB-compatible program.
|
| « Last Edit: May 16th, 2016, 1:00pm by Turtleman » |
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Card graphics not sticking
« Reply #21 on: May 16th, 2016, 4:59pm » |
|
on May 16th, 2016, 12:58pm, Turtleman wrote:| Any suggestions besides giving up would be welcome! |
|
It all depends on how much of your program is 'GUI' stuff (graphics/controls/sprites) and how much is 'computational' stuff (arithmetic, string manipulation, file handling, sound and so on).
As I explained before, LB/LBB rely heavily on the Windows API for GUI functionality. If your program makes extensive use of GUI elements then that's the principal concern as regards porting to other platforms - irrespective of what programming language is used.
Apart from Windows itself, only Wine provides a high degree of compatibility with the Win32 API. That at least gives you a route to porting your program to Linux (86) and to Mac OS-X, because both those platforms are well supported by Wine.
Otherwise it's going to mean replacing all the GUI aspects of your program with something more generic. Only you know how practical that would be.
Richard.
|
|
Logged
|
|
|
|
Turtleman
New Member
member is offline


Gender: 
Posts: 29
|
 |
Re: Card graphics not sticking
« Reply #22 on: May 21st, 2016, 10:09am » |
|
It's feedback time! I cut the program's 37K lines of code down to 2.4K in an attempt to get one common section of code running in LBB at a time. Interestingly, one of the displays was "flickering" several times in LBB when opening a new window, but wasn't flickering when running in LB. It took some time; but as it turns out, I was doing several redundant reads from the hard drive that went unnoticed in LB, but was very evident in LBB. This particular routine is only active when opening a certain segment of code and won't slow down normal operation, but there are undoubtedly other inefficiencies in the rest of the program that I'll be looking into.
I really like the fact that making an executable is so much easier in LBB, along with eliminating a zillion flush statements, so I have a high incentive to continue the investigation. More as I go.
|
|
Logged
|
|
|
|
|