Add sound

This commit is contained in:
Miloslav Ciz 2025-01-29 16:27:47 +01:00
parent be11c582b1
commit 67e0814afb
8 changed files with 124 additions and 94 deletions

121
map.h
View file

@ -1,7 +1,8 @@
#ifndef _LCR_MAP
#define _LCR_MAP
/*
/** @file map.h
Licar: map module
This implements maps (i.e. tracks, levels, ...).
@ -58,31 +59,29 @@
#include "general.h"
#define LCR_MAP_NAME_MAX_LEN 15 /**< Maximum map name length (without
terminating zero. */
#define LCR_BLOCK_START_CHAR ':'
#define LCR_MAP_NAME_MAX_LEN 15 /**< Maximum map name length (without
terminating zero. */
#define LCR_BLOCK_START_CHAR ':'
/** Maximum number of triangles of a block shape. */
#define LCR_MAP_BLOCK_SHAPE_MAX_BYTES 80
#define LCR_BLOCK_TRANSFORM_FLIP_H 0x10
#define LCR_BLOCK_TRANSFORM_ROT_90 0x20
#define LCR_BLOCK_TRANSFORM_ROT_180 0x40
#define LCR_BLOCK_TRANSFORM_ROT_270 0x60
#define LCR_BLOCK_TRANSFORM_FLIP_V 0x80
#define LCR_BLOCK_TRANSFORM_FLIP_H 0x10
#define LCR_BLOCK_TRANSFORM_ROT_90 0x20
#define LCR_BLOCK_TRANSFORM_ROT_180 0x40
#define LCR_BLOCK_TRANSFORM_ROT_270 0x60
#define LCR_BLOCK_TRANSFORM_FLIP_V 0x80
#define LCR_BLOCK_XYZ_TO_COORD(x,y,z) // ???
#define LCR_MAP_BLOCK(t,x,y,z,m,r) t,(uint8_t) (x | (y << 6)), \
(uint8_t) ((y >> 2) | (z << 4)), \
(uint8_t) ((z >> 4) | (m << 2) | (r))
#define LCR_MAP_BLOCK(t,x,y,z,m,r) t,(uint8_t) (x | (y << 6)), \
(uint8_t) ((y >> 2) | (z << 4)), \
(uint8_t) ((z >> 4) | (m << 2) | (r))
#define LCR_BLOCK_SIZE 4 ///< size of map block, in bytes
#define LCR_BLOCK_SIZE 4 ///< size of map block, in bytes
#define LCR_BLOCK_MATERIAL_CONCRETE 0x00
#define LCR_BLOCK_MATERIAL_GRASS 0x01
#define LCR_BLOCK_MATERIAL_DIRT 0x02
#define LCR_BLOCK_MATERIAL_ICE 0x03
#define LCR_BLOCK_MATERIAL_CONCRETE 0x00
#define LCR_BLOCK_MATERIAL_GRASS 0x01
#define LCR_BLOCK_MATERIAL_DIRT 0x02
#define LCR_BLOCK_MATERIAL_ICE 0x03
// normal blocks:
#define LCR_BLOCK_FULL '=' ///< completely filled block
@ -97,7 +96,7 @@
#define LCR_BLOCK_RAMP_14 '_' ///< plain ramp, 1/4 size
#define LCR_BLOCK_RAMP_12_UP '\'' ///< ramp, 1/2 size, elevated up
#define LCR_BLOCK_RAMP_CORNER 'v' ///< corner of a ramp
#define LCR_BLOCK_RAMP_CURVED_PLAT ']' ///< curved ramp with top platgform
#define LCR_BLOCK_RAMP_CURVED_PLAT ']' ///< curved ramp with top platform
#define LCR_BLOCK_RAMP_CURVED ')' ///< curv. ramp without top platf.
#define LCR_BLOCK_RAMP_CURVED_WALL '}' ///< curved ramp plus small wall
#define LCR_BLOCK_RAMP_STEEP '|' ///< extremely steep ramp
@ -712,18 +711,18 @@ void LCR_mapGetBlockShape(uint8_t blockType, uint8_t transform,
{
uint8_t
xRight = 6 >>
(blockType == LCR_BLOCK_LEFT ||
blockType == LCR_BLOCK_BOTTOM_LEFT ||
blockType == LCR_BLOCK_BOTTOM_LEFT_FRONT ||
blockType == LCR_BLOCK_LEFT_FRONT),
((blockType == LCR_BLOCK_LEFT) |
(blockType == LCR_BLOCK_BOTTOM_LEFT) |
(blockType == LCR_BLOCK_BOTTOM_LEFT_FRONT) |
(blockType == LCR_BLOCK_LEFT_FRONT)),
yTop = 4 >>
(blockType == LCR_BLOCK_BOTTOM ||
blockType == LCR_BLOCK_BOTTOM_ACCEL ||
blockType == LCR_BLOCK_BOTTOM_LEFT ||
blockType == LCR_BLOCK_BOTTOM_LEFT_FRONT),
((blockType == LCR_BLOCK_BOTTOM) |
(blockType == LCR_BLOCK_BOTTOM_ACCEL) |
(blockType == LCR_BLOCK_BOTTOM_LEFT) |
(blockType == LCR_BLOCK_BOTTOM_LEFT_FRONT)),
zBack = 6 >>
(blockType == LCR_BLOCK_BOTTOM_LEFT_FRONT ||
blockType == LCR_BLOCK_LEFT_FRONT);
((blockType == LCR_BLOCK_BOTTOM_LEFT_FRONT) |
(blockType == LCR_BLOCK_LEFT_FRONT));
ADD(0,0,0) ADD(xRight,0,0) ADD(xRight,yTop,0) // front
ADD(0,0,0) ADD(xRight,yTop,0) ADD(0,yTop,0)
@ -737,7 +736,6 @@ void LCR_mapGetBlockShape(uint8_t blockType, uint8_t transform,
ADD(0,yTop,0) ADD(xRight,yTop,zBack) ADD(0,yTop,zBack)
ADD(0,0,0) ADD(xRight,0,zBack) ADD(xRight,0,0) // bottom
ADD(0,0,0) ADD(0,0,zBack) ADD(xRight,0,zBack)
break;
}
@ -843,14 +841,14 @@ void LCR_mapGetBlockShape(uint8_t blockType, uint8_t transform,
{
uint8_t right = blockType == LCR_BLOCK_CORNER ? 6 : 3;
ADD(0,0,0) ADD(right,0,6) ADD(right,4,6) // front/right
ADD(0,0,0) ADD(right,0,6) ADD(right,4,6) // front/right
ADD(0,0,0) ADD(right,4,6) ADD(0,4,0)
ADD(0,0,0) ADD(0,4,6) ADD(0,0,6) // left
ADD(0,0,0) ADD(0,4,6) ADD(0,0,6) // left
ADD(0,0,0) ADD(0,4,0) ADD(0,4,6)
ADD(right,0,6) ADD(0,0,6) ADD(0,4,6) // back
ADD(right,0,6) ADD(0,0,6) ADD(0,4,6) // back
ADD(0,4,6) ADD(right,4,6) ADD(right,0,6)
ADD(0,4,0) ADD(right,4,6) ADD(0,4,6) // top
ADD(0,0,6) ADD(right,0,6) ADD(0,0,0) // bottom
ADD(0,4,0) ADD(right,4,6) ADD(0,4,6) // top
ADD(0,0,6) ADD(right,0,6) ADD(0,0,0) // bottom
break;
}
@ -862,58 +860,58 @@ void LCR_mapGetBlockShape(uint8_t blockType, uint8_t transform,
mx = blockType == LCR_BLOCK_CORNER_CONVEX ? 4 : 2,
mz = blockType == LCR_BLOCK_CORNER_CONVEX ? 2 : 4;
ADD(0,0,0) ADD(0,4,6) ADD(0,0,6) // left
ADD(0,0,0) ADD(0,4,0) ADD(0,4,6) // left
ADD(6,0,6) ADD(0,0,6) ADD(0,4,6) // back
ADD(0,4,6) ADD(6,4,6) ADD(6,0,6) // back
ADD(0,0,0) ADD(mx,4,mz) ADD(0,4,0) // right
ADD(0,0,0) ADD(0,4,6) ADD(0,0,6) // left
ADD(0,0,0) ADD(0,4,0) ADD(0,4,6) // left
ADD(6,0,6) ADD(0,0,6) ADD(0,4,6) // back
ADD(0,4,6) ADD(6,4,6) ADD(6,0,6) // back
ADD(0,0,0) ADD(mx,4,mz) ADD(0,4,0) // right
ADD(mx,0,mz) ADD(mx,4,mz) ADD(0,0,0)
ADD(6,4,6) ADD(mx,4,mz) ADD(6,0,6)
ADD(6,0,6) ADD(mx,4,mz) ADD(mx,0,mz)
ADD(0,4,0) ADD(mx,4,mz) ADD(0,4,6) // top
ADD(0,4,0) ADD(mx,4,mz) ADD(0,4,6) // top
ADD(0,4,6) ADD(mx,4,mz) ADD(6,4,6)
ADD(0,0,0) ADD(0,0,6) ADD(mx,0,mz) // bottom
ADD(0,0,0) ADD(0,0,6) ADD(mx,0,mz) // bottom
ADD(0,0,6) ADD(6,0,6) ADD(mx,0,mz)
break;
}
case LCR_BLOCK_BUMP:
ADD(3,0,0) ADD(6,0,3) ADD(3,1,3) // top
ADD(3,0,0) ADD(6,0,3) ADD(3,1,3) // top
ADD(6,0,3) ADD(3,0,6) ADD(3,1,3)
ADD(3,0,6) ADD(0,0,3) ADD(3,1,3)
ADD(0,0,3) ADD(3,0,0) ADD(3,1,3)
ADD(3,0,0) ADD(3,0,6) ADD(6,0,3) // bottom
ADD(3,0,6) ADD(3,0,0) ADD(0,0,3) // bottom
ADD(3,0,0) ADD(3,0,6) ADD(6,0,3) // bottom
ADD(3,0,6) ADD(3,0,0) ADD(0,0,3) // bottom
break;
case LCR_BLOCK_RAMP_CORNER:
ADD(6,0,6) ADD(0,0,0) ADD(6,4,0) // diagonal
ADD(6,0,6) ADD(6,4,0) ADD(6,0,0) // right
ADD(0,0,0) ADD(6,0,0) ADD(6,4,0) // front
ADD(0,0,0) ADD(6,0,6) ADD(6,0,0) // bottom
ADD(6,0,6) ADD(0,0,0) ADD(6,4,0) // diagonal
ADD(6,0,6) ADD(6,4,0) ADD(6,0,0) // right
ADD(0,0,0) ADD(6,0,0) ADD(6,4,0) // front
ADD(0,0,0) ADD(6,0,6) ADD(6,0,0) // bottom
break;
case LCR_BLOCK_HILL:
ADD(0,0,0) ADD(6,0,0) ADD(0,2,1) // front
ADD(0,0,0) ADD(6,0,0) ADD(0,2,1) // front
ADD(6,0,0) ADD(6,2,1) ADD(0,2,1)
ADD(0,2,1) ADD(6,2,1) ADD(0,3,2) // front 2
ADD(0,2,1) ADD(6,2,1) ADD(0,3,2) // front 2
ADD(6,2,1) ADD(6,3,2) ADD(0,3,2)
ADD(0,3,2) ADD(6,3,2) ADD(0,4,4) // front 3
ADD(0,3,2) ADD(6,3,2) ADD(0,4,4) // front 3
ADD(6,3,2) ADD(6,4,4) ADD(0,4,4)
ADD(0,4,4) ADD(6,4,4) ADD(0,4,6) // top
ADD(0,4,4) ADD(6,4,4) ADD(0,4,6) // top
ADD(6,4,4) ADD(6,4,6) ADD(0,4,6)
ADD(0,0,0) ADD(0,0,6) ADD(6,0,0) // bottom
ADD(0,0,0) ADD(0,0,6) ADD(6,0,0) // bottom
ADD(6,0,0) ADD(0,0,6) ADD(6,0,6)
ADD(0,0,6) ADD(0,4,6) ADD(6,4,6) // back
ADD(0,0,6) ADD(0,4,6) ADD(6,4,6) // back
ADD(0,0,6) ADD(6,4,6) ADD(6,0,6)
ADD(0,0,0) ADD(0,2,1) ADD(0,0,6) // left
ADD(0,0,0) ADD(0,2,1) ADD(0,0,6) // left
ADD(0,2,1) ADD(0,3,2) ADD(0,0,6)
ADD(0,3,2) ADD(0,4,4) ADD(0,0,6)
ADD(0,4,4) ADD(0,4,6) ADD(0,0,6)
ADD(6,0,0) ADD(6,0,6) ADD(6,2,1) // right
ADD(6,2,1) ADD(6,0,6) ADD(6,3,2)
ADD(6,3,2) ADD(6,0,6) ADD(6,4,4)
ADD(6,4,4) ADD(6,0,6) ADD(6,4,6)
ADD(6,0,0) ADD(6,0,6) ADD(6,2,1) // right
ADD(6,2,1) ADD(6,0,6) ADD(6,3,2)
ADD(6,3,2) ADD(6,0,6) ADD(6,4,4)
ADD(6,4,4) ADD(6,0,6) ADD(6,4,6)
break;
@ -927,7 +925,6 @@ void LCR_mapGetBlockShape(uint8_t blockType, uint8_t transform,
uint8_t x, y, z;
_LCR_decodeMapBlockCoords(bytes[i],&x,&y,&z);
LCR_TRANSFORM_COORDS(transform,x,y,z,6,4)
bytes[i] = _LCR_encodeMapBlockCoords(x,y,z);