English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. AMOS

 
 
Thread Tools
Old 25 July 2020, 16:48   #1
Brick Nash
Prototron

Brick Nash's Avatar
 
Join Date: Mar 2015
Location: UK
Posts: 297
Getting screen flicker on my HUD screen

I'm having a little bother managing my screens. The HUD screen I have is flickering like crazy and I've no idea why. It's odd because the flickering parts are Bobs, but the Yellow outline to the screen and the actual yellow health bars are a drawn Box and a Bar which don't seem to be affected.

[ Show youtube player ]

If I take out the player and enemy procedures from the main loop it seems to help, but I'm unsure why they are affecting what's on the HUD screen.

It may be how I'm organising my main loop, which is something like this:

Code:
Do
Wait VBL
Screen 1
Proc Screen 1 Update Stuff (Healthbars, Timer, Lives etc)
Screen 2
Main Game Stuff (The actual game screen: Players, enemies, priority etc.)
Loop
It may be some sort of issue with Double Buffering, but I don't really know how to handle that with two screens.

I'm kind of stuck, so any help would be great! Thanks.
Brick Nash is offline  
Old 26 July 2020, 15:20   #2
adrazar
Registered User

 
Join Date: Feb 2017
Location: Oslo
Posts: 51
The Double Buffer command only works on the current screen, so if you need several double buffered screens you need to call Double Buffer once for each of them. If I'm not mistaken the flickering is due to one such missing Double Buffer statement.

I think it is unnecessary to double buffer the HUD screen though, because you don't really need Bobs in it. Paste the images once during setup instead, and update the time and health bar whenever the game data differs from the displayed data (i.e. compare the game data with a dedicated variable for the currently displayed health of each player, the currently displayed time, etc.).
adrazar is offline  
Old 27 July 2020, 12:22   #3
Brick Nash
Prototron

Brick Nash's Avatar
 
Join Date: Mar 2015
Location: UK
Posts: 297
Quote:
Originally Posted by adrazar View Post
The Double Buffer command only works on the current screen, so if you need several double buffered screens you need to call Double Buffer once for each of them. If I'm not mistaken the flickering is due to one such missing Double Buffer statement.

I think it is unnecessary to double buffer the HUD screen though, because you don't really need Bobs in it. Paste the images once during setup instead, and update the time and health bar whenever the game data differs from the displayed data (i.e. compare the game data with a dedicated variable for the currently displayed health of each player, the currently displayed time, etc.).
Thanks for the reply. Yeah I was figuring it was the Double Buffer system as I couldn't work out how to efficiently apply it to two screens, and when I applied Double Buffer to both it slowed the game down.

That's good to know about the HUD screen. I'm kind of guessing what to do as I've never handled any kind of panel/score/timer screen before.

So would it be like just some timers in the main loop which triggers a clear and re-draw of the screen when necessary? Maybe call a procedure?

EDIT: Yep it's working now. Just calling the procedure to update info and re-draw when needed. It's a teeny bit flickery although almost unnoticeable, but I'm just using the automatic Double Buffer setting so I may try experimenting with doing it manually.

Last edited by Brick Nash; 27 July 2020 at 19:12.
Brick Nash is offline  
Old 27 July 2020, 21:20   #4
adrazar
Registered User

 
Join Date: Feb 2017
Location: Oslo
Posts: 51
The central idea which I failed to communicate (oops), is that you never need to clear the entire HUD screen at any time during the game loop. Instead you can just modify small bits of it whenever a change occurs, for example by applying Bar to the end of a health bar to make it shorter.

When and how to check for changes? I imagined you could keep the same basic program structure as you showed in the first post, and let the check for changes be done in a procedure/gosub HUDSCREEN at "Update Stuff". Changes are detected by comparing the game variables with a duplicate set of variables managed by HUDSCREEN. A little example to clarify:

Code:
Dim HEALTH(4) : Rem Remaining health of each player
Dim HUDHEALTH(4) : Rem Duplicate of HEALTH(), managed by HUDSCREEN

HUDSCREEN:
If HEALTH(1)<HUDHEALTH(1)
   HUDHEALTH(1)=HEALTH(1) : Rem  Dec HUDHEALTH(1) for a gliding reduction
   'Update the Health Bar of Player 1 [to match HUDHEALTH(1)]
End If
'Repeat the above code for each active Health Bar
Return
Maybe you got this already as I see you've sorted out the flickering now.

An easy thing to try as remedy against the remaining slight flicker is to switch the order of Update Stuff and Main Game Stuff in the game loop. (Where the idea is that the video beam gets time enough to travel below the HUD screen before Update Stuff starts messing with it).
adrazar is offline  
Old 29 July 2020, 11:27   #5
Brick Nash
Prototron

Brick Nash's Avatar
 
Join Date: Mar 2015
Location: UK
Posts: 297
Quote:
Originally Posted by adrazar View Post
The central idea which I failed to communicate (oops), is that you never need to clear the entire HUD screen at any time during the game loop. Instead you can just modify small bits of it whenever a change occurs, for example by applying Bar to the end of a health bar to make it shorter.

When and how to check for changes? I imagined you could keep the same basic program structure as you showed in the first post, and let the check for changes be done in a procedure/gosub HUDSCREEN at "Update Stuff". Changes are detected by comparing the game variables with a duplicate set of variables managed by HUDSCREEN. A little example to clarify:

Code:
Dim HEALTH(4) : Rem Remaining health of each player
Dim HUDHEALTH(4) : Rem Duplicate of HEALTH(), managed by HUDSCREEN

HUDSCREEN:
If HEALTH(1)<HUDHEALTH(1)
   HUDHEALTH(1)=HEALTH(1) : Rem  Dec HUDHEALTH(1) for a gliding reduction
   'Update the Health Bar of Player 1 [to match HUDHEALTH(1)]
End If
'Repeat the above code for each active Health Bar
Return
Maybe you got this already as I see you've sorted out the flickering now.

An easy thing to try as remedy against the remaining slight flicker is to switch the order of Update Stuff and Main Game Stuff in the game loop. (Where the idea is that the video beam gets time enough to travel below the HUD screen before Update Stuff starts messing with it).
That's a great idea. I'll have a look at re-organising stuff so that it has time to do updates instead of darting back.

Thanks!
Brick Nash 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
A1200 screen flicker ItsTheSmell support.Hardware 3 18 May 2019 13:35
Screen flicker on floppy access gazj82 support.Hardware 5 11 April 2016 02:14
Amiga 600 not booting... Yellow screen, and Red screen when turning PSU off jbenam support.Hardware 34 20 March 2011 23:10
DCE: Flicker Magic screen modes Mick_AKA support.Hardware 6 16 June 2005 05:42
Who here has the dodgy A1200 with screen flicker? Bloodwych Retrogaming General Discussion 0 30 December 2001 23:36

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 17:51.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Page generated in 0.06672 seconds with 15 queries