Correct line numbers, remove ptr arithmetic

This commit is contained in:
ABelliqueux 2021-08-04 17:47:03 +02:00
parent af763ae9f9
commit 0eb3f5c49e

View File

@ -52,7 +52,7 @@ void display(void)
PutDrawEnv(&draw[db]);
// 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]);
// Uncomment the following line to use a regular oredered OT. Uncomment l.100 accordingly
// Comment above line, and uncomment the following line to use a regular oredered OT. Comment l.71 and Uncomment l.73 accordingly
//~ DrawOTag(ot[db]);
db = !db;
nextpri = primbuff[db];
@ -69,17 +69,17 @@ int main(void)
{
// 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
// Use regular order OT, uncomment l.53 accordingly
//~ ClearOTag(ot[db], OTLEN);
// 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)
// Using a Regular or Reverse OT will have an effect on drawing order. (See lines 77 and 100)
// Using a Regular or Reverse OT will have an effect on drawing order. (See lines 53 and 73)
yellow_tile = (TILE * ) nextpri; // yellow_tile is a pointer to primbuf content at adress nextpri, that's cast (type converted) to a TILE struc.
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
addPrim(ot[db][OTLEN - 1], yellow_tile); // Add primitive to ordering table
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.
@ -87,18 +87,18 @@ int main(void)
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
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,
// so it is drawn before, thus under 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.
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
setRGB0(pink_tile, 255, 32, 255); // Set color
addPrim(ot[db] + OTLEN - 2, pink_tile); // Add primitive to ordering table
addPrim(ot[db][OTLEN - 2], pink_tile); // Add primitive to ordering table
nextpri += sizeof(TILE);
FntPrint("Hello tile !");
FntFlush(-1);