Game development using C and sys functions, double buffer problem
Hi.
I'm working on my game engine again, and I have performance problems when it runs on stock A600 (whithout acceleration) with Kickstart 2.0. For this system the double buffer is implemented doubling the height of screen and performing a ScrollVPort to the actual frame. When I use this trick, the frame rate drops to the 50%, 25 fps only. Any idea about why this problem occurs? If I don't use double buffering, I have tried also a basic example blitting a tilemap with vertical scroll from my engine, and there isn't enough time every frame to draw it using amigaos functions, and it only makes a few blittings every frame, it blit the next tile row meanwhile the scroll is running, not a complete row, I must forget something, it's a simple tilemap. Code:
#include <stdlib.h> |
I got the answer, one view, two bitmaps, creating two copperlist for each bitmap and changing the copper list of the view every frame, as explained here, good reading indeed:
https://wiki.amigaos.net/wiki/Classi...ffered_Display Here is my implementation of this double buffer technique, it works on AOS 2.0 running at 50 fps.Anyway, any attempt to call ScrollVPort decreases performance at 25 fps, so this technique will not give you 50 fps for games that use scroll, I do not know if this is the best you can get using the system functions. Code:
#include <stdlib.h> |
Ahaha, amazing.
I was about to answer, but you finally found a technique that is far more efficient than everything I tried. As you probably know, there is no official support for double buffering in AmigaOS 1.3/2.0. In my own project (an adventure game for the OCS range of Amigas), I'm using the MakeScreen()/RethinkDisplay() technique, but it is known for being the slowest method ever (the autodocs say RethinkDisplay() takes milliseconds). The ScrollVPort() trick is supposed to be faster, but as the source code of this 3.1 version is approx. 300 lines of asm, so I guess this might be why it is a bit slower than what we expected :) for the records, here is my double buffer routine (works on AmigaDOS1.3, but hell, it is SO SLOW) : Code:
void flipBuffers(buffered_screen *screen) |
RethinkDisplay is probably one of the worst options for games. My code doesn't run under AmigaOS 1.3, but I will take a look to see if it can work.
|
just some additional info:
ScrollVPort(&screen->ViewPort); is calling WaitBOVP(&screen->ViewPort); so a WaitTOF(); after that might be the cause to skip a frame. And there is this comment to WaitBOVP(&screen->ViewPort);: Quote:
|
Alternatively it's possible to open two screens and perform the frame flipping with ScreenToFront -- if the game does not need to multitask.
But under OS i would rather use a back-buffer (i.e. mem copy to do the refresh). This is better for performance if only part of the screen needs updating. |
Quote:
ScreenToFront is calling RethinkDisplay |
Quote:
And, of course, this doesn't seem to be working :( (not to mention that audio also is very hard to keep in sync with audio.device, but this is a separate topic). Before I go back to killing the OS (seems the only viable alternative), is there anything I might be missing? This is roughly the main loop: Code:
// Use the currently loaded buffer Code:
inline void swapBuffers(struct DoubleBufferGfxData* dblBufferData, UWORD buffer, UWORD* palette) { Is there a way to have proper colour reload? Maybe using custom copper lists? (which basically would get me closer to not using the OS...). EDIT: it seems that investigating the ViewPort structure led me to the solution. I added this to the code above: Code:
viewPort->DspIns = dblBufferData->dspIns[buffer]; |
All times are GMT +2. The time now is 03:39. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.