SpaceCadetPinball/SpaceCadetPinball/gdrv.h

75 lines
1.6 KiB
C
Raw Normal View History

2020-11-07 16:41:14 +01:00
#pragma once
2020-11-08 16:37:59 +01:00
enum class BitmapTypes : uint8_t
2020-11-08 16:37:59 +01:00
{
2020-11-13 17:04:58 +01:00
None = 0,
RawBitmap = 1,
DibBitmap = 2,
Spliced = 3,
2020-11-08 16:37:59 +01:00
};
2020-11-13 17:04:58 +01:00
struct Rgba
{
uint8_t Blue;
uint8_t Green;
uint8_t Red;
uint8_t Alpha;
};
union ColorRgba
{
ColorRgba() = default;
explicit ColorRgba(uint32_t color)
: Color(color)
{
}
explicit ColorRgba(Rgba rgba)
: rgba(rgba)
{
}
uint32_t Color;
Rgba rgba;
};
static_assert(sizeof(ColorRgba) == 4, "Wrong size of RGBA color");
struct gdrv_bitmap8
{
gdrv_bitmap8(int width, int height, bool indexed);
gdrv_bitmap8(const struct dat8BitBmpHeader& header);
~gdrv_bitmap8();
void ScaleIndexed(float scaleX, float scaleY);
ColorRgba* BmpBufPtr1;
char* IndexedBmpPtr;
int Width;
int Height;
int Stride;
int IndexedStride;
BitmapTypes BitmapType;
int XPosition;
int YPosition;
unsigned Resolution;
SDL_Texture* Texture;
};
2020-11-08 16:37:59 +01:00
2020-11-07 16:41:14 +01:00
class gdrv
{
public:
static int display_palette(ColorRgba* plt);
static void fill_bitmap(gdrv_bitmap8* bmp, int width, int height, int xOff, int yOff, uint8_t fillChar);
2020-11-13 17:04:58 +01:00
static void copy_bitmap(gdrv_bitmap8* dstBmp, int width, int height, int xOff, int yOff, gdrv_bitmap8* srcBmp,
int srcXOff, int srcYOff);
static void copy_bitmap_w_transparency(gdrv_bitmap8* dstBmp, int width, int height, int xOff, int yOff,
gdrv_bitmap8* srcBmp, int srcXOff, int srcYOff);
static void grtext_draw_ttext_in_box(LPCSTR text, int xOff, int yOff, int width, int height, int a6);
static void ApplyPalette(gdrv_bitmap8& bmp);
static void CreatePreview(gdrv_bitmap8& bmp);
2020-11-08 16:37:59 +01:00
private:
static ColorRgba current_palette[256];
2020-11-07 16:41:14 +01:00
};