1080p user interface mod

Full Game Conversions and Custom maps
tuia
Posts: 129
Joined: Tue Sep 06, 2011 12:36 pm
Location: Lisbon, Portugal

Re: 1080p user interface mod

Post by tuia »

Nice work! You can show menu resolution according to your Video.con file settings. Instead of changing the hardcoded values (0x320 and 0x258) starting at offset 0x002B1143, change at offset 0x0005DD6A from D2 33 to 02 34. This will redirect the call to another function, that reads the resolution values from Video.con file.
You should use BF1942-v1.61-nocd-widescreen-fix.zip, which is based on widescreen gaming forum .exe and has some CD checks fixed and another bug fixed. The widescreen gaming forum package is missing BF1942.org file to join servers. Read included .nfo file for more information.
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: 1080p user interface mod

Post by Apache Thunder »

Very cool. I made the changes to the two bytes of code in the exe Tuia mentioned and BAM, the Menu runs at whatever resolution I set to game to. The menu won't change resolution unless I switch to ingame or exit/restart, but that's not really a problem.

I did noticed however my BIK element I have on the profiles menu in the main menu (in my BFH'42 mod) has a visible border on the right and bottom edges now that the menu is running at a different resolution. My higher resolution serverinfo.dds file also looks MUCH better. Node sizes are still the same, but if the node(s) in the meme files refer to higher resolution images, then they will have increased detail once the menu is running at a higher resolution then standard. I am unsure if I should bother trying to fix the visible border on the BIK video. There's a chance it may funk it up for the standard Menu resolution. :P

Also another benefit is the game is can now insta switch from ingame to menu. I press ESC and it brings the menu up instantly. The game no longer has to pause for a moment to switch down to the resolution the MENU used to be hardcoded too. It wasn't always this way. I recall the singleplayer demo had the menu able to run at whatever resolution the game was set too. But then again the menu from that version of the game had rather poor quality images like a crappy mouse cursor and a few other issues.

With BF1942's more refined menu in the retail exe, I am curious as to why Dice hard-coded the menu to such a low resolution. :(

The code in the EXE is an alien language to me. How Tuia manages to figure this stuff out is beyond my comprehension. You're work will always be appreciated here Tuia! Many thanks!
ImageImageImage
I have cameras in your head!
Seth
Posts: 16
Joined: Sun Jun 19, 2011 10:49 am

Re: 1080p user interface mod

Post by Seth »

This mod is great and very useful. I should suggest an improvement: add the mod that s[sk] made for a larger font for player tags. It is most needed precisely when using a high screen resolution. It can be improved by replacing the font with a better looking one, and maybe not quite as large. There are some more interesting things mentioned in that topic, such as the game.fontRatio command.
There are two issues with the scaling: 1. size - when fonts are scaled proportionally in both dimensions, according to the screen resolution; and 2. stretching - fonts get distorted due to stretching to fit the widescreen aspect ratio. s[sk]'s method of increasing text size works for the player tags and console text, because the font they use is about the only one in the game that is not scaled according to the screen resolution. Since the game seems to know how to (however badly) scale the other fonts in the game according to the screen resolution, it would probably also be comfortable using fonts of any resolution. So if you simply use the same method as that used by s[sk] for these other fonts, maybe you will get the increased detail fonts you need, while having normal size texts.
In any case, it should be possible to modify the fonts so that when they get stretched, the distortion is not that bad. They can at least be made narrower, so that when they get stretched they get back to a normal proportion. This may not fix the issue of the distortions due to the bad algorithm used for scaling, but having a high resolution font will greatly improve it.

However, I was most pleased to see the hack by tuia. This repeated switching between resolutions every time you start the game, join a server, go to the menu, go back, load next map, etc. is just annoying for multiple reasons. It takes a couple of seconds for every resolution switch; messes with the interface of other programs (e.g. Winamp, Task Manager); it sometimes messes up desktop icons; and many other things. So it will be very useful to use this patch. Thank you! However, there is still something that makes the game switch to 800x600 for a second and back every time bf1942.exe starts, which also happens every time the map changes. It does not look like it is related to the intro movies, since I have the .bik files in \Movies deleted and use the +restart 1 parameter. Btw, could it be related to BlackScreen.exe, what is this file for anyway? If all resolution switching could be eliminated, it would be very nice. Also could the same patch be made for Battlefield Vietnam? It would be much appreciated!
Bitcoin address: 1NEoGgsFS9vxLT3eW4w6RFdvzPXLpQX66t
tuia
Posts: 129
Joined: Tue Sep 06, 2011 12:36 pm
Location: Lisbon, Portugal

Re: 1080p user interface mod

Post by tuia »

BlackScreen.exe loads BF1942.exe and takes as parameter a process ID to open. I don't think it's used anymore in BF1942 v1.61. You can type "BlackScreen.exe 1" and see what happens. Resolution switching can probably be eliminated with some small code changes, BF1942.exe is hardcoded to start at 800x600 and after it reads values from game.setGameDisplayMode.
About font scaling, in BF1942.exe some horizontal resolutions, like 640, 1024, 1152 and 1280 have hardcoded scale factors to resize font. At those horizontal resolutions font can be scaled with game.fontRatio command. At higher resolutions, font can't be scaled unless the executable is patched.
I've tested these menu textures from your 1080p UI mod and at low resolutions from 640x480 to 1280x1024, some textures like radio tooltips and server menu buttons look blurred. GameSpy and PunkBuster logo also. I don't understand why some textures scale down correctly and others don't. Anyway, your mod is a great and refreshing improvement to BF1942. It can be used without Merciless mod.
Seth
Posts: 16
Joined: Sun Jun 19, 2011 10:49 am

Re: 1080p user interface mod

Post by Seth »

Indeed, I tried starting a Notepad process, and running BlackScreen.exe with Notepad's PID. It closes the process with the given PID, shows a black screen in the desktop resolution for a few seconds, and only then BF1942.exe starts and does the switching to 800x600 and back, as it does every time.
unexpectedpanda wrote:The mmenu and movies in BF1942 usually render at 800x600. In hex, this is 0320 0258. This is stored in the executable byte-shifted twice to the left, so we're looking for an entry of 20 03, followed not too far after by 58 02.
Not sure what you meant to say there, but they are not bit shifted or anything like that, they are just integer values with the bytes written in reverse order. So 00 00 03 20 (800 in hex, 4 bytes) becomes 20 03 00 00. I have no idea what the byte C7 after it means, but I just searched for all places that have 20 03 00 00 C7, followed shortly after by 58 02 00 00, and replaced them with the values for my preferred resolution. Now there is absolutely no switching back and forth between resolutions. It is not a perfect solution but it's good enough for me.

Edit: forgot to mention I did it for both Battlefield 1942 and Battlefield Vietnam and it works.
Last edited by Seth on Sat Jun 01, 2013 1:54 pm, edited 1 time in total.
Bitcoin address: 1NEoGgsFS9vxLT3eW4w6RFdvzPXLpQX66t
tuia
Posts: 129
Joined: Tue Sep 06, 2011 12:36 pm
Location: Lisbon, Portugal

Re: 1080p user interface mod

Post by tuia »

Seth wrote:I have no idea what the byte C7 after it means, but I just searched for all places that have 20 03 00 00 C7, followed shortly after by 58 02 00 00, and replaced them with the values for my preferred resolution. Now there is absolutely no switching back and forth between resolutions. It is not a perfect solution but it's good enough for me.
The byte C7 is the opcode for the mov instruction http://pdos.csail.mit.edu/6.828/2010/re ... 86/MOV.htm, following XX XX XX 20 03 00 00 instruction. The changes you made were to the hardcoded resolution values, it can probably be set to always read from video.con file game.setGameDisplayMode values.
I found out why the menu textures and radio tooltips look blurred. The textures .dds files from Merciless mod were saved with generated mipmaps and I was running BF1942 at lowest texture quality, meaning low resolution mipmap from texture picked. I manually removed mipmaps because they are senseless for menu buttons and radio tooltips.
First, what is a mip map and why do they blur? A mip map is a set of lower resolution versions of a texture, all saved together inside a single file. Each smaller version is 1/4 the size of the previous. In computer simulations, as a 3D object moves farther from our point of view, the level of detail visible in it's textures decreases.

With a texture without mip maps, the computer has to process the texture file as it is rendered smaller on the screen, and sometimes there will be artifacts from this processing. Also, there is some wasted processing power in having high resolution textures shown on objects which are only rendered as a few pixels on screen. Using mip maps allows the simulation to 'down shift' to a smaller texture version as an object is rendered farther away, and since the rendered texture is lower resolution, there are less texture pixels being rendered on those distant objects.

A side effect of mip map textures is that sometimes they are not rendered at full resolution when they are near our point of view in the simulator. This is when we see a blurry texture, as the simulator has chosen a lower resolution version from the saved mip maps, and we plainly see the low resolution texture.
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: 1080p user interface mod

Post by Apache Thunder »

Mipmaps is something DDS textures uses. It's primarily used to optimize video ram usage for ingame mesh textures. So for example a distant object will switch to a lower mipmap with a lower resolution and thus frees up more video ram or if "texture quality" in the video settings is lowered. This is also why using DDS textures for object light maps generally improves performance a lot because TGA files don't support mipmaps.

But for HUD and UI textures, mipmaps is not something that would be useful and isn't intended to be used in a 2D system since the textures are all the same distance from the screen. When ever I make UI elements I usually try to keep to using TGA format unless it's a vanilla element I'm replacing. (If a vanilla file is in DDS format, then the replacement texture in the new mod has to be in the same format, other wise the game ignores it and loads the original instead)
ImageImageImage
I have cameras in your head!
tuia
Posts: 129
Joined: Tue Sep 06, 2011 12:36 pm
Location: Lisbon, Portugal

Re: 1080p user interface mod

Post by tuia »

Some custom maps unfortunately have mipmaps generated for HUD textures and minimap. I have to play at lowest texture quality and those custom HUD icons are blurred and ugly.
Fixed the menu textures, removing all mipmaps and exchanged some icons. Background.tga was downscaled to 1600x900, because it would not display in my laptop, don't know why. Download the menu_001.zip file, extract it and copy menu_001.rfa to <BF1942 DIR>\Mods\bf1942\Archives. If you don't want to use it anymore, just delete menu_001.rfa and you'll revert back to the old style.
BiNO
Posts: 2
Joined: Sun Jul 06, 2014 10:21 am

Re: 1080p user interface mod

Post by BiNO »

offline :( :(
could someone reupoad?
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: 1080p user interface mod

Post by Apache Thunder »

tuia wrote:Some custom maps unfortunately have mipmaps generated for HUD textures and minimap. I have to play at lowest texture quality and those custom HUD icons are blurred and ugly.
Fixed the menu textures, removing all mipmaps and exchanged some icons. Background.tga was downscaled to 1600x900, because it would not display in my laptop, don't know why. Download the menu_001.zip file, extract it and copy menu_001.rfa to <BF1942 DIR>\Mods\bf1942\Archives. If you don't want to use it anymore, just delete menu_001.rfa and you'll revert back to the old style.

Indeed. This is why I tried to forgo DDS format entirely for HUD related things in my latest mods. The map thumbnail/loadscreen/minimap in my BF242 redux mod are all TGA files for example. :P

And even in my older mods the DDS files I did use never had mipmaps enabled. :P
ImageImageImage
I have cameras in your head!
Post Reply