English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 27 July 2017, 12:16   #61
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
That's more or less it really. I don't know if you're a reader of Amiga Future, but these are the very topics I'm covering at the moment in the Blitz tutorial series - blitting methods and double buffering are coming up in the next issue, with scrolling, dual playfields and sprites the following issue. But the basics are:

0: n = 0
1: Draw graphics required to bitmap n
2: Wait for vertical blank
3: Display bitmap n
4: n = 1 - n ; swap n between 0 and 1
5: Goto 1

In this way, you never draw to the bitmap that's actually displayed on screen. This means you can take as long as you like drawing the next frame, and when it's ready put it on display and redraw the first one. You don't need separate screens to do this - just bitmaps, and using a variable (n in my example) means you don't have to have two separate bits of code for drawing the two frames; just Use Bitmap n and then draw as you need.

Triple buffering adds another buffer to the cycle so that your program can draw ahead without waiting for the second buffer to become displayed. But this is of limited use for typical Amiga games which generally run in sync with the vertical blank. Alternatively (and I think this is what idrougge is talking about), a third bitmap can be used to provide "fill-in" data when QBlit is used - sections of the third bitmap are copied back to the currently used bitmap when shapes are erased and re-blitted. This is similar to a buffered blit but gives you a bit more control.

Last edited by Daedalus; 27 July 2017 at 12:27.
Daedalus is offline  
Old 27 July 2017, 12:36   #62
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
Start a new thread and we'll talk.
idrougge is offline  
Old 28 February 2019, 17:01   #63
madaxe
Registered User
 
madaxe's Avatar
 
Join Date: Jan 2019
Location: Coimbra / Portugal
Posts: 54
Quote:
Originally Posted by Daedalus View Post
0: n = 0
1: Draw graphics required to bitmap n
2: Wait for vertical blank
3: Display bitmap n
4: n = 1 - n ; swap n between 0 and 1
5: Goto 1

Sorry to ask @Daedalus, but it should not be


3: n=1-n
4: Display bitmap n


Instead?
madaxe is offline  
Old 28 February 2019, 18:16   #64
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
No... Well, you can do it that way too, but you also need to adjust the other steps to suit. Specifically, you need to draw to bitmap 1-n then instead of bitmap n, since displaying bitmap n then drawing to it will defeat the whole purpose of doing double buffering.
Daedalus is offline  
Old 28 February 2019, 18:57   #65
rcman
Long time Amiga Owner
 
rcman's Avatar
 
Join Date: Jun 2017
Location: Uxbridge Canada
Age: 56
Posts: 182
Quote:
Originally Posted by Daedalus View Post
That's more or less it really. I don't know if you're a reader of Amiga Future, but these are the very topics I'm covering at the moment in the Blitz tutorial series - blitting methods and double buffering are coming up in the next issue, with scrolling, dual playfields and sprites the following issue. But the basics are:

0: n = 0
1: Draw graphics required to bitmap n
2: Wait for vertical blank
3: Display bitmap n
4: n = 1 - n ; swap n between 0 and 1
5: Goto 1

In this way, you never draw to the bitmap that's actually displayed on screen. This means you can take as long as you like drawing the next frame, and when it's ready put it on display and redraw the first one. You don't need separate screens to do this - just bitmaps, and using a variable (n in my example) means you don't have to have two separate bits of code for drawing the two frames; just Use Bitmap n and then draw as you need.

Triple buffering adds another buffer to the cycle so that your program can draw ahead without waiting for the second buffer to become displayed. But this is of limited use for typical Amiga games which generally run in sync with the vertical blank. Alternatively (and I think this is what idrougge is talking about), a third bitmap can be used to provide "fill-in" data when QBlit is used - sections of the third bitmap are copied back to the currently used bitmap when shapes are erased and re-blitted. This is similar to a buffered blit but gives you a bit more control.

Have anything posted to your tutorials?

RC
rcman is offline  
Old 28 February 2019, 19:39   #66
madaxe
Registered User
 
madaxe's Avatar
 
Join Date: Jan 2019
Location: Coimbra / Portugal
Posts: 54
Quote:
Originally Posted by Daedalus View Post
No... Well, you can do it that way too, but you also need to adjust the other steps to suit. Specifically, you need to draw to bitmap 1-n then instead of bitmap n, since displaying bitmap n then drawing to it will defeat the whole purpose of doing double buffering.
Thanks
I thought that was something like:

.Loop
Draw objects in BitMap 0
Wait for vertical blank
Display BitMap1
Draw objects in BitMap 1
Wait for vertical blank
Display BitMap 0
Goto Loop

When using a Dual PlayField the method is the same?
madaxe is offline  
Old 28 February 2019, 21:37   #67
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Quote:
Originally Posted by rcman View Post
Have anything posted to your tutorials?
Not sure what you mean there... I covered double buffering in the Amiga Future tutorials a good while back, issue 128 if that's what you mean?


Quote:
Originally Posted by madaxe View Post
Thanks
I thought that was something like:

.Loop
Draw objects in BitMap 0
Wait for vertical blank
Display BitMap1
Draw objects in BitMap 1
Wait for vertical blank
Display BitMap 0
Goto Loop

When using a Dual PlayField the method is the same?
That's very similar, but you don't want to be drawing shapes to a bitmap that's currently displayed. It will work fine if you're running smoothly at 50fps, but if any frame takes longer than a frame to draw, you'll get flicker and jitter in your shapes.
Daedalus is offline  
Old 01 March 2019, 15:07   #68
rcman
Long time Amiga Owner
 
rcman's Avatar
 
Join Date: Jun 2017
Location: Uxbridge Canada
Age: 56
Posts: 182
Quote:
Originally Posted by Daedalus View Post
Not sure what you mean there... I covered double buffering in the Amiga Future tutorials a good while back, issue 128 if that's what you mean?



That's very similar, but you don't want to be drawing shapes to a bitmap that's currently displayed. It will work fine if you're running smoothly at 50fps, but if any frame takes longer than a frame to draw, you'll get flicker and jitter in your shapes.
Sorry I've never heard of the Futures Tutorials. I looked that up, it comes up with a magazine. Is that what you're talking about?
RC
rcman is offline  
Old 01 March 2019, 17:03   #69
madaxe
Registered User
 
madaxe's Avatar
 
Join Date: Jan 2019
Location: Coimbra / Portugal
Posts: 54
Quote:
Originally Posted by Daedalus View Post
That's very similar, but you don't want to be drawing shapes to a bitmap that's currently displayed. It will work fine if you're running smoothly at 50fps, but if any frame takes longer than a frame to draw, you'll get flicker and jitter in your shapes.

Ahhhhhh, ok, that really makes sense
Thanks for your explanation @Daedalus, now I understand the concept about dual buffer
madaxe is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Color Saturation and Color Tint/Hue Retro-Nerd support.WinUAE 22 02 August 2018 10:38
Printing in color with WinUAE on color laser source support.Apps 7 14 April 2013 00:32
ISO true color to 256 color algorithm Lord Riton Coders. General 19 15 April 2011 17:49
New ShMUp, help required Marcuz project.Amiga Game Factory 3 28 June 2007 09:49
Cloudphobia (shmup) Dastardly Retrogaming General Discussion 0 07 November 2003 16:53

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 03:47.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.10947 seconds with 16 queries