annotate 3x666.c @ 25:f896fe6a98da

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