Make the entire misc library compile natively
parent
7126c6dab0
commit
5c060d9f8e
38
Makefile
38
Makefile
|
@ -12,7 +12,8 @@ MAPSRC=maps
|
||||||
MAPBIN=data/maps
|
MAPBIN=data/maps
|
||||||
FOLDERS=$(CODEDEFS) $(BIN) $(IR) $(MAPBIN)
|
FOLDERS=$(CODEDEFS) $(BIN) $(IR) $(MAPBIN)
|
||||||
|
|
||||||
CFLAGS += -O2 -g -lm
|
CFLAGS += -O2 -g -c
|
||||||
|
LFLAGS += -O2 -g -lm
|
||||||
|
|
||||||
GDCC_TARGET=--bc-target=Doominati
|
GDCC_TARGET=--bc-target=Doominati
|
||||||
GDCC_LFLAGS += $(GDCC_TARGET)
|
GDCC_LFLAGS += $(GDCC_TARGET)
|
||||||
|
@ -34,15 +35,31 @@ MISC_SOURCES=$(wildcard $(SRC)/m_*.c)
|
||||||
MISC_HEADERS=$(wildcard $(SRC)/m_*.h)
|
MISC_HEADERS=$(wildcard $(SRC)/m_*.h)
|
||||||
MISC_OUTPUTS=$(MISC_SOURCES:$(SRC)/m_%.c=$(IR)/m_%.ir)
|
MISC_OUTPUTS=$(MISC_SOURCES:$(SRC)/m_%.c=$(IR)/m_%.ir)
|
||||||
MISC_BINARYS=$(CODEDEFS)/eikyo-misc.bin
|
MISC_BINARYS=$(CODEDEFS)/eikyo-misc.bin
|
||||||
|
MISC_LIBOUTS=$(MISC_SOURCES:$(SRC)/%.c=$(BIN)/%.o)
|
||||||
|
MISC_LIBRARY=$(BIN)/eikyo-misc.o
|
||||||
|
|
||||||
RNDR_SOURCES=$(wildcard $(SRC)/r_*.c)
|
RNDR_SOURCES=$(wildcard $(SRC)/r_*.c)
|
||||||
RNDR_HEADERS=$(wildcard $(SRC)/r_*.h)
|
RNDR_HEADERS=$(wildcard $(SRC)/r_*.h)
|
||||||
RNDR_OUTPUTS=$(RNDR_SOURCES:$(SRC)/r_%.c=$(IR)/r_%.ir)
|
RNDR_OUTPUTS=$(RNDR_SOURCES:$(SRC)/r_%.c=$(IR)/r_%.ir)
|
||||||
RNDR_BINARYS=$(CODEDEFS)/eikyo-render.bin
|
RNDR_BINARYS=$(CODEDEFS)/eikyo-render.bin
|
||||||
|
|
||||||
|
GOL5_SOURCES=$(SRC)/golan5.c
|
||||||
|
GOL5_OUTPUTS=$(GOL5_SOURCES:$(SRC)/%.c=$(BIN)/%.o)
|
||||||
|
GOL5_BINARYS=$(BIN)/golan5
|
||||||
|
|
||||||
|
LIBC_OUTPUTS=$(IR)/libc.ir $(IR)/libGDCC.ir
|
||||||
|
LIBC_BINARYS=$(CODEDEFS)/stdlib.bin
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
|
||||||
all: $(FOLDERS) $(CODEDEFS)/stdlib.bin $(GAME_BINARYS) $(MAIN_BINARYS) $(MISC_BINARYS) $(RNDR_BINARYS) $(MAPS_OUTPUTS)
|
all: $(FOLDERS) $(LIBC_BINARYS) $(GAME_BINARYS) $(MAIN_BINARYS) $(MISC_BINARYS) $(RNDR_BINARYS) $(MAPS_OUTPUTS)
|
||||||
|
|
||||||
|
$(GOL5_BINARYS): $(GOL5_OUTPUTS) $(MISC_LIBOUTS)
|
||||||
|
$(GAME_BINARYS): $(GAME_OUTPUTS)
|
||||||
|
$(MAIN_BINARYS): $(MAIN_OUTPUTS)
|
||||||
|
$(MISC_BINARYS): $(MISC_OUTPUTS)
|
||||||
|
$(RNDR_BINARYS): $(RNDR_OUTPUTS)
|
||||||
|
$(LIBC_BINARYS): $(LIBC_OUTPUTS)
|
||||||
|
|
||||||
$(FOLDERS):
|
$(FOLDERS):
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
@ -50,25 +67,22 @@ $(FOLDERS):
|
||||||
clean:
|
clean:
|
||||||
rm -f $(addsuffix /*,$(FOLDERS))
|
rm -f $(addsuffix /*,$(FOLDERS))
|
||||||
|
|
||||||
$(MAPBIN)/%.gmf0: $(MAPSRC)/%.gmf9 $(BIN)/golan5
|
$(MAPBIN)/%.gmf0: $(MAPSRC)/%.gmf9 $(GOL5_BINARYS)
|
||||||
$(BIN)/golan5 $< $@
|
$(GOL5_BINARYS) $< $@
|
||||||
|
|
||||||
$(BIN)/golan5: $(SRC)/golan5.c $(SRC)/m_binio.c $(SRC)/m_token.c $(SRC)/m_tokbuf.c
|
|
||||||
$(BIN)/%:
|
$(BIN)/%:
|
||||||
$(CC) $(CFLAGS) $(LFLAGS) -o $@ $^
|
$(CC) $(LFLAGS) -o $@ $^
|
||||||
|
|
||||||
|
$(BIN)/%.o: $(SRC)/%.c
|
||||||
|
$(CC) $(CFLAGS) -o $@ $<
|
||||||
|
|
||||||
$(CODEDEFS)/stdlib.bin: $(IR)/libc.ir $(IR)/libGDCC.ir
|
|
||||||
$(GAME_BINARYS): $(GAME_OUTPUTS)
|
|
||||||
$(MAIN_BINARYS): $(MAIN_OUTPUTS)
|
|
||||||
$(MISC_BINARYS): $(MISC_OUTPUTS)
|
|
||||||
$(RNDR_BINARYS): $(RNDR_OUTPUTS)
|
|
||||||
$(CODEDEFS)/%.bin:
|
$(CODEDEFS)/%.bin:
|
||||||
$(GDCC_LD) $(GDCC_LFLAGS) -o $@ $^
|
$(GDCC_LD) $(GDCC_LFLAGS) -o $@ $^
|
||||||
|
|
||||||
$(IR)/%.ir: $(SRC)/%.c $(GAME_HEADERS) $(MISC_HEADERS) $(RNDR_HEADERS)
|
$(IR)/%.ir: $(SRC)/%.c $(GAME_HEADERS) $(MISC_HEADERS) $(RNDR_HEADERS)
|
||||||
$(GDCC_CC) $(GDCC_CFLAGS) -o $@ $<
|
$(GDCC_CC) $(GDCC_CFLAGS) -o $@ $<
|
||||||
|
|
||||||
$(IR)/libc.ir $(IR)/libGDCC.ir:
|
$(LIBC_OUTPUTS):
|
||||||
$(GDCC_MAKELIB) $(GDCC_CFLAGS) -o $@ $(basename $(@F))
|
$(GDCC_MAKELIB) $(GDCC_CFLAGS) -o $@ $(basename $(@F))
|
||||||
|
|
||||||
## EOF
|
## EOF
|
||||||
|
|
|
@ -20,13 +20,44 @@ void M_IO_WriteLE4u(FILE *fp, mword v)
|
||||||
//
|
//
|
||||||
// M_IO_WriteLE4k
|
// M_IO_WriteLE4k
|
||||||
//
|
//
|
||||||
void M_IO_WriteLE4k(FILE *fp, float v)
|
void M_IO_WriteLE4k(FILE *fp, fixed v)
|
||||||
{
|
{
|
||||||
|
#if __GDCC__
|
||||||
|
M_IO_WriteLE4u(fp, *(mword *)&v);
|
||||||
|
#else
|
||||||
float a = fabsf(v);
|
float a = fabsf(v);
|
||||||
mword k = ((mword)a << 7) & 0x7FFFFF80;
|
mword k = ((mword)a << 7) & 0x7FFFFF80;
|
||||||
k |= (mword)(fmod(a, 1) * 0x7F) & 0x7F;
|
k |= (mword)(fmod(a, 1) * 0x7F) & 0x7F;
|
||||||
if(v < 0) k |= 0x80000000;
|
if(v < 0) k |= 0x80000000;
|
||||||
M_IO_WriteLE4u(fp, k);
|
M_IO_WriteLE4u(fp, k);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// M_IO_ReadLE4u
|
||||||
|
//
|
||||||
|
mword M_IO_ReadLE4u(FILE *fp)
|
||||||
|
{
|
||||||
|
mbyte data[4];
|
||||||
|
fread(data, 1, 4, fp);
|
||||||
|
return ((mword)data[0] << 0) | ((mword)data[1] << 8) |
|
||||||
|
((mword)data[2] << 16) | ((mword)data[3] << 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// M_IO_ReadLE4k
|
||||||
|
//
|
||||||
|
fixed M_IO_ReadLE4k(FILE *fp)
|
||||||
|
{
|
||||||
|
#if __GDCC__
|
||||||
|
return (union {mword u; fixed k;}){M_IO_ReadLE4u(fp)}.k;
|
||||||
|
#else
|
||||||
|
mword u = M_IO_ReadLE4u(fp);
|
||||||
|
float res = (u & 0x7FFFFF80) >> 7;
|
||||||
|
res += (u & 0x7F) / 127.f;
|
||||||
|
if(u & 0x80000000) res *= -1;
|
||||||
|
return res;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
// Extern Functions ----------------------------------------------------------|
|
// Extern Functions ----------------------------------------------------------|
|
||||||
|
|
||||||
void M_IO_WriteLE4u(FILE *fp, mword v);
|
void M_IO_WriteLE4u(FILE *fp, mword v);
|
||||||
void M_IO_WriteLE4k(FILE *fp, float v);
|
void M_IO_WriteLE4k(FILE *fp, fixed v);
|
||||||
|
mword M_IO_ReadLE4u(FILE *fp);
|
||||||
|
fixed M_IO_ReadLE4k(FILE *fp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
#include "m_str.h"
|
#include "m_str.h"
|
||||||
#include "m_types.h"
|
#include "m_types.h"
|
||||||
|
|
||||||
|
#if __GDCC__
|
||||||
#include <Doominati.h>
|
#include <Doominati.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
@ -15,7 +17,9 @@
|
||||||
//
|
//
|
||||||
char *M_StrFmt(char const *fmt, ...)
|
char *M_StrFmt(char const *fmt, ...)
|
||||||
{
|
{
|
||||||
|
#if __GDCC__
|
||||||
[[__no_init]]
|
[[__no_init]]
|
||||||
|
#endif
|
||||||
static char bufs[3][0x2800];
|
static char bufs[3][0x2800];
|
||||||
static int idx;
|
static int idx;
|
||||||
|
|
||||||
|
@ -41,6 +45,7 @@ mword M_StrHash(char const *s)
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __GDCC__
|
||||||
//
|
//
|
||||||
// M_StrCreate
|
// M_StrCreate
|
||||||
//
|
//
|
||||||
|
@ -48,5 +53,6 @@ __str M_StrCreate(char const *s)
|
||||||
{
|
{
|
||||||
return DGE_String_Create(s, strlen(s));
|
return DGE_String_Create(s, strlen(s));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
|
|
||||||
char *M_StrFmt(char const *fmt, ...);
|
char *M_StrFmt(char const *fmt, ...);
|
||||||
mword M_StrHash(char const *s);
|
mword M_StrHash(char const *s);
|
||||||
|
|
||||||
|
#if __GDCC__
|
||||||
__str M_StrCreate(char const *s);
|
__str M_StrCreate(char const *s);
|
||||||
char *M_StrDup(char const *s);
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -15,27 +15,33 @@
|
||||||
|
|
||||||
// Types ---------------------------------------------------------------------|
|
// Types ---------------------------------------------------------------------|
|
||||||
|
|
||||||
|
typedef size_t msize; // Machine Size
|
||||||
|
typedef ptrdiff_t mpdif; // Machine Pointer Difference
|
||||||
|
typedef uint8_t mbyte; // Machine Byte
|
||||||
|
typedef uint16_t hword; // Half Word
|
||||||
|
typedef uint32_t mword; // Machine Word
|
||||||
|
typedef uint64_t dword; // Double Word
|
||||||
#if __GDCC__
|
#if __GDCC__
|
||||||
typedef unsigned long fract ulfra;
|
typedef uint96_t tword; // Triple Word
|
||||||
typedef short accum fixed; // Fixed
|
|
||||||
typedef long fract lfrac; // Long Fractional
|
|
||||||
#endif
|
#endif
|
||||||
typedef size_t msize; // Machine Size
|
typedef int8_t chara; // Character
|
||||||
typedef ptrdiff_t mpdif; // Machine Pointer Difference
|
typedef int16_t int16; // Integer (16 bits)
|
||||||
typedef uint8_t mbyte; // Machine Byte
|
typedef int32_t integ; // Integer (Machine)
|
||||||
typedef uint16_t hword; // Half Word
|
typedef int64_t int64; // Integer (64 bits)
|
||||||
typedef uint32_t mword; // Machine Word
|
|
||||||
typedef uint64_t dword; // Double Word
|
|
||||||
#if __GDCC__
|
#if __GDCC__
|
||||||
typedef uint96_t tword; // Triple Word
|
typedef int96_t int96; // Integer (96 bits)
|
||||||
#endif
|
#endif
|
||||||
typedef int8_t chara; // Character
|
|
||||||
typedef int16_t int16; // Integer (16 bits)
|
|
||||||
typedef int32_t integ; // Integer (Machine)
|
|
||||||
typedef int64_t int64; // Integer (64 bits)
|
|
||||||
#if __GDCC__
|
#if __GDCC__
|
||||||
typedef int96_t int96; // Integer (96 bits)
|
typedef short accum fixed; // Fixed
|
||||||
|
typedef unsigned long fract ulfra; // Unsigned Long Fractional
|
||||||
|
typedef long fract lfrac; // Long Fractional
|
||||||
|
#else
|
||||||
|
typedef float fixed;
|
||||||
#endif
|
#endif
|
||||||
typedef unsigned M_texid; // Texture ID
|
|
||||||
|
typedef unsigned M_texid; // Texture ID
|
||||||
|
typedef unsigned M_shdid; // Shader ID
|
||||||
|
typedef unsigned M_fntid; // Font ID
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue