- fixed typos in csprite's code generator for nasm
authorJohn Tsiombikas <nuclear@member.fsf.org>
Thu, 19 Dec 2019 02:12:31 +0000 (04:12 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Thu, 19 Dec 2019 02:12:31 +0000 (04:12 +0200)
- integrated (in the UNIX build only) automatic generation of compiled
  sprites with csprite
- converted the UNIX build to 32bit, to allow using the same assembly
  code as with the DOS version (again for compiled sprites mostly)

.gitignore
GNUmakefile
libs/anim/GNUmakefile
libs/imago/GNUmakefile
libs/mikmod/GNUmakefile
tools/csprite/src/main.c

index 33467bd..afb00f8 100644 (file)
@@ -38,3 +38,5 @@ data
 *.COF
 *.dja
 *.DJA
 *.COF
 *.dja
 *.DJA
+tools/csprite/csprite
+font.asm
index 199fc30..1ee0a1e 100644 (file)
@@ -3,11 +3,20 @@ obj = $(src:.c=.o) $(asmsrc:.asm=.o)
 dep = $(obj:.o=.d)
 bin = demo
 
 dep = $(obj:.o=.d)
 bin = demo
 
+asmsrc += font.asm
+
 inc = -I/usr/local/include -Isrc -Isrc/scr -Isrc/sdl -Ilibs -Ilibs/imago/src -Ilibs/mikmod/include
 warn = -pedantic -Wall -Wno-unused-variable -Wno-unused-function
 
 inc = -I/usr/local/include -Isrc -Isrc/scr -Isrc/sdl -Ilibs -Ilibs/imago/src -Ilibs/mikmod/include
 warn = -pedantic -Wall -Wno-unused-variable -Wno-unused-function
 
-CFLAGS = $(warn) -g $(inc) `sdl-config --cflags`
-LDFLAGS = -Llibs/imago -Llibs/mikmod -limago -lmikmod `sdl-config --libs` -lm
+CFLAGS = $(arch) $(warn) -g $(inc) `sdl-config --cflags`
+LDFLAGS = $(arch) -Llibs/imago -Llibs/mikmod -limago -lmikmod $(sdl_ldflags) -lm
+
+ifneq ($(shell uname -m), i386)
+       arch = -m32
+       sdl_ldflags = -L/usr/lib/i386-linux-gnu -lSDL
+else
+       sdl_ldflags = `sdl-config --libs`
+endif
 
 $(bin): $(obj) imago mikmod
        $(CC) -o $@ $(obj) $(LDFLAGS)
 
 $(bin): $(obj) imago mikmod
        $(CC) -o $@ $(obj) $(LDFLAGS)
@@ -18,6 +27,7 @@ $(bin): $(obj) imago mikmod
 -include $(dep)
 
 %.d: %.c
 -include $(dep)
 
 %.d: %.c
+       @echo dep $@
        @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
 
 .PHONY: imago
        @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
 
 .PHONY: imago
@@ -40,3 +50,9 @@ clean:
 .PHONY: cleandep
 cleandep:
        rm -f $(dep)
 .PHONY: cleandep
 cleandep:
        rm -f $(dep)
+
+tools/csprite/csprite:
+       $(MAKE) -C tools/csprite
+
+font.asm: data/font.png tools/csprite/csprite
+       tools/csprite/csprite -n font -s 16x16 -r 288x32+32+17 -conv565 -nasm $< >$@
index b795392..55fe6c0 100644 (file)
@@ -2,7 +2,7 @@ src = $(wildcard src/*.c)
 obj = $(src:.c=.o)
 alib = libanim.a
 
 obj = $(src:.c=.o)
 alib = libanim.a
 
-CFLAGS = -Wno-main -g -I.. -I../../src
+CFLAGS = -m32 -Wno-main -g -I.. -I../../src
 
 $(alib): $(obj)
        $(AR) rcs $@ $(obj)
 
 $(alib): $(obj)
        $(AR) rcs $@ $(obj)
index 2c73904..8940d2a 100644 (file)
@@ -5,7 +5,7 @@ src = $(wildcard src/*.c) \
 obj = $(src:.c=.o)
 alib = libimago.a
 
 obj = $(src:.c=.o)
 alib = libimago.a
 
-CFLAGS = -Wno-main -g -Izlib -Ilibpng -Ijpeglib
+CFLAGS = -m32 -Wno-main -g -Izlib -Ilibpng -Ijpeglib
 
 $(alib): $(obj)
        $(AR) rcs $@ $(obj)
 
 $(alib): $(obj)
        $(AR) rcs $@ $(obj)
index a6f162b..9f472ff 100644 (file)
@@ -10,7 +10,7 @@ alib = libmikmod.a
 def = -DHAVE_CONFIG_H -DMIKMOD_BUILD
 inc = -I. -Iinclude
 warn = -pedantic -Wall -Wno-unused-variable -Wno-unused-function
 def = -DHAVE_CONFIG_H -DMIKMOD_BUILD
 inc = -I. -Iinclude
 warn = -pedantic -Wall -Wno-unused-variable -Wno-unused-function
-CFLAGS = $(warn) -g $(def) $(inc) `pkg-config --cflags sdl`
+CFLAGS = -m32 $(warn) -g $(def) $(inc) `pkg-config --cflags sdl`
 
 $(alib): $(obj)
        $(AR) rcs $@ $(obj)
 
 $(alib): $(obj)
        $(AR) rcs $@ $(obj)
index f0880b8..5bece2d 100644 (file)
@@ -126,10 +126,10 @@ const char *prefixfmt[] = {
        "tiletab:\n",
 
        /* NASM template */
        "tiletab:\n",
 
        /* NASM template */
-       "\tglobl %s\n"
+       "\tglobal %s\n"
        "%s:\n"
        "\tmov eax, [esp + 12]\n"
        "%s:\n"
        "\tmov eax, [esp + 12]\n"
-       "\tmov ecx. %d\n"
+       "\tmov ecx, %d\n"
        "\tmul ecx\n"
        "\tadd eax, [esp + 8]\n"
        "\tadd eax, [esp + 4]\n"
        "\tmul ecx\n"
        "\tadd eax, [esp + 8]\n"
        "\tadd eax, [esp + 4]\n"