Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshyfishy22 committed Sep 8, 2023
2 parents c41b7db + 466bc01 commit bbbf803
Show file tree
Hide file tree
Showing 30 changed files with 616 additions and 214 deletions.
10 changes: 10 additions & 0 deletions misc/xbox/ps_coloured.ps.cg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
struct vOut {
float4 color : COLOR;
};

float4 main(
vOut input
) : COLOR
{
return input.color;
}
12 changes: 12 additions & 0 deletions misc/xbox/ps_textured.ps.cg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
struct vOut {
float4 color : COLOR;
float2 tex0 : TEXCOORD0;
};

float4 main(
vOut input,
uniform sampler2D tex
) : COLOR
{
return tex2D(tex, input.tex0.xy) * input.color;
}
6 changes: 3 additions & 3 deletions misc/xbox/colored_vs.cg → misc/xbox/vs_coloured.vs.cg
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ vOut main(

position = float4(input.position.xyz, 1.0f);
position = mul(position, mvp);
//position.xyz = position.xyz / position.w;
position.xyz = position.xyz / position.w;

position.x = position.x * half_viewport.x + half_viewport.x;
position.y = -position.y * half_viewport.y + half_viewport.y;
position.z = position.z * half_viewport.z + half_viewport.z;
position.w = half_viewport.w;
//position.w = 1.0 / half_viewport.w;

result.col = input.color;
result.pos = position;
result.col = input.color;
return result;
}
35 changes: 35 additions & 0 deletions misc/xbox/vs_textured.vs.cg
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
struct vIn {
float4 tex : TEXCOORD;
float4 color : DIFFUSE;
float4 position : POSITION;
};

struct vOut {
float4 pos : POSITION;
float4 col : COLOR;
float4 tex : TEXCOORD0;
};

vOut main(
vIn input,
uniform float4x4 mvp,
uniform float4 half_viewport
)
{
vOut result;
float4 position;

position = float4(input.position.xyz, 1.0f);
position = mul(position, mvp);
position.xyz = position.xyz / position.w;

position.x = position.x * half_viewport.x + half_viewport.x;
position.y = -position.y * half_viewport.y + half_viewport.y;
position.z = position.z * half_viewport.z + half_viewport.z;
//position.w = 1.0 / half_viewport.w;

result.pos = position;
result.col = input.color;
result.tex = input.tex;
return result;
}
58 changes: 46 additions & 12 deletions src/Chat.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,32 +649,37 @@ static struct ChatCommand TeleportCommand = {
/*########################################################################################################################*
*------------------------------------------------------BlockEditCommand----------------------------------------------------*
*#########################################################################################################################*/
static cc_bool BlockEditCommand_GetTexture(const cc_string* value, int* tex) {
static cc_bool BlockEditCommand_GetInt(const cc_string* str, const char* name, int* value, int min, int max) {
int maxTexs = ATLAS1D_MAX_ATLASES;

if (!Convert_ParseInt(value, tex)) {
Chat_AddRaw("&eBlockEdit: &eTexture must be an integer");
if (!Convert_ParseInt(str, value)) {
Chat_Add1("&eBlockEdit: &e%c must be an integer", name);
return false;
}

if (*tex < 0 || *tex >= maxTexs) {
Chat_Add1("&eBlockEdit: &eTexture must be between 0 and %i", &maxTexs);
if (*value < min || *value > max) {
Chat_Add3("&eBlockEdit: &e%c must be between %i and %i", name, &min, &max);
return false;
}
return true;
}
static cc_bool BlockEditCommand_GetTexture(const cc_string* str, int* tex) {
return BlockEditCommand_GetInt(str, "Texture", tex, 0, ATLAS1D_MAX_ATLASES - 1);
}

static void BlockEditCommand_Execute(const cc_string* args, int argsCount__) {
cc_string parts[3];
cc_string* prop;
cc_string* value;
int argsCount, block, tex;
int argsCount, block, v;

if (String_CaselessEqualsConst(args, "properties")) {
Chat_AddRaw("&eEditable block properties:");
Chat_AddRaw("&a name &e- Sets the name of the block");
Chat_AddRaw("&a all &e- Sets textures on all six sides of the block");
Chat_AddRaw("&a sides &e- Sets textures on four sides of the block");
Chat_AddRaw("&a left/right/front/back/top/bottom &e- Sets one texture");
Chat_AddRaw("&a collide &e- Sets collision mode of the block");
return;
}

Expand All @@ -690,20 +695,49 @@ static void BlockEditCommand_Execute(const cc_string* args, int argsCount__) {
return;
}

/* TODO: Redo as an array */
prop = &parts[1];
value = &parts[2];
if (String_CaselessEqualsConst(prop, "name")) {
Block_SetName(block, value);
} else if (String_CaselessEqualsConst(prop, "all")) {
if (!BlockEditCommand_GetTexture(value, &tex)) return;
if (!BlockEditCommand_GetTexture(value, &v)) return;

Block_SetSide(tex, block);
Block_Tex(block, FACE_YMAX) = tex;
Block_Tex(block, FACE_YMIN) = tex;
Block_SetSide(v, block);
Block_Tex(block, FACE_YMAX) = v;
Block_Tex(block, FACE_YMIN) = v;
} else if (String_CaselessEqualsConst(prop, "sides")) {
if (!BlockEditCommand_GetTexture(value, &tex)) return;
if (!BlockEditCommand_GetTexture(value, &v)) return;

Block_SetSide(v, block);
} else if (String_CaselessEqualsConst(prop, "left")) {
if (!BlockEditCommand_GetTexture(value, &v)) return;

Block_Tex(block, FACE_XMIN) = v;
} else if (String_CaselessEqualsConst(prop, "right")) {
if (!BlockEditCommand_GetTexture(value, &v)) return;

Block_Tex(block, FACE_XMAX) = v;
} else if (String_CaselessEqualsConst(prop, "bottom")) {
if (!BlockEditCommand_GetTexture(value, &v)) return;

Block_Tex(block, FACE_YMIN) = v;
} else if (String_CaselessEqualsConst(prop, "top")) {
if (!BlockEditCommand_GetTexture(value, &v)) return;

Block_Tex(block, FACE_YMAX) = v;
} else if (String_CaselessEqualsConst(prop, "front")) {
if (!BlockEditCommand_GetTexture(value, &v)) return;

Block_Tex(block, FACE_ZMIN) = v;
} else if (String_CaselessEqualsConst(prop, "back")) {
if (!BlockEditCommand_GetTexture(value, &v)) return;

Block_Tex(block, FACE_ZMAX) = v;
} else if (String_CaselessEqualsConst(prop, "collide")) {
if (!BlockEditCommand_GetInt(value, "Collide mode", &v, 0, COLLIDE_CLIMB)) return;

Block_SetSide(tex, block);
Blocks.Collide[block] = v;
} else {
Chat_Add1("&eBlockEdit: &eUnknown property %s &e(See &a/client help blockedit&e)", prop);
return;
Expand Down
3 changes: 2 additions & 1 deletion src/Graphics_D3D11.c
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ static BitmapCol* D3D11_GetRow(struct Bitmap* bmp, int y) {
}

cc_result Gfx_TakeScreenshot(struct Stream* output) {
ID3D11Texture2D* tmp;
ID3D11Texture2D* tmp = NULL;
struct Bitmap bmp;
HRESULT hr;

Expand Down Expand Up @@ -1080,6 +1080,7 @@ cc_result Gfx_TakeScreenshot(struct Stream* output) {

finished:
if (tmp) { ID3D11Texture2D_Release(tmp); }
ID3D11Resource_Release(backbuffer_res);
return hr;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Graphics_PSP.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ static void guInit(void) {
sceGuScissor(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
sceGuDisable(GU_SCISSOR_TEST);


//sceGuDisable(GU_CLIP_PLANES);
sceGuEnable(GU_CLIP_PLANES); // TODO: swap near/far instead of this?
sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);

sceGuFinish();
Expand Down Expand Up @@ -218,6 +217,7 @@ void Gfx_CalcPerspectiveMatrix(struct Matrix* matrix, float fov, float aspect, f
matrix->row3.W = -1.0f;
matrix->row4.Z = -(2.0f * zFar * zNear) / (zFar - zNear);
matrix->row4.W = 0.0f;
// TODO: should direct3d9 one be used insted with clip range from 0,1 ?
}


Expand Down
Loading

0 comments on commit bbbf803

Please sign in to comment.