Help required - compiling with SDL renderer (#116)

All your MAngband related technical questions answered. Problems compiling or running the game/server? No problem! Ask here.
Post Reply
PowerWyrm
Balrog
Posts: 1574
Joined: Sun 27.11.2005, 15:57

Help required - compiling with SDL renderer (#116)

Post by PowerWyrm » Mon 18.02.2008, 16:15

Ok... I tried to compile MAng (in my case PWMAng, but it's the same) with SDL renderer activated.
I implemented the changes from #116, downloaded and unzipped the SDL-1.2.13 package, unzipped the Borland.zip package (I use BCC6 to compile my code so I need a Borland makefile), compiled the SDL.dll and SDL.lib files (took me three ****ing hours!!! because the stupid makefile is for version 1.2.4 and not 1.2.13, so there were files missing, paths to change, compile errors to fix...), added all sdlxxx.h files to the /client subdirectory, added sdl.lib to the bcc lib subdirectory, modified my makefile to add a USE_SDL define, client\main-sdl.c client\maim-sdl.c client\sdl-xxx.c client\client.c client\set_focus.c files and sdl.lib to the link path... and I'm still getting errors...

Error: Unresolved external '_SDL_FillRect' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIN-SDL.OBJ
Error: Unresolved external '_SDL_UpdateRect' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIN-SDL.OBJ
Error: Unresolved external '_SDL_CreateRGBSurface' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIN-SDL.OBJ
Error: Unresolved external '_SDL_SetAlpha' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIN-SDL.OBJ
Error: Unresolved external '_SDL_FreeSurface' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIN-SDL.OBJ
Error: Unresolved external '_SDL_WaitEvent' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIN-SDL.OBJ
Error: Unresolved external '_reset_visuals' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIN-SDL.OBJ
Error: Unresolved external '_SDL_SaveBMP_RW' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIN-SDL.OBJ
Error: Unresolved external '_SDL_GetRGB' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIM-SDL.OBJ
Error: Unresolved external '_SDL_MapRGB' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIM-SDL.OBJ
Error: Unresolved external '_SDL_UpperBlit' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIM-SDL.OBJ
Error: Unresolved external '_SDL_PollEvent' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIN-SDL.OBJ
Error: Unresolved external '_SDL_Flip' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIN-SDL.OBJ
Error: Unresolved external '_SDL_Delay' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIN-SDL.OBJ
Error: Unresolved external '_SDL_SetColors' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIN-SDL.OBJ
Error: Unresolved external '_SDL_Init' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIN-SDL.OBJ
Error: Unresolved external '_SDL_Quit' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIN-SDL.OBJ
Error: Unresolved external '_SDL_SetVideoMode' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIN-SDL.OBJ
Error: Unresolved external '_SDL_WM_SetCaption' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIN-SDL.OBJ
Error: Unresolved external '_SDL_EnableKeyRepeat' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIN-SDL.OBJ
Error: Unresolved external '_SDL_ShowCursor' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIN-SDL.OBJ
Error: Unresolved external '_SDL_RWFromFile' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIN-SDL.OBJ
Error: Unresolved external '_SDL_LoadBMP_RW' referenced from D:\EXTRA\PWMANGBAND\SRC\CLIENT\MAIN-SDL.OBJ

Note that I don't get any errors for maim-sdl which also uses SDL functions...

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

Post by PowerWyrm » Tue 19.02.2008, 12:09

Well I managed to compile the damn thing by simply adding all the SDL obj files to the makefile... but there has to be a better way to do this (the linker should use the lib file and then dynamically link all the functions to SDL.dll).
Anyway... when I launch the client with SDL activated, I have a fugitive vision of a window and then nothing else... so the question is... has anyone managed to make this damn thing work???
A typical error I get is:
mangclient.exe: Vid. init.: We asked for (0) and got SDL_HWPALETTE (20000000)

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

Post by PowerWyrm » Tue 19.02.2008, 13:07

Ok... sounds like we are making some progress here...
The message I was getting is just a warning, not an error. I found out I didn't have MANGBAND defined, so another crucial define, OLD_TERM_28X, was not defined. This was making SDL load the wrong font files and quit with an error...
So now the SDL renderer is correctly activated... and looks horribly ugly. And I have the following problems:
- mangband.ini is not loaded anymore, I have to type name and password each time...
- the window is too large! (just a bit, but it's annoying... and I don't seem to be able to resize it)
- all the old terms are replaced by an unique window, which is hard to get used to... and now equipment and inventory overlap (at least in PWMAng which has 14 equipment slots instead of 12)
- all keyboard inputs are defined for a QWERTY keyboard... I am totally lost with my AZERTY keyboard!!!
Any idea on how to correct all those problems?

User avatar
Flambard
King Vampire
Posts: 258
Joined: Wed 20.06.2007, 10:49

Post by Flambard » Tue 19.02.2008, 15:12

First of all, be ready to provide all the nessecary information for compiling it with borland, it seems not to be an easy task? :) Thanks.

Ok for keyboard inputs, I think you shall try fiddling with the pref files? Not sure.

You can provide --width, --height and --fullscreen command line parameters to adjust window size.

Fonts are not adjustable (hardcoded), as you noticed mangband.ini is not loaded ofcourse. For inventory overlapping, I think there'll be a feature to adjust all the 'sub-windows' positions in future versions (1.2). Being in one window is the POINT of the renderer, not a problem ;)

All I can suggest is to wait for 1.2 dev phase, lots of those problems will be addressed by that time. Or you can start addressing them yourself ofcourse.

Lastly, please do realise that it might not be a good substitution for windows client. Currently win client is a better choice for a windows user (and I always thought it was the best out of all the other versions). But don't underestimate the power of sdl either ;P

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

Post by PowerWyrm » Wed 20.02.2008, 13:49

Compiling with Borland is easy... just annoying and time consuming when it should just be a question of launching MAKE with the proper makefile. I had to edit SDL.mak to correct wrong paths, add missing obj files, remove obsolete obj files, edit the CPP path and LIB path... then correct compile errors in SDL_stdinc.h, SDL_systhread.c and SDL_sysevents.c

For the keyboard problem, I checked forums about it and found an interesting comment from main SDL developer Sam Lantinga (note that this has been posted SEVEN years ago, and that SDL hasn't been touched since then!):
It's not a bug in SDL. It's what I've been saying for ages... that's
what DirectX is returning as the key code. You can't rely on the VK
keysyms reflecting the keyboard layout because they're just great big
gamepad button identifiers. It's only when they're translated into
character codes that they start to have meaningful ascii values and
will match the actual keyboard layout.

Max hacked the MacOS code to do a partial keyboard translation on each
key so we know what it _should_ be, but really MacOS has the same problem.
The only environment that maps the scancodes to virtual keys while
respecting the keyboard layout is X11. And, Mattias, you're in cushy
land there.. :)

It's a real problem, and I'm not sure how to solve it at this point.
Basically, SDL simply doesn't work with non-QWERTY keyboards :(
The only way to fix the problem is to use Unicode characters (by enabling Unicode in SDL using SDL_EnableUNICODE(1)) and rewrite the SDL_keysymtostr() function in maim-sdl.c to map not only the keys from sdl_keymap, but *all* the keys (jeez!)... gonna investigate this when I have time.

Defining width and height doesn't seem very useful, since everyone uses different screen resolutions... however the "fullscreen" mode seems interesting and I'm gonna use it.

Inventory overlapping should be fixed easily... since there is plenty of unused room below the inventory sub-window. I'm gonna simply see where the top position of this window is defined and move it...

I really find this SDL renderer ugly, and of course it won't be a substitution for windows client... I just wanted to see if it worked, simply because I know there has been an isometric view implementation of Angband/ToME using SDL and it really looked cool, and I wanted to check if it would be possible to port it to MAng/PWMAng.

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

Post by PowerWyrm » Thu 21.02.2008, 13:17

Ok, the keyboard problem is solved (or at least most of the problems with key mappings should be gone now)... as I said I simply activated Unicode characters and rewrote SDL_keysymtostr() in maim-sdl.c to use the translated Unicode characters as often as possible instead of the SDL virtual keysyms.
For PWMAngband, I added a shortcut to mangclient.exe with the --fullscreen command line parameter... and the SDL client looks better that way.
Inventory overlapping is fixed... just had to change a hardcoded value in init_one_term().
So now PWMAngband has a SDL client too... I can't wait to look at the isometric view implementation to make it look awesome :wink:

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

Post by PowerWyrm » Fri 22.02.2008, 12:37

Today, I downloaded the source code for Angband 2.9.1 with the isometric view (IsoAngband 0.2.4). It looks quite simple to implement... but will certainly need a lot of time to do so. Unfortunately, this project is dead for 5 years now, and there seems no chance for it to be reactivated...
Anyway I'm gonna try to see what I can do with this code for PWMAngband... check my progress in the PWMAngband forum.

Post Reply