Rtl Foreground: Difference between revisions

From Uzebox Wiki
Jump to navigation Jump to search
Line 11: Line 11:
*-DRTL_VSYNC_WAIT - specify 0 to stop processing effects early, or 1 to WaitVsync(1) then continue with effect.
*-DRTL_VSYNC_WAIT - specify 0 to stop processing effects early, or 1 to WaitVsync(1) then continue with effect.


I highly recommend you first try WITHOUT either switch. If you are having problems try reducing ram usage, and free up some extra cycles with -DFIRST_RENDER_LINE. See rtl_Primer for more information on extra cycles. Unfortunately if you do not have enough time, it will likely have a poor visual result. Surprisingly, this works with not much extra time so generally this will be a non-issue. Enough talk, let's see some code. These are the functions you will be using:
I highly recommend you first try WITHOUT either switch. If you are having problems try reducing ram usage, and free up some extra cycles with -DFIRST_RENDER_LINE. See rtl_Primer for more information on extra cycles. Unfortunately if you do not have enough time, it will likely have a poor visual result. Fortunately though, this works with not much extra time so generally this will be a non-issue. Enough talk, let's see some code. These are the functions you will be using:


*void rtl_SetForeground(const uint8_t * map, const uint8_t * tiles, uint8_t start, uint8_t end)
*void rtl_SetForeground(const uint8_t * map, const uint8_t * tiles, uint8_t start, uint8_t end)
**This sets the parameters of your foreground. The first argument is a pointer to a map(at least the size of the screen area sprites can move on). The second argument is a pointer to the actual graphics data you will use for the foreground. This is in the same standard format as other 8bpp Uzebox graphics, and you can use the same tools you use normally to prepare the data. The third argument declares the first tile index that will be considered a foreground. So if for instance a sprite is on top of tile 20 and start is declared as 10, the 10th tile in the foreground tiles will be blitted over the sprite at that location(20-start make sense?). End similarly declares the last tile index that is considered foreground. To disable using foreground maps, simply set map to NULL. To disable the use of indexed foreground simple set start and end to 0.
**This sets the parameters of your foreground.  
***const uint8_t *map-a pointer to a map representing the foreground(at least the size of the screen area sprites can move on).  
***const uint8_t *tiles-a pointer to the actual graphics data you will use for the foreground. This is in the same standard format as other 8bpp Uzebox graphics, and you can use the same tools you use normally to prepare the data.
***uint8_t start-declares the first tile index that will be considered a foreground. So if for instance a sprite is on top of tile 20 and start is declared as 10, the 10th tile in the foreground tiles will be blitted over the sprite at that location(20-start make sense?).  
***uint8_t end-similarly, declares the last tile index that is considered foreground. To disable using foreground maps, simply set map to NULL. To disable the use of indexed foreground simple set start and end to 0.

Revision as of 01:55, 13 December 2011

Foreground Effects For Uzebox

With rtl_Foreground there is now an easy and standard way to create objects your sprites can hide behind. This introduces a level of depth to your game's visuals, and perhaps can even be used as a gameplay element. Let's take a look at what we're talking about.

Foreground1.png

See those deadly bunnies hiding in wait for their victims? Looks pretty good eh? So, let's see how simple it is to add this functionality to your game!

Using rtl_Foreground

rtl_Foreground consumes only a few extra bytes of ram, minimal code space, and a moderate amount of cpu cycles depending on how many sprites are behind the foreground. To enable, you must add -DRTL_FOREGROUND to your kernel or cflags in your makefile.There is also built in functionality that provides some measure of protection from stack overflow, allowing the user's program to either WaitVsync(1) or simply stop the effect short to avoid running out of cycles. This is enabled with two switches added in your make file:

  • -DRTL_FOREGROUND_SAFETY - specifies that you would like RTL to take precautions against stack overflow.
  • -DRTL_VSYNC_WAIT - specify 0 to stop processing effects early, or 1 to WaitVsync(1) then continue with effect.

I highly recommend you first try WITHOUT either switch. If you are having problems try reducing ram usage, and free up some extra cycles with -DFIRST_RENDER_LINE. See rtl_Primer for more information on extra cycles. Unfortunately if you do not have enough time, it will likely have a poor visual result. Fortunately though, this works with not much extra time so generally this will be a non-issue. Enough talk, let's see some code. These are the functions you will be using:

  • void rtl_SetForeground(const uint8_t * map, const uint8_t * tiles, uint8_t start, uint8_t end)
    • This sets the parameters of your foreground.
      • const uint8_t *map-a pointer to a map representing the foreground(at least the size of the screen area sprites can move on).
      • const uint8_t *tiles-a pointer to the actual graphics data you will use for the foreground. This is in the same standard format as other 8bpp Uzebox graphics, and you can use the same tools you use normally to prepare the data.
      • uint8_t start-declares the first tile index that will be considered a foreground. So if for instance a sprite is on top of tile 20 and start is declared as 10, the 10th tile in the foreground tiles will be blitted over the sprite at that location(20-start make sense?).
      • uint8_t end-similarly, declares the last tile index that is considered foreground. To disable using foreground maps, simply set map to NULL. To disable the use of indexed foreground simple set start and end to 0.