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