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