Author Topic: Newbe needs info on where to find what in code  (Read 38586 times)

Offline Callahan

  • Captain
  • ***
  • Posts: 61
    • View Profile
Re: Newbe needs info on where to find what in code
« Reply #45 on: April 06, 2018, 07:12:50 pm »
Almost there. A very good guide, Yankes!
It would compile, but says "SDL.H" was not found when it tried to include it.
I tried to download the SDL 1.2 for MinGW32 and the other stuff from the OXC help page and added the folders to the project, but either I downloaded the wrong things or placed them in the wrong position.
OK, I got the right location of SDL.
Next is yaml-cpp/yaml.h not being found. It is placed in "C:\work\yaml-cpp"
According to makefile, this is the right place. What am I missing?


Strike that, too. I should have taken the content of yaml-cpp Master into yaml-cpp, but I copied the folder.
Now it does compile. In a few Minutes I will know if it was sucessfull

Yankes, your guide should replace the old one at
https://www.ufopaedia.org/index.php/Compiling_with_MinGW_(OpenXcom)
You are 75% faster and equally less complicated.
« Last Edit: April 06, 2018, 08:21:27 pm by Callahan »

Online Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3348
    • View Profile
Re: Newbe needs info on where to find what in code
« Reply #46 on: April 06, 2018, 08:50:27 pm »
Great, I will add my guide there for other to use.

Offline Callahan

  • Captain
  • ***
  • Posts: 61
    • View Profile
Re: Newbe needs info on where to find what in code
« Reply #47 on: April 06, 2018, 09:30:37 pm »
It compiled the openxcom.exe. I will compress and upload the composed MinGW and "work" folder for anyone as ready to use download to insert any OXC code the next few days. Just in case some of those download links become dead in the future.

I'll now test the exe by playing, but I have to overwrite a few things in hex editor to make it work in my Win 2000, as OXC does not normally support that OS. I'll report back here tomorrow if it is playable.

Then I can turn my attention to the code itself. I'll write in Notpad++ and compile it in MinGW.
Will take a while until I figure out what all the new C++ expressions do. The syntax is quite different from my old C++ 6.
Many thanks for all your help and patience.


Online Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3348
    • View Profile
Re: Newbe needs info on where to find what in code
« Reply #48 on: April 06, 2018, 10:23:36 pm »
It compiled the openxcom.exe. I will compress and upload the composed MinGW and "work" folder for anyone as ready to use download to insert any OXC code the next few days. Just in case some of those download links become dead in the future.

I'll now test the exe by playing, but I have to overwrite a few things in hex editor to make it work in my Win 2000, as OXC does not normally support that OS. I'll report back here tomorrow if it is playable.

Then I can turn my attention to the code itself. I'll write in Notpad++ and compile it in MinGW.
Will take a while until I figure out what all the new C++ expressions do. The syntax is quite different from my old C++ 6.
Many thanks for all your help and patience.
You can check out if NetBeans work on your machine (is based on Java), it have support for 99% thing that is used in OXCE code.
It have support for MinGW compiling and gdb debugging.

btw what you did chane in exe to run in in Win2k?
btw2 I updated https://www.ufopaedia.org/index.php/Compiling_with_MinGW_(OpenXcom) with my guide for runing it

Offline Callahan

  • Captain
  • ***
  • Posts: 61
    • View Profile
Re: Newbe needs info on where to find what in code
« Reply #49 on: April 07, 2018, 12:16:16 pm »
To get OXCE work on my win 2000, I just butchered the exe as well as several DLLs into submission.

OXCE checks for several DLLs in Windows/system32. While it is unhealthy to just copy DLLs from WinXP SP3 to Win2000, you can hex edit the exe to look for the DLLs in the wrong spot, or for a wrong filename (easiest). A fallback is then executed to look for the missing DLLs in the installation folder.
Then download the DLLs that are looked for in their WinXP SP3 version and put them into installation folder.

Next you have to hex edit those DLLs inside the installation folder to prevent themselves to look for other DLLs in Windows/system32. A wrong name works well here, too. Again a fallback is executed and the DLLs from the installation folder are used.
Once the DLLs are setup properly, one has only to edit the exe in case it is replaced.
This procedure completely bypasses the installed windows version.
It is possible this would work even down to Win95, but may require additional DLLs to be butchered. I'll test that in a quiet minute on one of my really old machines.

The new guide is great. This makes things a whole lot easier especially for people who have zero experience with MinGW compilers. Well done.

EDIT
There are a lot of differences to the exe I got from Meridian/the Piratez mod.

My exe is 17 MB instead of 11 MB, does check for additional DLLs, and does not have the alien head icon, but dos prompt icon.
I used OXCE 3.5 plus proto code from here:
https://github.com/MeridianOXC/OpenXcom/tree/oxce3.5-plus-proto
Does this difference result from different code, the compiler itself, or the makefile?
« Last Edit: April 07, 2018, 02:50:37 pm by Callahan »

Online Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3348
    • View Profile
Re: Newbe needs info on where to find what in code
« Reply #50 on: April 07, 2018, 03:09:57 pm »
one diffrence is that you compiled my branch OXCE and Meridian have OXCE+ it have more features than my branch. You can use same setup to compile his version.
adding exe icon is separate step that is not included in my guide because is not critical part.
size of exe is cause what type of compilation is used, exe from Piratez is in release mode and my makefile create debug mode, you can change this altering `CXXFLAGS ?= -Og` line.

Offline Callahan

  • Captain
  • ***
  • Posts: 61
    • View Profile
Re: Newbe needs info on where to find what in code
« Reply #51 on: April 07, 2018, 03:52:37 pm »
Thanks for the explanation. Every bit of this is quite new to me. As if I had just started programming....
And I am a bit confused over the branch used, as I used the OXCE 3.5 PLUS proto. This should have been Meridians version.
To what would I have to alter the "CXXFLAGS ?= -Og" line for a smaller release version?

I also had a bit of trouble with the syntax. It seems to rely heavily on objects. Not my strong side.
Nevertheless I changed the reaction fire system and it does now seem to be identical to DOS XC 1 & 2.
Further tests will be made by me to confirm this.
Next I'll try to make it load extra images/sprites only just before they are used. That will enable me to run the monster mod on my wimpy system.
Do you know where the function of loading the defined extra sprites/images is located?
I would also like to take a look at the function that does execute the blit on screen.
Is this just 1 function, or does geoscape and ufopedia use other blitters than battlescape?
« Last Edit: April 07, 2018, 04:12:00 pm by Callahan »

Online Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3348
    • View Profile
Re: Newbe needs info on where to find what in code
« Reply #52 on: April 07, 2018, 04:23:42 pm »
Majority of blits is done using `Surface::blitNShade` in battlescape.
And loading by `Mod::loadVanillaResources` and some others functions.

Offline Callahan

  • Captain
  • ***
  • Posts: 61
    • View Profile
Re: Newbe needs info on where to find what in code
« Reply #53 on: April 07, 2018, 06:38:54 pm »
Very good, thanks. You saved me alot of time browsing every CPP file.
That will give me a point from where to start understanding how it works.

Offline Callahan

  • Captain
  • ***
  • Posts: 61
    • View Profile
Re: Newbe needs info on where to find what in code
« Reply #54 on: April 08, 2018, 07:04:05 pm »
@Meridian.
Do you use some special makefile for compiling the OXCE 3.5 plus proto code?

I tried with several of the makefiles contained in the download as well as all CXXFLAGs from -O0 to -Og, but my exe does not shrink below 16.7 MB. Your Lucky Luke exe was only 11 MB. How did you achieve that?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9078
    • View Profile
Re: Newbe needs info on where to find what in code
« Reply #55 on: April 08, 2018, 07:27:16 pm »
@Meridian.
Do you use some special makefile for compiling the OXCE 3.5 plus proto code?

I tried with several of the makefiles contained in the download as well as all CXXFLAGs from -O0 to -Og, but my exe does not shrink below 16.7 MB. Your Lucky Luke exe was only 11 MB. How did you achieve that?

I use makefile.mxe from Yankes:

Details attached here: https://openxcom.org/forum/index.php/topic,2915.msg61137.html#msg61137

https://github.com/MeridianOXC/OpenXcom/blob/oxce3.5-plus-proto/src/Makefile.mxe

PS: don't know what the difference could be... maybe you have older version of yaml-cpp which still has Boost...

Offline Callahan

  • Captain
  • ***
  • Posts: 61
    • View Profile
Re: Newbe needs info on where to find what in code
« Reply #56 on: April 08, 2018, 07:43:57 pm »
Thanks, that's an interesting discussion.
I got yaml-cpp from here:
https://github.com/jbeder/yaml-cpp/archive/master.zip
No idea if this is a version with/without boost. I'm totally new to yaml and MinGW.

I'll also try if I can get this MXE build chain to work in my windows.
I'm really jealous. Your work is so small and elegant, while I feel like a bull in a china shop with my oversized and cumbersome build. I still need to learn alot more.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9078
    • View Profile
Re: Newbe needs info on where to find what in code
« Reply #57 on: April 08, 2018, 08:01:58 pm »
Master yaml-cpp is without Boost, since 2016 or so... so that wouldn't be an issue.

Maybe because you're doing a "debug build" instead of a "release build"?

Online Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3348
    • View Profile
Re: Newbe needs info on where to find what in code
« Reply #58 on: April 09, 2018, 01:28:51 am »
@Callahan try use `-O3  -s` and probably more immorality size of exe is irrelevant, i have 500MiB exes when build local debug... and it still work fine.
Simply different lib set could make it too, as long everything work fine, difference in size should be ignored.

Offline Callahan

  • Captain
  • ***
  • Posts: 61
    • View Profile
Re: Newbe needs info on where to find what in code
« Reply #59 on: April 09, 2018, 12:43:29 pm »
Confusing. Using O3 -s increased the size of the exe by 0.3 MB.
Dissecting the exe, I found the main trouble to be "AddVectoredExceptionHandler" and "RemoveVectoredExceptionHandler" of Kernel32.dll / Kernel32.lib. They are not existent in the Kernel of my Win 2k, but only in my transplanted DLLs.
I also suffer a very notable performance loss using my own exe, probably because of these not native functions.

I have identified them to be part of the MinGW-64 defines, Bin, Include and Lib. I'll try to manually remove them from the MinGW files to stop the linker from adding them.
Patching the content of my MinGW-64 with old stuff from MinGW32 may do the trick better yet.
Does anyone have those files available? The installer for the old MinGW version is offline.

@Meridian, it might be you have those files for compiling.
Can you check if you have the files:
libwinpthread-1.dll
errhandlingapi.h
libkernel32.a
libntdll.a
libpthread.a
libwinpthread-1.dll
libwinpthread.a
libwinpthread-1.dll

I also added my exe with the new reaction fire system. I should be closer to OG from what I've seen in the few test I made yet.