SDL2 MAngband interface

All your MAngband related technical questions answered. Problems compiling or running the game/server? No problem! Ask here.
Post Reply
kts
Mangy-Looking Leper
Posts: 3
Joined: Mon 02.02.2015, 21:59
Contact:

SDL2 MAngband interface

Post by kts » Mon 02.02.2015, 22:33

Hail, all.

To any with an ear on IRC, some of this was mentioned there (acenoid recommended I echo info here).

Due to wanting to play MAngband w/ a few others (all using different operating systems), I spent some time last week writing an SDL2 interface for MAngband (pict-enabled) tied to the 1.1.2 release. I originally tried to work with the SDL interface, but building on OS X proved to be annoying, so I figured it wouldn't be too bad to write it in SDL2 - I also tried to port SDL->SDL2 first, but got annoyed and just wrote the whole thing from scratch.

Image

It was certainly fun learning how "z-term" stuff works and studying the code to figure out how to map everything properly (not hard, but interesting).

At any rate, I had a few key questions:

What code base would be best to integrate this with?
As stated, this is tied to the 1.1.2 release. However, I merged my main-sdl2 stuff (and a few checks in a couple places) with the latest from git, but it wasn't possible to test due to network-related failures (even a self-hosted server using the same git version, it had various packet errors). What code-base would be best to tie this to?

Do accurate MAngband pict table maps exist?
Given that I'm a boor who likes graphics (what started this whole endeavor, really), is there a graphics file and pict "table map"(high-bit set char/attr pairs) that matches MAngband? I apologize if this information is already available, but I was not met with much luck finding one that worked. In the attached screenshot, I put some basic mappings to test things out, such as the store doors and "grass" to the rocks sprite. The 1.1.2 included graphics and pict table maps did not seem to match up with MAngband (although a handful of items did).

I've been holding off on creating my own MAngband pict table map (and modified graphics file) as it's a bit of busy-work that isn't the most thrilling due to the hope that there may exist one already. I am dubious, however, as a forum post here (from 2009, mind you) mentions that char/attr pairs need to be remapped.

Short of there existing appropriate maps, I was going to make a script that gathers all MAngband objects (and their appropriate types) and populates a spritesheet based on their index number (e.g., assuming rows to consist of 16 cols, object id 17 would fall on the coords 1x1). Following this, a previously defined pict table map could be used to move old sprite locations to their new, id-specific locations. Unless I'm missing something, it'd be logically easier to map graphics in a way that corresponds to the underlying game data, but I could be mistaken since I don't know MAngband/Angband's rational too well.

I do not want to create a significantly different way of doing stuff that breaks compatibility with other interfaces, so some guidance/discussion would be much appreciated.

----

I haven't entirely completed the client, as I need to study the z-term to figure out how exactly to send key commands/keypresses, but it should be ready soon (around 650 lines of code at the moment, including some comments).

Beyond compiling/running on OS X, it also works fine on Windows 7 and Linux. I'm currently using SDL2's multiple window support, but I will implement single-window virtualized terms (easily done since I'm not rendering directly to screen, but rather to framebuffer textures for each window - it'd just be a matter of rendering in a single window's context with offsets).

Also, sorry about the IRC spam - I noticed that the "mangband" bot announces connection/disconnection status, and I have been doing much of that due to client testing. :)

PowerWyrm
Balrog
Posts: 1574
Joined: Sun 27.11.2005, 15:57

Re: SDL2 MAngband interface

Post by PowerWyrm » Tue 03.02.2015, 11:59

Just for info, the current server code is based from the 1.1.3 branch of git: https://github.com/mangband/mangband/tree/version-1_1_3. You should probably start from that version. Unfortunately, the graphical code is completely broken in MAngband, I don't remember at all if something has been done to fix it, not even sure if has been done in the trunk. If you want something that's remotely related, check what I've done in my PWMAngband variant. If you're using 16x16 tiles, the file you want is the Adam Bolt tileset (16x16.png). Check main-sdl.c to see how the UI is built (SDL 1.2) and readpng.c to see how graphics are loaded from the png file.

kts
Mangy-Looking Leper
Posts: 3
Joined: Mon 02.02.2015, 21:59
Contact:

Re: SDL2 MAngband interface

Post by kts » Thu 05.02.2015, 02:36

Thanks for the response.

Perhaps it wasn't terribly clear, but as shown in the original post, I already have an SDL2 client working with graphics. I will certainly port to whatever version makes the most sense to, but I cannot "start from" any version at this point, as I'm well beyond that stage. ;)

In regards to tiles, thankfully, someone fixed the char/attr mapping for Bolt's tileset (from trunk), so most things display fine. I've added a couple MAngband-specific graphics to Bolt's tileset, as taken from trunk.

As an update of sorts, the client fully works on OS X(native), Windows, and Linux and graphics work well, using a handful of SDL2 keymap macros. At the moment, I just need to have configuration settings loaded from the mangclient INI and "virtual term" implemented (most of it is already functional in that regard, it just needs some modifications).

To any interested, I've been mentioning progress in #MAngband-dev -- Flambard has been nice enough to give a few tips in that regard.

One Question: Is the 1.1.3 tree broken like trunk is? I couldn't get a trunk client to connect to a trunk server (or a 1.1.2 server) at all (on Linux and OS X). When asking in IRC, it seems that trunk does not really work (and when it does, it's a mystery).

kts
Mangy-Looking Leper
Posts: 3
Joined: Mon 02.02.2015, 21:59
Contact:

Re: SDL2 MAngband interface

Post by kts » Thu 14.05.2015, 05:07

Hail wary travelers,

due to jjrh's proddings, I have forked (in the github sense, mind you!) the mangband repo and incorporated my SDL2 interface to both the master branch and the version-1_3_3 branch. The repo is at https://github.com/kettek/mangband/

Currently the 'master' branch is problematic, as it bails when connecting to a server with an "Undefined packet 0 error". AFAIK, the 'master' branch is broken in general and I'm not sure what has actually changed in the networking layer to cause such problems. I could look into this, but I anticipate that those who implemented the changes would have a better grasp on potential issues than I would.

Otherwise, the version-1_1_3 branch works well on Mac OS 10.6.8, Slackware Linux 14.1, and Windows 7.

There are testing binaries available at http://kettek.net/archive/etc/mangband/ for Mac OS X and Windows - let me know how they work and if you run into any issues.

There is still work to be done, as is noted at the head of 'main-sdl2.c'. However, I would like to get people's opinions on the client and if any approaches I've taken are problematic. Once it is in a complete enough state -- or if Flambard or others deem it acceptable --, it would be beneficial, I think, to integrate it with the official mangband github repo through a pull request.

Have some screenshots:
mangband-1.1.3_lin.png
Slackware 14.1 + i3wm + MAngband 1.1.3 SDL2 client
mangband-1.1.3_lin.png (21.64 KiB) Viewed 12818 times
mangband-1.1.3_osx.png
Mac OS 10.6 + MAngband 1.1.3 SDL2 client
mangband-1.1.3_osx.png (84 KiB) Viewed 12818 times
mangband-1.1.3_win32.png
Windows 7 + MAngband 1.1.3 SDL2 client
mangband-1.1.3_win32.png (100.67 KiB) Viewed 12818 times

Post Reply