SpaceCadetPinball/SpaceCadetPinball/gdrv.h

70 lines
2.0 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 : char
2020-11-08 16:37:59 +01:00
{
2020-11-13 17:04:58 +01:00
None = 0,
RawBitmap = 1,
DibBitmap = 2,
Spliced = 4,
2020-11-08 16:37:59 +01:00
};
struct gdrv_bitmap8
2020-11-08 16:37:59 +01:00
{
char* BmpBufPtr1;
int Width;
int Height;
int Stride;
BitmapTypes BitmapType;
2020-11-08 16:37:59 +01:00
int XPosition;
int YPosition;
};
2020-11-13 17:04:58 +01:00
struct Rgba
{
uint8_t peRed;
uint8_t peGreen;
uint8_t peBlue;
uint8_t peFlags;
};
union ColorRgba
{
uint32_t Color;
Rgba rgba;
};
static_assert(sizeof(ColorRgba) == 4, "Wrong size of RGBA color");
2020-11-08 16:37:59 +01:00
2020-11-07 16:41:14 +01:00
class gdrv
{
public:
static SDL_Rect DestinationRect;
static int init(int width, int height);
2020-11-13 17:04:58 +01:00
static int uninit();
2020-11-08 16:37:59 +01:00
static void get_focus();
static int create_bitmap(gdrv_bitmap8* bmp, int width, int height);
static int create_raw_bitmap(gdrv_bitmap8* bmp, int width, int height, int flag);
static int create_spliced_bitmap(gdrv_bitmap8* bmp, int width, int height, int size);
2020-11-13 17:04:58 +01:00
static int destroy_bitmap(gdrv_bitmap8* bmp);
static int display_palette(ColorRgba* plt);
2021-02-09 16:09:44 +01:00
static void start_blit_sequence();
2020-11-13 17:04:58 +01:00
static void end_blit_sequence();
static void blit(gdrv_bitmap8* bmp, int xSrc, int ySrc, int xDest, int yDest, int width, int height);
2020-11-13 17:04:58 +01:00
static void blat(gdrv_bitmap8* bmp, int xDest, int yDest);
static void fill_bitmap(gdrv_bitmap8* bmp, int width, int height, int xOff, int yOff, char fillChar);
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 BlitScreen();
2020-11-08 16:37:59 +01:00
private:
static SDL_Texture* vScreenTex;
static char* vScreenPixels;
static int vScreenWidth, vScreenHeight;
static ColorRgba current_palette[256];
2021-02-09 16:09:44 +01:00
static int StretchDIBitsScaled(int xSrc, int ySrc, int xDst, int yDst,
int width, int height, gdrv_bitmap8* bmp);
2020-11-07 16:41:14 +01:00
};