4 echo "$0 game.exe FILES OBJ"
5 echo "extracts ags game files into FILES and script files into OBJ"
6 echo "also a Makefile is created which automatically recompiles"
7 echo "and reinjects changed asm (.s) files into 'game.ags'"
11 test $# -ne 3 && usage
13 BINDIR
=$
(dirname $
(readlink
-f "$0"))
21 $BINDIR/agstract
"$GAME" "$FILES"
22 $BINDIR/agscriptxtract
"$FILES" "$OBJS"
24 DATAFILE
="$FILES"/game28.dta
25 test -e "$DATAFILE" || DATAFILE
="$FILES"/ac2game.dta
26 test -e "$DATAFILE" ||
{ echo "error: none of datafiles game28.dta/ac2game.dta found" 2>&1; exit 1; }
28 # fix timestamps of object files so they're newer than .s
29 for i
in "$OBJS"/*.o
; do touch "$i" ; done
31 # fix timestamps of game files so they're newer than .o
32 for i
in "$FILES"/* ; do touch "$i" ; done
34 MAKEFILE
=$PWD/Makefile
35 cat << EOF > "$MAKEFILE"
39 FILES = \$(sort \$(wildcard \$(FILES_DIR)/*))
41 OBJS = \$(sort \$(wildcard \$(OBJS_DIR)/*.o))
42 SRCS = \$(OBJS:%.o=%.s)
43 OPT_FILES = \$(SRCS:%.s=%.sopt)
48 OPT_FLAGS=-cmp -pushpop -sourceline -lnl -ll -cmp2 -axmar -mrswap
53 agspack \$(FILES_DIR) \$(GAME)
55 optimize: \$(OPT_FILES)
56 \$(foreach file, \$(OPT_FILES), mv \$(file) \$(file:%.sopt=%.s) ; )
60 \$(FILES_DIR)/%.crm: \$(OBJS_DIR)/%.o
63 \$(OBJS_DIR)/%.sopt: \$(OBJS_DIR)/%.s
64 agsoptimize \$(OPT_FLAGS) \$< \$@
66 \$(OBJS_DIR)/%.o: \$(OBJS_DIR)/%.s
67 agssemble \$(AS_FLAGS) \$< \$@
72 for i
in globalscript.o dialogscript.o gamescript
*.o
; do
73 test -e "$i" && printf '\t$(OBJS_DIR)/%s \\\n' "$i" >> "$MAKEFILE" || true
76 cat << EOF >> "$MAKEFILE"
78 \$(GAME_DATA): \$(GAME_DATA_FILES)
79 agsinject -e -t \$(GAME_DATA) 0:\$(OBJS_DIR)/globalscript.o \\
85 printf '\t %d:$(OBJS_DIR)/%s \\\n' $cnt "$i" >> "$MAKEFILE"
89 while test -e gamescript
${ocnt}.o
; do
91 printf '\t %d:$(OBJS_DIR)/%s \\\n' $cnt "$i" >> "$MAKEFILE"
95 printf '\t\n' >> "$MAKEFILE"