allegro4r 0.0.1-x86-mswin32-60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/Manifest.txt +59 -0
- data/README.txt +94 -0
- data/examples/exdbuf.rb +58 -0
- data/examples/exfixed.rb +46 -0
- data/examples/exflame.rb +200 -0
- data/examples/exflip.rb +87 -0
- data/examples/exfont.rb +70 -0
- data/examples/exhello.rb +46 -0
- data/examples/exjoy.rb +206 -0
- data/examples/exkeys.rb +216 -0
- data/examples/exmem.rb +50 -0
- data/examples/exmidi.rb +97 -0
- data/examples/exmouse.rb +149 -0
- data/examples/expal.rb +70 -0
- data/examples/expat.rb +62 -0
- data/examples/exsample.rb +89 -0
- data/examples/extimer.rb +84 -0
- data/examples/unifont.dat +0 -0
- data/ext/a4r_API_BITMAP.c +27 -0
- data/ext/a4r_API_DIGI_DRIVER.c +14 -0
- data/ext/a4r_API_GFX_DRIVER.c +14 -0
- data/ext/a4r_API_JOYSTICK_AXIS_INFO.c +53 -0
- data/ext/a4r_API_JOYSTICK_BUTTON_INFO.c +27 -0
- data/ext/a4r_API_JOYSTICK_DRIVER.c +14 -0
- data/ext/a4r_API_JOYSTICK_INFO.c +84 -0
- data/ext/a4r_API_JOYSTICK_STICK_INFO.c +62 -0
- data/ext/a4r_API_KEYBOARD_DRIVER.c +14 -0
- data/ext/a4r_API_MIDI_DRIVER.c +14 -0
- data/ext/a4r_API_MOUSE_DRIVER.c +14 -0
- data/ext/a4r_API_PALETTE.c +63 -0
- data/ext/a4r_API_RGB.c +118 -0
- data/ext/a4r_API_TIMER_DRIVER.c +14 -0
- data/ext/a4r_API_bitmap_objects.c +310 -0
- data/ext/a4r_API_blitting_and_sprites.c +86 -0
- data/ext/a4r_API_digital_sample_routines.c +83 -0
- data/ext/a4r_API_direct_access_to_video_memory.c +102 -0
- data/ext/a4r_API_drawing_primitives.c +114 -0
- data/ext/a4r_API_file_and_compression_routines.c +27 -0
- data/ext/a4r_API_fixed_point_math_routines.c +98 -0
- data/ext/a4r_API_fonts.c +147 -0
- data/ext/a4r_API_graphics_modes.c +155 -0
- data/ext/a4r_API_joystick_routines.c +213 -0
- data/ext/a4r_API_keyboard_routines.c +420 -0
- data/ext/a4r_API_misc.c +133 -0
- data/ext/a4r_API_mouse_routines.c +220 -0
- data/ext/a4r_API_music_routines_midi.c +147 -0
- data/ext/a4r_API_palette_routines.c +112 -0
- data/ext/a4r_API_sound_init_routines.c +29 -0
- data/ext/a4r_API_text_output.c +178 -0
- data/ext/a4r_API_timer_routines.c +250 -0
- data/ext/a4r_API_transparency_and_patterned_drawing.c +87 -0
- data/ext/a4r_API_truecolor_pixel_formats.c +44 -0
- data/ext/a4r_API_unicode_routines.c +53 -0
- data/ext/a4r_API_using_allegro.c +98 -0
- data/ext/allegro4r.c +866 -0
- data/ext/allegro4r.h +311 -0
- data/ext/allegro4r.so +0 -0
- data/ext/extconf.rb +11 -0
- metadata +113 -0
@@ -0,0 +1,220 @@
|
|
1
|
+
#include "allegro4r.h"
|
2
|
+
|
3
|
+
/*
|
4
|
+
* call-seq:
|
5
|
+
* install_mouse -> int
|
6
|
+
*
|
7
|
+
* Installs the Allegro mouse handler. You must do this before using any other
|
8
|
+
* mouse functions.
|
9
|
+
*
|
10
|
+
* Return value: Returns -1 on failure, zero if the mouse handler is already
|
11
|
+
* installed (in which case this function does nothing) and the number of
|
12
|
+
* buttons on the mouse if the mouse handler has successfully been installed
|
13
|
+
* (ie. this is the first time a handler is installed or you have removed the
|
14
|
+
* previous one).
|
15
|
+
*
|
16
|
+
* Note that the number of mouse buttons returned by this function is more an
|
17
|
+
* indication than a physical reality. With most devices there is no way of
|
18
|
+
* telling how many buttons there are, and any user can override the number of
|
19
|
+
* mouse buttons returned by this function with a custom configuration file and
|
20
|
+
* the variable num_buttons. Even if this value is overridden by the user, the
|
21
|
+
* global mouse variables will still report whatever the hardware is sending.
|
22
|
+
*/
|
23
|
+
VALUE a4r_API_install_mouse(VALUE self)
|
24
|
+
{
|
25
|
+
return INT2FIX(install_mouse());
|
26
|
+
}
|
27
|
+
|
28
|
+
/*
|
29
|
+
* call-seq:
|
30
|
+
* poll_mouse -> int
|
31
|
+
*
|
32
|
+
* Wherever possible, Allegro will read the mouse input asynchronously (ie. from
|
33
|
+
* inside an interrupt handler), but on some platforms that may not be possible,
|
34
|
+
* in which case you must call this routine at regular intervals to update the
|
35
|
+
* mouse state variables. To help you test your mouse polling code even if you
|
36
|
+
* are programming on a platform that doesn't require it, after the first time
|
37
|
+
* that you call this function Allegro will switch into polling mode, so from
|
38
|
+
* that point onwards you will have to call this routine in order to get any
|
39
|
+
* mouse input at all, regardless of whether the current driver actually needs
|
40
|
+
* to be polled or not.
|
41
|
+
*
|
42
|
+
* Return value: Returns zero on success, or a negative number on failure (ie.
|
43
|
+
* no mouse driver installed).
|
44
|
+
*/
|
45
|
+
VALUE a4r_API_poll_mouse(VALUE self)
|
46
|
+
{
|
47
|
+
return INT2FIX(poll_mouse());
|
48
|
+
}
|
49
|
+
|
50
|
+
/*
|
51
|
+
* call-seq:
|
52
|
+
* mouse_x -> int
|
53
|
+
*
|
54
|
+
* Global variables containing the current mouse position and button state.
|
55
|
+
* Wherever possible these values will be updated asynchronously, but if
|
56
|
+
* mouse_needs_poll returns true, you must manually call poll_mouse to update
|
57
|
+
* them with the current input state. The 'mouse_x' and 'mouse_y' positions are
|
58
|
+
* integers ranging from zero to the bottom right corner of the screen. The
|
59
|
+
* 'mouse_z' and 'mouse_w' variables hold the current vertical and horizontal
|
60
|
+
* wheel position, when using an input driver that supports wheel mice. The
|
61
|
+
* 'mouse_b' variable is a bitfield indicating the state of each button: bit 0
|
62
|
+
* is the left button, bit 1 the right, and bit 2 the middle button. Additional
|
63
|
+
* non standard mouse buttons might be available as higher bits in this
|
64
|
+
* variable. Usage example:
|
65
|
+
* printf("Left button is pressed\n") if (mouse_b & 1) > 0
|
66
|
+
*
|
67
|
+
* printf("Right button is not pressed\n") if (mouse_b & 2) != 0
|
68
|
+
*
|
69
|
+
* The 'mouse_pos' variable has the current X coordinate in the upper 16 bits
|
70
|
+
* and the Y in the lower 16 bits. This may be useful in tight polling loops
|
71
|
+
* where a mouse interrupt could occur between your reading of the two separate
|
72
|
+
* variables, since you can copy this value into a local variable with a single
|
73
|
+
* instruction and then split it up at your leisure. Example:
|
74
|
+
* pos = mouse_pos
|
75
|
+
* x = pos >> 16
|
76
|
+
* y = pos & 0x0000ffff
|
77
|
+
*/
|
78
|
+
VALUE a4r_API_mouse_x(VALUE self)
|
79
|
+
{
|
80
|
+
return INT2FIX(mouse_x);
|
81
|
+
}
|
82
|
+
|
83
|
+
/*
|
84
|
+
* call-seq:
|
85
|
+
* mouse_y -> int
|
86
|
+
*
|
87
|
+
* See mouse_x.
|
88
|
+
*/
|
89
|
+
VALUE a4r_API_mouse_y(VALUE self)
|
90
|
+
{
|
91
|
+
return INT2FIX(mouse_y);
|
92
|
+
}
|
93
|
+
|
94
|
+
/*
|
95
|
+
* call-seq:
|
96
|
+
* mouse_z -> int
|
97
|
+
*
|
98
|
+
* See mouse_x.
|
99
|
+
*/
|
100
|
+
VALUE a4r_API_mouse_z(VALUE self)
|
101
|
+
{
|
102
|
+
return INT2FIX(mouse_z);
|
103
|
+
}
|
104
|
+
|
105
|
+
/*
|
106
|
+
* call-seq:
|
107
|
+
* mouse_w -> int
|
108
|
+
*
|
109
|
+
* See mouse_x.
|
110
|
+
*/
|
111
|
+
VALUE a4r_API_mouse_w(VALUE self)
|
112
|
+
{
|
113
|
+
return INT2FIX(mouse_w);
|
114
|
+
}
|
115
|
+
|
116
|
+
/*
|
117
|
+
* call-seq:
|
118
|
+
* mouse_b -> int
|
119
|
+
*
|
120
|
+
* See mouse_x.
|
121
|
+
*/
|
122
|
+
VALUE a4r_API_mouse_b(VALUE self)
|
123
|
+
{
|
124
|
+
return INT2FIX(mouse_b);
|
125
|
+
}
|
126
|
+
|
127
|
+
/*
|
128
|
+
* call-seq:
|
129
|
+
* show_mouse(bmp) -> nil
|
130
|
+
*
|
131
|
+
* Tells Allegro to display a mouse pointer on the screen. This will only work
|
132
|
+
* if the timer module has been installed. The mouse pointer will be drawn onto
|
133
|
+
* the specified bitmap, which should normally be 'screen' (see later for
|
134
|
+
* information about bitmaps). To hide the mouse pointer, call show_mouse(nil).
|
135
|
+
*
|
136
|
+
* Warning: if you draw anything onto the screen while the pointer is visible, a
|
137
|
+
* mouse movement interrupt could occur in the middle of your drawing operation.
|
138
|
+
* If this happens the mouse buffering and graphics drawing code will get
|
139
|
+
* confused and will leave 'mouse droppings' all over the screen. To prevent
|
140
|
+
* this, you must make sure you turn off the mouse pointer whenever you draw
|
141
|
+
* onto the screen. This is not needed if you are using a hardware cursor.
|
142
|
+
*
|
143
|
+
* Note: you must not be showing a mouse pointer on a bitmap at the time that
|
144
|
+
* the bitmap is destroyed with destroy_bitmap, e.g. call show_mouse(nil) before
|
145
|
+
* destroying the bitmap. This does not apply to 'screen' since you never
|
146
|
+
* destroy 'screen' with destroy_bitmap.
|
147
|
+
*/
|
148
|
+
VALUE a4r_API_show_mouse(VALUE self, VALUE bmp)
|
149
|
+
{
|
150
|
+
BITMAP *b;
|
151
|
+
if (bmp == Qnil)
|
152
|
+
b = NULL;
|
153
|
+
else
|
154
|
+
Data_Get_Struct(bmp, BITMAP, b);
|
155
|
+
show_mouse(b);
|
156
|
+
return Qnil;
|
157
|
+
}
|
158
|
+
|
159
|
+
/*
|
160
|
+
* call_seq:
|
161
|
+
* get_mouse_mickeys -> [int_x, int_y]
|
162
|
+
*
|
163
|
+
* Measures how far the mouse has moved since the last call to this function.
|
164
|
+
* The values of mickeyx and mickeyy will become negative if the mouse is moved
|
165
|
+
* left or up, respectively. The mouse will continue to generate movement
|
166
|
+
* mickeys even when it reaches the edge of the screen, so this form of input
|
167
|
+
* can be useful for games that require an infinite range of mouse movement.
|
168
|
+
*
|
169
|
+
* Note that the infinite movement may not work in windowed mode, since under
|
170
|
+
* some platforms the mouse would leave the window, and may not work at all if
|
171
|
+
* the hardware cursor is in use.
|
172
|
+
*
|
173
|
+
* *** The Ruby method signature differs from the Allegro method signature. The
|
174
|
+
* Allegro signature take int_x and int_y by reference, but the Ruby signature
|
175
|
+
* returns an array containing the values of int_x and int_y.
|
176
|
+
*/
|
177
|
+
VALUE a4r_API_get_mouse_mickeys(VALUE self)
|
178
|
+
{
|
179
|
+
int x, y;
|
180
|
+
get_mouse_mickeys(&x, &y);
|
181
|
+
return rb_ary_new3(2, INT2FIX(x), INT2FIX(y));
|
182
|
+
}
|
183
|
+
|
184
|
+
/*
|
185
|
+
* call-seq:
|
186
|
+
* set_mouse_sprite(bmp) -> nil
|
187
|
+
*
|
188
|
+
* You don't like Allegro's mouse pointer? No problem. Use this function to
|
189
|
+
* supply an alternative of your own. If you change the pointer and then want to
|
190
|
+
* get Allegro's lovely arrow back again, call set_mouse_sprite(nil).
|
191
|
+
*
|
192
|
+
* As a bonus, set_mouse_sprite(nil) uses the current palette in choosing colors
|
193
|
+
* for the arrow. So if your arrow mouse sprite looks ugly after changing the
|
194
|
+
* palette, call set_mouse_sprite(nil).
|
195
|
+
*/
|
196
|
+
VALUE a4r_API_set_mouse_sprite(VALUE self, VALUE bmp)
|
197
|
+
{
|
198
|
+
BITMAP *b;
|
199
|
+
if (bmp == Qnil)
|
200
|
+
b = NULL;
|
201
|
+
else
|
202
|
+
Data_Get_Struct(bmp, BITMAP, b);
|
203
|
+
set_mouse_sprite(b);
|
204
|
+
return Qnil;
|
205
|
+
}
|
206
|
+
|
207
|
+
/*
|
208
|
+
* call-seq:
|
209
|
+
* set_mouse_sprite_focus(x, y) -> nil
|
210
|
+
*
|
211
|
+
* The mouse focus is the bit of the pointer that represents the actual mouse
|
212
|
+
* position, ie. the (mouse_x, mouse_y) position. By default this is the top
|
213
|
+
* left corner of the arrow, but if you are using a different mouse pointer you
|
214
|
+
* might need to alter it.
|
215
|
+
*/
|
216
|
+
VALUE a4r_API_set_mouse_sprite_focus(VALUE self, VALUE x, VALUE y)
|
217
|
+
{
|
218
|
+
set_mouse_sprite_focus(FIX2INT(x), FIX2INT(y));
|
219
|
+
return Qnil;
|
220
|
+
}
|
@@ -0,0 +1,147 @@
|
|
1
|
+
#include "allegro4r.h"
|
2
|
+
|
3
|
+
/*
|
4
|
+
* call-seq:
|
5
|
+
* load_midi(filename) -> a_midi
|
6
|
+
*
|
7
|
+
* Loads a MIDI file (handles both format 0 and format 1). Example:
|
8
|
+
* music = load_midi("backmus.mid")
|
9
|
+
* abort_on_error("Couldn't load background music!") if music.nil?
|
10
|
+
*
|
11
|
+
* Return value: Returns a reference to a MIDI structure, or nil on error.
|
12
|
+
* Remember to free this MIDI file later to avoid memory leaks.
|
13
|
+
*/
|
14
|
+
VALUE a4r_API_load_midi(VALUE self, VALUE filename)
|
15
|
+
{
|
16
|
+
MIDI *m = load_midi(StringValuePtr(filename));
|
17
|
+
if (m == NULL)
|
18
|
+
return Qnil;
|
19
|
+
|
20
|
+
VALUE obj = Data_Wrap_Struct(cAPI_MIDI, 0, 0, m);
|
21
|
+
return obj;
|
22
|
+
}
|
23
|
+
|
24
|
+
/*
|
25
|
+
* call-seq:
|
26
|
+
* destroy_midi(midi) -> nil
|
27
|
+
*
|
28
|
+
* Destroys a MIDI structure when you are done with it. It is safe to call this
|
29
|
+
* even when the MIDI file might be playing, because it checks and will kill it
|
30
|
+
* off if it is active. Use this to avoid memory leaks in your program.
|
31
|
+
*/
|
32
|
+
VALUE a4r_API_destroy_midi(VALUE self, VALUE midi)
|
33
|
+
{
|
34
|
+
MIDI *m;
|
35
|
+
Data_Get_Struct(midi, MIDI, m);
|
36
|
+
destroy_midi(m);
|
37
|
+
return Qnil;
|
38
|
+
}
|
39
|
+
|
40
|
+
/*
|
41
|
+
* call-seq:
|
42
|
+
* play_midi(midi, loop) -> int
|
43
|
+
*
|
44
|
+
* Starts playing the specified MIDI file, first stopping whatever music was
|
45
|
+
* previously playing. If the loop flag is set to true, the data will be
|
46
|
+
* repeated until replaced with something else, otherwise it will stop at the
|
47
|
+
* end of the file. Passing a nil will stop whatever music is currently playing.
|
48
|
+
*
|
49
|
+
* Return value: Returns non-zero if an error occurs (this may happen if a
|
50
|
+
* patch-caching wavetable driver is unable to load the required samples, or at
|
51
|
+
* least it might in the future when somebody writes some patch-caching
|
52
|
+
* wavetable drivers :-)
|
53
|
+
*/
|
54
|
+
VALUE a4r_API_play_midi(VALUE self, VALUE midi, VALUE loop)
|
55
|
+
{
|
56
|
+
MIDI *m;
|
57
|
+
if (midi == Qnil)
|
58
|
+
m = NULL;
|
59
|
+
else
|
60
|
+
Data_Get_Struct(midi, MIDI, m);
|
61
|
+
|
62
|
+
return INT2FIX(play_midi(m, RTEST(loop)));
|
63
|
+
}
|
64
|
+
|
65
|
+
/*
|
66
|
+
* call-seq:
|
67
|
+
* midi_pause -> nil
|
68
|
+
*
|
69
|
+
* Pauses the MIDI player.
|
70
|
+
*/
|
71
|
+
VALUE a4r_API_midi_pause(VALUE self)
|
72
|
+
{
|
73
|
+
midi_pause();
|
74
|
+
return Qnil;
|
75
|
+
}
|
76
|
+
|
77
|
+
/*
|
78
|
+
* call-seq:
|
79
|
+
* midi_resume -> nil
|
80
|
+
*
|
81
|
+
* Resumes playback of a paused MIDI file.
|
82
|
+
*/
|
83
|
+
VALUE a4r_API_midi_resume(VALUE self)
|
84
|
+
{
|
85
|
+
midi_resume();
|
86
|
+
return Qnil;
|
87
|
+
}
|
88
|
+
|
89
|
+
/*
|
90
|
+
* call-seq:
|
91
|
+
* get_midi_length(midi) -> int
|
92
|
+
*
|
93
|
+
* This function will simulate playing the given MIDI, from start to end, to
|
94
|
+
* determine how long it takes to play. After calling this function, midi_pos
|
95
|
+
* will contain the negative number of beats, and midi_time the length of the
|
96
|
+
* midi, in seconds.
|
97
|
+
*
|
98
|
+
* Note that any currently playing midi is stopped when you call this function.
|
99
|
+
* Usually you would call it before play_midi, to get the length of the midi to
|
100
|
+
* be played, like in this example:
|
101
|
+
* length = get_midi_length(my_midi)
|
102
|
+
* play_midi(my_midi)
|
103
|
+
* loop do
|
104
|
+
* pos = midi_time
|
105
|
+
* textprintf_ex(screen, font, 0, 0, c, -1, "%d:%02d / %d:%02d\n" %
|
106
|
+
* [pos / 60, pos % 60, length / 60, length % 60])
|
107
|
+
* rest(100)
|
108
|
+
* break unless pos <= length
|
109
|
+
* end
|
110
|
+
*
|
111
|
+
* Return value: Returns the value of midi_time, the length of the midi.
|
112
|
+
*/
|
113
|
+
VALUE a4r_API_get_midi_length(VALUE self, VALUE midi)
|
114
|
+
{
|
115
|
+
MIDI *m;
|
116
|
+
Data_Get_Struct(midi, MIDI, m);
|
117
|
+
return INT2FIX(get_midi_length(m));
|
118
|
+
}
|
119
|
+
|
120
|
+
/*
|
121
|
+
* call-seq:
|
122
|
+
* midi_pos -> int
|
123
|
+
*
|
124
|
+
* Stores the current position (beat number) in the MIDI file, or contains a
|
125
|
+
* negative number if no music is currently playing. Useful for synchronising
|
126
|
+
* animations with the music, and for checking whether a MIDI file has finished
|
127
|
+
* playing.
|
128
|
+
*/
|
129
|
+
VALUE a4r_API_midi_pos(VALUE self)
|
130
|
+
{
|
131
|
+
// TODO: Convert to data struct or cached or hooked variable?
|
132
|
+
return LONG2FIX(midi_pos);
|
133
|
+
}
|
134
|
+
|
135
|
+
/*
|
136
|
+
* call-seq:
|
137
|
+
* midi_time -> int
|
138
|
+
*
|
139
|
+
* Contains the position in seconds in the currently playing midi. This is
|
140
|
+
* useful if you want to display the current song position in seconds, not as
|
141
|
+
* beat number.
|
142
|
+
*/
|
143
|
+
VALUE a4r_API_midi_time(VALUE self)
|
144
|
+
{
|
145
|
+
// TODO: Convert to data struct or cached or hooked variable?
|
146
|
+
return LONG2FIX(midi_time);
|
147
|
+
}
|
@@ -0,0 +1,112 @@
|
|
1
|
+
#include "allegro4r.h"
|
2
|
+
|
3
|
+
/*
|
4
|
+
* call-seq:
|
5
|
+
* set_palette(p) -> nil
|
6
|
+
*
|
7
|
+
* Sets the entire palette of 256 colors. You should provide an array of 256 RGB
|
8
|
+
* structures. Unlike set_color, there is no need to call vsync before this
|
9
|
+
* function. Example:
|
10
|
+
* palette = PALETTE.new
|
11
|
+
* ...
|
12
|
+
* bmp = load_bitmap(filename, palette)
|
13
|
+
* abort_on_error("Couldn't load bitmap!") if bmp.nil?
|
14
|
+
* set_palette(palette)
|
15
|
+
*/
|
16
|
+
VALUE a4r_API_set_palette(VALUE self, VALUE p)
|
17
|
+
{
|
18
|
+
// TODO: Check data type of palette? Also, allow array of 256 RGBs
|
19
|
+
PALETTE *pal;
|
20
|
+
Data_Get_Struct(p, PALETTE, pal);
|
21
|
+
set_palette(*pal);
|
22
|
+
return Qnil;
|
23
|
+
}
|
24
|
+
|
25
|
+
/*
|
26
|
+
* call_seq:
|
27
|
+
* get_palette(p) -> nil
|
28
|
+
*
|
29
|
+
* Retrieves the entire palette of 256 colors. You should provide an array of
|
30
|
+
* 256 RGB structures to store it in. Example:
|
31
|
+
* pal = PALETTE.new
|
32
|
+
* ...
|
33
|
+
* get_palette(pal)
|
34
|
+
*/
|
35
|
+
VALUE a4r_API_get_palette(VALUE self, VALUE p)
|
36
|
+
{
|
37
|
+
// TODO: Check data type of p?
|
38
|
+
PALETTE *pal;
|
39
|
+
Data_Get_Struct(p, PALETTE, pal);
|
40
|
+
get_palette(*pal);
|
41
|
+
return Qnil;
|
42
|
+
}
|
43
|
+
|
44
|
+
/*
|
45
|
+
* call-seq:
|
46
|
+
* default_palette -> pal
|
47
|
+
*
|
48
|
+
* The default IBM BIOS palette. This will be automatically selected whenever
|
49
|
+
* you set a new graphics mode. The palette contains 16 basic colors plus many
|
50
|
+
* gradients between them. If you want to see the values, you can write a small
|
51
|
+
* Allegro program which saves a screenshot with this palette, or open the
|
52
|
+
* grabber tool provided with Allegro and create a new palette object, which
|
53
|
+
* will use this palette by default.
|
54
|
+
*/
|
55
|
+
VALUE a4r_API_default_palette(VALUE self)
|
56
|
+
{
|
57
|
+
// TODO: Convert to data struct or cached or hooked variable?
|
58
|
+
PALETTE *pal = &default_palette;
|
59
|
+
VALUE obj = Data_Wrap_Struct(cAPI_PALETTE, 0, 0, pal);
|
60
|
+
return obj;
|
61
|
+
}
|
62
|
+
|
63
|
+
/*
|
64
|
+
* call-seq:
|
65
|
+
* black_palette -> pal
|
66
|
+
*
|
67
|
+
* A palette containing solid black colors, used by the fade routines.
|
68
|
+
*/
|
69
|
+
VALUE a4r_API_black_palette(VALUE self)
|
70
|
+
{
|
71
|
+
// TODO: Convert to data struct or cached or hooked variable?
|
72
|
+
PALETTE *pal = &black_palette;
|
73
|
+
VALUE obj = Data_Wrap_Struct(cAPI_PALETTE, 0, 0, pal);
|
74
|
+
return obj;
|
75
|
+
}
|
76
|
+
|
77
|
+
/*
|
78
|
+
* call-seq:
|
79
|
+
* desktop_palette -> pal
|
80
|
+
*
|
81
|
+
* The palette used by the Atari ST low resolution desktop. I'm not quite sure
|
82
|
+
* why this is still here, except that the grabber and test programs use it. It
|
83
|
+
* is probably the only Atari legacy code left in Allegro, and it would be a
|
84
|
+
* shame to remove it :-)
|
85
|
+
*
|
86
|
+
* The contents of this palette are 16 colors repeated 16 times. Color entry
|
87
|
+
* zero is equal to color entry 16, which is equal to color entry 24, etc.
|
88
|
+
* Index Color RGB values
|
89
|
+
* 0 White 63 63 63
|
90
|
+
* 1 Red 63 0 0
|
91
|
+
* 2 Green 0 63 0
|
92
|
+
* 3 Yellow 63 63 0
|
93
|
+
* 4 Blue 0 0 63
|
94
|
+
* 5 Pink 63 0 63
|
95
|
+
* 6 Cyan 0 63 63
|
96
|
+
* 7 Grey 16 16 16
|
97
|
+
* 8 Light grey 31 31 31
|
98
|
+
* 9 Light red 63 31 31
|
99
|
+
* 10 Light green 31 63 31
|
100
|
+
* 11 Light yellow 63 63 31
|
101
|
+
* 12 Light blue 31 31 63
|
102
|
+
* 13 Light pink 63 31 63
|
103
|
+
* 14 Light cyan 31 63 63
|
104
|
+
* 15 Black 0 0 0
|
105
|
+
*/
|
106
|
+
VALUE a4r_API_desktop_palette(VALUE self)
|
107
|
+
{
|
108
|
+
// TODO: Convert to data struct or cached or hooked variable?
|
109
|
+
PALETTE *pal = &desktop_palette;
|
110
|
+
VALUE obj = Data_Wrap_Struct(cAPI_PALETTE, 0, 0, pal);
|
111
|
+
return obj;
|
112
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#include "allegro4r.h"
|
2
|
+
|
3
|
+
/*
|
4
|
+
* call-seq:
|
5
|
+
* install_sound(digi, midi, cfg_path) -> int
|
6
|
+
*
|
7
|
+
* Initialises the sound module. You should normally pass DIGI_AUTODETECT and
|
8
|
+
* MIDI_AUTODETECT as the driver parameters to this function, in which case
|
9
|
+
* Allegro will read hardware settings from the current configuration file. This
|
10
|
+
* allows the user to select different values with the setup utility: see the
|
11
|
+
* config section for details. Alternatively, see the platform specific
|
12
|
+
* documentation for a list of the available drivers. The cfg_path parameter is
|
13
|
+
* only present for compatibility with previous versions of Allegro, and has no
|
14
|
+
* effect on anything.
|
15
|
+
*
|
16
|
+
* Return value: Returns zero if the sound is successfully installed, and -1 on
|
17
|
+
* failure. If it fails it will store a description of the problem in
|
18
|
+
* allegro_error.
|
19
|
+
*/
|
20
|
+
VALUE a4r_API_install_sound(VALUE self, VALUE digi, VALUE midi, VALUE cfg_path)
|
21
|
+
{
|
22
|
+
char *c;
|
23
|
+
if (cfg_path == Qnil)
|
24
|
+
c = NULL;
|
25
|
+
else
|
26
|
+
c = StringValuePtr(cfg_path);
|
27
|
+
|
28
|
+
return INT2FIX(install_sound(FIX2INT(digi), FIX2INT(midi), c));
|
29
|
+
}
|
@@ -0,0 +1,178 @@
|
|
1
|
+
#include "allegro4r.h"
|
2
|
+
|
3
|
+
/*
|
4
|
+
* call-seq:
|
5
|
+
* font -> a_fnt
|
6
|
+
*
|
7
|
+
* A simple 8x8 fixed size font (the mode 13h BIOS default). If you want to
|
8
|
+
* alter the font used by the GUI routines, change this to point to one of your
|
9
|
+
* own fonts. This font contains the standard ASCII (U+20 to U+7F), Latin-1
|
10
|
+
* (U+A1 to U+FF), and Latin Extended-A (U+0100 to U+017F) character ranges.
|
11
|
+
*/
|
12
|
+
VALUE a4r_API_font(VALUE self)
|
13
|
+
{
|
14
|
+
// TODO: Convert to data struct or cached or hooked variable?
|
15
|
+
FONT *fnt = font;
|
16
|
+
VALUE obj = Data_Wrap_Struct(cAPI_FONT, 0, 0, fnt);
|
17
|
+
return obj;
|
18
|
+
}
|
19
|
+
|
20
|
+
/*
|
21
|
+
* call-seq:
|
22
|
+
* font = fnt -> fnt
|
23
|
+
*
|
24
|
+
* See font.
|
25
|
+
*/
|
26
|
+
VALUE a4r_API_font_set(VALUE self, VALUE f)
|
27
|
+
{
|
28
|
+
FONT *fnt;
|
29
|
+
Data_Get_Struct(f, FONT, fnt);
|
30
|
+
font = fnt;
|
31
|
+
return f;
|
32
|
+
}
|
33
|
+
|
34
|
+
/*
|
35
|
+
* call-seq:
|
36
|
+
* text_length(f, str) -> int
|
37
|
+
*
|
38
|
+
* Returns the length (in pixels) of a string in the specified font. Example:
|
39
|
+
* width = text_length(font, "I love spam")
|
40
|
+
* ...
|
41
|
+
* bmp = create_bitmap(width, height)
|
42
|
+
*/
|
43
|
+
VALUE a4r_API_text_length(VALUE self, VALUE f, VALUE str)
|
44
|
+
{
|
45
|
+
FONT *fnt;
|
46
|
+
Data_Get_Struct(f, FONT, fnt);
|
47
|
+
return INT2FIX(text_length(fnt, StringValuePtr(str)));
|
48
|
+
}
|
49
|
+
|
50
|
+
/*
|
51
|
+
* call-seq:
|
52
|
+
* text_height(f) -> int
|
53
|
+
*
|
54
|
+
* Returns the height (in pixels) of the specified font. Example:
|
55
|
+
* height = text_height(font)
|
56
|
+
* ...
|
57
|
+
* bmp = create_bitmap(width, height)
|
58
|
+
*/
|
59
|
+
VALUE a4r_API_text_height(VALUE self, VALUE f)
|
60
|
+
{
|
61
|
+
FONT *fnt;
|
62
|
+
Data_Get_Struct(f, FONT, fnt);
|
63
|
+
return INT2FIX(text_height(fnt));
|
64
|
+
}
|
65
|
+
|
66
|
+
/*
|
67
|
+
* call-seq:
|
68
|
+
* textout_ex(bmp, f, s, x, y, color, bg) -> nil
|
69
|
+
*
|
70
|
+
* Writes the string 's' onto the bitmap at position x, y, using the specified
|
71
|
+
* font, foreground color and background color. If the background color is -1,
|
72
|
+
* then the text is written transparently. If the foreground color is -1 and a
|
73
|
+
* color font is in use, it will be drawn using the colors from the original
|
74
|
+
* font bitmap (the one you imported into the grabber program), which allows
|
75
|
+
* multicolored text output. For high and true color fonts, the foreground color
|
76
|
+
* is ignored and always treated as -1. Example:
|
77
|
+
* # Show the program's version in blue letters.
|
78
|
+
* textout_ex(screen, font, "v4.2.0-beta2", 10, 10,
|
79
|
+
* makecol(0, 0, 255), -1)
|
80
|
+
*/
|
81
|
+
VALUE a4r_API_textout_ex(VALUE self, VALUE bmp, VALUE f, VALUE s, VALUE x, VALUE y, VALUE color, VALUE bg)
|
82
|
+
{
|
83
|
+
BITMAP *b;
|
84
|
+
Data_Get_Struct(bmp, BITMAP, b);
|
85
|
+
FONT *fnt;
|
86
|
+
Data_Get_Struct(f, FONT, fnt);
|
87
|
+
textout_ex(b, fnt, StringValuePtr(s), FIX2INT(x), FIX2INT(y), FIX2INT(color), FIX2INT(bg));
|
88
|
+
return Qnil;
|
89
|
+
}
|
90
|
+
|
91
|
+
/*
|
92
|
+
* call-seq:
|
93
|
+
* textout_centre_ex(bmp, f, s, x, y, color, bg) -> nil
|
94
|
+
*
|
95
|
+
* Like textout_ex, but interprets the x coordinate as the centre rather than
|
96
|
+
* the left edge of the string. Example:
|
97
|
+
* # Important texts go in the middle.
|
98
|
+
* width = text_length("GAME OVER")
|
99
|
+
* textout_centre_ex(screen, font, "GAME OVER",
|
100
|
+
* SCREEN_W / 2, SCREEN_H / 2,
|
101
|
+
* makecol(255, 0, 0), makecol(0, 0, 0))
|
102
|
+
*/
|
103
|
+
VALUE a4r_API_textout_centre_ex(VALUE self, VALUE bmp, VALUE f, VALUE s, VALUE x, VALUE y, VALUE color, VALUE bg)
|
104
|
+
{
|
105
|
+
BITMAP *b;
|
106
|
+
Data_Get_Struct(bmp, BITMAP, b);
|
107
|
+
FONT *fnt;
|
108
|
+
Data_Get_Struct(f, FONT, fnt);
|
109
|
+
textout_centre_ex(b, fnt, StringValuePtr(s), FIX2INT(x), FIX2INT(y), FIX2INT(color), FIX2INT(bg));
|
110
|
+
return Qnil;
|
111
|
+
}
|
112
|
+
|
113
|
+
/*
|
114
|
+
* call-seq:
|
115
|
+
* textprintf_ex(bmp, f, x, y, color, by, fmt) -> nil
|
116
|
+
*
|
117
|
+
* Formatted text output, using a printf style format string. Due to an internal
|
118
|
+
* limitation, this function can't be used for extremely long texts. If you
|
119
|
+
* happen to reach this limit, you can work around it by using uszprintf and
|
120
|
+
* textout_ex, which don't have any. Example:
|
121
|
+
* textprintf_ex(screen, font, 10, 10, makecol(255, 100, 200),
|
122
|
+
* -1, "Score: %d" % player_score)
|
123
|
+
*/
|
124
|
+
VALUE a4r_API_textprintf_ex(VALUE self, VALUE bmp, VALUE f, VALUE x, VALUE y, VALUE color, VALUE bg, VALUE fmt)
|
125
|
+
{
|
126
|
+
// TODO: Make this actually work like printf with arbitrary number of parameters
|
127
|
+
BITMAP *b;
|
128
|
+
Data_Get_Struct(bmp, BITMAP, b);
|
129
|
+
FONT *fnt;
|
130
|
+
Data_Get_Struct(f, FONT, fnt);
|
131
|
+
textprintf_ex(b, fnt, FIX2INT(x), FIX2INT(y), FIX2INT(color), FIX2INT(bg), StringValuePtr(fmt));
|
132
|
+
return Qnil;
|
133
|
+
}
|
134
|
+
|
135
|
+
/*
|
136
|
+
* call-seq:
|
137
|
+
* textprintf_centre_ex(bmp, f, x, y, color, bg, fmt) -> nil
|
138
|
+
*
|
139
|
+
* Like textprintf_ex, but interprets the x coordinate as the centre rather than
|
140
|
+
* the left edge of the string. This function shares the text length limitation
|
141
|
+
* of textprintf_ex. Example:
|
142
|
+
* textprintf_centre_ex(screen, font, SCREEN_W / 2, 120,
|
143
|
+
* makecol(0, 100, 243), -1,
|
144
|
+
* "Your best score so far was %d!" %
|
145
|
+
* total_max_points)
|
146
|
+
*/
|
147
|
+
VALUE a4r_API_textprintf_centre_ex(VALUE self, VALUE bmp, VALUE f, VALUE x, VALUE y, VALUE color, VALUE bg, VALUE fmt)
|
148
|
+
{
|
149
|
+
// TODO: Make this actually work like printf with arbitrary number of parameters
|
150
|
+
BITMAP *b;
|
151
|
+
Data_Get_Struct(bmp, BITMAP, b);
|
152
|
+
FONT *fnt;
|
153
|
+
Data_Get_Struct(f, FONT, fnt);
|
154
|
+
textprintf_centre_ex(b, fnt, FIX2INT(x), FIX2INT(y), FIX2INT(color), FIX2INT(bg), StringValuePtr(fmt));
|
155
|
+
return Qnil;
|
156
|
+
}
|
157
|
+
|
158
|
+
/*
|
159
|
+
* call-seq:
|
160
|
+
* textprintf_right_ex(bmp, f, x, y, color, bg, fmt) -> nil
|
161
|
+
*
|
162
|
+
* Like textprintf_ex, but interprets the x coordinate as the right rather than
|
163
|
+
* the left edge of the string. This function shares the text length limitation
|
164
|
+
* of textprintf_ex. Example:
|
165
|
+
* textprintf_right_ex(screen, font, SCREEN_W - 10, 10,
|
166
|
+
* makecol(200, 200, 20), -1,
|
167
|
+
* "%d bullets left" % player_ammo)
|
168
|
+
*/
|
169
|
+
VALUE a4r_API_textprintf_right_ex(VALUE self, VALUE bmp, VALUE f, VALUE x, VALUE y, VALUE color, VALUE bg, VALUE fmt)
|
170
|
+
{
|
171
|
+
// TODO: Make this actually work like printf with arbitrary number of parameters
|
172
|
+
BITMAP *b;
|
173
|
+
Data_Get_Struct(bmp, BITMAP, b);
|
174
|
+
FONT *fnt;
|
175
|
+
Data_Get_Struct(f, FONT, fnt);
|
176
|
+
textprintf_right_ex(b, fnt, FIX2INT(x), FIX2INT(y), FIX2INT(color), FIX2INT(bg), StringValuePtr(fmt));
|
177
|
+
return Qnil;
|
178
|
+
}
|