Improve renderer, handle textures

This commit is contained in:
Miloslav Ciz 2024-08-01 21:41:21 +02:00
parent 2b4516f408
commit 2241b4d635
5 changed files with 191 additions and 59 deletions

22
map.h
View file

@ -64,7 +64,9 @@
#define LCR_BLOCK_SIZE 4 ///< size of map block, in bytes
#define LCR_BLOCK_MATERIAL_CONCRETE 0x00
#define LCR_BLOCK_MATERIAL_DIRT 0x01
#define LCR_BLOCK_MATERIAL_GRASS 0x01
#define LCR_BLOCK_MATERIAL_DIRT 0x02
#define LCR_BLOCK_MATERIAL_ICE 0x03
#define LCR_MAP_COUNT 1
@ -80,9 +82,12 @@
#define LCR_BLOCK_RAMP_CURVED_SHORT 0x08
#define LCR_BLOCK_RAMP_CURVED_WALL 0x09
#define LCR_BLOCK_CHECKPOINT_0 0x10 ///< checkpoint, not taken
#define LCR_BLOCK_CHECKPOINT_1 0x11 ///< checkpoint, taken
#define LCR_BLOCK_FINISH 0x12 ///< finish
#define LCR_BLOCK_FULL_ACCEL 0x40
#define LCR_BLOCK_FULL_STICKER 0x60
#define LCR_BLOCK_CHECKPOINT_0 0x10 ///< checkpoint, not taken
#define LCR_BLOCK_CHECKPOINT_1 0x11 ///< checkpoint, taken
#define LCR_BLOCK_FINISH 0x12 ///< finish
// special blocks:
#define LCR_BLOCK_NONE 0x80 /**< no block, can be used e.g to make
@ -138,6 +143,11 @@ uint8_t LCR_mapBlockGetTransform(const uint8_t block[LCR_BLOCK_SIZE])
return block[3] & 0xf0;
}
uint8_t LCR_mapBlockGetMaterial(const uint8_t block[LCR_BLOCK_SIZE])
{
return (block[3] >> 2) & 0x03;
}
uint32_t LCR_mapBlockGetCoordNumber(const uint8_t block[LCR_BLOCK_SIZE])
{
return block[1] | (((uint32_t) block[2]) << 8) |
@ -301,6 +311,8 @@ void _LCR_decodeMapBlockCoords(uint8_t byte, uint8_t *x, uint8_t *y, uint8_t *z)
*z = (byte / 35);
}
#define LCR_BLOCK_SHAPE_COORD_MAX 12
/**
Decodes XYZ coordinates encoded in a byte returned by LCR_mapGetBlockShape.
Each coordinate will be in range 0 to 12 (including both). This unusual range
@ -357,6 +369,8 @@ void LCR_mapGetBlockShape(uint8_t blockType, uint8_t transform,
case LCR_BLOCK_LEFT:
case LCR_BLOCK_BOTTOM_LEFT:
case LCR_BLOCK_BOTTOM_LEFT_FRONT:
case LCR_BLOCK_FULL_ACCEL:
case LCR_BLOCK_FULL_STICKER:
{
uint8_t xRight = 6, yTop = 4,
zBack = 6 >> (blockType == LCR_BLOCK_BOTTOM_LEFT_FRONT);