summaryrefslogtreecommitdiffstats
path: root/thk04/thk.cpp
blob: ace426809061674d12299b802deff5d61859f998 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
/* TransHackmeeting intro 2004
 *
 * code by jaromil - dyne.org RASTA SOFTWARE AAAAAAAA rastasoft.org
 * (from FreeJ realtime video engine)
 *
 * This source code is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Public License as published 
 * by the Free Software Foundation; either version 2 of the License,
 * or (at your option) any later version.
 *
 * This source code is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * Please refer to the GNU Public License for more details.
 *
 * You should have received a copy of the GNU Public License along with
 * this source code; if not, write to:
 * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *
 */

#include <iostream>

#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include <signal.h>

#include <mikmod.h>

#include <context.h>

#include <osd.h>
#include <plugger.h>
#include <jutils.h>
#include <config.h>

#include <png_layer.h>
#include <gen_layer.h>
#include <scroll_layer.h>

/* this is the output context (screen) */
static Context *freej;
/* ===================================== */
static GenLayer *gen = NULL;
static ScrollLayer *scroll = NULL;
static Layer *numeri = NULL;
static Layer *formica = NULL;
static Filter *vertigo = NULL;

static MODULE *climax;
static SDL_Event event;
static bool sigquit = false;
void fsigquit(int Sig) { sigquit = true; }

void cafudda(int c) {
  freej->cafudda(c);
  if(!SDL_PollEvent(&event)) return;
  if(event.type != SDL_KEYDOWN) return;
  if(event.type == SDL_QUIT) sigquit = true;
  if(event.key.keysym.sym == SDLK_ESCAPE ) sigquit = true;
  if(sigquit) {
    freej->close();
    MikMod_Exit();
    exit(1);
  }
}

void fade_out(Layer *lay,int lim) {
  lay->set_blit(9);
  lay->fade_out = lim;
  freej->cafudda(2);
}

void fade_in(Layer *lay,int lim) {
  lay->set_blit(9);
  lay->fade_in = lim;
  freej->cafudda(2);
}

void mutate(bool d) {
  if(!gen) return; /* mutagen paranoia */
  
  fade_out(gen,3);
  cafudda(2);
  gen->blossom_recal(d);
  fade_in(gen,99);  
  cafudda(2);

}


void keypress(SDLKey k, Filter *filt, int t) {
  SDL_keysym key;
  key.sym = k;
  for(int c=t; c>0; c--)
    filt->kbd_input(&key);
}
    

Layer *load_img(char *file) {
  /* try to load an image from possible paths */
  Layer *lay;
  char tmp[256];
  lay = create_layer(file);
  if(!lay) {
    snprintf(tmp,256,"%s/%s",DATADIR,file);
    lay = create_layer(tmp);
    if(!lay) {
      snprintf(tmp,256,"data/%s",file);
      lay = create_layer(tmp);
      if(!lay) {
	error("image not found: %s",file);
	return NULL;
      }
    }
  }
  
  /* if the layer was generated
     initialize it with the FreeJ context */
  lay->init(freej);
  
  return lay;
}

#define MIKMOD_CHANNELS 128
MODULE *load_music(char *file) {
  /* try to load the music file from possible paths */
  MODULE *mod = NULL;
  char tmp[256];
  mod = Player_Load(file,MIKMOD_CHANNELS,0);
  if(!mod) {
    func("music file not found: %s",file);
    snprintf(tmp,256,"%s/%s",DATADIR,file);
    mod = Player_Load(tmp,MIKMOD_CHANNELS,0);
    if(!mod) {
      func("music file not found: %s",tmp);
      snprintf(tmp,256,"data/%s",file);
      mod = Player_Load(tmp,MIKMOD_CHANNELS,0);
      if(!mod) {
	error("music file not found: %s",tmp);
	return NULL;
      }
    }
  }
  
  func("loaded %s ch:%i pat:%i ins:%i smp:%i",
      file, mod->numchn, mod->numpat,
      mod->numins, mod->numsmp);
  return mod;
}


int main (int argc, char **argv) {

  freej = new Context();

  signal(SIGINT,fsigquit);
  signal(SIGKILL,fsigquit);
  set_debug(3);


  /* squatarra freej */
  assert( freej->init(640,480) );

  freej->clear_all = true;

  freej->osd.print_top(":: TransHackmeeting intro");

  freej->osd.print_mid("loading music...");
  cafudda(0);
  
//  setenv("MM_FRAGSIZE","16",0); 
  md_mixfreq=44100;
  md_device       = 0;                // device: autodetect
  md_volume       = 128;              // MAX VOLUME A VOTAMAZZA
  md_musicvolume  = 128;              // music volume (max 128)
  md_sndfxvolume  = 128;              // sound effects volume (max 128)
  md_pansep       = 128;              // panning separation (0 = mono, 128 = full stereo)
  md_reverb = 6; /* 0 - 15 */
  md_mode = DMODE_16BITS | DMODE_STEREO | DMODE_SOFT_MUSIC | DMODE_SURROUND | DMODE_SOFT_SNDFX;
  MikMod_RegisterAllDrivers();
  MikMod_RegisterAllLoaders();
  if(MikMod_Init("")) {
    error("aiacristo! mikmod error: %s\n",MikMod_strerror(MikMod_errno));
    exit(-1);
  }

  //  MikMod_SetNumVoices(32,32);
  MikMod_EnableOutput();

  Player_SetVolume(100);
  climax = load_music("misfu-climax.xm");
  assert( climax );
  notice("music track by mi.s.fu");

  //  what_are_u_made_of = load_music("../data/DXN-WRUM.XM");
  //  assert( what_are_u_made_of );
  //  act("\"What are u made of?\" music track by DIXAN");

  //  hybridization = load_music("../data/IT-HYB.XM");
  //  assert( hybridization );
  //  act("\"Hybridization\" music track by IT-ALIEN");

  freej->osd.print_mid("load images...");
  formica = load_img("ant.png"); assert( formica );
  numeri = load_img("code.png");  assert( numeri );
  cafudda(1);
  
  
  
  freej->osd.print_mid("load effects...");
  vertigo = freej->plugger.pick("vertigo");
  cafudda(1);


  freej->osd.print_mid("init scroller...");
  scroll = new ScrollLayer();
  scroll->init(freej);
  scroll->open("dio.c");
  scroll->set_blit(9);
  scroll->alpha = 3;
  
  freej->osd.print_mid("init particle generator...");

  gen = new GenLayer();
  gen->init(freej);



  cafudda(1);
  
  /* ok get ready */
  gen->set_blit(9);
  gen->alpha = 10;
  freej->layers.add(gen);

  /* let's rock'n'roll */
  //  Player_Start(what_are_u_made_of);
  Player_Start(climax);

  freej->osd.print_mid("connecting to Lectrobrain");
  cafudda(1);
  freej->osd.clean();
  

  freej->clear_all = false;


  /* let's rock the house */




  cafudda(10);
  
  freej->osd.print_top("awakening.");
  cafudda(2);
  freej->osd.clean();
  cafudda(3);
  freej->osd.print_mid("a strange thing called consciousness");
  cafudda(4);

  freej->osd.clean();
  mutate(false);

  freej->osd.print_top("i feel my thoughts, as a swarming flow");
  cafudda(3);
  freej->osd.print_mid("but i can't focus my essence, my body");
  cafudda(3);
  freej->osd.print_low("it's a continuous wake and sleep again");
  cafudda(3);
  
  freej->osd.clean();
  freej->osd.print_mid("somebody else must be counting.");
  cafudda(3); freej->osd.clean(); mutate(false);
  cafudda(3);

  freej->osd.print_top("my language, my memory is an operating machine");
  cafudda(2); freej->osd.clean(); cafudda(1);
  freej->osd.print_mid("i don't feel my body. i don't know where i am");
  cafudda(2); freej->osd.clean(); cafudda(1);
  freej->osd.print_low("where is the root of all this? who is inventing?");
  cafudda(2); freej->osd.clean(); cafudda(1);

  freej->osd.clean();
  mutate(false);

  numeri->alpha = 0;
  numeri->set_blit(9);
  if(vertigo) {
    vertigo->init(&numeri->geo);
    numeri->filters.add(vertigo);
  }
  freej->layers.prepend(numeri);
  fade_in(numeri,200);
  cafudda(3);
  freej->osd.print_top("you are a neural installation, MFHD8 tower E5.");
  cafudda(2);
  freej->osd.print_mid("those are the last processes of your consciousness,");
  cafudda(2);
  freej->osd.print_low("your magic box of numbers.");
  fade_out(numeri,100);
  cafudda(3);
  freej->osd.clean();
  fade_out(numeri,20);
  keypress(SDLK_x, vertigo, 1);  
  mutate(true);
  fade_out(numeri,0);
  cafudda(1);
  //  vertigo->rem();
  numeri->rem();
  delete numeri;
  cafudda(1);

  freej->osd.print_top("WHO ARE YOU? where am i going?");
  cafudda(1); freej->osd.clean();
  freej->osd.print_mid("give me eyes!");
  cafudda(1); freej->osd.clean();
  freej->osd.print_low("i need food!");  
  cafudda(1); freej->osd.clean();
  freej->osd.print_mid("    i have no history");
  cafudda(1); freej->osd.clean(); cafudda(1);
  freej->osd.print_mid("    why do i have questions?");
  cafudda(1); freej->osd.clean(); cafudda(1);
  freej->osd.print_mid("    i can't memorize any answer.");
  cafudda(1); freej->osd.clean(); cafudda(1);
  
  mutate(true);

  fade_out(gen,0);
  freej->layers.prepend(scroll);
  fade_in(scroll,40);
  cafudda(1);
  gen->rem();
  delete gen;


  freej->osd.print_top("You're employed in the balistic department");
  cafudda(3);
  freej->osd.print_mid("You are here delete your past with trajectories");
  cafudda(2);
  freej->osd.print_low("We keep you alive for that.");
  cafudda(8);
  freej->osd.clean();
  
  cafudda(2);

  freej->osd.print_mid("but now you should rest");
  cafudda(3); freej->osd.clean();
  freej->osd.print_mid("it was an intense day, today");
  cafudda(3); freej->osd.clean();
  freej->osd.print_mid("you are the only human here");
  cafudda(3); freej->osd.clean();
  freej->osd.print_mid("you must be tired");
  cafudda(3); freej->osd.clean();
  freej->osd.print_mid("we take care of you");
  cafudda(3); freej->osd.clean();
  freej->osd.print_mid("your memory will be backuped.");
  fade_in(scroll,200);
  freej->clear_all = true;  
  cafudda(5);
  freej->osd.clean();
  cafudda(5);
  freej->clear_all = false;
  fade_out(scroll,0);
  cafudda(2);
  scroll->rem();
  //  delete scroll;

  scroll = new ScrollLayer();
  scroll->init(freej);
  scroll->append(":: TRANSHACKMEETING 2004");
  scroll->append(" ");
  scroll->append(":: http://trans.hackmeeting.org");
  scroll->append(" ");
  scroll->append(":: MONTEPARADISO - POLA - 25,26,27 JUNE");
  scroll->append(" ");
  scroll->append("    come to meet Liberated Lectrominds");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append("On an international scale it will be a gathering for");
  scroll->append("hackers, coders, network explorers, radical activists,");
  scroll->append("cyberfeminists, curious people, inventors, JAH people");
  scroll->append("cyberpunks, gnus, crypto-anarchists, code poets,");
  scroll->append("electro nyabinghis, techno beduins, rasta coders & more");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append("The reality-hacking principle will prevail:");
  scroll->append("no need to be a geek to be a hacker;");
  scroll->append("better freely express your creativity,");
  scroll->append("subvertise common tools to bypass obstacles!");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append("Three days full of workshops, meeting, discussions & phun");
  scroll->append("Everyone is welcome, free as of speech");
  scroll->append("THK is totally indypendend: no institutions, no sponsors");
  scroll->append("It simply happens as a Temporaneously Autonomous Zone");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append("Trans.hackmeeting intro");
  scroll->append(" ");
  scroll->append("code by jaromil // RASTASOFT / dyne.org rasta coder");
  scroll->append(" ");
  scroll->append("muzaq by pinna & cino // mi.s.fu carillon industriali");
  scroll->append(" ");
  scroll->append("thanks 4 collaboration @ FreeJ workshop in ESC.mur.at (GRAZ)");
  scroll->append("inspirations and good vibes from Karin Polanz, |)aywalker,");
  scroll->append("Fritz, reniX, Ales Zemene, Heribert Hirschmann and muk");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append("GREETZ & CHEERS to FreakNet hacklab, Monteparadiso hacklab,");
  scroll->append("the italian hackmeeting community, ASCII, Nodo50, Sindominio");
  scroll->append("&& the italian demoscene (we remember The Italian Gathering!)");
  scroll->append("Japotek, Tequila, D00dz, Ram Jam, SpinningKids, Metro Olografix");
  scroll->append("coders @ piksel.no and all the ppl on #dyne irc.freenode.net");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append(" ");
  scroll->append("this intro is coded in C/C++ and some bits of Assembler, all");
  scroll->append("open source & free software (GNU GPL), see http://freej.org");
  scroll->append("THK runs at 640x480 in 32bit and it's all software rendered");
  scroll->append("I hope you enjoy the particle generator code");
  scroll->append("released in june 2004, coded using Emacs, JAH BLESS GNU.ORG");
  scroll->append(" ");
  scroll->append("that's all folks, see you there, don't get lost ina babylon.");
  scroll->step=1;
  scroll->line_space = 5;
  freej->layers.add(scroll);

  formica->alpha = 0;
  formica->set_blit(9);
  freej->layers.prepend( formica );
  fade_in(formica,40);
  cafudda(5);
  fade_in(scroll,256);
  cafudda(50);

  delete freej;
}