/[projet1]/users/mmu_man/demos/oric/INVAL2K9/stars.c
Defence Force logotype

Contents of /users/mmu_man/demos/oric/INVAL2K9/stars.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 863 - (show annotations)
Fri Sep 21 12:36:30 2012 UTC (7 years, 8 months ago) by mmu_man
File MIME type: text/plain
File size: 6647 byte(s)
Move ORIC demos to demos/oric/

1 /* -*- c-basic-offset: 8 -*-
2 * (c) 2008, Francois Revol <revol@free.fr>
3 *
4 */
5
6 #include "global.h"
7 #include "stdlib.h"
8 //#include "fpmath.h"
9 #include "math.h"
10
11 #include "stars_tabs.h"
12
13 //#define DONTDRAW 1
14
15
16 //#define OPT_ 1
17 //#define USETRIGO 1
18
19 extern char div8u(char a,char b);
20 extern char div8s(char a,char b);
21
22
23 static const char *sText = "plop";
24 /*" THIS IS THE END - THANKS FOR WATCHING - SEE YOU NEXT TIME Credits: Code: mmu_man - Music: mmu_man :D - pictures: my webcam ";*/
25
26 #define CN "\007"
27 #define CT "\007"
28 #define CL "\002" /* labels */
29 #define CU "\004" /* urls */
30 #define CS "\002" /* separator */
31 #define CSEP "|"
32 #define SEP CS CSEP CN
33
34
35 static const char *sTexts[] = {
36 /*
37 "You are invited to : Alchimie 2k9" SEP "6-8 novembre 2009",
38 "Demo party / Conferences / Stands",
39 "Themes : Creation / Robotique / Developpement durable",
40 "DemoParty : OldSchool / NewSchool / Graph / Musique / Wild",
41 "Platefomes : Amiga / Atari / Linux / Haiku / ORIC / Ti92 ...",
42 "\x02Stands :\007assos\x02/\x07G3L\x02/\x07revendeurs Amiga... ",
43 "\x04http://triplea.fr/\x07",
44 "Greets : Cicile & Fabounio - TripleA - G3L - Corto - ",
45 "Rajah Lone / Renaissance - purelamers - Pops / woodtower - ",
46 "_DBug_ / Defence Force - PopsyTeam - Hello / SECTOR ONE - MJJ Prods",
47 "Credits : Code: mmu_man - Music : mmu_man",
48 */
49 NULL
50 };
51
52
53 extern int8 costable[256];
54
55
56
57 #if 1
58
59
60 struct _transform {
61 int8 *tabx;
62 int8 *taby;
63 char duration;
64 char rasters;
65 char equalizer;
66 //char noerase;
67 const char *text;
68 };
69
70 #define D1 40
71
72 static struct _transform gTransformList[] = {
73 { tabx_0, taby_0, D1, 0, 1, CL"You are invited to :"CN" Alchimie 2k9" SEP "6-8 novembre 2009 " },
74 { tabx_1, taby_1, D1, 0, 0, CN"Demo party"SEP"Conferences"SEP"Stands " },
75 { tabx_2, taby_2, D1, 0, 0, CL"Themes :"CN"Creation"SEP"Robotique"SEP"Developpement durable " },
76 { tabx_3, taby_3, 4*D1, 0, 0, CL"DemoParty :"CN"OldSchool"SEP"NewSchool"SEP"Graph"SEP"Musique"SEP"Wild " },
77 { tabx_1, taby_1, D1, 0, 0, CL"Platefomes :"CN"Amiga"SEP"Atari"SEP"Linux"SEP"Haiku"SEP"ORIC"SEP"Ti92 ... " },
78 { tabx_1, taby_1, D1, 0, 0, CL"Stands :"CN"assos"SEP"G3L"SEP"Voxel Amiga Shop"SEP"... " },
79 { tabx_1, taby_1, D1, 0, 0, CU"http://triplea.fr/ " },
80 { tabx_1, taby_1, D1, 1, 0, CL"Greets :"CN"Cicile & Fabounio"SEP"TripleA"SEP"G3L"SEP"Corto"SEP"Rajah Lone / Renaissance"SEP"purelamers"SEP"Pops / woodtower"SEP"_DBug_ / Defence Force"SEP"PopsyTeam"SEP"Hello / SECTOR ONE"SEP"MJJ Prods " },
81 { tabx_1, taby_1, D1, 0, 0, CL"Credits :"CN"Code: mmu_man"SEP"Music : mmu_man " },
82 { tabx_1, taby_1, D1, 0, 0, CL" \001</HADOPI> "},
83
84 //{ 0, 0, 2, 0, D1, 0 },
85 //{ 0, 1, 0, 0, D1, 1 }
86 };
87
88 #define NTRANS (sizeof(gTransformList)/sizeof(struct _transform))
89
90 static uint8 gTransform;
91
92 static struct _transform *gTr;
93
94
95 /* we'll use a 192x192 window (16*6*2)x(16*6*2) */
96
97
98 #define WW (16*6*2)
99 //#define WW (16*4*2)
100 #define WH WW
101
102 #define TAB_W 16
103 #define TAB_H 16
104
105 #define TAB_S (TAB_W*TAB_H)
106
107 #define O_X (-WW/2)
108 #define O_Y (-WH/2)
109
110 #define D_X (WW/TAB_W)
111 #define D_Y (WH/TAB_H)
112
113 #define DIV_X (TAB_W/WW)
114 #define DIV_Y (TAB_H/WH)
115
116 #define DO_X ((240 - WW)/2)
117 #define DO_Y ((200 - WH)/2)
118
119 /*
120 struct _vec {
121 char x;
122 char y;
123 };
124 */
125
126 static uint8 duration;
127
128 struct _star {
129 char oldx;
130 char oldy;
131 char x;
132 char y;
133 char tx;
134 char ty;
135 char sz;
136 };
137
138 #define NSTARS 10
139
140 struct _star gStars[NSTARS];
141
142 static uint8 sMusicDelay = 0;
143 //#define MUSIC_DELAY 4
144
145 void stars_do(void)
146 {
147 char uno = 1; /* either 1 or -1 to avoid 0 in some places */
148 #ifndef DONTDRAW
149 //StopInterrupt();
150 #endif
151
152
153 do {
154 int8 *tabx;
155 int8 *taby;
156 gTr = &gTransformList[gTransform];
157 tabx = gTr->tabx;
158 taby = gTr->taby;
159
160 if (gTr->text)
161 hires_scroll_text_set(gTr->text, A_FWWHITE);
162
163 if (gTr->rasters)
164 raster_start();
165
166 //printf("T%d\n", gTransform);
167
168 duration = gTr->duration;
169 // 1line/ tick -> must have time to regen whole tab
170 if (duration < TAB_H)
171 duration = TAB_H;
172
173 #ifdef DONTDRAW
174 stars_dump_tab(tabx, taby);
175 get();
176 #endif
177 do {
178 char o;
179 struct _star *s = gStars;
180 for (o = 0; o < NSTARS; o++, s++) {
181 uint8 tabo;
182 // update
183 if (!s->x && !s->y) {
184 uint16 x = ((uint16)rand() % WW);
185 uint16 y = ((uint16)rand() % WH);
186 //s->tx = x / D_X;
187 s->tx = div8s(x, D_X);
188 s->x = x + O_X;
189 //s->ty = y / D_Y;
190 s->ty = div8s(y, D_Y);
191 s->y = y + O_Y;
192 s->oldx=s->x;
193 s->oldy=s->y;
194
195 //printf("US[%d] %d,%d %d,%d\n", o, s->x, s->y, s->tx, s->ty);
196 }
197 //OPTIMIZED:
198 //tabo = TAB_W * s->ty + s->tx;
199 tabo = (((uint8)s->ty) << 4) | s->tx;
200
201 //printf("tab[%d,%d:%d] %d,%d\n", s->tx, s->ty, tabo, tabx[tabo], taby[tabo]);
202 s->x = s->oldx + tabx[tabo];
203 s->y = s->oldy + taby[tabo];
204
205 // XXX: is it really needed ?
206 // maybe only for rotations
207
208
209 #ifndef DONTDRAW
210
211 //if (!gTr->noerase) {
212 #if 1
213 GCLRPIX((uint8)(/*(uint16)*/DO_X-O_X+s->oldx),
214 (uint8)(/*(uint16)*/DO_Y-O_Y+s->oldy));
215 #endif
216 #if 0
217 curset(DO_X-O_X+s->oldx,DO_Y-O_Y+s->oldy,3);
218 hchar('a',0,0);
219 #endif
220 //}
221 #endif
222
223 // out of screen ?
224 if (s->x < O_X || s->x > O_X+WW-1) {
225 s->x = 0;
226 s->y = 0;
227 continue;
228 }
229 if (s->y < O_Y || s->y > O_Y+WH-1) {
230 s->x = 0;
231 s->y = 0;
232 continue;
233 }
234
235 //#ifdef IM_NOT_SURE_ABOUT_THAT
236 #if 0
237 s->tx = (s->x / D_X) + TAB_W/2;
238 s->ty = (s->y / D_Y) + TAB_H/2;
239 #endif
240 s->tx = div8s(s->x, D_X) + TAB_W/2;
241 s->ty = div8s(s->y, D_Y) + TAB_H/2;
242 //#endif
243
244 //ASSERT(s->x != s->oldx || s->y != s->oldy);
245 #ifndef DONTDRAW
246 #if 1
247 GSETPIX((uint8)(/*(uint16)*/DO_X-O_X+s->x),
248 (uint8)(/*(uint16)*/DO_Y-O_Y+s->y));
249 #endif
250 #if 0
251 curset(DO_X-O_X+s->x,DO_Y-O_Y+s->y,3);
252 hchar('a',0,1);
253 #endif
254 #endif /* DONTDRAW */
255 s->oldx=s->x;
256 s->oldy=s->y;
257
258 }
259 //
260 #ifdef DONTDRAW
261 //get();
262 #endif
263
264 // update
265
266 if (gTr->text)
267 hires_scroll_text_slice(0);
268 if (gTr->rasters)
269 raster_slice();
270 if (gTr->equalizer)
271 eq_update();
272 //duration--;
273 music_slice();
274 } while (duration && !hires_scroll_text_is_once());
275 if (gTr->rasters)
276 raster_stop();
277 if (gTr->equalizer)
278 eq_fini();
279
280 } while (gTransform++ < NTRANS-1);
281
282
283
284 #ifndef DONTDRAW
285 //RestoreInterrupt();
286 #endif
287 }
288
289 void stars_start(void)
290 {
291 char o;
292 gTransform = 0;
293 gTr = &gTransformList[0];
294 //XXX:
295 #ifdef DONTDRAW
296 DO_TEXT();
297 #endif
298 cls();
299 //printf("G\n");
300
301 #ifdef USETRIGO
302 //stars_dump_taba(taba);
303 #endif
304
305 #ifdef DONTDRAW
306 //stars_dump_tab(tab1x, tab1y);
307 #endif
308 //printf("GD\n");
309 for (o = 0; o < NSTARS; o++) {
310 gStars[o].x = 0;
311 gStars[o].y = 0;
312 }
313
314 }
315
316
317 #endif

  ViewVC Help
Powered by ViewVC 1.1.26