Mercurial > hg > forks > 3x666-SDL
annotate 3x666.c @ 37:38b7583302c3
Add commandline parsing and help.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 19 Mar 2013 02:55:25 +0200 |
parents | dca4b72dc2e0 |
children | da3a7c376a84 |
rev | line source |
---|---|
9 | 1 #include <SDL.h> |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
2 #include <math.h> |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
3 #include <stdlib.h> |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
4 #include <unistd.h> |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
5 #include <string.h> |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
6 #include <stdarg.h> |
0 | 7 #include "config.h" |
8 #include "3xfont.h" | |
9 | |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
10 |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
11 #if !defined(FALSE) && !defined(TRUE) && !defined(BOOL) |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
12 typedef enum { FALSE = 0, TRUE = 1 } BOOL; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
13 #endif |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
14 |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
15 #ifndef BOOL |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
16 # ifdef bool |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
17 # define BOOL bool |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
18 # else |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
19 # define BOOL int |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
20 # endif |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
21 #endif |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
22 |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
23 |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
24 struct |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
25 { |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
26 int tickLen; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
27 int frameTime, frameCount, |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
28 startTime, endTime; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
29 |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
30 BOOL exitFlag; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
31 |
19
16efabca7e04
Some work on making the audio work .. there is sound, but it's not correct.
Matti Hamalainen <ccr@tnsp.org>
parents:
18
diff
changeset
|
32 int mixFill, mixBufSize; |
21
19fccd4a7404
Now works (or at least sounds like it sounds like it should sound like) :D ..
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
33 Sint32 *mixBuf; |
19
16efabca7e04
Some work on making the audio work .. there is sound, but it's not correct.
Matti Hamalainen <ccr@tnsp.org>
parents:
18
diff
changeset
|
34 |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
35 int optVFlags; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
36 SDL_Surface *screen; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
37 SDL_Event event; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
38 SDL_AudioSpec optAfmt; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
39 } engine; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
40 |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
41 |
0 | 42 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
43 typedef struct |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
44 { |
9 | 45 int x, y, z; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
46 } vec3d; |
0 | 47 |
7 | 48 |
0 | 49 int *ballz; |
50 | |
17 | 51 void setpal(void); |
52 | |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
53 |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
54 |
31 | 55 static void dmPrintVA(int level, const char *fmt, va_list ap) |
14 | 56 { |
37
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
57 (void) level; |
26
7f7330567277
Silence some build warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
58 #ifdef __WIN32 |
7f7330567277
Silence some build warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
59 (void) fmt; |
7f7330567277
Silence some build warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
60 (void) ap; |
7f7330567277
Silence some build warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
61 #else |
14 | 62 vfprintf(stderr, fmt, ap); |
63 #endif | |
64 } | |
65 | |
66 | |
31 | 67 static void dmPrint(int level, const char *fmt, ...) |
14 | 68 { |
26
7f7330567277
Silence some build warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
69 #ifdef __WIN32 |
7f7330567277
Silence some build warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
70 (void) fmt; |
7f7330567277
Silence some build warnings.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
71 #else |
14 | 72 va_list ap; |
73 | |
74 va_start(ap, fmt); | |
31 | 75 dmPrintVA(level, fmt, ap); |
14 | 76 va_end(ap); |
77 #endif | |
78 } | |
79 | |
80 | |
31 | 81 static inline int dmClamp(const int v, const int min, const int max) |
82 { | |
83 return (v < min ? min : (v > max ? max : v)); | |
84 } | |
85 | |
86 | |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
87 void dmErrorVA(const char *fmt, va_list ap) |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
88 { |
14 | 89 fprintf(stderr, SET_PROG_NAME ": "); |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
90 vfprintf(stderr, fmt, ap); |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
91 } |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
92 |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
93 |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
94 void dmError(const char *fmt, ...) |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
95 { |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
96 va_list ap; |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
97 |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
98 va_start(ap, fmt); |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
99 dmErrorVA(fmt, ap); |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
100 va_end(ap); |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
101 } |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
102 |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
103 |
31 | 104 static int engineGetTick() |
105 { | |
106 return ((engine.frameTime - engine.startTime) * SET_DEMOHZ) / 1000; | |
107 } | |
108 | |
109 | |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
110 static BOOL engineInitializeVideo() |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
111 { |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
112 SDL_FreeSurface(engine.screen); |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
113 |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
114 engine.screen = SDL_SetVideoMode(SET_VID_BUFW, SET_VID_BUFH, 8, engine.optVFlags); |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
115 if (engine.screen == NULL) |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
116 { |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
117 dmError("Can't SDL_SetVideoMode(): %s\n", SDL_GetError()); |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
118 return FALSE; |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
119 } |
16
e846eda89058
(Re)Set palette when (re)initializing video - aka fs/window.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
120 |
e846eda89058
(Re)Set palette when (re)initializing video - aka fs/window.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
121 setpal(); |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
122 return TRUE; |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
123 } |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
124 |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
125 |
0 | 126 /**************** tEXT dRAWiNG rOUTiNES ********** |
127 | |
128 bitmaps are for lamers :) let's use a little 12-segment calculator font... | |
129 ascii chars 32..90, 16 bits per char unpacked -> 114 bytes for the whole | |
130 font ;) let's credit karl/nooon for the original idea. */ | |
131 | |
18 | 132 void txtDrawSegment(int y, int x, int w, int h) |
0 | 133 { |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
134 /* clip clip clip */ |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
135 if (x + w > SET_VID_BUFW) |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
136 w = SET_VID_BUFW - x; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
137 if (x < 0) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
138 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
139 w += x; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
140 x = 0; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
141 } |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
142 if (y + h > SET_VID_BUFH) |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
143 h = SET_VID_BUFH - y; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
144 if (y < 0) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
145 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
146 h += y; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
147 y = 0; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
148 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
149 if (w > 0 && h > 0) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
150 { |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
151 Uint8 *b = engine.screen->pixels + (y * engine.screen->pitch) + x; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
152 for (; h; h--) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
153 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
154 memset(b, 122, w); |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
155 b += engine.screen->pitch; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
156 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
157 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
158 } |
0 | 159 |
18 | 160 void txtDrawChar(int x, int y, int c, int xunit, int yunit) |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
161 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
162 x -= xunit * 2; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
163 y -= yunit * 3; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
164 for (;;) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
165 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
166 if (!c) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
167 break; |
0 | 168 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
169 if (c & 1) |
18 | 170 txtDrawSegment(y, x + 1, xunit * 2 - 2, yunit); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
171 if (c & 2) |
18 | 172 txtDrawSegment(y, x + 1 + xunit * 2, xunit * 2 - 2, yunit); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
173 y++; |
0 | 174 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
175 c >>= 2; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
176 if (!c) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
177 break; |
0 | 178 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
179 if (c & 1) |
18 | 180 txtDrawSegment(y, x, xunit, yunit * 3 - 2); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
181 if (c & 2) |
18 | 182 txtDrawSegment(y, x + ((xunit * 3) >> 1), xunit, yunit * 3 - 2); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
183 if (c & 4) |
18 | 184 txtDrawSegment(y, x + xunit * 3, xunit, yunit * 3 - 2); |
0 | 185 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
186 y += yunit * 2; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
187 c >>= 3; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
188 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
189 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
190 |
9 | 191 void drawtxtscr(char *str) |
0 | 192 { |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
193 int x = SET_VID_BUFW >> 4, y = SET_VID_BUFH >> 3; |
9 | 194 while (*str) |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
195 { |
9 | 196 if (*str >= 32) |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
197 { |
18 | 198 txtDrawChar(x, y, phont[*str - 32], SET_VID_BUFW / 50, SET_VID_BUFW / 80); |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
199 x += SET_VID_BUFW / 10; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
200 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
201 else |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
202 { |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
203 x = SET_VID_BUFW >> 4; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
204 y += SET_VID_BUFW / 10; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
205 } |
9 | 206 str++; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
207 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
208 } |
0 | 209 |
210 | |
9 | 211 void flashtxt(char *str) |
0 | 212 { |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
213 int x = (SET_VID_BUFW >> 1) - (strlen(str) + 1) * 3 * SET_VID_BUFW / 80; |
9 | 214 while (*str) |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
215 { |
18 | 216 txtDrawChar(x, SET_VID_BUFH >> 1, phont[*str++ - 32], SET_VID_BUFW / 50, SET_VID_BUFW / 80); |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
217 x += SET_VID_BUFW / 10; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
218 } |
0 | 219 } |
220 | |
221 /*************************** DA PHONGBALL HEAVEN ************** | |
222 | |
223 A short course on phongball theory! | |
224 | |
225 A sphere: x^2+y^2+z^2=R^2 | |
226 | |
227 Diffuse shading: intensity = dotproduct(surfacenormal,lightvector) | |
228 | |
229 (doing this for every drawn point of the surface is sometimes called | |
230 phong shading even if the normals aren't actually interpolated) | |
231 | |
232 For a sphere, a normal vector at a point of the surface == constant * | |
233 the coordinates of the point (if center == origo). | |
234 | |
235 Thus, the function for the intensity of a 2d-projected phongball can be | |
236 stated as | |
237 | |
238 intensity(x,y) = l.x*x + l.y*y + l.z*z, z = sqrt(R^2-x^2-y^2) | |
239 | |
240 The first two muls can be eliminated easily. (and will be eliminated by | |
241 a good compiler even if you are lazy) | |
242 | |
243 The third mul can be eliminated by approximating l.z*z with a function | |
244 of the form f(x)=a*x^2+c. This approximation makes the ball look a bit | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
245 "twisty" but who cares, it just looks damn cool ;) |
0 | 246 |
247 ***/ | |
248 | |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
249 #if (SET_VID_BUFH < SET_VID_BUFW) |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
250 # define maxR (SET_VID_BUFH >> 1) |
0 | 251 #else |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
252 # define maxR (SET_VID_BUFW >> 1) |
0 | 253 #endif |
254 | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
255 struct |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
256 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
257 int *tab; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
258 signed int R; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
259 } balltab[50]; |
0 | 260 |
261 void preball() | |
262 { | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
263 unsigned int rR; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
264 signed int R; |
0 | 265 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
266 for (rR = 0; rR < 48; rR++) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
267 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
268 int R2, *d; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
269 signed int y; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
270 R = (maxR * (rR + 4)) / 52; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
271 if (R < 2) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
272 R = 2; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
273 R2 = R * R; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
274 balltab[rR].R = R; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
275 d = balltab[rR].tab = malloc(R * 2 * sizeof(int)); |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
276 for (y = -R + 1; y < R - 1; y++) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
277 *d++ = sqrt(R2 - y * y); |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
278 } |
0 | 279 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
280 balltab[49].R = balltab[48].R = balltab[47].R; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
281 balltab[49].tab = balltab[48].tab = balltab[47].tab; |
0 | 282 } |
283 | |
284 | |
9 | 285 void drawball_inloop(Uint8 *d, int dotxyz, int ddot, int dddot, int x) |
0 | 286 { |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
287 for (; x; x--) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
288 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
289 dotxyz += ddot; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
290 ddot += dddot; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
291 *d++ = dotxyz >> 16; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
292 } |
0 | 293 } |
294 | |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
295 void drawball(SDL_Surface *screen, vec3d * l, int relR) |
0 | 296 { |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
297 int R = balltab[relR].R, *s = balltab[relR].tab; |
0 | 298 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
299 signed int doty = (-(R - 1) * l->y); |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
300 signed int y = R * 2 - 2; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
301 |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
302 Uint8 *dp = screen->pixels + (SET_VID_BUFW >> 1) - R + ((SET_VID_BUFH >> 1) - R) * screen->pitch; |
0 | 303 |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
304 for (; y; y--) |
9 | 305 { |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
306 int halfw = *s++; |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
307 if (halfw) |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
308 { |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
309 drawball_inloop(dp + R - halfw, |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
310 (doty - (l->x * halfw)) << 8, |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
311 (l->x + l->z) << 8, |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
312 0 - ((l->z << 8) / halfw), halfw << 1); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
313 } |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
314 dp += screen->pitch; |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
315 doty += l->y; |
9 | 316 } |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
317 } |
0 | 318 |
319 /* some extra for freaks: a plasma made with the phongball innerloop :) | |
320 looks ugly. | |
321 | |
322 void drawplasma(char *d,float t) | |
323 { | |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
324 int y=SET_VID_BUFH; float u=0,du=500/SET_VID_BUFH; |
0 | 325 |
326 for(;y;y--){ | |
327 drawball_inloop(d, | |
328 sin(t*0.02+0+u*0.033)*65536*256, | |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
329 cos(t*0.04+1+u*0.022)*65536*4096/SET_VID_BUFW, |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
330 -2*cos(t*0.04+1+u*0.022)*65536*4096/(SET_VID_BUFW*SET_VID_BUFW), SET_VID_BUFW); |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
331 d+=SET_VID_BUFW; |
0 | 332 u+=du; |
333 } | |
334 } | |
335 */ | |
336 | |
337 /************************ oTHA FX ***************/ | |
338 | |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
339 void rotochess(SDL_Surface *screen, int du, int dv, int iu, int iv) |
0 | 340 { |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
341 int hu = iu - (dv * (SET_VID_BUFH >> 1)) - (du * (SET_VID_BUFW >> 1)), |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
342 hv = iv + (du * (SET_VID_BUFH >> 1)) - (dv * (SET_VID_BUFW >> 1)); |
0 | 343 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
344 int y; |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
345 Uint8 *dp = screen->pixels; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
346 |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
347 for (y = SET_VID_BUFH; y; y--) |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
348 { |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
349 Uint8 *d = dp; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
350 int u = hu, v = hv, x; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
351 for (x = SET_VID_BUFW; x; x--) |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
352 { |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
353 u += du; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
354 v += dv; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
355 *d++ = ((u ^ v) >> 8) & 0xb1; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
356 } |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
357 dp += screen->pitch; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
358 hu += dv; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
359 hv -= du; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
360 } |
0 | 361 } |
362 | |
363 /***************************************************************/ | |
364 | |
9 | 365 |
17 | 366 void setpal(void) |
0 | 367 { |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
368 SDL_Color pal[SET_VID_COLORS]; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
369 int i, a = 3, b = 0; |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
370 |
24
7c314ac342f4
Cleanups and plug some memory leaks.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
371 for (i = SET_VID_COLORS - 1; i >= 0; i--) |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
372 { |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
373 int n = (i + 128) & 255; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
374 pal[n].r = (abs(i - 140) >> a) & 255; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
375 pal[n].g = ((abs(i - 128) >> b) & 255) ^ 1; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
376 pal[n].b = (abs(i - 96) >> b) & 255; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
377 if (i == 128) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
378 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
379 a = 0; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
380 b = 1; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
381 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
382 } |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
383 |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
384 SDL_SetColors(engine.screen, pal, 0, SET_VID_COLORS); |
0 | 385 } |
386 | |
9 | 387 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
388 void unitvec(vec3d * v, float a, float b, float c, float m) |
0 | 389 { |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
390 float cam = cos(a) * m, sam = sin(a) * m, sbcam = sin(b) * cam; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
391 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
392 v->x = cos(b) * cam; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
393 v->y = cos(c) * sam - sin(c) * sbcam; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
394 v->z = cos(c) * sbcam + sin(c) * sam; |
0 | 395 } |
396 | |
27 | 397 |
0 | 398 /************************* MUSiC cODE **************************/ |
399 | |
400 /* This table was ripped (and reduced and rudely integerized) from the | |
401 Maube tracker by K .. keep on the good work man! ;) */ | |
402 | |
9 | 403 const Sint16 noterate[3 * 12] = |
8 | 404 { |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
405 1000, 1059, 1122, 1189, 1259, 1334, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
406 1414, 1498, 1587, 1681, 1781, 1887, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
407 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
408 2000, 2118, 2244, 2378, 2519, 2669, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
409 2828, 2996, 3174, 3363, 3563, 3775, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
410 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
411 4000, 4237, 4489, 4756, 5039, 5339, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
412 5656, 5993, 6349, 6727, 7127, 7550 |
0 | 413 }; |
414 | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
415 /* 64 bytes of pure musical power ;) |
0 | 416 Originally composed with Scream Tracker. */ |
417 | |
8 | 418 const char basstrak[32] = |
419 { | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
420 12, 0, 24, 12, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
421 12, 24, 12, 24, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
422 12, 0, 24, 12, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
423 12, 24, 12, 24, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
424 15, 0, 27, 15, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
425 15, 27, 15, 27, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
426 14, 0, 26, 14, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
427 15, 27, 17, 29 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
428 }; |
0 | 429 |
8 | 430 const char melody[32] = |
431 { | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
432 24, 12, 19, 15, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
433 24, 0, 19, 0, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
434 24, 12, 19, 15, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
435 24, 0, 15, 19, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
436 15, 19, 15, 19, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
437 22, 0, 15, 19, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
438 14, 17, 21, 14, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
439 22, 17, 17, 22 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
440 }; |
0 | 441 |
24
7c314ac342f4
Cleanups and plug some memory leaks.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
442 int *drum0 = NULL, |
7c314ac342f4
Cleanups and plug some memory leaks.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
443 *drum1 = NULL; |
0 | 444 |
9 | 445 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
446 /* sampling sucks! */ |
0 | 447 void audio_precalcs() |
448 { | |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
449 int drumlgt = engine.tickLen * SET_ROWTIX * 4; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
450 int *d = drum0 = malloc(drumlgt * sizeof(int)), |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
451 *e = drum1 = malloc(drumlgt * sizeof(int)), i, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
452 vol = 24680, dvol = 35000 / (float) drumlgt; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
453 int o = 0, oo = 0; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
454 float a = 0, da = 386 / (float) drumlgt, dda = da / (float) drumlgt; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
455 |
31 | 456 dmPrint(0, "aCtIvATiNg 303 eMuLAtOR\n"); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
457 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
458 for (i = drumlgt; i; i--) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
459 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
460 o = (o >> 1) + (rand() % vol) - (rand() % vol); |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
461 oo = (oo * 2 + ((rand() % vol) - (rand() % vol))) / 3; |
0 | 462 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
463 o *= sin(a); |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
464 oo *= sin(a); |
0 | 465 |
15 | 466 *d++ = (vol * sin((a / 2) + ((float) dmClamp(o * 2, -65535, 65535)) / 80000)); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
467 *e++ = (vol * sin(a + ((float) oo) / 60000)); |
0 | 468 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
469 a += da; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
470 da -= dda; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
471 vol -= dvol; |
9 | 472 } |
473 } | |
0 | 474 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
475 |
24
7c314ac342f4
Cleanups and plug some memory leaks.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
476 void audio_close() |
7c314ac342f4
Cleanups and plug some memory leaks.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
477 { |
7c314ac342f4
Cleanups and plug some memory leaks.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
478 if (drum0) free(drum0); |
7c314ac342f4
Cleanups and plug some memory leaks.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
479 if (drum1) free(drum1); |
7c314ac342f4
Cleanups and plug some memory leaks.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
480 } |
7c314ac342f4
Cleanups and plug some memory leaks.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
481 |
27 | 482 |
21
19fccd4a7404
Now works (or at least sounds like it sounds like it should sound like) :D ..
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
483 static int engineRenderAudio(Sint32 *stream) |
0 | 484 { |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
485 static int rowno = 0; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
486 static signed int delta = -5; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
487 static char ismelody = 0, silend = 0; |
15 | 488 int i, rowlgt = engine.tickLen * SET_ROWTIX; |
21
19fccd4a7404
Now works (or at least sounds like it sounds like it should sound like) :D ..
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
489 Sint32 *d = stream, note; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
490 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
491 /* BASS (sawtooth ofcoz) */ |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
492 note = basstrak[(rowno >> 1) & 31]; |
0 | 493 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
494 if (!note) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
495 note = basstrak[((rowno >> 1) & 31) - 1]; |
9 | 496 else |
497 if (rowno & 1) | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
498 note = 0; |
9 | 499 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
500 if ((rowno & 3) == 3) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
501 note = 0; |
9 | 502 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
503 if (note) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
504 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
505 int ps = 16384, dps; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
506 note += delta; |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
507 dps = ((noterate[note] << 10) / SET_AUDIO_FREQ); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
508 for (i = rowlgt; i; i--) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
509 { |
21
19fccd4a7404
Now works (or at least sounds like it sounds like it should sound like) :D ..
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
510 *d++ = ps; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
511 ps = (ps + dps) & 32767; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
512 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
513 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
514 else |
9 | 515 { |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
516 for (i = rowlgt; i; i--) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
517 *d++ = 16384; |
9 | 518 } |
0 | 519 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
520 /* MELODY (sawtooth as well :) */ |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
521 if (!(silend && ((rowno & 63) > 47))) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
522 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
523 if (ismelody) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
524 { |
21
19fccd4a7404
Now works (or at least sounds like it sounds like it should sound like) :D ..
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
525 d = stream; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
526 if (rowno & 1) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
527 note = 0; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
528 else |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
529 note = melody[(rowno >> 1) & 31]; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
530 if (note) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
531 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
532 int ps = 16384, dps; /* this loop is different */ |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
533 note += delta; |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
534 dps = ((noterate[note] << 12) / engine.optAfmt.freq); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
535 for (i = rowlgt; i; i--) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
536 { |
21
19fccd4a7404
Now works (or at least sounds like it sounds like it should sound like) :D ..
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
537 *d++ += ps; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
538 ps = (ps + dps) & 32767; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
539 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
540 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
541 } |
9 | 542 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
543 /* DRUMS (rave on!!!) */ |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
544 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
545 int *s = drum1; |
21
19fccd4a7404
Now works (or at least sounds like it sounds like it should sound like) :D ..
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
546 d = stream; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
547 if (rowno & 4) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
548 s = drum0; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
549 s += (rowno & 3) * rowlgt; |
0 | 550 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
551 for (i = rowlgt; i; i--) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
552 *d++ += *s++; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
553 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
554 } |
21
19fccd4a7404
Now works (or at least sounds like it sounds like it should sound like) :D ..
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
555 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
556 /* PATTERN SHIFT */ |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
557 rowno++; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
558 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
559 /* no switch+case? just check out how gcc handles them! |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
560 it's 1024+ bytes for every phukken switch statement! |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
561 in this case we can prefer size to speed, can't we? */ |
0 | 562 |
9 | 563 if ((rowno & 63) == 0) |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
564 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
565 int r = rowno >> 6; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
566 if (r == 2) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
567 delta = 0; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
568 if (r == 4) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
569 ismelody = 1; |
8 | 570 if (r == 6 || r == 10) |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
571 delta = 5; |
8 | 572 if (r == 7 || r == 11) |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
573 silend = 1; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
574 if (r == 8) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
575 delta = silend = 0; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
576 if (r == 12) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
577 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
578 rowno = ismelody = silend = 0; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
579 delta = -5; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
580 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
581 } |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
582 |
15 | 583 return rowlgt; |
584 } | |
585 | |
586 | |
587 static void engineAudioCallback(void *userdata, Uint8 *stream, int len) | |
588 { | |
589 (void) userdata; | |
31 | 590 |
19
16efabca7e04
Some work on making the audio work .. there is sound, but it's not correct.
Matti Hamalainen <ccr@tnsp.org>
parents:
18
diff
changeset
|
591 // We inherently assume mono here, as the audio code is not |
16efabca7e04
Some work on making the audio work .. there is sound, but it's not correct.
Matti Hamalainen <ccr@tnsp.org>
parents:
18
diff
changeset
|
592 // capable of producing stereo anyway (for now, at least.) |
21
19fccd4a7404
Now works (or at least sounds like it sounds like it should sound like) :D ..
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
593 int i, need = len / sizeof(Sint16); |
19
16efabca7e04
Some work on making the audio work .. there is sound, but it's not correct.
Matti Hamalainen <ccr@tnsp.org>
parents:
18
diff
changeset
|
594 |
31 | 595 // fprintf(stderr, "%p : %p @ %d -> %d\n", userdata, stream, len, need); |
596 // fflush(stderr); | |
597 | |
598 #if 1 | |
19
16efabca7e04
Some work on making the audio work .. there is sound, but it's not correct.
Matti Hamalainen <ccr@tnsp.org>
parents:
18
diff
changeset
|
599 // The audio rendering handling is a bit silly due to the way |
16efabca7e04
Some work on making the audio work .. there is sound, but it's not correct.
Matti Hamalainen <ccr@tnsp.org>
parents:
18
diff
changeset
|
600 // the original code works (assumes that it can always render |
16efabca7e04
Some work on making the audio work .. there is sound, but it's not correct.
Matti Hamalainen <ccr@tnsp.org>
parents:
18
diff
changeset
|
601 // a certain amount/duration of data, instead of being given |
16efabca7e04
Some work on making the audio work .. there is sound, but it's not correct.
Matti Hamalainen <ccr@tnsp.org>
parents:
18
diff
changeset
|
602 // the buffer duration/size to render. So we cope with that here. |
25 | 603 if (need >= engine.mixBufSize) |
604 need = engine.mixBufSize; | |
605 | |
31 | 606 while (engine.mixFill < need) |
19
16efabca7e04
Some work on making the audio work .. there is sound, but it's not correct.
Matti Hamalainen <ccr@tnsp.org>
parents:
18
diff
changeset
|
607 { |
16efabca7e04
Some work on making the audio work .. there is sound, but it's not correct.
Matti Hamalainen <ccr@tnsp.org>
parents:
18
diff
changeset
|
608 int got = engineRenderAudio(engine.mixBuf + engine.mixFill); |
16efabca7e04
Some work on making the audio work .. there is sound, but it's not correct.
Matti Hamalainen <ccr@tnsp.org>
parents:
18
diff
changeset
|
609 engine.mixFill += got; |
16efabca7e04
Some work on making the audio work .. there is sound, but it's not correct.
Matti Hamalainen <ccr@tnsp.org>
parents:
18
diff
changeset
|
610 } |
16efabca7e04
Some work on making the audio work .. there is sound, but it's not correct.
Matti Hamalainen <ccr@tnsp.org>
parents:
18
diff
changeset
|
611 |
21
19fccd4a7404
Now works (or at least sounds like it sounds like it should sound like) :D ..
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
612 Sint16 *dp = (Sint16 *) stream; |
19fccd4a7404
Now works (or at least sounds like it sounds like it should sound like) :D ..
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
613 Sint32 *sp = engine.mixBuf; |
19fccd4a7404
Now works (or at least sounds like it sounds like it should sound like) :D ..
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
614 for (i = 0; i < need; i++) |
19fccd4a7404
Now works (or at least sounds like it sounds like it should sound like) :D ..
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
615 *dp++ = dmClamp(*sp++, -32767, 32767); |
19fccd4a7404
Now works (or at least sounds like it sounds like it should sound like) :D ..
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
616 |
19
16efabca7e04
Some work on making the audio work .. there is sound, but it's not correct.
Matti Hamalainen <ccr@tnsp.org>
parents:
18
diff
changeset
|
617 engine.mixFill -= need; |
16efabca7e04
Some work on making the audio work .. there is sound, but it's not correct.
Matti Hamalainen <ccr@tnsp.org>
parents:
18
diff
changeset
|
618 if (engine.mixFill > 0) |
16efabca7e04
Some work on making the audio work .. there is sound, but it's not correct.
Matti Hamalainen <ccr@tnsp.org>
parents:
18
diff
changeset
|
619 { |
21
19fccd4a7404
Now works (or at least sounds like it sounds like it should sound like) :D ..
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
620 memmove(engine.mixBuf, engine.mixBuf + need, engine.mixFill * sizeof(Sint32)); |
19
16efabca7e04
Some work on making the audio work .. there is sound, but it's not correct.
Matti Hamalainen <ccr@tnsp.org>
parents:
18
diff
changeset
|
621 } |
25 | 622 #endif |
0 | 623 } |
624 | |
625 | |
626 /**************** tEXT gENERATORS eTC ***************/ | |
627 | |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
628 char skrtxt[] = |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
629 { |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
630 " HI THERE ! THIS IS THE FIRST OCSA RELEASE FOR LINUX ! " |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
631 "IT'S A STUPID INTRO CALLED 3X666 ! " |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
632 }; |
0 | 633 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
634 |
0 | 635 #define CHTIME 16 |
636 #define CHPSCR 8 | |
637 | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
638 void plainscroll(int t) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
639 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
640 int chno = t / CHTIME; |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
641 int x = 0 - ((t % CHTIME) * (SET_VID_BUFW / CHPSCR)) / CHTIME; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
642 int h = (abs((t % 48) - 24) * SET_VID_BUFH) / 256, i; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
643 char *c = skrtxt + chno; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
644 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
645 for (i = 0; i < CHPSCR + 1; i++) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
646 { |
18 | 647 txtDrawChar(x, (SET_VID_BUFH * 3) / 4, phont[*c++ - 32], SET_VID_BUFW / (6 * CHPSCR), h); |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
648 x += SET_VID_BUFW / CHPSCR; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
649 } |
0 | 650 } |
651 | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
652 char *lyrix(void) |
0 | 653 { |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
654 static int phinext = 0, philast; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
655 int phiwsty; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
656 char *phiword; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
657 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
658 phiwsty = phinext; |
0 | 659 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
660 if (!phiwsty) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
661 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
662 if (!(rand() & 3)) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
663 phiwsty = 13; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
664 else |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
665 phiwsty = 1 + (rand() & 1); |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
666 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
667 if (phiwsty == 1) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
668 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
669 char *w[] = { "HERE", "THERE", "NOW", "TOMORROW", "TODAY", "NEVER" }; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
670 phiword = w[rand() % 6]; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
671 if (rand() & 1) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
672 phinext = 2; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
673 else |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
674 phinext = 12; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
675 } |
8 | 676 else |
677 if (phiwsty == 2) | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
678 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
679 char nx[] = { 5, 10, 7, 3, 11 }; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
680 philast = rand() & 1; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
681 if (!philast) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
682 phiword = "YOU"; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
683 else |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
684 phiword = "I"; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
685 phinext = nx[rand() % 5]; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
686 } |
8 | 687 else |
688 if (phiwsty == 3) | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
689 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
690 char *w[] = { "DON'T", "CAN'T", "WON'T", "COULDN'T" }; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
691 phiword = w[rand() % 4]; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
692 phinext = 7 + (rand() & 4); |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
693 } |
8 | 694 else |
695 if (phiwsty == 4) | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
696 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
697 if (rand() & 1) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
698 phiword = "YOU"; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
699 else |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
700 phiword = "ME"; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
701 if (rand() & 1) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
702 phinext = 6; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
703 else if (rand() & 1) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
704 phinext = 0; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
705 else |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
706 phinext = 11; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
707 } |
8 | 708 else |
709 if (phiwsty == 5) | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
710 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
711 if (philast) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
712 phiword = "AM"; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
713 else |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
714 phiword = "ARE"; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
715 if (rand() & 1) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
716 phinext = 6; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
717 else |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
718 phinext = 12 + (rand() & 1); |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
719 } |
8 | 720 else |
721 if (phiwsty == 6) | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
722 { |
8 | 723 char *w[] = { |
724 "FALLING", "THINKING", "DREAMING", "CRYING", | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
725 "LYING", "REACHING", "BREATHING", "BURNING", "RUNNING" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
726 }; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
727 phiword = w[rand() % 9]; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
728 if (rand() & 1) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
729 phinext = 9; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
730 else if (rand() & 1) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
731 phinext = 0; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
732 else |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
733 phinext = 13; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
734 } |
8 | 735 else |
736 if (phiwsty == 7) | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
737 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
738 char nx[] = { 8, 4, 12 }; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
739 if (rand() & 1) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
740 phiword = "NEED"; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
741 else |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
742 phiword = "WANT"; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
743 phinext = nx[rand() % 3]; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
744 } |
8 | 745 else |
746 if (phiwsty == 8) | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
747 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
748 phiword = "TO"; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
749 phinext = 11; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
750 } |
8 | 751 else |
752 if (phiwsty == 9) | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
753 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
754 char *w[] = { "DOWN", "OFF", "OUT", "UP", "ABOUT" }; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
755 phiword = w[rand() % 5]; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
756 if (rand() & 1) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
757 phinext = rand() & 4; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
758 else |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
759 phinext = 12 + (rand() & 1); |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
760 } |
8 | 761 else |
762 if (phiwsty == 10) | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
763 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
764 char *w[] = { "CAN", "COULD", "WOULD", "MAY", "MIGHT" }; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
765 phiword = w[rand() % 5]; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
766 if (rand() & 1) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
767 phinext = 11; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
768 else |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
769 phinext = 12; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
770 } |
8 | 771 else |
772 if (phiwsty == 11) | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
773 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
774 char *w[] = { "SEE", "HEAR", "FEEL", "THINK" }; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
775 phiword = w[rand() % 4]; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
776 if (rand() & 1) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
777 phinext = 12; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
778 else |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
779 phinext = rand() & 4; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
780 } |
8 | 781 else |
782 if (phiwsty == 12) | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
783 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
784 char *w[] = { "WHAT", "SOMETHING", "NOTHING", "THINGS", "WHATEVER" }; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
785 phiword = w[rand() % 5]; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
786 phinext = 2; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
787 } |
8 | 788 else |
789 if (phiwsty == 13) | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
790 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
791 phiword = "THE"; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
792 phinext = 14; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
793 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
794 else |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
795 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
796 char *w[] = { "WAY", "EYES", "WORLD", "ROBOT", "FREEDOM", "HATE" }; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
797 phiword = w[rand() % 6]; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
798 phinext = 0; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
799 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
800 return phiword; |
0 | 801 } |
802 | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
803 char *dotxtscr(void) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
804 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
805 static int cnt = 0; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
806 cnt++; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
807 if (cnt == 1) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
808 return "WHERES THE\n" "DESIGN?\n\n" "WHERES THE\n" "ATTITUDE?!"; |
0 | 809 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
810 if (cnt == 2) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
811 return "NOTHING\n" "HAPPENED\n" "IN 1997"; |
0 | 812 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
813 if (cnt == 3) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
814 return "PERHAPS\n" "IT IS TIME\n" "FOR A NEW\n" "PROPHECY?"; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
815 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
816 if (cnt == 4) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
817 return "IN 1998,\n" "SCENE WILL\n" "DIE !!!!!"; |
0 | 818 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
819 if (cnt == 5) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
820 return "PHONGBALLS\n" "WILL\n" "INVADE\n" "THE WORLD"; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
821 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
822 if ((cnt == 6) || (cnt == 7)) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
823 return "HALUU OLLA\n" "APPELSIINI"; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
824 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
825 return NULL; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
826 } |
0 | 827 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
828 const char *endscroll = |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
829 "THAT'S ALL\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
830 "FOLKS !\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
831 "\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
832 "ALL CODING +\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
833 "COMPOSING\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
834 "BY VIZNUT !\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
835 "\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
836 "WHAT A\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
837 "MARVELOUS\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
838 "PALETTE !\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
839 "WHAT A\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
840 "SUPERB TUNE !\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
841 "\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
842 "BUT IT'S ALL\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
843 "BELOW 10 KB\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
844 "AND RUNS\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
845 "SMOOTHLY ON\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
846 "A 386\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
847 "\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
848 "GREETINGS TO\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
849 "ALL THE\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
850 "LINUX SCENE !\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
851 "\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
852 "LET'S MAKE\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
853 "THIS WORLD A\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
854 "BETTER PLACE\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
855 "TO LIVE IN !\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
856 "\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
857 "THIS IS JUST\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
858 "A PIECE OF\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
859 "SHITTY CODE\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
860 "BUT IT'S ALL\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
861 "YOURS !\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
862 "\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
863 "RIP OFF\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
864 "EVERYTHING !\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
865 "USE IT FOR\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
866 "SOMETHING\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
867 "CREATIVE !\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
868 "\n" |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
869 "\n\n\nOCSA 1998"; |
0 | 870 |
871 | |
872 void doendscroll(int t) | |
873 { | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
874 const char *s = endscroll; |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
875 int y = SET_VID_BUFH - (SET_VID_BUFH * t / 512), x = SET_VID_BUFW / 24; |
0 | 876 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
877 while (*s) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
878 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
879 if (*s < 32) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
880 { |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
881 x = SET_VID_BUFW / 24; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
882 y += SET_VID_BUFH / 8; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
883 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
884 else |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
885 if (y >= 0 - (SET_VID_BUFH / 8) && y < SET_VID_BUFH) |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
886 { |
18 | 887 txtDrawChar(x, y, phont[*s - 32], SET_VID_BUFW / 60, SET_VID_BUFH / 60); |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
888 x += SET_VID_BUFW / 13; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
889 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
890 s++; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
891 } |
0 | 892 } |
893 | |
894 /********************** tHA kORE bEGiNS *********************/ | |
895 | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
896 #define BLACKBG 0x0001 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
897 #define FLASHBG 0x0002 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
898 #define OCSALOGO 0x0004 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
899 #define SCROLL0 0x0008 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
900 #define BALLIE 0x0010 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
901 #define BALLJUMPS 0x0020 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
902 #define COUNTAH 0x0040 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
903 #define CHESSBG 0x0080 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
904 #define PLASMABG 0x0100 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
905 #define FLASHTXT 0x0200 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
906 #define TXTSCR 0x0400 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
907 #define ENDSCR 0x0800 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
908 #define DEMOEND 0x1000 |
0 | 909 |
14 | 910 const Uint16 dezign[] = { |
9 | 911 0 , BLACKBG | OCSALOGO | SCROLL0, |
912 256 , FLASHBG | BALLIE | BALLJUMPS | COUNTAH, | |
913 384 , BLACKBG | BALLIE | BALLJUMPS | COUNTAH | OCSALOGO, | |
914 400 , BLACKBG | BALLIE | COUNTAH | OCSALOGO, | |
915 416 , BLACKBG | BALLIE, | |
916 448 , BLACKBG | BALLIE | TXTSCR, | |
917 512 , CHESSBG | BALLIE | BALLJUMPS | TXTSCR, | |
918 576 , CHESSBG | BALLIE | BALLJUMPS | TXTSCR, | |
919 640 , CHESSBG | BALLIE | BALLJUMPS | TXTSCR, | |
920 704 , CHESSBG | BALLIE | BALLJUMPS | TXTSCR, | |
921 768 , FLASHBG | FLASHTXT, | |
922 896 , FLASHBG | FLASHTXT | TXTSCR, | |
923 962 , FLASHBG | FLASHTXT | TXTSCR | BALLIE | BALLJUMPS, | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
924 1024, BLACKBG | BALLIE | ENDSCR, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
925 1152, CHESSBG | BALLIE | BALLJUMPS | ENDSCR, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
926 1344, FLASHBG | BALLIE | BALLJUMPS | ENDSCR, |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
927 1536, DEMOEND |
0 | 928 }; |
929 | |
930 | |
931 /* don't look at the rest of the code, it just sucks :) */ | |
932 | |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
933 int main(int argc, char *argv[]) |
0 | 934 { |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
935 BOOL initSDL = FALSE; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
936 const int U = SET_VID_BUFW / 40; |
14 | 937 const Uint16 *dez = dezign; |
37
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
938 int flagz = 0, flixtim = 0, argn; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
939 char *phiword = NULL, *dizainword = NULL; |
0 | 940 |
24
7c314ac342f4
Cleanups and plug some memory leaks.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
941 memset(&engine, 0, sizeof(engine)); |
7c314ac342f4
Cleanups and plug some memory leaks.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
942 |
31 | 943 dmPrint(0, |
14 | 944 SET_PROG_NAME " by Ocsa (PWP) (c) 1998\n" |
945 "libSDL port by ccr/TNSP^PWP (c) 2013\n"); | |
946 | |
947 // Parse commandline options | |
37
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
948 for (argn = 1; argn < argc; argn++) |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
949 { |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
950 char *arg = argv[argn]; |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
951 if (arg[0] == '-') |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
952 switch (arg[1]) |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
953 { |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
954 case 'f': |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
955 engine.optVFlags |= SDL_FULLSCREEN; |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
956 break; |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
957 |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
958 case '?': |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
959 case 'h': |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
960 dmPrint(0, |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
961 "Usage: %s [options]\n" |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
962 "\n" |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
963 " -f Start in full screen\n" |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
964 " -h/-? Show this help\n" |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
965 "\n", argv[0]); |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
966 goto error_exit; |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
967 |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
968 default: |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
969 dmError("Invalid option '%s'.\n", arg); |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
970 goto error_exit; |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
971 } |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
972 else |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
973 { |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
974 dmError("Invalid argument '%s'.\n", arg); |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
975 goto error_exit; |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
976 } |
38b7583302c3
Add commandline parsing and help.
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
977 } |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
978 |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
979 |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
980 // Initialize SDL components |
31 | 981 dmPrint(0, "Engine initializing ..\n"); |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
982 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) != 0) |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
983 { |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
984 dmError("Could not initialize SDL: %s\n", SDL_GetError()); |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
985 goto error_exit; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
986 } |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
987 initSDL = TRUE; |
0 | 988 |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
989 // Initialize audio parts |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
990 engine.optAfmt.freq = SET_AUDIO_FREQ; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
991 engine.optAfmt.format = AUDIO_S16SYS; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
992 engine.optAfmt.channels = SET_AUDIO_CHN; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
993 engine.optAfmt.samples = engine.optAfmt.freq / 16; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
994 engine.optAfmt.callback = engineAudioCallback; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
995 |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
996 // Initialize SDL audio |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
997 if (SDL_OpenAudio(&engine.optAfmt, NULL) < 0) |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
998 { |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
999 dmError("Couldn't open SDL audio: %s\n", SDL_GetError()); |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1000 } |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1001 |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
1002 // Initialize SDL video |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
1003 if (!engineInitializeVideo()) |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
1004 goto error_exit; |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1005 |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1006 SDL_ShowCursor(SDL_DISABLE); |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1007 SDL_WM_SetCaption(SET_WIN_NAME, SET_WIN_NAME); |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1008 |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
1009 // Initialize effects |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1010 preball(); |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1011 srand(0); |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1012 |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1013 engine.tickLen = engine.optAfmt.freq / SET_DEMOHZ; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1014 audio_precalcs(); |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1015 setpal(); |
0 | 1016 |
33 | 1017 engine.mixBufSize = engine.optAfmt.freq * sizeof(Sint32) * 2; |
19
16efabca7e04
Some work on making the audio work .. there is sound, but it's not correct.
Matti Hamalainen <ccr@tnsp.org>
parents:
18
diff
changeset
|
1018 engine.mixBuf = malloc(engine.mixBufSize); |
16efabca7e04
Some work on making the audio work .. there is sound, but it's not correct.
Matti Hamalainen <ccr@tnsp.org>
parents:
18
diff
changeset
|
1019 |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
1020 // Start audio, enter main loop |
32 | 1021 dmPrint(0, "We are go.\n"); |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1022 SDL_LockAudio(); |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1023 SDL_PauseAudio(0); |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1024 SDL_UnlockAudio(); |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1025 engine.startTime = SDL_GetTicks(); |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1026 |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1027 while (!engine.exitFlag) |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1028 { |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
1029 // Handle SDL events |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1030 while (SDL_PollEvent(&engine.event)) |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1031 switch (engine.event.type) |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1032 { |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1033 case SDL_KEYDOWN: |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1034 switch (engine.event.key.keysym.sym) |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1035 { |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1036 case SDLK_ESCAPE: |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1037 engine.exitFlag = TRUE; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1038 break; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1039 |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1040 case SDLK_f: |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1041 engine.optVFlags ^= SDL_FULLSCREEN; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1042 if (!engineInitializeVideo()) |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1043 goto error_exit; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1044 break; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1045 |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1046 case SDLK_RETURN: |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1047 if (engine.event.key.keysym.mod & KMOD_ALT) |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1048 { |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1049 engine.optVFlags ^= SDL_FULLSCREEN; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1050 if (!engineInitializeVideo()) |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1051 goto error_exit; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1052 } |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1053 break; |
0 | 1054 |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1055 default: |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1056 break; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1057 } |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1058 |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1059 break; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1060 |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1061 case SDL_VIDEOEXPOSE: |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1062 break; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1063 |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1064 case SDL_QUIT: |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1065 engine.exitFlag = TRUE; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1066 break; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1067 } |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1068 |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1069 // Draw frame |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1070 engine.frameTime = SDL_GetTicks(); |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
1071 int qt = engineGetTick(&engine); |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1072 |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1073 if (SDL_MUSTLOCK(engine.screen) != 0 && SDL_LockSurface(engine.screen) != 0) |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1074 { |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1075 dmError("Can't lock surface.\n"); |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1076 goto error_exit; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1077 } |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1078 |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1079 // Main rendering code |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
1080 while ((qt / SET_ROWTIX >= *dez) && (flagz & DEMOEND) == 0) |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1081 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1082 dez++; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1083 flagz = *dez++; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1084 if (flagz & FLASHTXT) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1085 flixtim = *(dez - 2); |
14 | 1086 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1087 if (flagz & TXTSCR) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1088 dizainword = dotxtscr(); |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1089 } |
0 | 1090 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1091 if (flagz & FLASHTXT) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1092 { |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
1093 while ((qt / SET_ROWTIX) >= flixtim) |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1094 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1095 phiword = lyrix(); |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1096 flixtim += 4; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1097 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1098 } |
0 | 1099 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1100 if (flagz & DEMOEND) |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1101 engine.exitFlag = TRUE; |
0 | 1102 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1103 if (flagz & BLACKBG) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1104 { |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1105 SDL_FillRect(engine.screen, NULL, 0); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1106 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1107 else |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1108 if (flagz & FLASHBG) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1109 { |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
1110 unsigned char col = 130 + (qt % 48) * 2; |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1111 SDL_FillRect(engine.screen, NULL, col); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1112 } |
0 | 1113 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1114 if (flagz & CHESSBG) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1115 { |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
1116 int zoom = (10 + abs(((qt >> 1) % 96) - 48)) * 4096 / SET_VID_BUFW; |
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
1117 rotochess(engine.screen, sin(qt * 0.03) * zoom, cos(qt * 0.03) * zoom, 0, 0); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1118 } |
0 | 1119 |
14 | 1120 //if(flagz&PLASMABG) drawplasma(ruutu, qt); |
0 | 1121 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1122 if (flagz & OCSALOGO) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1123 { |
18 | 1124 txtDrawChar(U * 6, U * 4, phont['O' - 32], U + U * sin(qt * 0.10 + 3), |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1125 U); |
18 | 1126 txtDrawChar(U * 14, U * 4, phont['C' - 32], U, |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
1127 U + U * sin(qt * 0.11 + 3)); |
18 | 1128 txtDrawChar(U * 22, U * 4, phont['S' - 32], U, |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
1129 U + U * sin(qt * 0.12 + 3)); |
18 | 1130 txtDrawChar(U * 30, U * 4, phont['A' - 32], |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
1131 U + U * sin(qt * 0.13 + 3), U); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1132 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1133 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1134 if (flagz & SCROLL0) |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
1135 plainscroll(qt); |
0 | 1136 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1137 if (flagz & BALLIE) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1138 { |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1139 int zoom; |
14 | 1140 vec3d joo; |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1141 if (flagz & BALLJUMPS) |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
1142 zoom = abs((qt % 96) - 48); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1143 else |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1144 zoom = 47; |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1145 |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1146 zoom = dmClamp(zoom, 0, 47); |
0 | 1147 |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
1148 unitvec(&joo, 0.038 * qt, 0.023 * qt, 0.011 * qt, |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1149 32000 / balltab[zoom].R); |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1150 joo.z <<= 1; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1151 |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1152 drawball(engine.screen, &joo, zoom); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1153 } |
0 | 1154 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1155 if (flagz & FLASHTXT) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1156 flashtxt(phiword); |
9 | 1157 |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
1158 if ((flagz & TXTSCR) && ((qt / SET_ROWTIX) & 2)) |
9 | 1159 drawtxtscr(dizainword); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1160 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1161 if (flagz & ENDSCR) |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
1162 doendscroll(qt - 1024 * SET_ROWTIX); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1163 |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1164 if (flagz & COUNTAH) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1165 { |
13
3a358d053ffc
Runs now, audio does not work yet and the pace seems slightly too fast (not
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
1166 int n = ((qt * 50 / 48) - 256 * 6); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1167 int dis = (rand() % U) >> 1; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1168 if (n > 666) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1169 n = 666; |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1170 |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1171 if (n > 600) |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1172 { |
18 | 1173 txtDrawChar(U * 12 + dis, (SET_VID_BUFH >> 1) + dis + U * 6, |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1174 phont['X' - 32], U, U); |
18 | 1175 txtDrawChar(U * 22 + dis, (SET_VID_BUFH >> 1) + dis + U * 6, |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1176 phont['3' - 32], U, U); |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1177 } |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1178 |
18 | 1179 txtDrawChar(U * 28 + dis, SET_VID_BUFH >> 1, phont[16 + (n % 10)], U, U); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1180 n /= 10; |
18 | 1181 txtDrawChar(U * 18 + dis, SET_VID_BUFH >> 1, phont[16 + (n % 10)], U, U); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1182 n /= 10; |
18 | 1183 txtDrawChar(U * 8 + dis, SET_VID_BUFH >> 1, phont[16 + (n % 10)], U, U); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1184 n /= 10; |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1185 } |
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1186 |
14 | 1187 // Flip screen, increase frame count, wait |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1188 if (SDL_MUSTLOCK(engine.screen) != 0) |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1189 SDL_UnlockSurface(engine.screen); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1190 |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1191 engine.frameCount++; |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1192 SDL_Flip(engine.screen); |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1193 SDL_Delay(20); |
3
4dd2b0c81ad2
Cleanups, removing cruft, re-indent.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1194 } |
9 | 1195 |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1196 error_exit: |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1197 // Shutdown |
31 | 1198 dmPrint(0, "Shutting down.\n"); |
1199 dmPrint(1, "%d frames in %d ms, %1.2f fps\n", | |
28 | 1200 engine.frameCount, |
1201 engine.frameTime - engine.startTime, | |
1202 (float) (engine.frameCount * 1000.0f) / (float) (engine.frameTime - engine.startTime) | |
1203 ); | |
1204 | |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1205 SDL_ShowCursor(SDL_ENABLE); |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1206 if (engine.screen) |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1207 SDL_FreeSurface(engine.screen); |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1208 |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1209 SDL_LockAudio(); |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1210 SDL_PauseAudio(1); |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1211 SDL_UnlockAudio(); |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1212 |
24
7c314ac342f4
Cleanups and plug some memory leaks.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
1213 audio_close(); |
7c314ac342f4
Cleanups and plug some memory leaks.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
1214 |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1215 if (initSDL) |
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1216 SDL_Quit(); |
24
7c314ac342f4
Cleanups and plug some memory leaks.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
1217 |
7c314ac342f4
Cleanups and plug some memory leaks.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
1218 if (engine.mixBuf) |
7c314ac342f4
Cleanups and plug some memory leaks.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
1219 free(engine.mixBuf); |
7c314ac342f4
Cleanups and plug some memory leaks.
Matti Hamalainen <ccr@tnsp.org>
parents:
22
diff
changeset
|
1220 |
11
fcae85b39931
Slowly getting closer. Does not compile yet, and it's messy.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
1221 return 0; |
0 | 1222 } |