Pad_Button

This commit is contained in:
krystalgamer 2024-09-30 18:28:37 +02:00
parent 425784f9e8
commit dd4d1feacb
7 changed files with 135 additions and 10 deletions

View File

@ -7,6 +7,7 @@
#include "mess.h"
#include "ps2m3d.h"
#include "pshell.h"
#include "spool.h"
#include <cmath>
#include <cstring>
@ -82,7 +83,70 @@ void PCGfx_ClipTriToNearPlane(_DXVERT **,_DXVERT *const *)
// @MEDIUMTODO
void PCGfx_DoModelPreview(void)
{
i32 totalSomething = 0;
CSuper* SuperItem = 0;
CSuper* SuperItemNext = 0;
PShell_Initialise();
i32 freeIndex = 0;
for (; freeIndex < MAXPSX; freeIndex)
{
if (!PSXRegion[freeIndex].Filename[0])
break;
}
i32 v24[40];
for (i32 j = 0; j < freeIndex; j++)
{
i32 v8 = PSXRegion[j].pPSX[2];
v24[j] = v8;
totalSomething += v8;
}
if (totalSomething && freeIndex)
{
PCGfx_SetSkyColor(0xFF800080);
i32 v9;
for (v9 = 0; v9 < freeIndex; v9++)
{
if (v24[v9] > 0)
{
if (!PSXRegion[v9].IsSuper)
{
SuperItem = reinterpret_cast<CSuper*>(PSXRegion[v9].pSuper);
SuperItemNext = reinterpret_cast<CSuper*>(SuperItem->field_20);
SuperItem->field_20 = 0;
}
SuperItem = createSuperItem(PSXRegion[v9].pSuper);
}
}
gMikeCamera[0].Position.vx = SuperItem->mPos.vx >> 12;
gMikeCamera[0].Position.vy = SuperItem->mPos.vy >> 12;
gMikeCamera[0].Position.vz = (SuperItem->mPos.vz >> 12) - 1;
gMikeCamera[0].Angles.vx = 0;
gMikeCamera[0].Angles.vy = 0;
gMikeCamera[0].Angles.vz = 0;
gMikeCamera[0].Style = 0;
i32 stop = 0;
while (!stop)
{
}
if (PSXRegion[v9].IsSuper)
{
delete SuperItem;
}
else
{
SuperItem->field_20 = SuperItemNext;
}
}
}
// @MEDIUMTODO
@ -602,9 +666,10 @@ void ZCLIP_VERT(_DXVERT *,_DXVERT *,_DXVERT *,float)
}
// @SMALLTODO
void createSuperItem(CItem *)
CSuper* createSuperItem(CItem *)
{
printf("createSuperItem(CItem *)");
return (CSuper*)0x30092024;
}
// @SMALLTODO

View File

@ -81,7 +81,7 @@ EXPORT void PCGfx_SetSkyColor(u32);
EXPORT void PCGfx_UseTexture(i32,DCGfx_BlendingMode);
EXPORT void PCPanel_DrawTexturedPoly(float,Texture const *,i32,i32,i32,i32,u8);
EXPORT void ZCLIP_VERT(_DXVERT *,_DXVERT *,_DXVERT *,float);
EXPORT void createSuperItem(CItem *);
EXPORT CSuper* createSuperItem(CItem *);
EXPORT void setupFog(void);
EXPORT void submitPoly(_DXVERT **,i32);

View File

@ -422,6 +422,7 @@ i32 validate(void)
validate_AnimPacket();
validate_SCalcBuffer();
validate_SCheat();
validate_SButton();
puts("[*] Validation done!");

View File

@ -57,10 +57,47 @@ void DCPad_Vibrate(i32,signed char,u8,u8)
printf("DCPad_Vibrate(i32,signed char,u8,u8)");
}
// @SMALLTODO
void Pad_Button(SButton *,i32)
EXPORT i32 Pad_IdleTime;
// @Ok
// @Matching
void Pad_Button(SButton* pBut, i32 state)
{
printf("Pad_Button(SButton *,i32)");
pBut->TriggeredTime++;
if (!pBut->Pressed)
{
if (state)
{
pBut->Triggered = 1;
pBut->field_2 = pBut->TriggeredTime < 10;
pBut->TriggeredTime = 0;
}
}
else
{
pBut->field_2 = 0;
}
if ( state )
{
Pad_IdleTime = 0;
pBut->Pressed = 1;
}
else
{
pBut->Pressed = 0;
}
if ( pBut->Pressed )
{
pBut->PressedTime++;
pBut->ReleasedTime = 0;
}
else
{
pBut->PressedTime = 0;
pBut->ReleasedTime++;
}
}
// @SMALLTODO
@ -106,3 +143,17 @@ void validate_SControl(void)
VALIDATE(SControl, field_148, 0x148);
VALIDATE(SControl, field_14C, 0x14C);
}
void validate_SButton(void)
{
VALIDATE_SIZE(SButton, 0x10);
VALIDATE(SButton, Pressed, 0x0);
VALIDATE(SButton, Triggered, 0x1);
VALIDATE(SButton, field_2, 0x2);
VALIDATE(SButton, PressedTime, 0x4);
VALIDATE(SButton, ReleasedTime, 0x8);
VALIDATE(SButton, TriggeredTime, 0xC);
}

View File

@ -17,6 +17,13 @@ struct SControl
struct SButton
{
u8 Pressed;
u8 Triggered;
u8 field_2;
i32 PressedTime;
i32 ReleasedTime;
i32 TriggeredTime;
};
EXPORT void Pad_SetDigitalMapping(SControl*, i32, i32, i32, i32);
@ -36,6 +43,7 @@ EXPORT void Pad_SetAnalogueMapping(SControl *,u8,u8,u8,u8,i32,i32,i32,i32);
EXPORT void Pad_Update(void);
void validate_SControl(void);
void validate_SButton(void);
EXPORT extern SControl gSControl;
#endif

View File

@ -141,7 +141,7 @@ i32 Spool_PSX(
if (IsEnviro)
{
print_if_false(EnviroList == 0, "EnviroList not NULL");
EnviroList = PSXRegion[openSpot].field_10;
EnviroList = PSXRegion[openSpot].pSuper;
gSpoolRegionRelatedOne = gSpoolRegionRelatedTwo;
gCommandPointRelated[0] = Spool_SkipPackets(PSXRegion[openSpot].pPSX);
@ -462,9 +462,9 @@ void Spool_Init(void)
PSXRegion[i].Usable = 0;
PSXRegion[i].ppModels = 0;
delete[] PSXRegion[i].field_10;
delete[] PSXRegion[i].pSuper;
PSXRegion[i].field_10 = 0;
PSXRegion[i].pSuper = 0;
PSXRegion[i].pPSX = 0;
PSXRegion[i].pAnimFile = 0;
PSXRegion[i].pHierarchy = 0;
@ -1075,7 +1075,7 @@ void validate_SPSXRegion(void)
VALIDATE(SPSXRegion, Usable, 0xA);
VALIDATE(SPSXRegion, Protected, 0xB);
VALIDATE(SPSXRegion, pModelChecksums, 0xC);
VALIDATE(SPSXRegion, field_10, 0x10);
VALIDATE(SPSXRegion, pSuper, 0x10);
VALIDATE(SPSXRegion, ppModels, 0x14);
VALIDATE(SPSXRegion, pPSX, 0x18);
VALIDATE(SPSXRegion, pAnimFile, 0x1C);

View File

@ -41,7 +41,7 @@ struct SPSXRegion {
// offset: 000C
u32 *pModelChecksums;
CItem* field_10;
CItem* pSuper;
// offset: 0010 (36 bytes)
void **ppModels; // SMode