Improve renderer a bit

This commit is contained in:
Miloslav Ciz 2024-07-31 16:07:25 +02:00
parent 6f020c852f
commit 2b4516f408
2 changed files with 58 additions and 29 deletions

View file

@ -25,11 +25,19 @@ static const uint8_t map1[] =
10,
10,
0,
LCR_MAP_BLOCK(LCR_BLOCK_FULL,32,32,32,LCR_BLOCK_MATERIAL_CONCRETE,0),
LCR_MAP_BLOCK(LCR_BLOCK_FULL,33,32,32,LCR_BLOCK_MATERIAL_CONCRETE,0),
LCR_MAP_BLOCK(LCR_BLOCK_FULL,32,0,32,LCR_BLOCK_MATERIAL_CONCRETE,0),
LCR_MAP_BLOCK(LCR_BLOCK_FULL,33,63,32,LCR_BLOCK_MATERIAL_CONCRETE,0),
LCR_MAP_BLOCK(LCR_BLOCK_RAMP_CURVED_WALL,34,32,32,LCR_BLOCK_MATERIAL_CONCRETE,/*LCR_BLOCK_TRANSFORM_ROT_90*/0),
LCR_MAP_BLOCK(LCR_BLOCK_RAMP_CURVED_WALL,35,32,32,LCR_BLOCK_MATERIAL_CONCRETE,LCR_BLOCK_TRANSFORM_ROT_90),
LCR_MAP_BLOCK(LCR_BLOCK_FULL,38,35,32,LCR_BLOCK_MATERIAL_CONCRETE,0),
LCR_MAP_BLOCK(LCR_BLOCK_FULL,39,35,32,LCR_BLOCK_MATERIAL_CONCRETE,0),
LCR_MAP_BLOCK(LCR_BLOCK_FULL,40,35,32,LCR_BLOCK_MATERIAL_CONCRETE,0),
LCR_MAP_BLOCK(LCR_BLOCK_FULL,41,35,32,LCR_BLOCK_MATERIAL_CONCRETE,0),
LCR_MAP_BLOCK(LCR_BLOCK_FULL,42,35,32,LCR_BLOCK_MATERIAL_CONCRETE,0),
LCR_MAP_BLOCK(LCR_BLOCK_FULL,43,35,32,LCR_BLOCK_MATERIAL_CONCRETE,0),
LCR_MAP_BLOCK(LCR_BLOCK_FULL,44,35,32,LCR_BLOCK_MATERIAL_CONCRETE,0),
LCR_MAP_BLOCK(LCR_BLOCK_BOTTOM_LEFT,34,32,33,LCR_BLOCK_MATERIAL_CONCRETE,LCR_BLOCK_TRANSFORM_ROT_90),
LCR_MAP_BLOCK(LCR_BLOCK_FULL,32,33,32,LCR_BLOCK_MATERIAL_CONCRETE,0),
@ -4803,7 +4811,7 @@ static const uint8_t LCR_images[] =
0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x02,0x00,0x02,0x02,0x02,0x02,
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x02,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0xc2,0xc2,0x02,0xc2,
0xc2,0xc2,0xc2,0xbe,0xbe,0xc2,0xc2,0xc2,0xc2,0xc2,0xc2,0xc2,0xc2,0x02,0x02,0x00,
0xc2,0xc2,0xc2,0x00,0x00,0xc2,0xc2,0xc2,0xc2,0xc2,0xc2,0xc2,0xc2,0x02,0x02,0x00,
0x00,0x00,0x00,0x02,0x00,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
@ -4811,7 +4819,7 @@ static const uint8_t LCR_images[] =
0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x02,
0x02,0x02,0x02,0x02,0x02,0xc2,0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x02,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0xc2,0xc2,
0xc2,0xc2,0xbe,0xbe,0xc2,0xc2,0xc2,0xc2,0xc2,0xc2,0xc2,0x02,0x02,0x02,0x02,0x02,
0xc2,0xc2,0x00,0x00,0xc2,0xc2,0xc2,0xc2,0xc2,0xc2,0xc2,0x02,0x02,0x02,0x02,0x02,
0x00,0x00,0x00,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
@ -4865,22 +4873,22 @@ static const uint8_t LCR_images[] =
0x01,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0xbb,0xbb,0xbb,
0xbb,0xbb,0x03,0x03,0x03,0x03,0x3a,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0xc2,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
0x02,0xbe,0x02,0x02,0x02,0xc2,0x02,0x02,0x00,0x00,0x02,0x02,0x01,0x00,0x02,0x02,
0x02,0x00,0x02,0x02,0x02,0xc2,0x02,0x02,0x00,0x00,0x02,0x02,0x01,0x00,0x02,0x02,
0x01,0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0xc2,0x02,
0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcb,0x00,0x00,
0x00,0x00,0x00,0x00,0xcb,0x02,0x02,0xc2,0x02,0xcb,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0xd2,0x01,0x01,0x01,0x01,0x01,0x03,0x01,0x03,0x03,0x03,0x03,0xd2,
0x01,0x03,0x03,0xbb,0xbb,0x03,0x03,0xbb,0xbb,0xbb,0x03,0xbb,0xbb,0xbb,0xbb,0xbb,
0xbb,0x97,0x03,0x03,0x03,0x03,0x03,0x03,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0xc2,0x02,0x02,0x02,0xbe,
0x02,0xbe,0xbe,0xc2,0xc2,0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x02,0x01,0x01,0x02,
0x00,0x00,0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0xc2,0x02,0x02,0x02,0x00,
0x02,0x00,0x00,0xc2,0xc2,0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x02,0x01,0x01,0x02,
0x02,0x01,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x02,0x02,0x02,
0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xcb,0x00,0x02,0x02,0xcb,0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,
0x00,0x00,0x00,0xd2,0x01,0x01,0x01,0x01,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0xbb,0xbb,0x03,0x03,0xbb,0xbb,0xbb,0xbb,0xbb,0xbb,0x03,0xbb,0xbb,
0xbb,0x97,0x97,0x97,0x97,0xbb,0xbb,0x03,0x03,0x01,0x01,0x01,0x01,0x01,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x02,0x02,0x02,0x02,0x02,0xbe,0x02,0xbe,0x02,
0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x02,0x02,0x02,0x02,0x02,0x00,0x02,0x00,0x02,
0x02,0x02,0xc2,0x02,0x02,0x02,0x00,0x01,0x01,0x02,0x00,0x02,0x02,0x02,0x01,0x01,
0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x01,0x01,0x00,0x00,0x02,0x02,0x02,
0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcb,
@ -4888,7 +4896,7 @@ static const uint8_t LCR_images[] =
0x01,0x01,0xd2,0x00,0x01,0xd2,0xd2,0x03,0x03,0x03,0x01,0x01,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0xbb,0xbb,0xbb,0xbb,0xbb,0xbb,0x03,0xbb,0xbb,
0x97,0x97,0xbb,0xbb,0x97,0x97,0x03,0xbb,0x03,0x03,0x03,0x03,0x3a,0x01,0x01,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0xc2,0x02,0x02,0x02,0x02,0x02,0xbe,
0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x02,0xc2,0x02,0x02,0x02,0x02,0x02,0x00,
0x02,0x02,0x02,0x02,0x00,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x02,0x02,
0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
@ -5848,6 +5856,10 @@ void LCR_loadImage(unsigned int index)
_LCR_currentImagePixel = _LCR_currentImage;
}
/**
Changes currently loaded image's brightness either up or down by modifying
its palette. This can be used for shading.
*/
void LCR_imageChangeBrightness(int up)
{
if (up)
@ -5859,16 +5871,22 @@ void LCR_imageChangeBrightness(int up)
((_LCR_currentImagePalette[i] >> 1) & 0x7bef);
}
/**
Samples currently loaded image at given pixels coordinates (with wrapping).
This is slower than reading the image pixel by pixel.
*/
uint16_t LCR_sampleImage(int x, int y)
{
x = (y * LCR_IMAGE_SIZE + x) % (LCR_IMAGE_SIZE * LCR_IMAGE_SIZE);
if (x < 0) // TODO: optimize
x += LCR_IMAGE_SIZE * LCR_IMAGE_SIZE;
// TODO: bottleneck, later on optimize here
x = (y % LCR_IMAGE_SIZE) * LCR_IMAGE_SIZE + (x % LCR_IMAGE_SIZE);
x += (x < 0) * (LCR_IMAGE_SIZE * LCR_IMAGE_SIZE);
return _LCR_currentImagePalette[_LCR_currentImage[x]];
}
/**
Gets the next pixel of currently loaded image. This is faster than sampling
the image by pixel coordinates.
*/
uint16_t LCR_getNextImagePixel(void)
{
uint16_t r = _LCR_currentImagePalette[*_LCR_currentImagePixel];