changeset 40:9cbb03e85597

Update to latest dmlib API changes.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 13 Apr 2013 02:16:31 +0300
parents 57d67886153e
children 78e0daf6f6af
files Makefile Makefile.gwin build-data.sh config.mak krapula.c
diffstat 5 files changed, 98 insertions(+), 71 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Tue Oct 16 03:24:47 2012 +0300
+++ b/Makefile	Sat Apr 13 02:16:31 2013 +0300
@@ -4,6 +4,15 @@
 SDL_CFLAGS=`sdl-config --cflags`
 SDL_LDFLAGS=`sdl-config --static-libs`
 
+TREMOR_CFLAGS=-I/usr/local/lib/
+TREMOR_LDFLAGS=/usr/local/lib/libvorbisidec.a /usr/lib/i386-linux-gnu/libogg.a
+
+LIBPNG_CFLAGS=`pkg-config --cflags libpng`
+LIBPNG_LDFLAGS=`pkg-config --libs libpng`
+
+ZLIB_CFLAGS=`pkg-config --cflags zlib`
+ZLIB_LDFLAGS=`pkg-config --libs zlib`
+
 RANLIB=ranlib
 
 DMLIB = ./dmlib/
--- a/Makefile.gwin	Tue Oct 16 03:24:47 2012 +0300
+++ b/Makefile.gwin	Sat Apr 13 02:16:31 2013 +0300
@@ -14,6 +14,15 @@
 SDL_CFLAGS=`$(MINGW_PATH)/bin/sdl-config --cflags`
 SDL_LDFLAGS=`$(MINGW_PATH)/bin/sdl-config --libs` -lSDL -L$(BINPATH)
 
+TREMOR_CFLAGS=-I$(MINGW_PATH)/include/tremor
+TREMOR_LDFLAGS=$(MINGW_PATH)/lib/libvorbisidec.a  $(MINGW_PATH)/lib/libogg.a
+
+LIBPNG_CFLAGS=-I$(MINGW_PATH)/include
+LIBPNG_LDFLAGS=$(MINGW_PATH)/lib/libpng.a
+
+ZLIB_CFLAGS=
+ZLIB_LDFLAGS=$(MINGW_PATH)/lib/libz.a
+
 #CFLAGS=-mwindows
 LDFLAGS=-lmingw32 -s
 
--- a/build-data.sh	Tue Oct 16 03:24:47 2012 +0300
+++ b/build-data.sh	Sat Apr 13 02:16:31 2013 +0300
@@ -5,7 +5,7 @@
 
 if test ! -x "$CPACKED"; then
 	make -f Makefile clean
-	make -f Makefile EXEEXT=".bin" BINPATH="$CPWD" "$CPACKED"
+	make -f Makefile EXEEXT=".bin" BINPATH="$CPWD/" "$CPACKED"
 fi
 
 cd "$CPWD/data" && $CPACKED -c -p "$CPWD/exe/$CPACKFILE" *
--- a/config.mak	Tue Oct 16 03:24:47 2012 +0300
+++ b/config.mak	Sat Apr 13 02:16:31 2013 +0300
@@ -1,6 +1,6 @@
 # Additional binaries (aka the demo)
 DEMO_BIN=krapula
-DEMO_OBJS=dmsimple.o
+DEMO_OBJS=krapula.o dmsimple.o
 BINARIES=$(DEMO_BIN)
 
 # Build engine tests and tools? (Please notice that what
@@ -8,6 +8,12 @@
 DM_BUILD_TESTS=no
 DM_BUILD_TOOLS=yes
 
+# Timeline support? (required for editor and complex demos)
+DM_USE_TIMELINE=no
+
+# Build Qt based demo editor?
+DM_BUILD_EDITOR=no
+
 # Build with runtime asserts?
 DM_USE_ASSERTS=yes
 
@@ -24,6 +30,7 @@
 DM_USE_MEMIO=no
 
 
+DM_GFX_BM_TEXT=yes
 DM_GFX_TTF_TEXT=no
 DM_GFX_LINES=no
 DM_GFX_BLITS=yes
--- a/krapula.c	Tue Oct 16 03:24:47 2012 +0300
+++ b/krapula.c	Sat Apr 13 02:16:31 2013 +0300
@@ -328,32 +328,33 @@
 SDL_Surface *nosfe[NOSFE_MAX - NOSFE_MIN + 1];
 
 
-int demoPreInit()
+int demoPreInit(DMEngineData *engine)
 {
     dmInitProg("krapula",
         "Lauantai Aamun Krapula",
         "0.2", "(c) 2012 Anciat Prodz & TNSP", "PENIS.");
 
-    engine.optPackFilename = "orvellys.dat";
-    engine.optDataPath  = NULL;
-    engine.optResFlags  = DRF_USE_PACK | DRF_PRELOAD_RES;
+    engine->optPackFilename = "orvellys.dat";
+    engine->optDataPath  = NULL;
+    engine->optResFlags  = DRF_USE_PACK | DRF_PRELOAD_RES;
 
-    engine.optScrWidth  = 640;
-    engine.optScrHeight = 480;
-    engine.optBitDepth  = 32;
-    engine.optVFlags    = SDL_SWSURFACE | SDL_HWPALETTE;
+    engine->optVidSetup  = DM_VSETUP_ASPECT;
+    engine->optVidWidth  = 640;
+    engine->optVidHeight = 480;
+    engine->optVidDepth  = 32;
+    engine->optVFlags    = SDL_SWSURFACE;
 
 
-    engine.demoInit = demoInit;
-    engine.demoRender = demoRender;
-    engine.demoShutdown = demoShutdown;
-    engine.demoQuit = demoQuit;
+    engine->demoInit = demoInit;
+    engine->demoRender = demoRender;
+    engine->demoShutdown = demoShutdown;
+    engine->demoQuit = demoQuit;
 
     return DMERR_OK;
 }
 
 
-static int demoInit()
+static int demoInit(DMEngineData *engine)
 {
     int i;
 
@@ -364,18 +365,18 @@
     {
         char fname[32];
         snprintf(fname, sizeof(fname), "%08d.jpg", NOSFE_MIN + i);
-        engineGetResImage(nosfe[i], fname);
+        engineGetResImage(engine, nosfe[i], fname);
     }
 
     for (i = 0; i < ncredits; i++)
-        engineGetResImage(credits[i].img, credits[i].filename);
+        engineGetResImage(engine, credits[i].img, credits[i].filename);
 
     bmap = SDL_CreateRGBSurface(SDL_SWSURFACE, QWIDTH, QHEIGHT, 8, 0, 0, 0, 0);
 
 
     // Initialize music player
     JSSModule *mod = NULL;
-    engineGetResModule(mod, "krapula.xm");
+    engineGetResModule(engine, mod, "krapula.xm");
 
     if ((i = jssConvertModuleForPlaying(mod)) != DMERR_OK)
     {
@@ -384,17 +385,18 @@
         return DMERR_INIT_FAIL;
     }
     
-    jvmSetCallback(engine.dev, jmpExec, engine.plr);
-    jmpSetModule(engine.plr, mod);
-    jmpPlayOrder(engine.plr, 0);
-    jvmSetGlobalVol(engine.dev, 55);
+    jvmSetCallback(engine->dev, jmpExec, engine->plr);
+    jmpSetModule(engine->plr, mod);
+    jmpPlayOrder(engine->plr, 0);
+    jvmSetGlobalVol(engine->dev, 55);
 
     return DMERR_OK;
 }
 
 
-static void demoShutdown()
+static void demoShutdown(DMEngineData *engine)
 {
+    (void) engine;
     SDL_FreeSurface(bmap);
 }
 
@@ -405,13 +407,13 @@
 }
 
 
-static int demoRender()
+static int demoRender(DMEngineData *engine)
 {
-    float t = engineGetTimeDT();
+    float t = engineGetTimeDT(engine);
 
     if (t < 5)
     {
-        int dt = engineGetTime(0);
+        int dt = engineGetTime(engine, 0);
         static SDL_Surface *anciat;
         static DMLerpContext lerpX, lerpY, lerpD;
         static DMScaledBlitFunc nblit;
@@ -419,8 +421,8 @@
         static BOOL nollattu = FALSE;
         if (!nollattu)
         {
-            engineGetResImage(anciat, "anciat.png");
-            nblit = dmGetScaledBlitFunc(bmap->format, engine.screen->format, DMD_NONE);
+            engineGetResImage(engine, anciat, "anciat.png");
+            nblit = dmGetScaledBlitFunc(bmap->format, engine->screen->format, DMD_NONE);
             dmMakePalette(bmap);
             dmLerpInit(&lerpX, 0, QWIDTH, 5000);
             dmLerpInit(&lerpY, QHEIGHT * 0.25, QHEIGHT * 0.75, 5000);
@@ -433,12 +435,12 @@
         light.z = 128;
 
         dmShadowTraceHeightMap2(bmap->pixels, anciat->pixels, &light);
-        nblit(bmap, 0, 0, engine.screen->w, engine.screen->h, engine.screen);
+        nblit(bmap, 0, 0, engine->screen->w, engine->screen->h, engine->screen);
     }
     else
     if (t < 10)
     {
-        int dt = engineGetTime(5);
+        int dt = engineGetTime(engine, 5);
         static SDL_Surface *logobg, *logolayer1, *logolayer2;
         static DMScaledBlitFunc nblit, kblit;
         static DMLerpContext lerpD;
@@ -446,12 +448,12 @@
 
         if (!nollattu)
         {
-            engineGetResImage(logobg, "logobg.png");
-            engineGetResImage(logolayer1, "logolayer1.png");
-            engineGetResImage(logolayer2, "logolayer2.png");
+            engineGetResImage(engine, logobg, "logobg.png");
+            engineGetResImage(engine, logolayer1, "logolayer1.png");
+            engineGetResImage(engine, logolayer2, "logolayer2.png");
 
-            nblit = dmGetScaledBlitFunc(logobg->format, engine.screen->format, DMD_TRANSPARENT);
-            kblit = dmGetScaledBlitFunc(logobg->format, engine.screen->format, DMD_NONE);
+            nblit = dmGetScaledBlitFunc(logobg->format, engine->screen->format, DMD_TRANSPARENT);
+            kblit = dmGetScaledBlitFunc(logobg->format, engine->screen->format, DMD_NONE);
             dmLerpInit(&lerpD, 0.01, 500, 10000);
             nollattu = TRUE;
         }
@@ -465,14 +467,14 @@
         int x2 = t2 * 25.0f + q, y2 = t * 35.0f + q*2.0f,
             w2 = t2 * 70.0f + q, h2 = t * 40.0f + q*2.0f;
 
-        kblit(logobg, 0, 0, engine.screen->w, engine.screen->h, engine.screen);
-        nblit(logolayer1, -x, -y, engine.screen->w+w, engine.screen->h+h, engine.screen);
-        nblit(logolayer2, -x2, -y2, engine.screen->w+w2, engine.screen->h+h2, engine.screen);
+        kblit(logobg, 0, 0, engine->screen->w, engine->screen->h, engine->screen);
+        nblit(logolayer1, -x, -y, engine->screen->w+w, engine->screen->h+h, engine->screen);
+        nblit(logolayer2, -x2, -y2, engine->screen->w+w2, engine->screen->h+h2, engine->screen);
     }
     else
     if (t < 20)
     {
-        int dt = engineGetTime(10);
+        int dt = engineGetTime(engine, 10);
         static SDL_Surface *gay, *logobg;
         static DMLerpContext lerpX, lerpY, lerpD;
         static DMScaledBlitFunc nblit, kblit;
@@ -482,10 +484,10 @@
 
         if (!nollattu)
         {
-            engineGetResImage(gay, "gay.png");
-            engineGetResImage(logobg, "logobg.png");
-            nblit = dmGetScaledBlitFunc(bmap->format, engine.screen->format, DMD_NONE);
-            kblit = dmGetScaledBlitFunc(logobg->format, engine.screen->format, DMD_TRANSPARENT);
+            engineGetResImage(engine, gay, "gay.png");
+            engineGetResImage(engine, logobg, "logobg.png");
+            nblit = dmGetScaledBlitFunc(bmap->format, engine->screen->format, DMD_NONE);
+            kblit = dmGetScaledBlitFunc(logobg->format, engine->screen->format, DMD_TRANSPARENT);
             dmMakePalette(bmap);
             dmLerpInit(&lerpX, QWIDTH, 0, 10000);
             dmLerpInit(&lerpY, QHEIGHT * 0.25, QHEIGHT * 0.75, 10000);
@@ -501,11 +503,11 @@
 
         dmShadowTraceHeightMap(bmap->pixels, heightMap, &light);
 
-        nblit(bmap, 0, 0, engine.screen->w, engine.screen->h, engine.screen);
+        nblit(bmap, 0, 0, engine->screen->w, engine->screen->h, engine->screen);
 
         if ((dt / 100) % 10 < 5)
         {
-            kblit(gay, 0, 0, engine.screen->w, engine.screen->h, engine.screen);
+            kblit(gay, 0, 0, engine->screen->w, engine->screen->h, engine->screen);
         }
     }
     else
@@ -516,28 +518,28 @@
         static DMLerpContext lerpX, lerpY, lerpZ;
         static DMScaledBlitFunc nblit, kblit;
         static BOOL stateChange, nollattu = FALSE;
-        int currFrame = engineGetTime(20) * 15 / 1000;
+        int currFrame = engineGetTime(engine, 20) * 15 / 1000;
         if (!nollattu)
         {
-            engineGetResImage(ruutu, "ruutu.png");
+            engineGetResImage(engine, ruutu, "ruutu.png");
             dmClearSurface(ruutu, dmMapRGBA(ruutu, 0,0,0,0));
-            nblit = dmGetScaledBlitFunc(nosfe[0]->format, engine.screen->format, DMD_NONE);
-            kblit = dmGetScaledBlitFunc(credits[0].img->format, engine.screen->format, DMD_TRANSPARENT);
+            nblit = dmGetScaledBlitFunc(nosfe[0]->format, engine->screen->format, DMD_NONE);
+            kblit = dmGetScaledBlitFunc(credits[0].img->format, engine->screen->format, DMD_TRANSPARENT);
             currCredit = -1;
             currState = -1;
             stateChange = TRUE;
             nollattu = TRUE;
         }
 
-        float gt = 1.0f + sin(engineGetTime(0) / 250.0f);
+        float gt = 1.0f + sin(engineGetTime(engine, 0) / 250.0f);
         int g1 = gt * 25.0f, g2 = gt * 50.0f;
         
-        nblit(nosfe[currFrame % NOSFE_MAX], -g1, -g1, engine.screen->w+g2, engine.screen->h+g2, engine.screen);
+        nblit(nosfe[currFrame % NOSFE_MAX], -g1, -g1, engine->screen->w+g2, engine->screen->h+g2, engine->screen);
 
         if (t >= 30)
         {
-            int qtime = engineGetTime(30);
-            int creditTime = (engineGetTime(0) - creditStartTime);
+            int qtime = engineGetTime(engine, 30);
+            int creditTime = engineGetTime(engine, 0) - creditStartTime;
             float zscale;
             if ( ( (qtime / (CREDITS_SPEED + 500)) % 2) == 0 && currState == -1)
                 stateChange = TRUE;
@@ -550,7 +552,7 @@
                     case 0:
                         {
                         int qt = (qtime / 100) % nrandomCoords;
-                        creditStartTime = engineGetTime(0);
+                        creditStartTime = engineGetTime(engine, 0);
                         creditTime = 0;
                         dmLerpInit(&lerpX, randomCoords[qt].x, credits[currCredit].x - 50, CREDITS_SPEED);
                         dmLerpInit(&lerpY, randomCoords[qt].y, credits[currCredit].y - 50, CREDITS_SPEED);
@@ -586,7 +588,7 @@
 
             if (currCredit > 0)
             {
-                kblit(ruutu, 0, 0, engine.screen->w, engine.screen->h, engine.screen);
+                kblit(ruutu, 0, 0, engine->screen->w, engine->screen->h, engine->screen);
             }
 
             if (currState == 1)
@@ -604,7 +606,7 @@
                     dmLerpSCurve(&lerpY, creditTime) - (zscale * credits[currCredit].img->h),
                     credits[currCredit].img->w * (1.0f + zscale),
                     credits[currCredit].img->h * (1.0f + zscale),
-                    engine.screen);
+                    engine->screen);
             }
         }
         
@@ -612,7 +614,7 @@
     else
     if (t < 60)
     {
-        int dt = engineGetTime(45);
+        int dt = engineGetTime(engine, 45);
         static SDL_Surface *logobg, *greets;
         static DMScaledBlitFunc nblit, kblit;
         static DMLerpContext lerpD;
@@ -620,10 +622,10 @@
 
         if (!nollattu)
         {
-            engineGetResImage(logobg, "logobg.png");
-            engineGetResImage(greets, "greetings.png");
-            nblit = dmGetScaledBlitFunc(logobg->format, engine.screen->format, DMD_TRANSPARENT);
-            kblit = dmGetScaledBlitFunc(logobg->format, engine.screen->format, DMD_NONE);
+            engineGetResImage(engine, logobg, "logobg.png");
+            engineGetResImage(engine, greets, "greetings.png");
+            nblit = dmGetScaledBlitFunc(logobg->format, engine->screen->format, DMD_TRANSPARENT);
+            kblit = dmGetScaledBlitFunc(logobg->format, engine->screen->format, DMD_NONE);
             dmLerpInit(&lerpD, 0.01, 500, 10000);
             nollattu = TRUE;
         }
@@ -634,11 +636,11 @@
         int x = t * 25.0f + q, y = t * 35.0f + q,
             w = t * 70.0f + q*2.0f, h = t * 40.0f + q*2.0f;
 
-        kblit(logobg, -j, -j, engine.screen->w+j*2.0f, engine.screen->h+j*2.0f, engine.screen);
-        nblit(greets, -x, -y, engine.screen->w+w, engine.screen->h+h, engine.screen);
+        kblit(logobg, -j, -j, engine->screen->w+j*2.0f, engine->screen->h+j*2.0f, engine->screen);
+        nblit(greets, -x, -y, engine->screen->w+w, engine->screen->h+h, engine->screen);
     }
     else
-        engine.exitFlag = TRUE;
+        engine->exitFlag = TRUE;
 
 
     {
@@ -651,32 +653,32 @@
 
         if (!nollattu)
         {
-            engineGetResImage(feidi, "feidi.png");
+            engineGetResImage(engine, feidi, "feidi.png");
             dmLerpInit(&fadeLerp, 255, 0, 250);
             nollattu = TRUE;
         }
 
-        JSS_LOCK(engine.plr);
+        JSS_LOCK(engine->plr);
         for (hit = FALSE, ch = 0; ch < 6; ch++)
-        if (engine.plr->channels[ch].nextInstrument == 0)
+        if (engine->plr->channels[ch].nextInstrument == 0)
         {
             hit = TRUE;
             break;
         }
-        JSS_UNLOCK(engine.plr);
+        JSS_UNLOCK(engine->plr);
 
         if (hit && !fadeActive)
         {
             fadeActive = TRUE;
-            fadeStartTime = engineGetTime(0);
+            fadeStartTime = engineGetTime(engine, 0);
         }
         if (fadeActive)
         {
-            int fadeTime = engineGetTime(0) - fadeStartTime;
+            int fadeTime = engineGetTime(engine, 0) - fadeStartTime;
             if (fadeTime < 250)
             {
                 dmScaledBlitSurface32to32TransparentGA(feidi,
-                    0, 0, engine.screen->w, engine.screen->h, engine.screen,
+                    0, 0, engine->screen->w, engine->screen->h, engine->screen,
                     dmLerpSCurve(&fadeLerp, fadeTime));
             }
             else