annotate demo.c @ 37:dc514b8d8cdd default tip

s/EXEEXT/BINEXT/g
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 05 Dec 2019 18:22:11 +0200
parents 0b74381be601
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 #include "dmengine.h"
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 #include "dmtext.h"
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 #include "dmfft.h"
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 #include "dmvecmat.h"
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 #include <math.h>
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 static int demoInit(DMEngineData *engine);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 static void demoShutdown(DMEngineData *engine);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 static int demoRender(DMEngineData *engine);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 int demoPreInit(DMEngineData *engine)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 dmInitProg("bussi",
2
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
15 "Bussi by AnCiat ProDucTionz",
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 "0", "ENGINE INITTIALISSSIZING!!!!!", NULL);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 engine->optPackFilename = "bussi.dat";
27
8a604636b077 Use STDIO when enabled.
Matti Hamalainen <ccr@tnsp.org>
parents: 23
diff changeset
19 engine->optResFlags = DRF_USE_PACK | DRF_PRELOAD_RES
8a604636b077 Use STDIO when enabled.
Matti Hamalainen <ccr@tnsp.org>
parents: 23
diff changeset
20 #ifdef DM_USE_STDIO
8a604636b077 Use STDIO when enabled.
Matti Hamalainen <ccr@tnsp.org>
parents: 23
diff changeset
21 | DRF_USE_STDIO
8a604636b077 Use STDIO when enabled.
Matti Hamalainen <ccr@tnsp.org>
parents: 23
diff changeset
22 #endif
8a604636b077 Use STDIO when enabled.
Matti Hamalainen <ccr@tnsp.org>
parents: 23
diff changeset
23 ;
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 engine->optAudioSetup = DM_ASETUP_JSS;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 engine->optVidSetup = DM_VSETUP_ASPECT;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 engine->optVidWidth = 640;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 engine->optVidHeight = 480;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 engine->optVidDepth = 32;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 engine->demoInit = demoInit;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 engine->demoRender = demoRender;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 engine->demoShutdown = demoShutdown;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 return DMERR_OK;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 #define FFT_SIZE 128
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 DMFFTContext fft;
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
41 DMResource *teksti = NULL;
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
42 DMBitmapFont *font = NULL;
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
43
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
44 typedef struct
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
45 {
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
46 int layer;
13
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
47 int freq;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
48 int max;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
49 float ypos;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
50 float speed;
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
51 char *filename;
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
52 SDL_Surface *img;
13
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
53 int count;
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
54 } DMItemDef;
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
55
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
56
13
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
57 typedef struct
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
58 {
13
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
59 BOOL enabled;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
60 float xtime, xpos, ypos;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
61 DMItemDef *ref;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
62 } DMFooItemDef;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
63
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
64
36
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
65 static DMItemDef items[] =
13
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
66 {
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
67 { 0, 3, 1, 0.53, 0.2, "viitta.png", NULL, 0 },
16
80634079f275 Import asset.
Matti Hamalainen <ccr@tnsp.org>
parents: 13
diff changeset
68 { 0, 1, 3, -0.2, 0.05, "pilvi.png", NULL, 0 },
13
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
69 { 0, 1, 3, 0.28 , 0.1 , "puu_pv_2.png", NULL, 0 },
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
70 { 1, 9, 2, 0.25 , 0.8 , "puu_pv_1.png", NULL, 0 },
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
71 };
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
72
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
73 static const int nitems = sizeof(items) / sizeof(items[0]);
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
74
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
75
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 static int demoInit(DMEngineData *engine)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 int i;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 JSSModule *mod = NULL;
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
82 SDL_Color pal[DMFONT_NPALETTE];
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
83 DMResource *tmp;
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
85 // FFT init
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 dmInitializeFFT(&fft, FFT_SIZE);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
88 // Skrolliteksti
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
89 if ((teksti = engineFindResource(engine, "skrolli.txt")) == NULL)
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
90 return DMERR_INIT_FAIL;
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
91
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
92 // Skrollerin fontti
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
93 if ((tmp = engineFindResource(engine, "fontti.dmf")) == NULL)
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
94 return DMERR_INIT_FAIL;
36
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
95
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
96 if ((i = dmLoadBitmapFont(tmp, &font)) != DMERR_OK)
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
97 return i;
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
98
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
99 for (i = 0; i < DMFONT_NPALETTE; i++)
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
100 {
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
101 pal[i].r = pal[i].g = pal[i].b = i * 8;
36
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
102 pal[i].a = i > 0 ? 255 : 0;
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
103 }
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
104
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
105 dmSetBitmapFontPalette(font, pal, 0, DMFONT_NPALETTE);
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
106
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
107 // Musa
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 engineGetResModule(engine, mod, "pas2.xm");
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 if ((i = jssConvertModuleForPlaying(mod)) != DMERR_OK)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 dmErrorMsg("Could not convert module for playing, %d: %s\n",
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 i, dmErrorStr(i));
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114 return DMERR_INIT_FAIL;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 }
36
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
116
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 jvmSetCallback(engine->jssDev, jmpExec, engine->jssPlr);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 jmpSetModule(engine->jssPlr, mod);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119 jmpPlayOrder(engine->jssPlr, 0);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120 jvmSetGlobalVol(engine->jssDev, 55);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
122
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
123 // Osa kuvadatasta
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
124 for (i = 0; i < nitems; i++)
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
125 engineGetResImage(engine, items[i].img, items[i].filename);
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
126
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127 // Jne
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128 srand(15);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 return DMERR_OK;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134 static void demoShutdown(DMEngineData *engine)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136 (void) engine;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137 dmEndFFT(&fft);
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
138 dmFreeBitmapFont(font);
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142 static inline float dmCX(DMEngineData *engine, const float x)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144 return (x * engine->screen->w);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147
34
80e514ceb7cc Constify.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
148 static inline float dmCY(const DMEngineData *engine, const float y)
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150 return (y * engine->screen->h);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153
34
80e514ceb7cc Constify.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
154 static inline float dmQX(const DMEngineData *engine, const SDL_Surface *img, const float x)
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156 return engine->optVidNative ? (img->w * x) : (img->w * engine->screen->w * x) / 640.0f;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159
34
80e514ceb7cc Constify.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
160 static inline float dmQY(const DMEngineData *engine, const SDL_Surface *img, const float y)
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
162 return engine->optVidNative ? (img->h * y) : (img->h * engine->screen->h * y) / 480.0f;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
165
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166 #define DM_RADIAL_BLUR(YC, XC) \
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167 DMVector p1 = { xc, yc, 0, 0 }, p2 = { cx, cy, 0, 0 }, v; \
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168 dm_vector_sub_r(&v, &p2, &p1); \
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169 dm_vector_scale(&v, scale); \
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170 dm_vector_add(&v, &p1); \
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171 if (v.y YC || v.x XC) continue; \
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172 DMColor *dp = pix + xc, \
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173 *q = ((DMColor *)img->pixels) + ((int)(v.y) * pitch) + (int)v.x; \
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174 dp->r = (q->r + dp->r) / 2; \
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175 dp->g = (q->g + dp->g) / 2; \
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176 dp->b = (q->b + dp->b) / 2;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180 void dmRadialBlur(SDL_Surface *img, const int cx, const int cy, const DMFloat scale)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182 const int pitch = img->pitch / sizeof(DMColor);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
183 int xc, yc;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185 #pragma omp parallel private(yc, xc) shared(img)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
186 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
187 #pragma omp sections nowait
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
188 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
189 #pragma omp section
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
190 for (yc = cy; yc >= 0; yc--)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
192 DMColor *pix = ((DMColor *)img->pixels) + yc * pitch;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193 for (xc = cx + 1; xc < img->w; xc++)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195 DM_RADIAL_BLUR(< 0, >= img->w)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199 #pragma omp section
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200 for (yc = cy; yc >= 0; yc--)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202 DMColor *pix = ((DMColor *)img->pixels) + yc * pitch;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203 for (xc = cx; xc > 0; xc--)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
204 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
205 DM_RADIAL_BLUR(< 0, < 0)
36
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
206 }
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209 #pragma omp section
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 for (yc = cy + 1; yc < img->h; yc++)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
211 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
212 DMColor *pix = ((DMColor *)img->pixels) + yc * pitch;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
213 for (xc = cx; xc > 0; xc--)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215 DM_RADIAL_BLUR(>= img->h, < 0)
36
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
216 }
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
217 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
219 #pragma omp section
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220 for (yc = cy + 1; yc < img->h; yc++)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
221 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
222 DMColor *pix = ((DMColor *)img->pixels) + yc * pitch;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
223 for (xc = cx + 1; xc < img->w; xc++)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
224 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225 DM_RADIAL_BLUR(>= img->h, >= img->w)
36
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
226 }
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
229 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
231
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232
9
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
233 static int my_toupper(int ch)
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
234 {
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
235 switch (ch)
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
236 {
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
237 case 0xe4: return 142;
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
238 case 0xf6: return 153;
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
239 default:
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
240 if (ch >= 'a' && ch <= 'z')
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
241 return ch - 'a' + 'A';
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
242 else
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
243 return ch;
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
244 }
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
245 }
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
246
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
247
13
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
248 static DMItemDef * dmGetItem(int t)
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
249 {
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
250 int i;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
251 for (i = 0; i < nitems; i++)
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
252 {
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
253 DMItemDef *def = &items[i];
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
254 if (t % def->freq == 0 && def->count <= def->max)
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
255 return def;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
256 }
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
257 return NULL;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
258 }
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
259
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
260
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
261 static void dmRenderItems(DMEngineData *engine, DMScaledBlitFunc ablit, DMFooItemDef *mitems, const int nmitems, const int layer)
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
262 {
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
263 int i;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
264 for (i = 0; i < nmitems; i++)
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
265 {
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
266 DMFooItemDef *item = &mitems[i];
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
267
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
268 if (item->enabled && item->ref->layer == layer)
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
269 {
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
270 ablit(item->ref->img,
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
271 dmCX(engine, item->xpos),
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
272 dmCY(engine, item->ypos),
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
273 dmQX(engine, item->ref->img, 1),
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
274 dmQY(engine, item->ref->img, 1),
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
275 engine->screen);
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
276 }
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
277 }
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
278 }
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
279
9
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
280
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
281 static int demoRender(DMEngineData *engine)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
282 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
283 float t = engineGetTimeDT(engine);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
284
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
285 //
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
286 // Do FFT
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
287 //
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
288 DMFFTType fftPow = 0;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
289 BOOL fftOK = FALSE;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
290 static DMFFTType fftAmp[FFT_SIZE / 2];
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
291 static DMFFTType fftData[FFT_SIZE];
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
292
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
293 dmMutexLock(engine->audioStreamMutex);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
294 if (engine->audioStreamBuf != 0 && engine->audioStreamLen > FFT_SIZE)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
295 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
296 int i;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
297 Sint16 *buf = (Sint16 *) engine->audioStreamBuf;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
298 for (i = 0; i < FFT_SIZE; i++)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
299 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
300 fftData[i] = *buf;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
301 buf += 2;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
302 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
303 fftOK = TRUE;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
304 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
305 dmMutexUnlock(engine->audioStreamMutex);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
306
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
307 if (fftOK)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
308 {
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
309 dmRealFFT(&fft, fftData);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
310 dmConvertFFTtoPowerAndSum(&fft, fftData, fftAmp, 1.0, &fftPow, 0.00004f);
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
311 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
312
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
313
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
314 //
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
315 // Taustaskrolli
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
316 //
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
317 {
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
318 static SDL_Surface *tausta = NULL,
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
319 *aurinko = NULL,
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
320 *bussi = NULL,
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
321 *rengas = NULL;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
322
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
323 static DMScaledBlitFunc cblit = NULL, ablit = NULL;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
324 static BOOL nollattu = FALSE;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
325 static DMLerpContext fadeLerp, fadeLerp2, fadeLerp3;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
326
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
327 if (!nollattu)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
328 {
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
329 dmLerpInit(&fadeLerp, 0, 255, 3000);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
330 dmLerpInit(&fadeLerp2, 0, 255, 4000);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
331 dmLerpInit(&fadeLerp3, 0, 1.2, 3000);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
332 engineGetResImage(engine, tausta, "tausta_pv.png");
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
333 engineGetResImage(engine, aurinko, "aurinko.png");
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
334 engineGetResImage(engine, bussi, "auto.png");
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
335 engineGetResImage(engine, rengas, "rengas.png");
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
336 cblit = dmGetScaledBlitFunc(tausta->format, engine->screen->format, DMD_NONE);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
337 ablit = dmGetScaledBlitFunc(bussi->format, engine->screen->format, DMD_TRANSPARENT);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
338 }
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
339
7
dde02bd75871 Scaling fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
340 int x1 = - ((int)dmQX(engine, tausta, t * 0.2) % (int) dmQX(engine, tausta, 1)),
dde02bd75871 Scaling fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
341 x2 = x1 + dmQX(engine, tausta, 1);
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
342
21
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
343 cblit(tausta, x1, 0, dmQX(engine, tausta, 1), dmQY(engine, tausta, 1), engine->screen);
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
344 cblit(tausta, x2, 0, dmQX(engine, tausta, 1), dmQY(engine, tausta, 1), engine->screen);
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
345
13
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
346 float qm = sin(t * 0.1 + fftPow * 5) * 0.05, qm2 = qm * 10;
21
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
347 ablit(aurinko,
13
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
348 dmCX(engine, 0.8 - dmLerpSCurveClamp(&fadeLerp3, engineGetTime(engine, 0) * 0.01) * 0.3 - qm),
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
349 dmCY(engine, 0.05 - qm),
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
350 dmQX(engine, aurinko, 1 + qm2),
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
351 dmQY(engine, aurinko, 1 + qm2),
21
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
352 engine->screen);
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
353
13
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
354 // Puut ym. liikennejutut
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
355 #define DM_MAX_MITEMS 16
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
356 static DMFooItemDef mitems[DM_MAX_MITEMS];
16
80634079f275 Import asset.
Matti Hamalainen <ccr@tnsp.org>
parents: 13
diff changeset
357 if (t > 6)
13
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
358 {
16
80634079f275 Import asset.
Matti Hamalainen <ccr@tnsp.org>
parents: 13
diff changeset
359 float dt = (t - 6);
13
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
360 static BOOL nollattu = FALSE;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
361 int i;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
362
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
363 if (!nollattu)
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
364 {
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
365 memset(mitems, 0, sizeof(mitems));
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
366 nollattu = TRUE;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
367 }
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
368
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
369 for (i = 0; i < DM_MAX_MITEMS; i++)
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
370 {
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
371 DMFooItemDef *item = &mitems[i];
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
372 if (!item->enabled && (item->ref = dmGetItem((int) t * 10 + 1)) != NULL)
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
373 {
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
374 item->enabled = TRUE;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
375 item->ref->count++;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
376 item->xtime = dt;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
377 item->ypos = item->ref->ypos + sin(dt) * 0.001f;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
378 }
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
379 }
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
380 for (i = 0; i < DM_MAX_MITEMS; i++)
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
381 {
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
382 DMFooItemDef *item = &mitems[i];
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
383 if (item->enabled)
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
384 {
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
385 float xpos = (dt - item->xtime) * item->ref->speed;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
386 if (xpos > 1.5)
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
387 {
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
388 item->enabled = FALSE;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
389 item->ref->count--;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
390 }
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
391 else
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
392 item->xpos = 1 - xpos;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
393 }
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
394 }
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
395 }
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
396
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
397 dmRenderItems(engine, ablit, mitems, DM_MAX_MITEMS, 0);
36
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
398
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
399 // Bussi ajaa sisään
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
400 if (t > 14)
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
401 {
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
402 float
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
403 dt = engineGetTime(engine, 14),
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
404 ajelu = dmLerpSCurveClamp(&fadeLerp3, dt),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
405 xc = dmCX(engine, -1 + ajelu),
13
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
406 yc = dmCY(engine, 0.38 + sin(t * 10) * 0.005),
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
407 yc2 = yc + dmQY(engine, bussi, 0.7) + dmCY(engine, sin(t * 20) * 0.001);
36
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
408
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
409 ablit(rengas, xc + dmQX(engine, bussi, 0.07), yc2, dmQX(engine, rengas, 1), dmQY(engine, rengas, 1), engine->screen);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
410 ablit(rengas, xc + dmQX(engine, bussi, 0.80), yc2, dmQX(engine, rengas, 1), dmQY(engine, rengas, 1), engine->screen);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
411 ablit(bussi, xc, yc, dmQX(engine, bussi, 1), dmQY(engine, bussi, 1), engine->screen);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
412 }
36
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
413
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
414
13
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
415 dmRenderItems(engine, ablit, mitems, DM_MAX_MITEMS, 1);
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
416 }
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
417
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
418 //
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
419 // AP logo
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
420 //
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
421 if (t > 4 && t < 8)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
422 {
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
423 int dt = engineGetTime(engine, 4);
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
424 static DMLerpContext fadeLerp;
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
425 static SDL_Surface *logo = NULL;
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
426 static BOOL nollattu = FALSE;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
427 if (!nollattu)
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
428 {
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
429 dmLerpInit(&fadeLerp, 0, 255, 1000);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
430 engineGetResImage(engine, logo, "ap.png");
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
431 nollattu = TRUE;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
432 }
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
433
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
434 int fadeVal;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
435 if (dt < 1000)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
436 fadeVal = dmLerpSCurveClamp(&fadeLerp, dt);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
437 else
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
438 if (dt > 3000)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
439 fadeVal = 255 - dmLerpSCurveClamp(&fadeLerp, dt - 3000);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
440 else
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
441 fadeVal = 255;
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
442
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
443 dmScaledBlitSurface32to32TransparentGA(logo,
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
444 dmQX(engine, logo, 0.2),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
445 dmQY(engine, logo, 0.3),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
446 dmQX(engine, logo, 1),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
447 dmQY(engine, logo, 1),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
448 engine->screen, fadeVal);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
449 }
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
450
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
451 //
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
452 // BUSSI logo
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
453 //
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
454 if (t > 10 && t < 14)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
455 {
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
456 int dt = engineGetTime(engine, 10);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
457 static DMLerpContext fadeLerp;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
458 static SDL_Surface *logo = NULL, *logo2 = NULL;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
459 static BOOL nollattu = FALSE;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
460 if (!nollattu)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
461 {
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
462 dmLerpInit(&fadeLerp, 0, 255, 1000);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
463 engineGetResImage(engine, logo, "bussi_logo.png");
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
464 engineGetResImage(engine, logo2, "dosa.png");
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
465 nollattu = TRUE;
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
466 }
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
467
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
468 int fadeVal, fadeVal2;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
469 if (dt < 1000)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
470 fadeVal = dmLerpSCurveClamp(&fadeLerp, dt);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
471 else
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
472 if (dt > 3000)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
473 fadeVal = 255 - dmLerpSCurveClamp(&fadeLerp, dt - 3000);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
474 else
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
475 fadeVal = 255;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
476
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
477 if (dt > 1000)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
478 {
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
479 if (dt < 2000)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
480 fadeVal2 = dmLerpSCurveClamp(&fadeLerp, dt - 1000);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
481 else
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
482 if (dt > 3000)
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
483 fadeVal2 = 255 - dmLerpSCurveClamp(&fadeLerp, dt - 3000);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
484 else
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
485 fadeVal2 = 255;
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
486 }
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
487 else
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
488 fadeVal2 = 0;
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
489
3
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
490 dmScaledBlitSurface32to32TransparentGA(logo,
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
491 dmCX(engine, 0.10),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
492 dmCY(engine, 0.2),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
493 dmQX(engine, logo, 1),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
494 dmQY(engine, logo, 1),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
495 engine->screen, fadeVal);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
496
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
497 dmScaledBlitSurface32to32TransparentGA(logo2,
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
498 dmCX(engine, 0.6),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
499 dmCY(engine, 0.6),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
500 dmQX(engine, logo2, 1),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
501 dmQY(engine, logo2, 1),
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
502 engine->screen, fadeVal2);
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
503 }
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
504
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
505
13
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
506 //
9
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
507 // Skrolleri
13
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
508 //
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
509 if (t > 3)
9
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
510 {
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
511 int tt = engineGetTime(engine, 2);
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
512 static DMScaledBlitFunc cblit, qblit;
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
513 static BOOL nollattu = FALSE;
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
514 if (!nollattu)
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
515 {
36
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
516 cblit = dmGetScaledBlitFunc(font->glyphs->format, engine->screen->format, DMD_TRANSPARENT);
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
517 qblit = dmGetScaledBlitFunc(font->glyphs->format, engine->screen->format, DMD_SATURATE);
9
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
518 }
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
519
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
520 size_t txtLen = teksti->rawSize - 1;
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
521 Uint8 *txtData = teksti->rawData;
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
522 int fwidth = font->width * 2 + 2;
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
523 int xc, offs, scrollTime = tt / 10,
36
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
524 // v-- bug
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
525 scrWidth = engine->screen->w / (dmQX(engine, font->glyphs, 1) + dmCX(engine, 0.001));
9
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
526
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
527 for (xc = offs = 0; offs < scrWidth; offs++)
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
528 {
36
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
529 const int ch = txtData[((scrollTime / fwidth) + offs) % txtLen];
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
530 SDL_Surface glyph;
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
531
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
532 dmGetBMGlyph(&glyph, font, my_toupper(ch));
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
533
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
534 float mt = (offs * 20 + tt) / 100.0f;
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
535 int dx = xc - (scrollTime % fwidth),
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
536 dy = dmCY(engine, 0.8 + sin(mt) * 0.05),
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
537 dw = glyph.w * 2 * (1.0f + sin(mt) * 0.1f),
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
538 dh = glyph.h * 2 * (1.0f + cos(mt) * 0.2f);
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
539
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
540 cblit(&glyph, dx+1, dy+1, dw+1, dh+1, engine->screen);
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
541 qblit(&glyph, dx, dy, dw, dh, engine->screen);
0b74381be601 Cleanups and more work towards working implementation on SDL2. But it's not
Matti Hamalainen <ccr@tnsp.org>
parents: 34
diff changeset
542
9
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
543 xc += fwidth;
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
544 }
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
545 }
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
546
13
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
547 //
21
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
548 // Alku- ja Loppufeidi
13
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
549 //
9
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
550 {
21
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
551 static DMLerpContext fadeLerp, fadeLerp2;
9
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
552 static SDL_Surface *feidi = NULL;
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
553 static BOOL nollattu = FALSE;
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
554 if (!nollattu)
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
555 {
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
556 engineGetResImage(engine, feidi, "feidi.png");
21
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
557 dmLerpInit(&fadeLerp, 255, 0, 3000);
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
558 dmLerpInit(&fadeLerp2, 0, 255, 5000);
9
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
559 }
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
560
21
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
561 int fadeVal = -1;
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
562 if (t < 5)
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
563 fadeVal = dmLerpSCurveClamp(&fadeLerp, engineGetTime(engine, 0));
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
564 else
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
565 if (t > 70)
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
566 fadeVal = dmLerpSCurveClamp(&fadeLerp2, engineGetTime(engine, 70));
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
567
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
568 if (fadeVal >= 0)
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
569 {
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
570 dmScaledBlitSurface32to32TransparentGA(feidi,
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
571 0,
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
572 0,
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
573 dmQX(engine, feidi, 1),
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
574 dmQY(engine, feidi, 1),
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
575 engine->screen,
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
576 fadeVal);
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
577 }
9
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
578 }
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
579
13
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
580 //
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
581 // Maskaus
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
582 //
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
583 {
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
584 static DMScaledBlitFunc cblit = NULL;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
585 static SDL_Surface *maski = NULL;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
586 static BOOL nollattu = FALSE;
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
587
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
588 if (!nollattu)
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
589 {
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
590 engineGetResImage(engine, maski, "maski.png");
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
591 cblit = dmGetScaledBlitFunc(maski->format, engine->screen->format, DMD_TRANSPARENT);
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
592 }
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
593
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
594 cblit(maski,
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
595 0, 0,
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
596 dmQX(engine, maski, 1),
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
597 dmQY(engine, maski, 1),
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
598 engine->screen);
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
599 }
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
600
952e27204992 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
601
9
77b2bb97fa59 Some stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
602 if (t > 75)
5
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
603 return 1;
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
604 else
dcec61df1633 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
605 return DMERR_OK;
0
f339a3903bc9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
606 }