Add platform const

This commit is contained in:
Miloslav Číž 2019-10-02 20:31:27 +02:00
parent 2d3956a506
commit 5f83fd9acf
7 changed files with 38 additions and 11 deletions

View File

@ -25,7 +25,8 @@ static inline uint8_t SFG_getTexel(const uint8_t *texture, uint8_t x, uint8_t y)
return texture[(x & 0x1f) * SFG_TEXTURE_SIZE + (y & 0x1f)];
}
const uint8_t SFG_texturesWall[][SFG_TEXTURE_SIZE * SFG_TEXTURE_SIZE] =
SFG_PROGRAM_MEMORY uint8_t
SFG_texturesWall[][SFG_TEXTURE_SIZE * SFG_TEXTURE_SIZE] =
{
{ // 0: white wooden planks
4,4,4,21,4,4,4,3,5,4,4,21,5,21,4,4,57,21,20,4,4,21,21,4,20,4,4,3,4,3,5,4,4,4,21,
@ -486,7 +487,7 @@ const uint8_t SFG_texturesWall[][SFG_TEXTURE_SIZE * SFG_TEXTURE_SIZE] =
}
};
const uint8_t SFG_sprites[][SFG_TEXTURE_SIZE * SFG_TEXTURE_SIZE] =
SFG_PROGRAM_MEMORY uint8_t SFG_sprites[][SFG_TEXTURE_SIZE * SFG_TEXTURE_SIZE] =
{
{ // 0: barrel
175,175,175,175,175,175,175,175,175,175,175,175,175,175,175,175,175,175,175,175,
@ -532,7 +533,8 @@ const uint8_t SFG_sprites[][SFG_TEXTURE_SIZE * SFG_TEXTURE_SIZE] =
}
};
const uint8_t SFG_backgrounds[][SFG_TEXTURE_SIZE * SFG_TEXTURE_SIZE] =
SFG_PROGRAM_MEMORY
uint8_t SFG_backgrounds[][SFG_TEXTURE_SIZE * SFG_TEXTURE_SIZE] =
{
{ // 5
10,10,10,10,10,10,19,19,12,13,13,13,13,13,13,13,13,14,64,80,64,64,73,64,64,64,

View File

@ -91,7 +91,7 @@ static inline SFG_TileDefinition SFG_getMapTile
return level->tileDictionary[tile & 0x3f];
}
static const SFG_Level SFG_level0 =
SFG_PROGRAM_MEMORY SFG_Level SFG_level0 =
{
{ // mapArray
#define o 0
@ -194,7 +194,7 @@ static const SFG_Level SFG_level0 =
32 // ceilingColor
};
static const SFG_Level SFG_level1 =
SFG_PROGRAM_MEMORY SFG_Level SFG_level1 =
{
{ // mapArray
#define o 0

29
main.c
View File

@ -1,8 +1,4 @@
#include <stdint.h>
#include "constants.h"
#include "levels.h"
#include "assets.h"
#include "palette.h"
/*
The following keys are mandatory to be implemented on any platform in order
@ -36,6 +32,9 @@
#define SFG_LOG(str) ; ///< Can be redefined to log messages for better debug.
#define SFG_PROGRAM_MEMORY static const /**< Can be redefined to platform's
specifier of program meory. */
/** Return 1 (0) if given key is pressed (not pressed). At least the mandatory
keys have to be implemented, the optional keys don't have to ever return 1.
See the key contant definitions to see which ones are mandatory. */
@ -71,6 +70,11 @@ void SFG_init();
#include "platform_sdl.h"
#endif
#include "constants.h"
#include "levels.h"
#include "assets.h"
#include "palette.h"
#define SFG_MS_PER_FRAME (1000 / SFG_FPS) // ms per frame with target FPS
#define SFG_PLAYER_TURN_UNITS_PER_FRAME\
@ -138,6 +142,21 @@ void SFG_initPlayer()
RCL_RayConstraints SFG_rayConstraints;
typedef struct
{
uint8_t coords[2];
uint8_t state; /**< door state in format:
ccbaaaaa
aaaaa: current door height (how much they're open)
b: whether currently going up (0) or down (1)
cc: by which keys the door is unlocked
*/
} SFG_doorRecord;
#define SFG_MAX_DOORS 32
/**
Stores the current level and helper precomputed vaues for better performance.
*/
@ -148,6 +167,8 @@ struct
uint32_t timeStart;
uint8_t floorColor;
uint8_t ceilingColor;
SFG_doorRecord doors[SFG_MAX_DOORS];
uint8_t doorRecordCount;
} SFG_currentLevel;
void SFG_pixelFunc(RCL_PixelInfo *pixel)

3
make.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
clear; clear; g++ -x c -g -fmax-errors=5 -pedantic -O3 -Wall -Wextra -o game main.c -lSDL2 2>&1 >/dev/null && ./game

View File

@ -9,7 +9,7 @@
#ifndef PALETTE_256_H
#define PALETTE_256_H
const uint16_t paletteRGB565[256] = {
SFG_PROGRAM_MEMORY uint16_t paletteRGB565[256] = {
0, 8484, 19017, 27501, 38034, 46518, 57051, 65535, 8354, 16709, 25096, 33450,
41805, 50192, 58546, 64853, 8386, 16805, 25224, 33642, 42061, 50480, 58898,
65269, 6402, 14853, 23304, 29706, 38157, 46608, 55058, 61429, 4354, 10757,

View File

@ -22,6 +22,7 @@
#define SFG_RAYCASTING_MAX_HITS 6
#include "Pokitto.h"
#include "palette.h"
Pokitto::Core pokitto;

View File

@ -8,7 +8,7 @@
/**
Turn on for previes mode for map editing (flying, noclip, fast movement etc.).
*/
#define SFG_PREVIEW_MODE 1
#define SFG_PREVIEW_MODE 0
/**
How much faster movement is in the preview mode.