LB Booster
« Card graphics not sticking »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:52am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1 ... 3 4 5  Notify Send Topic Print
 veryhotthread  Author  Topic: Card graphics not sticking  (Read 153 times)
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Card graphics not sticking
« Reply #60 on: May 29th, 2016, 10:37pm »

on May 29th, 2016, 8:12pm, tsh73 wrote:
It is a quick way to move piece of code away.

I can think of only two reasons why you would ever want to "move a piece of code away". The first is when the same functionality is duplicated in two (or more) places in your program, so it is more efficient to create a 'shared' subroutine that can be called from both places. The second is when a section of code performs some relatively complex self-contained operation, which would make the program harder to read and understand if it is coded 'inline'.

In the first case it is important that the 'shared' subroutine can be called from multiple places without imposing artificial constraints on the calling code. For example it may make no sense for the two or more different places in the program to use the same variable names for the subroutine's inputs and outputs.

In the second case it is important that the calling program can be read and understood in isolation, without the detailed implementation of the subroutine being known. In particular the subroutine must not have unwanted 'side effects' such as modifying the values of variables that the calling code may be using.

Crucially, in both cases only a SUB (or a FUNCTION) meets these requirements. The inputs and outputs need not have the same variable names in the different places from which it is called, and any 'temporary' variables used within the subroutine are independent of those outside.

So my firm opinion is that GOSUB should never ever be used in a program written today. The sole purpose of GOSUB is to make it easier to port a legacy program that was originally written for an ancient version of BASIC that had no other kind of subroutine.

Richard.
User IP Logged

michael
New Member
Image


member is offline

Avatar




PM


Posts: 28
xx Re: Card graphics not sticking
« Reply #61 on: May 30th, 2016, 11:54pm »

There is of course these commands too that allow you to do draws behind the scenes and show the draws at will.

These are built into LBB but have BBC Basic origin
Just passing on what Richard sent me for off screen draws.

!*refresh off
!*refresh on
!*refresh

refresh off turns off the automatic refresh
refresh refreshes the screen and shows the updated draws
refresh on returns the automatic refresh to automatic.

We may as well offer this since it is a part of LBB.. (but is not a part of LB. So you wont be able to share such code in LB forums.
« Last Edit: May 31st, 2016, 12:24am by michael » User IP Logged

I make program generators and some utilities. Its my hobby
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Card graphics not sticking
« Reply #62 on: May 31st, 2016, 08:23am »

on May 30th, 2016, 11:54pm, michael wrote:
There is of course these commands too that allow you to do draws behind the scenes and show the draws at will.

Except that they only work when drawing graphics into the mainwin, so are not generally useful.

The easiest way to achieve 'flicker free' animated graphics in LBB (other than using sprites) is to use the normal JB/LB commands but to put them all - including the initial CLS - into a single string. That makes the best use of LBB's double-buffering:

Code:
    timer 40, [animate]
    wait
    
[animate]
    g$ = "cls;"
    g$ += "<graphics commands>;"
    g$ += "<more graphics commands>"
    #g g$
    wait 

By concatenating all the graphics commands for one 'frame' into a single string (sadly you can't do that if text is included) you avoid the possibility of Windows refreshing the screen when the graphics are only partly drawn, which is what results in flickering.

There may still be some 'tearing' (because the drawing isn't synchronized with the display refresh rate) but with care you can get good results this way.

Richard.
User IP Logged

Pages: 1 ... 3 4 5  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls