annotate dmsimple.c @ 369:e1c984404b6b

Re-entrancy.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 17 Oct 2012 00:23:36 +0300
parents 9875c65029af
children 8a98037c5cf7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
310
713c8018c3ce Fix includes in the dmsimple engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 278
diff changeset
1 #include <SDL.h>
342
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
2 #include "dmengine.h"
310
713c8018c3ce Fix includes in the dmsimple engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 278
diff changeset
3 #include "dmargs.h"
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4
366
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
5 static DMEngineData engine;
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
6
121
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
7 static DMOptArg optList[] =
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
8 {
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
9 { 0, '?', "help", "Show this help", OPT_NONE },
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
10 { 1, 'v', "verbose", "Be more verbose", OPT_NONE },
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
11 { 2, 'f', "fs", "Fullscreen", OPT_NONE },
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
12 };
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
13
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
14 const int optListN = sizeof(optList) / sizeof(optList[0]);
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
15
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
16
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
17
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
18 static void argShowHelp()
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
19 {
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
20 dmPrintBanner(stdout, dmProgName, "[options]");
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
21 dmArgsPrintHelp(stdout, optList, optListN);
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
22 }
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
23
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
24
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
25 static BOOL argHandleOpt(const int optN, char *optArg, char *currArg)
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
26 {
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
27 (void) optArg;
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
28
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
29 switch (optN)
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
30 {
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
31 case 0:
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
32 argShowHelp();
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
33 exit(0);
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
34 break;
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
35
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
36 case 1:
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
37 dmVerbosity++;
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
38 break;
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
39
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
40 case 2:
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
41 engine.optVFlags |= SDL_FULLSCREEN;
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
42 break;
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
43
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
44 default:
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
45 dmError("Unknown option '%s'.\n", currArg);
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
46 return FALSE;
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
47 }
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
48
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
49 return TRUE;
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
50 }
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
51
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
52
342
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
53 static void engineAudioCallback(void *userdata, Uint8 *stream, int len)
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
54 {
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
55 (void) userdata;
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
56
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
57 if (engine.paused)
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
58 {
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
59 memset(stream, 0, len);
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
60 }
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
61 else
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
62 #ifdef DM_USE_JSS
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
63 {
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
64 if (engine.dev != NULL)
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
65 jvmRenderAudio(engine.dev, stream, len / jvmGetSampleSize(engine.dev));
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
66 }
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
67 #endif
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
68 #ifdef DM_USE_TREMOR
361
bf60f60cafba Fix engine breakage.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
69 if (engine.audioPos + len >= engine.audioRes->rdataSize)
342
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
70 {
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
71 engine.exitFlag = TRUE;
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
72 }
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
73 else
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
74 {
361
bf60f60cafba Fix engine breakage.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
75 memcpy(stream, engine.audioRes->rdata + engine.audioPos, len);
342
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
76 engine.audioPos += len;
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
77 }
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
78 #endif
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
79 }
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
80
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
81
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
82 static int engineShowProgress(int loaded, int total)
40
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
83 {
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
84 int dx = 60,
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
85 dh = 20,
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
86 dw = engine.screen->w - (2 * dx),
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
87 dy = (engine.screen->h - dh) / 2;
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
88
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
89 if (SDL_MUSTLOCK(engine.screen) != 0 && SDL_LockSurface(engine.screen) != 0)
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
90 return DMERR_INIT_FAIL;
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
91
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
92 // Draw the progress bar
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
93 dmClearSurface(engine.screen, dmMapRGBA(engine.screen, 0,0,0,0));
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
94 dmFillRect(engine.screen, dx, dy, dx+dw, dy+dh, dmMapRGB(engine.screen, 255,255,255));
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
95 dmFillRect(engine.screen, dx+1, dy+1, dx+dw-1, dy+dh-1, dmMapRGB(engine.screen, 0,0,0));
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
96
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
97 if (total > 0)
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
98 {
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
99 dmFillRect(engine.screen,
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
100 dx+3, dy+3,
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
101 dx + 3 + ((dw - 3) * loaded) / total,
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
102 dy + dh - 3,
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
103 dmMapRGB(engine.screen, 200,200,200));
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
104 }
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
105
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
106 // Flip screen
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
107 if (SDL_MUSTLOCK(engine.screen) != 0)
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
108 SDL_UnlockSurface(engine.screen);
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
109
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
110 SDL_Flip(engine.screen);
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
111 return DMERR_OK;
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
112 }
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
113
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
114
342
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
115 static int engineLoadResources()
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 {
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 int err, loaded, total;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118
359
59045853853d Make resource management re-entrant.
Matti Hamalainen <ccr@tnsp.org>
parents: 354
diff changeset
119 err = dmres_preload(engine.resources, TRUE, &loaded, &total);
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120
359
59045853853d Make resource management re-entrant.
Matti Hamalainen <ccr@tnsp.org>
parents: 354
diff changeset
121 while ((err = dmres_preload(engine.resources, FALSE, &loaded, &total)) == DMERR_PROGRESS)
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122 {
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 // Show a nice progress bar while loading
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124 if (total > 0 && (loaded % 2) == 0)
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125 {
40
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
126 if ((err = engineShowProgress(loaded, total)) != DMERR_OK)
a239b7d4e13b Modularize progress meter.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
127 return err;
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128 }
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 }
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 return err;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132 }
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134
342
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
135 static BOOL engineInitializeVideo()
332
d4802335cbbc Clean up video (re)initialization.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
136 {
d4802335cbbc Clean up video (re)initialization.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
137 dmPrint(1, "Initializing SDL video %d x %d x %dbpp, flags=0x%08x\n",
d4802335cbbc Clean up video (re)initialization.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
138 engine.optScrWidth, engine.optScrHeight, engine.optBitDepth, engine.optVFlags);
d4802335cbbc Clean up video (re)initialization.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
139
d4802335cbbc Clean up video (re)initialization.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
140 SDL_FreeSurface(engine.screen);
d4802335cbbc Clean up video (re)initialization.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
141
d4802335cbbc Clean up video (re)initialization.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
142 engine.screen = SDL_SetVideoMode(engine.optScrWidth, engine.optScrHeight, engine.optBitDepth, engine.optVFlags);
d4802335cbbc Clean up video (re)initialization.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
143 if (engine.screen == NULL)
d4802335cbbc Clean up video (re)initialization.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
144 {
d4802335cbbc Clean up video (re)initialization.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
145 dmError("Can't SDL_SetVideoMode(): %s\n", SDL_GetError());
d4802335cbbc Clean up video (re)initialization.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
146 return FALSE;
d4802335cbbc Clean up video (re)initialization.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
147 }
d4802335cbbc Clean up video (re)initialization.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
148 return TRUE;
d4802335cbbc Clean up video (re)initialization.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
149 }
d4802335cbbc Clean up video (re)initialization.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
150
d4802335cbbc Clean up video (re)initialization.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
151
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152 int main(int argc, char *argv[])
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153 {
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154 int err;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155 BOOL initSDL = FALSE;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157 memset(&engine, 0, sizeof(engine));
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 // Pre-initialization
366
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
160 if ((err = demoPreInit(&engine)) != DMERR_OK)
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 goto error_exit;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
162
121
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
163 if (!dmArgsProcess(argc, argv, optList, optListN,
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
164 argHandleOpt, NULL, FALSE))
16fc6e6cf3b5 Move option handling to the simple demo engine.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
165 return DMERR_INIT_FAIL;
123
6f7356f3b91c Add engine startup messages showing prod name and "TNSP simple demoengine blurb".
Matti Hamalainen <ccr@tnsp.org>
parents: 122
diff changeset
166
6f7356f3b91c Add engine startup messages showing prod name and "TNSP simple demoengine blurb".
Matti Hamalainen <ccr@tnsp.org>
parents: 122
diff changeset
167 dmPrint(0,
6f7356f3b91c Add engine startup messages showing prod name and "TNSP simple demoengine blurb".
Matti Hamalainen <ccr@tnsp.org>
parents: 122
diff changeset
168 "%s\n"
312
99dc5d012081 Change startup messages.
Matti Hamalainen <ccr@tnsp.org>
parents: 310
diff changeset
169 "%s\n"
99dc5d012081 Change startup messages.
Matti Hamalainen <ccr@tnsp.org>
parents: 310
diff changeset
170 "TNSP simple demoengine initializing.\n",
123
6f7356f3b91c Add engine startup messages showing prod name and "TNSP simple demoengine blurb".
Matti Hamalainen <ccr@tnsp.org>
parents: 122
diff changeset
171 dmProgDesc, dmProgAuthor);
125
5102ec9e9bce Add a blurb about used features/3rd party code (zlib, Tremor, SDL).
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
172
5102ec9e9bce Add a blurb about used features/3rd party code (zlib, Tremor, SDL).
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
173 dmPrint(0,
5102ec9e9bce Add a blurb about used features/3rd party code (zlib, Tremor, SDL).
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
174 "Using libSDL, "
5102ec9e9bce Add a blurb about used features/3rd party code (zlib, Tremor, SDL).
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
175 #ifdef DM_USE_TREMOR
5102ec9e9bce Add a blurb about used features/3rd party code (zlib, Tremor, SDL).
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
176 "Tremor Vorbis codec"
5102ec9e9bce Add a blurb about used features/3rd party code (zlib, Tremor, SDL).
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
177 #endif
5102ec9e9bce Add a blurb about used features/3rd party code (zlib, Tremor, SDL).
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
178 #ifdef DM_USE_PACKFS
5102ec9e9bce Add a blurb about used features/3rd party code (zlib, Tremor, SDL).
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
179 ", zlib and modified stb_image.\n"
5102ec9e9bce Add a blurb about used features/3rd party code (zlib, Tremor, SDL).
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
180 #else
5102ec9e9bce Add a blurb about used features/3rd party code (zlib, Tremor, SDL).
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
181 " and modified stb_image.\n"
5102ec9e9bce Add a blurb about used features/3rd party code (zlib, Tremor, SDL).
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
182 #endif
5102ec9e9bce Add a blurb about used features/3rd party code (zlib, Tremor, SDL).
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
183 "See README.txt for more information.\n");
5102ec9e9bce Add a blurb about used features/3rd party code (zlib, Tremor, SDL).
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
184
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185 // Initialize resource subsystem
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
186 dmPrint(1, "Initializing resources subsystem.\n");
359
59045853853d Make resource management re-entrant.
Matti Hamalainen <ccr@tnsp.org>
parents: 354
diff changeset
187 if ((err = dmres_init(&engine.resources, engine.optPackFilename, engine.optDataPath, engine.optResFlags, engineClassifier)) != DMERR_OK)
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
188 {
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
189 dmError("Could not initialize resource manager: %d, %s.\n", err, dmErrorStr(err));
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
190 goto error_exit;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191 }
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
192
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193 // Initialize SDL components
122
5ba672ebe014 Add some verbose engine startup messages.
Matti Hamalainen <ccr@tnsp.org>
parents: 121
diff changeset
194 dmPrint(1, "Initializing libSDL.\n");
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) != 0)
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196 {
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197 dmError("Could not initialize SDL: %s\n", SDL_GetError());
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198 goto error_exit;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199 }
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200 initSDL = TRUE;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201
122
5ba672ebe014 Add some verbose engine startup messages.
Matti Hamalainen <ccr@tnsp.org>
parents: 121
diff changeset
202 // Initialize audio parts
126
97488948215c Allow setting audio format settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 125
diff changeset
203 if (engine.optAfmt.freq == 0 && engine.optAfmt.channels == 0)
97488948215c Allow setting audio format settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 125
diff changeset
204 {
97488948215c Allow setting audio format settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 125
diff changeset
205 // Defaults, if none seem to be set
97488948215c Allow setting audio format settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 125
diff changeset
206 engine.optAfmt.freq = 44100;
97488948215c Allow setting audio format settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 125
diff changeset
207 engine.optAfmt.format = AUDIO_S16SYS;
97488948215c Allow setting audio format settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 125
diff changeset
208 engine.optAfmt.channels = 2;
316
a03e604f4e75 Adjust audio buffer size.
Matti Hamalainen <ccr@tnsp.org>
parents: 312
diff changeset
209 engine.optAfmt.samples = engine.optAfmt.freq / 16;
126
97488948215c Allow setting audio format settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 125
diff changeset
210 }
105
d5d27f262227 Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
211
d5d27f262227 Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
212 #ifdef DM_USE_JSS
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
213 jssInit();
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214
105
d5d27f262227 Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
215 switch (engine.optAfmt.format)
d5d27f262227 Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
216 {
110
8db49a23b393 Fixes to make the JSS audio subsystem support work again in the engine framework.
Matti Hamalainen <ccr@tnsp.org>
parents: 109
diff changeset
217 case AUDIO_S16SYS: engine.jss_format = JSS_AUDIO_S16; break;
8db49a23b393 Fixes to make the JSS audio subsystem support work again in the engine framework.
Matti Hamalainen <ccr@tnsp.org>
parents: 109
diff changeset
218 case AUDIO_U16SYS: engine.jss_format = JSS_AUDIO_U16; break;
8db49a23b393 Fixes to make the JSS audio subsystem support work again in the engine framework.
Matti Hamalainen <ccr@tnsp.org>
parents: 109
diff changeset
219 case AUDIO_S8: engine.jss_format = JSS_AUDIO_S8; break;
8db49a23b393 Fixes to make the JSS audio subsystem support work again in the engine framework.
Matti Hamalainen <ccr@tnsp.org>
parents: 109
diff changeset
220 case AUDIO_U8: engine.jss_format = JSS_AUDIO_U8; break;
105
d5d27f262227 Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
221 }
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
222
105
d5d27f262227 Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
223 dmPrint(1, "Initializing miniJSS mixer with fmt=%d, chn=%d, freq=%d\n",
110
8db49a23b393 Fixes to make the JSS audio subsystem support work again in the engine framework.
Matti Hamalainen <ccr@tnsp.org>
parents: 109
diff changeset
224 engine.jss_format, engine.optAfmt.channels, engine.optAfmt.freq);
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225
110
8db49a23b393 Fixes to make the JSS audio subsystem support work again in the engine framework.
Matti Hamalainen <ccr@tnsp.org>
parents: 109
diff changeset
226 if ((engine.dev = jvmInit(engine.jss_format, engine.optAfmt.channels, engine.optAfmt.freq, JMIX_AUTO)) == NULL)
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227 {
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 dmError("jvmInit() returned NULL, voi perkele.\n");
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
229 goto error_exit;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230 }
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
231
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232 if ((engine.plr = jmpInit(engine.dev)) == NULL)
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
233 {
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234 dmError("jmpInit() returned NULL\n");
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235 goto error_exit;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
236 }
105
d5d27f262227 Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
237 #endif
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
239 // Initialize SDL audio
105
d5d27f262227 Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
240 dmPrint(1, "Trying to init SDL audio with: fmt=%d, chn=%d, freq=%d\n",
d5d27f262227 Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
241 engine.optAfmt.format, engine.optAfmt.channels, engine.optAfmt.freq);
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242
342
c6ec970dc3cf Separate some demo engine parts to two different modules.
Matti Hamalainen <ccr@tnsp.org>
parents: 336
diff changeset
243 engine.optAfmt.callback = engineAudioCallback;
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244
105
d5d27f262227 Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
245 if (SDL_OpenAudio(&engine.optAfmt, NULL) < 0)
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
246 {
122
5ba672ebe014 Add some verbose engine startup messages.
Matti Hamalainen <ccr@tnsp.org>
parents: 121
diff changeset
247 dmError("Couldn't open SDL audio: %s\n", SDL_GetError());
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248 goto error_exit;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249 }
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
250
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
251 // Initialize SDL video
127
ab4086db7dad Various improvements in modularity.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
252 if (engine.demoInitPreVideo != NULL &&
366
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
253 (err = engine.demoInitPreVideo(&engine)) != DMERR_OK)
127
ab4086db7dad Various improvements in modularity.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
254 {
ab4086db7dad Various improvements in modularity.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
255 dmError("demoInitPreVideo() failed, %d: %s\n", err, dmErrorStr(err));
ab4086db7dad Various improvements in modularity.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
256 goto error_exit;
ab4086db7dad Various improvements in modularity.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
257 }
ab4086db7dad Various improvements in modularity.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
258
332
d4802335cbbc Clean up video (re)initialization.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
259 if (!engineInitializeVideo())
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
260 goto error_exit;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
261
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
262 SDL_ShowCursor(SDL_DISABLE);
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
263 SDL_WM_SetCaption(dmProgDesc, dmProgName);
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
264
127
ab4086db7dad Various improvements in modularity.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
265 if (engine.demoInitPostVideo != NULL &&
366
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
266 (err = engine.demoInitPostVideo(&engine)) != DMERR_OK)
127
ab4086db7dad Various improvements in modularity.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
267 {
ab4086db7dad Various improvements in modularity.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
268 dmError("demoInitPostVideo() failed, %d: %s\n", err, dmErrorStr(err));
ab4086db7dad Various improvements in modularity.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
269 goto error_exit;
ab4086db7dad Various improvements in modularity.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
270 }
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
271
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
272 // Load resources
122
5ba672ebe014 Add some verbose engine startup messages.
Matti Hamalainen <ccr@tnsp.org>
parents: 121
diff changeset
273 dmPrint(1, "Loading resources, please wait...\n");
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
274 if ((err = engineLoadResources()) != DMERR_OK)
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
275 {
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
276 dmError("Error loading resources, %d: %s.\n",
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
277 err, dmErrorStr(err));
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
278 goto error_exit;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
279 }
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
280
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
281 // Final initializations
366
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
282 if ((err = engine.demoInit(&engine)) != DMERR_OK)
354
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
283 {
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
284 dmError("Failure in demoInit(), %d: %s\n",
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
285 err, dmErrorStr(err));
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
286 goto error_exit;
354
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
287 }
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
288
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
289 // Initialize effects
369
e1c984404b6b Re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
290 if ((err = engineInitializeEffects(&engine)) != DMERR_OK)
354
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
291 {
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
292 dmError("Effects initialization failed, %d: %s\n",
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
293 err, dmErrorStr(err));
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
294 goto error_exit;
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
295 }
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
296
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
297 // Use a timeline, if set
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
298 if (engine.timeline != NULL)
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
299 {
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
300 if ((err = dmLoadTimeline(engine.timeline, &engine.tl)) != DMERR_OK)
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
301 {
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
302 dmError("Error loading timeline, %d: %s\n", err,
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
303 dmErrorStr(err));
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
304 goto error_exit;
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
305 }
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
306
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
307 if ((err = dmPrepareTimeline(engine.tl, engine.ptl)) != DMERR_OK)
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
308 {
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
309 dmError("Error creating prepared timeline, %d: %s\n",
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
310 err, dmErrorStr(err));
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
311 goto error_exit;
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
312 }
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
313 }
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
314
122
5ba672ebe014 Add some verbose engine startup messages.
Matti Hamalainen <ccr@tnsp.org>
parents: 121
diff changeset
315 dmPrint(1, "Starting up.\n");
278
919e7de91758 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
316
919e7de91758 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
317 SDL_LockAudio();
41
780300a8d322 Move SDL_PauseAudio(0) to the "engine" instead of the demo code.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
318 SDL_PauseAudio(0);
278
919e7de91758 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
319 SDL_UnlockAudio();
919e7de91758 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
320
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
321 engine.startTime = SDL_GetTicks();
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
322
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
323 while (!engine.exitFlag)
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
324 {
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
325 while (SDL_PollEvent(&engine.event))
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
326 switch (engine.event.type)
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
327 {
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
328 case SDL_KEYDOWN:
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
329 switch (engine.event.key.keysym.sym)
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
330 {
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
331 case SDLK_ESCAPE:
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
332 engine.exitFlag = TRUE;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
333 break;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
334
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
335 case SDLK_SPACE:
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
336 engine.pauseFlag = !engine.pauseFlag;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
337 break;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
338
336
13dba73cf28e Add 'F' key to fullscreen toggling, in addition to alt+enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 335
diff changeset
339 case SDLK_f:
13dba73cf28e Add 'F' key to fullscreen toggling, in addition to alt+enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 335
diff changeset
340 engine.optVFlags ^= SDL_FULLSCREEN;
13dba73cf28e Add 'F' key to fullscreen toggling, in addition to alt+enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 335
diff changeset
341 if (!engineInitializeVideo())
13dba73cf28e Add 'F' key to fullscreen toggling, in addition to alt+enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 335
diff changeset
342 goto error_exit;
13dba73cf28e Add 'F' key to fullscreen toggling, in addition to alt+enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 335
diff changeset
343 break;
13dba73cf28e Add 'F' key to fullscreen toggling, in addition to alt+enter.
Matti Hamalainen <ccr@tnsp.org>
parents: 335
diff changeset
344
109
3de6301dcfe1 Implement fullscrene toggling via alt+enter
Matti Hamalainen <ccr@tnsp.org>
parents: 105
diff changeset
345 case SDLK_RETURN:
3de6301dcfe1 Implement fullscrene toggling via alt+enter
Matti Hamalainen <ccr@tnsp.org>
parents: 105
diff changeset
346 if (engine.event.key.keysym.mod & KMOD_ALT)
3de6301dcfe1 Implement fullscrene toggling via alt+enter
Matti Hamalainen <ccr@tnsp.org>
parents: 105
diff changeset
347 {
332
d4802335cbbc Clean up video (re)initialization.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
348 engine.optVFlags ^= SDL_FULLSCREEN;
d4802335cbbc Clean up video (re)initialization.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
349 if (!engineInitializeVideo())
d4802335cbbc Clean up video (re)initialization.
Matti Hamalainen <ccr@tnsp.org>
parents: 316
diff changeset
350 goto error_exit;
109
3de6301dcfe1 Implement fullscrene toggling via alt+enter
Matti Hamalainen <ccr@tnsp.org>
parents: 105
diff changeset
351 }
3de6301dcfe1 Implement fullscrene toggling via alt+enter
Matti Hamalainen <ccr@tnsp.org>
parents: 105
diff changeset
352 break;
93
15fdd5573344 Add simple (and buggy / not really working) debug mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
353
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354 default:
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
355 break;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
356 }
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
357
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
358 break;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
359
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
360 case SDL_VIDEOEXPOSE:
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
361 break;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
362
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
363 case SDL_QUIT:
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
364 engine.exitFlag = TRUE;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
365 break;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
366 }
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
367
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
368 // Draw frame
361
bf60f60cafba Fix engine breakage.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
369 engine.frameTime = SDL_GetTicks();
93
15fdd5573344 Add simple (and buggy / not really working) debug mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
370 if (engine.pauseFlag != engine.paused)
15fdd5573344 Add simple (and buggy / not really working) debug mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
371 {
15fdd5573344 Add simple (and buggy / not really working) debug mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
372 engine.paused = engine.pauseFlag;
367
9875c65029af Work towards re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 366
diff changeset
373 engine.pauseTime = engineGetTick(&engine);
93
15fdd5573344 Add simple (and buggy / not really working) debug mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
374 }
15fdd5573344 Add simple (and buggy / not really working) debug mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
375
15fdd5573344 Add simple (and buggy / not really working) debug mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
376 if (engine.paused)
15fdd5573344 Add simple (and buggy / not really working) debug mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
377 {
361
bf60f60cafba Fix engine breakage.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
378 engine.startTime = engine.frameTime - engine.pauseTime;
93
15fdd5573344 Add simple (and buggy / not really working) debug mode.
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
379 }
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
380
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
381 if (SDL_MUSTLOCK(engine.screen) != 0 && SDL_LockSurface(engine.screen) != 0)
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
382 {
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
383 dmError("Can't lock surface.\n");
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
384 goto error_exit;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
385 }
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
386
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
387 // Call main tick
345
cac13f180169 Work towards timeline support.
Matti Hamalainen <ccr@tnsp.org>
parents: 342
diff changeset
388 if (engine.demoRender != NULL)
cac13f180169 Work towards timeline support.
Matti Hamalainen <ccr@tnsp.org>
parents: 342
diff changeset
389 {
366
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
390 if ((err = engine.demoRender(&engine)) != DMERR_OK)
345
cac13f180169 Work towards timeline support.
Matti Hamalainen <ccr@tnsp.org>
parents: 342
diff changeset
391 goto error_exit;
cac13f180169 Work towards timeline support.
Matti Hamalainen <ccr@tnsp.org>
parents: 342
diff changeset
392 }
cac13f180169 Work towards timeline support.
Matti Hamalainen <ccr@tnsp.org>
parents: 342
diff changeset
393 else
cac13f180169 Work towards timeline support.
Matti Hamalainen <ccr@tnsp.org>
parents: 342
diff changeset
394 {
366
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
395 if ((err = dmExecuteTimeline(engine.ptl, engine.screen, engineGetTick(&engine))) != DMERR_OK)
345
cac13f180169 Work towards timeline support.
Matti Hamalainen <ccr@tnsp.org>
parents: 342
diff changeset
396 goto error_exit;
cac13f180169 Work towards timeline support.
Matti Hamalainen <ccr@tnsp.org>
parents: 342
diff changeset
397 }
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
398
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
399 // Flip screen
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
400 if (SDL_MUSTLOCK(engine.screen) != 0)
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
401 SDL_UnlockSurface(engine.screen);
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
402
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
403 SDL_Flip(engine.screen);
105
d5d27f262227 Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
404 SDL_Delay(engine.paused ? 100 : 20);
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
405
361
bf60f60cafba Fix engine breakage.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
406 engine.frameCount++;
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
407 }
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
408
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
409 // Print benchmark results
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
410 engine.endTime = SDL_GetTicks();
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
411 dmPrint(1, "%d frames in %d ms, fps = %1.3f\n",
361
bf60f60cafba Fix engine breakage.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
412 engine.frameCount, engine.endTime - engine.startTime,
bf60f60cafba Fix engine breakage.
Matti Hamalainen <ccr@tnsp.org>
parents: 359
diff changeset
413 (float) (engine.frameCount * 1000.0f) / (float) (engine.endTime - engine.startTime));
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
414
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
415
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
416 error_exit:
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
417
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
418 dmPrint(1, "Shutting down.\n");
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
419 SDL_ShowCursor(SDL_ENABLE);
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
420
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
421 if (engine.screen)
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
422 SDL_FreeSurface(engine.screen);
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
423
278
919e7de91758 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
424 SDL_LockAudio();
919e7de91758 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
425 SDL_PauseAudio(1);
105
d5d27f262227 Beging merging of dmsimple2-fork into the main "engine".
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
426 #ifdef DM_USE_JSS
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
427 jmpClose(engine.plr);
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
428 jvmClose(engine.dev);
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
429 jssClose();
278
919e7de91758 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
430 #endif
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
431 SDL_UnlockAudio();
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
432
354
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
433 dmFreeTimeline(engine.tl);
ba284f5e7ea5 More work on editor, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 351
diff changeset
434 dmFreePreparedTimelineData(engine.ptl);
369
e1c984404b6b Re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 367
diff changeset
435 engineShutdownEffects(&engine);
359
59045853853d Make resource management re-entrant.
Matti Hamalainen <ccr@tnsp.org>
parents: 354
diff changeset
436 dmres_close(engine.resources);
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
437
127
ab4086db7dad Various improvements in modularity.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
438 if (engine.demoShutdown != NULL)
366
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
439 engine.demoShutdown(&engine);
94
4bbfc0274b29 Change some function names, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 93
diff changeset
440
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
441 if (initSDL)
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
442 SDL_Quit();
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
443
127
ab4086db7dad Various improvements in modularity.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
444 if (engine.demoQuit != NULL)
366
38e10b5f4e09 Work towards base engine re-entrancy.
Matti Hamalainen <ccr@tnsp.org>
parents: 361
diff changeset
445 engine.demoQuit(&engine);
32
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
446
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
447 return 0;
d1a6833a5d67 Added a simple demo engine core.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
448 }