render v2, ready
This commit is contained in:
Binary file not shown.
@@ -61,7 +61,7 @@ int main()
|
||||
visualKickerStruct kicker1{};
|
||||
loader::kicker(509, &kicker1);
|
||||
|
||||
auto score1 = score::create("score1", 117);
|
||||
auto score1 = score::create("score1", nullptr);
|
||||
|
||||
auto pinballTable = new TPinballTable();
|
||||
//pinballTable->find_component(1);
|
||||
|
||||
@@ -47,7 +47,7 @@ TPinballComponent::TPinballComponent(TPinballTable* table, int groupIndex, bool
|
||||
zMap = static_cast<zmap_header_type*>(ListZMap->Get(0));
|
||||
if (ListBitmap)
|
||||
{
|
||||
visual_rect bmp1Rect{}, tmpRect{};
|
||||
rectangle_type bmp1Rect{}, tmpRect{};
|
||||
auto rootBmp = static_cast<gdrv_bitmap8*>(ListBitmap->Get(0));
|
||||
bmp1Rect.XPosition = rootBmp->XPosition - table->XOffset;
|
||||
bmp1Rect.YPosition = rootBmp->YPosition - table->YOffset;
|
||||
|
||||
@@ -58,7 +58,7 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
|
||||
TLightGroup* lightGroupObj = new TLightGroup(this, 0);
|
||||
this->LightGroup = lightGroupObj;
|
||||
|
||||
auto score1 = score::create("score1", pinball::render_background_bitmap);
|
||||
auto score1 = score::create("score1", render::background_bitmap);
|
||||
this->Score1 = score1;
|
||||
this->Score2 = score1;
|
||||
int scoreIndex = 1;
|
||||
@@ -71,8 +71,8 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
|
||||
while (scoreIndex < 4);
|
||||
this->UnknownP45 = 0;
|
||||
this->UnknownP73 = 3;
|
||||
this->ScoreBallcount = (int*)score::create("ballcount1", pinball::render_background_bitmap);
|
||||
this->ScorePlayerNumber1 = (int*)score::create("player_number1", pinball::render_background_bitmap);
|
||||
this->ScoreBallcount = (int*)score::create("ballcount1", render::background_bitmap);
|
||||
this->ScorePlayerNumber1 = (int*)score::create("player_number1", render::background_bitmap);
|
||||
int groupIndexObjects = loader::query_handle("table_objects");
|
||||
|
||||
short* shortArr = loader::query_iattribute(groupIndexObjects, 1025, &shortArrLength);
|
||||
|
||||
@@ -2,35 +2,117 @@
|
||||
#include "maths.h"
|
||||
|
||||
|
||||
void maths::enclosing_box(visual_rect* rect1, visual_rect* rect2, visual_rect* dstRect)
|
||||
void maths::enclosing_box(rectangle_type* rect1, rectangle_type* rect2, rectangle_type* dstRect)
|
||||
{
|
||||
int xPos1 = rect1->XPosition;
|
||||
int yPos1 = rect1->YPosition;
|
||||
int width1 = rect1->Width;
|
||||
int height1 = rect1->Height;
|
||||
int xPos2 = rect2->XPosition;
|
||||
bool rect2XPosLessRect1 = rect2->XPosition < rect1->XPosition;
|
||||
int yPos2 = rect2->YPosition;
|
||||
int width2 = rect2->Width;
|
||||
int height2 = rect2->Height;
|
||||
int xPos2_2 = rect2->XPosition;
|
||||
if (rect2XPosLessRect1)
|
||||
{
|
||||
width1 += xPos1 - xPos2;
|
||||
xPos1 = xPos2;
|
||||
}
|
||||
if (yPos2 < yPos1)
|
||||
{
|
||||
height1 += yPos1 - yPos2;
|
||||
yPos1 = yPos2;
|
||||
}
|
||||
if (width2 + xPos2 > xPos1 + width1)
|
||||
width1 = xPos2_2 + width2 - xPos1;
|
||||
int height1_2 = height1;
|
||||
if (height2 + yPos2 > height1 + yPos1)
|
||||
height1_2 = yPos2 + height2 - yPos1;
|
||||
dstRect->YPosition = yPos1;
|
||||
dstRect->Height = height1_2;
|
||||
dstRect->XPosition = xPos1;
|
||||
dstRect->Width = width1;
|
||||
}
|
||||
int yPos1 = rect1->YPosition;
|
||||
int width1 = rect1->Width;
|
||||
int height1 = rect1->Height;
|
||||
int xPos2 = rect2->XPosition;
|
||||
bool rect2XPosLessRect1 = rect2->XPosition < rect1->XPosition;
|
||||
int yPos2 = rect2->YPosition;
|
||||
int width2 = rect2->Width;
|
||||
int height2 = rect2->Height;
|
||||
int xPos2_2 = rect2->XPosition;
|
||||
if (rect2XPosLessRect1)
|
||||
{
|
||||
width1 += xPos1 - xPos2;
|
||||
xPos1 = xPos2;
|
||||
}
|
||||
if (yPos2 < yPos1)
|
||||
{
|
||||
height1 += yPos1 - yPos2;
|
||||
yPos1 = yPos2;
|
||||
}
|
||||
if (width2 + xPos2 > xPos1 + width1)
|
||||
width1 = xPos2_2 + width2 - xPos1;
|
||||
int height1_2 = height1;
|
||||
if (height2 + yPos2 > height1 + yPos1)
|
||||
height1_2 = yPos2 + height2 - yPos1;
|
||||
dstRect->YPosition = yPos1;
|
||||
dstRect->Height = height1_2;
|
||||
dstRect->XPosition = xPos1;
|
||||
dstRect->Width = width1;
|
||||
}
|
||||
|
||||
|
||||
int maths::rectangle_clip(rectangle_type* rect1, rectangle_type* rect2, rectangle_type* dstRect)
|
||||
{
|
||||
int xPos1 = rect1->XPosition;
|
||||
int yPos1 = rect1->YPosition;
|
||||
int height1 = rect1->Height;
|
||||
int xRight2 = rect2->XPosition + rect2->Width;
|
||||
int width1 = rect1->Width;
|
||||
int yRight2 = rect2->YPosition + rect2->Height;
|
||||
if (xPos1 + width1 < rect2->XPosition)
|
||||
return 0;
|
||||
if (xPos1 >= xRight2)
|
||||
return 0;
|
||||
int yPos2 = yPos1;
|
||||
if (yPos1 + height1 < rect2->YPosition || yPos1 >= yRight2)
|
||||
return 0;
|
||||
if (xPos1 < rect2->XPosition)
|
||||
{
|
||||
width1 += xPos1 - rect2->XPosition;
|
||||
xPos1 = rect2->XPosition;
|
||||
}
|
||||
if (xPos1 + width1 > xRight2)
|
||||
width1 = xRight2 - xPos1;
|
||||
int height2 = height1;
|
||||
if (yPos1 < rect2->YPosition)
|
||||
{
|
||||
height2 = yPos1 - rect2->YPosition + height1;
|
||||
yPos2 = rect2->YPosition;
|
||||
}
|
||||
if (height2 + yPos2 > yRight2)
|
||||
height2 = yRight2 - yPos2;
|
||||
if (!width1 || !height2)
|
||||
return 0;
|
||||
if (dstRect)
|
||||
{
|
||||
dstRect->XPosition = xPos1;
|
||||
dstRect->YPosition = yPos2;
|
||||
dstRect->Width = width1;
|
||||
dstRect->Height = height2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int maths::overlapping_box(rectangle_type* rect1, rectangle_type* rect2, rectangle_type* dstRect)
|
||||
{
|
||||
int v3; // esi
|
||||
int v4; // edi
|
||||
int v5; // esi
|
||||
int v6; // esi
|
||||
int v7; // edi
|
||||
|
||||
if (rect1->XPosition >= rect2->XPosition)
|
||||
{
|
||||
dstRect->XPosition = rect2->XPosition;
|
||||
v3 = rect1->Width - rect2->XPosition;
|
||||
v4 = rect1->XPosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
dstRect->XPosition = rect1->XPosition;
|
||||
v3 = rect2->Width - rect1->XPosition;
|
||||
v4 = rect2->XPosition;
|
||||
}
|
||||
dstRect->Width = v3 + v4 + 1;
|
||||
v5 = rect1->YPosition;
|
||||
if (v5 >= rect2->YPosition)
|
||||
{
|
||||
dstRect->YPosition = rect2->YPosition;
|
||||
v6 = rect1->Height - rect2->YPosition;
|
||||
v7 = rect1->YPosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
dstRect->YPosition = v5;
|
||||
v6 = rect2->Height - rect1->YPosition;
|
||||
v7 = rect2->YPosition;
|
||||
}
|
||||
dstRect->Height = v6 + v7 + 1;
|
||||
return dstRect->Width <= rect2->Width + rect1->Width && dstRect->Height <= rect2->Height + rect1->Height;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
struct __declspec(align(4)) visual_rect
|
||||
struct __declspec(align(4)) rectangle_type
|
||||
{
|
||||
int XPosition;
|
||||
int YPosition;
|
||||
@@ -12,7 +12,7 @@ struct __declspec(align(4)) visual_rect
|
||||
class maths
|
||||
{
|
||||
public:
|
||||
static void enclosing_box(visual_rect* rect1, visual_rect* rect2, visual_rect* dstRect);
|
||||
|
||||
static void enclosing_box(rectangle_type* rect1, rectangle_type* rect2, rectangle_type* dstRect);
|
||||
static int rectangle_clip(rectangle_type* rect1, rectangle_type* rect2, rectangle_type* dstRect);
|
||||
static int overlapping_box(rectangle_type* rect1, rectangle_type* rect2, rectangle_type* dstRect);
|
||||
};
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
|
||||
int pinball::quickFlag = 0;
|
||||
int pinball::render_background_bitmap = 0;
|
||||
TTextBox* pinball::InfoTextBox;
|
||||
TTextBox* pinball::MissTextBox;
|
||||
char pinball::getRcBuffer[6 * 256];
|
||||
|
||||
@@ -5,7 +5,6 @@ class pinball
|
||||
{
|
||||
public:
|
||||
static int quickFlag;
|
||||
static int render_background_bitmap;
|
||||
static TTextBox* InfoTextBox;
|
||||
static TTextBox* MissTextBox;
|
||||
static HINSTANCE hinst;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,30 +12,22 @@ enum class VisualType : char
|
||||
|
||||
struct __declspec(align(4)) render_sprite_type_struct
|
||||
{
|
||||
int XPosition;
|
||||
int YPosition;
|
||||
int Bmp8Width;
|
||||
int Bmp8Height;
|
||||
gdrv_bitmap8* RootBmp8;
|
||||
rectangle_type BmpRect;
|
||||
gdrv_bitmap8* Bmp;
|
||||
zmap_header_type* ZMap;
|
||||
char Unknown6_0;
|
||||
VisualType VisualType;
|
||||
short Depth;
|
||||
int XPosition2;
|
||||
int YPosition2;
|
||||
int Bmp8Width2;
|
||||
int Bmp8Height2;
|
||||
__int16 Depth;
|
||||
rectangle_type BmpRectCopy;
|
||||
int ZMapOffestY;
|
||||
int ZMapOffestX;
|
||||
int Unknown13;
|
||||
int Unknown14;
|
||||
int Unknown15;
|
||||
int Unknown16;
|
||||
int Unknown17;
|
||||
int Unknown18;
|
||||
visual_rect Rect;
|
||||
rectangle_type DirtyRect;
|
||||
render_sprite_type_struct** SpriteArray;
|
||||
int SpriteCount;
|
||||
rectangle_type BoundingRect;
|
||||
};
|
||||
|
||||
|
||||
static_assert(sizeof(render_sprite_type_struct) == 0x5c, "Wrong size render_sprite_type_struct");
|
||||
|
||||
class render
|
||||
@@ -45,12 +37,29 @@ public:
|
||||
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;
|
||||
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 uninit();
|
||||
static void update();
|
||||
static void paint();
|
||||
static int sprite_modified(render_sprite_type_struct* sprite);
|
||||
static render_sprite_type_struct* create_sprite(VisualType visualType, gdrv_bitmap8* rootBmp8,
|
||||
static void sprite_modified(render_sprite_type_struct* sprite);
|
||||
static render_sprite_type_struct* create_sprite(VisualType visualType, gdrv_bitmap8* bmp,
|
||||
zmap_header_type* zMap,
|
||||
int xPosition, int yPosition, visual_rect* rect);
|
||||
int xPosition, int yPosition, rectangle_type* rect);
|
||||
static void remove_sprite(render_sprite_type_struct* sprite);
|
||||
static void remove_ball(struct render_sprite_type_struct* ball);
|
||||
static void sprite_set(render_sprite_type_struct* sprite, gdrv_bitmap8* bmp, zmap_header_type* zMap, int xPos,
|
||||
int yPos);
|
||||
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 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);
|
||||
};
|
||||
|
||||
@@ -10,13 +10,13 @@ int score::init()
|
||||
return 1;
|
||||
}
|
||||
|
||||
scoreStruct* score::create(LPCSTR fieldName, int renderBgBmp)
|
||||
scoreStruct* score::create(LPCSTR fieldName, gdrv_bitmap8* renderBgBmp)
|
||||
{
|
||||
scoreStruct* score = (scoreStruct*)memory::allocate(sizeof(scoreStruct));
|
||||
if (!score)
|
||||
return nullptr;
|
||||
score->Unknown1 = -9999;
|
||||
score->RenderBgBmp = renderBgBmp;
|
||||
score->BackgroundBmp = renderBgBmp;
|
||||
__int16* shortArr = (__int16*)partman::field_labeled(loader::loader_table, fieldName, datFieldTypes::ShortArray);
|
||||
if (!shortArr)
|
||||
{
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#pragma once
|
||||
#include "gdrv.h"
|
||||
|
||||
struct scoreStruct
|
||||
{
|
||||
int Unknown1;
|
||||
int Unknown2;
|
||||
int RenderBgBmp;
|
||||
gdrv_bitmap8* BackgroundBmp;
|
||||
int Short1;
|
||||
int Short2;
|
||||
int Short3;
|
||||
@@ -25,6 +26,6 @@ class score
|
||||
{
|
||||
public:
|
||||
static int init();
|
||||
static scoreStruct* create(LPCSTR fieldName, int renderBgBmp);
|
||||
static scoreStruct* create(LPCSTR fieldName, gdrv_bitmap8* renderBgBmp);
|
||||
static scoreStruct* dup(scoreStruct* score, int scoreIndex);
|
||||
};
|
||||
|
||||
@@ -31,15 +31,11 @@ int zdrv::destroy_zmap(zmap_header_type* zmap)
|
||||
return -1;
|
||||
if (zmap->ZPtr1)
|
||||
memory::free(zmap->ZPtr1);
|
||||
zmap->Width = 0;
|
||||
zmap->Height = 0;
|
||||
zmap->Stride = 0;
|
||||
zmap->ZPtr1 = nullptr;
|
||||
zmap->ZPtr2 = nullptr;
|
||||
memset(zmap, 0, sizeof(zmap_header_type));
|
||||
return 0;
|
||||
}
|
||||
|
||||
void zdrv::fill(zmap_header_type* zmap, int width, int height, int xOff, int yOff, __int16 fillChar)
|
||||
void zdrv::fill(zmap_header_type* zmap, int width, int height, int xOff, int yOff, unsigned __int16 fillChar)
|
||||
{
|
||||
int fillCharInt = fillChar | (fillChar << 16);
|
||||
auto zmapPtr = &zmap->ZPtr1[2 * (xOff + zmap->Stride * (zmap->Height - height - yOff))];
|
||||
@@ -50,7 +46,7 @@ void zdrv::fill(zmap_header_type* zmap, int width, int height, int xOff, int yOf
|
||||
unsigned int widthDiv2 = static_cast<unsigned int>(width) >> 1;
|
||||
memset32(zmapPtr, fillCharInt, widthDiv2);
|
||||
|
||||
__int16* lastShort = (__int16*)&zmapPtr[2 * widthDiv2];
|
||||
auto lastShort = &zmapPtr[2 * widthDiv2];
|
||||
for (int i = widthMod2; i; --i)
|
||||
*lastShort++ = fillChar;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
static int pad(int width);
|
||||
static int create_zmap(zmap_header_type* zmap, int width, int height);
|
||||
static int destroy_zmap(zmap_header_type* zmap);
|
||||
static void fill(zmap_header_type* zmap, int width, int height, int xOff, int yOff, __int16 fillChar);
|
||||
static void fill(zmap_header_type* zmap, int width, int height, int xOff, int yOff, unsigned __int16 fillChar);
|
||||
static void paint(int width, int height, gdrv_bitmap8* dstBmp, int dstBmpXOff, int dstBmpYOff,
|
||||
zmap_header_type* dstZMap, int dstZMapXOff, int dstZMapYOff, gdrv_bitmap8* srcBmp, int srcBmpXOff,
|
||||
int srcBmpYOff, zmap_header_type* srcZMap, int srcZMapXOff, int srcZMapYOff);
|
||||
|
||||
Reference in New Issue
Block a user