Overv / MineAssemble

A tiny bootable Minecraft clone written partly in x86 assembly
MIT License
1.04k stars 68 forks source link

Menu Loop #4

Open ghost opened 11 years ago

ghost commented 11 years ago

When I press Enter to start playing, it loops back to the menu.

asido commented 11 years ago

I am quite sure that an issue here is with SSE 16 byte alignment. I was able to reproduce the issue and building with SSE disabled solved it. Specifically the restart is caused by function 'uint8_t raytrace(vec3 pos, vec3 dir, hit* info)' in src/reference.c:

    int x = (int) pos.x;
    int y = (int) pos.y;
    int z = (int) pos.z;

GCC generates SSE instructions here which trash all registers.

Here is the patch to Makefile:

diff --git a/Makefile b/Makefile
index 9c47644..e708464 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,7 @@ CFLAGS:=-std=c99 -MMD
 CFLAGS+=-m32
 CFLAGS+=-g -ggdb
 CFLAGS+=-O3 -ffast-math
+CFLAGS+=-mno-sse
 CFLAGS+=-ffreestanding -nostdlib -nostdinc -fno-builtin -nostartfiles -nodefaultlibs -fno-exceptions -fno-stack-protector -static -fno-pic

 LDFLAGS=-m elf_i386
Overv commented 11 years ago

This might just explain why the raytracing function doesn't work on my laptop at all. Nice find!

KoolenDasheppi commented 8 years ago

Could you add it to the prebuilt ISO? I don't have a Linux machine, so I don't think I can build it...

Overv commented 8 years ago

Unfortunately I don't have a Linux machine available right now either.

KoolenDasheppi commented 8 years ago

I'm gonna try it with Cygwin, I will get back to you when I am done. (If it even works)