gdrv: blit no more, present render:vScreen directly.
Improved split bitmap handling.
This commit is contained in:
@@ -18,16 +18,6 @@ EntryData::~EntryData()
|
|||||||
zdrv::destroy_zmap(reinterpret_cast<zmap_header_type*>(Buffer));
|
zdrv::destroy_zmap(reinterpret_cast<zmap_header_type*>(Buffer));
|
||||||
memory::free(Buffer);
|
memory::free(Buffer);
|
||||||
}
|
}
|
||||||
if (DerivedBmp)
|
|
||||||
{
|
|
||||||
gdrv::destroy_bitmap(DerivedBmp);
|
|
||||||
memory::free(DerivedBmp);
|
|
||||||
}
|
|
||||||
if (DerivedZMap)
|
|
||||||
{
|
|
||||||
zdrv::destroy_zmap(DerivedZMap);
|
|
||||||
memory::free(DerivedZMap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -38,8 +28,7 @@ GroupData::GroupData(int groupId)
|
|||||||
|
|
||||||
void GroupData::AddEntry(EntryData* entry)
|
void GroupData::AddEntry(EntryData* entry)
|
||||||
{
|
{
|
||||||
Entries.push_back(entry);
|
auto addEntry = true;
|
||||||
|
|
||||||
switch (entry->EntryType)
|
switch (entry->EntryType)
|
||||||
{
|
{
|
||||||
case FieldTypes::GroupName:
|
case FieldTypes::GroupName:
|
||||||
@@ -47,21 +36,23 @@ void GroupData::AddEntry(EntryData* entry)
|
|||||||
break;
|
break;
|
||||||
case FieldTypes::Bitmap8bit:
|
case FieldTypes::Bitmap8bit:
|
||||||
{
|
{
|
||||||
auto bmp = reinterpret_cast<gdrv_bitmap8*>(entry->Buffer);
|
auto srcBmp = reinterpret_cast<gdrv_bitmap8*>(entry->Buffer);
|
||||||
if (bmp->BitmapType == BitmapTypes::Spliced)
|
if (srcBmp->BitmapType == BitmapTypes::Spliced)
|
||||||
{
|
{
|
||||||
// Get rid of spliced bitmap early on, to simplify render pipeline
|
// Get rid of spliced bitmap early on, to simplify render pipeline
|
||||||
auto splitBmp = memory::allocate<gdrv_bitmap8>();
|
auto bmp = memory::allocate<gdrv_bitmap8>();
|
||||||
auto splitZMap = memory::allocate<zmap_header_type>();
|
auto zMap = memory::allocate<zmap_header_type>();
|
||||||
SplitSplicedBitmap(*bmp, *splitBmp, *splitZMap);
|
SplitSplicedBitmap(*srcBmp, *bmp, *zMap);
|
||||||
entry->DerivedBmp = splitBmp;
|
|
||||||
entry->DerivedZMap = splitZMap;
|
NeedsSort = true;
|
||||||
SetBitmap(splitBmp);
|
addEntry = false;
|
||||||
SetZMap(splitZMap);
|
AddEntry(new EntryData(FieldTypes::Bitmap8bit, reinterpret_cast<char*>(bmp)));
|
||||||
|
AddEntry(new EntryData(FieldTypes::Bitmap16bit, reinterpret_cast<char*>(zMap)));
|
||||||
|
delete entry;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetBitmap(bmp);
|
SetBitmap(srcBmp);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -72,6 +63,24 @@ void GroupData::AddEntry(EntryData* entry)
|
|||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (addEntry)
|
||||||
|
Entries.push_back(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GroupData::FinalizeGroup()
|
||||||
|
{
|
||||||
|
if (NeedsSort)
|
||||||
|
{
|
||||||
|
// Entries within a group are sorted by EntryType, in ascending order.
|
||||||
|
// Dat files follow this rule, zMaps inserted in the middle break it.
|
||||||
|
NeedsSort = false;
|
||||||
|
std::sort(Entries.begin(), Entries.end(), [](const EntryData* lhs, const EntryData* rhs)
|
||||||
|
{
|
||||||
|
return lhs->EntryType < rhs->EntryType;
|
||||||
|
});
|
||||||
|
Entries.shrink_to_fit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gdrv_bitmap8* GroupData::GetBitmap(int resolution) const
|
gdrv_bitmap8* GroupData::GetBitmap(int resolution) const
|
||||||
|
|||||||
@@ -43,12 +43,16 @@ enum class FieldTypes : int16_t
|
|||||||
|
|
||||||
struct EntryData
|
struct EntryData
|
||||||
{
|
{
|
||||||
|
EntryData() = default;
|
||||||
|
|
||||||
|
EntryData(FieldTypes entryType, char* buffer): EntryType(entryType), FieldSize(-1), Buffer(buffer)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
~EntryData();
|
~EntryData();
|
||||||
FieldTypes EntryType{};
|
FieldTypes EntryType{};
|
||||||
int FieldSize{};
|
int FieldSize{};
|
||||||
char* Buffer{};
|
char* Buffer{};
|
||||||
gdrv_bitmap8* DerivedBmp{};
|
|
||||||
zmap_header_type* DerivedZMap{};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class GroupData
|
class GroupData
|
||||||
@@ -59,6 +63,7 @@ public:
|
|||||||
|
|
||||||
GroupData(int groupId);
|
GroupData(int groupId);
|
||||||
void AddEntry(EntryData* entry);
|
void AddEntry(EntryData* entry);
|
||||||
|
void FinalizeGroup();
|
||||||
const std::vector<EntryData*>& GetEntries() const { return Entries; }
|
const std::vector<EntryData*>& GetEntries() const { return Entries; }
|
||||||
const EntryData* GetEntry(size_t index) const { return Entries[index]; }
|
const EntryData* GetEntry(size_t index) const { return Entries[index]; }
|
||||||
size_t EntryCount() const { return Entries.size(); }
|
size_t EntryCount() const { return Entries.size(); }
|
||||||
@@ -70,6 +75,7 @@ private:
|
|||||||
std::vector<EntryData*> Entries;
|
std::vector<EntryData*> Entries;
|
||||||
gdrv_bitmap8* Bitmaps[3]{};
|
gdrv_bitmap8* Bitmaps[3]{};
|
||||||
zmap_header_type* ZMaps[3]{};
|
zmap_header_type* ZMaps[3]{};
|
||||||
|
bool NeedsSort = false;
|
||||||
|
|
||||||
static void SplitSplicedBitmap(const gdrv_bitmap8& srcBmp, gdrv_bitmap8& bmp, zmap_header_type& zMap);
|
static void SplitSplicedBitmap(const gdrv_bitmap8& srcBmp, gdrv_bitmap8& bmp, zmap_header_type& zMap);
|
||||||
|
|
||||||
|
|||||||
@@ -85,15 +85,7 @@ void TTextBox::Clear()
|
|||||||
OffsetX,
|
OffsetX,
|
||||||
OffsetY);
|
OffsetY);
|
||||||
else
|
else
|
||||||
gdrv::fill_bitmap(&render::vscreen, Width, Height, OffsetX, OffsetY, 0);
|
gdrv::fill_bitmap(&render::vscreen, Width, Height, OffsetX, OffsetY, 0);
|
||||||
gdrv::blit(
|
|
||||||
&render::vscreen,
|
|
||||||
OffsetX,
|
|
||||||
OffsetY,
|
|
||||||
OffsetX + render::vscreen.XPosition,
|
|
||||||
OffsetY + render::vscreen.YPosition,
|
|
||||||
Width,
|
|
||||||
Height);
|
|
||||||
if (Timer)
|
if (Timer)
|
||||||
{
|
{
|
||||||
if (Timer != -1)
|
if (Timer != -1)
|
||||||
@@ -198,14 +190,6 @@ void TTextBox::Draw()
|
|||||||
auto font = Font;
|
auto font = Font;
|
||||||
if (!font)
|
if (!font)
|
||||||
{
|
{
|
||||||
gdrv::blit(
|
|
||||||
&render::vscreen,
|
|
||||||
OffsetX,
|
|
||||||
OffsetY,
|
|
||||||
OffsetX + render::vscreen.XPosition,
|
|
||||||
OffsetY + render::vscreen.YPosition,
|
|
||||||
Width,
|
|
||||||
Height);
|
|
||||||
gdrv::grtext_draw_ttext_in_box(
|
gdrv::grtext_draw_ttext_in_box(
|
||||||
Message1->Text,
|
Message1->Text,
|
||||||
render::vscreen.XPosition + OffsetX,
|
render::vscreen.XPosition + OffsetX,
|
||||||
@@ -275,14 +259,5 @@ void TTextBox::Draw()
|
|||||||
if ((*text & 0x7F) == '\n')
|
if ((*text & 0x7F) == '\n')
|
||||||
++text;
|
++text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gdrv::blit(
|
|
||||||
&render::vscreen,
|
|
||||||
OffsetX,
|
|
||||||
OffsetY,
|
|
||||||
OffsetX + render::vscreen.XPosition,
|
|
||||||
OffsetY + render::vscreen.YPosition,
|
|
||||||
Width,
|
|
||||||
Height);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ void fullscrn::window_size_changed()
|
|||||||
OffsetY = static_cast<int>(floor((height - res->TableHeight * ScaleY) / 2));
|
OffsetY = static_cast<int>(floor((height - res->TableHeight * ScaleY) / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
gdrv::DestinationRect = SDL_Rect
|
render::DestinationRect = SDL_Rect
|
||||||
{
|
{
|
||||||
OffsetX, OffsetY,
|
OffsetX, OffsetY,
|
||||||
width - OffsetX * 2, height - OffsetY * 2
|
width - OffsetX * 2, height - OffsetY * 2
|
||||||
|
|||||||
@@ -9,41 +9,7 @@
|
|||||||
#include "score.h"
|
#include "score.h"
|
||||||
#include "winmain.h"
|
#include "winmain.h"
|
||||||
|
|
||||||
SDL_Texture* gdrv::vScreenTex = nullptr;
|
|
||||||
ColorRgba* gdrv::vScreenPixels = nullptr;
|
|
||||||
int gdrv::vScreenWidth, gdrv::vScreenHeight;
|
|
||||||
ColorRgba gdrv::current_palette[256]{};
|
ColorRgba gdrv::current_palette[256]{};
|
||||||
SDL_Rect gdrv::DestinationRect{};
|
|
||||||
|
|
||||||
int gdrv::init(int width, int height)
|
|
||||||
{
|
|
||||||
{
|
|
||||||
UsingSdlHint hint{SDL_HINT_RENDER_SCALE_QUALITY, options::Options.LinearFiltering ? "linear" : "nearest"};
|
|
||||||
vScreenTex = SDL_CreateTexture
|
|
||||||
(
|
|
||||||
winmain::Renderer,
|
|
||||||
SDL_PIXELFORMAT_ARGB8888,
|
|
||||||
SDL_TEXTUREACCESS_STREAMING,
|
|
||||||
width, height
|
|
||||||
);
|
|
||||||
}
|
|
||||||
vScreenWidth = width;
|
|
||||||
vScreenHeight = height;
|
|
||||||
vScreenPixels = new ColorRgba[width * height];
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int gdrv::uninit()
|
|
||||||
{
|
|
||||||
SDL_DestroyTexture(vScreenTex);
|
|
||||||
delete[] vScreenPixels;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void gdrv::get_focus()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int gdrv::create_bitmap(gdrv_bitmap8* bmp, int width, int height, int stride, bool indexed)
|
int gdrv::create_bitmap(gdrv_bitmap8* bmp, int width, int height, int stride, bool indexed)
|
||||||
{
|
{
|
||||||
@@ -122,23 +88,23 @@ int gdrv::display_palette(ColorRgba* plt)
|
|||||||
{
|
{
|
||||||
const uint32_t sysPaletteColors[]
|
const uint32_t sysPaletteColors[]
|
||||||
{
|
{
|
||||||
0x00000000, // Color 0: transparent
|
0xff000000, // Color 0: transparent
|
||||||
0x00000080,
|
0xff000080,
|
||||||
0x00008000,
|
0xff008000,
|
||||||
0x00008080,
|
0xff008080,
|
||||||
0x00800000,
|
0xff800000,
|
||||||
0x00800080,
|
0xff800080,
|
||||||
0x00808000,
|
0xff808000,
|
||||||
0x00C0C0C0,
|
0xffC0C0C0,
|
||||||
0x00C0DCC0,
|
0xffC0DCC0,
|
||||||
0x00F0CAA6
|
0xffF0CAA6
|
||||||
};
|
};
|
||||||
|
|
||||||
memcpy(current_palette, sysPaletteColors, sizeof sysPaletteColors);
|
memcpy(current_palette, sysPaletteColors, sizeof sysPaletteColors);
|
||||||
|
|
||||||
for (int i = 0; i < 256; i++)
|
for (int i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
current_palette[i].rgba.peFlags = 0;
|
current_palette[i].rgba.Alpha = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pltSrc = &plt[10];
|
auto pltSrc = &plt[10];
|
||||||
@@ -147,18 +113,16 @@ int gdrv::display_palette(ColorRgba* plt)
|
|||||||
{
|
{
|
||||||
if (plt)
|
if (plt)
|
||||||
{
|
{
|
||||||
pltDst->rgba.peRed = pltSrc->rgba.peRed;
|
pltDst->rgba.Blue = pltSrc->rgba.Blue;
|
||||||
pltDst->rgba.peGreen = pltSrc->rgba.peGreen;
|
pltDst->rgba.Green = pltSrc->rgba.Green;
|
||||||
pltDst->rgba.peBlue = pltSrc->rgba.peBlue;
|
pltDst->rgba.Red = pltSrc->rgba.Red;
|
||||||
}
|
}
|
||||||
pltDst->rgba.peFlags = 4;
|
pltDst->rgba.Alpha = 0xFF;
|
||||||
pltSrc++;
|
pltSrc++;
|
||||||
pltDst++;
|
pltDst++;
|
||||||
}
|
}
|
||||||
|
|
||||||
current_palette[255].rgba.peBlue = -1;
|
current_palette[255].Color = 0xffFFFFFF;
|
||||||
current_palette[255].rgba.peGreen = -1;
|
|
||||||
current_palette[255].rgba.peRed = -1;
|
|
||||||
|
|
||||||
score::ApplyPalette();
|
score::ApplyPalette();
|
||||||
for (const auto group : pb::record_table->Groups)
|
for (const auto group : pb::record_table->Groups)
|
||||||
@@ -194,32 +158,6 @@ int gdrv::destroy_bitmap(gdrv_bitmap8* bmp)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gdrv::blit(gdrv_bitmap8* bmp, int xSrc, int ySrc, int xDest, int yDest, int width, int height)
|
|
||||||
{
|
|
||||||
StretchDIBitsScaled(
|
|
||||||
xSrc,
|
|
||||||
ySrc,
|
|
||||||
xDest,
|
|
||||||
yDest,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
bmp
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void gdrv::blat(gdrv_bitmap8* bmp, int xDest, int yDest)
|
|
||||||
{
|
|
||||||
StretchDIBitsScaled(
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
xDest,
|
|
||||||
yDest,
|
|
||||||
bmp->Width,
|
|
||||||
bmp->Height,
|
|
||||||
bmp
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void gdrv::fill_bitmap(gdrv_bitmap8* bmp, int width, int height, int xOff, int yOff, uint8_t fillChar)
|
void gdrv::fill_bitmap(gdrv_bitmap8* bmp, int width, int height, int xOff, int yOff, uint8_t fillChar)
|
||||||
{
|
{
|
||||||
auto color = current_palette[fillChar];
|
auto color = current_palette[fillChar];
|
||||||
@@ -272,64 +210,6 @@ void gdrv::grtext_draw_ttext_in_box(LPCSTR text, int xOff, int yOff, int width,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int gdrv::StretchDIBitsScaled(int xSrc, int ySrc, int xDst, int yDst,
|
|
||||||
int width, int height, gdrv_bitmap8* bmp)
|
|
||||||
{
|
|
||||||
// Negative dst == positive src offset
|
|
||||||
if (xDst < 0)
|
|
||||||
{
|
|
||||||
xSrc -= xDst;
|
|
||||||
xDst = 0;
|
|
||||||
}
|
|
||||||
if (yDst < 0)
|
|
||||||
{
|
|
||||||
ySrc -= yDst;
|
|
||||||
yDst = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clamp out of bounds rectangles
|
|
||||||
xSrc = std::max(0, std::min(xSrc, bmp->Width));
|
|
||||||
ySrc = std::max(0, std::min(ySrc, bmp->Height));
|
|
||||||
if (xSrc + width > bmp->Width)
|
|
||||||
width = bmp->Width - xSrc;
|
|
||||||
if (ySrc + height > bmp->Height)
|
|
||||||
height = bmp->Height - ySrc;
|
|
||||||
|
|
||||||
xDst = std::max(0, std::min(xDst, vScreenWidth));
|
|
||||||
yDst = std::max(0, std::min(yDst, vScreenHeight));
|
|
||||||
if (xDst + width > vScreenWidth)
|
|
||||||
width = vScreenWidth - xDst;
|
|
||||||
if (yDst + height > vScreenHeight)
|
|
||||||
height = vScreenHeight - yDst;
|
|
||||||
|
|
||||||
auto srcPtr = &bmp->BmpBufPtr1[bmp->Stride * ySrc + xSrc];
|
|
||||||
auto dstPtr = &vScreenPixels[vScreenWidth * yDst + xDst];
|
|
||||||
for (int y = height; y > 0; --y)
|
|
||||||
{
|
|
||||||
std::memcpy(dstPtr, srcPtr, width * sizeof(ColorRgba));
|
|
||||||
srcPtr += bmp->Stride;
|
|
||||||
dstPtr += vScreenWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void gdrv::BlitScreen()
|
|
||||||
{
|
|
||||||
int pitch = 0;
|
|
||||||
void* lockedPixels;
|
|
||||||
SDL_LockTexture
|
|
||||||
(
|
|
||||||
vScreenTex,
|
|
||||||
nullptr,
|
|
||||||
&lockedPixels,
|
|
||||||
&pitch
|
|
||||||
);
|
|
||||||
std::memcpy(lockedPixels, vScreenPixels, vScreenWidth * vScreenHeight * sizeof(ColorRgba));
|
|
||||||
SDL_UnlockTexture(vScreenTex);
|
|
||||||
SDL_RenderCopy(winmain::Renderer, vScreenTex, nullptr, &DestinationRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
void gdrv::ApplyPalette(gdrv_bitmap8& bmp)
|
void gdrv::ApplyPalette(gdrv_bitmap8& bmp)
|
||||||
{
|
{
|
||||||
if (bmp.BitmapType == BitmapTypes::None)
|
if (bmp.BitmapType == BitmapTypes::None)
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ enum class BitmapTypes : uint8_t
|
|||||||
|
|
||||||
struct Rgba
|
struct Rgba
|
||||||
{
|
{
|
||||||
uint8_t peRed;
|
uint8_t Blue;
|
||||||
uint8_t peGreen;
|
uint8_t Green;
|
||||||
uint8_t peBlue;
|
uint8_t Red;
|
||||||
uint8_t peFlags;
|
uint8_t Alpha;
|
||||||
};
|
};
|
||||||
|
|
||||||
union ColorRgba
|
union ColorRgba
|
||||||
@@ -57,32 +57,18 @@ struct gdrv_bitmap8
|
|||||||
class gdrv
|
class gdrv
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static SDL_Rect DestinationRect;
|
|
||||||
|
|
||||||
static int init(int width, int height);
|
|
||||||
static int uninit();
|
|
||||||
static void get_focus();
|
|
||||||
static int create_bitmap(gdrv_bitmap8* bmp, int width, int height, int stride = -1, bool indexed = true);
|
static int create_bitmap(gdrv_bitmap8* bmp, int width, int height, int stride = -1, bool indexed = true);
|
||||||
static int create_bitmap(gdrv_bitmap8& bmp, const struct dat8BitBmpHeader& header);
|
static int create_bitmap(gdrv_bitmap8& bmp, const struct dat8BitBmpHeader& header);
|
||||||
static int destroy_bitmap(gdrv_bitmap8* bmp);
|
static int destroy_bitmap(gdrv_bitmap8* bmp);
|
||||||
static int display_palette(ColorRgba* plt);
|
static int display_palette(ColorRgba* plt);
|
||||||
static void blit(gdrv_bitmap8* bmp, int xSrc, int ySrc, int xDest, int yDest, int width, int height);
|
|
||||||
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, uint8_t fillChar);
|
static void fill_bitmap(gdrv_bitmap8* bmp, int width, int height, int xOff, int yOff, uint8_t fillChar);
|
||||||
static void copy_bitmap(gdrv_bitmap8* dstBmp, int width, int height, int xOff, int yOff, gdrv_bitmap8* srcBmp,
|
static void copy_bitmap(gdrv_bitmap8* dstBmp, int width, int height, int xOff, int yOff, gdrv_bitmap8* srcBmp,
|
||||||
int srcXOff, int srcYOff);
|
int srcXOff, int srcYOff);
|
||||||
static void copy_bitmap_w_transparency(gdrv_bitmap8* dstBmp, int width, int height, int xOff, int yOff,
|
static void copy_bitmap_w_transparency(gdrv_bitmap8* dstBmp, int width, int height, int xOff, int yOff,
|
||||||
gdrv_bitmap8* srcBmp, int srcXOff, int srcYOff);
|
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 grtext_draw_ttext_in_box(LPCSTR text, int xOff, int yOff, int width, int height, int a6);
|
||||||
static void BlitScreen();
|
|
||||||
static void ApplyPalette(gdrv_bitmap8& bmp);
|
static void ApplyPalette(gdrv_bitmap8& bmp);
|
||||||
static void CreatePreview(gdrv_bitmap8& bmp);
|
static void CreatePreview(gdrv_bitmap8& bmp);
|
||||||
private:
|
private:
|
||||||
static SDL_Texture* vScreenTex;
|
|
||||||
static ColorRgba* vScreenPixels;
|
|
||||||
static int vScreenWidth, vScreenHeight;
|
|
||||||
static ColorRgba current_palette[256];
|
static ColorRgba current_palette[256];
|
||||||
|
|
||||||
static int StretchDIBitsScaled(int xSrc, int ySrc, int xDst, int yDst,
|
|
||||||
int width, int height, gdrv_bitmap8* bmp);
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ void nudge::_nudge(float xDiff, float yDiff)
|
|||||||
vector_type accelMod;
|
vector_type accelMod;
|
||||||
float invAccelX, invAccelY;
|
float invAccelX, invAccelY;
|
||||||
|
|
||||||
auto table = pb::MainTable;
|
|
||||||
auto ballList = pb::MainTable->BallList;
|
auto ballList = pb::MainTable->BallList;
|
||||||
accelMod.X = xDiff * 0.5f;
|
accelMod.X = xDiff * 0.5f;
|
||||||
accelMod.Y = yDiff * 0.5f;
|
accelMod.Y = yDiff * 0.5f;
|
||||||
@@ -91,10 +90,8 @@ void nudge::_nudge(float xDiff, float yDiff)
|
|||||||
else
|
else
|
||||||
invAccelY = 1.0f / ball->Acceleration.Y;
|
invAccelY = 1.0f / ball->Acceleration.Y;
|
||||||
ball->InvAcceleration.Y = invAccelY;
|
ball->InvAcceleration.Y = invAccelY;
|
||||||
table = pb::MainTable;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render::shift(static_cast<int>(floor(xDiff + 0.5f)), static_cast<int>(floor(0.5f - yDiff)), 0, 0, table->Width,
|
render::shift(static_cast<int>(floor(xDiff + 0.5f)), static_cast<int>(floor(0.5f - yDiff)));
|
||||||
table->Height);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -217,7 +217,6 @@ void options::toggle(Menu1 uIDCheckItem)
|
|||||||
case Menu1::WindowUniformScale:
|
case Menu1::WindowUniformScale:
|
||||||
Options.UniformScaling ^= true;
|
Options.UniformScaling ^= true;
|
||||||
fullscrn::window_size_changed();
|
fullscrn::window_size_changed();
|
||||||
pb::paint();
|
|
||||||
break;
|
break;
|
||||||
case Menu1::WindowLinearFilter:
|
case Menu1::WindowLinearFilter:
|
||||||
Options.LinearFiltering ^= true;
|
Options.LinearFiltering ^= true;
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ DatFile* partman::load_records(LPCSTR lpFileName, bool fullTiltMode)
|
|||||||
groupData->AddEntry(entryData);
|
groupData->AddEntry(entryData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
groupData->FinalizeGroup();
|
||||||
datFile->Groups.push_back(groupData);
|
datFile->Groups.push_back(groupData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,8 +75,7 @@ int pb::init()
|
|||||||
zMin = cameraInfo[1];
|
zMin = cameraInfo[1];
|
||||||
zScaler = cameraInfo[2];
|
zScaler = cameraInfo[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
gdrv::init(resInfo->TableWidth, resInfo->TableHeight);
|
|
||||||
render::init(nullptr, zMin, zScaler, resInfo->TableWidth, resInfo->TableHeight);
|
render::init(nullptr, zMin, zScaler, resInfo->TableWidth, resInfo->TableHeight);
|
||||||
gdrv::copy_bitmap(
|
gdrv::copy_bitmap(
|
||||||
&render::vscreen,
|
&render::vscreen,
|
||||||
@@ -116,7 +115,6 @@ int pb::uninit()
|
|||||||
if (MainTable)
|
if (MainTable)
|
||||||
delete MainTable;
|
delete MainTable;
|
||||||
MainTable = nullptr;
|
MainTable = nullptr;
|
||||||
gdrv::get_focus();
|
|
||||||
timer::uninit();
|
timer::uninit();
|
||||||
render::uninit();
|
render::uninit();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -131,14 +129,7 @@ void pb::reset_table()
|
|||||||
|
|
||||||
void pb::firsttime_setup()
|
void pb::firsttime_setup()
|
||||||
{
|
{
|
||||||
render::blit = 0;
|
|
||||||
render::update();
|
render::update();
|
||||||
render::blit = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void pb::paint()
|
|
||||||
{
|
|
||||||
render::paint();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void pb::mode_change(int mode)
|
void pb::mode_change(int mode)
|
||||||
@@ -493,9 +484,6 @@ void pb::keydown(int key)
|
|||||||
case 's':
|
case 's':
|
||||||
MainTable->AddScore(static_cast<int>(RandFloat() * 1000000.0f));
|
MainTable->AddScore(static_cast<int>(RandFloat() * 1000000.0f));
|
||||||
break;
|
break;
|
||||||
case SDLK_F11:
|
|
||||||
gdrv::get_focus();
|
|
||||||
break;
|
|
||||||
case SDLK_F12:
|
case SDLK_F12:
|
||||||
MainTable->port_draw();
|
MainTable->port_draw();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ public:
|
|||||||
static int uninit();
|
static int uninit();
|
||||||
static void reset_table();
|
static void reset_table();
|
||||||
static void firsttime_setup();
|
static void firsttime_setup();
|
||||||
static void paint();
|
|
||||||
static void mode_change(int mode);
|
static void mode_change(int mode);
|
||||||
static void toggle_demo();
|
static void toggle_demo();
|
||||||
static void replay_level(int demoMode);
|
static void replay_level(int demoMode);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -18,7 +18,7 @@ struct render_sprite_type_struct
|
|||||||
char UnknownFlag;
|
char UnknownFlag;
|
||||||
VisualTypes VisualType;
|
VisualTypes VisualType;
|
||||||
int16_t Depth;
|
int16_t Depth;
|
||||||
rectangle_type BmpRectCopy;
|
rectangle_type DirtyRectPrev;
|
||||||
int ZMapOffestY;
|
int ZMapOffestY;
|
||||||
int ZMapOffestX;
|
int ZMapOffestX;
|
||||||
rectangle_type DirtyRect;
|
rectangle_type DirtyRect;
|
||||||
@@ -31,20 +31,12 @@ struct render_sprite_type_struct
|
|||||||
class render
|
class render
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static int blit;
|
static gdrv_bitmap8 vscreen, *background_bitmap;
|
||||||
static int many_dirty, many_sprites, many_balls;
|
static SDL_Rect DestinationRect;
|
||||||
static render_sprite_type_struct **dirty_list, **sprite_list, **ball_list;
|
|
||||||
static zmap_header_type* background_zmap;
|
|
||||||
static int zmap_offset, zmap_offsetY, offset_x, offset_y;
|
|
||||||
static float zscaler, zmin, zmax;
|
|
||||||
static rectangle_type vscreen_rect;
|
|
||||||
static gdrv_bitmap8 vscreen, *background_bitmap, ball_bitmap[20];
|
|
||||||
static zmap_header_type zscreen;
|
|
||||||
|
|
||||||
static void init(gdrv_bitmap8* bmp, float zMin, float zScaler, int width, int height);
|
static void init(gdrv_bitmap8* bmp, float zMin, float zScaler, int width, int height);
|
||||||
static void uninit();
|
static void uninit();
|
||||||
static void update();
|
static void update();
|
||||||
static void paint();
|
|
||||||
static void sprite_modified(render_sprite_type_struct* sprite);
|
static void sprite_modified(render_sprite_type_struct* sprite);
|
||||||
static render_sprite_type_struct* create_sprite(VisualTypes visualType, gdrv_bitmap8* bmp,
|
static render_sprite_type_struct* create_sprite(VisualTypes visualType, gdrv_bitmap8* bmp,
|
||||||
zmap_header_type* zMap,
|
zmap_header_type* zMap,
|
||||||
@@ -55,11 +47,24 @@ public:
|
|||||||
int yPos);
|
int yPos);
|
||||||
static void sprite_set_bitmap(render_sprite_type_struct* sprite, gdrv_bitmap8* bmp);
|
static void sprite_set_bitmap(render_sprite_type_struct* sprite, gdrv_bitmap8* bmp);
|
||||||
static void set_background_zmap(struct zmap_header_type* zMap, int offsetX, int offsetY);
|
static void set_background_zmap(struct zmap_header_type* zMap, int offsetX, int offsetY);
|
||||||
static void ball_set(render_sprite_type_struct* sprite, gdrv_bitmap8* bmp, float depth, int xPos, int yPos);
|
static void ball_set(render_sprite_type_struct* sprite, gdrv_bitmap8* bmp, float depth, int xPos, int yPos);
|
||||||
|
static void shift(int offsetX, int offsetY);
|
||||||
|
static void build_occlude_list();
|
||||||
|
static void SpriteViewer(bool* show);
|
||||||
|
static void PresentVScreen();
|
||||||
|
private:
|
||||||
|
static int many_dirty, many_sprites, many_balls;
|
||||||
|
static render_sprite_type_struct **dirty_list, **sprite_list, **ball_list;
|
||||||
|
static zmap_header_type* background_zmap;
|
||||||
|
static int zmap_offset, zmap_offsetY, offset_x, offset_y;
|
||||||
|
static float zscaler, zmin, zmax;
|
||||||
|
static rectangle_type vscreen_rect;
|
||||||
|
static gdrv_bitmap8 ball_bitmap[20];
|
||||||
|
static zmap_header_type zscreen;
|
||||||
|
static SDL_Texture* vScreenTex;
|
||||||
|
|
||||||
static void repaint(struct render_sprite_type_struct* sprite);
|
static void repaint(struct render_sprite_type_struct* sprite);
|
||||||
static void paint_balls();
|
static void paint_balls();
|
||||||
static void unpaint_balls();
|
static void unpaint_balls();
|
||||||
static void shift(int offsetX, int offsetY, int xSrc, int ySrc, int DestWidth, int DestHeight);
|
static void BlitVScreen();
|
||||||
static void build_occlude_list();
|
|
||||||
static void SpriteViewer(bool* show);
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -207,16 +207,7 @@ void score::erase(scoreStruct* score, int blitFlag)
|
|||||||
score->OffsetX,
|
score->OffsetX,
|
||||||
score->OffsetY);
|
score->OffsetY);
|
||||||
else
|
else
|
||||||
gdrv::fill_bitmap(&render::vscreen, score->Width, score->Height, score->OffsetX, score->OffsetY, 0);
|
gdrv::fill_bitmap(&render::vscreen, score->Width, score->Height, score->OffsetX, score->OffsetY, 0);
|
||||||
if (blitFlag)
|
|
||||||
gdrv::blit(
|
|
||||||
&render::vscreen,
|
|
||||||
score->OffsetX,
|
|
||||||
score->OffsetY,
|
|
||||||
score->OffsetX + render::vscreen.XPosition,
|
|
||||||
score->OffsetY + render::vscreen.YPosition,
|
|
||||||
score->Width,
|
|
||||||
score->Height);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,15 +246,7 @@ void score::update(scoreStruct* score)
|
|||||||
else
|
else
|
||||||
gdrv::copy_bitmap(&render::vscreen, width, height, x, y, bmp, 0, 0);
|
gdrv::copy_bitmap(&render::vscreen, width, height, x, y, bmp, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gdrv::blit(
|
|
||||||
&render::vscreen,
|
|
||||||
score->OffsetX,
|
|
||||||
score->OffsetY,
|
|
||||||
score->OffsetX + render::vscreen.XPosition,
|
|
||||||
score->OffsetY + render::vscreen.YPosition,
|
|
||||||
score->Width,
|
|
||||||
score->Height);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
|||||||
gdrv::create_bitmap(&gfr_display, 400, 15, 400, false);
|
gdrv::create_bitmap(&gfr_display, 400, 15, 400, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
gdrv::blit(&gfr_display, 0, 0, 0, 30, 300, 10);
|
gdrv::copy_bitmap(&render::vscreen, 300, 10, 0, 30, &gfr_display, 0, 0);
|
||||||
gdrv::fill_bitmap(&gfr_display, 300, 10, 0, 0, 0);
|
gdrv::fill_bitmap(&gfr_display, 300, 10, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -284,7 +284,7 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
|||||||
RenderUi();
|
RenderUi();
|
||||||
|
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
gdrv::BlitScreen();
|
render::PresentVScreen();
|
||||||
|
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImGuiSDL::Render(ImGui::GetDrawData());
|
ImGuiSDL::Render(ImGui::GetDrawData());
|
||||||
@@ -307,7 +307,6 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
|||||||
midi::music_shutdown();
|
midi::music_shutdown();
|
||||||
pb::uninit();
|
pb::uninit();
|
||||||
Sound::Close();
|
Sound::Close();
|
||||||
gdrv::uninit();
|
|
||||||
ImGuiSDL::Deinitialize();
|
ImGuiSDL::Deinitialize();
|
||||||
ImGui_ImplSDL2_Shutdown();
|
ImGui_ImplSDL2_Shutdown();
|
||||||
SDL_DestroyRenderer(renderer);
|
SDL_DestroyRenderer(renderer);
|
||||||
@@ -649,8 +648,6 @@ int winmain::event_handler(const SDL_Event* event)
|
|||||||
midi::play_pb_theme(0);
|
midi::play_pb_theme(0);
|
||||||
no_time_loss = 1;
|
no_time_loss = 1;
|
||||||
has_focus = 1;
|
has_focus = 1;
|
||||||
gdrv::get_focus();
|
|
||||||
pb::paint();
|
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||||
case SDL_WINDOWEVENT_HIDDEN:
|
case SDL_WINDOWEVENT_HIDDEN:
|
||||||
@@ -660,7 +657,6 @@ int winmain::event_handler(const SDL_Event* event)
|
|||||||
Sound::Deactivate();
|
Sound::Deactivate();
|
||||||
midi::music_stop();
|
midi::music_stop();
|
||||||
has_focus = 0;
|
has_focus = 0;
|
||||||
gdrv::get_focus();
|
|
||||||
pb::loose_focus();
|
pb::loose_focus();
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||||
@@ -698,7 +694,6 @@ void winmain::memalloc_failure()
|
|||||||
{
|
{
|
||||||
midi::music_stop();
|
midi::music_stop();
|
||||||
Sound::Close();
|
Sound::Close();
|
||||||
gdrv::uninit();
|
|
||||||
char* caption = pinball::get_rc_string(170, 0);
|
char* caption = pinball::get_rc_string(170, 0);
|
||||||
char* text = pinball::get_rc_string(179, 0);
|
char* text = pinball::get_rc_string(179, 0);
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, caption, text, MainWindow);
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, caption, text, MainWindow);
|
||||||
@@ -723,7 +718,10 @@ void winmain::a_dialog()
|
|||||||
ImGui::TextUnformatted("Decompiled -> Ported to SDL");
|
ImGui::TextUnformatted("Decompiled -> Ported to SDL");
|
||||||
if (ImGui::SmallButton("Project home: https://github.com/k4zmu2a/SpaceCadetPinball"))
|
if (ImGui::SmallButton("Project home: https://github.com/k4zmu2a/SpaceCadetPinball"))
|
||||||
{
|
{
|
||||||
|
#if SDL_VERSION_ATLEAST(2, 0, 14)
|
||||||
|
// Relatively new feature, skip with older SDL
|
||||||
SDL_OpenURL("https://github.com/k4zmu2a/SpaceCadetPinball");
|
SDL_OpenURL("https://github.com/k4zmu2a/SpaceCadetPinball");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
|
|||||||
@@ -127,9 +127,9 @@ void zdrv::CreatePreview(zmap_header_type& zMap)
|
|||||||
for (auto x = 0; x < zMap.Width; x++)
|
for (auto x = 0; x < zMap.Width; x++)
|
||||||
{
|
{
|
||||||
auto depth = static_cast<uint8_t>((0xffff - *src++) / 0xff);
|
auto depth = static_cast<uint8_t>((0xffff - *src++) / 0xff);
|
||||||
color.rgba.peRed = depth;
|
color.rgba.Blue = depth;
|
||||||
color.rgba.peGreen = depth;
|
color.rgba.Green = depth;
|
||||||
color.rgba.peBlue = depth;
|
color.rgba.Red = depth;
|
||||||
*dst++ = color;
|
*dst++ = color;
|
||||||
}
|
}
|
||||||
src += zMap.Stride - zMap.Width;
|
src += zMap.Stride - zMap.Width;
|
||||||
|
|||||||
Reference in New Issue
Block a user