Move more stuff to general

This commit is contained in:
Miloslav Číž 2018-09-08 15:00:13 +02:00
parent 3457570fb6
commit 9129659e62

View file

@ -9,9 +9,6 @@
#include "general.hpp" #include "general.hpp"
#define SUBSAMPLE 2
#define SUBSAMPLED_WIDTH (SCREEN_WIDTH / SUBSAMPLE)
#define LEVEL_X_RES 29 #define LEVEL_X_RES 29
#define LEVEL_Y_RES 21 #define LEVEL_Y_RES 21
@ -19,8 +16,10 @@ Player player;
#define SPRITES 3 #define SPRITES 3
#define SPRITE_MAX_DISTANCE 5 * UNITS_PER_SQUARE #define SPRITE_MAX_DISTANCE 5 * UNITS_PER_SQUARE
Sprite sprites[SPRITES]; Sprite sprites[SPRITES];
/// For each level square says the texture index.
const unsigned char levelTexture[] = const unsigned char levelTexture[] =
{ {
1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3, 0, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3, 0, 3, 3, 2, 2, 2, 2,
@ -46,6 +45,7 @@ const unsigned char levelTexture[] =
1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3
}; };
/// For each level square says the floor height.
const signed char levelFloor[] = const signed char levelFloor[] =
{ {
40,40,40,40,40,40,40,40,48,40,48,40,40,40,40,40,40,48,40,48,40,48,40,48,48,24,24,26,28, 40,40,40,40,40,40,40,40,48,40,48,40,40,40,40,40,40,48,40,48,40,48,40,48,48,24,24,26,28,
@ -71,6 +71,7 @@ const signed char levelFloor[] =
0,24,24,24,32,32,32,27,24,27,30,34,36,38,36,34,36,34,34,32,32,33,37,39,24,24,24,24,24 0,24,24,24,32,32,32,27,24,27,30,34,36,38,36,34,36,34,34,32,32,33,37,39,24,24,24,24,24
}; };
/// For each level square says the ceiling height.
const signed char levelCeiling[] = const signed char levelCeiling[] =
{ {
40,40,40,40,40,40,40,99,99,99,99,36,40,40,40,40,40,36,99,99,99,99,99,99,99,99,99,99,99, 40,40,40,40,40,40,40,99,99,99,99,36,40,40,40,40,40,36,99,99,99,99,99,99,99,99,99,99,99,
@ -566,7 +567,6 @@ const unsigned char sprite2[] =
const unsigned char *textures[] = {texture1, texture2, texture3, texture4}; const unsigned char *textures[] = {texture1, texture2, texture3, texture4};
Unit textureAt(int16_t x, int16_t y) Unit textureAt(int16_t x, int16_t y)
{ {
if (x >= 0 && x < LEVEL_X_RES && y >= 0 && y < LEVEL_Y_RES) if (x >= 0 && x < LEVEL_X_RES && y >= 0 && y < LEVEL_Y_RES)
@ -593,6 +593,9 @@ Unit ceilingHeightAt(int16_t x, int16_t y)
return (v * UNITS_PER_SQUARE) / 8; return (v * UNITS_PER_SQUARE) / 8;
} }
/**
Function for drawing a single pixel (like fragment shader).
*/
inline void pixelFunc(PixelInfo pixel) inline void pixelFunc(PixelInfo pixel)
{ {
if (pixel.position.y == MIDDLE_ROW) if (pixel.position.y == MIDDLE_ROW)