Add resolution subdivision
This commit is contained in:
parent
ccbb9dfdc3
commit
e47704dbb0
3 changed files with 62 additions and 39 deletions
62
game.h
62
game.h
|
@ -52,12 +52,12 @@
|
|||
format (described in the map module) etc.
|
||||
*/
|
||||
|
||||
#define LCR_KEY_UP 0x00
|
||||
#define LCR_KEY_RIGHT 0x01
|
||||
#define LCR_KEY_DOWN 0x02
|
||||
#define LCR_KEY_LEFT 0x03
|
||||
#define LCR_KEY_A 0x04 ///< confirm, restart race
|
||||
#define LCR_KEY_B 0x05 ///< cancel, open menu
|
||||
#define LCR_KEY_UP 0x00
|
||||
#define LCR_KEY_RIGHT 0x01
|
||||
#define LCR_KEY_DOWN 0x02
|
||||
#define LCR_KEY_LEFT 0x03
|
||||
#define LCR_KEY_A 0x04 ///< confirm, restart race
|
||||
#define LCR_KEY_B 0x05 ///< cancel, open menu
|
||||
|
||||
#define LCR_KEYS_TOTAL 6
|
||||
|
||||
|
@ -201,19 +201,26 @@ uint8_t LCR_gameGetNextAudioSample(void);
|
|||
|
||||
// forward decls of pixel drawing functions for the renderer
|
||||
|
||||
/**
|
||||
Internal function for drawing pixels, takes into account setting etc., should
|
||||
be used instead of directly calling LCR_drawPixel.
|
||||
*/
|
||||
static inline void LCR_gameDrawPixel(unsigned long index, uint16_t color);
|
||||
|
||||
/**
|
||||
Internal pixel drawing function that puts a pixel at specified screen coords
|
||||
without checking for safety (it's faster but can only be done if we know for
|
||||
sure we're not drawing outside the screen).
|
||||
*/
|
||||
void LCR_drawPixelXYUnsafe(unsigned int x, unsigned int y, uint16_t color);
|
||||
static inline void LCR_gameDrawPixelXYUnsafe(unsigned int x, unsigned int y,
|
||||
uint16_t color);
|
||||
|
||||
/**
|
||||
Internal pixel drawing function that checks for out-of-screen coordinates. Use
|
||||
this if the pixel can potentially lie of screen (however if you know it won't,
|
||||
use the normal unsafe function in sake of performance).
|
||||
*/
|
||||
static inline void LCR_drawPixelXYSafe(unsigned int x, unsigned int y,
|
||||
static inline void LCR_gameDrawPixelXYSafe(unsigned int x, unsigned int y,
|
||||
uint_fast16_t color);
|
||||
|
||||
#include "general.h"
|
||||
|
@ -311,14 +318,32 @@ uint8_t LCR_gameMusicOn(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
void LCR_drawPixelXYUnsafe(unsigned int x, unsigned int y,
|
||||
void LCR_gameDrawPixel(unsigned long index, uint16_t color)
|
||||
{
|
||||
#if LCR_SETTING_RESOLUTION_SUBDIVIDE <= 1
|
||||
LCR_drawPixel(index,color);
|
||||
#else
|
||||
|
||||
index = ((index / LCR_EFFECTIVE_RESOLUTION_X) * LCR_SETTING_RESOLUTION_X +
|
||||
(index % LCR_EFFECTIVE_RESOLUTION_X)) * LCR_SETTING_RESOLUTION_SUBDIVIDE;
|
||||
|
||||
for (int y = 0; y < LCR_SETTING_RESOLUTION_SUBDIVIDE; ++y)
|
||||
{
|
||||
for (int x = 0; x < LCR_SETTING_RESOLUTION_SUBDIVIDE; ++x)
|
||||
{
|
||||
LCR_drawPixel(index,color);
|
||||
index++;
|
||||
}
|
||||
|
||||
index += LCR_SETTING_RESOLUTION_X - LCR_SETTING_RESOLUTION_SUBDIVIDE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void LCR_gameDrawPixelXYUnsafe(unsigned int x, unsigned int y,
|
||||
uint16_t color)
|
||||
{
|
||||
#if LCR_SETTING_RESOLUTION_SUBDIVIDE == 1
|
||||
LCR_drawPixel(y * LCR_SETTING_RESOLUTION_X + x,color);
|
||||
#else
|
||||
// TODO
|
||||
#endif
|
||||
LCR_gameDrawPixel(y * LCR_EFFECTIVE_RESOLUTION_X + x,color);
|
||||
}
|
||||
|
||||
void _LCR_physicdDebugDrawPixel(uint16_t x, uint16_t y, uint8_t color)
|
||||
|
@ -330,15 +355,15 @@ void _LCR_physicdDebugDrawPixel(uint16_t x, uint16_t y, uint8_t color)
|
|||
|
||||
for (int j = -1; j <= 2; ++j)
|
||||
for (int i = -1; i <= 2; ++i)
|
||||
LCR_drawPixelXYUnsafe(x + i,y + j,c);
|
||||
LCR_gameDrawPixelXYUnsafe(x + i,y + j,c);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void LCR_drawPixelXYSafe(unsigned int x, unsigned int y,
|
||||
static inline void LCR_gameDrawPixelXYSafe(unsigned int x, unsigned int y,
|
||||
uint_fast16_t color)
|
||||
{
|
||||
if (x < LCR_EFFECTIVE_RESOLUTION_X && y < LCR_EFFECTIVE_RESOLUTION_Y)
|
||||
LCR_drawPixelXYUnsafe(x,y,color);
|
||||
LCR_gameDrawPixelXYUnsafe(x,y,color);
|
||||
}
|
||||
|
||||
void LCR_gameSetState(uint8_t state)
|
||||
|
@ -969,9 +994,6 @@ void LCR_checkBeatenMaps(void)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void LCR_gameEnd(void)
|
||||
{
|
||||
LCR_LOG0("ending");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue