SaturnRingLibrary 0.6
SGL wrapper
 
Loading...
Searching...
No Matches
SRL::VDP2::ScrollScreen< ScreenType, Id, On > Class Template Reference

Detailed Description

template<class ScreenType, int16_t Id, uint16_t On>
class SRL::VDP2::ScrollScreen< ScreenType, Id, On >

Functionality available to all Scroll Screen interfaces.

#include <srl_vdp2.hpp>

Static Public Member Functions

static void * GetCellAddress ()
 Gets the starting address in VRAM of Cel data allocated to this scroll.
 
static uint32_t GetCellOffset (SRL::Tilemap::TilemapInfo &tile, void *cellAddress)
 Compute the offset that must be added to map data When Corresponding Cel Data does not start on a VRAM bank boundary.
 
static void * GetMapAddress ()
 Gets the starting address in VRAM of Map data allocated to this scroll.
 
static void * GetPageAddress (uint8_t index)
 returns the VRAM Address of the specified page number in a scroll's Page Table or nullptr if the requested page is outside of allocated Map Bounds
 
static uint32_t GetPalOffset (int8_t paletteID=-1)
 Gets the Pallet Bank That must be included in Map Data to Reference a Palette in CRAM.
 
static void * GetPlaneAddress (uint8_t index)
 Gets the VRAM Address of the specified plane in a scroll's Page Table (units of 1x1, 2x1, or 2x2 pages)
 
static void LoadTilemap (SRL::Tilemap::ITilemap &tilemap)
 Loads Tilemap data to VRAM using ITilemap Interface and configures the Scroll Screen to use it.
 
static void ScrollDisable ()
 Removes the Scroll Screen from VDP2 cycle pattern register to disable display.
 
static void ScrollEnable ()
 Registers Scroll in VDP2 cycle pattern to enable display of this Scroll Screen.
 
static void * SetCellAddress (void *address, int size)
 Manually Sets VRAM area for Cell Data (Advanced Use Cases)
 
static void * SetMapAddress (void *Address, int Size)
 Manually Sets VRAM area for Map Data (Advanced Use Cases)
 
static void SetMapLayout (uint8_t a, uint8_t b, uint8_t c, uint8_t d)
 Manually set the Plane layout of a Scroll Screen.
 
static void SetOpacity (Types::Fxp opacity=1.0)
 Set the opacity of a scroll screen.
 
static void SetPriority (SRL::VDP2::Priority pr)
 Set the Display Priority of a Scroll Screen.
 

Static Public Attributes

static void * CellAddress = (void*)(VDP2_VRAM_A0 - 1)
 VRAM Address to start of Cell data when displying Tilemap or Bitmap data when using bitmaps.
 
static int CellAllocSize = -1
 
static Tilemap::TilemapInfo Info = Tilemap::TilemapInfo()
 Tilemap config info for the ScrollScreen.
 
static void * MapAddress = (void*)(VDP2_VRAM_A0 - 1)
 VRAM Address of ScrollScreen's Map data when displaying Tilemap.
 
static int MapAllocSize = -1
 Size of manually allocated VRAM for Map Data.
 
static constexpr int16_t ScreenID = Id
 SGL identifier for the ScrollScreen.
 
static constexpr uint16_t ScreenON = On
 SGL flag for the ScrollScreen.
 
static CRAM::Palette TilePalette = CRAM::Palette()
 CRAM Pallet for the ScrollScreen.
 

Member Function Documentation

◆ GetCellAddress()

template<class ScreenType , int16_t Id, uint16_t On>
static void * SRL::VDP2::ScrollScreen< ScreenType, Id, On >::GetCellAddress ( )
inlinestatic

Gets the starting address in VRAM of Cel data allocated to this scroll.

Returns
Address of Cel data
Note
Returns starting address of bitmap when displaying Bitmap Scroll

◆ GetCellOffset()

template<class ScreenType , int16_t Id, uint16_t On>
static uint32_t SRL::VDP2::ScrollScreen< ScreenType, Id, On >::GetCellOffset ( SRL::Tilemap::TilemapInfo & tile,
void * cellAddress )
inlinestatic

Compute the offset that must be added to map data When Corresponding Cel Data does not start on a VRAM bank boundary.

Parameters
tileThe data configuration of the tilemap
cellAddressAddress of corresponding Cel Data in VRAM (must be a 32 byte boundary)
Returns
The Cel Offset to add to to map data

◆ GetMapAddress()

template<class ScreenType , int16_t Id, uint16_t On>
static void * SRL::VDP2::ScrollScreen< ScreenType, Id, On >::GetMapAddress ( )
inlinestatic

Gets the starting address in VRAM of Map data allocated to this scroll.

Returns
Address of Map data

◆ GetPageAddress()

template<class ScreenType , int16_t Id, uint16_t On>
static void * SRL::VDP2::ScrollScreen< ScreenType, Id, On >::GetPageAddress ( uint8_t index)
inlinestatic

returns the VRAM Address of the specified page number in a scroll's Page Table or nullptr if the requested page is outside of allocated Map Bounds

Parameters
indexThe index of desired page in the page table
Returns
VRAM Address of the page index

◆ GetPalOffset()

template<class ScreenType , int16_t Id, uint16_t On>
static uint32_t SRL::VDP2::ScrollScreen< ScreenType, Id, On >::GetPalOffset ( int8_t paletteID = -1)
inlinestatic

Gets the Pallet Bank That must be included in Map Data to Reference a Palette in CRAM.

Parameters
paletteID(optional) specify to reference an arbitrary palette, otherwise uses Id from ScrollScreen::TilePalette
Returns
The Formatted Palette ID to be included in Map Indicies to reference a specified palette

◆ GetPlaneAddress()

template<class ScreenType , int16_t Id, uint16_t On>
static void * SRL::VDP2::ScrollScreen< ScreenType, Id, On >::GetPlaneAddress ( uint8_t index)
inlinestatic

Gets the VRAM Address of the specified plane in a scroll's Page Table (units of 1x1, 2x1, or 2x2 pages)

Parameters
indexThe index of desired plane in page table
Returns
VRAM Address of the plane index
Note
PlaneAddress and PageAddress are equal when Plane Size is set to 1x1

◆ LoadTilemap()

template<class ScreenType , int16_t Id, uint16_t On>
static void SRL::VDP2::ScrollScreen< ScreenType, Id, On >::LoadTilemap ( SRL::Tilemap::ITilemap & tilemap)
inlinestatic

Loads Tilemap data to VRAM using ITilemap Interface and configures the Scroll Screen to use it.

If VRAM for this ScrollScreen's data has already been allocated by the user, SRL will attempt to load to the allocated VRAM and raise assert if the Tilemap Data does not fit within the existing allocation. If VRAM was not allocated SRL will attempt to auto allocate the Tilemap data and raise assert if there is not enough VRAM available to allocate.

Parameters
tilemapThe Tilemap to load
Note
Manual VRAM allocation is for advanced use cases as is NOT verified for proper bank alignment
Does not turn Scroll Display on- once loaded use ScrollEnable() to display a Scroll Screen
It is recommended to perform loading/allocation for RBG0 before NBG0-3 screens if using it

◆ ScrollDisable()

template<class ScreenType , int16_t Id, uint16_t On>
static void SRL::VDP2::ScrollScreen< ScreenType, Id, On >::ScrollDisable ( )
inlinestatic

Removes the Scroll Screen from VDP2 cycle pattern register to disable display.

Asserts when registration of a scroll fails due to cycle pattern conflicts. Possible causes: Assert should never occur here unless the user independently invoked SGL's slScrAutoDisp() with specifications differing from those tracked by SRL

◆ ScrollEnable()

template<class ScreenType , int16_t Id, uint16_t On>
static void SRL::VDP2::ScrollScreen< ScreenType, Id, On >::ScrollEnable ( )
inlinestatic

Registers Scroll in VDP2 cycle pattern to enable display of this Scroll Screen.

Asserts when registration of a scroll fails due to cycle pattern conflicts. Possible causes: -Too many Scroll Layers with higher bit depth are storing data in the same VRAM bank -NBG0 or NBG1 have their minimum scale limit set too small(eg 1/2x or 1/4x scale) -NBG Data was stored in a bank reserved by RBG0 Potential conflicts are minimized when using Automatic Allocation and setting the desired scale limits of NBG0/NBG1 beforehand.

◆ SetCellAddress()

template<class ScreenType , int16_t Id, uint16_t On>
static void * SRL::VDP2::ScrollScreen< ScreenType, Id, On >::SetCellAddress ( void * address,
int size )
inlinestatic

Manually Sets VRAM area for Cell Data (Advanced Use Cases)

This function manually sets an area in VRAM for a scrolls Cel Data to be loaded to. Unless the Address is obtained from VDP2::VRAM::Allocate(), the VRAM allocator will be bypassed entirely. No Checks are performed for proper data allignment or cycle conflicts. For advanced use cases only.

//Manually Set NBG0 to store 16bpp Cel Data in an 0x8000 byte region allocated in VRAM bank A1:
SRL::VDP2::NBG0::SetCelAddress(SRL::VDP2::VRAM::Allocate(0x8000,32,SRL::VDP2::VramBank::A1, 3),0x8000);
static void * Allocate(uint32_t size, uint32_t boundary, VDP2::VramBank bank, uint8_t cycles=0)
Linearly Allocates Vram in a bank.
Definition srl_vdp2.hpp:93
Parameters
addressthe VRAM address of the allocation
sizethe size of the allocation
Returns
Echoes Address

◆ SetMapAddress()

template<class ScreenType , int16_t Id, uint16_t On>
static void * SRL::VDP2::ScrollScreen< ScreenType, Id, On >::SetMapAddress ( void * Address,
int Size )
inlinestatic

Manually Sets VRAM area for Map Data (Advanced Use Cases)

This function manually sets an area in VRAM for a scroll's Map Data to be loaded to. Unless the Address is obtained from VDP2::VRAM::Allocate() the VRAM allocator will be bypassed entirely. No Checks are performed for proper data alignment or cycle conflicts. For advanced use cases only.

//Manually Set NBG0 to store Map Data in an 0x8000 byte region allocated in VRAM bank A1:
SRL::VDP2::NBG0::SetMapAddress(SRL::VDP2::VRAM::Allocate(0x8000,1024,SRL::VDP2::VramBank::A1, 1),0x8000);
static void * SetMapAddress(void *Address, int Size)
Manually Sets VRAM area for Map Data (Advanced Use Cases)
Definition srl_vdp2.hpp:407
Parameters
Addressthe VRAM address of the allocation
Sizethe size of the allocation
Returns
Echoes Address

◆ SetMapLayout()

template<class ScreenType , int16_t Id, uint16_t On>
static void SRL::VDP2::ScrollScreen< ScreenType, Id, On >::SetMapLayout ( uint8_t a,
uint8_t b,
uint8_t c,
uint8_t d )
inlinestatic

Manually set the Plane layout of a Scroll Screen.

This function manually sets the 4 planes comprising a NBG scroll screen in cases when the default plane tiling pattern is not desired.

Parameters
a,b,c,dthe plane indicies of the 4 planes that will display in the normal scroll
Note
RBG0 does not currently support multi plane patterns, so only plane [a] will be used

◆ SetOpacity()

template<class ScreenType , int16_t Id, uint16_t On>
static void SRL::VDP2::ScrollScreen< ScreenType, Id, On >::SetOpacity ( Types::Fxp opacity = 1.0)
inlinestatic

Set the opacity of a scroll screen.

This Function takes the opacity specified as a fixed point value and converts it to one of the 32 color calculation ratios that a scroll screen can use (value is floored to the nearest ratio). Color Calculation is turned on if Opacity < 1.0, or off if Opacity>= 1.0. Color calculation is unchanged if value is negative.

Note
Color ratios only apply to highest priority pixels in frame
When ColorCalcMode is set to UseColorAddition, all scrolls with opacity < 1.0 will use color addition in place of their specified ratios.
Parameters
opacityFxp decimal value between 0.0 and 1.0 representing pixel opacity for the scroll screen (Default 1.0)

◆ SetPriority()

template<class ScreenType , int16_t Id, uint16_t On>
static void SRL::VDP2::ScrollScreen< ScreenType, Id, On >::SetPriority ( SRL::VDP2::Priority pr)
inlinestatic

Set the Display Priority of a Scroll Screen.

Note
Higher value layers display on top of lower layers
When 2 or more scroll screens are assigned the same layer, their priority resolves as SPRITE>RBG0>NBG0>NBG1>NBG2>NBG3
Parameters
prThe Priority Layer for the Scroll Screen

Member Data Documentation

◆ CellAllocSize

template<class ScreenType , int16_t Id, uint16_t On>
int SRL::VDP2::ScrollScreen< ScreenType, Id, On >::CellAllocSize = -1
inlinestatic

Size of manually allocated VRAM for Cel Data