Remove map

This commit is contained in:
Miloslav Číž 2019-09-29 09:50:58 +02:00
parent 85bb83ea01
commit 1defd298e4
2 changed files with 105 additions and 114 deletions

View File

@ -67,16 +67,11 @@ typedef struct
texture). */ texture). */
uint8_t doorTextureIndex; /**< Index (global, NOT from textureIndices) of a uint8_t doorTextureIndex; /**< Index (global, NOT from textureIndices) of a
texture used for door. */ texture used for door. */
} SFG_Map;
typedef struct
{
SFG_Map map;
} SFG_Level; } SFG_Level;
static inline SFG_TileDefinition SFG_getMapTile static inline SFG_TileDefinition SFG_getMapTile
( (
const SFG_Map *map, const SFG_Level *level,
int16_t x, int16_t x,
int16_t y, int16_t y,
uint8_t *properties uint8_t *properties
@ -88,15 +83,14 @@ static inline SFG_TileDefinition SFG_getMapTile
return SFG_OUTSIDE_TILE; return SFG_OUTSIDE_TILE;
} }
uint8_t tile = map->mapArray[y * SFG_MAP_SIZE + x]; uint8_t tile = level->mapArray[y * SFG_MAP_SIZE + x];
*properties = tile & 0xc0; *properties = tile & 0xc0;
return map->tileDictionary[tile & 0x3f]; return level->tileDictionary[tile & 0x3f];
} }
static const SFG_Level SFG_level0 = static const SFG_Level SFG_level0 =
{ {
{ // map
{ // map.mapArray { // map.mapArray
#define o 0 #define o 0
#define AA (0x04 | SFG_TILE_PROPERTY_ELEVATOR) #define AA (0x04 | SFG_TILE_PROPERTY_ELEVATOR)
@ -193,7 +187,6 @@ static const SFG_Level SFG_level0 =
}, },
{0, 1, 2, 3, 4, 5, 10}, // map.textureIndices {0, 1, 2, 3, 4, 5, 10}, // map.textureIndices
7 // map.doorTextureIndex 7 // map.doorTextureIndex
}
}; };
#endif // guard #endif // guard

14
main.c
View File

@ -85,7 +85,6 @@ uint16_t SFG_backgroundScroll;
*/ */
struct struct
{ {
const SFG_Map *mapPointer;
const SFG_Level *levelPointer; const SFG_Level *levelPointer;
const uint8_t* textures[7]; const uint8_t* textures[7];
uint32_t timeStart; uint32_t timeStart;
@ -106,7 +105,7 @@ void SFG_pixelFunc(RCL_PixelInfo *pixel)
: :
( (
(pixel->texCoords.y > RCL_UNITS_PER_SQUARE) ? (pixel->texCoords.y > RCL_UNITS_PER_SQUARE) ?
(pixel->hit.type & 0x7) : 255 // SFG_currentLevel.mapPointer->doorTextureIndex (pixel->hit.type & 0x7) : 255 // SFG_currentLevel.levelPointer->doorTextureIndex
) )
): ):
((pixel->hit.type & 0x38) >> 3); ((pixel->hit.type & 0x38) >> 3);
@ -121,7 +120,7 @@ void SFG_pixelFunc(RCL_PixelInfo *pixel)
(SFG_getTexel( (SFG_getTexel(
textureIndex != 255 ? textureIndex != 255 ?
SFG_currentLevel.textures[textureIndex]: SFG_currentLevel.textures[textureIndex]:
SFG_texturesWall[SFG_currentLevel.mapPointer->doorTextureIndex], SFG_texturesWall[SFG_currentLevel.levelPointer->doorTextureIndex],
pixel->texCoords.x / 32, pixel->texCoords.x / 32,
textureV / 32) textureV / 32)
) : ) :
@ -179,7 +178,7 @@ RCL_Unit SFG_texturesAt(int16_t x, int16_t y)
{ {
uint8_t p; uint8_t p;
SFG_TileDefinition tile = SFG_getMapTile(&(SFG_level0.map),x,y,&p); SFG_TileDefinition tile = SFG_getMapTile(&SFG_level0,x,y,&p);
return return
SFG_TILE_FLOOR_TEXTURE(tile) | (SFG_TILE_CEILING_TEXTURE(tile) << 3) | p; SFG_TILE_FLOOR_TEXTURE(tile) | (SFG_TILE_CEILING_TEXTURE(tile) << 3) | p;
// ^ store both textures (floor and ceiling) and properties in one number // ^ store both textures (floor and ceiling) and properties in one number
@ -206,7 +205,7 @@ RCL_Unit SFG_floorHeightAt(int16_t x, int16_t y)
{ {
uint8_t properties; uint8_t properties;
SFG_TileDefinition tile = SFG_getMapTile(&(SFG_level0.map),x,y,&properties); SFG_TileDefinition tile = SFG_getMapTile(&SFG_level0,x,y,&properties);
return properties != SFG_TILE_PROPERTY_ELEVATOR ? return properties != SFG_TILE_PROPERTY_ELEVATOR ?
SFG_TILE_FLOOR_HEIGHT(tile) * SFG_WALL_HEIGHT_STEP : SFG_TILE_FLOOR_HEIGHT(tile) * SFG_WALL_HEIGHT_STEP :
@ -221,7 +220,7 @@ RCL_Unit SFG_floorHeightAt(int16_t x, int16_t y)
RCL_Unit SFG_ceilingHeightAt(int16_t x, int16_t y) RCL_Unit SFG_ceilingHeightAt(int16_t x, int16_t y)
{ {
uint8_t properties; uint8_t properties;
SFG_TileDefinition tile = SFG_getMapTile(&(SFG_level0.map),x,y,&properties); SFG_TileDefinition tile = SFG_getMapTile(&SFG_level0,x,y,&properties);
if (properties == SFG_TILE_PROPERTY_ELEVATOR) if (properties == SFG_TILE_PROPERTY_ELEVATOR)
return SFG_CEILING_MAX_HEIGHT; return SFG_CEILING_MAX_HEIGHT;
@ -261,11 +260,10 @@ void SFG_recompurePLayerDirection()
void SFG_setLevel(const SFG_Level *level) void SFG_setLevel(const SFG_Level *level)
{ {
SFG_currentLevel.levelPointer = level; SFG_currentLevel.levelPointer = level;
SFG_currentLevel.mapPointer = &(level->map);
for (uint8_t i = 0; i < 7; ++i) for (uint8_t i = 0; i < 7; ++i)
SFG_currentLevel.textures[i] = SFG_currentLevel.textures[i] =
SFG_texturesWall[level->map.textureIndices[i]]; SFG_texturesWall[level->textureIndices[i]];
SFG_currentLevel.timeStart = SFG_getTimeMs(); SFG_currentLevel.timeStart = SFG_getTimeMs();