Skip to content

Commit

Permalink
#368 fix stack overflow, fix transformRoom_c
Browse files Browse the repository at this point in the history
  • Loading branch information
XProger committed Nov 26, 2022
1 parent 3ab926d commit b60788e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/platform/gba/asm/flush.s
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Te .req index01
PN .req index23
sprites .req index01

SP_SIZE = (7 * VERTEX_SIZEOF) + 4
SP_SIZE = (8 * VERTEX_SIZEOF) + 4
SP_SPRITES = SP_SIZE - 4

.extern rasterize_c, drawPoly
Expand Down
27 changes: 14 additions & 13 deletions src/platform/gba/render.iwram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ void transformRoom_c(const RoomVertex* vertices, int32 count)
{
uint32 value = *(uint32*)(vertices++);

int32 vx = (0xFF & (value));
int32 vy = (0xFF & (value >> 8));
int32 vz = (0xFF & (value >> 16));
int32 vg = (0xFF & (value >> 24)) << 5;
int32 vx = (value & (0xFF)) << 8;
int32 vy = (value & (0xFF << 8));
int32 vz = (value & (0xFF << 16)) >> 8;
int32 vg = (value & (0xFF << 24)) >> (24 - 5);

const Matrix &m = matrixGet();
int32 x = DP43(m.e00, m.e01, m.e02, m.e03, vx, vy, vz);
Expand All @@ -177,17 +177,17 @@ void transformRoom_c(const RoomVertex* vertices, int32 count)

if (z <= VIEW_MIN_F) {
clip = CLIP_NEAR;
z = VIEW_MIN_F >> 8;
z = VIEW_MIN_F;
}

if (z >= VIEW_MAX_F >> 8) {
if (z >= VIEW_MAX_F) {
clip = CLIP_FAR;
z = VIEW_MAX_F >> 8;
z = VIEW_MAX_F;
}

x >>= FIXED_SHIFT - 8;
y >>= FIXED_SHIFT - 8;
z >>= FIXED_SHIFT - 8;
x >>= FIXED_SHIFT;
y >>= FIXED_SHIFT;
z >>= FIXED_SHIFT;

if (z > FOG_MIN)
{
Expand Down Expand Up @@ -231,9 +231,9 @@ void transformRoomUW_c(const RoomVertex* vertices, int32 count)
{
uint32 value = *(uint32*)(vertices++);

int32 vx = (value & (0xFF)) << 10;
int32 vx = (value & (0xFF)) << 8;
int32 vy = (value & (0xFF << 8));
int32 vz = (value & (0xFF << 16)) >> 6;
int32 vz = (value & (0xFF << 16)) >> 8;
int32 vg = (value & (0xFF << 24)) >> (24 - 5);

const Matrix &m = matrixGet();
Expand Down Expand Up @@ -590,7 +590,7 @@ void flush_c()

gFacesBase = gFaces;

VertexLink v[4 + 3];
VertexLink v[8];
VertexLink* q = v;
VertexLink* t = v + 4;
// quad
Expand All @@ -609,6 +609,7 @@ void flush_c()
t[1].next = 1;
t[2].prev = -1;
t[2].next = -2;
// t[3] dummy

PROFILE(CNT_FLUSH);

Expand Down

0 comments on commit b60788e

Please sign in to comment.