Skip to content

Commit 6715079

Browse files
PS1/Saturn: Water/Bedrock renders
1 parent 576faba commit 6715079

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

src/EnvRenderer.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@
2222

2323
cc_bool EnvRenderer_Legacy, EnvRenderer_Minimal;
2424

25-
#define EnvRenderer_AxisSize() (EnvRenderer_Legacy ? 128 : 2048)
25+
static CC_INLINE int EnvRenderer_AxisSize(void) {
26+
if (Gfx.Limitations & GFX_LIMIT_MAX_VERTEX_SIZE) return 8;
27+
28+
return EnvRenderer_Legacy ? 128 : 2048;
29+
}
30+
2631
/* Returns the number of vertices needed to subdivide a quad */
2732
static int CalcNumVertices(int axis1Len, int axis2Len) {
2833
int axisSize = EnvRenderer_AxisSize();
@@ -189,7 +194,7 @@ static CC_NOINLINE void BuildClouds(void) {
189194

190195
void EnvRenderer_RenderClouds(void) {
191196
float offset;
192-
if (Env.CloudsHeight < -2000) return;
197+
if (Env.CloudsHeight < -2000 || !clouds_tex) return;
193198

194199
if (!clouds_vb) {
195200
BuildClouds();

src/Game.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,10 @@ extern cc_string Game_Mppass;
3737
#define Game_NumStates 1
3838
#endif
3939

40-
#if defined CC_BUILD_N64
40+
#if defined CC_BUILD_N64 || defined CC_BUILD_PS1 || defined CC_BUILD_SATURN
4141
#define DEFAULT_VIEWDIST 20
42-
#elif defined CC_BUILD_NDS || defined CC_BUILD_SATURN
42+
#elif defined CC_BUILD_NDS
4343
#define DEFAULT_VIEWDIST 192
44-
#elif defined CC_BUILD_PS1
45-
#define DEFAULT_VIEWDIST 64
4644
#else
4745
#define DEFAULT_VIEWDIST 512
4846
#endif

src/Graphics.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ CC_VAR extern struct _GfxData {
6969
/* Whether the graphics backend supports non power of two textures */
7070
cc_bool SupportsNonPowTwoTextures;
7171
/* Limitations of the graphics backend, see GFX_LIMIT values */
72-
cc_bool Limitations;
72+
cc_uint8 Limitations;
7373
/* Type of the backend (e.g. OpenGL, Direct3D 9, etc)*/
7474
cc_uint8 BackendType;
7575
cc_bool __pad;
@@ -91,6 +91,8 @@ CC_VAR extern struct _GfxData {
9191
/* Whether the graphics backend requires very large quads to be broken */
9292
/* up into smaller quads, to reduce fog interpolation artifacts */
9393
#define GFX_LIMIT_VERTEX_ONLY_FOG 0x02
94+
/* Whether the graphics backend only supports a small maximum quad size */
95+
#define GFX_LIMIT_MAX_VERTEX_SIZE 0x04
9496

9597
extern const cc_string Gfx_LowPerfMessage;
9698

src/Graphics_PS1.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ static void BuildContext(RenderBuffer* buf) {
106106
prim->area_code[0] = GP0_CMD_DRAW_MIN_PACK(buf->clipX, buf->clipY);
107107
prim->area_code[1] = GP0_CMD_DRAW_MAX_PACK(buf->clipX + buf->clipW - 1, buf->clipY + buf->clipH - 1);
108108
prim->ofst_code[0] = GP0_CMD_DRAW_OFFSET_PACK(buf->clipX + buf->ofstX, buf->clipY + buf->ofstY);
109+
// VRAM clear command
109110
prim->fill_code[0] = PACK_RGBC(0, 0, 0, GP0_CMD_MEM_FILL);
110111
prim->fill_code[1] = GP0_CMD_FILL_XY(buf->clipX, buf->clipY);
111112
prim->fill_code[2] = GP0_CMD_FILL_WH(buf->clipW, buf->clipH);
@@ -173,6 +174,7 @@ void Gfx_Create(void) {
173174
Gfx.MaxTexWidth = 128;
174175
Gfx.MaxTexHeight = 256;
175176
Gfx.Created = true;
177+
Gfx.Limitations = GFX_LIMIT_MAX_VERTEX_SIZE;
176178

177179
Gfx_RestoreState();
178180
SetupContexts(Window_Main.Width, Window_Main.Height);

src/Graphics_Saturn.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#define SCREEN_WIDTH 320
1111
#define SCREEN_HEIGHT 224
12-
#define CMDS_COUNT 400
12+
#define CMDS_COUNT 450
1313
#define HDR_CMDS 2
1414

1515
static struct {
@@ -120,7 +120,7 @@ void Gfx_Create(void) {
120120
Gfx.MaxTexWidth = 128;
121121
Gfx.MaxTexHeight = 16; // 128
122122
Gfx.Created = true;
123-
Gfx.Limitations = GFX_LIMIT_NO_UV_SUPPORT;
123+
Gfx.Limitations = GFX_LIMIT_NO_UV_SUPPORT | GFX_LIMIT_MAX_VERTEX_SIZE;
124124
}
125125

126126
void Gfx_Free(void) {

0 commit comments

Comments
 (0)