Clarify OT order vs drawing order
This commit is contained in:
parent
abdd2fb0f8
commit
4e5c4f0088
65
hello_tile.c
65
hello_tile.c
@ -71,7 +71,10 @@ void display(void)
|
|||||||
|
|
||||||
SetDispMask(1);
|
SetDispMask(1);
|
||||||
|
|
||||||
|
// We're using a reverse OT, so we want to display the last item first. See PsyQ's LibRef47.pdf, p.277
|
||||||
DrawOTag(ot[db] + OTLEN - 1);
|
DrawOTag(ot[db] + OTLEN - 1);
|
||||||
|
// Uncomment the following line to use a regular oredered OT. Uncomment l.100 accordingly
|
||||||
|
//~ DrawOTag(ot[db]);
|
||||||
|
|
||||||
db = !db;
|
db = !db;
|
||||||
|
|
||||||
@ -81,39 +84,61 @@ void display(void)
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
// These two tiles are added at the same OT index
|
||||||
TILE * blue_tile;
|
TILE * blue_tile;
|
||||||
TILE * pink_tile;
|
TILE * pink_tile;
|
||||||
|
// This one is added at a different OT index
|
||||||
|
TILE * yellow_tile;
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
ClearOTagR(ot[db], OTLEN); // Initialize the reversed ordering table. Last element will be drawn first.
|
// Initialize the reversed ordering table. This means the elements at index OTLEN - 1 is drawn first.
|
||||||
|
ClearOTagR(ot[db], OTLEN);
|
||||||
|
// Use regular order OT, uncomment l.77 accordingly
|
||||||
|
//~ ClearOTag(ot[db], OTLEN);
|
||||||
|
|
||||||
blue_tile = (TILE * ) nextpri; // blue_tile is a pointer to primbuf content at adress nextpri, that's cast (type converted) to a blue_tile struc.
|
// yellow_tile is before pink and blue tile in the code,
|
||||||
|
// and it displays behind because it is added to a different ot index (od[db] + OTLEN - 1)
|
||||||
setTile(blue_tile); // initialize the blue_tile structure ( fill the length and tag(?) value )
|
// Using a Regular or Reverse OT will have an effect on drawing order. (See lines 77 and 100)
|
||||||
setXY0(blue_tile, CENTERX - 16, CENTERY - 32); // Set X,Y
|
|
||||||
setWH(blue_tile, 32, 64); // Set Width, Height
|
yellow_tile = (TILE * ) nextpri; // yellow_tile is a pointer to primbuf content at adress nextpri, that's cast (type converted) to a TILE struc.
|
||||||
setRGB0(blue_tile, 60, 180, 255); // Set color
|
|
||||||
addPrim(ot[db], blue_tile); // Add primitive to ordering table
|
setTile(yellow_tile); // initialize the TILE structure ( fill the length and tag(?) value )
|
||||||
|
setXY0(yellow_tile, CENTERX - 32 , CENTERY - 48); // Set X,Y
|
||||||
|
setWH(yellow_tile, 128, 40); // Set Width, Height
|
||||||
|
setRGB0(yellow_tile, 255, 255, 0); // Set color
|
||||||
|
addPrim(ot[db] + OTLEN - 1, yellow_tile); // Add primitive to ordering table
|
||||||
|
|
||||||
nextpri += sizeof(TILE); // Increment the adress nextpri points to by the size of TILE struct
|
nextpri += sizeof(TILE);
|
||||||
|
|
||||||
|
// blue_tile added at od[db] + OTLEN - 2
|
||||||
|
|
||||||
|
blue_tile = (TILE * ) nextpri; // blue_tile is a pointer to primbuf content at adress nextpri, that's cast (type converted) to a blue_tile struc.
|
||||||
|
|
||||||
|
setTile(blue_tile); // initialize the blue_tile structure ( fill the length and tag(?) value )
|
||||||
|
setXY0(blue_tile, CENTERX - 16, CENTERY - 32); // Set X,Y
|
||||||
|
setWH(blue_tile, 32, 64); // Set Width, Height
|
||||||
|
setRGB0(blue_tile, 60, 180, 255); // Set color
|
||||||
|
addPrim(ot[db] + OTLEN - 2, blue_tile); // Add primitive to ordering table
|
||||||
|
|
||||||
|
nextpri += sizeof(TILE); // Increment the adress nextpri points to by the size of TILE struct
|
||||||
|
|
||||||
// pink_tile is after blue_tile in the code,
|
// pink_tile is after blue_tile in the code,
|
||||||
// but we're using a reversed ordering table
|
// so it is drawn before, thus under blue_tile.
|
||||||
// so it is drawn before, thus bellow blue_tile.
|
// However, it is added at the same ot index (od[db] + OTLEN - 2)
|
||||||
|
// so using a Regular or Reverse OT won't have an effect on drawing order.
|
||||||
|
|
||||||
pink_tile = (TILE * ) nextpri; // pink_tile is a pointer to primbuf content at adress nextpri, that's cast (type converted) to a TILE struc.
|
pink_tile = (TILE * ) nextpri; // pink_tile is a pointer to primbuf content at adress nextpri, that's cast (type converted) to a TILE struc.
|
||||||
|
|
||||||
setTile(pink_tile); // initialize the TILE structure ( fill the length and tag(?) value )
|
setTile(pink_tile); // initialize the TILE structure ( fill the length and tag(?) value )
|
||||||
setXY0(pink_tile, CENTERX, CENTERY - 64); // Set X,Y
|
setXY0(pink_tile, CENTERX, CENTERY - 64); // Set X,Y
|
||||||
setWH(pink_tile, 64, 64); // Set Width, Height
|
setWH(pink_tile, 64, 64); // Set Width, Height
|
||||||
setRGB0(pink_tile, 255, 32, 255); // Set color
|
setRGB0(pink_tile, 255, 32, 255); // Set color
|
||||||
addPrim(ot[db], pink_tile); // Add primitive to ordering table
|
addPrim(ot[db] + OTLEN - 2, pink_tile); // Add primitive to ordering table
|
||||||
|
|
||||||
nextpri += sizeof(TILE);
|
nextpri += sizeof(TILE);
|
||||||
|
|
||||||
FntPrint("Hello tile !");
|
FntPrint("Hello tile !");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user