changeset 36:0b74381be601

Cleanups and more work towards working implementation on SDL2. But it's not compiling yet.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 29 Oct 2019 15:13:31 +0200
parents 2239a5ccf827
children dc514b8d8cdd
files demo.c
diffstat 1 files changed, 28 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/demo.c	Tue Oct 29 14:46:37 2019 +0200
+++ b/demo.c	Tue Oct 29 15:13:31 2019 +0200
@@ -16,8 +16,6 @@
         "0", "ENGINE INITTIALISSSIZING!!!!!", NULL);
 
     engine->optPackFilename  = "bussi.dat";
-    engine->optDataPath      = NULL;
-
     engine->optResFlags      = DRF_USE_PACK | DRF_PRELOAD_RES
 #ifdef DM_USE_STDIO
     | DRF_USE_STDIO
@@ -25,12 +23,10 @@
     ;
 
     engine->optAudioSetup    = DM_ASETUP_JSS;
-
     engine->optVidSetup      = DM_VSETUP_ASPECT;
     engine->optVidWidth      = 640;
     engine->optVidHeight     = 480;
     engine->optVidDepth      = 32;
-    engine->optVFlags        = SDL_SWSURFACE;
 
     engine->demoInit = demoInit;
     engine->demoRender = demoRender;
@@ -66,7 +62,7 @@
 } DMFooItemDef;
 
 
-static DMItemDef items[] = 
+static DMItemDef items[] =
 {
     { 0,  3, 1,  0.53, 0.2, "viitta.png", NULL, 0 },
     { 0,  1, 3,  -0.2, 0.05, "pilvi.png", NULL, 0 },
@@ -96,14 +92,14 @@
     // Skrollerin fontti
     if ((tmp = engineFindResource(engine, "fontti.dmf")) == NULL)
         return DMERR_INIT_FAIL;
-    
+
     if ((i = dmLoadBitmapFont(tmp, &font)) != DMERR_OK)
         return i;
 
     for (i = 0; i < DMFONT_NPALETTE; i++)
     {
         pal[i].r = pal[i].g = pal[i].b = i * 8;
-        pal[i].unused = i > 0 ? 255 : 0;
+        pal[i].a = i > 0 ? 255 : 0;
     }
 
     dmSetBitmapFontPalette(font, pal, 0, DMFONT_NPALETTE);
@@ -117,7 +113,7 @@
             i, dmErrorStr(i));
         return DMERR_INIT_FAIL;
     }
-    
+
     jvmSetCallback(engine->jssDev, jmpExec, engine->jssPlr);
     jmpSetModule(engine->jssPlr, mod);
     jmpPlayOrder(engine->jssPlr, 0);
@@ -207,7 +203,7 @@
                 for (xc = cx; xc > 0; xc--)
                 {
                     DM_RADIAL_BLUR(< 0, < 0)
-                }    
+                }
             }
 
 #pragma omp section
@@ -217,7 +213,7 @@
                 for (xc = cx; xc > 0; xc--)
                 {
                     DM_RADIAL_BLUR(>= img->h, < 0)
-                }    
+                }
             }
 
 #pragma omp section
@@ -227,7 +223,7 @@
                 for (xc = cx + 1; xc < img->w; xc++)
                 {
                     DM_RADIAL_BLUR(>= img->h, >= img->w)
-                }    
+                }
             }
         }
     }
@@ -399,7 +395,7 @@
         }
 
         dmRenderItems(engine, ablit, mitems, DM_MAX_MITEMS, 0);
-        
+
         // Bussi ajaa sisään
         if (t > 14)
         {
@@ -409,12 +405,12 @@
                 xc = dmCX(engine, -1 + ajelu),
                 yc = dmCY(engine, 0.38 + sin(t * 10) * 0.005),
                 yc2 = yc + dmQY(engine, bussi, 0.7) + dmCY(engine, sin(t * 20) * 0.001);
-            
+
             ablit(rengas, xc + dmQX(engine, bussi, 0.07), yc2, dmQX(engine, rengas, 1), dmQY(engine, rengas, 1), engine->screen);
             ablit(rengas, xc + dmQX(engine, bussi, 0.80), yc2, dmQX(engine, rengas, 1), dmQY(engine, rengas, 1), engine->screen);
             ablit(bussi, xc, yc, dmQX(engine, bussi, 1), dmQY(engine, bussi, 1), engine->screen);
         }
-        
+
 
         dmRenderItems(engine, ablit, mitems, DM_MAX_MITEMS, 1);
     }
@@ -517,31 +513,33 @@
         static BOOL nollattu = FALSE;
         if (!nollattu)
         {
-            cblit = dmGetScaledBlitFunc(font->glyphs[65]->format, engine->screen->format, DMD_TRANSPARENT);
-            qblit = dmGetScaledBlitFunc(font->glyphs[65]->format, engine->screen->format, DMD_SATURATE);
+            cblit = dmGetScaledBlitFunc(font->glyphs->format, engine->screen->format, DMD_TRANSPARENT);
+            qblit = dmGetScaledBlitFunc(font->glyphs->format, engine->screen->format, DMD_SATURATE);
         }
 
         size_t txtLen = teksti->rawSize - 1;
         Uint8 *txtData = teksti->rawData;
         int fwidth = font->width * 2 + 2;
         int xc, offs, scrollTime = tt / 10,
-            scrWidth = engine->screen->w / (dmQX(engine, font->glyphs[65], 1) + dmCX(engine, 0.001));
+            //                                                 v-- bug
+            scrWidth = engine->screen->w / (dmQX(engine, font->glyphs, 1) + dmCX(engine, 0.001));
 
         for (xc = offs = 0; offs < scrWidth; offs++)
         {
-            int ch = txtData[((scrollTime / fwidth) + offs) % txtLen];
-            SDL_Surface *glyph = dmGetBMGlyph(font, my_toupper(ch));
-            if (glyph != NULL)
-            {
-                float mt = (offs * 20 + tt) / 100.0f;
-                int dx = xc - (scrollTime % fwidth),
-                    dy = dmCY(engine, 0.8 + sin(mt) * 0.05),
-                    dw = glyph->w * 2 * (1.0f + sin(mt) * 0.1f),
-                    dh = glyph->h * 2 * (1.0f + cos(mt) * 0.2f);
-                    
-                cblit(glyph, dx+1, dy+1, dw+1, dh+1, engine->screen);
-                qblit(glyph, dx, dy, dw, dh, engine->screen);
-            }
+            const int ch = txtData[((scrollTime / fwidth) + offs) % txtLen];
+            SDL_Surface glyph;
+
+            dmGetBMGlyph(&glyph, font, my_toupper(ch));
+
+            float mt = (offs * 20 + tt) / 100.0f;
+            int dx = xc - (scrollTime % fwidth),
+                dy = dmCY(engine, 0.8 + sin(mt) * 0.05),
+                dw = glyph.w * 2 * (1.0f + sin(mt) * 0.1f),
+                dh = glyph.h * 2 * (1.0f + cos(mt) * 0.2f);
+
+            cblit(&glyph, dx+1, dy+1, dw+1, dh+1, engine->screen);
+            qblit(&glyph, dx, dy, dw, dh, engine->screen);
+
             xc += fwidth;
         }
     }