[!x86] games/frozen-bubble: perl 5.30 and display issues

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[!x86] games/frozen-bubble: perl 5.30 and display issues

Charlene Wendling
Hi,

To start with, the game is not maintained upstream, and as the server
has glib2 deprecation warnings, it may not be built in a close future.
It does not run on x86 due to a BROKEN p5-SDL on these 2 archs, and
updating p5-SDL does not solve this specific issue.

I tried playing it on macppc, but:

- it's broken with Perl 5.30: it still uses the removed [0] 'if 0'
  instead of state() for lexically scoped variables that won't be
  reinitialised. The below diff fix that, and allows the game to
  be started.
- there are graphic issues: the title screen is black. The directional
  arrow that helps throwing bubbles is invisible. Also libpng complains
  about some interlaced PNGs, the below diff deinterlace them.

The game is barely playable because of these graphic issues on macppc,
i wonder if people on other !x86 archs manage to have something that
really works.

Feedback is welcome :)

Charlène.


[0] https://rt-archive.perl.org/perl5/Ticket/Display.html?id=133543


Index: Makefile
===================================================================
RCS file: /cvs/ports/games/frozen-bubble/Makefile,v
retrieving revision 1.28
diff -u -p -u -p -r1.28 Makefile
--- Makefile 17 Jul 2019 14:49:22 -0000 1.28
+++ Makefile 26 Jan 2020 23:01:14 -0000
@@ -6,7 +6,7 @@ COMMENT-server = server for the frozen-b
 VER = 2.2.0
 DISTNAME = frozen-bubble-${VER}
 PKGNAME-main = ${DISTNAME}
-REVISION-main = 14
+REVISION-main = 15
 PKGNAME-server = frozen-bubble-server-${VER}
 REVISION-server = 10
 CATEGORIES = games
@@ -29,6 +29,9 @@ BUILD_DEPENDS = devel/p5-SDL \
  devel/p5-Locale-gettext \
  devel/gettext,-tools
 
+# Needed for post-patch deinterlacing
+BUILD_DEPENDS += graphics/ImageMagick
+
 RUN_DEPENDS-main = devel/p5-SDL \
  devel/p5-Locale-gettext \
  ${BASE_PKGPATH},-server
@@ -46,5 +49,14 @@ WANTLIB-main = SDL SDL_Pango SDL_mixer
 WANTLIB-server = c glib-2.0 intl pthread
 
 MULTI_PACKAGES = -main -server
+
+# fix "Interlace handling should be turned on when using png_read_image"
+post-patch:
+ @cd ${WRKSRC} && for interlaced in gfx/flags/flag-de.png \
+ gfx/flags/flag-fi.png \
+ gfx/flags/flag-no.png; \
+ do \
+ ${LOCALBASE}/bin/mogrify -interlace none $${interlaced} ;\
+ done
 
 .include <bsd.port.mk>
Index: patches/patch-c_stuff_lib_FBLE_pm
===================================================================
RCS file: patches/patch-c_stuff_lib_FBLE_pm
diff -N patches/patch-c_stuff_lib_FBLE_pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-c_stuff_lib_FBLE_pm 26 Jan 2020 23:01:14 -0000
@@ -0,0 +1,34 @@
+$OpenBSD$
+
+Perl 5.30+ prohibits using my() in false conditionals
+
+Index: c_stuff/lib/FBLE.pm
+--- c_stuff/lib/FBLE.pm.orig
++++ c_stuff/lib/FBLE.pm
+@@ -31,6 +31,8 @@
+
+ package FBLE;
+
++use feature qw(state);
++
+ use POSIX(qw(floor ceil));
+ use SDL;
+ use SDL::App;
+@@ -1405,7 +1407,7 @@ sub display_levelset_screenshot {
+                    $rect{middle}->y + $rect{middle}->height/2 - $rect{screenshot}->height/8 - 3 + $widgetMove);
+
+
+-    my %shrinks if 0;
++    state %shrinks;
+     my $current_nb = $start_level || 1;
+     if (!exists $shrinks{$name}{$current_nb}) {
+         my $surf = SDL::Surface->new(-name => "$FPATH/gfx/menu/please_wait.png");
+@@ -1417,7 +1419,7 @@ sub display_levelset_screenshot {
+         $app->update($rect{middle});
+
+         #- sorta "read ahead": will compute next 10 levels screenshots as well
+-        my $s_save if 0;
++        state $s_save;
+         if (!$s_save) {
+             $s_save = SDL::Surface->new(-name => "$FPATH/gfx/level_editor.png");
+         }
Index: patches/patch-frozen-bubble
===================================================================
RCS file: patches/patch-frozen-bubble
diff -N patches/patch-frozen-bubble
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-frozen-bubble 26 Jan 2020 23:01:14 -0000
@@ -0,0 +1,52 @@
+$OpenBSD$
+
+Perl 5.30+ prohibits using my() in false conditionals
+
+Index: frozen-bubble
+--- frozen-bubble.orig
++++ frozen-bubble
+@@ -47,6 +47,8 @@ use vars qw($TARGET_ANIM_SPEED $BUBBLE_SIZE $ROW_SIZE
+             $lev_number $playermalus $mptrainingdiff $loaded_levelset $direct_levelset $chainreaction %chains %img_mini $frame $sock $gameserver $mynick
+             $continuegamewhenplayersleave $singleplayertargetting $mylatitude $mylongitude %autokick $replayparam $autorecord $comment $saveframes $saveframesbase $saveframescounter);
+
++use feature qw(state);
++
+ use Getopt::Long;
+ use Data::Dumper;
+ use Locale::gettext;
+@@ -269,7 +271,7 @@ sub play_music($) {
+     $app->delay(400);
+     $app->delay(10) while $mixer->playing_music;  #- mikmod will segfault if we try to load a music while old one is still fading out
+     my %musics = (intro => '/snd/introzik.ogg', main1p => '/snd/frozen-mainzik-1p.ogg', main2p => '/snd/frozen-mainzik-2p.xm');
+-    my $mus if 0;                                 #- I need to keep a reference on the music or it will be collected at the end of this function, thus I manually collect previous music
++    state $mus;                                 #- I need to keep a reference on the music or it will be collected at the end of this function, thus I manually collect previous music
+     if (@playlist) {
+ my $tryanother = sub {
+    my $elem = chomp_(shift @playlist);
+@@ -3488,7 +3490,7 @@ sub choose_1p_game_mode() {
+         };
+
+         my $img = $imgbin{'1p_panel'};
+-        my $save if 0;
++        state $save;
+         my $drect = SDL::Rect->new(-width => $img->width, -height => $img->height,
+                                    -x => $MENUPOS{xpos_panel}, '-y' => $MENUPOS{ypos_panel});
+         if ($save) {
+@@ -5573,7 +5575,7 @@ sub menu {
+ 'highscores' => { pos => 8, type => 'run',
+   run => sub { $menu_display_highscores->() } },
+       );
+-    my $current_pos if 0; $current_pos ||= 1;
++    state $current_pos; $current_pos ||= 1;
+     my @menu_invalids;
+     $invalidate_all = sub { push @menu_invalids, $menu_entries{$_}->{pos} foreach keys %menu_entries };
+
+@@ -5724,7 +5726,7 @@ sub menu {
+ }
+
+ if ($graphics_level > 1) {
+-    my $banner_pos if 0;
++    state $banner_pos;
+    $banner_pos ||= 670;
+    foreach my $b (keys %banners) {
+ my $xpos = $banners{$b} - $banner_pos;

Reply | Threaded
Open this post in threaded view
|

Re: [!x86] games/frozen-bubble: perl 5.30 and display issues

George Koehler-2
On Mon, 27 Jan 2020 00:37:46 +0100
Charlene Wendling <[hidden email]> wrote:

> Hi,
>
> To start with, the game is not maintained upstream, and as the server
> has glib2 deprecation warnings, it may not be built in a close future.
> It does not run on x86 due to a BROKEN p5-SDL on these 2 archs, and
> updating p5-SDL does not solve this specific issue.

I thank you for your many fixes for OpenBSD macppc.

MetaCPAN shows an SDL-2.548 from a different author (FROGGS).
FreeBSD and NetBSD both have p5-SDL-2.548.  (I find them by searching
'!cpan SDL', '!freebsd p5-SDL', '!pkgsrc p5-SDL' in DuckDuckGo.)

My macppc machine is busy building devel/llvm, so I can't play
frozen-bubble unless I can unbreak p5-SDL on amd64.  I started trying
to update p5-SDL to 2.548, but the update is not trival.  Our patches
become rejects, or don't find files to patch.  The API changed,
like SDL::App to SDLx::App.

OpenBSD has frozen-bubble 2.20.  NetBSD has 2.2.1beta1; it does
"use new SDL Perl API", says http://www.frozen-bubble.org/downloads/

KTHAKORE publishes Games-FrozenBubble-2.212 on CPAN.
FreeBSD builds 2.213.20170702 from kthakore's GitHub.

--George

Reply | Threaded
Open this post in threaded view
|

unbreak devel/p5-SDL (Re: [!x86] games/frozen-bubble: perl 5.30 and display issues)

George Koehler-2
Cc bentley because of games/vacuum

On Wed, 29 Jan 2020 23:57:34 -0500
George Koehler <[hidden email]> wrote:

> On Mon, 27 Jan 2020 00:37:46 +0100
> Charlene Wendling <[hidden email]> wrote:
>
> > It does not run on x86 due to a BROKEN p5-SDL on these 2 archs, and
> > updating p5-SDL does not solve this specific issue.
>
> MetaCPAN shows an SDL-2.548 from a different author (FROGGS)....

SDL-2.548 is still broken.  I found a problem with boot_SDL() and
reported it: https://github.com/PerlGameDev/SDL/issues/294

Instead of updating to 2.548 (which might be incompatible with our
games), I propose to patch out the bug in 2.1.3.  With this diff, I can
now install devel/p5-SDL and play games/vacuum on amd64.  I also tried
games/frozen-bubble with cwen's fixes, but it needs COMPILER=ports-gcc.
In a moment, I will try to patch frozen-bubble for clang.

This diff for devel/p5-SDL also
 - removes HOMEPAGE; looks like a parked domain.
 - adds c to WANTLIB, because 'make port-lib-depends-check'.
 - removes BROKEN-i386, but I didn't test i386.
   (I would need to setup my i386 virtual machine again.)

'make test' passes on amd64.  I don't try macppc (because my iMac is
busy trying to build devel/llvm), would like to hear from cwen or
someone who has frozen-bubble or vacuum on macppc.

Is this diff for devel/p5-SDL ok to commit?
It is ok gkoehler@ if cwen@ commits it.

--George

Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/p5-SDL/Makefile,v
retrieving revision 1.19
diff -u -p -r1.19 Makefile
--- Makefile 17 Jul 2019 14:49:21 -0000 1.19
+++ Makefile 1 Feb 2020 22:56:27 -0000
@@ -1,23 +1,19 @@
 # $OpenBSD: Makefile,v 1.19 2019/07/17 14:49:21 danj Exp $
 
-BROKEN-amd64 = perl -e 'use SDL' segfaults
-BROKEN-i386 = dependent ports (frozen-bubble, vacuum) fail: loadable library and perl binaries are mismatched (got handshake key 0x2b, needed 0xXXXXXX)
-
 COMMENT = Simple DirectMedia Layer for Perl
-HOMEPAGE = http://sdlperl.org/
 
 MODULES = cpan
 VER = 2.1.3
 DISTNAME = SDL_Perl-${VER}
 PKGNAME = p5-SDL-${VER}
-REVISION = 7
+REVISION = 8
 CATEGORIES = devel graphics
 CPAN_AUTHOR = DGOEHRIG
 
 # GPLv2
 PERMIT_PACKAGE = Yes
 
-WANTLIB += GL GLU SDL jpeg perl png pthread
+WANTLIB += GL GLU SDL c jpeg perl png pthread
 
 RUN_DEPENDS = devel/p5-YAML
 BUILD_DEPENDS = ${RUN_DEPENDS}
Index: patches/patch-Build_PL
===================================================================
RCS file: /cvs/ports/devel/p5-SDL/patches/patch-Build_PL,v
retrieving revision 1.2
diff -u -p -r1.2 patch-Build_PL
--- patches/patch-Build_PL 3 Nov 2013 07:52:02 -0000 1.2
+++ patches/patch-Build_PL 1 Feb 2020 22:56:27 -0000
@@ -1,7 +1,8 @@
 $OpenBSD: patch-Build_PL,v 1.2 2013/11/03 07:52:02 ajacoutot Exp $
---- Build.PL.orig Wed Oct  5 02:25:49 2005
-+++ Build.PL Mon May 25 14:22:30 2009
-@@ -35,7 +36,7 @@ my %subsystems =
+Index: Build.PL
+--- Build.PL.orig
++++ Build.PL
+@@ -35,7 +35,7 @@ my %subsystems =
  SDL => {
  file      => {
  from  => 'src/SDL.xs',
@@ -10,7 +11,7 @@ $OpenBSD: patch-Build_PL,v 1.2 2013/11/0
  },
  libraries => [qw( SDL SDL_image SDL_mixer SDL_net SDL_ttf SDL_gfx
                   png jpeg smpeg )],
-@@ -43,14 +44,14 @@ my %subsystems =
+@@ -43,14 +43,14 @@ my %subsystems =
  OpenGL => {
  file      => {
  from => 'src/OpenGL.xs',
@@ -27,7 +28,7 @@ $OpenBSD: patch-Build_PL,v 1.2 2013/11/0
  },
  libraries => [qw( SDL SDL_image )],
  },
-@@ -123,6 +124,7 @@ my %xs = map { $subsystems{$_}{file}{from} => $subsyst
+@@ -123,6 +123,7 @@ my %xs = map { $subsystems{$_}{file}{from} => $subsyst
      keys %subsystems;
 
  my $build   = SDL::Build->new(
Index: patches/patch-src_SDL_xs
===================================================================
RCS file: /cvs/ports/devel/p5-SDL/patches/patch-src_SDL_xs,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 patch-src_SDL_xs
--- patches/patch-src_SDL_xs 2 Jun 2009 21:57:38 -0000 1.1.1.1
+++ patches/patch-src_SDL_xs 1 Feb 2020 22:56:27 -0000
@@ -1,6 +1,12 @@
 $OpenBSD: patch-src_SDL_xs,v 1.1.1.1 2009/06/02 21:57:38 sthen Exp $
---- src/SDL.xs.orig Wed Oct  5 02:25:49 2005
-+++ src/SDL.xs Thu May 28 14:54:55 2009
+
+Add missing arguments to boot_SDL(); this fixes a crash or failure in
+Perl_xs_handshake() on some arches.  This patch does pass the CV of
+the wrong function, but the handshake accepts it.
+
+Index: src/SDL.xs
+--- src/SDL.xs.orig
++++ src/SDL.xs
 @@ -69,7 +69,7 @@ static int sdl_perl_use_smpeg_audio = 0;
  #define HAVE_TLS_CONTEXT
  #endif
@@ -10,6 +16,22 @@ $OpenBSD: patch-src_SDL_xs,v 1.1.1.1 200
 
  Uint32
  sdl_perl_timer_callback ( Uint32 interval, void* param )
+@@ -189,13 +189,13 @@ sdl_perl_atexit (void)
+ #endif
+ }
+
+-void boot_SDL();
++void boot_SDL(pTHX_ CV *);
+ void boot_SDL__OpenGL();
+
+ XS(boot_SDL_perl)
+ {
+ GET_TLS_CONTEXT
+- boot_SDL();
++ boot_SDL(aTHX_ cv);
+ }
+
+ MODULE = SDL_perl PACKAGE = SDL
 @@ -3911,7 +3911,7 @@ GFXFilledpieColor ( dst, x, y, rad, start, end, color
      Sint16 end;
      Uint32 color;

Reply | Threaded
Open this post in threaded view
|

Re: [!x86] games/frozen-bubble: perl 5.30 and display issues

George Koehler-2
In reply to this post by Charlene Wendling
On Mon, 27 Jan 2020 00:37:46 +0100
Charlene Wendling <[hidden email]> wrote:

> I tried playing it on macppc, but:
>
> - it's broken with Perl 5.30: ...
> - there are graphic issues: the title screen is black. The directional
>   arrow that helps throwing bubbles is invisible. Also libpng complains
>   about some interlaced PNGs, the below diff deinterlace them.

After I fixed devel/p5-SDL on my amd64 desktop, I learned that
games/frozen-bubble is broken with clang.  After I apply cwen's diff,
I must either build frozen-bubble with COMPILER=ports-gcc, or add the
patch (below) for clang.  I don't see graphic problems on amd64; the
title screen and the arrow look good.  --George

--- /dev/null Sat Feb  1 19:37:21 2020
+++ patches/patch-c_stuff_fb_c_stuff_xs Sat Feb  1 19:29:16 2020
@@ -0,0 +1,125 @@
+$OpenBSD$
+
+Fix build with clang: it errors when functions are inside other
+functions.  Rename sqr(int) to prevent conflict with sqr(float).
+
+Index: c_stuff/fb_c_stuff.xs
+--- c_stuff/fb_c_stuff.xs.orig
++++ c_stuff/fb_c_stuff.xs
+@@ -94,17 +94,17 @@ int rand_(double val) { return 1+(int) (val*rand()/(RA
+
+ /* -------------- Double Store ------------------ */
+
++static void copy_line(int l, SDL_Surface * s, SDL_Surface * img) {
++ memcpy(s->pixels + l*img->pitch, img->pixels + l*img->pitch, img->pitch);
++}
++static void copy_column(int c, SDL_Surface * s, SDL_Surface * img) {
++ int bpp = img->format->BytesPerPixel;
++ for (y=0; y<YRES; y++)
++ memcpy(s->pixels + y*img->pitch + c*bpp, img->pixels + y*img->pitch + c*bpp, bpp);
++}
++
+ void store_effect(SDL_Surface * s, SDL_Surface * img)
+ {
+- void copy_line(int l) {
+- memcpy(s->pixels + l*img->pitch, img->pixels + l*img->pitch, img->pitch);
+- }
+- void copy_column(int c) {
+- int bpp = img->format->BytesPerPixel;
+- for (y=0; y<YRES; y++)
+- memcpy(s->pixels + y*img->pitch + c*bpp, img->pixels + y*img->pitch + c*bpp, bpp);
+- }
+-
+ int step = 0;
+ int store_thickness = 15;
+
+@@ -116,8 +116,8 @@ void store_effect(SDL_Surface * s, SDL_Surface * img)
+ for (i=0; i<=YRES/2/store_thickness; i++) {
+ int v = step - i;
+ if (v >= 0 && v < store_thickness) {
+- copy_line(i*store_thickness + v);
+- copy_line(YRES - 1 - (i*store_thickness + v));
++ copy_line(i*store_thickness + v, s, img);
++ copy_line(YRES - 1 - (i*store_thickness + v), s, img);
+ }
+ }
+ step++;
+@@ -133,8 +133,8 @@ void store_effect(SDL_Surface * s, SDL_Surface * img)
+ for (i=0; i<=XRES/2/store_thickness; i++) {
+ int v = step - i;
+ if (v >= 0 && v < store_thickness) {
+- copy_column(i*store_thickness + v);
+- copy_column(XRES - 1 - (i*store_thickness + v));
++ copy_column(i*store_thickness + v, s, img);
++ copy_column(XRES - 1 - (i*store_thickness + v), s, img);
+ }
+ }
+ step++;
+@@ -176,21 +176,22 @@ void bars_effect(SDL_Surface * s, SDL_Surface * img)
+
+ /* -------------- Squares ------------------ */
+
++static const int squares_size = 32;
++
++static int fillrect(int i, int j, SDL_Surface * s, SDL_Surface * img, int bpp) {
++ int c, v;
++ if (i >= XRES/squares_size || j >= YRES/squares_size)
++ return 0;
++ v = i*squares_size*bpp + j*squares_size*img->pitch;
++ for (c=0; c<squares_size; c++)
++ memcpy(s->pixels + v + c*img->pitch, img->pixels + v + c*img->pitch, squares_size*bpp);
++ return 1;
++}
++
+ void squares_effect(SDL_Surface * s, SDL_Surface * img)
+ {
+ int bpp = img->format->BytesPerPixel;
+- const int squares_size = 32;
+
+- int fillrect(int i, int j) {
+- int c, v;
+- if (i >= XRES/squares_size || j >= YRES/squares_size)
+- return 0;
+- v = i*squares_size*bpp + j*squares_size*img->pitch;
+- for (c=0; c<squares_size; c++)
+- memcpy(s->pixels + v + c*img->pitch, img->pixels + v + c*img->pitch, squares_size*bpp);
+- return 1;
+- }
+-
+ int still_moving = 1;
+
+ for (i=0; still_moving; i++) {
+@@ -200,7 +201,7 @@ void squares_effect(SDL_Surface * s, SDL_Surface * img
+
+ still_moving = 0;
+ for (j=i; j>=0; j--) {
+- if (fillrect(j, k))
++ if (fillrect(j, k, s, img, bpp))
+ still_moving = 1;
+ k++;
+ }
+@@ -212,20 +213,20 @@ void squares_effect(SDL_Surface * s, SDL_Surface * img
+
+ /* -------------- Circle ------------------ */
+
++static int sqi(int v) { return v*v; }
++
+ int * circle_steps;
+ const int circle_max_steps = 40;
+ void circle_init(void)
+ {
+- int sqr(int v) { return v*v; }
+-
+ circle_steps = malloc(XRES * YRES * sizeof(int));
+ if (!circle_steps)
+ fb__out_of_memory();
+
+ for (y=0; y<YRES; y++)
+ for (x=0; x<XRES; x++) {
+- int max = sqrt(sqr(XRES/2) + sqr(YRES/2));
+- int value = sqrt(sqr(x-XRES/2) + sqr(y-YRES/2));
++ int max = sqrt(sqi(XRES/2) + sqi(YRES/2));
++ int value = sqrt(sqi(x-XRES/2) + sqi(y-YRES/2));
+ circle_steps[x+y*XRES] = (max-value)*circle_max_steps/max;
+ }
+ }

Reply | Threaded
Open this post in threaded view
|

Re: unbreak devel/p5-SDL (Re: [!x86] games/frozen-bubble: perl 5.30 and display issues)

Charlene Wendling
In reply to this post by George Koehler-2
On Sat, 1 Feb 2020 19:00:41 -0500
George Koehler wrote:

> Cc bentley because of games/vacuum
>
> On Wed, 29 Jan 2020 23:57:34 -0500
> George Koehler <[hidden email]> wrote:
>
> > On Mon, 27 Jan 2020 00:37:46 +0100
> > Charlene Wendling <[hidden email]> wrote:
> >
> > > It does not run on x86 due to a BROKEN p5-SDL on these 2 archs,
> > > and updating p5-SDL does not solve this specific issue.
> >
> > MetaCPAN shows an SDL-2.548 from a different author (FROGGS)....
>
> SDL-2.548 is still broken.  I found a problem with boot_SDL() and
> reported it: https://github.com/PerlGameDev/SDL/issues/294
>
> Instead of updating to 2.548 (which might be incompatible with our
> games), I propose to patch out the bug in 2.1.3.  With this diff, I
> can now install devel/p5-SDL and play games/vacuum on amd64.  I also
> tried games/frozen-bubble with cwen's fixes, but it needs
> COMPILER=ports-gcc. In a moment, I will try to patch frozen-bubble
> for clang.

About updating -- for frozen-bubble we may have a chance with kthakore's
"fork", but for vacuum HOMEPAGE is dead, so it may be more complicated.

> This diff for devel/p5-SDL also
>  - removes HOMEPAGE; looks like a parked domain.
>  - adds c to WANTLIB, because 'make port-lib-depends-check'.
>  - removes BROKEN-i386, but I didn't test i386.
>    (I would need to setup my i386 virtual machine again.)
>
> 'make test' passes on amd64.  I don't try macppc (because my iMac is
> busy trying to build devel/llvm), would like to hear from cwen or
> someone who has frozen-bubble or vacuum on macppc.
>
> Is this diff for devel/p5-SDL ok to commit?

It works fine on amd64 and powerpc (with no extra regression with
frozen-bubble/powerpc)

> It is ok gkoehler@ if cwen@ commits it.

It's your diff so you should commit it :) It's OK cwen@, but you
should wait for more feedback on other archs.

> --George
>
> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/devel/p5-SDL/Makefile,v
> retrieving revision 1.19
> diff -u -p -r1.19 Makefile
> --- Makefile 17 Jul 2019 14:49:21 -0000 1.19
> +++ Makefile 1 Feb 2020 22:56:27 -0000
> @@ -1,23 +1,19 @@
>  # $OpenBSD: Makefile,v 1.19 2019/07/17 14:49:21 danj Exp $
>  
> -BROKEN-amd64 = perl -e 'use SDL' segfaults
> -BROKEN-i386 = dependent ports (frozen-bubble, vacuum)
> fail: loadable library and perl binaries are mismatched (got
> handshake key 0x2b, needed 0xXXXXXX) - COMMENT =
> Simple DirectMedia Layer for Perl -HOMEPAGE =
> http://sdlperl.org/ 
>  MODULES = cpan
>  VER = 2.1.3
>  DISTNAME = SDL_Perl-${VER}
>  PKGNAME = p5-SDL-${VER}
> -REVISION = 7
> +REVISION = 8
>  CATEGORIES = devel graphics
>  CPAN_AUTHOR = DGOEHRIG
>  
>  # GPLv2
>  PERMIT_PACKAGE = Yes
>  
> -WANTLIB += GL GLU SDL jpeg perl png pthread
> +WANTLIB += GL GLU SDL c jpeg perl png pthread
>  
>  RUN_DEPENDS = devel/p5-YAML
>  BUILD_DEPENDS = ${RUN_DEPENDS}
> Index: patches/patch-Build_PL
> ===================================================================
> RCS file: /cvs/ports/devel/p5-SDL/patches/patch-Build_PL,v
> retrieving revision 1.2
> diff -u -p -r1.2 patch-Build_PL
> --- patches/patch-Build_PL 3 Nov 2013 07:52:02 -0000 1.2
> +++ patches/patch-Build_PL 1 Feb 2020 22:56:27 -0000
> @@ -1,7 +1,8 @@
>  $OpenBSD: patch-Build_PL,v 1.2 2013/11/03 07:52:02 ajacoutot Exp $
> ---- Build.PL.orig Wed Oct  5 02:25:49 2005
> -+++ Build.PL Mon May 25 14:22:30 2009
> -@@ -35,7 +36,7 @@ my %subsystems =
> +Index: Build.PL
> +--- Build.PL.orig
> ++++ Build.PL
> +@@ -35,7 +35,7 @@ my %subsystems =
>   SDL => {
>   file      => {
>   from  => 'src/SDL.xs',
> @@ -10,7 +11,7 @@ $OpenBSD: patch-Build_PL,v 1.2 2013/11/0
>   },
>   libraries => [qw( SDL SDL_image SDL_mixer SDL_net
> SDL_ttf SDL_gfx png jpeg smpeg )],
> -@@ -43,14 +44,14 @@ my %subsystems =
> +@@ -43,14 +43,14 @@ my %subsystems =
>   OpenGL => {
>   file      => {
>   from => 'src/OpenGL.xs',
> @@ -27,7 +28,7 @@ $OpenBSD: patch-Build_PL,v 1.2 2013/11/0
>   },
>   libraries => [qw( SDL SDL_image )],
>   },
> -@@ -123,6 +124,7 @@ my %xs = map { $subsystems{$_}{file}{from} =>
> $subsyst +@@ -123,6 +123,7 @@ my %xs = map { $subsystems{$_}{file}
> {from} => $subsyst keys %subsystems;
>  
>   my $build   = SDL::Build->new(
> Index: patches/patch-src_SDL_xs
> ===================================================================
> RCS file: /cvs/ports/devel/p5-SDL/patches/patch-src_SDL_xs,v
> retrieving revision 1.1.1.1
> diff -u -p -r1.1.1.1 patch-src_SDL_xs
> --- patches/patch-src_SDL_xs 2 Jun 2009 21:57:38 -0000
> 1.1.1.1 +++ patches/patch-src_SDL_xs 1 Feb 2020 22:56:27 -0000
> @@ -1,6 +1,12 @@
>  $OpenBSD: patch-src_SDL_xs,v 1.1.1.1 2009/06/02 21:57:38 sthen Exp $
> ---- src/SDL.xs.orig Wed Oct  5 02:25:49 2005
> -+++ src/SDL.xs Thu May 28 14:54:55 2009
> +
> +Add missing arguments to boot_SDL(); this fixes a crash or failure in
> +Perl_xs_handshake() on some arches.  This patch does pass the CV of
> +the wrong function, but the handshake accepts it.
> +
> +Index: src/SDL.xs
> +--- src/SDL.xs.orig
> ++++ src/SDL.xs
>  @@ -69,7 +69,7 @@ static int sdl_perl_use_smpeg_audio = 0;
>   #define HAVE_TLS_CONTEXT
>   #endif
> @@ -10,6 +16,22 @@ $OpenBSD: patch-src_SDL_xs,v 1.1.1.1 200
>  
>   Uint32
>   sdl_perl_timer_callback ( Uint32 interval, void* param )
> +@@ -189,13 +189,13 @@ sdl_perl_atexit (void)
> + #endif
> + }
> +
> +-void boot_SDL();
> ++void boot_SDL(pTHX_ CV *);
> + void boot_SDL__OpenGL();
> +
> + XS(boot_SDL_perl)
> + {
> + GET_TLS_CONTEXT
> +- boot_SDL();
> ++ boot_SDL(aTHX_ cv);
> + }
> +
> + MODULE = SDL_perl PACKAGE = SDL
>  @@ -3911,7 +3911,7 @@ GFXFilledpieColor ( dst, x, y, rad, start,
> end, color Sint16 end;
>       Uint32 color;
>

Reply | Threaded
Open this post in threaded view
|

Unbreak games/frozen-bubble (Was: Re: [!x86] games/frozen-bubble: perl 5.30 and display issues)

Charlene Wendling
In reply to this post by George Koehler-2
On Sat, 1 Feb 2020 19:40:27 -0500
George Koehler wrote:

> On Mon, 27 Jan 2020 00:37:46 +0100
> Charlene Wendling <[hidden email]> wrote:
>
> > I tried playing it on macppc, but:
> >
> > - it's broken with Perl 5.30: ...
> > - there are graphic issues: the title screen is black. The
> > directional arrow that helps throwing bubbles is invisible. Also
> > libpng complains about some interlaced PNGs, the below diff
> > deinterlace them.
>
> After I fixed devel/p5-SDL on my amd64 desktop, I learned that
> games/frozen-bubble is broken with clang.  After I apply cwen's diff,
> I must either build frozen-bubble with COMPILER=ports-gcc, or add the
> patch (below) for clang.  I don't see graphic problems on amd64; the
> title screen and the arrow look good.  --George

It works fine on amd64, has no further regressions on powerpc, and
i'm fine with your clang fix. Obviously, powerpc issues should not
hinder the x86 fix, and i've no objection to see that diff committed
after devel/p5-SDL is committed.

For everyone's convenience, here is a diff with the Perl 5.30 fixes
and the clang one combined.

Charlène.


Index: Makefile
===================================================================
RCS file: /cvs/ports/games/frozen-bubble/Makefile,v
retrieving revision 1.28
diff -u -p -u -p -r1.28 Makefile
--- Makefile 17 Jul 2019 14:49:22 -0000 1.28
+++ Makefile 2 Feb 2020 14:05:17 -0000
@@ -6,7 +6,7 @@ COMMENT-server = server for the frozen-b
 VER = 2.2.0
 DISTNAME = frozen-bubble-${VER}
 PKGNAME-main = ${DISTNAME}
-REVISION-main = 14
+REVISION-main = 15
 PKGNAME-server = frozen-bubble-server-${VER}
 REVISION-server = 10
 CATEGORIES = games
@@ -29,6 +29,9 @@ BUILD_DEPENDS = devel/p5-SDL \
  devel/p5-Locale-gettext \
  devel/gettext,-tools
 
+# Needed for post-patch deinterlacing
+BUILD_DEPENDS += graphics/ImageMagick
+
 RUN_DEPENDS-main = devel/p5-SDL \
  devel/p5-Locale-gettext \
  ${BASE_PKGPATH},-server
@@ -46,5 +49,14 @@ WANTLIB-main = SDL SDL_Pango SDL_mixer
 WANTLIB-server = c glib-2.0 intl pthread
 
 MULTI_PACKAGES = -main -server
+
+# fix "Interlace handling should be turned on when using png_read_image"
+post-patch:
+ @cd ${WRKSRC} && for interlaced in gfx/flags/flag-de.png \
+ gfx/flags/flag-fi.png \
+ gfx/flags/flag-no.png; \
+ do \
+ ${LOCALBASE}/bin/mogrify -interlace none $${interlaced} ;\
+ done
 
 .include <bsd.port.mk>
Index: patches/patch-c_stuff_fb_c_stuff_xs
===================================================================
RCS file: patches/patch-c_stuff_fb_c_stuff_xs
diff -N patches/patch-c_stuff_fb_c_stuff_xs
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-c_stuff_fb_c_stuff_xs 2 Feb 2020 14:05:17 -0000
@@ -0,0 +1,125 @@
+$OpenBSD$
+
+Fix build with clang: it errors when functions are inside other
+functions.  Rename sqr(int) to prevent conflict with sqr(float).
+
+Index: c_stuff/fb_c_stuff.xs
+--- c_stuff/fb_c_stuff.xs.orig
++++ c_stuff/fb_c_stuff.xs
+@@ -94,17 +94,17 @@ int rand_(double val) { return 1+(int) (val*rand()/(RA
+
+ /* -------------- Double Store ------------------ */
+
++static void copy_line(int l, SDL_Surface * s, SDL_Surface * img) {
++ memcpy(s->pixels + l*img->pitch, img->pixels + l*img->pitch, img->pitch);
++}
++static void copy_column(int c, SDL_Surface * s, SDL_Surface * img) {
++ int bpp = img->format->BytesPerPixel;
++ for (y=0; y<YRES; y++)
++ memcpy(s->pixels + y*img->pitch + c*bpp, img->pixels + y*img->pitch + c*bpp, bpp);
++}
++
+ void store_effect(SDL_Surface * s, SDL_Surface * img)
+ {
+- void copy_line(int l) {
+- memcpy(s->pixels + l*img->pitch, img->pixels + l*img->pitch, img->pitch);
+- }
+- void copy_column(int c) {
+- int bpp = img->format->BytesPerPixel;
+- for (y=0; y<YRES; y++)
+- memcpy(s->pixels + y*img->pitch + c*bpp, img->pixels + y*img->pitch + c*bpp, bpp);
+- }
+-
+ int step = 0;
+ int store_thickness = 15;
+
+@@ -116,8 +116,8 @@ void store_effect(SDL_Surface * s, SDL_Surface * img)
+ for (i=0; i<=YRES/2/store_thickness; i++) {
+ int v = step - i;
+ if (v >= 0 && v < store_thickness) {
+- copy_line(i*store_thickness + v);
+- copy_line(YRES - 1 - (i*store_thickness + v));
++ copy_line(i*store_thickness + v, s, img);
++ copy_line(YRES - 1 - (i*store_thickness + v), s, img);
+ }
+ }
+ step++;
+@@ -133,8 +133,8 @@ void store_effect(SDL_Surface * s, SDL_Surface * img)
+ for (i=0; i<=XRES/2/store_thickness; i++) {
+ int v = step - i;
+ if (v >= 0 && v < store_thickness) {
+- copy_column(i*store_thickness + v);
+- copy_column(XRES - 1 - (i*store_thickness + v));
++ copy_column(i*store_thickness + v, s, img);
++ copy_column(XRES - 1 - (i*store_thickness + v), s, img);
+ }
+ }
+ step++;
+@@ -176,21 +176,22 @@ void bars_effect(SDL_Surface * s, SDL_Surface * img)
+
+ /* -------------- Squares ------------------ */
+
++static const int squares_size = 32;
++
++static int fillrect(int i, int j, SDL_Surface * s, SDL_Surface * img, int bpp) {
++ int c, v;
++ if (i >= XRES/squares_size || j >= YRES/squares_size)
++ return 0;
++ v = i*squares_size*bpp + j*squares_size*img->pitch;
++ for (c=0; c<squares_size; c++)
++ memcpy(s->pixels + v + c*img->pitch, img->pixels + v + c*img->pitch, squares_size*bpp);
++ return 1;
++}
++
+ void squares_effect(SDL_Surface * s, SDL_Surface * img)
+ {
+ int bpp = img->format->BytesPerPixel;
+- const int squares_size = 32;
+
+- int fillrect(int i, int j) {
+- int c, v;
+- if (i >= XRES/squares_size || j >= YRES/squares_size)
+- return 0;
+- v = i*squares_size*bpp + j*squares_size*img->pitch;
+- for (c=0; c<squares_size; c++)
+- memcpy(s->pixels + v + c*img->pitch, img->pixels + v + c*img->pitch, squares_size*bpp);
+- return 1;
+- }
+-
+ int still_moving = 1;
+
+ for (i=0; still_moving; i++) {
+@@ -200,7 +201,7 @@ void squares_effect(SDL_Surface * s, SDL_Surface * img
+
+ still_moving = 0;
+ for (j=i; j>=0; j--) {
+- if (fillrect(j, k))
++ if (fillrect(j, k, s, img, bpp))
+ still_moving = 1;
+ k++;
+ }
+@@ -212,20 +213,20 @@ void squares_effect(SDL_Surface * s, SDL_Surface * img
+
+ /* -------------- Circle ------------------ */
+
++static int sqi(int v) { return v*v; }
++
+ int * circle_steps;
+ const int circle_max_steps = 40;
+ void circle_init(void)
+ {
+- int sqr(int v) { return v*v; }
+-
+ circle_steps = malloc(XRES * YRES * sizeof(int));
+ if (!circle_steps)
+ fb__out_of_memory();
+
+ for (y=0; y<YRES; y++)
+ for (x=0; x<XRES; x++) {
+- int max = sqrt(sqr(XRES/2) + sqr(YRES/2));
+- int value = sqrt(sqr(x-XRES/2) + sqr(y-YRES/2));
++ int max = sqrt(sqi(XRES/2) + sqi(YRES/2));
++ int value = sqrt(sqi(x-XRES/2) + sqi(y-YRES/2));
+ circle_steps[x+y*XRES] = (max-value)*circle_max_steps/max;
+ }
+ }
Index: patches/patch-c_stuff_lib_FBLE_pm
===================================================================
RCS file: patches/patch-c_stuff_lib_FBLE_pm
diff -N patches/patch-c_stuff_lib_FBLE_pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-c_stuff_lib_FBLE_pm 2 Feb 2020 14:05:17 -0000
@@ -0,0 +1,34 @@
+$OpenBSD$
+
+Perl 5.30+ prohibits using my() in false conditionals
+
+Index: c_stuff/lib/FBLE.pm
+--- c_stuff/lib/FBLE.pm.orig
++++ c_stuff/lib/FBLE.pm
+@@ -31,6 +31,8 @@
+
+ package FBLE;
+
++use feature qw(state);
++
+ use POSIX(qw(floor ceil));
+ use SDL;
+ use SDL::App;
+@@ -1405,7 +1407,7 @@ sub display_levelset_screenshot {
+                    $rect{middle}->y + $rect{middle}->height/2 - $rect{screenshot}->height/8 - 3 + $widgetMove);
+
+
+-    my %shrinks if 0;
++    state %shrinks;
+     my $current_nb = $start_level || 1;
+     if (!exists $shrinks{$name}{$current_nb}) {
+         my $surf = SDL::Surface->new(-name => "$FPATH/gfx/menu/please_wait.png");
+@@ -1417,7 +1419,7 @@ sub display_levelset_screenshot {
+         $app->update($rect{middle});
+
+         #- sorta "read ahead": will compute next 10 levels screenshots as well
+-        my $s_save if 0;
++        state $s_save;
+         if (!$s_save) {
+             $s_save = SDL::Surface->new(-name => "$FPATH/gfx/level_editor.png");
+         }
Index: patches/patch-frozen-bubble
===================================================================
RCS file: patches/patch-frozen-bubble
diff -N patches/patch-frozen-bubble
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-frozen-bubble 2 Feb 2020 14:05:17 -0000
@@ -0,0 +1,52 @@
+$OpenBSD$
+
+Perl 5.30+ prohibits using my() in false conditionals
+
+Index: frozen-bubble
+--- frozen-bubble.orig
++++ frozen-bubble
+@@ -47,6 +47,8 @@ use vars qw($TARGET_ANIM_SPEED $BUBBLE_SIZE $ROW_SIZE
+             $lev_number $playermalus $mptrainingdiff $loaded_levelset $direct_levelset $chainreaction %chains %img_mini $frame $sock $gameserver $mynick
+             $continuegamewhenplayersleave $singleplayertargetting $mylatitude $mylongitude %autokick $replayparam $autorecord $comment $saveframes $saveframesbase $saveframescounter);
+
++use feature qw(state);
++
+ use Getopt::Long;
+ use Data::Dumper;
+ use Locale::gettext;
+@@ -269,7 +271,7 @@ sub play_music($) {
+     $app->delay(400);
+     $app->delay(10) while $mixer->playing_music;  #- mikmod will segfault if we try to load a music while old one is still fading out
+     my %musics = (intro => '/snd/introzik.ogg', main1p => '/snd/frozen-mainzik-1p.ogg', main2p => '/snd/frozen-mainzik-2p.xm');
+-    my $mus if 0;                                 #- I need to keep a reference on the music or it will be collected at the end of this function, thus I manually collect previous music
++    state $mus;                                 #- I need to keep a reference on the music or it will be collected at the end of this function, thus I manually collect previous music
+     if (@playlist) {
+ my $tryanother = sub {
+    my $elem = chomp_(shift @playlist);
+@@ -3488,7 +3490,7 @@ sub choose_1p_game_mode() {
+         };
+
+         my $img = $imgbin{'1p_panel'};
+-        my $save if 0;
++        state $save;
+         my $drect = SDL::Rect->new(-width => $img->width, -height => $img->height,
+                                    -x => $MENUPOS{xpos_panel}, '-y' => $MENUPOS{ypos_panel});
+         if ($save) {
+@@ -5573,7 +5575,7 @@ sub menu {
+ 'highscores' => { pos => 8, type => 'run',
+   run => sub { $menu_display_highscores->() } },
+       );
+-    my $current_pos if 0; $current_pos ||= 1;
++    state $current_pos; $current_pos ||= 1;
+     my @menu_invalids;
+     $invalidate_all = sub { push @menu_invalids, $menu_entries{$_}->{pos} foreach keys %menu_entries };
+
+@@ -5724,7 +5726,7 @@ sub menu {
+ }
+
+ if ($graphics_level > 1) {
+-    my $banner_pos if 0;
++    state $banner_pos;
+    $banner_pos ||= 670;
+    foreach my $b (keys %banners) {
+ my $xpos = $banners{$b} - $banner_pos;







Reply | Threaded
Open this post in threaded view
|

Re: Unbreak games/frozen-bubble (Was: Re: [!x86] games/frozen-bubble: perl 5.30 and display issues)

George Koehler-2
On Sun, 2 Feb 2020 15:12:29 +0100
Charlene Wendling <[hidden email]> wrote:

> It works fine on amd64, has no further regressions on powerpc, and
> i'm fine with your clang fix. Obviously, powerpc issues should not
> hinder the x86 fix, and i've no objection to see that diff committed
> after devel/p5-SDL is committed.
>
> For everyone's convenience, here is a diff with the Perl 5.30 fixes
> and the clang one combined.

The combined diff is ok gkoehler@

I have no opinion about whether your games/frozen-bubble commit will
happen before or after my devel/p5-SDL commit.  --George

>
> Charlène.
>
>
> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/games/frozen-bubble/Makefile,v
> retrieving revision 1.28
> diff -u -p -u -p -r1.28 Makefile
> --- Makefile 17 Jul 2019 14:49:22 -0000 1.28
> +++ Makefile 2 Feb 2020 14:05:17 -0000
> @@ -6,7 +6,7 @@ COMMENT-server = server for the frozen-b
>  VER = 2.2.0
>  DISTNAME = frozen-bubble-${VER}
>  PKGNAME-main = ${DISTNAME}
> -REVISION-main = 14
> +REVISION-main = 15
>  PKGNAME-server = frozen-bubble-server-${VER}
>  REVISION-server = 10
>  CATEGORIES = games
> @@ -29,6 +29,9 @@ BUILD_DEPENDS = devel/p5-SDL \
>   devel/p5-Locale-gettext \
>   devel/gettext,-tools
>  
> +# Needed for post-patch deinterlacing
> +BUILD_DEPENDS += graphics/ImageMagick
> +
>  RUN_DEPENDS-main = devel/p5-SDL \
>   devel/p5-Locale-gettext \
>   ${BASE_PKGPATH},-server
> @@ -46,5 +49,14 @@ WANTLIB-main = SDL SDL_Pango SDL_mixer
>  WANTLIB-server = c glib-2.0 intl pthread
>  
>  MULTI_PACKAGES = -main -server
> +
> +# fix "Interlace handling should be turned on when using png_read_image"
> +post-patch:
> + @cd ${WRKSRC} && for interlaced in gfx/flags/flag-de.png \
> + gfx/flags/flag-fi.png \
> + gfx/flags/flag-no.png; \
> + do \
> + ${LOCALBASE}/bin/mogrify -interlace none $${interlaced} ;\
> + done
>  
>  .include <bsd.port.mk>
> Index: patches/patch-c_stuff_fb_c_stuff_xs
> ===================================================================
> RCS file: patches/patch-c_stuff_fb_c_stuff_xs
> diff -N patches/patch-c_stuff_fb_c_stuff_xs
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-c_stuff_fb_c_stuff_xs 2 Feb 2020 14:05:17 -0000
> @@ -0,0 +1,125 @@
> +$OpenBSD$
> +
> +Fix build with clang: it errors when functions are inside other
> +functions.  Rename sqr(int) to prevent conflict with sqr(float).
> +
> +Index: c_stuff/fb_c_stuff.xs
> +--- c_stuff/fb_c_stuff.xs.orig
> ++++ c_stuff/fb_c_stuff.xs
> +@@ -94,17 +94,17 @@ int rand_(double val) { return 1+(int) (val*rand()/(RA
> +
> + /* -------------- Double Store ------------------ */
> +
> ++static void copy_line(int l, SDL_Surface * s, SDL_Surface * img) {
> ++ memcpy(s->pixels + l*img->pitch, img->pixels + l*img->pitch, img->pitch);
> ++}
> ++static void copy_column(int c, SDL_Surface * s, SDL_Surface * img) {
> ++ int bpp = img->format->BytesPerPixel;
> ++ for (y=0; y<YRES; y++)
> ++ memcpy(s->pixels + y*img->pitch + c*bpp, img->pixels + y*img->pitch + c*bpp, bpp);
> ++}
> ++
> + void store_effect(SDL_Surface * s, SDL_Surface * img)
> + {
> +- void copy_line(int l) {
> +- memcpy(s->pixels + l*img->pitch, img->pixels + l*img->pitch, img->pitch);
> +- }
> +- void copy_column(int c) {
> +- int bpp = img->format->BytesPerPixel;
> +- for (y=0; y<YRES; y++)
> +- memcpy(s->pixels + y*img->pitch + c*bpp, img->pixels + y*img->pitch + c*bpp, bpp);
> +- }
> +-
> + int step = 0;
> + int store_thickness = 15;
> +
> +@@ -116,8 +116,8 @@ void store_effect(SDL_Surface * s, SDL_Surface * img)
> + for (i=0; i<=YRES/2/store_thickness; i++) {
> + int v = step - i;
> + if (v >= 0 && v < store_thickness) {
> +- copy_line(i*store_thickness + v);
> +- copy_line(YRES - 1 - (i*store_thickness + v));
> ++ copy_line(i*store_thickness + v, s, img);
> ++ copy_line(YRES - 1 - (i*store_thickness + v), s, img);
> + }
> + }
> + step++;
> +@@ -133,8 +133,8 @@ void store_effect(SDL_Surface * s, SDL_Surface * img)
> + for (i=0; i<=XRES/2/store_thickness; i++) {
> + int v = step - i;
> + if (v >= 0 && v < store_thickness) {
> +- copy_column(i*store_thickness + v);
> +- copy_column(XRES - 1 - (i*store_thickness + v));
> ++ copy_column(i*store_thickness + v, s, img);
> ++ copy_column(XRES - 1 - (i*store_thickness + v), s, img);
> + }
> + }
> + step++;
> +@@ -176,21 +176,22 @@ void bars_effect(SDL_Surface * s, SDL_Surface * img)
> +
> + /* -------------- Squares ------------------ */
> +
> ++static const int squares_size = 32;
> ++
> ++static int fillrect(int i, int j, SDL_Surface * s, SDL_Surface * img, int bpp) {
> ++ int c, v;
> ++ if (i >= XRES/squares_size || j >= YRES/squares_size)
> ++ return 0;
> ++ v = i*squares_size*bpp + j*squares_size*img->pitch;
> ++ for (c=0; c<squares_size; c++)
> ++ memcpy(s->pixels + v + c*img->pitch, img->pixels + v + c*img->pitch, squares_size*bpp);
> ++ return 1;
> ++}
> ++
> + void squares_effect(SDL_Surface * s, SDL_Surface * img)
> + {
> + int bpp = img->format->BytesPerPixel;
> +- const int squares_size = 32;
> +
> +- int fillrect(int i, int j) {
> +- int c, v;
> +- if (i >= XRES/squares_size || j >= YRES/squares_size)
> +- return 0;
> +- v = i*squares_size*bpp + j*squares_size*img->pitch;
> +- for (c=0; c<squares_size; c++)
> +- memcpy(s->pixels + v + c*img->pitch, img->pixels + v + c*img->pitch, squares_size*bpp);
> +- return 1;
> +- }
> +-
> + int still_moving = 1;
> +
> + for (i=0; still_moving; i++) {
> +@@ -200,7 +201,7 @@ void squares_effect(SDL_Surface * s, SDL_Surface * img
> +
> + still_moving = 0;
> + for (j=i; j>=0; j--) {
> +- if (fillrect(j, k))
> ++ if (fillrect(j, k, s, img, bpp))
> + still_moving = 1;
> + k++;
> + }
> +@@ -212,20 +213,20 @@ void squares_effect(SDL_Surface * s, SDL_Surface * img
> +
> + /* -------------- Circle ------------------ */
> +
> ++static int sqi(int v) { return v*v; }
> ++
> + int * circle_steps;
> + const int circle_max_steps = 40;
> + void circle_init(void)
> + {
> +- int sqr(int v) { return v*v; }
> +-
> + circle_steps = malloc(XRES * YRES * sizeof(int));
> + if (!circle_steps)
> + fb__out_of_memory();
> +
> + for (y=0; y<YRES; y++)
> + for (x=0; x<XRES; x++) {
> +- int max = sqrt(sqr(XRES/2) + sqr(YRES/2));
> +- int value = sqrt(sqr(x-XRES/2) + sqr(y-YRES/2));
> ++ int max = sqrt(sqi(XRES/2) + sqi(YRES/2));
> ++ int value = sqrt(sqi(x-XRES/2) + sqi(y-YRES/2));
> + circle_steps[x+y*XRES] = (max-value)*circle_max_steps/max;
> + }
> + }
> Index: patches/patch-c_stuff_lib_FBLE_pm
> ===================================================================
> RCS file: patches/patch-c_stuff_lib_FBLE_pm
> diff -N patches/patch-c_stuff_lib_FBLE_pm
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-c_stuff_lib_FBLE_pm 2 Feb 2020 14:05:17 -0000
> @@ -0,0 +1,34 @@
> +$OpenBSD$
> +
> +Perl 5.30+ prohibits using my() in false conditionals
> +
> +Index: c_stuff/lib/FBLE.pm
> +--- c_stuff/lib/FBLE.pm.orig
> ++++ c_stuff/lib/FBLE.pm
> +@@ -31,6 +31,8 @@
> +
> + package FBLE;
> +
> ++use feature qw(state);
> ++
> + use POSIX(qw(floor ceil));
> + use SDL;
> + use SDL::App;
> +@@ -1405,7 +1407,7 @@ sub display_levelset_screenshot {
> +                    $rect{middle}->y + $rect{middle}->height/2 - $rect{screenshot}->height/8 - 3 + $widgetMove);
> +
> +
> +-    my %shrinks if 0;
> ++    state %shrinks;
> +     my $current_nb = $start_level || 1;
> +     if (!exists $shrinks{$name}{$current_nb}) {
> +         my $surf = SDL::Surface->new(-name => "$FPATH/gfx/menu/please_wait.png");
> +@@ -1417,7 +1419,7 @@ sub display_levelset_screenshot {
> +         $app->update($rect{middle});
> +
> +         #- sorta "read ahead": will compute next 10 levels screenshots as well
> +-        my $s_save if 0;
> ++        state $s_save;
> +         if (!$s_save) {
> +             $s_save = SDL::Surface->new(-name => "$FPATH/gfx/level_editor.png");
> +         }
> Index: patches/patch-frozen-bubble
> ===================================================================
> RCS file: patches/patch-frozen-bubble
> diff -N patches/patch-frozen-bubble
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-frozen-bubble 2 Feb 2020 14:05:17 -0000
> @@ -0,0 +1,52 @@
> +$OpenBSD$
> +
> +Perl 5.30+ prohibits using my() in false conditionals
> +
> +Index: frozen-bubble
> +--- frozen-bubble.orig
> ++++ frozen-bubble
> +@@ -47,6 +47,8 @@ use vars qw($TARGET_ANIM_SPEED $BUBBLE_SIZE $ROW_SIZE
> +             $lev_number $playermalus $mptrainingdiff $loaded_levelset $direct_levelset $chainreaction %chains %img_mini $frame $sock $gameserver $mynick
> +             $continuegamewhenplayersleave $singleplayertargetting $mylatitude $mylongitude %autokick $replayparam $autorecord $comment $saveframes $saveframesbase $saveframescounter);
> +
> ++use feature qw(state);
> ++
> + use Getopt::Long;
> + use Data::Dumper;
> + use Locale::gettext;
> +@@ -269,7 +271,7 @@ sub play_music($) {
> +     $app->delay(400);
> +     $app->delay(10) while $mixer->playing_music;  #- mikmod will segfault if we try to load a music while old one is still fading out
> +     my %musics = (intro => '/snd/introzik.ogg', main1p => '/snd/frozen-mainzik-1p.ogg', main2p => '/snd/frozen-mainzik-2p.xm');
> +-    my $mus if 0;                                 #- I need to keep a reference on the music or it will be collected at the end of this function, thus I manually collect previous music
> ++    state $mus;                                 #- I need to keep a reference on the music or it will be collected at the end of this function, thus I manually collect previous music
> +     if (@playlist) {
> + my $tryanother = sub {
> +    my $elem = chomp_(shift @playlist);
> +@@ -3488,7 +3490,7 @@ sub choose_1p_game_mode() {
> +         };
> +
> +         my $img = $imgbin{'1p_panel'};
> +-        my $save if 0;
> ++        state $save;
> +         my $drect = SDL::Rect->new(-width => $img->width, -height => $img->height,
> +                                    -x => $MENUPOS{xpos_panel}, '-y' => $MENUPOS{ypos_panel});
> +         if ($save) {
> +@@ -5573,7 +5575,7 @@ sub menu {
> + 'highscores' => { pos => 8, type => 'run',
> +   run => sub { $menu_display_highscores->() } },
> +       );
> +-    my $current_pos if 0; $current_pos ||= 1;
> ++    state $current_pos; $current_pos ||= 1;
> +     my @menu_invalids;
> +     $invalidate_all = sub { push @menu_invalids, $menu_entries{$_}->{pos} foreach keys %menu_entries };
> +
> +@@ -5724,7 +5726,7 @@ sub menu {
> + }
> +
> + if ($graphics_level > 1) {
> +-    my $banner_pos if 0;
> ++    state $banner_pos;
> +    $banner_pos ||= 670;
> +    foreach my $b (keys %banners) {
> + my $xpos = $banners{$b} - $banner_pos;
>
>
>
>
>
>
>


--
George Koehler <[hidden email]>

Reply | Threaded
Open this post in threaded view
|

Re: Unbreak games/frozen-bubble (Was: Re: [!x86] games/frozen-bubble: perl 5.30 and display issues)

Andrew Hewus Fresh
On Sun, Feb 02, 2020 at 03:48:22PM -0500, George Koehler wrote:

> On Sun, 2 Feb 2020 15:12:29 +0100
> Charlene Wendling <[hidden email]> wrote:
>
> > It works fine on amd64, has no further regressions on powerpc, and
> > i'm fine with your clang fix. Obviously, powerpc issues should not
> > hinder the x86 fix, and i've no objection to see that diff committed
> > after devel/p5-SDL is committed.
> >
> > For everyone's convenience, here is a diff with the Perl 5.30 fixes
> > and the clang one combined.
>
> The combined diff is ok gkoehler@

OK afresh1@ on both p5-SDL and this frozen-bubble change.  It works much
better (at all) on my i386 and amd64 and apparently not any worse on
macppc.



> I have no opinion about whether your games/frozen-bubble commit will
> happen before or after my devel/p5-SDL commit.  --George
>
> >
> > Charlène.
> >
> >
> > Index: Makefile
> > ===================================================================
> > RCS file: /cvs/ports/games/frozen-bubble/Makefile,v
> > retrieving revision 1.28
> > diff -u -p -u -p -r1.28 Makefile
> > --- Makefile 17 Jul 2019 14:49:22 -0000 1.28
> > +++ Makefile 2 Feb 2020 14:05:17 -0000
> > @@ -6,7 +6,7 @@ COMMENT-server = server for the frozen-b
> >  VER = 2.2.0
> >  DISTNAME = frozen-bubble-${VER}
> >  PKGNAME-main = ${DISTNAME}
> > -REVISION-main = 14
> > +REVISION-main = 15
> >  PKGNAME-server = frozen-bubble-server-${VER}
> >  REVISION-server = 10
> >  CATEGORIES = games
> > @@ -29,6 +29,9 @@ BUILD_DEPENDS = devel/p5-SDL \
> >   devel/p5-Locale-gettext \
> >   devel/gettext,-tools
> >  
> > +# Needed for post-patch deinterlacing
> > +BUILD_DEPENDS += graphics/ImageMagick
> > +
> >  RUN_DEPENDS-main = devel/p5-SDL \
> >   devel/p5-Locale-gettext \
> >   ${BASE_PKGPATH},-server
> > @@ -46,5 +49,14 @@ WANTLIB-main = SDL SDL_Pango SDL_mixer
> >  WANTLIB-server = c glib-2.0 intl pthread
> >  
> >  MULTI_PACKAGES = -main -server
> > +
> > +# fix "Interlace handling should be turned on when using png_read_image"
> > +post-patch:
> > + @cd ${WRKSRC} && for interlaced in gfx/flags/flag-de.png \
> > + gfx/flags/flag-fi.png \
> > + gfx/flags/flag-no.png; \
> > + do \
> > + ${LOCALBASE}/bin/mogrify -interlace none $${interlaced} ;\
> > + done
> >  
> >  .include <bsd.port.mk>
> > Index: patches/patch-c_stuff_fb_c_stuff_xs
> > ===================================================================
> > RCS file: patches/patch-c_stuff_fb_c_stuff_xs
> > diff -N patches/patch-c_stuff_fb_c_stuff_xs
> > --- /dev/null 1 Jan 1970 00:00:00 -0000
> > +++ patches/patch-c_stuff_fb_c_stuff_xs 2 Feb 2020 14:05:17 -0000
> > @@ -0,0 +1,125 @@
> > +$OpenBSD$
> > +
> > +Fix build with clang: it errors when functions are inside other
> > +functions.  Rename sqr(int) to prevent conflict with sqr(float).
> > +
> > +Index: c_stuff/fb_c_stuff.xs
> > +--- c_stuff/fb_c_stuff.xs.orig
> > ++++ c_stuff/fb_c_stuff.xs
> > +@@ -94,17 +94,17 @@ int rand_(double val) { return 1+(int) (val*rand()/(RA
> > +
> > + /* -------------- Double Store ------------------ */
> > +
> > ++static void copy_line(int l, SDL_Surface * s, SDL_Surface * img) {
> > ++ memcpy(s->pixels + l*img->pitch, img->pixels + l*img->pitch, img->pitch);
> > ++}
> > ++static void copy_column(int c, SDL_Surface * s, SDL_Surface * img) {
> > ++ int bpp = img->format->BytesPerPixel;
> > ++ for (y=0; y<YRES; y++)
> > ++ memcpy(s->pixels + y*img->pitch + c*bpp, img->pixels + y*img->pitch + c*bpp, bpp);
> > ++}
> > ++
> > + void store_effect(SDL_Surface * s, SDL_Surface * img)
> > + {
> > +- void copy_line(int l) {
> > +- memcpy(s->pixels + l*img->pitch, img->pixels + l*img->pitch, img->pitch);
> > +- }
> > +- void copy_column(int c) {
> > +- int bpp = img->format->BytesPerPixel;
> > +- for (y=0; y<YRES; y++)
> > +- memcpy(s->pixels + y*img->pitch + c*bpp, img->pixels + y*img->pitch + c*bpp, bpp);
> > +- }
> > +-
> > + int step = 0;
> > + int store_thickness = 15;
> > +
> > +@@ -116,8 +116,8 @@ void store_effect(SDL_Surface * s, SDL_Surface * img)
> > + for (i=0; i<=YRES/2/store_thickness; i++) {
> > + int v = step - i;
> > + if (v >= 0 && v < store_thickness) {
> > +- copy_line(i*store_thickness + v);
> > +- copy_line(YRES - 1 - (i*store_thickness + v));
> > ++ copy_line(i*store_thickness + v, s, img);
> > ++ copy_line(YRES - 1 - (i*store_thickness + v), s, img);
> > + }
> > + }
> > + step++;
> > +@@ -133,8 +133,8 @@ void store_effect(SDL_Surface * s, SDL_Surface * img)
> > + for (i=0; i<=XRES/2/store_thickness; i++) {
> > + int v = step - i;
> > + if (v >= 0 && v < store_thickness) {
> > +- copy_column(i*store_thickness + v);
> > +- copy_column(XRES - 1 - (i*store_thickness + v));
> > ++ copy_column(i*store_thickness + v, s, img);
> > ++ copy_column(XRES - 1 - (i*store_thickness + v), s, img);
> > + }
> > + }
> > + step++;
> > +@@ -176,21 +176,22 @@ void bars_effect(SDL_Surface * s, SDL_Surface * img)
> > +
> > + /* -------------- Squares ------------------ */
> > +
> > ++static const int squares_size = 32;
> > ++
> > ++static int fillrect(int i, int j, SDL_Surface * s, SDL_Surface * img, int bpp) {
> > ++ int c, v;
> > ++ if (i >= XRES/squares_size || j >= YRES/squares_size)
> > ++ return 0;
> > ++ v = i*squares_size*bpp + j*squares_size*img->pitch;
> > ++ for (c=0; c<squares_size; c++)
> > ++ memcpy(s->pixels + v + c*img->pitch, img->pixels + v + c*img->pitch, squares_size*bpp);
> > ++ return 1;
> > ++}
> > ++
> > + void squares_effect(SDL_Surface * s, SDL_Surface * img)
> > + {
> > + int bpp = img->format->BytesPerPixel;
> > +- const int squares_size = 32;
> > +
> > +- int fillrect(int i, int j) {
> > +- int c, v;
> > +- if (i >= XRES/squares_size || j >= YRES/squares_size)
> > +- return 0;
> > +- v = i*squares_size*bpp + j*squares_size*img->pitch;
> > +- for (c=0; c<squares_size; c++)
> > +- memcpy(s->pixels + v + c*img->pitch, img->pixels + v + c*img->pitch, squares_size*bpp);
> > +- return 1;
> > +- }
> > +-
> > + int still_moving = 1;
> > +
> > + for (i=0; still_moving; i++) {
> > +@@ -200,7 +201,7 @@ void squares_effect(SDL_Surface * s, SDL_Surface * img
> > +
> > + still_moving = 0;
> > + for (j=i; j>=0; j--) {
> > +- if (fillrect(j, k))
> > ++ if (fillrect(j, k, s, img, bpp))
> > + still_moving = 1;
> > + k++;
> > + }
> > +@@ -212,20 +213,20 @@ void squares_effect(SDL_Surface * s, SDL_Surface * img
> > +
> > + /* -------------- Circle ------------------ */
> > +
> > ++static int sqi(int v) { return v*v; }
> > ++
> > + int * circle_steps;
> > + const int circle_max_steps = 40;
> > + void circle_init(void)
> > + {
> > +- int sqr(int v) { return v*v; }
> > +-
> > + circle_steps = malloc(XRES * YRES * sizeof(int));
> > + if (!circle_steps)
> > + fb__out_of_memory();
> > +
> > + for (y=0; y<YRES; y++)
> > + for (x=0; x<XRES; x++) {
> > +- int max = sqrt(sqr(XRES/2) + sqr(YRES/2));
> > +- int value = sqrt(sqr(x-XRES/2) + sqr(y-YRES/2));
> > ++ int max = sqrt(sqi(XRES/2) + sqi(YRES/2));
> > ++ int value = sqrt(sqi(x-XRES/2) + sqi(y-YRES/2));
> > + circle_steps[x+y*XRES] = (max-value)*circle_max_steps/max;
> > + }
> > + }
> > Index: patches/patch-c_stuff_lib_FBLE_pm
> > ===================================================================
> > RCS file: patches/patch-c_stuff_lib_FBLE_pm
> > diff -N patches/patch-c_stuff_lib_FBLE_pm
> > --- /dev/null 1 Jan 1970 00:00:00 -0000
> > +++ patches/patch-c_stuff_lib_FBLE_pm 2 Feb 2020 14:05:17 -0000
> > @@ -0,0 +1,34 @@
> > +$OpenBSD$
> > +
> > +Perl 5.30+ prohibits using my() in false conditionals
> > +
> > +Index: c_stuff/lib/FBLE.pm
> > +--- c_stuff/lib/FBLE.pm.orig
> > ++++ c_stuff/lib/FBLE.pm
> > +@@ -31,6 +31,8 @@
> > +
> > + package FBLE;
> > +
> > ++use feature qw(state);
> > ++
> > + use POSIX(qw(floor ceil));
> > + use SDL;
> > + use SDL::App;
> > +@@ -1405,7 +1407,7 @@ sub display_levelset_screenshot {
> > +                    $rect{middle}->y + $rect{middle}->height/2 - $rect{screenshot}->height/8 - 3 + $widgetMove);
> > +
> > +
> > +-    my %shrinks if 0;
> > ++    state %shrinks;
> > +     my $current_nb = $start_level || 1;
> > +     if (!exists $shrinks{$name}{$current_nb}) {
> > +         my $surf = SDL::Surface->new(-name => "$FPATH/gfx/menu/please_wait.png");
> > +@@ -1417,7 +1419,7 @@ sub display_levelset_screenshot {
> > +         $app->update($rect{middle});
> > +
> > +         #- sorta "read ahead": will compute next 10 levels screenshots as well
> > +-        my $s_save if 0;
> > ++        state $s_save;
> > +         if (!$s_save) {
> > +             $s_save = SDL::Surface->new(-name => "$FPATH/gfx/level_editor.png");
> > +         }
> > Index: patches/patch-frozen-bubble
> > ===================================================================
> > RCS file: patches/patch-frozen-bubble
> > diff -N patches/patch-frozen-bubble
> > --- /dev/null 1 Jan 1970 00:00:00 -0000
> > +++ patches/patch-frozen-bubble 2 Feb 2020 14:05:17 -0000
> > @@ -0,0 +1,52 @@
> > +$OpenBSD$
> > +
> > +Perl 5.30+ prohibits using my() in false conditionals
> > +
> > +Index: frozen-bubble
> > +--- frozen-bubble.orig
> > ++++ frozen-bubble
> > +@@ -47,6 +47,8 @@ use vars qw($TARGET_ANIM_SPEED $BUBBLE_SIZE $ROW_SIZE
> > +             $lev_number $playermalus $mptrainingdiff $loaded_levelset $direct_levelset $chainreaction %chains %img_mini $frame $sock $gameserver $mynick
> > +             $continuegamewhenplayersleave $singleplayertargetting $mylatitude $mylongitude %autokick $replayparam $autorecord $comment $saveframes $saveframesbase $saveframescounter);
> > +
> > ++use feature qw(state);
> > ++
> > + use Getopt::Long;
> > + use Data::Dumper;
> > + use Locale::gettext;
> > +@@ -269,7 +271,7 @@ sub play_music($) {
> > +     $app->delay(400);
> > +     $app->delay(10) while $mixer->playing_music;  #- mikmod will segfault if we try to load a music while old one is still fading out
> > +     my %musics = (intro => '/snd/introzik.ogg', main1p => '/snd/frozen-mainzik-1p.ogg', main2p => '/snd/frozen-mainzik-2p.xm');
> > +-    my $mus if 0;                                 #- I need to keep a reference on the music or it will be collected at the end of this function, thus I manually collect previous music
> > ++    state $mus;                                 #- I need to keep a reference on the music or it will be collected at the end of this function, thus I manually collect previous music
> > +     if (@playlist) {
> > + my $tryanother = sub {
> > +    my $elem = chomp_(shift @playlist);
> > +@@ -3488,7 +3490,7 @@ sub choose_1p_game_mode() {
> > +         };
> > +
> > +         my $img = $imgbin{'1p_panel'};
> > +-        my $save if 0;
> > ++        state $save;
> > +         my $drect = SDL::Rect->new(-width => $img->width, -height => $img->height,
> > +                                    -x => $MENUPOS{xpos_panel}, '-y' => $MENUPOS{ypos_panel});
> > +         if ($save) {
> > +@@ -5573,7 +5575,7 @@ sub menu {
> > + 'highscores' => { pos => 8, type => 'run',
> > +   run => sub { $menu_display_highscores->() } },
> > +       );
> > +-    my $current_pos if 0; $current_pos ||= 1;
> > ++    state $current_pos; $current_pos ||= 1;
> > +     my @menu_invalids;
> > +     $invalidate_all = sub { push @menu_invalids, $menu_entries{$_}->{pos} foreach keys %menu_entries };
> > +
> > +@@ -5724,7 +5726,7 @@ sub menu {
> > + }
> > +
> > + if ($graphics_level > 1) {
> > +-    my $banner_pos if 0;
> > ++    state $banner_pos;
> > +    $banner_pos ||= 670;
> > +    foreach my $b (keys %banners) {
> > + my $xpos = $banners{$b} - $banner_pos;
> >
> >
> >
> >
> >
> >
> >
>
>
> --
> George Koehler <[hidden email]>
>

--
andrew - http://afresh1.com

Whatever happened to the days when hacking started at the cerebral cortex
and not the keyboard?
                      -- Sid from UserFriendly.org