Ultimate Amiga

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2]   Go Down

Author Topic: Screen Swap and Screen Offset timing  (Read 673 times)

adrazar

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 16
  • Generic Amiga User
Re: Screen Swap and Screen Offset timing
« Reply #15 on: October 05, 2017, 12:22:46 PM »

Quote
I'm lost  ;D
Thanks for letting me know! I think I understand what's unclear concerning both things you mention:
Quote
'do stuff
If Timer-T=0 Then Wait Vbl

Why for the heavens would you want to slow down artificially this routine by half to 25 pfs?  :o
Sometimes the "do stuff" part gets done within one vertical blank. If there were no artificially added wait between this and Screen Swap, the display would in these cases suddenly update at a 50 fps rate. This is undesirable as I want the game to run at a constant frame rate, hence the wait.
Quote
The example I showed you above works fluently at 50 fps and the change is seen... well, normally, as one would expect.

Frame:  Command:                   Offset:
1       Screen Offset 0,1,0       (0,0)
2       Screen Offset 0,2,0       (0,0)
3       Screen Offset 0,3,0       (1,0)
4       Screen Offset 0,4,0       (2,0)
5       Screen Offset 0,5,0       (3,0)
6       -                         (4,0)
7       -                         (5,0)
8       -                         (5,0)

This table illustrates the relation between calls to Screen Offset and what's being displayed on the screen for each of eight frames. The offset is lagging a frame behind what one would consider natural behaviour! Running 50 fps (like in the table) makes almost nothing out of this peculiarity, especially when scrolling at constant speed in one direction. But when trying to go 25 fps (like me), the change of buffer and change of offset happens on separate frames if this is not taken into account. A nasty shaking results. And of course it never occured to me that something like THIS could be the reason! That is, until I suddenly had a stroke of luck... :)

The program that put me on the right track was based on your example (most notably the Box):
Code: [Select]
Screen Open 0,640,200,16,Lowres
Screen Display 0,128,50,320,200
Flash Off : Curs Off : Cls 0
Box 0,0 To 319,199

Double Buffer : Autoback 0
For X=0 to 320
   Plot X,1
   Screen Offset 0,X,0
   Screen Swap : Wait Vbl
Next X
Isn't that point a litte far to the right... ???
« Last Edit: October 05, 2017, 12:45:57 PM by adrazar »
Logged

Umpal

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 31
  • Programming and graphic
Re: Screen Swap and Screen Offset timing
« Reply #16 on: October 08, 2017, 06:38:19 PM »

Quote
(...) I want the game to run at a constant frame rate, hence the wait.

That explains everything (in this matter  ;)). Well, eager to see your final product! Keep up the good work mate.
Logged
Pages: 1 [2]   Go Up