summaryrefslogtreecommitdiffstats
path: root/frozen-bubble/build/frozen-bubble-sdl_perl.patch
diff options
context:
space:
mode:
author Eric Hameleers <alien@slackware.com>2006-10-09 13:54:48 +0000
committer Eric Hameleers <alien@slackware.com>2006-10-09 13:54:48 +0000
commit21bf5c9a956c66b4c415ae0630145b08c7e92326 (patch)
tree9b2f055bdcd2ca50cf4633397d9cf0b6d1d42757 /frozen-bubble/build/frozen-bubble-sdl_perl.patch
parent6fa30e1b529affbe9ce7f79a830987a20682cab1 (diff)
downloadasb-21bf5c9a956c66b4c415ae0630145b08c7e92326.tar.gz
asb-21bf5c9a956c66b4c415ae0630145b08c7e92326.tar.xz
Initial revision
Diffstat (limited to 'frozen-bubble/build/frozen-bubble-sdl_perl.patch')
-rw-r--r--frozen-bubble/build/frozen-bubble-sdl_perl.patch125
1 files changed, 125 insertions, 0 deletions
diff --git a/frozen-bubble/build/frozen-bubble-sdl_perl.patch b/frozen-bubble/build/frozen-bubble-sdl_perl.patch
new file mode 100644
index 00000000..be3afe4d
--- /dev/null
+++ b/frozen-bubble/build/frozen-bubble-sdl_perl.patch
@@ -0,0 +1,125 @@
+Based on upstream patch:
+http://www.frozen-bubble.org/perl-SDL.patch
+
+This version of the patch works with both sdl-perl-1.x and sdl-perl-2.x
+
+--- frozen-bubble
++++ frozen-bubble
+@@ -90,3 +90,4 @@
+
+ $version = '1.0.0';
++$SDL_VER = substr($SDL::VERSION, 0, 1); # Extract sdl-perl's major num
+
+@@ -161,6 +161,19 @@
+
+ #- ----------- sound related stuff ----------------------------------------
+
++sub get_sound {
++ my ($sound) = @_;
++ if ($SDL_VER eq 1) {
++ if (ref($sound) eq 'SDL::Sound') {
++ return $sound{$_}{-data};
++ } else {
++ return $sound->{-data};
++ }
++ } else {
++ return $$sound;
++ }
++}
++
+ sub play_sound($) {
+ $mixer_enabled && $mixer && !$sfx_disabled && $sound{$_[0]} and $mixer->play_channel(-1, $sound{$_[0]}, 0);
+ }
+@@ -179,7 +188,7 @@
+ $elem or return -1;
+ -f $elem or return 0;
+ $mus = SDL::Music->new($elem);
+- if ($mus->{-data}) {
++ if (get_sound($mus)) {
+ print STDERR "[Playlist] playing `$elem'\n";
+ $mixer->play_music($mus, 0);
+ return 1;
+@@ -191,9 +200,9 @@
+ while ($tryanother->() == 0) {};
+ } else {
+ $mus = SDL::Music->new("$FPATH$musics{$name}");
+- $mus->{-data} or print STDERR "Warning, could not create new music from `$FPATH$musics{$name}' (reason: ", $app->error, ").\n";
++ get_sound($mus) or print STDERR "Warning, could not create new music from `$FPATH$musics{$name}' (reason: ", $app->error, ").\n";
+ if ($pos) {
+- fb_c_stuff::fade_in_music_position($mus->{-data}, -1, 500, $pos);
++ fb_c_stuff::fade_in_music_position(get_sound($mus), -1, 500, $pos);
+ } else {
+ $mixer->play_music($mus, -1);
+ }
+@@ -212,7 +221,7 @@
+ foreach (@sounds) {
+ my $sound_path = "$FPATH/snd/$_.wav";
+ $sound{$_} = SDL::Sound->new($sound_path);
+- if ($sound{$_}{-data}) {
++ if (get_sound($sound{$_})) {
+ $sound{$_}->volume(80);
+ } else {
+ print STDERR "Warning, could not create new sound from `$sound_path'.\n";
+@@ -233,6 +233,14 @@
+
+ #- ----------- graphics related stuff --------------------------------------
+
++sub SDL_TEXTWIDTH {
++ if (defined(&SDL::App::SDL_TEXTWIDTH)) {
++ SDL::App::SDL_TEXTWIDTH(@_); # perl-sdl-1.x
++ } else {
++ SDL::SFont::SDL_TEXTWIDTH(@_); # perl-sdl-2.x
++ }
++}
++
+ sub add_default_rect($) {
+ my ($surface) = @_;
+ $rects{$surface} = SDL::Rect->new(-width => $surface->width, -height => $surface->height);
+@@ -304,10 +304,28 @@
+ return $save;
+ }
+
++sub surf {
++ my ($surface) = @_;
++ if (ref($surface) eq 'HASH') {
++ return $surface->{-surface};
++ } else {
++ return $$surface;
++ }
++}
++
++sub rect {
++ my ($rect) = @_;
++ if (ref($rect) eq 'HASH') {
++ return $rect->{-rect};
++ } else {
++ return $$rect;
++ }
++}
++
+ sub add_image($) {
+ my $file = "$FPATH/gfx/$_[0]";
+ my $img = SDL::Surface->new(-name => $file);
+- $img->{-surface} or die "FATAL: Couldn't load `$file' into a SDL::Surface.\n";
++ surf($img) or die "FATAL: Couldn't load `$file' into a SDL::Surface.\n";
+ add_default_rect($img);
+ return $img;
+ }
+@@ -1473,7 +1491,7 @@
+ }
+
+ put_image($imgbin{hiscore_frame}, $high_posx - 7, $high_posy - 6);
+- fb_c_stuff::shrink($app->{-surface}, $background->display_format->{-surface}, $high_posx, $high_posy, $high_rect->{-rect}, 4);
++ fb_c_stuff::shrink(surf($app), surf($background->display_format), $high_posx, $high_posy, rect($high_rect), 4);
+ $centered_print->($high_posx, $high_posy, $high->{name});
+ $centered_print->($high_posx, $high_posy+20, $high->{level} eq 'WON' ? "WON!" : "LVL-".$high->{level});
+ my $min = int($high->{time}/60);
+@@ -1642,7 +1660,7 @@
+ $background->blit($apprects{main}, $app, $apprects{main});
+ $app->flip;
+ } else {
+- fb_c_stuff::effect($app->{-surface}, $background->display_format->{-surface});
++ fb_c_stuff::effect(surf($app), surf($background->display_format));
+ }
+
+ $display_on_app_disabled = 0;