Angband Forums

Angband Forums (http://angband.oook.cz/forum/index.php)
-   Development (http://angband.oook.cz/forum/forumdisplay.php?f=10)
-   -   SDL2 port when ? (http://angband.oook.cz/forum/showthread.php?t=9076)

Magnate September 23, 2018 08:07

Hi Shirish, thanks for the email. It's funny how life happens sometimes, I was thinking only the other day it's time I updated Angband in Debian, 4.x must be pretty mature now and I expect some free time this fall ... and lo, something happens to pull me back.

I can't promise anything soon, but months rather than years. I'll start with a bog-standard package of Angband 4.x, then I'm going to fix up angband-audio, then I'll see if I can help on SDL2.

Derakon, Nick - hope you're well.

CC

Nick September 23, 2018 10:19

Quote:

Originally Posted by Magnate (Post 133397)
Hi Shirish, thanks for the email. It's funny how life happens sometimes, I was thinking only the other day it's time I updated Angband in Debian, 4.x must be pretty mature now and I expect some free time this fall ... and lo, something happens to pull me back.

I can't promise anything soon, but months rather than years. I'll start with a bog-standard package of Angband 4.x, then I'm going to fix up angband-audio, then I'll see if I can help on SDL2.

Derakon, Nick - hope you're well.

CC

Good to hear from you! Am currently recovering from surgery according to plan, so let's call that well :)

Derakon September 23, 2018 14:49

Good to see you, Magnate! I'm doing decently well. Life continues on, no great peaks nor abyssal chasms.

t4nk September 24, 2018 11:27

I sent the pull request:
https://github.com/angband/angband/pull/502

For those who are interested in compiling it (instructions for Debian-based systems!):

You'll need three libraries: the "base" SDL2, SDL2_ttf (fonts stuff) and SDL2_image (loading .png files and such). Also, their dependecies (Freetype, zlib and co). If you want sounds, you'll also need SDL2_mixer. In short:
Code:

apt-get install libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev
Clone the repo and switch to sdl2 branch:
Code:

git clone https://github.com/t4nk074/angband
git checkout sdl2

Configure Angband without any frontends (just in case):
Code:

cd angband
./autogen.sh
./configure --with-no-install --disable-curses --disable-x11

(I think other stuff is disabled by default)

Now compile the game using Makefile.sdl2:
Code:

cd src
make -f Makefile.sdl2

If you want sounds, use this instead:
Code:

cd src
SOUND=yes make -f Makefile.sdl2

Now it should work... well, works for me :)
Code:

cd ..
./angband

Let me know if there are any problems!

shirish September 24, 2018 15:57

Reply in-line :-

Quote:

Originally Posted by t4nk (Post 133411)
I sent the pull request:
https://github.com/angband/angband/pull/502

For those who are interested in compiling it (instructions for Debian-based systems!):

You'll need three libraries: the "base" SDL2, SDL2_ttf (fonts stuff) and SDL2_image (loading .png files and such). Also, their dependecies (Freetype, zlib and co). If you want sounds, you'll also need SDL2_mixer. In short:
Code:

apt-get install libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev
Clone the repo and switch to sdl2 branch:
Code:

git clone https://github.com/t4nk074/angband
git checkout sdl2


Shouldn't this be from inside the repo. I have done the following -

Code:

~/games$ git clone https://github.com/t4nk074/angband angband-t4nk074
Cloning into 'angband-t4nk074'...
remote: Counting objects: 56527, done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 56527 (delta 15), reused 14 (delta 8), pack-reused 56489
Receiving objects: 100% (56527/56527), 64.93 MiB | 287.00 KiB/s, done.
Resolving deltas: 100% (45476/45476), done.

Then -

Code:

~/games$ cd angband-t4nk074/
~/games/angband-t4nk074$ git checkout sdl2
Branch 'sdl2' set up to track remote branch 'sdl2' from 'origin'.
Switched to a new branch 'sdl2'

I would be updating my answer as I do the next steps.

Quote:

Originally Posted by t4nk (Post 133411)
Configure Angband without any frontends (just in case):
Code:

cd angband
./autogen.sh
./configure --with-no-install --disable-curses --disable-x11

(I think other stuff is disabled by default)

Now compile the game using Makefile.sdl2:
Code:

cd src
make -f Makefile.sdl2

If you want sounds, use this instead:
Code:

cd src
SOUND=yes make -f Makefile.sdl2

Now it should work... well, works for me :)
Code:

cd ..
./angband

Let me know if there are any problems!

The compilation terminated see https://paste.debian.net/1043948/

This is when I have all the -dev versions that were needed -

Code:

$ apt-cache policy libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev
libsdl2-dev:
  Installed: 2.0.8+dfsg1-2
  Candidate: 2.0.8+dfsg1-2
  Version table:
 *** 2.0.8+dfsg1-2 500
        500 http://deb.debian.org/debian buster/main amd64 Packages
        100 http://deb.debian.org/debian unstable/main amd64 Packages
        100 /var/lib/dpkg/status
libsdl2-ttf-dev:
  Installed: 2.0.14+dfsg1-2
  Candidate: 2.0.14+dfsg1-2
  Version table:
 *** 2.0.14+dfsg1-2 500
        500 http://deb.debian.org/debian buster/main amd64 Packages
        100 http://deb.debian.org/debian unstable/main amd64 Packages
        100 /var/lib/dpkg/status
libsdl2-image-dev:
  Installed: 2.0.3+dfsg1-1
  Candidate: 2.0.3+dfsg1-1
  Version table:
 *** 2.0.3+dfsg1-1 500
        500 http://deb.debian.org/debian buster/main amd64 Packages
        100 http://deb.debian.org/debian unstable/main amd64 Packages
        100 /var/lib/dpkg/status
libsdl2-mixer-dev:
  Installed: 2.0.2+dfsg1-2
  Candidate: 2.0.2+dfsg1-2
  Version table:
 *** 2.0.2+dfsg1-2 500
        500 http://deb.debian.org/debian buster/main amd64 Packages
        100 http://deb.debian.org/debian unstable/main amd64 Packages
        100 /var/lib/dpkg/status


takkaria September 24, 2018 16:37

You should probably run ./configure with --disable-sdl-mixer too. (Hi magnate!)

shirish September 24, 2018 16:59

Quote:

Originally Posted by takkaria (Post 133414)
You should probably run ./configure with --disable-sdl-mixer too. (Hi magnate!)

Hi all,

I retried and failed -

Code:

~/games/angband-t4nk074$ ./autogen.sh
*info* running aclocal (-I m4)
*info* running autoheader
*info* running autoconf

and then - will be sharing just the start and end messages -

Code:

~/games/angband-t4nk074$ ./configure --with-no-install --disable-curses --disable-x11 --disable-sdl-mixer
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
.....
.....
configure: creating ./config.status
config.status: creating mk/buildsys.mk
config.status: creating mk/extra.mk
config.status: creating mk/sinclude.mk
config.status: creating src/autoconf.h
config.status: src/autoconf.h is unchanged

Configuration:

  Install path:                          (not used)
  binary path:                            ..
  config path:                            /home/shirish/games/angband-t4nk074/lib/
  lib path:                              /home/shirish/games/angband-t4nk074/lib/
  doc path:                              /home/shirish/games/angband-t4nk074/doc/
  var path:                              /home/shirish/games/angband-t4nk074/lib/

-- Frontends --
- Curses                                  Disabled
- X11                                    Disabled
- SDL                                    Disabled
- Windows                                Disabled
- Test                                    No
- Stats                                  No

- SDL sound                              Disabled

Still got the same issue -

Code:

shirish@debian:~/games/angband-t4nk074$ cd src/
shirish@debian:~/games/angband-t4nk074/src$ SOUND=yes make -f Makefile.sdl2
        CC snd-sdl.c         
snd-sdl.c:25:10: fatal error: SDL/SDL.h: No such file or directory
 #include <SDL/SDL.h>
          ^~~~~~~~~~~
compilation terminated.
make: *** [Makefile.sdl2:100: snd-sdl.o] Error 1

Perhaps it should be -
SDL2/SDL.h

Code:

$ dpkg -L libsdl2-dev | grep SDL.h
/usr/include/SDL2/SDL.h
/usr/include/SDL2/SDL_haptic.h
/usr/include/SDL2/SDL_hints.h

I was able to fix it by doing in sdl2.c -

Code:

$ cat snd-sdl.c | grep include
 *    are included in all such copies.  Other copyrights may also apply.
#include "angband.h"
#include "init.h"
#include "sound.h"
#include <SDL2/SDL.h>
#include <SDL2/SDL_mixer.h>

just changed SDL/SDL.h and SDL/SDL_mixer.h to SDL2/SDL.h and SDL2/SDL.mixer.h

and was able to compile -

Code:

~/games/angband-t4nk074/src$ SOUND=yes make -f Makefile.sdl2
        CC snd-sdl.c         
      LINK angband           
cp angband ..


t4nk September 24, 2018 17:06

Quote:

Originally Posted by shirish (Post 133413)
The compilation terminated see https://paste.debian.net/1043948/

Ah, I see. I have SDL1 headers installed, so gcc looks into /usr/include and there is "SDL" directory there. You have only SDL2, so you have /usr/include/SDL2 (but not /usr/include/SDL). So it fails to find it (SDL_mixer API hasn't changed between 1 and 2).

Anyway, looks like you're close :) snd-sdl.c has two lines:

Code:

#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>

(lines 25 and 26)

Those need to be replaced with:

Code:

#include <SDL.h>
#include <SDL_mixer.h>


shirish September 24, 2018 17:09

@t4nk, I just did that, see above ;)

Btw we don't seem to have any graphics, it still shows up in ASCII mode with the skeletons as background.

I did try -
Code:

~/games/angband-t4nk074$ ./angband -g -ssdl -msdl2
Also angband doesn't seem to have any options for windowed mode from what all I could see/gather -

Code:

$ ./angband --help
Usage: angband [options] [-- subopts]
  -n            Start a new character (WARNING: overwrites default savefile without -u)
  -l            Lists all savefiles you can play
  -w            Resurrect dead character (marks savefile)
  -g            Request graphics mode
  -x<opt>        Debug options; see -xhelp
  -u<who>        Use your <who> savefile
  -d<dir>=<path> Override a specific directory with <path>. <path> can be:
    scores (default is /home/shirish/games/angband-t4nk074/lib/scores)
    gamedata (default is /home/shirish/games/angband-t4nk074/lib/gamedata)
    screens (default is /home/shirish/games/angband-t4nk074/lib/screens)
    help (default is /home/shirish/games/angband-t4nk074/lib/help)
    info (default is /home/shirish//.angband/Angband/info)
    pref (default is /home/shirish/games/angband-t4nk074/lib/customize)
    fonts (default is /home/shirish/games/angband-t4nk074/lib/fonts)
    tiles (default is /home/shirish/games/angband-t4nk074/lib/tiles)
    sounds (default is /home/shirish/games/angband-t4nk074/lib/sounds)
    icons (default is /home/shirish/games/angband-t4nk074/lib/icons)
    user (default is /home/shirish//.angband/Angband)
    save (default is /home/shirish/games/angband-t4nk074/lib/save)
                Multiple -d options are allowed.
  -s<mod>        Use sound module <sys>:
    sdl  SDL_mixer sound module
       
  -m<sys>        Use module <sys>, where <sys> can be:
    sdl2  SDL2 frontend

Also for the mixer, shouldn't it be sdl2_mixer. I haven't been able to hear any sound :(

t4nk September 24, 2018 17:10

p.s. Hi, Takkaria :)


All times are GMT +1. The time now is 11:28.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, vBulletin Solutions Inc.