annotate oxl.h @ 0:0e4f2da58161

Initial import.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 15 Mar 2013 05:00:01 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /********************
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 OCSALiB, the revolutionary -- version 0.0.1alpha
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 (c) viznut/ocsa '98 vheikkil@hytti.uku.fi
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 use it the way you like, i don't care :)
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 ***************/
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 typedef struct {int r,g,b; } rgb;
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 extern void oxl_setpalette(rgb *pal);
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 extern void oxl_doframe(char *vscr);
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 extern int oxl_timer(void);
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 extern void oxl_doaudio(int*(player()));
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 extern void oxl_init_video(void);
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 extern void oxl_init_audio(int rowtix);
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 extern void oxl_init_timer(void);
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 extern void oxl_end(void);
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 extern int AUFREQ, TIKLGT;
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 /*x.
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 Just in case you _may_ want to use this in your own proggie (urgh)
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 let's put some documentation here :)
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 ** FUNCTIONS **
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 void oxl_setpalette(rgb *pal)
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 pal is a table containing three ints (r,g,b) for every color.
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 the values vary 0..255.
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 void oxl_doframe(char *vscr)
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 blits the contents of the offscreen buffer to the screen.
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 the size of the buffer is BUFW * BUFH * 8 bits.
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 int oxl_timer(void)
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 the current timer value. the number of timer ticks per second is
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 defined by the DEMOHZ constant.
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 void oxl_doaudio(int*(player()));
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 fills the audio output buffers up to 50%.
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 player is a user-specified function returning a pointer to some raw
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 audio data (e.g. the mixer output for the next row of a pattern)
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 the first int of the data is the length of the rest (in ints).
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 the buffer is int* but the data is 16bit unsigned. values going out
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 of the range 0..65535 will be clipped.
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 AUFREQ specifies the output frequency.
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 void oxl_init_video(void);
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 adjusts the display for the demo.
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 oxl_doframe and oxl_setpalette need this.
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 void oxl_init_audio(int rowtix);
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 inits the audio stuff, possibly changing the value of AUFREQ.
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 rowtix is the maximum length (in ticks) of an audio chunk produced
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 by int*(player()). (the 'physical length' in samples is therefore
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 rowtix*AUFREQ/DEMOHZ)
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 oxl_doaudio needs this. does nothing if nosound.
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 void oxl_init_timer(void);
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76 starts the timer. oxl_timer needs this.
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 with sounds on, the timing is actually based on the byte counter of
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 the sound device but put this in your code anyway.
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 void oxl_end(void);
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 closes the multimedia subsystems. these things should be done
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 automatically when the program terminates, so you really don't need
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 this function.
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 ** CONSTANTS REQUIRED **
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 AUDIO (0/1)
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 VIDEO (vga/X11)
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 BUFW, BUFH (buffer size)
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 DEMOHZ (timer ticks per second)
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 ** THINGS TO DO **
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96 - A guard process that tries to keep up the audio even if the main
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 loop is frozen. (e.g. if the svgalib screen is not active or if
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 you move the window in X)
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 - Make sure the window start address is properly aligned for the
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 maximum performance.
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 - Do not calculate the contents of the buffer if the screen/window
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104 is not visible.
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106 - A variable palette size: if the palette fits in the end of the
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 default colormap, we have to be able to use it instead of rudely
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 using a private map.
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 - Support for visual depths other than 8bpp.
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 - Support for 16-bit multimedia sound systems. Stereo?
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114 - mSDoS support (for dummies)
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 - AAlib support
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 - An automatical reselection of X11 gfx mode to best fit the size of
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119 the buffer.
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 - X fullscreen mode
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 - X rootwindow mode
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125 - Etc etc... but still trying to keep it in a relevant size ;)
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126
0e4f2da58161 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127 .x*/