allegro4r 0.0.1

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.
Files changed (59) hide show
  1. data/History.txt +4 -0
  2. data/Manifest.txt +58 -0
  3. data/README.txt +94 -0
  4. data/examples/exdbuf.rb +58 -0
  5. data/examples/exfixed.rb +46 -0
  6. data/examples/exflame.rb +200 -0
  7. data/examples/exflip.rb +87 -0
  8. data/examples/exfont.rb +70 -0
  9. data/examples/exhello.rb +46 -0
  10. data/examples/exjoy.rb +206 -0
  11. data/examples/exkeys.rb +216 -0
  12. data/examples/exmem.rb +50 -0
  13. data/examples/exmidi.rb +97 -0
  14. data/examples/exmouse.rb +149 -0
  15. data/examples/expal.rb +70 -0
  16. data/examples/expat.rb +62 -0
  17. data/examples/exsample.rb +89 -0
  18. data/examples/extimer.rb +84 -0
  19. data/examples/unifont.dat +0 -0
  20. data/ext/a4r_API_BITMAP.c +27 -0
  21. data/ext/a4r_API_DIGI_DRIVER.c +14 -0
  22. data/ext/a4r_API_GFX_DRIVER.c +14 -0
  23. data/ext/a4r_API_JOYSTICK_AXIS_INFO.c +53 -0
  24. data/ext/a4r_API_JOYSTICK_BUTTON_INFO.c +27 -0
  25. data/ext/a4r_API_JOYSTICK_DRIVER.c +14 -0
  26. data/ext/a4r_API_JOYSTICK_INFO.c +84 -0
  27. data/ext/a4r_API_JOYSTICK_STICK_INFO.c +62 -0
  28. data/ext/a4r_API_KEYBOARD_DRIVER.c +14 -0
  29. data/ext/a4r_API_MIDI_DRIVER.c +14 -0
  30. data/ext/a4r_API_MOUSE_DRIVER.c +14 -0
  31. data/ext/a4r_API_PALETTE.c +63 -0
  32. data/ext/a4r_API_RGB.c +118 -0
  33. data/ext/a4r_API_TIMER_DRIVER.c +14 -0
  34. data/ext/a4r_API_bitmap_objects.c +310 -0
  35. data/ext/a4r_API_blitting_and_sprites.c +86 -0
  36. data/ext/a4r_API_digital_sample_routines.c +83 -0
  37. data/ext/a4r_API_direct_access_to_video_memory.c +102 -0
  38. data/ext/a4r_API_drawing_primitives.c +114 -0
  39. data/ext/a4r_API_file_and_compression_routines.c +27 -0
  40. data/ext/a4r_API_fixed_point_math_routines.c +98 -0
  41. data/ext/a4r_API_fonts.c +147 -0
  42. data/ext/a4r_API_graphics_modes.c +155 -0
  43. data/ext/a4r_API_joystick_routines.c +213 -0
  44. data/ext/a4r_API_keyboard_routines.c +420 -0
  45. data/ext/a4r_API_misc.c +133 -0
  46. data/ext/a4r_API_mouse_routines.c +220 -0
  47. data/ext/a4r_API_music_routines_midi.c +147 -0
  48. data/ext/a4r_API_palette_routines.c +112 -0
  49. data/ext/a4r_API_sound_init_routines.c +29 -0
  50. data/ext/a4r_API_text_output.c +178 -0
  51. data/ext/a4r_API_timer_routines.c +250 -0
  52. data/ext/a4r_API_transparency_and_patterned_drawing.c +87 -0
  53. data/ext/a4r_API_truecolor_pixel_formats.c +44 -0
  54. data/ext/a4r_API_unicode_routines.c +53 -0
  55. data/ext/a4r_API_using_allegro.c +98 -0
  56. data/ext/allegro4r.c +866 -0
  57. data/ext/allegro4r.h +311 -0
  58. data/ext/extconf.rb +11 -0
  59. metadata +112 -0
@@ -0,0 +1,50 @@
1
+ #
2
+ # Example program (C Version) for the Allegro library, by Shawn Hargreaves.
3
+ # (Ruby port by Jason Frey)
4
+ #
5
+ # This program demonstrates the use of memory bitmaps. It creates
6
+ # a small temporary bitmap in memory, draws some circles onto it,
7
+ # and then blits lots of copies of it onto the screen.
8
+ #
9
+
10
+ require 'rubygems'
11
+ require 'allegro4r'
12
+ include Allegro4r::API
13
+
14
+ exit 1 if allegro_init != 0
15
+ install_keyboard
16
+
17
+ if set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0
18
+ if set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0
19
+ set_gfx_mode(GFX_TEXT, 0, 0, 0, 0)
20
+ allegro_message("Unable to set any graphic mode\n%s\n" % allegro_error)
21
+ exit 1
22
+ end
23
+ end
24
+
25
+ set_palette(desktop_palette)
26
+
27
+ # make a memory bitmap sized 20x20
28
+ memory_bitmap = create_bitmap(20, 20)
29
+
30
+ # draw some circles onto it
31
+ clear_bitmap(memory_bitmap)
32
+ (0..15).each do |x|
33
+ circle(memory_bitmap, 10, 10, x, palette_color[x])
34
+ end
35
+
36
+ # blit lots of copies of it onto the screen
37
+ acquire_screen
38
+
39
+ (0...SCREEN_H()).step(20) do |y|
40
+ (0...SCREEN_W()).step(20) do |x|
41
+ blit(memory_bitmap, screen, 0, 0, x, y, 20, 20)
42
+ end
43
+ end
44
+
45
+ release_screen
46
+
47
+ # free the memory bitmap
48
+ destroy_bitmap(memory_bitmap)
49
+
50
+ readkey
@@ -0,0 +1,97 @@
1
+ #
2
+ # Example program (C Version) for the Allegro library, by Shawn Hargreaves.
3
+ # (Ruby port by Jason Frey)
4
+ #
5
+ # This program demonstrates how to play MIDI files.
6
+ #
7
+
8
+ require 'rubygems'
9
+ require 'allegro4r'
10
+ include Allegro4r::API
11
+
12
+ paused = false
13
+ done = false
14
+
15
+ exit 1 if allegro_init != 0
16
+
17
+ if ARGV.length != 1
18
+ allegro_message("Usage: 'ruby exmidi.rb filename.mid'\n")
19
+ exit 1
20
+ end
21
+
22
+ install_keyboard
23
+ install_timer
24
+
25
+ # install a MIDI sound driver
26
+ if install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, nil) != 0
27
+ allegro_message("Error initialising sound system\n%s\n" % allegro_error)
28
+ exit 1
29
+ end
30
+
31
+ # read in the MIDI file
32
+ the_music = load_midi(ARGV[0])
33
+ if the_music.nil?
34
+ allegro_message("Error reading MIDI file '%s'\n" % ARGV[0])
35
+ exit 1
36
+ end
37
+ length = get_midi_length(the_music)
38
+ beats = -midi_pos # get_midi_length updates midi_pos to the negative
39
+ # number of beats (quarter notes) in the midi.
40
+
41
+ if set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0
42
+ if set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0
43
+ set_gfx_mode(GFX_TEXT, 0, 0, 0, 0)
44
+ allegro_message("Unable to set any graphic mode\n%s\n" % allegro_error)
45
+ exit 1
46
+ end
47
+ end
48
+
49
+ # try to continue in the background
50
+ if set_display_switch_mode(SWITCH_BACKGROUND)
51
+ set_display_switch_mode(SWITCH_BACKAMNESIA)
52
+ end
53
+
54
+ set_palette(desktop_palette)
55
+ background_color = makecol(255, 255, 255)
56
+ text_color = makecol(0, 0, 0)
57
+ clear_to_color(screen, background_color)
58
+ th = text_height(font)
59
+ x = SCREEN_W() / 2
60
+
61
+ textprintf_centre_ex(screen, font, x, SCREEN_H() / 3, text_color, -1, "Driver: %s" % midi_driver.name)
62
+ textprintf_centre_ex(screen, font, x, SCREEN_H() / 2, text_color, -1, "Playing %s" % get_filename(ARGV[0]))
63
+
64
+ # start up the MIDI file
65
+ play_midi(the_music, true)
66
+
67
+ y = 2 * SCREEN_H() / 3
68
+ tw = text_length(font, "0000:00 / 0000:00")
69
+ # wait for a key press
70
+ while !done
71
+ # P key pauses/resumes, any other key exits.
72
+ while keypressed
73
+ k = readkey & 255
74
+ if k == ?p
75
+ paused = !paused
76
+ if paused
77
+ midi_pause
78
+ textprintf_centre_ex(screen, font, x, y + th * 3, text_color, -1, "P A U S E D")
79
+ else
80
+ midi_resume
81
+ rectfill(screen, x - tw / 2, y + th * 3, x + tw / 2, y + th * 4, background_color)
82
+ end
83
+ else
84
+ done = true
85
+ end
86
+ end
87
+ pos = midi_time
88
+ beat = midi_pos
89
+ rectfill(screen, x - tw / 2, y, x + tw / 2, y + th * 2, background_color)
90
+ textprintf_centre_ex(screen, font, x, y, text_color, -1, "%d:%02d / %d:%02d" % [pos / 60, pos % 60, length / 60, length % 60])
91
+ textprintf_centre_ex(screen, font, x, y + th, text_color, -1, "beat %d / %d" % [beat, beats])
92
+ # We have nothing else to do.
93
+ rest(100)
94
+ end
95
+
96
+ # destroy the MIDI file
97
+ destroy_midi(the_music)
@@ -0,0 +1,149 @@
1
+ #
2
+ # Example program (C Version) for the Allegro library, by Shawn Hargreaves.
3
+ # (Ruby port by Jason Frey)
4
+ #
5
+ # This program demonstrates how to get mouse input. The
6
+ # first part of the test retrieves the raw mouse input data
7
+ # and displays it on the screen without using any mouse
8
+ # cursor. When you press a key the standard arrow-like mouse
9
+ # cursor appears. You are not restricted to this shape,
10
+ # and a second key press modifies the cursor to be several
11
+ # concentric colored circles. They are not joined together,
12
+ # so you can still see bits of what's behind when you move the
13
+ # cursor over the printed text message.
14
+ #
15
+
16
+ require 'rubygems'
17
+ require 'allegro4r'
18
+ include Allegro4r::API
19
+
20
+ def print_all_buttons
21
+ fc = makecol(0, 0, 0)
22
+ bc = makecol(255, 255, 255)
23
+ textprintf_right_ex(screen, font, 320, 50, fc, bc, "buttons")
24
+ (0...8).each do |i|
25
+ x = 320
26
+ y = 60 + i * 10
27
+ if (mouse_b & (1 << i)) != 0
28
+ textprintf_right_ex(screen, font, x, y, fc, bc, "%2d" % (1 + i))
29
+ else
30
+ textprintf_right_ex(screen, font, x, y, fc, bc, " ")
31
+ end
32
+ end
33
+ end
34
+
35
+ mickeyx = 0
36
+ mickeyy = 0
37
+ c = 0
38
+
39
+ exit 1 if allegro_init != 0
40
+ install_keyboard
41
+ install_timer
42
+
43
+ if set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0
44
+ if set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0
45
+ set_gfx_mode(GFX_TEXT, 0, 0, 0, 0)
46
+ allegro_message("Unable to set any graphic mode\n%s\n" % allegro_error)
47
+ exit 1
48
+ end
49
+ end
50
+
51
+ set_palette(desktop_palette)
52
+ clear_to_color(screen, makecol(255, 255, 255))
53
+
54
+ # Detect mouse presence
55
+ if install_mouse < 0
56
+ textout_centre_ex(screen, font, "No mouse detected, but you need one!", SCREEN_W()/2, SCREEN_H()/2, makecol(0, 0, 0), makecol(255, 255, 255))
57
+ readkey
58
+ exit 0
59
+ end
60
+
61
+ textprintf_centre_ex(screen, font, SCREEN_W()/2, 8, makecol(0, 0, 0), makecol(255, 255, 255), "Driver: %s" % mouse_driver.name)
62
+
63
+ loop do
64
+ # On most platforms (eg. DOS) things will still work correctly
65
+ # without this call, but it is a good idea to include it in any
66
+ # programs that you want to be portable, because on some platforms
67
+ # you may not be able to get any mouse input without it.
68
+ poll_mouse
69
+
70
+ acquire_screen
71
+
72
+ # the mouse position is stored in the variables mouse_x and mouse_y
73
+ textprintf_ex(screen, font, 16, 48, makecol(0, 0, 0), makecol(255, 255, 255), "mouse_x = %-5d" % mouse_x)
74
+ textprintf_ex(screen, font, 16, 64, makecol(0, 0, 0), makecol(255, 255, 255), "mouse_y = %-5d" % mouse_y)
75
+
76
+ # or you can use this function to measure the speed of movement.
77
+ # Note that we only call it every fourth time round the loop:
78
+ # there's no need for that other than to slow the numbers down
79
+ # a bit so that you will have time to read them...
80
+ c += 1
81
+ mickeyx, mickeyy = get_mouse_mickeys if (c & 3) == 0
82
+
83
+ textprintf_ex(screen, font, 16, 88, makecol(0, 0, 0), makecol(255, 255, 255), "mickey_x = %-7d" % mickeyx)
84
+ textprintf_ex(screen, font, 16, 104, makecol(0, 0, 0), makecol(255, 255, 255), "mickey_y = %-7d" % mickeyy)
85
+
86
+ # the mouse button state is stored in the variable mouse_b
87
+ if (mouse_b & 1) != 0
88
+ textout_ex(screen, font, "left button is pressed ", 16, 128, makecol(0, 0, 0), makecol(255, 255, 255))
89
+ else
90
+ textout_ex(screen, font, "left button not pressed", 16, 128, makecol(0, 0, 0), makecol(255, 255, 255))
91
+ end
92
+
93
+ if (mouse_b & 2) != 0
94
+ textout_ex(screen, font, "right button is pressed ", 16, 144, makecol(0, 0, 0), makecol(255, 255, 255))
95
+ else
96
+ textout_ex(screen, font, "right button not pressed", 16, 144, makecol(0, 0, 0), makecol(255, 255, 255))
97
+ end
98
+
99
+ if (mouse_b & 4) != 0
100
+ textout_ex(screen, font, "middle button is pressed ", 16, 160, makecol(0, 0, 0), makecol(255, 255, 255))
101
+ else
102
+ textout_ex(screen, font, "middle button not pressed", 16, 160, makecol(0, 0, 0), makecol(255, 255, 255))
103
+ end
104
+
105
+ # the wheel position is stored in the variable mouse_z
106
+ textprintf_ex(screen, font, 16, 184, makecol(0, 0, 0), makecol(255, 255, 255), "mouse_z = %-5d mouse_w = %-5d" % [mouse_z, mouse_w])
107
+
108
+ print_all_buttons
109
+
110
+ release_screen
111
+
112
+ vsync
113
+
114
+ break if keypressed
115
+ end
116
+
117
+ clear_keybuf
118
+
119
+ # To display a mouse pointer, call show_mouse(). There are several
120
+ # things you should be aware of before you do this, though. For one,
121
+ # it won't work unless you call install_timer() first. For another,
122
+ # you must never draw anything onto the screen while the mouse
123
+ # pointer is visible. So before you draw anything, be sure to turn
124
+ # the mouse off with show_mouse(NULL), and turn it back on again when
125
+ # you are done.
126
+ clear_to_color(screen, makecol(255, 255, 255))
127
+ textout_centre_ex(screen, font, "Press a key to change cursor", SCREEN_W()/2, SCREEN_H()/2, makecol(0, 0, 0), makecol(255, 255, 255))
128
+ show_mouse(screen)
129
+ readkey
130
+ show_mouse(nil)
131
+
132
+ # create a custom mouse cursor bitmap...
133
+ custom_cursor = create_bitmap(32, 32)
134
+ clear_to_color(custom_cursor, bitmap_mask_color(screen))
135
+ (0...8).each do |c|
136
+ circle(custom_cursor, 16, 16, c * 2, palette_color[c])
137
+ end
138
+
139
+ # select the custom cursor and set the focus point to the middle of it
140
+ set_mouse_sprite(custom_cursor)
141
+ set_mouse_sprite_focus(16, 16)
142
+
143
+ clear_to_color(screen, makecol(255, 255, 255))
144
+ textout_centre_ex(screen, font, "Press a key to quit", SCREEN_W()/2, SCREEN_H()/2, makecol(0, 0, 0), makecol(255, 255, 255))
145
+ show_mouse(screen)
146
+ readkey
147
+ show_mouse(nil)
148
+
149
+ destroy_bitmap(custom_cursor)
@@ -0,0 +1,70 @@
1
+ #
2
+ # Example program (C Version) for the Allegro library, by Shawn Hargreaves.
3
+ # (Ruby port by Jason Frey)
4
+ #
5
+ # This program demonstrates how to manipulate the palette. It draws
6
+ # a set of concentric circles onto the screen and animates them by
7
+ # cycling the palette.
8
+ #
9
+
10
+ require 'rubygems'
11
+ require 'allegro4r'
12
+ include Allegro4r::API
13
+
14
+ palette = PALETTE.new
15
+
16
+ exit 1 if allegro_init != 0
17
+ install_keyboard
18
+ if set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0
19
+ if set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0
20
+ allegro_message("Error setting graphics mode\n%s\n" % allegro_error)
21
+ exit 1
22
+ end
23
+ end
24
+
25
+ # first set the palette to black to hide what we are doing
26
+ set_palette(black_palette)
27
+
28
+ # draw some circles onto the screen
29
+ acquire_screen
30
+
31
+ 255.downto(1) do |c|
32
+ circlefill(screen, SCREEN_W()/2, SCREEN_H()/2, c, c)
33
+ end
34
+
35
+ release_screen
36
+
37
+ install_mouse
38
+ show_mouse(screen)
39
+
40
+ # fill our palette with a gradually altering sequence of colors
41
+ (0...64).each do |c|
42
+ palette[c].r = c;
43
+ palette[c].g = 0;
44
+ palette[c].b = 0;
45
+ end
46
+ (64...128).each do |c|
47
+ palette[c].r = 127 - c;
48
+ palette[c].g = c - 64;
49
+ palette[c].b = 0;
50
+ end
51
+ (128...192).each do |c|
52
+ palette[c].r = 0;
53
+ palette[c].g = 191 - c;
54
+ palette[c].b = c - 128;
55
+ end
56
+ (192...256).each do |c|
57
+ palette[c].r = 0;
58
+ palette[c].g = 0;
59
+ palette[c].b = 255 - c;
60
+ end
61
+
62
+ # animate the image by rotating the palette
63
+ while !keypressed do
64
+ temp = palette[255].dup
65
+ 255.downto(1) do |c|
66
+ palette[c] = palette[c - 1]
67
+ end
68
+ palette[0] = temp
69
+ set_palette(palette)
70
+ end
@@ -0,0 +1,62 @@
1
+ #
2
+ # Example program (C Version) for the Allegro library, by Shawn Hargreaves.
3
+ # (Ruby port by Jason Frey)
4
+ #
5
+ # This program demonstrates the use of patterned drawing and sub-bitmaps.
6
+ #
7
+
8
+ require 'rubygems'
9
+ require 'allegro4r'
10
+ include Allegro4r::API
11
+
12
+ def draw_pattern(bitmap, message, color)
13
+ acquire_bitmap(bitmap)
14
+
15
+ # create a pattern bitmap
16
+ pattern = create_bitmap(text_length(font, message), text_height(font))
17
+ clear_to_color(pattern, bitmap_mask_color(pattern))
18
+ textout_ex(pattern, font, message, 0, 0, palette_color[255], bitmap_mask_color(screen))
19
+
20
+ # cover the bitmap with the pattern
21
+ drawing_mode(DRAW_MODE_MASKED_PATTERN, pattern, 0, 0)
22
+ rectfill(bitmap, 0, 0, bitmap.w, bitmap.h, palette_color[color])
23
+ solid_mode
24
+
25
+ # destroy the pattern bitmap
26
+ destroy_bitmap(pattern)
27
+
28
+ release_bitmap(bitmap)
29
+ end
30
+
31
+ exit 1 if allegro_init != 0
32
+ install_keyboard
33
+
34
+ if set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0
35
+ if set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0
36
+ allegro_message("Unable to set any graphic mode\n%s\n" % allegro_error)
37
+ exit 1
38
+ end
39
+ end
40
+
41
+ set_palette(desktop_palette)
42
+ clear_to_color(screen, makecol(255, 255, 255))
43
+
44
+ # first cover the whole screen with a pattern
45
+ draw_pattern(screen, "<screen>", 255)
46
+
47
+ # draw the pattern onto a memory bitmap and then blit it to the screen
48
+ bitmap = create_bitmap(128, 32)
49
+ clear_to_color(bitmap, makecol(255, 255, 255))
50
+ draw_pattern(bitmap, "<memory>", 1)
51
+ masked_blit(bitmap, screen, 0, 0, 32, 32, 128, 32)
52
+ destroy_bitmap(bitmap)
53
+
54
+ # or we could use a sub-bitmap. These share video memory with their
55
+ # parent, so the drawing will be visible without us having to blit it
56
+ # across onto the screen.
57
+ bitmap = create_sub_bitmap(screen, 224, 64, 64, 128)
58
+ rectfill(screen, 224, 64, 286, 192, makecol(255, 255, 255))
59
+ draw_pattern(bitmap, "<subbmp>", 4)
60
+ destroy_bitmap(bitmap)
61
+
62
+ readkey
@@ -0,0 +1,89 @@
1
+ #
2
+ # Example program (C Version) for the Allegro library, by Shawn Hargreaves.
3
+ # (Ruby port by Jason Frey)
4
+ #
5
+ # This program demonstrates how to play samples. You have to
6
+ # use this example from the command line to specify as first
7
+ # parameter a WAV or VOC sound file to play. If the file is
8
+ # loaded successfully, the sound will be played in an infinite
9
+ # loop. While it is being played, you can use the left and right
10
+ # arrow keys to modify the panning of the sound. You can also
11
+ # use the up and down arrow keys to modify the pitch.
12
+ #
13
+
14
+ require 'rubygems'
15
+ require 'allegro4r'
16
+ include Allegro4r::API
17
+
18
+ pan = 128
19
+ pitch = 1000
20
+
21
+ exit 1 if allegro_init != 0
22
+
23
+ if ARGV.length != 1
24
+ allegro_message("Usage: 'ruby exsample.rb filename.[wav|voc]'\n")
25
+ exit 1
26
+ end
27
+
28
+ install_keyboard
29
+ install_timer
30
+
31
+ # install a digital sound driver
32
+ if install_sound(DIGI_AUTODETECT, MIDI_NONE, nil) != 0
33
+ allegro_message("Error initialising sound system\n%s\n" % allegro_error)
34
+ exit 1
35
+ end
36
+
37
+ # read in the WAV file
38
+ the_sample = load_sample(ARGV[0])
39
+ if the_sample.nil?
40
+ allegro_message("Error reading WAV file '%s'\n" % ARGV[0])
41
+ exit 1
42
+ end
43
+
44
+ if set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0
45
+ if set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0
46
+ set_gfx_mode(GFX_TEXT, 0, 0, 0, 0)
47
+ allegro_message("Unable to set any graphic mode\n%s\n" % allegro_error)
48
+ exit 1
49
+ end
50
+ end
51
+
52
+ set_palette(desktop_palette)
53
+ clear_to_color(screen, makecol(255,255,255))
54
+
55
+ textprintf_centre_ex(screen, font, SCREEN_W()/2, SCREEN_H()/3, makecol(0, 0, 0), -1, "Driver: %s" % digi_driver.name)
56
+ textprintf_centre_ex(screen, font, SCREEN_W()/2, SCREEN_H()/2, makecol(0, 0, 0), -1, "Playing %s" % ARGV[0])
57
+ textprintf_centre_ex(screen, font, SCREEN_W()/2, SCREEN_H()*2/3, makecol(0, 0, 0), -1, "Use the arrow keys to adjust it")
58
+
59
+ # start up the sample
60
+ play_sample(the_sample, 255, pan, pitch, true)
61
+
62
+ loop do
63
+ poll_keyboard
64
+
65
+ # alter the pan position?
66
+ if key[KEY_LEFT] && pan > 0
67
+ pan -= 1
68
+ elsif key[KEY_RIGHT] && pan < 255
69
+ pan += 1
70
+ end
71
+
72
+ # alter the pitch?
73
+ if key[KEY_UP] && pitch < 16384
74
+ pitch = ((pitch * 513) / 512) + 1
75
+ elsif key[KEY_DOWN] && pitch > 64
76
+ pitch = ((pitch * 511) / 512) - 1
77
+ end
78
+
79
+ # adjust the sample
80
+ adjust_sample(the_sample, 255, pan, pitch, true)
81
+
82
+ # delay a bit
83
+ rest(2)
84
+
85
+ break unless !key[KEY_ESC] && !key[KEY_SPACE]
86
+ end
87
+
88
+ # destroy the sample
89
+ destroy_sample(the_sample)