mirror of
https://gitlab.com/kholdfuzion/goldeneye_src
synced 2026-07-08 21:04:54 -04:00
Everybody loves a good yearly or so update
This commit is contained in:
+172
-88
@@ -21,11 +21,16 @@
|
||||
#define PLUS() +
|
||||
#define ZERO() 0
|
||||
#define ONE() 1
|
||||
|
||||
#define EXPAND(a) a
|
||||
#define EAT(x)
|
||||
#define STR(n) #n
|
||||
|
||||
#ifdef __sgi
|
||||
# define EXPAND(a) a
|
||||
# define EAT(x)
|
||||
#else
|
||||
# define EXPAND(...) __VA_ARGS__
|
||||
# define EAT(x, ...) __VA_ARGS__
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Force the pre-processor to expand the macro a large number of times. Usage:
|
||||
@@ -87,7 +92,11 @@
|
||||
#define EVAL8(a) EVAL4(EVAL2(EVAL1(a)))
|
||||
#define EVAL4(a) EVAL2(EVAL1(a))
|
||||
#define EVAL2(a) EVAL1(a)
|
||||
#define EVAL1(VA) IF_VA(EXPAND(DEFER(IS_PAREN)(VA)))(DEFER(EXPAND_ARGS_STACK)) VA
|
||||
#ifdef __sgi
|
||||
# define EVAL1(VA) IF_VA(EXPAND(DEFER(IS_PAREN)(VA)))(DEFER(EXPAND_ARGS_STACK)) VA
|
||||
#else
|
||||
# define EVAL1(...) __VA_ARGS__
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Causes a function-style macro to require an additional pass to be expanded.
|
||||
@@ -181,15 +190,29 @@
|
||||
#define CAT(a, b) PRIMITIVECAT(a, b)
|
||||
#define PRIMITIVECAT(a, b) a##b
|
||||
|
||||
/**
|
||||
* Get the first argument and ignore the rest.
|
||||
*/
|
||||
#define FIRST_PRE_VA(a) a
|
||||
#ifdef __sgi
|
||||
/**
|
||||
* Get the first argument and ignore the rest.
|
||||
*/
|
||||
#define FIRST_PRE_VA(a) a
|
||||
#else
|
||||
/**
|
||||
* Get the first argument and ignore the rest.
|
||||
*/
|
||||
# define FIRST_PRE_VA(a,...) a
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get the second argument and ignore the rest.
|
||||
*/
|
||||
#define SECOND_PRE_VA(a, b) b
|
||||
#ifdef __sgi
|
||||
/**
|
||||
* Get the second argument and ignore the rest.
|
||||
*/
|
||||
# define SECOND_PRE_VA(a, b) b
|
||||
#else
|
||||
/**
|
||||
* Get the second argument and ignore the rest.
|
||||
*/
|
||||
# define SECOND_PRE_VA(a, b,...) b
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Expects a single input (not containing commas). Returns 1 if the input is
|
||||
@@ -200,42 +223,54 @@
|
||||
* This macro abuses the fact that PROBE() contains a comma while other valid
|
||||
* inputs must not.
|
||||
*/
|
||||
#define IS_PROBE(a) SECOND_PRE_VA(a, 0)
|
||||
#define PROBE() ~, 1
|
||||
|
||||
/**
|
||||
* Detect Parenthesis
|
||||
* @return TRUE/FALSE
|
||||
*/
|
||||
#define IS_PAREN(x) IS_PROBE(IS_PAREN_PROBE x)
|
||||
#define IS_PAREN_PROBE(A) PROBE(~)
|
||||
|
||||
#ifdef EXPAND_EXAMPLES
|
||||
IS_PAREN((S)) // Expands to 1
|
||||
IS_PAREN(xxx) // Expands to 0
|
||||
#ifdef __sgi
|
||||
# define IS_PROBE(a) SECOND_PRE_VA(a, 0)
|
||||
# define PROBE() ~, 1
|
||||
#else
|
||||
# define IS_PROBE(...) SECOND_PRE_VA(__VA_ARGS__,0)
|
||||
# define PROBE(...) ~, 1, __VA_ARGS__
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Detects if arg or macro is defined as nothing.
|
||||
* Detect Parenthesis
|
||||
* @return TRUE/FALSE
|
||||
*/
|
||||
|
||||
#ifdef __sgi
|
||||
# define IS_PAREN(x) IS_PROBE(IS_PAREN_PROBE x)
|
||||
# define IS_PAREN_PROBE(A) PROBE(~)
|
||||
#else
|
||||
# define IS_PAREN(...) IS_PROBE(IS_PAREN_PROBE __VA_ARGS__)
|
||||
# define IS_PAREN_PROBE(...) PROBE(~) __VA_ARGS__
|
||||
#endif
|
||||
|
||||
#ifdef EXPAND_EXAMPLES
|
||||
//IS PAREN
|
||||
IS_PAREN((S)) // IS...((s)) Expands to 1
|
||||
IS_PAREN(xxx) // IS...(xxx) Expands to 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Detects if arg or macro is defined as nothing.
|
||||
*/
|
||||
#define IS_EMPTY(x) _IS_EMPTY(x)
|
||||
#define _IS_EMPTY(x) IS_PROBE(CAT(_IS_EMPTY, _##x##_))
|
||||
#define _IS_EMPTY__ PROBE(~) /*NULL*/
|
||||
|
||||
/**
|
||||
* Detects if arg or macro is a Bool (1 or 0).
|
||||
* Detects if arg or macro is a Bool (1 or 0).
|
||||
* Use _IS_BOOL to prevent first expansion (TRUE/FALSE macro)
|
||||
* @return TRUE/FALSE
|
||||
*/
|
||||
#define IS_BOOL(x) _IS_BOOL(x)
|
||||
#define _IS_BOOL(x) IS_PROBE(CAT(_IS_BOOL, _##x##_))
|
||||
#define _IS_BOOL_TRUE_ PROBE(~)
|
||||
#define _IS_BOOL_FALSE_ PROBE(~)
|
||||
#define _IS_BOOL_FALSE_ PROBE(~)
|
||||
#define _IS_BOOL_1_ PROBE(~)
|
||||
#define _IS_BOOL_0_ PROBE(~)
|
||||
|
||||
/**
|
||||
* Macro version of "defined" however its limited to 1/0/nothing. Any other value
|
||||
* Macro version of "defined" however its limited to 1/0/nothing. Any other value
|
||||
* is indistuiguishable from a random name
|
||||
* Certain pre-defined definitions can be "NOTDEFINED" eg THIS.
|
||||
* so checking IF(DEFINED(THIS)) is asking if THIS is NOT defined
|
||||
@@ -268,6 +303,7 @@
|
||||
|
||||
|
||||
#ifdef EXPAND_EXAMPLES
|
||||
//NOT
|
||||
NOT(1) // not 1
|
||||
NOT(0) // not 0
|
||||
NOT() // not
|
||||
@@ -295,7 +331,7 @@
|
||||
#define _IF_VA_0(a)
|
||||
|
||||
/**
|
||||
* _VA_ARGS_ for c89
|
||||
* _VA_ARGS_ for c89
|
||||
* Allows up to 32 Args on the stack
|
||||
*/
|
||||
#define EXPAND_ARGS_STACK(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,AA,AB,AC,AD,AE,AF,ERROR) \
|
||||
@@ -399,39 +435,63 @@ IF_VA(NOT(IS_EMPTY(A)))/*
|
||||
*/(/*
|
||||
*/COMMA() undefinedlocal = 1/0 "_VA_ARGS Stack full"/*
|
||||
*/)/*
|
||||
*/) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )
|
||||
*/) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )
|
||||
/**
|
||||
* Push/Pop VA Args arrays
|
||||
*/
|
||||
#define POP_ARG(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,AA,AB,AC,AD,AE,AF) /*
|
||||
*/(IF_VA(IS_PAREN(A))(_POP_ARG A) /*
|
||||
ELSE*/IF_VA(NOT(IS_PAREN(A)))(EXPAND_ARGS_STACK(B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,AA,AB,AC,AD,AE,AF)))
|
||||
#define _POP_ARG(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,AA,AB,AC,AD,AE,AF) EXPAND_ARGS_STACK(B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,AA,AB,AC,AD,AE,AF)
|
||||
#define PUSH_ARG(A,B)(A, TRY_EXPAND(B))
|
||||
|
||||
/**
|
||||
#ifdef __sgi
|
||||
# define POP_ARG(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,AA,AB,AC,AD,AE,AF) /*
|
||||
*/(IF_VA(IS_PAREN(A))(_POP_ARG A) /*
|
||||
ELSE*/IF_VA(NOT(IS_PAREN(A)))(EXPAND_ARGS_STACK(B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,AA,AB,AC,AD,AE,AF)))
|
||||
# define _POP_ARG(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, AA, AB, AC, AD, AE, AF) EXPAND_ARGS_STACK(B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, AA, AB, AC, AD, AE, AF)
|
||||
#else
|
||||
# define POP_ARG(A, ...) (IF_VA(IS_PAREN(A))(_POP_ARG A) IF_VA(NOT(IS_PAREN(A))) (_POP_ARG(A, __VA_ARGS__))
|
||||
# define _POP_ARG(A, ...) __VA_ARGS__
|
||||
#endif
|
||||
# define PUSH_ARG(A,B)(A, TRY_EXPAND(B))
|
||||
|
||||
/**
|
||||
* TRY Expand If Array
|
||||
*/
|
||||
#define TRY_EXPAND(c) _TRY_EXPAND(IS_PAREN(c))(c)
|
||||
#define _TRY_EXPAND(c) CAT(__TRY_EXPAND_, c)
|
||||
#define __TRY_EXPAND_1(a) EXPAND_ARGS_STACK a
|
||||
#ifdef __sgi
|
||||
# define __TRY_EXPAND_1(a) EXPAND_ARGS_STACK a
|
||||
#else
|
||||
# define __TRY_EXPAND_1(A) __TRY_EXPAND_11 A
|
||||
# define __TRY_EXPAND_11(...) __VA_ARGS__
|
||||
#endif
|
||||
#define __TRY_EXPAND_0(a) a
|
||||
|
||||
/**
|
||||
* Get the first argument and ignore the rest.
|
||||
*/
|
||||
#define FIRST(a) EXPAND(DEFER(FIRST_PRE_VA)(TRY_EXPAND(a)))
|
||||
|
||||
/**
|
||||
* Get the second argument and ignore the rest.
|
||||
*/
|
||||
#define SECOND(a, b) EXPAND(DEFER(SECOND_PRE_VA)(TRY_EXPAND(a), b))
|
||||
#ifdef __sgi
|
||||
/**
|
||||
* Get the first argument and ignore the rest.
|
||||
*/
|
||||
# define FIRST(a) EXPAND(DEFER(FIRST_PRE_VA)(TRY_EXPAND(a)))
|
||||
/**
|
||||
* Get the second argument and ignore the rest.
|
||||
*/
|
||||
# define SECOND(a, b) EXPAND(DEFER(SECOND_PRE_VA)(TRY_EXPAND(a), b))
|
||||
|
||||
#else
|
||||
/**
|
||||
* Get the first argument and ignore the rest.
|
||||
*/
|
||||
# define FIRST(A,...) EXPAND(DEFER(FIRST_PRE_VA)(TRY_EXPAND(a)))
|
||||
/**
|
||||
* Get the second argument and ignore the rest.
|
||||
*/
|
||||
# define SECOND(a, b,...) EXPAND(DEFER(SECOND_PRE_VA)(TRY_EXPAND(a), b))
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef EXPAND_EXAMPLES
|
||||
// POP ARG
|
||||
// POP ARG (THIS, IS, a, TEST, hy)
|
||||
POP_ARG(THIS, IS, a, TEST, hy)
|
||||
// push arg
|
||||
PUSH_ARG(test, (this, is, a, test, with, a , is, so, is, a, test, with, a , is, so, is, a, test, with, a , is, so, is, a, test, with, a , is, so))
|
||||
// push arg test (this, is, a, test, with, a , is, so, is, a, test, with, a , is, so, is, a, test, with, a , is, so, is, a, test, with, a , is, so)
|
||||
PUSH_ARG(test, (this, is, a, test, with, a2 , is2, so, is3, a3, test2, with2, a3 , is4, so4, is5, a4, test3, with3, a6 , is6, so5, is7, a7, test4, with5, a8 , is8, so8))
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -453,14 +513,14 @@ IF_VA(NOT(IS_EMPTY(A)))/*
|
||||
/**
|
||||
* Logical AND. Simply performs a lookup.
|
||||
*/
|
||||
#define AND(a, b) CAT(CAT(_AND_, a), b)
|
||||
#define _AND_00 0
|
||||
#define _AND_01 0
|
||||
#define _AND_10 0
|
||||
#define _AND_11 1
|
||||
#define AND_CPPLIB(a, b) CAT(CAT(_AND_CPPLIB_, a), b)
|
||||
#define _AND_CPPLIB_00 0
|
||||
#define _AND_CPPLIB_01 0
|
||||
#define _AND_CPPLIB_10 0
|
||||
#define _AND_CPPLIB_11 1
|
||||
|
||||
/**
|
||||
* Macro if statement.
|
||||
* Macro if statement.
|
||||
* Usage:
|
||||
* IF(condition) \
|
||||
* ( \
|
||||
@@ -474,16 +534,16 @@ IF_VA(NOT(IS_EMPTY(A)))/*
|
||||
#define _IF_1(a) TRY_EXPAND(a)
|
||||
#define _IF_0(a)
|
||||
|
||||
/**
|
||||
* Macro if/else statement.
|
||||
/**
|
||||
* Macro if/else statement.
|
||||
* Usage:
|
||||
*
|
||||
* IF_ELSE(condition)
|
||||
* ((
|
||||
* expansion when true
|
||||
* ))
|
||||
* ((
|
||||
* expansion when false
|
||||
* IF_ELSE(condition)
|
||||
* ((
|
||||
* expansion when true
|
||||
* ))
|
||||
* ((
|
||||
* expansion when false
|
||||
* ))
|
||||
* @param condition
|
||||
* @return TRUE/FALSE
|
||||
@@ -496,10 +556,13 @@ IF_VA(NOT(IS_EMPTY(A)))/*
|
||||
|
||||
|
||||
#ifdef EXPAND_EXAMPLES
|
||||
IF_ELSE(220)((it was, non - zero))(it was zero) // Expands to "non Zero"
|
||||
//if else 220
|
||||
IF_ELSE(220)((it was, non - zero))(it was zero) // Expands to "it was, non Zero"
|
||||
//if 06
|
||||
IF(06)(NONZERO)
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* When
|
||||
*/
|
||||
@@ -507,12 +570,16 @@ IF_VA(NOT(IS_EMPTY(A)))/*
|
||||
#endif
|
||||
/**
|
||||
* Macro which checks if it has any arguments. Returns '0' if there are no
|
||||
* arguments, '1' otherwise.
|
||||
* arguments, '1' otherwise.
|
||||
* Limitation: HAS_ARGS(,1,2,3) returns 0 -- this check essentially only checks
|
||||
* that the first argument exists.
|
||||
* @return TRUE/FALSE
|
||||
*/
|
||||
#define HAS_ARGS(a) BOOL(EXPAND(_END_OF_ARGUMENTS_ FIRST(a)()))
|
||||
#ifdef __sgi
|
||||
# define HAS_ARGS(a) BOOL(EXPAND(_END_OF_ARGUMENTS_ FIRST(a)()))
|
||||
#else
|
||||
# define HAS_ARGS(...) BOOL(FIRST(__VA_ARGS__))
|
||||
#endif
|
||||
#define _END_OF_ARGUMENTS_() 0
|
||||
|
||||
/*
|
||||
@@ -523,7 +590,7 @@ for_each(v.begin(), v.end(), [](int &number)
|
||||
*/
|
||||
/**
|
||||
* foreach macro
|
||||
* @param
|
||||
* @param
|
||||
*/
|
||||
#define foreach(var, collection) for (var = *collection; var; var++)
|
||||
|
||||
@@ -535,8 +602,9 @@ HAS_ARGS((a, b, c))
|
||||
//no
|
||||
HAS_ARGS()
|
||||
HAS_ARGS(())
|
||||
HAS_ARGS(( ()))
|
||||
|
||||
HAS_ARGS(( ())) //this one has too many parens
|
||||
#endif
|
||||
#if 0
|
||||
# define test() Im expanded
|
||||
DEFER8(test)() EVAL1(EVAL4(DEFER4(test)()))
|
||||
|
||||
@@ -545,7 +613,7 @@ HAS_ARGS(( ()))
|
||||
// RECURSE
|
||||
EVAL16(RECURSE((this, is, a, test, WITH, MANY, ARGS)))
|
||||
#endif
|
||||
|
||||
#ifdef __sgi
|
||||
#define COUNTPARAMS(X) \
|
||||
IF_ELSE(IS_PAREN(X)) /*
|
||||
*/( /*
|
||||
@@ -563,22 +631,37 @@ HAS_ARGS(( ()))
|
||||
*/COUNT /*
|
||||
*/)
|
||||
# define _COUNTPARMS() COUNTPARAMS_INNER
|
||||
|
||||
#else
|
||||
# define ELEVENTH_ARGUMENT(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, ...) a11
|
||||
# define COUNTPARAMS(...) IF_ELSE(IS_PAREN(__VA_ARGS__))(_COUNTPARAMS __VA_ARGS__)(ELEVENTH_ARGUMENT(dummy, ##__VA_ARGS__, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0))
|
||||
# define _COUNTPARAMS(...) ELEVENTH_ARGUMENT(dummy, ##__VA_ARGS__, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
|
||||
#endif
|
||||
|
||||
#ifdef EXPAND_EXAMPLES
|
||||
// COUNTPARAMS - IT WORKS!!!, THIS WILL BE GREAT FOR AI
|
||||
//0
|
||||
COUNTPARAMS(())
|
||||
//1
|
||||
COUNTPARAMS((A))
|
||||
// 2
|
||||
COUNTPARAMS((A, B))
|
||||
// 3
|
||||
COUNTPARAMS((A, B, C))
|
||||
// 4
|
||||
COUNTPARAMS((A, B, C, D))
|
||||
// 5
|
||||
COUNTPARAMS((A, B, C, D, E))
|
||||
// 6
|
||||
COUNTPARAMS((A, B, C, D, E, F))
|
||||
// 7
|
||||
COUNTPARAMS((A, B, C, D, E, F, G))
|
||||
COUNTPARAMS((A, B, C, D, E, F,G,H))
|
||||
COUNTPARAMS((A, B, C, D, E, F,G,H,I))
|
||||
// 8
|
||||
COUNTPARAMS((A, B, C, D, E, F, G, H))
|
||||
// 9
|
||||
COUNTPARAMS((A, B, C, D, E, F, G, H, I))
|
||||
|
||||
#enAdif
|
||||
#endif
|
||||
#if 0
|
||||
#define LIST_TO_TUPLE(list) \
|
||||
IF_ELSE(IS_PAREN(list))\
|
||||
(\
|
||||
@@ -586,8 +669,8 @@ HAS_ARGS(( ()))
|
||||
)\
|
||||
(\
|
||||
list\
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
#define LIST_TO_TUPLE_INNER(list, listb) \
|
||||
IF_ELSE(HAS_ARGS(list)) \
|
||||
(\
|
||||
@@ -595,25 +678,26 @@ HAS_ARGS(( ()))
|
||||
)\
|
||||
(\
|
||||
0 listb\
|
||||
)
|
||||
#define _LIST_TO_TUPLE_INNER() LIST_TO_TUPLE_INNER
|
||||
// list to tuple
|
||||
LIST_TO_TUPLE((this, (is, (a, (li8st, (lots, (of, (test, (another, )))))))))
|
||||
//SINGLE
|
||||
)
|
||||
#define _LIST_TO_TUPLE_INNER() LIST_TO_TUPLE_INNER
|
||||
// list to tuple
|
||||
LIST_TO_TUPLE((this, (is, (a, (li8st, (lots, (of, (test, (another, )))))))))
|
||||
//SINGLE
|
||||
LIST_TO_TUPLE((this,(is)))
|
||||
|
||||
#endif
|
||||
|
||||
#define REPEAT(count, macro, a) \
|
||||
IF_ELSE(DEC(count)) \
|
||||
(DEFER3(REPEAT_INDIRECT)()(DEC(count), macro, a))( \
|
||||
/* Do nothing, just terminate */) DEFER(macro)(DEC(count), a)
|
||||
|
||||
#define REPEAT_INDIRECT() REPEAT
|
||||
|
||||
#ifdAef EXPAND_EXAMPLES
|
||||
// An example of using this macro
|
||||
#ifdef EXPAND_EXAMPLES
|
||||
// An example of repeat 9
|
||||
# define M(i, _) i
|
||||
EVAL16(REPEAT(9, M, ~)) // 0 1 2 3 4 5 6 7
|
||||
#endiAf
|
||||
EVAL16(REPEAT(9, M, ~)) // 0 1 2 3 4 5 6 7 8
|
||||
#endif
|
||||
|
||||
#define WHILE(pred, op, a) \
|
||||
IF(pred(a)) \
|
||||
@@ -649,4 +733,4 @@ LIST_TO_TUPLE((this,(is)))
|
||||
|
||||
/*MAP(MAKE_HAPPY, COMMA, (1,2,3,A))*/
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
all: $(APPROM)
|
||||
@if [ -f ge007.$(OUTCODE).sha1 ]; then \
|
||||
$(SHA1SUM) -c ge007.$(OUTCODE).sha1 && echo "\n MATCH!\n\n" || (echo "\n ERROR!\n\n\n NOT MATCH!\n\n" && exit 1); \
|
||||
fi
|
||||
@echo "\nRom File Generated in Build Directory. \n\n"
|
||||
|
||||
.SECONDARY:
|
||||
$(APPELF) $(APPROM) $(APPBIN) $(ULTRAOBJECTS) $(BUILD_DIR)/ge007.$(OUTCODE).map \
|
||||
$(HEADEROBJECTS) $(BOOTOBJECTS) $(CODEOBJECTS) $(GAMEOBJECTS) $(RZOBJECTS) \
|
||||
$(OBSEG_OBJECTS) $(OBSEG_RZ) $(ROMOBJECTS) $(RAMROM_OBJECTS) $(FONTOBJECTS) $(MUSIC_OBJECTS) $(IMAGE_OBJS) $(MUSIC_RZ_FILES)
|
||||
|
||||
ifeq ($(filter clean nuke dataclean help codeclean context cmdbuilder test stanclean setupclean,$(MAKECMDGOALS)),)
|
||||
# Dont print version on "default" since it will be spat out twice
|
||||
ifneq ($(filter $(VERSION),$(ALLOWED_VERSIONS)),)
|
||||
#$(info VERSION=$(VERSION))
|
||||
else
|
||||
$(error VERSION "$(VERSION)" not supported")
|
||||
endif
|
||||
# Make tools if out of date
|
||||
$(info Building tools...)
|
||||
DUMMY != make -s -C tools >&2 || echo FAIL
|
||||
ifeq ($(DUMMY),FAIL)
|
||||
$(error Failed to build tools)
|
||||
endif
|
||||
$(info Building $(VERSION) ROM...)
|
||||
|
||||
endif
|
||||
|
||||
# Build RSP
|
||||
$(BUILD_DIR)/rsp/%.bin: rsp/*.s
|
||||
$(ARMIPS) -sym $@.sym -strequ CODE_FILE $(BUILD_DIR)/rsp/$*.bin -strequ DATA_FILE $(BUILD_DIR)/rsp/$*_data.bin $<
|
||||
|
||||
$(BUILD_DIR)/src/rspboot.o: $(BUILD_DIR)/rsp/rspboot.bin
|
||||
|
||||
#Build asm files in root
|
||||
$(BUILD_DIR)/%.o: src/%.s
|
||||
$(AS) $(ASFLAGS) -o $@ $<
|
||||
|
||||
#Build asm files in src/
|
||||
$(BUILD_DIR)/src/%.o: src/%.s
|
||||
$(AS) $(ASFLAGS) -o $@ $<
|
||||
|
||||
#Build Images
|
||||
$(BUILD_DIR)/assets/images/split/%.o: assets/images/split/%.bin
|
||||
$(LD) -r -b binary $< -o $@
|
||||
|
||||
#Compress Obseg
|
||||
$(BUILD_DIR)/$(OBSEGMENT): $(OBSEG_RZ) $(IMAGE_OBJS)
|
||||
|
||||
|
||||
#Build C files in src/
|
||||
$(BUILD_DIR)/src/%.o: src/%.c
|
||||
@if grep -q 'GLOBAL_ASM(' $<; then \
|
||||
$(ASM_PREPROC) $(OPTIMIZATION) $< | $(CC) -c $(CFLAGS) tools/asm-processor/include-stdin.c -o $@ $(OPTIMIZATION); \
|
||||
$(ASM_PREPROC) $(OPTIMIZATION) $< --post-process $@ --assembler "$(AS) $(ASFLAGS)" --asm-prelude tools/asm-processor/prelude.s; \
|
||||
else \
|
||||
$(CC) -c $(CFLAGS) -o $@ $(OPTIMIZATION) $<; \
|
||||
fi
|
||||
|
||||
|
||||
#Build RamRom
|
||||
$(BUILD_DIR)/assets/ramrom/%.o: assets/ramrom/%.s
|
||||
$(AS) $(ASFLAGS) -o $@ $<
|
||||
|
||||
#Build fonts
|
||||
$(BUILD_DIR)/assets/font/%.o: assets/font/%.c
|
||||
$(CC) -c $(CFLAGS) -o $@ $(OPTIMIZATION) $<
|
||||
|
||||
#Build asm files in assets/
|
||||
$(BUILD_DIR)/assets/%.o: assets/%.s
|
||||
$(AS) $(ASFLAGS) -o $@ $<
|
||||
|
||||
#Build Obseg
|
||||
$(BUILD_DIR)/assets/obseg/%.o: assets/obseg/%.s $(OBSEG_RZ)
|
||||
$(AS) $(ASFLAGS) -o $@ $<
|
||||
|
||||
#Build C files in assets/
|
||||
$(BUILD_DIR)/assets/%.o: assets/%.c
|
||||
$(CC) -c $(CFLAGS) -o $@ $(OPTIMIZATION) $<
|
||||
|
||||
#$(BUILD_DIR)/src/random.o: OPTIMIZATION := -O3
|
||||
#$(BUILD_DIR)/src/random.o: INCLUDE := -I . -I include -I include/PR
|
||||
#$(BUILD_DIR)/src/random.o: MIPSISET := -mips3 -o32
|
||||
#$(BUILD_DIR)/src/random.o: src/random.c
|
||||
# $(CC) -c -Wab,-r4300_mul -non_shared -G 0 -Xcpluscomm $(CFLAGWARNING) -woff 819,820,852,821,838,649 -signed $(INCLUDE) $(MIPSISET) $(LCDEFS) -DTARGET_N64 $(OPTIMIZATION) -o $@ $<
|
||||
|
||||
#Link Files
|
||||
$(APPELF): $(RSPOBJECTS) $(ULTRAOBJECTS) $(HEADEROBJECTS) $(OBSEG_RZ) $(BUILD_DIR)/$(OBSEGMENT) $(MUSIC_RZ_FILES) $(BOOTOBJECTS) $(CODEOBJECTS) $(GAMEOBJECTS) $(RZOBJECTS) $(ROMOBJECTS) $(ASSET_DATAOBJECTS) $(ROMOBJECTS2) $(RAMROM_OBJECTS) $(FONTOBJECTS) $(MUSIC_OBJECTS) $(OBSEG_OBJECTS) ge007.ld
|
||||
cpp $(LDFILEOPTS) -P ge007.ld -o build/ge007.$(OUTCODE).ld
|
||||
@echo "Linking Files into ELF"
|
||||
$(LD) $(LDFLAGS) -o $@
|
||||
|
||||
$(APPBIN): $(APPELF)
|
||||
@echo "Building ROM"
|
||||
$(OBJCOPY) $< $@ -O binary --gap-fill=0xff
|
||||
|
||||
$(APPROM): $(APPBIN)
|
||||
@echo "Compressing ROM"
|
||||
$(DATASEG_COMP) $< $(OUTCODE)
|
||||
@echo "Finalizing ROM"
|
||||
$(N64CKSUM) $< $@
|
||||
|
||||
.PRECIOUS: %.bin %.o
|
||||
|
||||
## Phony Recipies - Get Make to do something ##
|
||||
|
||||
|
||||
.PHONY: all default codeclean dataclean clean cmdbuilder test help
|
||||
|
||||
setupclean:
|
||||
rm -f $(APPELF) $(APPROM) $(APPBIN) $(BUILD_DIR)/ge007.$(OUTCODE).map \
|
||||
$(SETUP_BUILD_FILES)
|
||||
|
||||
stanclean:
|
||||
rm -f $(APPELF) $(APPROM) $(APPBIN) $(BUILD_DIR)/ge007.$(OUTCODE).map \
|
||||
$(STAN_BUILD_FILES)
|
||||
|
||||
libultraclean:
|
||||
rm -f $(APPELF) $(APPROM) $(APPBIN) $(BUILD_DIR)/ge007.$(OUTCODE).map \
|
||||
$(ULTRAOBJECTS)
|
||||
|
||||
codeclean:
|
||||
rm -f $(APPELF) $(APPROM) $(APPBIN) $(ULTRAOBJECTS) $(BUILD_DIR)/ge007.$(OUTCODE).map \
|
||||
$(HEADEROBJECTS) $(BOOTOBJECTS) $(CODEOBJECTS) $(GAMEOBJECTS) $(RZOBJECTS) $(RSPOBJECTS)
|
||||
|
||||
dataclean:
|
||||
rm -f $(APPELF) $(APPROM) $(APPBIN) $(ULTRAOBJECTS) $(BUILD_DIR)/ge007.$(OUTCODE).map \
|
||||
$(OBSEG_OBJECTS) $(OBSEG_RZ) $(ROMOBJECTS) $(RAMROM_OBJECTS) $(FONTOBJECTS) $(MUSIC_OBJECTS) $(IMAGE_OBJS) $(MUSIC_RZ_FILES) \
|
||||
$(STAN_BUILD_FILES) $(SETUP_BUILD_FILES)
|
||||
|
||||
clean::
|
||||
# if this command is modified, make sure to update this in the `nuke` recipe.
|
||||
rm -f $(APPELF) $(APPROM) $(APPBIN) $(ULTRAOBJECTS) $(BUILD_DIR)/ge007.$(OUTCODE).map \
|
||||
$(HEADEROBJECTS) $(BOOTOBJECTS) $(CODEOBJECTS) $(GAMEOBJECTS) $(RZOBJECTS) \
|
||||
$(OBSEG_OBJECTS) $(OBSEG_RZ) $(ROMOBJECTS) $(RAMROM_OBJECTS) $(FONTOBJECTS) $(MUSIC_OBJECTS) $(IMAGE_OBJS) $(MUSIC_RZ_FILES) $(RSPOBJECTS) \
|
||||
$(STAN_BUILD_FILES) $(SETUP_BUILD_FILES)
|
||||
|
||||
nuke:
|
||||
@echo deleting files specified from make clean ...
|
||||
@# if this command is modified, update the `clean` recipe above.
|
||||
rm -f $(APPELF) $(APPROM) $(APPBIN) $(ULTRAOBJECTS) $(BUILD_DIR)/ge007.$(OUTCODE).map \
|
||||
$(HEADEROBJECTS) $(BOOTOBJECTS) $(CODEOBJECTS) $(GAMEOBJECTS) $(RZOBJECTS) \
|
||||
$(OBSEG_OBJECTS) $(OBSEG_RZ) $(ROMOBJECTS) $(RAMROM_OBJECTS) $(FONTOBJECTS) $(MUSIC_OBJECTS) $(IMAGE_OBJS) $(MUSIC_RZ_FILES) $(RSPOBJECTS) \
|
||||
$(STAN_BUILD_FILES) $(SETUP_BUILD_FILES)
|
||||
@echo
|
||||
@echo make: deleting build folders and files
|
||||
$(foreach x,$(ALLOWED_COUNTRYCODE),rm -r -f -d "$(BUILD_DIR_BASE)/$(x)/"${\n})
|
||||
@echo
|
||||
@echo make: deleting bin / rsp / asp
|
||||
rm -r -f -d "bin/"
|
||||
@echo
|
||||
@echo make: deleting assets
|
||||
rm -r -f -d "assets/images/split/"
|
||||
rm -r -f "assets/music/*.bin" "assets/obseg/bg/*.bin" "assets/obseg/brief/*.bin" "assets/obseg/chr/*.bin" "assets/obseg/gun/*.bin" "assets/obseg/prop/*.bin" "assets/obseg/setup/*.bin" "assets/obseg/setup/e/*.bin" "assets/obseg/setup/u/*.bin" "assets/obseg/setup/j/*.bin" "assets/obseg/stan/*.bin" "assets/obseg/text/*.bin" "assets/obseg/text/e/*.bin" "assets/obseg/text/u/*.bin" "assets/obseg/text/j/*.bin" "assets/ramrom/*.bin" "assets/ramrom/e/*.bin" "assets/ramrom/u/*.bin" "assets/ramrom/j/*.bin"
|
||||
|
||||
help:
|
||||
@echo "mmakefile help"
|
||||
@echo ""
|
||||
@echo " supported targets:"
|
||||
@echo ""
|
||||
@echo " all Build all (default)"
|
||||
@echo " clean Delete all known build artifacts"
|
||||
@echo " nuke Delete all files explicitly listed in Makefile (same as make clean),"
|
||||
@echo " all build output for all versions, any .bin file in assets folders,"
|
||||
@echo " and asp/rsp bin."
|
||||
@echo " dataclean Delete only asset build artifacts"
|
||||
@echo " codeclean Delete only code (asm, .c) build artifacts"
|
||||
@echo " libultraclean Delete only code (asm, .c) build artifacts "
|
||||
@echo " from Rare's libultra files"
|
||||
@echo " stanclean Delete only stan build artifacts"
|
||||
@echo " setupclean Delete only setup build artifacts"
|
||||
@echo " cmdbuilder BuildAI Commands"
|
||||
@echo " context [file] BuildContext File from [file]"
|
||||
@echo " eg make context src/game/chrai.c"
|
||||
@echo " test Re-Run Data Verification "
|
||||
@echo ""
|
||||
@echo ""
|
||||
@echo " options:"
|
||||
@echo ""
|
||||
@echo " VERSION=v Region version. (US is default)"
|
||||
@echo " Supported values: ${ALLOWED_VERSIONS}\n"
|
||||
|
||||
test:
|
||||
@$(SHA1SUM) --quiet -c checksums.txt
|
||||
|
||||
ifneq ($(filter-out context,$(MAKECMDGOALS)),)
|
||||
CONTEXTFILE := $(filter-out context ,$(MAKECMDGOALS))
|
||||
else
|
||||
CONTEXTFILE := build/ctx.c
|
||||
endif
|
||||
context:
|
||||
@clear
|
||||
@echo Building Context File [ctx.h] from $(CONTEXTFILE)
|
||||
@echo "#define TRUE 1" > build/ctx.h
|
||||
@echo "#define FALSE 0" >> build/ctx.h
|
||||
ifeq ($(CONTEXTFILE),build/ctx.c)
|
||||
@echo "#include <bondtypes.h>" > build/ctx.c
|
||||
endif
|
||||
@sed -n -E ':x /\\$$/ { N; s/\\\n//g ; bx };''/(^\s*#define)|(\\$$)/p; /(\\$$)/p;' src/bondconstants.h src/bondtypes.h $(CONTEXTFILE) >> build/ctx.h
|
||||
@$(CC) -c $(CFLAGS) $(CONTEXTFILE) -E > build/ctx2.h 2> /dev/null || (rm build/ctx2.h && exit 1)
|
||||
@sed -E '/^\s*$$/d' build/ctx2.h >> build/ctx.h
|
||||
@rm build/ctx.c build/ctx2.h || exit 0
|
||||
@echo You can find it in Build [build/ctx.h].
|
||||
|
||||
textures:
|
||||
$(foreach x,$(IMAGE_BINS),tools/mktex/build/tex2png $(x) assets/images/out ${\n})
|
||||
+3
-1
@@ -29,7 +29,7 @@ extern "C" {
|
||||
* standard header ARE SPECIFIED BY ANSI! CONFORMANCE WILL BE ALTERED
|
||||
* IF ANY NEW IDENTIFIERS ARE ADDED TO THIS AREA UNLESS THEY ARE IN ANSI's
|
||||
* RESERVED NAMESPACE. (i.e., unless they are prefixed by __[a-z] or
|
||||
* _[A-Z]. For external objects, identifiers with the prefix _[a-z]
|
||||
* _[A-Z]. For external objects, identifiers with the prefix _[a-z]
|
||||
* are also reserved.)
|
||||
*/
|
||||
|
||||
@@ -42,6 +42,8 @@ extern "C" {
|
||||
extern void osSyncPrintf(const char *fmt, ...);
|
||||
#define assert(EX) if(!(EX))osSyncPrintf("\n--- ASSERTION FAULT - %s - %s, line %d\n\n", # EX , __FILE__, __LINE__)
|
||||
|
||||
#define assertmsg(EX, MSG) if (!(EX)) osSyncPrintf(MSG)
|
||||
|
||||
// extern void __assert(const char *, const char *, int);
|
||||
// #ifdef __ANSI_CPP__
|
||||
// #define assert(EX) ((EX)?((void)0):__assert( # EX , __FILE__, __LINE__))
|
||||
|
||||
@@ -195,6 +195,12 @@
|
||||
_g->words.w0 = _SHIFTL(G_LOADTLUT, 24, 8) | _SHIFTL((a), 14, 10) | _SHIFTL((b), 2, 10); \
|
||||
_g->words.w1 = _SHIFTL(0x06, 24, 8) | _SHIFTL((c), 14, 10) | _SHIFTL((d), 2, 10); \
|
||||
}
|
||||
#define gDPLoadTLUT07(pkt, a, b, c, d) \
|
||||
{ \
|
||||
Gfx *_g = (Gfx *)pkt; \
|
||||
_g->words.w0 = _SHIFTL(G_LOADTLUT, 24, 8) | _SHIFTL((a), 14, 10) | _SHIFTL((b), 2, 10); \
|
||||
_g->words.w1 = _SHIFTL(0x07, 24, 8) | _SHIFTL((c), 14, 10) | _SHIFTL((d), 2, 10); \
|
||||
}
|
||||
|
||||
#define gDPLoadTLUTCmd2(pkt, tile, count) \
|
||||
{ \
|
||||
|
||||
@@ -2,6 +2,18 @@
|
||||
|
||||
.macro glabel label
|
||||
.global \label
|
||||
.balign 4
|
||||
.type \label, @function
|
||||
\label:
|
||||
.endm
|
||||
|
||||
.macro dlabel label
|
||||
.global \label
|
||||
\label:
|
||||
.endm
|
||||
|
||||
.macro jlabel label
|
||||
.global \label
|
||||
.type \label, @function
|
||||
\label:
|
||||
.endm
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
|
||||
#Only Draw PBar if NOT verbose
|
||||
ifeq ($(VERBOSE),0)
|
||||
|
||||
# Separate "constant" drawing from variable drawing to speed up PBar rendering
|
||||
# draws a box and fills it grey ready for blue bar
|
||||
SetupProgressBar = \
|
||||
{ \
|
||||
str="$(SAVECURSOR)$(call SET_SCROLLREGION,4,0)$(call CURSOR_GOTO,2,999)$(VT_ED)$(call CURSOR_GOTO,1)";\
|
||||
str=$$str"\033(0lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk"; \
|
||||
str=$$str"\nx$(call SET_TEXTATTRIB,$(BG_GRAY))%78s$(RESTORECOLOUR)x\n"; \
|
||||
str=$$str"mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj\033(B"; \
|
||||
str=$$str"$(RESTORECURSOR)"; \
|
||||
printf $$str ""; \
|
||||
}
|
||||
|
||||
#(call DrawProgressBar,Percent)
|
||||
# OR
|
||||
#(call DrawProgressBar,NumberOfItemsDone,TotalNumberOfItems)
|
||||
# If second param is given, use it to work out a percentage.
|
||||
# divide the percentage into a 80 char long bar
|
||||
# paint the whole bar grey
|
||||
# paint the first half, then text, then second half.
|
||||
# clear colour codes
|
||||
DrawProgressBar = \
|
||||
{ \
|
||||
$(if $(2), \
|
||||
if [ "$(1)" -ne "$(2)" ]; \
|
||||
then \
|
||||
_pdone=`expr 100 / $(2) \* $(1)`; \
|
||||
else \
|
||||
_pdone=100; \
|
||||
fi \
|
||||
,_pdone=$(1) \
|
||||
); \
|
||||
pdone=`expr $$_pdone \* 74 / 100`; \
|
||||
pdoneb=0; \
|
||||
str="$(SAVECURSOR)$(call CURSOR_GOTO,2,2)";\
|
||||
str=$$str"$(call SET_TEXTATTRIB,$(BOLD),$(FG_WHITE),$(BG_NAVY))" ; \
|
||||
\
|
||||
if [ "$$pdone" -lt "36" ]; \
|
||||
then \
|
||||
str=$$str"%$${pdone}s"; \
|
||||
str=$$str"$(call SET_TEXTATTRIB,$(BG_GRAY))";\
|
||||
pdoneb=`expr 36 - $$pdone`; \
|
||||
str=$$str"%$${pdoneb}s%3d%%"; \
|
||||
else \
|
||||
pdoneb=`expr $$pdone - 36`; \
|
||||
str=$$str"%1s%35s%3d%%%$${pdoneb}s"; \
|
||||
fi; \
|
||||
str=$$str"$(RESTORECURSOR)$(RESTORECOLOUR)"; \
|
||||
printf $$str "" "" $$_pdone; \
|
||||
}
|
||||
# Increment Progress Bar From percentage (1), and increase by 1 every (2) seconds.
|
||||
# Continue doing so until calling process ends
|
||||
IncrementProgressBarFromAtRate = \
|
||||
{ \
|
||||
i=$(1); \
|
||||
while [ -d /proc/$$! ] && [ $$i -le 100 ]; do \
|
||||
$(call DrawProgressBar,$$i); \
|
||||
i=$$((i+1)); \
|
||||
sleep $(2); \
|
||||
done; \
|
||||
}
|
||||
endif #Verbose No Draw PBar
|
||||
|
||||
# Ask to continue
|
||||
# (1) Prompt,
|
||||
# (2) Do if Yes,
|
||||
# (3) Do if No [can be blank],
|
||||
# (4) Do if anything else [can be blank]
|
||||
# (5) Timeout [can be blank]
|
||||
ContinuePrompt = \
|
||||
{ \
|
||||
echo "$1 [y/n]"; \
|
||||
$(if $(5), readchr(){ old=$$(stty -g); stty raw -echo min 0 time 30; printf '%s' $$(dd bs=1 count=1 2>/dev/null); stty $$old;}; REPLY=$$(readchr) ,read REPLY ); \
|
||||
echo $$REPLY; case $$REPLY in \
|
||||
y|Y) $2;; \
|
||||
n|N) $3;; \
|
||||
*) $4;; \
|
||||
esac; \
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
|
||||
## VT100 Codes ##
|
||||
|
||||
SAVECURSOR := \0337\033[s
|
||||
RESTORECURSOR := \0338\033[u
|
||||
SET_SCROLLREGION = \033[$(1);$(2)r
|
||||
RESTORESCROLLREGION := \033[r
|
||||
RESTORESCROLLREGION2 = $(SAVECURSOR)$(RESTORESCROLLREGION)$(RESTORECURSOR)\033[1A
|
||||
CURSOR_GOTO = \033[$(1);$(2)H
|
||||
SET_TEXTATTRIB = \033[$(1)$(if $(2),;$(2))$(if $(3),;$(3))m
|
||||
BELL := \007
|
||||
VT_ED := \033[2J
|
||||
VT_CUU = \033[$(1)A
|
||||
VT_CUD = \033[$(1)B
|
||||
VT_CUF = \033[$(1)C
|
||||
VT_CUB = \033[$(1)D
|
||||
|
||||
#Attributes
|
||||
RESTORECOLOUR := \033[m
|
||||
BOLD := 1
|
||||
DIM := 2
|
||||
UNDERSCORE := 4
|
||||
BLINK := 5
|
||||
INVERT := 7
|
||||
HIDDEN := 8
|
||||
|
||||
#Colours
|
||||
FG_BLACK:= 30
|
||||
FG_MAROON:= 31
|
||||
FG_GREEN:= 32
|
||||
FG_OLIVE:= 33
|
||||
FG_NAVY:= 34
|
||||
FG_PURPLE:= 35
|
||||
FG_TEAL:= 36
|
||||
FG_SILVER:= 37
|
||||
FG_GRAY:= 90
|
||||
FG_RED:= 91
|
||||
FG_LIME:= 92
|
||||
FG_YELLOW:= 93
|
||||
FG_BLUE:= 94
|
||||
FG_VIOLET:= 95
|
||||
FG_CYAN:= 96
|
||||
FG_WHITE:= 97
|
||||
|
||||
BG_BLACK:= 40
|
||||
BG_MAROON:= 41
|
||||
BG_GREEN:= 42
|
||||
BG_OLIVE:= 43
|
||||
BG_NAVY:= 44
|
||||
BG_PURPLE:= 45
|
||||
BG_TEAL:= 46
|
||||
BG_SILVER:= 47
|
||||
BG_GRAY:= 100
|
||||
BG_RED:= 101
|
||||
BG_LIME:= 102
|
||||
BG_YELLOW:= 103
|
||||
BG_BLUE:= 104
|
||||
BG_VIOLET:= 105
|
||||
BG_CYAN:= 106
|
||||
BG_WHITE:= 107
|
||||
|
||||
# define a "newline" variable to be used in make scripts
|
||||
# use with ${\n}
|
||||
# https://stackoverflow.com/questions/12528637/how-do-i-execute-each-command-in-a-list
|
||||
define \n
|
||||
|
||||
|
||||
endef
|
||||
#end newline.
|
||||
|
||||
#Colour IDO Output (GCC does this automatically)
|
||||
CLR_OUT := sed -E
|
||||
#colour AI errors
|
||||
CLR_OUT += -e 's/\(\(\x27E\x27\,\x27R\x27\,\x27R\x27\,\x27O\x27\,\x27R\x27,\s?((\x27?,?\s?\x27.)*)\x27,\s?\x27([^x27])\x27\)/((\x27ERROR\x27,\1\3\x27\)/g; :loop s/\(\((\x27ERROR)((\x27?,?\s?\x27.)*),?\s?\x27(.)\x27([^x27]*)\x27\)/((\1\2\5\x27\)/g; tloop; '
|
||||
#colour errors
|
||||
CLR_OUT += -e "s/(ERROR:[^\x27]*?\x27)|(^.*[Ee]rror.*)|(Mis-Match in)|(:\sFAILED)/$$(echo "$(call SET_TEXTATTRIB,$(FG_RED))")&$$(echo "$(RESTORECOLOUR)")/g"
|
||||
#colour warnings
|
||||
CLR_OUT += -e "s/^.*[Ww]arning.*/$$(echo "$(call SET_TEXTATTRIB,$(FG_YELLOW))")&$$(echo "$(RESTORECOLOUR)")/g"
|
||||
#colour Info Tags
|
||||
CLR_OUT += -e "s/^.*(([Bb]uilding)|(:\sOK)|([Ll]inkin)).*/$$(echo "$(call SET_TEXTATTRIB,$(FG_LIME))")&$$(echo "$(RESTORECOLOUR)")/g"
|
||||
#colour filenames
|
||||
CLR_OUT += -e "s/((([^\/]*([^s][^t][^d][^i][^n])\.c)|([^\/]*\.o))\s)/$$(echo "$(call SET_TEXTATTRIB,$(FG_WHITE))")&$$(echo "$(RESTORECOLOUR)")/g"
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
################################################################################
|
||||
# CMD Builder
|
||||
################################################################################
|
||||
|
||||
#CMD Builder tools
|
||||
AI_CMD_BUILDER := $(TOOLS_DIR)/cmdbuilder.c
|
||||
AI_CMD_LIST_DEFINITIONS := src/aicommands.def
|
||||
AI_CMD_LIST_TEMP := $(BUILD_DIR)/aicommands.temp
|
||||
AI_CMD_LIST_H2 := src/aicommands2.h
|
||||
#Pre-Format encoding newlines and tags
|
||||
AI_CMD_BUILDER_PRECONVERT := sed -E
|
||||
AI_CMD_BUILDER_PRECONVERT += -e 's/\x27\\n\x27/\x27\/n\x27/g;' # encode '\n' as '/n' (TEXT PRINT command)
|
||||
AI_CMD_BUILDER_PRECONVERT += -e '/^\s*\*/ s/\x27/\?\?x27/g;' # encode DocBlock(/**...**/) quotes '' as x27
|
||||
AI_CMD_BUILDER_PRECONVERT += -e '/\/\*\*/ , /\*\// s/([^/])$$/\1 \\n\\/g;' # encode DocBlock(/**...**/) Newlines as \n\ .
|
||||
#AI_CMD_BUILDER_PRECONVERT += -e '/^\s*\*/ s/([^\/])$$/\1 \\n\\/g;' # encode DocBlock(/**...**/) Newlines as \n\ .
|
||||
AI_CMD_BUILDER_PRECONVERT += -e 's/[^/\*\S]\*$$/\\n\\/g; s/^(\s*)\*[^/\*]/\1 /g;' # remove DocBlock sides (causes problems with tooltips) fixed to check for ordinary comment
|
||||
#AI_CMD_BUILDER_PRECONVERT += -e '/^_AI_CMD_POLYMORPH\(CMDNAME,\n(.|\n)*?\s{19}DESCRIPTION(\)| DESCRIPTION2\))/ s/[^,]\n/\\n\\/g;' # Newlines in POLYMORPHS
|
||||
AI_CMD_BUILDER_PRECONVERT += -e 's/\/\*\*/\?\?\\\*\(\*\*/g;' # encode /** as ??\*(**
|
||||
AI_CMD_BUILDER_PRECONVERT += -e 's/\*\*\//\*\*\)\*\?\?\\ /g;' # encode **/ as **)*??\
|
||||
|
||||
#Format Newlines and Comment tags
|
||||
AI_CMD_BUILDER_CONVERT := sed -E
|
||||
AI_CMD_BUILDER_CONVERT += -e 's/\\n/\n/g;' # add newlines
|
||||
AI_CMD_BUILDER_CONVERT += -e 's/\?{2}\=/\#/g;' # replace ??= with hash for defines
|
||||
AI_CMD_BUILDER_CONVERT += -e 's/\?{2}\\/\//g;' # replace ??\ with /
|
||||
AI_CMD_BUILDER_CONVERT += -e 's/DEFINE([^D])/\#define\1/g;' # replace DEFINE with #define
|
||||
AI_CMD_BUILDER_CONVERT += -e 's/\\.*/\\/g;' # replace \... with \ (line continuation)
|
||||
AI_CMD_BUILDER_CONVERT += -e 's/\*\(\*/\*/g;' # replace *(* with *
|
||||
AI_CMD_BUILDER_CONVERT += -e 's/\*\)\*/\*/g;' # replace *)* with *
|
||||
AI_CMD_BUILDER_CONVERT += -e 's/MAKE_EXPAND\(([^\n]*)MAKE_EXPAND_END\)/\1/g;' # replace MAKE_EXPAND(CONTENTS) with CONTENTS
|
||||
AI_CMD_BUILDER_CONVERT += -e 's/\?{2}x27/\x27/g;' # replace ??x27 with '
|
||||
AI_CMD_BUILDER_CONVERT += -e 's/\x27\/n\x27/\x27\\n\x27/g;' # replace '/n' with '\n'
|
||||
AI_CMD_BUILDER_CONVERT += -e 's/AI_EndList\s*,/AI_EndList/g;' # replace AI_EndList , with AI_EndList
|
||||
AI_CMD_BUILDER_CONVERT += -e 's/ *(,|;) */\1 /g; ' # remove spaces
|
||||
AI_CMD_BUILDER_CONVERT += -e '/define (AICMDSIZE)|(AI.*_LENGTH)/! s/define ([^ ]*) *\( *([^ ]*)/define \1(\2/g; ' # for each command, remove the space so macro is read as a function
|
||||
AI_CMD_BUILDER_CONVERT += -e '/^typedef/ s/\}/\n\}/g; /^typedef/ s/(; |\{)/\1\n /g;' # for each typedef, break into ALLMAN
|
||||
AI_CMD_BUILDER_CONVERT += -e '/^typedef/ s/(\{)/\n\1/g; /^\s*AI_/ s/,/,\\\n /g' # for each command, break into a list
|
||||
AI_CMD_BUILDER_CONVERT += -e '/^ *$$/d; s/ *\n/\n/g;' # remove surplus newlines
|
||||
|
||||
AI_CMD_LIST_H2_HEADER := \
|
||||
"/******************************************************************************\n\
|
||||
* *\n\
|
||||
* *\n\
|
||||
* Do not edit this file. It was automatically generated by \"cmdbuilder\" *\n\
|
||||
* from the file \"$(AI_CMD_LIST_DEFINITIONS)\". *\n\
|
||||
* To Add/Remove/Modify AI Commands please edit \"$(AI_CMD_LIST_DEFINITIONS)\" *\n\
|
||||
* and then run *\n\
|
||||
* make cmdbuilder *\n\
|
||||
* *\n\
|
||||
* *\n\
|
||||
*****************************************************************************/\n\n"
|
||||
|
||||
|
||||
cmdbuilder:
|
||||
@clear
|
||||
@echo
|
||||
@echo Building AI Command Macros...
|
||||
@echo
|
||||
@$(call SetupProgressBar)
|
||||
@$(call DrawProgressBar,0)
|
||||
@ # copy command definitions to temp
|
||||
@cp $(AI_CMD_LIST_DEFINITIONS) $(AI_CMD_LIST_TEMP)
|
||||
@$(call DrawProgressBar,5)
|
||||
@ # Preformat Definitions for builder (encode documentation tags)
|
||||
@$(call PRINT_STATUS,"Pre Formatting",$(AI_CMD_LIST_DEFINITIONS))
|
||||
@$(AI_CMD_BUILDER_PRECONVERT) $(AI_CMD_LIST_TEMP) > $(AI_CMD_LIST_DEFINITIONS)
|
||||
@$(call DrawProgressBar,10)
|
||||
@ # Print Header
|
||||
@echo $(AI_CMD_LIST_H2_HEADER) > $(AI_CMD_LIST_H2)
|
||||
@$(call DrawProgressBar,11)
|
||||
@ # Execute Builder and format (re-add newlines, documentation tags etc) -C keeps /**/ comments
|
||||
@$(call PRINT_STATUS,"Processing",$(AI_CMD_LIST_DEFINITIONS))
|
||||
@echo This might take some time...
|
||||
@$(CC) -Xcpluscomm -c $(AI_CMD_BUILDER) $(INCLUDE) -w 581 -E | $(AI_CMD_BUILDER_CONVERT) >> $(AI_CMD_LIST_H2) || (cp $(AI_CMD_LIST_TEMP) $(AI_CMD_LIST_DEFINITIONS) ; echo Error with cmdbuilder ; false) & $(call IncrementProgressBarFromAtRate,12,0.5)
|
||||
@$(call DrawProgressBar,98)
|
||||
@ # restore command def from temp (no encoding)
|
||||
@cp $(AI_CMD_LIST_TEMP) $(AI_CMD_LIST_DEFINITIONS)
|
||||
@$(call DrawProgressBar,99)
|
||||
@rm $(AI_CMD_LIST_TEMP)
|
||||
@$(call DrawProgressBar,100)
|
||||
@echo
|
||||
@echo Done!
|
||||
@echo
|
||||
@echo Rebuild AI Command Macros whenever changing aicommands.def.
|
||||
@echo "\n$(BELL)$(RESTORESCROLLREGION2)"
|
||||
|
||||
Reference in New Issue
Block a user