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));
|
||||
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)
|
||||
{
|
||||
Entries.push_back(entry);
|
||||
|
||||
auto addEntry = true;
|
||||
switch (entry->EntryType)
|
||||
{
|
||||
case FieldTypes::GroupName:
|
||||
@@ -47,21 +36,23 @@ void GroupData::AddEntry(EntryData* entry)
|
||||
break;
|
||||
case FieldTypes::Bitmap8bit:
|
||||
{
|
||||
auto bmp = reinterpret_cast<gdrv_bitmap8*>(entry->Buffer);
|
||||
if (bmp->BitmapType == BitmapTypes::Spliced)
|
||||
auto srcBmp = reinterpret_cast<gdrv_bitmap8*>(entry->Buffer);
|
||||
if (srcBmp->BitmapType == BitmapTypes::Spliced)
|
||||
{
|
||||
// Get rid of spliced bitmap early on, to simplify render pipeline
|
||||
auto splitBmp = memory::allocate<gdrv_bitmap8>();
|
||||
auto splitZMap = memory::allocate<zmap_header_type>();
|
||||
SplitSplicedBitmap(*bmp, *splitBmp, *splitZMap);
|
||||
entry->DerivedBmp = splitBmp;
|
||||
entry->DerivedZMap = splitZMap;
|
||||
SetBitmap(splitBmp);
|
||||
SetZMap(splitZMap);
|
||||
auto bmp = memory::allocate<gdrv_bitmap8>();
|
||||
auto zMap = memory::allocate<zmap_header_type>();
|
||||
SplitSplicedBitmap(*srcBmp, *bmp, *zMap);
|
||||
|
||||
NeedsSort = true;
|
||||
addEntry = false;
|
||||
AddEntry(new EntryData(FieldTypes::Bitmap8bit, reinterpret_cast<char*>(bmp)));
|
||||
AddEntry(new EntryData(FieldTypes::Bitmap16bit, reinterpret_cast<char*>(zMap)));
|
||||
delete entry;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetBitmap(bmp);
|
||||
SetBitmap(srcBmp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -72,6 +63,24 @@ void GroupData::AddEntry(EntryData* entry)
|
||||
}
|
||||
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
|
||||
|
||||
@@ -43,12 +43,16 @@ enum class FieldTypes : int16_t
|
||||
|
||||
struct EntryData
|
||||
{
|
||||
EntryData() = default;
|
||||
|
||||
EntryData(FieldTypes entryType, char* buffer): EntryType(entryType), FieldSize(-1), Buffer(buffer)
|
||||
{
|
||||
}
|
||||
|
||||
~EntryData();
|
||||
FieldTypes EntryType{};
|
||||
int FieldSize{};
|
||||
char* Buffer{};
|
||||
gdrv_bitmap8* DerivedBmp{};
|
||||
zmap_header_type* DerivedZMap{};
|
||||
};
|
||||
|
||||
class GroupData
|
||||
@@ -59,6 +63,7 @@ public:
|
||||
|
||||
GroupData(int groupId);
|
||||
void AddEntry(EntryData* entry);
|
||||
void FinalizeGroup();
|
||||
const std::vector<EntryData*>& GetEntries() const { return Entries; }
|
||||
const EntryData* GetEntry(size_t index) const { return Entries[index]; }
|
||||
size_t EntryCount() const { return Entries.size(); }
|
||||
@@ -70,6 +75,7 @@ private:
|
||||
std::vector<EntryData*> Entries;
|
||||
gdrv_bitmap8* Bitmaps[3]{};
|
||||
zmap_header_type* ZMaps[3]{};
|
||||
bool NeedsSort = false;
|
||||
|
||||
static void SplitSplicedBitmap(const gdrv_bitmap8& srcBmp, gdrv_bitmap8& bmp, zmap_header_type& zMap);
|
||||
|
||||
|
||||
@@ -86,14 +86,6 @@ void TTextBox::Clear()
|
||||
OffsetY);
|
||||
else
|
||||
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 != -1)
|
||||
@@ -198,14 +190,6 @@ void TTextBox::Draw()
|
||||
auto font = 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(
|
||||
Message1->Text,
|
||||
render::vscreen.XPosition + OffsetX,
|
||||
@@ -276,13 +260,4 @@ void TTextBox::Draw()
|
||||
++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));
|
||||
}
|
||||
|
||||
gdrv::DestinationRect = SDL_Rect
|
||||
render::DestinationRect = SDL_Rect
|
||||
{
|
||||
OffsetX, OffsetY,
|
||||
width - OffsetX * 2, height - OffsetY * 2
|
||||
|
||||
@@ -9,41 +9,7 @@
|
||||
#include "score.h"
|
||||
#include "winmain.h"
|
||||
|
||||
SDL_Texture* gdrv::vScreenTex = nullptr;
|
||||
ColorRgba* gdrv::vScreenPixels = nullptr;
|
||||
int gdrv::vScreenWidth, gdrv::vScreenHeight;
|
||||
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)
|
||||
{
|
||||
@@ -122,23 +88,23 @@ int gdrv::display_palette(ColorRgba* plt)
|
||||
{
|
||||
const uint32_t sysPaletteColors[]
|
||||
{
|
||||
0x00000000, // Color 0: transparent
|
||||
0x00000080,
|
||||
0x00008000,
|
||||
0x00008080,
|
||||
0x00800000,
|
||||
0x00800080,
|
||||
0x00808000,
|
||||
0x00C0C0C0,
|
||||
0x00C0DCC0,
|
||||
0x00F0CAA6
|
||||
0xff000000, // Color 0: transparent
|
||||
0xff000080,
|
||||
0xff008000,
|
||||
0xff008080,
|
||||
0xff800000,
|
||||
0xff800080,
|
||||
0xff808000,
|
||||
0xffC0C0C0,
|
||||
0xffC0DCC0,
|
||||
0xffF0CAA6
|
||||
};
|
||||
|
||||
memcpy(current_palette, sysPaletteColors, sizeof sysPaletteColors);
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
current_palette[i].rgba.peFlags = 0;
|
||||
current_palette[i].rgba.Alpha = 0;
|
||||
}
|
||||
|
||||
auto pltSrc = &plt[10];
|
||||
@@ -147,18 +113,16 @@ int gdrv::display_palette(ColorRgba* plt)
|
||||
{
|
||||
if (plt)
|
||||
{
|
||||
pltDst->rgba.peRed = pltSrc->rgba.peRed;
|
||||
pltDst->rgba.peGreen = pltSrc->rgba.peGreen;
|
||||
pltDst->rgba.peBlue = pltSrc->rgba.peBlue;
|
||||
pltDst->rgba.Blue = pltSrc->rgba.Blue;
|
||||
pltDst->rgba.Green = pltSrc->rgba.Green;
|
||||
pltDst->rgba.Red = pltSrc->rgba.Red;
|
||||
}
|
||||
pltDst->rgba.peFlags = 4;
|
||||
pltDst->rgba.Alpha = 0xFF;
|
||||
pltSrc++;
|
||||
pltDst++;
|
||||
}
|
||||
|
||||
current_palette[255].rgba.peBlue = -1;
|
||||
current_palette[255].rgba.peGreen = -1;
|
||||
current_palette[255].rgba.peRed = -1;
|
||||
current_palette[255].Color = 0xffFFFFFF;
|
||||
|
||||
score::ApplyPalette();
|
||||
for (const auto group : pb::record_table->Groups)
|
||||
@@ -194,32 +158,6 @@ int gdrv::destroy_bitmap(gdrv_bitmap8* bmp)
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (bmp.BitmapType == BitmapTypes::None)
|
||||
|
||||
@@ -11,10 +11,10 @@ enum class BitmapTypes : uint8_t
|
||||
|
||||
struct Rgba
|
||||
{
|
||||
uint8_t peRed;
|
||||
uint8_t peGreen;
|
||||
uint8_t peBlue;
|
||||
uint8_t peFlags;
|
||||
uint8_t Blue;
|
||||
uint8_t Green;
|
||||
uint8_t Red;
|
||||
uint8_t Alpha;
|
||||
};
|
||||
|
||||
union ColorRgba
|
||||
@@ -57,32 +57,18 @@ struct gdrv_bitmap8
|
||||
class gdrv
|
||||
{
|
||||
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, const struct dat8BitBmpHeader& header);
|
||||
static int destroy_bitmap(gdrv_bitmap8* bmp);
|
||||
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 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();
|
||||
static void ApplyPalette(gdrv_bitmap8& bmp);
|
||||
static void CreatePreview(gdrv_bitmap8& bmp);
|
||||
private:
|
||||
static SDL_Texture* vScreenTex;
|
||||
static ColorRgba* vScreenPixels;
|
||||
static int vScreenWidth, vScreenHeight;
|
||||
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;
|
||||
float invAccelX, invAccelY;
|
||||
|
||||
auto table = pb::MainTable;
|
||||
auto ballList = pb::MainTable->BallList;
|
||||
accelMod.X = xDiff * 0.5f;
|
||||
accelMod.Y = yDiff * 0.5f;
|
||||
@@ -91,10 +90,8 @@ void nudge::_nudge(float xDiff, float yDiff)
|
||||
else
|
||||
invAccelY = 1.0f / ball->Acceleration.Y;
|
||||
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,
|
||||
table->Height);
|
||||
render::shift(static_cast<int>(floor(xDiff + 0.5f)), static_cast<int>(floor(0.5f - yDiff)));
|
||||
}
|
||||
|
||||
@@ -217,7 +217,6 @@ void options::toggle(Menu1 uIDCheckItem)
|
||||
case Menu1::WindowUniformScale:
|
||||
Options.UniformScaling ^= true;
|
||||
fullscrn::window_size_changed();
|
||||
pb::paint();
|
||||
break;
|
||||
case Menu1::WindowLinearFilter:
|
||||
Options.LinearFiltering ^= true;
|
||||
|
||||
@@ -130,6 +130,7 @@ DatFile* partman::load_records(LPCSTR lpFileName, bool fullTiltMode)
|
||||
groupData->AddEntry(entryData);
|
||||
}
|
||||
|
||||
groupData->FinalizeGroup();
|
||||
datFile->Groups.push_back(groupData);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,6 @@ int pb::init()
|
||||
zScaler = cameraInfo[2];
|
||||
}
|
||||
|
||||
gdrv::init(resInfo->TableWidth, resInfo->TableHeight);
|
||||
render::init(nullptr, zMin, zScaler, resInfo->TableWidth, resInfo->TableHeight);
|
||||
gdrv::copy_bitmap(
|
||||
&render::vscreen,
|
||||
@@ -116,7 +115,6 @@ int pb::uninit()
|
||||
if (MainTable)
|
||||
delete MainTable;
|
||||
MainTable = nullptr;
|
||||
gdrv::get_focus();
|
||||
timer::uninit();
|
||||
render::uninit();
|
||||
return 0;
|
||||
@@ -131,14 +129,7 @@ void pb::reset_table()
|
||||
|
||||
void pb::firsttime_setup()
|
||||
{
|
||||
render::blit = 0;
|
||||
render::update();
|
||||
render::blit = 1;
|
||||
}
|
||||
|
||||
void pb::paint()
|
||||
{
|
||||
render::paint();
|
||||
}
|
||||
|
||||
void pb::mode_change(int mode)
|
||||
@@ -493,9 +484,6 @@ void pb::keydown(int key)
|
||||
case 's':
|
||||
MainTable->AddScore(static_cast<int>(RandFloat() * 1000000.0f));
|
||||
break;
|
||||
case SDLK_F11:
|
||||
gdrv::get_focus();
|
||||
break;
|
||||
case SDLK_F12:
|
||||
MainTable->port_draw();
|
||||
break;
|
||||
|
||||
@@ -44,7 +44,6 @@ public:
|
||||
static int uninit();
|
||||
static void reset_table();
|
||||
static void firsttime_setup();
|
||||
static void paint();
|
||||
static void mode_change(int mode);
|
||||
static void toggle_demo();
|
||||
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;
|
||||
VisualTypes VisualType;
|
||||
int16_t Depth;
|
||||
rectangle_type BmpRectCopy;
|
||||
rectangle_type DirtyRectPrev;
|
||||
int ZMapOffestY;
|
||||
int ZMapOffestX;
|
||||
rectangle_type DirtyRect;
|
||||
@@ -31,20 +31,12 @@ struct render_sprite_type_struct
|
||||
class render
|
||||
{
|
||||
public:
|
||||
static int blit;
|
||||
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 vscreen, *background_bitmap, ball_bitmap[20];
|
||||
static zmap_header_type zscreen;
|
||||
static gdrv_bitmap8 vscreen, *background_bitmap;
|
||||
static SDL_Rect DestinationRect;
|
||||
|
||||
static void init(gdrv_bitmap8* bmp, float zMin, float zScaler, int width, int height);
|
||||
static void uninit();
|
||||
static void update();
|
||||
static void paint();
|
||||
static void sprite_modified(render_sprite_type_struct* sprite);
|
||||
static render_sprite_type_struct* create_sprite(VisualTypes visualType, gdrv_bitmap8* bmp,
|
||||
zmap_header_type* zMap,
|
||||
@@ -56,10 +48,23 @@ public:
|
||||
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 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 paint_balls();
|
||||
static void unpaint_balls();
|
||||
static void shift(int offsetX, int offsetY, int xSrc, int ySrc, int DestWidth, int DestHeight);
|
||||
static void build_occlude_list();
|
||||
static void SpriteViewer(bool* show);
|
||||
static void BlitVScreen();
|
||||
};
|
||||
|
||||
@@ -208,15 +208,6 @@ void score::erase(scoreStruct* score, int blitFlag)
|
||||
score->OffsetY);
|
||||
else
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,14 +247,6 @@ void score::update(scoreStruct* score)
|
||||
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::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);
|
||||
}
|
||||
}
|
||||
@@ -284,7 +284,7 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
||||
RenderUi();
|
||||
|
||||
SDL_RenderClear(renderer);
|
||||
gdrv::BlitScreen();
|
||||
render::PresentVScreen();
|
||||
|
||||
ImGui::Render();
|
||||
ImGuiSDL::Render(ImGui::GetDrawData());
|
||||
@@ -307,7 +307,6 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
||||
midi::music_shutdown();
|
||||
pb::uninit();
|
||||
Sound::Close();
|
||||
gdrv::uninit();
|
||||
ImGuiSDL::Deinitialize();
|
||||
ImGui_ImplSDL2_Shutdown();
|
||||
SDL_DestroyRenderer(renderer);
|
||||
@@ -649,8 +648,6 @@ int winmain::event_handler(const SDL_Event* event)
|
||||
midi::play_pb_theme(0);
|
||||
no_time_loss = 1;
|
||||
has_focus = 1;
|
||||
gdrv::get_focus();
|
||||
pb::paint();
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||
case SDL_WINDOWEVENT_HIDDEN:
|
||||
@@ -660,7 +657,6 @@ int winmain::event_handler(const SDL_Event* event)
|
||||
Sound::Deactivate();
|
||||
midi::music_stop();
|
||||
has_focus = 0;
|
||||
gdrv::get_focus();
|
||||
pb::loose_focus();
|
||||
break;
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||
@@ -698,7 +694,6 @@ void winmain::memalloc_failure()
|
||||
{
|
||||
midi::music_stop();
|
||||
Sound::Close();
|
||||
gdrv::uninit();
|
||||
char* caption = pinball::get_rc_string(170, 0);
|
||||
char* text = pinball::get_rc_string(179, 0);
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, caption, text, MainWindow);
|
||||
@@ -723,7 +718,10 @@ void winmain::a_dialog()
|
||||
ImGui::TextUnformatted("Decompiled -> Ported to SDL");
|
||||
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");
|
||||
#endif
|
||||
}
|
||||
ImGui::Separator();
|
||||
|
||||
|
||||
@@ -127,9 +127,9 @@ void zdrv::CreatePreview(zmap_header_type& zMap)
|
||||
for (auto x = 0; x < zMap.Width; x++)
|
||||
{
|
||||
auto depth = static_cast<uint8_t>((0xffff - *src++) / 0xff);
|
||||
color.rgba.peRed = depth;
|
||||
color.rgba.peGreen = depth;
|
||||
color.rgba.peBlue = depth;
|
||||
color.rgba.Blue = depth;
|
||||
color.rgba.Green = depth;
|
||||
color.rgba.Red = depth;
|
||||
*dst++ = color;
|
||||
}
|
||||
src += zMap.Stride - zMap.Width;
|
||||
|
||||
Reference in New Issue
Block a user