mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 09:01:57 -05:00
TNT shouldn't blow up in singleplayer when in classic mode
This commit is contained in:
parent
b24e2cb56b
commit
e91fff6f85
6 changed files with 50 additions and 215 deletions
|
@ -12,7 +12,7 @@ BUILTIN_ASSETS=
|
|||
SH_PROGRAM := ClassiCube-saturn
|
||||
SH_SRCS := $(wildcard src/*.c)
|
||||
|
||||
SH_CFLAGS+= -Os -I. -DPLAT_SATURN
|
||||
SH_CFLAGS+= -Os -I. -DPLAT_SATURN -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers
|
||||
SH_LDFLAGS+=
|
||||
|
||||
IP_VERSION:= V1.000
|
||||
|
|
|
@ -552,6 +552,7 @@ void Physics_Init(void) {
|
|||
Physics.OnRandomTick[BLOCK_STILL_LAVA] = Physics_ActivateLava;
|
||||
|
||||
Physics.OnPlace[BLOCK_SLAB] = Physics_HandleSlab;
|
||||
if (Game_ClassicMode) return;
|
||||
Physics.OnPlace[BLOCK_COBBLE_SLAB] = Physics_HandleCobblestoneSlab;
|
||||
Physics.OnPlace[BLOCK_TNT] = Physics_HandleTnt;
|
||||
}
|
||||
|
|
|
@ -18,15 +18,17 @@ static cc_bool renderingDisabled;
|
|||
*#########################################################################################################################*/
|
||||
static void InitGLState(void) {
|
||||
glClearDepth(1.0f);
|
||||
glDepthMask(GL_TRUE);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glDisable(GL_FOG);
|
||||
ALPHA_TEST_ENABLED = GL_FALSE;
|
||||
CULLING_ENABLED = GL_FALSE;
|
||||
BLEND_ENABLED = GL_FALSE;
|
||||
DEPTH_TEST_ENABLED = GL_FALSE;
|
||||
DEPTH_MASK_ENABLED = GL_TRUE;
|
||||
TEXTURES_ENABLED = GL_FALSE;
|
||||
FOG_ENABLED = GL_FALSE;
|
||||
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
}
|
||||
|
||||
void Gfx_Create(void) {
|
||||
|
@ -53,15 +55,21 @@ void Gfx_Free(void) {
|
|||
Gfx_FreeState();
|
||||
}
|
||||
|
||||
#define gl_Toggle(cap) if (enabled) { glEnable(cap); } else { glDisable(cap); }
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------State management----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static PackedCol gfx_clearColor;
|
||||
void Gfx_SetFaceCulling(cc_bool enabled) { gl_Toggle(GL_CULL_FACE); }
|
||||
static void SetAlphaBlend(cc_bool enabled) { gl_Toggle(GL_BLEND); }
|
||||
|
||||
void Gfx_SetFaceCulling(cc_bool enabled) {
|
||||
CULLING_ENABLED = enabled;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
}
|
||||
|
||||
static void SetAlphaBlend(cc_bool enabled) {
|
||||
BLEND_ENABLED = enabled;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
}
|
||||
void Gfx_SetAlphaArgBlend(cc_bool enabled) { }
|
||||
|
||||
void Gfx_ClearColor(PackedCol color) {
|
||||
|
@ -78,10 +86,24 @@ static void SetColorWrite(cc_bool r, cc_bool g, cc_bool b, cc_bool a) {
|
|||
// TODO: Doesn't work
|
||||
}
|
||||
|
||||
void Gfx_SetDepthWrite(cc_bool enabled) { glDepthMask(enabled); }
|
||||
void Gfx_SetDepthTest(cc_bool enabled) { gl_Toggle(GL_DEPTH_TEST); }
|
||||
void Gfx_SetDepthWrite(cc_bool enabled) {
|
||||
if (DEPTH_MASK_ENABLED == enabled) return;
|
||||
|
||||
DEPTH_MASK_ENABLED = enabled;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
}
|
||||
|
||||
static void SetAlphaTest(cc_bool enabled) { gl_Toggle(GL_ALPHA_TEST); }
|
||||
void Gfx_SetDepthTest(cc_bool enabled) {
|
||||
if (DEPTH_TEST_ENABLED == enabled) return;
|
||||
|
||||
DEPTH_TEST_ENABLED = enabled;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
}
|
||||
|
||||
static void SetAlphaTest(cc_bool enabled) {
|
||||
ALPHA_TEST_ENABLED = enabled;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
}
|
||||
|
||||
void Gfx_DepthOnlyRendering(cc_bool depthOnly) {
|
||||
// don't need a fake second pass in this case
|
||||
|
@ -354,7 +376,10 @@ static FogFunc gfx_fogMode = -1;
|
|||
|
||||
void Gfx_SetFog(cc_bool enabled) {
|
||||
gfx_fogEnabled = enabled;
|
||||
gl_Toggle(GL_FOG);
|
||||
if (FOG_ENABLED == enabled) return;
|
||||
|
||||
FOG_ENABLED = enabled;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
}
|
||||
|
||||
void Gfx_SetFogCol(PackedCol color) {
|
||||
|
@ -503,11 +528,8 @@ void Gfx_SetVertexFormat(VertexFormat fmt) {
|
|||
gfx_format = fmt;
|
||||
gfx_stride = strideSizes[fmt];
|
||||
|
||||
if (fmt == VERTEX_FORMAT_TEXTURED) {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
} else {
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
TEXTURES_ENABLED = fmt == VERTEX_FORMAT_TEXTURED;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
}
|
||||
|
||||
void Gfx_DrawVb_Lines(int verticesCount) {
|
||||
|
@ -549,9 +571,8 @@ cc_result Gfx_TakeScreenshot(struct Stream* output) {
|
|||
}
|
||||
|
||||
void Gfx_GetApiInfo(cc_string* info) {
|
||||
GLint freeMem, usedMem;
|
||||
glGetIntegerv(GL_FREE_TEXTURE_MEMORY_KOS, &freeMem);
|
||||
glGetIntegerv(GL_USED_TEXTURE_MEMORY_KOS, &usedMem);
|
||||
GLint freeMem = _glFreeTextureMemory();
|
||||
GLint usedMem = _glUsedTextureMemory();
|
||||
|
||||
float freeMemMB = freeMem / (1024.0 * 1024.0);
|
||||
float usedMemMB = usedMem / (1024.0 * 1024.0);
|
||||
|
@ -592,10 +613,11 @@ extern float VP_COL_Y_PLUS_HHEIGHT, VP_TEX_Y_PLUS_HHEIGHT;
|
|||
|
||||
void Gfx_SetViewport(int x, int y, int w, int h) {
|
||||
if (x == 0 && y == 0 && w == Game.Width && h == Game.Height) {
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
SCISSOR_TEST_ENABLED = GL_FALSE;
|
||||
} else {
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
SCISSOR_TEST_ENABLED = GL_TRUE;
|
||||
}
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
|
||||
glViewport(x, y, w, h);
|
||||
glScissor (x, y, w, h);
|
||||
|
|
|
@ -543,7 +543,7 @@ static void DrawTriangle(Vector4 v0, Vector4 v1, Vector4 v2, struct VertexTextur
|
|||
*dw++ = xyz.xyz;
|
||||
}
|
||||
dw++; // one more to even out number of doublewords
|
||||
q = dw;
|
||||
q = (qword_t*)dw;
|
||||
}
|
||||
|
||||
static void DrawTriangles(int verticesCount, int startVertex) {
|
||||
|
|
76
third_party/gldc/gldc.h
vendored
76
third_party/gldc/gldc.h
vendored
|
@ -29,26 +29,6 @@ __BEGIN_DECLS
|
|||
|
||||
/* Scissor box */
|
||||
#define GL_SCISSOR_TEST 0x0008 /* capability bit */
|
||||
#define GL_SCISSOR_BOX 0x0C10
|
||||
|
||||
/* Depth buffer */
|
||||
#define GL_NEVER 0x0200
|
||||
#define GL_LESS 0x0201
|
||||
#define GL_EQUAL 0x0202
|
||||
#define GL_LEQUAL 0x0203
|
||||
#define GL_GREATER 0x0204
|
||||
#define GL_NOTEQUAL 0x0205
|
||||
#define GL_GEQUAL 0x0206
|
||||
#define GL_ALWAYS 0x0207
|
||||
#define GL_DEPTH_TEST 0x0B71
|
||||
#define GL_DEPTH_FUNC 0x0B74
|
||||
#define GL_DEPTH_WRITEMASK 0x0B72
|
||||
|
||||
/* Blending */
|
||||
#define GL_BLEND 0x0BE2 /* capability bit */
|
||||
|
||||
/* Misc texture constants */
|
||||
#define GL_TEXTURE_2D 0x0001 /* capability bit */
|
||||
|
||||
/* Texture Environment */
|
||||
#define GL_TEXTURE_ENV_MODE 0x2200
|
||||
|
@ -60,13 +40,6 @@ __BEGIN_DECLS
|
|||
#define GL_NEAREST 0x2600
|
||||
#define GL_LINEAR 0x2601
|
||||
|
||||
/* Fog */
|
||||
#define GL_FOG 0x0004 /* capability bit */
|
||||
|
||||
#define GL_FRONT_AND_BACK 0x0408
|
||||
#define GL_FRONT 0x0404
|
||||
#define GL_BACK 0x0405
|
||||
|
||||
#define GL_SHADE_MODEL 0x0b54
|
||||
#define GL_FLAT 0x1d00
|
||||
#define GL_SMOOTH 0x1d01
|
||||
|
@ -93,8 +66,6 @@ __BEGIN_DECLS
|
|||
|
||||
#define GL_RGBA 0x1908
|
||||
|
||||
#define GL_CULL_FACE 0x0B44
|
||||
|
||||
#define GLbyte char
|
||||
#define GLshort short
|
||||
#define GLint int
|
||||
|
@ -105,50 +76,19 @@ __BEGIN_DECLS
|
|||
#define GLenum unsigned int
|
||||
#define GLsizei unsigned int
|
||||
#define GLclampf float
|
||||
#define GLclampd float
|
||||
#define GLubyte unsigned char
|
||||
#define GLboolean unsigned char
|
||||
#define GL_FALSE 0
|
||||
#define GL_TRUE 1
|
||||
|
||||
/* Stubs for portability */
|
||||
#define GL_ALPHA_TEST 0x0BC0
|
||||
|
||||
#define GLAPI extern
|
||||
#define APIENTRY
|
||||
|
||||
/* Start Submission of Primitive Data */
|
||||
/* Currently Supported Primitive Types:
|
||||
-GL_POINTS ( does NOT work with glDrawArrays )( ZClipping NOT supported )
|
||||
-GL_TRIANGLES ( works with glDrawArrays )( ZClipping supported )
|
||||
-GL_TRIANLGLE_STRIP ( works with glDrawArrays )( ZClipping supported )
|
||||
-GL_QUADS ( works with glDrawArrays )( ZClipping supported )
|
||||
**/
|
||||
|
||||
/* Enable / Disable Capability */
|
||||
/* Currently Supported Capabilities:
|
||||
GL_TEXTURE_2D
|
||||
GL_BLEND
|
||||
GL_DEPTH_TEST
|
||||
GL_LIGHTING
|
||||
GL_SCISSOR_TEST
|
||||
GL_FOG
|
||||
GL_CULL_FACE
|
||||
GL_KOS_NEARZ_CLIPPING
|
||||
GL_KOS_TEXTURE_MATRIX
|
||||
*/
|
||||
GLAPI void glEnable(GLenum cap);
|
||||
GLAPI void glDisable(GLenum cap);
|
||||
|
||||
/* Clear Caps */
|
||||
GLAPI void glClear(GLuint mode);
|
||||
|
||||
/* Depth Testing */
|
||||
GLAPI void glClearDepth(GLfloat depth);
|
||||
GLAPI void glDepthMask(GLboolean flag);
|
||||
GLAPI void glDepthFunc(GLenum func);
|
||||
GLAPI void glDepthRange(GLclampf n, GLclampf f);
|
||||
GLAPI void glDepthRangef(GLclampf n, GLclampf f);
|
||||
|
||||
/* Shading - Flat or Goraud */
|
||||
GLAPI void glShadeModel(GLenum mode);
|
||||
|
@ -178,22 +118,10 @@ GLAPI void gldcBindTexture(GLuint texture);
|
|||
GLAPI int gldcAllocTexture(GLsizei w, GLsizei h, GLenum format, GLenum type);
|
||||
GLAPI void gldcGetTexture(GLvoid** data, GLsizei* width, GLsizei* height);
|
||||
|
||||
|
||||
/* GL Array API - Only GL_TRIANGLES, GL_TRIANGLE_STRIP, and GL_QUADS are supported */
|
||||
GLAPI void gldcVertexPointer(GLsizei stride, const GLvoid *pointer);
|
||||
|
||||
/* Array Data Submission */
|
||||
GLAPI void glDrawArrays(GLenum mode, GLint first, GLsizei count);
|
||||
|
||||
/* Transformation / Matrix Functions */
|
||||
|
||||
GLAPI void glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
|
||||
GLAPI void glScissor(GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
|
||||
/* glGet Functions */
|
||||
GLAPI void glGetIntegerv(GLenum pname, GLint *params);
|
||||
|
||||
GLAPI void glAlphaFunc(GLenum func, GLclampf ref);
|
||||
|
||||
|
||||
|
@ -226,10 +154,6 @@ typedef struct {
|
|||
/* Memory allocation extension (GL_KOS_texture_memory_management) */
|
||||
GLAPI void glDefragmentTextureMemory_KOS(void);
|
||||
|
||||
#define GL_FREE_TEXTURE_MEMORY_KOS 0xEF3D
|
||||
#define GL_USED_TEXTURE_MEMORY_KOS 0xEF3E
|
||||
#define GL_FREE_CONTIGUOUS_TEXTURE_MEMORY_KOS 0xEF3F
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !__GL_GL_H */
|
112
third_party/gldc/src/state.c
vendored
112
third_party/gldc/src/state.c
vendored
|
@ -39,109 +39,12 @@ void _glInitContext() {
|
|||
scissor_rect.height = vid_mode->height;
|
||||
}
|
||||
|
||||
GLAPI void APIENTRY glEnable(GLenum cap) {
|
||||
switch(cap) {
|
||||
case GL_TEXTURE_2D:
|
||||
if(TEXTURES_ENABLED != GL_TRUE) {
|
||||
TEXTURES_ENABLED = GL_TRUE;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
}
|
||||
break;
|
||||
case GL_CULL_FACE: {
|
||||
CULLING_ENABLED = GL_TRUE;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
} break;
|
||||
case GL_DEPTH_TEST: {
|
||||
if(DEPTH_TEST_ENABLED != GL_TRUE) {
|
||||
DEPTH_TEST_ENABLED = GL_TRUE;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
}
|
||||
} break;
|
||||
case GL_BLEND: {
|
||||
if(BLEND_ENABLED != GL_TRUE) {
|
||||
BLEND_ENABLED = GL_TRUE;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
}
|
||||
} break;
|
||||
case GL_SCISSOR_TEST: {
|
||||
SCISSOR_TEST_ENABLED = GL_TRUE;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
} break;
|
||||
case GL_FOG:
|
||||
if(FOG_ENABLED != GL_TRUE) {
|
||||
FOG_ENABLED = GL_TRUE;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
}
|
||||
break;
|
||||
case GL_ALPHA_TEST: {
|
||||
if(ALPHA_TEST_ENABLED != GL_TRUE) {
|
||||
ALPHA_TEST_ENABLED = GL_TRUE;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GLAPI void APIENTRY glDisable(GLenum cap) {
|
||||
switch(cap) {
|
||||
case GL_TEXTURE_2D:
|
||||
if(TEXTURES_ENABLED != GL_FALSE) {
|
||||
TEXTURES_ENABLED = GL_FALSE;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
}
|
||||
break;
|
||||
case GL_CULL_FACE: {
|
||||
CULLING_ENABLED = GL_FALSE;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
} break;
|
||||
case GL_DEPTH_TEST: {
|
||||
if(DEPTH_TEST_ENABLED != GL_FALSE) {
|
||||
DEPTH_TEST_ENABLED = GL_FALSE;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
}
|
||||
} break;
|
||||
case GL_BLEND: {
|
||||
if(BLEND_ENABLED != GL_FALSE) {
|
||||
BLEND_ENABLED = GL_FALSE;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
}
|
||||
} break;
|
||||
case GL_SCISSOR_TEST: {
|
||||
SCISSOR_TEST_ENABLED = GL_FALSE;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
} break;
|
||||
case GL_FOG:
|
||||
if(FOG_ENABLED != GL_FALSE) {
|
||||
FOG_ENABLED = GL_FALSE;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
}
|
||||
break;
|
||||
case GL_ALPHA_TEST: {
|
||||
if(ALPHA_TEST_ENABLED != GL_FALSE) {
|
||||
ALPHA_TEST_ENABLED = GL_FALSE;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Depth Testing */
|
||||
GLAPI void APIENTRY glClearDepth(GLfloat depth) {
|
||||
/* We reverse because using invW means that farther Z == lower number */
|
||||
pvr_set_zclip(MIN(1.0f - depth, PVR_MIN_Z));
|
||||
}
|
||||
|
||||
GLAPI void APIENTRY glDepthMask(GLboolean flag) {
|
||||
if(DEPTH_MASK_ENABLED != flag) {
|
||||
DEPTH_MASK_ENABLED = flag;
|
||||
STATE_DIRTY = GL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Shading - Flat or Goraud */
|
||||
GLAPI void APIENTRY glShadeModel(GLenum mode) {
|
||||
SHADE_MODEL = mode;
|
||||
|
@ -238,21 +141,6 @@ void _glApplyScissor(bool force) {
|
|||
scissor_rect.applied = true;
|
||||
}
|
||||
|
||||
void APIENTRY glGetIntegerv(GLenum pname, GLint *params) {
|
||||
switch(pname) {
|
||||
case GL_FREE_TEXTURE_MEMORY_KOS:
|
||||
*params = _glFreeTextureMemory();
|
||||
break;
|
||||
case GL_USED_TEXTURE_MEMORY_KOS:
|
||||
*params = _glUsedTextureMemory();
|
||||
break;
|
||||
case GL_FREE_CONTIGUOUS_TEXTURE_MEMORY_KOS:
|
||||
*params = _glFreeContiguousTextureMemory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Viewport VIEWPORT;
|
||||
|
||||
/* Set the GL viewport */
|
||||
|
|
Loading…
Reference in a new issue