Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions src/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,9 @@ void *mem_mark(void) {
}

// mem_bump is guaranteed to return a pointer aligned to 8 bytes.
// It is not guaranteed to return a pointer that immediately follows the
// previous one it handed out; use mem_bump_unaligned for that.

void *mem_bump(uint32_t size) {
// In addition to aligning the size itself, we must also align
// bump_len since a previous direct call to mem_bump_unaligned may
// have destroyed its alignment.
bump_len = round_up_to_word(bump_len);
size = round_up_to_word(size);
return mem_bump_unaligned(size);
}

// The only time this ever gets called is for loading primitives and objects.
// Ideally we would never call it at all, given the risk of bus errors.

void *mem_bump_unaligned(uint32_t size) {
error_if(bump_len + temp_len + size >= MEM_HUNK_BYTES, "Failed to allocate %d bytes in hunk mem", size);
uint8_t *p = &hunk[bump_len];
bump_len += size;
Expand Down
1 change: 0 additions & 1 deletion src/mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#define MEM_HUNK_BYTES (16 * 1024 * 1024)

void *mem_bump(uint32_t size);
void *mem_bump_unaligned(uint32_t size);
void *mem_mark(void);
void mem_reset(void *p);

Expand Down
26 changes: 12 additions & 14 deletions src/wipeout/droid.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ void droid_init(droid_t *droid, ship_t *ship) {
void droid_draw(droid_t *droid) {
droid->cycle_timer += system_tick() * M_PI * 2;

Prm prm = {.primitive = droid_model->primitives};
int rf = sinf(droid->cycle_timer) * 127 + 128;
int gf = sinf(droid->cycle_timer + 0.2) * 127 + 128;
int bf = sinf(droid->cycle_timer * 0.5 + 0.1) * 127 + 128;

for (int i = 0; i < 11; i++) {
primitive_t *prm = &droid_model->primitives[i];
rgba_t color;

if (i < 2) {
Expand All @@ -67,21 +67,19 @@ void droid_draw(droid_t *droid) {
color = rgba(rf, 40, 40, 0xFF);
}

switch (prm.f3->type) {
case PRM_TYPE_GT3:
prm.gt3->color[0] =
prm.gt3->color[1] =
prm.gt3->color[2] = color;
prm.gt3++;
switch (prm->type) {
case PRM_TYPE_TRI:
for (int j = 0; j < 3; j++) {
prm->u.tri.v[j].color = color;
}
break;

case PRM_TYPE_GT4:
prm.gt4->color[0] =
prm.gt4->color[1] =
prm.gt4->color[2] = color;
prm.gt4->color[3] = rgba(40,40,40,0xFF);
prm.gt4++;
case PRM_TYPE_QUAD:
for (int j = 0; j < 4; j++) {
prm->u.quad.v[j].color = color;
}
break;
default:
die("Can't happen: Expected primitive type %x or %x, got %x", PRM_TYPE_TRI, PRM_TYPE_QUAD, prm->type);
}
}

Expand Down
Loading