refactor, libc made optional
This commit is contained in:
+5
-5
@@ -1,26 +1,26 @@
|
||||
CC = clang
|
||||
# todo: Only link to libm on debug.
|
||||
CFLAGS = -Wall -std=c99 -g3 -O3
|
||||
CFLAGS = -Wall -std=c99 -g3 -O3 -flto=full
|
||||
DEPS = ../Common/lzw.h ../Common/mat.h ../Common/vec.h ../Common/fix.h ../Common/def.h ../Common/bits.h \
|
||||
../Common/gem.h \
|
||||
../Common/Timer/timer.h \
|
||||
./Display/display.h \
|
||||
./draw.h
|
||||
SRC = ../Common/lzw.c ../Common/fix.c ../Common/mat.c ./draw.c
|
||||
OBJ = ../Common/lzw.o ../Common/fix.o ../Common/mat.o ./draw.o
|
||||
LINUX = ./Main/linux.o ./amalgam.o Display/x11.o ../Common/Timer/unix.o
|
||||
LINUX = ./amalgam.c
|
||||
WASM = ./amalgam.c
|
||||
DOS = maindos.c Display/dos.c
|
||||
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
linux: CFLAGS += -msse2 -lm -lX11
|
||||
# TODO: Make it work with no stdlib.
|
||||
linux: CFLAGS += -msse2 -lm -lX11 # -nostdlib
|
||||
linux: $(LINUX) | $(SRC)
|
||||
$(CC) -o player $^ $(CFLAGS)
|
||||
|
||||
# Note: lld package might need to be downloaded.
|
||||
wasm: CFLAGS += --target=wasm32 -nostdlib -Wl,--no-entry
|
||||
wasm: CFLAGS += --target=wasm32 -nostdlib -Wl,--no-entry -msimd128
|
||||
wasm:
|
||||
$(CC) -o player.wasm $(WASM) $(CFLAGS)
|
||||
|
||||
|
||||
@@ -2,7 +2,17 @@
|
||||
Amalgamation file, compiling all in single unit.
|
||||
*/
|
||||
|
||||
#include "../Common/def.h"
|
||||
#include "../Common/fix.c"
|
||||
#include "../Common/lzw.c"
|
||||
#include "../Common/mat.c"
|
||||
#include "./draw.c"
|
||||
|
||||
#if COM_DEF_TARGET == COM_DEF_TARGET_LINUX
|
||||
#include "../Common/Std/libc.c"
|
||||
#include "../Common/Timer/posix.c"
|
||||
#include "./Display/x11.c"
|
||||
#include "./Main/linux.c"
|
||||
#elif COM_DEF_TARGET == COM_DEF_TARGET_WASM
|
||||
#include "../Common/Std/stub.c"
|
||||
#endif
|
||||
|
||||
+4
-4
@@ -6,14 +6,14 @@
|
||||
#if COM_DEF_TARGET == COM_DEF_TARGET_WASM
|
||||
uint8_t plr_draw_buffer[640 * 480 * 4];
|
||||
|
||||
__attribute__((export_name("plr_draw_get_pixel_buffer"))) uint8_t *
|
||||
plr_draw_get_pixel_buffer(void) {
|
||||
com_def_export_sym(
|
||||
"plr_draw_get_pixel_buffer") uint8_t *plr_draw_get_pixel_buffer(void) {
|
||||
return plr_draw_buffer;
|
||||
}
|
||||
#endif
|
||||
|
||||
__attribute__((export_name("plr_draw_screen"))) void
|
||||
plr_draw_screen(uint8_t *pixel_buffer) {
|
||||
com_def_export_sym("plr_draw_screen") void plr_draw_screen(
|
||||
uint8_t *pixel_buffer) {
|
||||
for (int y = 0; y < 480; y++) {
|
||||
for (int x = 0; x < 640; x++) {
|
||||
int pixel_index = (y * 640 + x) * 4;
|
||||
|
||||
Reference in New Issue
Block a user