mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2024-12-18 11:52:25 -05:00
Render tweaks part 3: bitmap/zMap pairs.
This commit is contained in:
parent
e7ddebd16c
commit
4ec30cf472
6 changed files with 37 additions and 35 deletions
|
@ -30,7 +30,7 @@ TBall::TBall(TPinballTable* table) : TPinballComponent(table, -1, false)
|
||||||
Position.X = 0.0;
|
Position.X = 0.0;
|
||||||
Position.Y = 0.0;
|
Position.Y = 0.0;
|
||||||
|
|
||||||
ListBitmap = new std::vector<gdrv_bitmap8*>();
|
ListBitmap = new std::vector<SpriteData>();
|
||||||
|
|
||||||
/*Full tilt: ball is ballN, where N[0,2] resolution*/
|
/*Full tilt: ball is ballN, where N[0,2] resolution*/
|
||||||
auto groupIndex = loader::query_handle(ballGroupName);
|
auto groupIndex = loader::query_handle(ballGroupName);
|
||||||
|
|
|
@ -18,7 +18,6 @@ TPinballComponent::TPinballComponent(TPinballTable* table, int groupIndex, bool
|
||||||
PinballTable = table;
|
PinballTable = table;
|
||||||
RenderSprite = nullptr;
|
RenderSprite = nullptr;
|
||||||
ListBitmap = nullptr;
|
ListBitmap = nullptr;
|
||||||
ListZMap = nullptr;
|
|
||||||
GroupName = nullptr;
|
GroupName = nullptr;
|
||||||
Control = nullptr;
|
Control = nullptr;
|
||||||
VisualPosNormX= -1.0f;
|
VisualPosNormX= -1.0f;
|
||||||
|
@ -35,31 +34,29 @@ TPinballComponent::TPinballComponent(TPinballTable* table, int groupIndex, bool
|
||||||
for (int index = 0; index < visualCount; ++index)
|
for (int index = 0; index < visualCount; ++index)
|
||||||
{
|
{
|
||||||
loader::query_visual(groupIndex, index, &visual);
|
loader::query_visual(groupIndex, index, &visual);
|
||||||
if (visual.Bitmap)
|
if (visual.Bitmap.Bmp)
|
||||||
{
|
{
|
||||||
|
assertm(visual.Bitmap.ZMap, "Bitmap/zMap pairing is mandatory");
|
||||||
if (!ListBitmap)
|
if (!ListBitmap)
|
||||||
ListBitmap = new std::vector<gdrv_bitmap8*>();
|
ListBitmap = new std::vector<SpriteData>();
|
||||||
ListBitmap->push_back(visual.Bitmap);
|
ListBitmap->push_back(visual.Bitmap);
|
||||||
}
|
}
|
||||||
if (visual.ZMap)
|
|
||||||
{
|
|
||||||
if (!ListZMap)
|
|
||||||
ListZMap = new std::vector<zmap_header_type*>();
|
|
||||||
ListZMap->push_back(visual.ZMap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ListBitmap)
|
if (ListBitmap)
|
||||||
{
|
{
|
||||||
rectangle_type bmp1Rect{}, tmpRect{};
|
rectangle_type bmp1Rect{}, tmpRect{};
|
||||||
auto rootBmp = ListBitmap->at(0);
|
const auto rootSprite = ListBitmap->at(0);
|
||||||
|
const auto rootBmp = rootSprite.Bmp;
|
||||||
|
|
||||||
bmp1Rect.XPosition = rootBmp->XPosition - table->XOffset;
|
bmp1Rect.XPosition = rootBmp->XPosition - table->XOffset;
|
||||||
bmp1Rect.YPosition = rootBmp->YPosition - table->YOffset;
|
bmp1Rect.YPosition = rootBmp->YPosition - table->YOffset;
|
||||||
bmp1Rect.Width = rootBmp->Width;
|
bmp1Rect.Width = rootBmp->Width;
|
||||||
bmp1Rect.Height = rootBmp->Height;
|
bmp1Rect.Height = rootBmp->Height;
|
||||||
|
|
||||||
for (auto index = 1u; index < ListBitmap->size(); index++)
|
for (auto index = 1u; index < ListBitmap->size(); index++)
|
||||||
{
|
{
|
||||||
auto bmp = ListBitmap->at(index);
|
auto bmp = ListBitmap->at(index).Bmp;
|
||||||
tmpRect.XPosition = bmp->XPosition - table->XOffset;
|
tmpRect.XPosition = bmp->XPosition - table->XOffset;
|
||||||
tmpRect.YPosition = bmp->YPosition - table->YOffset;
|
tmpRect.YPosition = bmp->YPosition - table->YOffset;
|
||||||
tmpRect.Width = bmp->Width;
|
tmpRect.Width = bmp->Width;
|
||||||
|
@ -67,12 +64,10 @@ TPinballComponent::TPinballComponent(TPinballTable* table, int groupIndex, bool
|
||||||
maths::enclosing_box(bmp1Rect, tmpRect, bmp1Rect);
|
maths::enclosing_box(bmp1Rect, tmpRect, bmp1Rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertm(ListZMap, "All sprites should have bitmap/zMap pairs");
|
|
||||||
auto zMap = ListZMap ? ListZMap->at(0) : nullptr;
|
|
||||||
RenderSprite = new render_sprite(
|
RenderSprite = new render_sprite(
|
||||||
VisualTypes::Sprite,
|
VisualTypes::Sprite,
|
||||||
rootBmp,
|
rootBmp,
|
||||||
zMap,
|
rootSprite.ZMap,
|
||||||
rootBmp->XPosition - table->XOffset,
|
rootBmp->XPosition - table->XOffset,
|
||||||
rootBmp->YPosition - table->YOffset,
|
rootBmp->YPosition - table->YOffset,
|
||||||
&bmp1Rect);
|
&bmp1Rect);
|
||||||
|
@ -101,7 +96,6 @@ TPinballComponent::~TPinballComponent()
|
||||||
}
|
}
|
||||||
|
|
||||||
delete ListBitmap;
|
delete ListBitmap;
|
||||||
delete ListZMap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -137,8 +131,9 @@ void TPinballComponent::SpriteSet(int index) const
|
||||||
zmap_header_type* zMap;
|
zmap_header_type* zMap;
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
{
|
{
|
||||||
bmp = ListBitmap->at(index);
|
auto& spriteData = ListBitmap->at(index);
|
||||||
zMap = ListZMap->at(index);
|
bmp = spriteData.Bmp;
|
||||||
|
zMap = spriteData.ZMap;
|
||||||
xPos = bmp->XPosition - PinballTable->XOffset;
|
xPos = bmp->XPosition - PinballTable->XOffset;
|
||||||
yPos = bmp->YPosition - PinballTable->YOffset;
|
yPos = bmp->YPosition - PinballTable->YOffset;
|
||||||
}
|
}
|
||||||
|
@ -157,12 +152,14 @@ void TPinballComponent::SpriteSetBall(int index, vector2i pos, float depth) cons
|
||||||
{
|
{
|
||||||
if (ListBitmap)
|
if (ListBitmap)
|
||||||
{
|
{
|
||||||
auto bmp = index >= 0 ? ListBitmap->at(index) : nullptr;
|
gdrv_bitmap8* bmp = nullptr;
|
||||||
if (bmp)
|
if (index >= 0)
|
||||||
{
|
{
|
||||||
|
bmp = ListBitmap->at(index).Bmp;
|
||||||
pos.X -= bmp->Width / 2;
|
pos.X -= bmp->Width / 2;
|
||||||
pos.Y -= bmp->Height / 2;
|
pos.Y -= bmp->Height / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderSprite->ball_set(bmp, depth, pos.X, pos.Y);
|
RenderSprite->ball_set(bmp, depth, pos.X, pos.Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
struct SpriteData;
|
||||||
struct vector2i;
|
struct vector2i;
|
||||||
struct zmap_header_type;
|
struct zmap_header_type;
|
||||||
struct gdrv_bitmap8;
|
struct gdrv_bitmap8;
|
||||||
|
@ -150,8 +151,7 @@ public:
|
||||||
int GroupIndex;
|
int GroupIndex;
|
||||||
render_sprite* RenderSprite;
|
render_sprite* RenderSprite;
|
||||||
TPinballTable* PinballTable;
|
TPinballTable* PinballTable;
|
||||||
std::vector<gdrv_bitmap8*>* ListBitmap;
|
std::vector<SpriteData>* ListBitmap;
|
||||||
std::vector<zmap_header_type*>* ListZMap;
|
|
||||||
private:
|
private:
|
||||||
float VisualPosNormX;
|
float VisualPosNormX;
|
||||||
float VisualPosNormY;
|
float VisualPosNormY;
|
||||||
|
|
|
@ -20,19 +20,20 @@ TTableLayer::TTableLayer(TPinballTable* table): TCollisionComponent(table, -1, f
|
||||||
|
|
||||||
auto groupIndex = loader::query_handle("table");
|
auto groupIndex = loader::query_handle("table");
|
||||||
loader::query_visual(groupIndex, 0, &visual);
|
loader::query_visual(groupIndex, 0, &visual);
|
||||||
|
auto spriteData = visual.Bitmap;
|
||||||
|
|
||||||
/*Full tilt: proj center first value is offset by resolution*/
|
/*Full tilt: proj center first value is offset by resolution*/
|
||||||
auto projCenter = loader::query_float_attribute(groupIndex, 0, 700 + fullscrn::GetResolution());
|
auto projCenter = loader::query_float_attribute(groupIndex, 0, 700 + fullscrn::GetResolution());
|
||||||
proj::recenter(projCenter[0], projCenter[1]);
|
proj::recenter(projCenter[0], projCenter[1]);
|
||||||
render::set_background_zmap(visual.ZMap, 0, 0);
|
render::set_background_zmap(spriteData.ZMap, 0, 0);
|
||||||
|
|
||||||
auto bmp = visual.Bitmap;
|
auto bmp = spriteData.Bmp;
|
||||||
VisBmp = visual.Bitmap;
|
VisBmp = bmp;
|
||||||
rect.XPosition = 0;
|
rect.XPosition = 0;
|
||||||
rect.YPosition = 0;
|
rect.YPosition = 0;
|
||||||
rect.Width = bmp->Width;
|
rect.Width = bmp->Width;
|
||||||
rect.Height = bmp->Height;
|
rect.Height = bmp->Height;
|
||||||
new render_sprite(VisualTypes::Background, bmp, visual.ZMap, 0, 0, &rect);
|
new render_sprite(VisualTypes::Background, bmp, spriteData.ZMap, 0, 0, &rect);
|
||||||
|
|
||||||
PinballTable->SoundIndex1 = visual.SoundIndex4;
|
PinballTable->SoundIndex1 = visual.SoundIndex4;
|
||||||
PinballTable->SoundIndex2 = visual.SoundIndex3;
|
PinballTable->SoundIndex2 = visual.SoundIndex3;
|
||||||
|
|
|
@ -75,8 +75,7 @@ void loader::default_vsi(visualStruct* visual)
|
||||||
visual->Elasticity = 0.60000002f;
|
visual->Elasticity = 0.60000002f;
|
||||||
visual->FloatArrCount = 0;
|
visual->FloatArrCount = 0;
|
||||||
visual->SoftHitSoundId = 0;
|
visual->SoftHitSoundId = 0;
|
||||||
visual->Bitmap = nullptr;
|
visual->Bitmap = { nullptr, nullptr };
|
||||||
visual->ZMap = nullptr;
|
|
||||||
visual->SoundIndex3 = 0;
|
visual->SoundIndex3 = 0;
|
||||||
visual->SoundIndex4 = 0;
|
visual->SoundIndex4 = 0;
|
||||||
}
|
}
|
||||||
|
@ -421,8 +420,9 @@ int loader::query_visual(int groupIndex, int groupIndexOffset, visualStruct* vis
|
||||||
if (stateId < 0)
|
if (stateId < 0)
|
||||||
return error(16, 18);
|
return error(16, 18);
|
||||||
|
|
||||||
visual->Bitmap = loader_table->GetBitmap(stateId);
|
auto bmp = loader_table->GetBitmap(stateId);
|
||||||
visual->ZMap = loader_table->GetZMap(stateId);
|
auto zMap = loader_table->GetZMap(stateId);
|
||||||
|
visual->Bitmap = { bmp, zMap };
|
||||||
|
|
||||||
auto shortArr = reinterpret_cast<int16_t*>(loader_table->field(stateId, FieldTypes::ShortArray));
|
auto shortArr = reinterpret_cast<int16_t*>(loader_table->field(stateId, FieldTypes::ShortArray));
|
||||||
if (shortArr)
|
if (shortArr)
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "gdrv.h"
|
|
||||||
#include "maths.h"
|
#include "maths.h"
|
||||||
#include "zdrv.h"
|
|
||||||
#include "TPinballComponent.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
class TPinballComponent;
|
||||||
|
struct zmap_header_type;
|
||||||
|
struct gdrv_bitmap8;
|
||||||
class DatFile;
|
class DatFile;
|
||||||
|
|
||||||
struct errorMsg
|
struct errorMsg
|
||||||
|
@ -31,6 +31,11 @@ struct visualKickerStruct
|
||||||
int HardHitSoundId;
|
int HardHitSoundId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SpriteData
|
||||||
|
{
|
||||||
|
gdrv_bitmap8* Bmp;
|
||||||
|
zmap_header_type* ZMap;
|
||||||
|
};
|
||||||
|
|
||||||
struct visualStruct
|
struct visualStruct
|
||||||
{
|
{
|
||||||
|
@ -43,8 +48,7 @@ struct visualStruct
|
||||||
int CollisionGroup;
|
int CollisionGroup;
|
||||||
int SoundIndex4;
|
int SoundIndex4;
|
||||||
int SoundIndex3;
|
int SoundIndex3;
|
||||||
gdrv_bitmap8* Bitmap;
|
SpriteData Bitmap;
|
||||||
zmap_header_type* ZMap;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(push)
|
#pragma pack(push)
|
||||||
|
|
Loading…
Reference in a new issue