changeset 653:469119cab5b2

More cleanup work. Build is broken for now.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 16 Apr 2013 06:18:02 +0300
parents d9888292f971
children 78fdc9c16db9
files Makefile.gen buttons.svg editor/buttons.svg editor/pause.png editor/play1.png editor/play2.png editor/rewind.png editor/stop.png fptest.c pause.png play1.png play2.png rewind.png stop.png tests/fptest.c
diffstat 15 files changed, 297 insertions(+), 273 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.gen	Tue Apr 16 06:04:22 2013 +0300
+++ b/Makefile.gen	Tue Apr 16 06:18:02 2013 +0300
@@ -30,8 +30,11 @@
 
 EDITOR_PRO = editor.pro
 EDITOR_MAKEFILE = Makefile.editor
-EDITOR_SOURCES = edmain.cpp edgui.cpp edview.cpp edtlobj.cpp edtimeline.cpp edwaveform.cpp edres.cpp
-EDITOR_HEADERS = edmain.h edtlobj.h edview.h edtimeline.h edwaveform.h edres.h
+EDITOR_SOURCES = editor/edmain.cpp editor/edgui.cpp editor/edview.cpp \
+	editor/edtlobj.cpp editor/edtimeline.cpp editor/edwaveform.cpp \
+	editor/edres.cpp
+EDITOR_HEADERS = editor/edmain.h editor/edtlobj.h editor/edview.h \
+	editor/edtimeline.h editor/edwaveform.h editor/edres.h
 
 
 ###
@@ -122,7 +125,7 @@
 ifeq ($(DM_BUILD_TESTS),yes)
 ifeq ($(DM_GFX_BLITS),yes)
 ifeq ($(DM_USE_STDIO),yes)
-BINARIES += blittest vptest efu
+TESTS_BINARIES += blittest vptest efu
 endif
 endif
 endif
@@ -212,7 +215,8 @@
 ifeq ($(DM_USE_STDIO),yes)
 TOOL_BINARIES+= objlink data2inc gfxconv gentab
 ifeq ($(SUP_MODLOAD),yes)
-TOOL_BINARIES+= viewmod mod2wav testpl
+TOOL_BINARIES+= viewmod mod2wav
+TESTS_BINARIES+= testpl
 ifeq ($(DM_GFX_BLITS),yes)
 TOOL_BINARIES+= view64
 ifeq ($(DM_GFX_BM_TEXT),yes)
@@ -232,6 +236,14 @@
 DM_CFLAGS += -DDM_USE_LIBPNG $(LIBPNG_CFLAGS) $(ZLIB_CFLAGS)
 endif
 
+ifeq ($(DM_BUILD_TESTS),yes)
+TESTS_BINARIES += vecmattest fptest
+endif
+
+FONTCONV_BIN=$(BINPATH)fontconv$(EXEEXT)
+DATA2INC_BIN=$(BINPATH)data2inc$(EXEEXT)
+
+
 ###
 ### Rest of the rules
 ###
@@ -243,35 +255,46 @@
 
 
 DMLIB_A=$(OBJPATH)dmlib.a
-DMLIB_OBJS += dmfile.o dmbstr.o dmlib.o dmlerp.o dmstring.o \
+DMLIB_OBJS += \
+	dmfile.o dmbstr.o dmlib.o dmlerp.o dmstring.o \
 	dmargs.o dmvecmat.o dmperlin.o dmimage.o \
-	dmwav.o	dmengine.o  dmq3d.o
+	dmwav.o	dmengine.o dmq3d.o
 
-ifeq ($(DM_BUILD_TESTS),yes)
-BINARIES += vecmattest fptest
-endif
 
-FONTCONV_BIN=$(BINPATH)fontconv$(EXEEXT)
-DATA2INC_BIN=$(BINPATH)data2inc$(EXEEXT)
-
+TESTS_TARGETS = $(addprefix $(BINPATH),$(addsuffix $(EXEEXT),$(TESTS_BINARIES)))
 TOOL_TARGETS = $(addprefix $(BINPATH),$(addsuffix $(EXEEXT),$(TOOL_BINARIES)))
-TARGETS += $(DMLIB_A) $(addprefix $(BINPATH),$(addsuffix $(EXEEXT),$(BINARIES))) $(TOOL_TARGETS)
+TARGETS += $(DMLIB_A) $(addprefix $(BINPATH),$(addsuffix $(EXEEXT),$(BINARIES))) \
+	$(TOOL_TARGETS) $(TESTS_TARGETS)
 
 all: $(TARGETS)
 
 ###
 ### Generic rules
 ###
-$(OBJPATH)gtk%.o: $(DMLIB)gtk%.c $(DMLIB)gtk%.h
-	@echo " CC $+"
-	@$(CC) $(CFLAGS) -c -o $@ $< $(DM_CFLAGS) $(GTK_CFLAGS)
-
-
 $(OBJPATH)%.d: $(DMLIB)%.c
 	@echo > $@
 	@grep '#\s*include\s*\"' $< | sed 's/#\s*include\s\s*"\(.*\)"/\1/' | while read i; do if test -e "$$i"; then echo "$$i" >> $@; fi; done
 
 
+$(OBJPATH)%.o: $(DMLIB)tests/%.c $(DMLIB)tests/%.h
+	@echo " CC $<"
+	@$(CC) $(CFLAGS) -c -o $@ $< $(DM_CFLAGS)
+
+$(OBJPATH)%.o: $(DMLIB)tests/%.c
+	@echo " CC $<"
+	@$(CC) $(CFLAGS) -c -o $@ $< $(DM_CFLAGS)
+
+
+$(OBJPATH)%.o: $(DMLIB)tools/%.c $(DMLIB)tools/%.h
+	@echo " CC $<"
+	@$(CC) $(CFLAGS) -c -o $@ $< $(DM_CFLAGS)
+
+$(OBJPATH)%.o: $(DMLIB)tools/%.c
+	@echo " CC $<"
+	@$(CC) $(CFLAGS) -c -o $@ $< $(DM_CFLAGS)
+
+
+
 $(OBJPATH)%.o: $(DMLIB)%.c $(DMLIB)%.h
 	@echo " CC $<"
 	@$(CC) $(CFLAGS) -c -o $@ $< $(DM_CFLAGS)
@@ -375,6 +398,11 @@
 	@echo " LINK $+"
 	@$(CC) -o $@ $(filter %.o %.a,$+) $(DM_LDFLAGS) -lm
 
+$(BINPATH)testpl$(EXEEXT): $(OBJPATH)testpl.o $(DMLIB_A)
+	@echo " LINK $+"
+	@$(CC) -o $@ $(filter %.o %.a,$+) $(DM_LDFLAGS) $(SDL_LDFLAGS)
+
+
 $(BINPATH)packed$(EXEEXT): $(OBJPATH)packed.o $(DMLIB_A)
 	@echo " LINK $+"
 	@$(CC) -o $@ $(filter %.o %.a,$+) $(DM_LDFLAGS)
@@ -402,10 +430,6 @@
 	@$(CC) -o $@ $(filter %.o %.a,$+) $(DM_LDFLAGS) $(SDL_LDFLAGS)
 
 
-$(BINPATH)testpl$(EXEEXT): $(OBJPATH)testpl.o $(DMLIB_A)
-	@echo " LINK $+"
-	@$(CC) -o $@ $(filter %.o %.a,$+) $(DM_LDFLAGS) $(SDL_LDFLAGS)
-
 $(BINPATH)$(DEMO_BIN)$(EXEEXT): $(addprefix $(OBJPATH),$(DEMO_OBJS)) $(DMLIB_A)
 	@echo " LINK $+"
 	@$(CC) -o $@ $(filter %.o %.a,$+) $(DM_LDFLAGS) $(SDL_LDFLAGS)
--- a/buttons.svg	Tue Apr 16 06:04:22 2013 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,152 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
-   xmlns:dc="http://purl.org/dc/elements/1.1/"
-   xmlns:cc="http://creativecommons.org/ns#"
-   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-   xmlns:svg="http://www.w3.org/2000/svg"
-   xmlns="http://www.w3.org/2000/svg"
-   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
-   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
-   width="32"
-   height="32"
-   id="svg2"
-   version="1.1"
-   inkscape:version="0.48.3.1 r9886"
-   sodipodi:docname="buttons.svg"
-   inkscape:export-filename="/home/ccr/4-po-dmt/dmlib/pause.png"
-   inkscape:export-xdpi="90"
-   inkscape:export-ydpi="90">
-  <defs
-     id="defs4" />
-  <sodipodi:namedview
-     id="base"
-     pagecolor="#ffffff"
-     bordercolor="#666666"
-     borderopacity="1.0"
-     inkscape:pageopacity="0.0"
-     inkscape:pageshadow="2"
-     inkscape:zoom="14.640625"
-     inkscape:cx="12.755351"
-     inkscape:cy="18.307383"
-     inkscape:document-units="px"
-     inkscape:current-layer="g2993"
-     showgrid="true"
-     inkscape:window-width="1278"
-     inkscape:window-height="992"
-     inkscape:window-x="0"
-     inkscape:window-y="0"
-     inkscape:window-maximized="0">
-    <inkscape:grid
-       type="xygrid"
-       id="grid3757"
-       empspacing="4"
-       visible="true"
-       enabled="true"
-       snapvisiblegridlinesonly="true" />
-  </sodipodi:namedview>
-  <metadata
-     id="metadata7">
-    <rdf:RDF>
-      <cc:Work
-         rdf:about="">
-        <dc:format>image/svg+xml</dc:format>
-        <dc:type
-           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
-        <dc:title></dc:title>
-      </cc:Work>
-    </rdf:RDF>
-  </metadata>
-  <g
-     inkscape:label="play"
-     inkscape:groupmode="layer"
-     id="layer1"
-     transform="translate(0,-1020.3622)"
-     style="display:none"
-     sodipodi:insensitive="true">
-    <path
-       style="fill:#888888;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
-       d="m 4.9999997,1046.3622 0,-20 20.0000003,10 z"
-       id="path3753"
-       inkscape:connector-curvature="0"
-       sodipodi:nodetypes="cccc" />
-  </g>
-  <g
-     style="display:none"
-     transform="translate(0,-1020.3622)"
-     id="g3831"
-     inkscape:groupmode="layer"
-     inkscape:label="play copy"
-     sodipodi:insensitive="true">
-    <path
-       sodipodi:nodetypes="cccc"
-       inkscape:connector-curvature="0"
-       id="path3833"
-       d="m 12,1046.3622 0,-20 16,10 z"
-       style="fill:#888888;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
-    <path
-       style="fill:#888888;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;display:inline"
-       d="m 6,1046.3622 0,-20 4,0 0,20 z"
-       id="path3753-6-6-8"
-       inkscape:connector-curvature="0"
-       sodipodi:nodetypes="ccccc" />
-  </g>
-  <g
-     style="display:none"
-     transform="translate(0,-1020.3622)"
-     id="g3780"
-     inkscape:groupmode="layer"
-     inkscape:label="rewind"
-     sodipodi:insensitive="true">
-    <path
-       sodipodi:nodetypes="cccc"
-       inkscape:connector-curvature="0"
-       id="path3782"
-       d="m 26,1046.3622 0,-20 -20.0000003,10 z"
-       style="fill:#888888;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
-    <path
-       sodipodi:nodetypes="cccc"
-       inkscape:connector-curvature="0"
-       id="path3782-0"
-       d="m 21,1046.3622 0,-20 -15,10 z"
-       style="fill:#888888;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.86602539;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;display:inline" />
-    <path
-       style="fill:#888888;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;display:inline"
-       d="m 5,1046.3622 0,-20 4,0 0,20 z"
-       id="path3753-6-6"
-       inkscape:connector-curvature="0"
-       sodipodi:nodetypes="ccccc" />
-  </g>
-  <g
-     inkscape:groupmode="layer"
-     id="layer2"
-     inkscape:label="stop"
-     style="display:none"
-     sodipodi:insensitive="true">
-    <path
-       style="fill:#888888;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
-       d="M 6,26 6,6 26,6 26,26 z"
-       id="path3753-6"
-       inkscape:connector-curvature="0"
-       sodipodi:nodetypes="ccccc" />
-  </g>
-  <g
-     style="display:inline"
-     inkscape:label="pause"
-     id="g2993"
-     inkscape:groupmode="layer">
-    <path
-       sodipodi:nodetypes="ccccc"
-       inkscape:connector-curvature="0"
-       id="path2995"
-       d="M 7,26 7,6 14,6 14,26 z"
-       style="fill:#888888;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
-    <path
-       sodipodi:nodetypes="ccccc"
-       inkscape:connector-curvature="0"
-       id="path2995-6"
-       d="m 17,26 0,-20 7,0 0,20 z"
-       style="fill:#888888;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;display:inline" />
-  </g>
-</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/editor/buttons.svg	Tue Apr 16 06:18:02 2013 +0300
@@ -0,0 +1,152 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="32"
+   height="32"
+   id="svg2"
+   version="1.1"
+   inkscape:version="0.48.3.1 r9886"
+   sodipodi:docname="buttons.svg"
+   inkscape:export-filename="/home/ccr/4-po-dmt/dmlib/pause.png"
+   inkscape:export-xdpi="90"
+   inkscape:export-ydpi="90">
+  <defs
+     id="defs4" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="14.640625"
+     inkscape:cx="12.755351"
+     inkscape:cy="18.307383"
+     inkscape:document-units="px"
+     inkscape:current-layer="g2993"
+     showgrid="true"
+     inkscape:window-width="1278"
+     inkscape:window-height="992"
+     inkscape:window-x="0"
+     inkscape:window-y="0"
+     inkscape:window-maximized="0">
+    <inkscape:grid
+       type="xygrid"
+       id="grid3757"
+       empspacing="4"
+       visible="true"
+       enabled="true"
+       snapvisiblegridlinesonly="true" />
+  </sodipodi:namedview>
+  <metadata
+     id="metadata7">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="play"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(0,-1020.3622)"
+     style="display:none"
+     sodipodi:insensitive="true">
+    <path
+       style="fill:#888888;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+       d="m 4.9999997,1046.3622 0,-20 20.0000003,10 z"
+       id="path3753"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="cccc" />
+  </g>
+  <g
+     style="display:none"
+     transform="translate(0,-1020.3622)"
+     id="g3831"
+     inkscape:groupmode="layer"
+     inkscape:label="play copy"
+     sodipodi:insensitive="true">
+    <path
+       sodipodi:nodetypes="cccc"
+       inkscape:connector-curvature="0"
+       id="path3833"
+       d="m 12,1046.3622 0,-20 16,10 z"
+       style="fill:#888888;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
+    <path
+       style="fill:#888888;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;display:inline"
+       d="m 6,1046.3622 0,-20 4,0 0,20 z"
+       id="path3753-6-6-8"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="ccccc" />
+  </g>
+  <g
+     style="display:none"
+     transform="translate(0,-1020.3622)"
+     id="g3780"
+     inkscape:groupmode="layer"
+     inkscape:label="rewind"
+     sodipodi:insensitive="true">
+    <path
+       sodipodi:nodetypes="cccc"
+       inkscape:connector-curvature="0"
+       id="path3782"
+       d="m 26,1046.3622 0,-20 -20.0000003,10 z"
+       style="fill:#888888;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
+    <path
+       sodipodi:nodetypes="cccc"
+       inkscape:connector-curvature="0"
+       id="path3782-0"
+       d="m 21,1046.3622 0,-20 -15,10 z"
+       style="fill:#888888;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.86602539;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;display:inline" />
+    <path
+       style="fill:#888888;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;display:inline"
+       d="m 5,1046.3622 0,-20 4,0 0,20 z"
+       id="path3753-6-6"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="ccccc" />
+  </g>
+  <g
+     inkscape:groupmode="layer"
+     id="layer2"
+     inkscape:label="stop"
+     style="display:none"
+     sodipodi:insensitive="true">
+    <path
+       style="fill:#888888;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+       d="M 6,26 6,6 26,6 26,26 z"
+       id="path3753-6"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="ccccc" />
+  </g>
+  <g
+     style="display:inline"
+     inkscape:label="pause"
+     id="g2993"
+     inkscape:groupmode="layer">
+    <path
+       sodipodi:nodetypes="ccccc"
+       inkscape:connector-curvature="0"
+       id="path2995"
+       d="M 7,26 7,6 14,6 14,26 z"
+       style="fill:#888888;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
+    <path
+       sodipodi:nodetypes="ccccc"
+       inkscape:connector-curvature="0"
+       id="path2995-6"
+       d="m 17,26 0,-20 7,0 0,20 z"
+       style="fill:#888888;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;display:inline" />
+  </g>
+</svg>
Binary file editor/pause.png has changed
Binary file editor/play1.png has changed
Binary file editor/play2.png has changed
Binary file editor/rewind.png has changed
Binary file editor/stop.png has changed
--- a/fptest.c	Tue Apr 16 06:04:22 2013 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-#include "dmlib.h"
-#include <stdio.h>
-
-#define FP_DW_SIZE 8
-#define FP_W0_SIZE 4
-
-void check(const char *str, DMFixedPoint v, Sint64 dw)
-{
-    DMFixedPoint *q = (DMFixedPoint *) &dw;
-
-    printf("%-15s = ", str); FP_PRINTF(v); printf("\n");
-    printf("should be       = "); FP_PRINTF((*q)); printf("\n");
-
-    if (v.dw != dw)
-    {
-        printf("ERROR! A test value differs from expected!\n");
-        exit(1);
-    }
-}
-
-int main(int argc, char *argv[])
-{
-    int i;
-    DMFixedPoint a, b, delta;
-    char *s;
-
-    (void) argc;
-    (void) argv;
-
-    // Check host characteristics
-    switch (SDL_BYTEORDER)
-    {
-        case SDL_BIG_ENDIAN: s = "big endian"; break;
-        case SDL_LIL_ENDIAN: s = "little endian"; break;
-        default: s = "unknown?"; break;
-    }
-    
-    printf(
-    "SDL byte order            = %s (%d)\n\n", s, SDL_BYTEORDER);
-    
-    printf(
-    "sizeof(DMFixedPoint)      = %d bytes\n"
-    "sizeof(DMFixedPoint.dw    = %d bytes (should be %d)\n"
-    "sizeof(DMFixedPoint.w[0]  = %d bytes (should be %d)\n",
-    sizeof(a), sizeof(a.dw), FP_DW_SIZE,
-    sizeof(a.w[0]), FP_W0_SIZE);
-    
-    if (sizeof(a.dw) != FP_DW_SIZE || sizeof(a.w[0]) != FP_W0_SIZE)
-    {
-        printf("ERROR! Some type sizes DO NOT MATCH!\n");
-        return -1;
-    }
-    
-    // TEST #1
-    printf("\nTEST #1: set initial values\n");
-    FP_SETHL(a, 55, 0);
-    check("a", a, 0x0000003700000000ULL);
-
-    FP_CONV(b, 178);
-    check("b", b, 0x00000000000000b2ULL);
-
-    FP_DIV_R(delta, a, b);
-    check("delta", delta, 0x000000004f19e33cULL);
-
-    // Test #2
-    printf("\nTEST #2: 50 x (a + delta)\n");
-    for (i = 0; i < 50; i++)
-    {
-        FP_ADD(a, delta);
-    }
-    check("a end", a, 0x00000046730e61b8ULL);
-
-
-    // Test #3
-    printf("\nTEST #3: 50 x (a - delta)\n");
-    for (i = 0; i < 50; i++)
-    {
-        FP_SUB(a, delta);
-    }
-    check("a end", a, 0x0000003700000000ULL);
-
-    // Test #4
-    printf("\nTEST #4: 5 x (a * delta)\n");
-    for (i = 0; i < 5; i++)
-    {
-        FP_MUL(a, delta);
-    }
-    check("a end", a, 0xd644e40000000000ULL);
-
-    // Test #5
-    printf("\nTEST #4: 2 x (a / delta)\n");
-    for (i = 0; i < 2; i++)
-    {
-        FP_DIV(a, delta);
-    }
-    check("a end", a, 8ULL);
-
-    return 0;
-}
Binary file pause.png has changed
Binary file play1.png has changed
Binary file play2.png has changed
Binary file rewind.png has changed
Binary file stop.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fptest.c	Tue Apr 16 06:18:02 2013 +0300
@@ -0,0 +1,99 @@
+#include "dmlib.h"
+#include <stdio.h>
+
+#define FP_DW_SIZE 8
+#define FP_W0_SIZE 4
+
+void check(const char *str, DMFixedPoint v, Sint64 dw)
+{
+    DMFixedPoint *q = (DMFixedPoint *) &dw;
+
+    printf("%-15s = ", str); FP_PRINTF(v); printf("\n");
+    printf("should be       = "); FP_PRINTF((*q)); printf("\n");
+
+    if (v.dw != dw)
+    {
+        printf("ERROR! A test value differs from expected!\n");
+        exit(1);
+    }
+}
+
+int main(int argc, char *argv[])
+{
+    int i;
+    DMFixedPoint a, b, delta;
+    char *s;
+
+    (void) argc;
+    (void) argv;
+
+    // Check host characteristics
+    switch (SDL_BYTEORDER)
+    {
+        case SDL_BIG_ENDIAN: s = "big endian"; break;
+        case SDL_LIL_ENDIAN: s = "little endian"; break;
+        default: s = "unknown?"; break;
+    }
+    
+    printf(
+    "SDL byte order            = %s (%d)\n\n", s, SDL_BYTEORDER);
+    
+    printf(
+    "sizeof(DMFixedPoint)      = %d bytes\n"
+    "sizeof(DMFixedPoint.dw    = %d bytes (should be %d)\n"
+    "sizeof(DMFixedPoint.w[0]  = %d bytes (should be %d)\n",
+    sizeof(a), sizeof(a.dw), FP_DW_SIZE,
+    sizeof(a.w[0]), FP_W0_SIZE);
+    
+    if (sizeof(a.dw) != FP_DW_SIZE || sizeof(a.w[0]) != FP_W0_SIZE)
+    {
+        printf("ERROR! Some type sizes DO NOT MATCH!\n");
+        return -1;
+    }
+    
+    // TEST #1
+    printf("\nTEST #1: set initial values\n");
+    FP_SETHL(a, 55, 0);
+    check("a", a, 0x0000003700000000ULL);
+
+    FP_CONV(b, 178);
+    check("b", b, 0x00000000000000b2ULL);
+
+    FP_DIV_R(delta, a, b);
+    check("delta", delta, 0x000000004f19e33cULL);
+
+    // Test #2
+    printf("\nTEST #2: 50 x (a + delta)\n");
+    for (i = 0; i < 50; i++)
+    {
+        FP_ADD(a, delta);
+    }
+    check("a end", a, 0x00000046730e61b8ULL);
+
+
+    // Test #3
+    printf("\nTEST #3: 50 x (a - delta)\n");
+    for (i = 0; i < 50; i++)
+    {
+        FP_SUB(a, delta);
+    }
+    check("a end", a, 0x0000003700000000ULL);
+
+    // Test #4
+    printf("\nTEST #4: 5 x (a * delta)\n");
+    for (i = 0; i < 5; i++)
+    {
+        FP_MUL(a, delta);
+    }
+    check("a end", a, 0xd644e40000000000ULL);
+
+    // Test #5
+    printf("\nTEST #4: 2 x (a / delta)\n");
+    for (i = 0; i < 2; i++)
+    {
+        FP_DIV(a, delta);
+    }
+    check("a end", a, 8ULL);
+
+    return 0;
+}