thobbsinteractive / magic-carpet-2-hd

Recode Binary code of game Magic Carpet2 to C/C++ language(remake MC2 for any platform)
GNU General Public License v3.0
30 stars 4 forks source link

On ARM systems the game crashes going to in the map screen #114

Open GrimSqueaker opened 2 years ago

GrimSqueaker commented 2 years ago

I have tried to build on Raspberry Pi OS 11 (32 bit). The build works fine and the game can reach the main menu. Intro videos play well. But there are graphical glitches in the main menu and the level selection screen cannot be reached (segfault). This issue is intended to report the current state and maybe track progress to get the game running on ARM. 2022-07-20-234234

thobbsinteractive commented 2 years ago

It is awesome that you tried this!

thobbsinteractive commented 2 years ago

Can we close this now with the latest merge?

GrimSqueaker commented 2 years ago

No, this is more of a long term project to figure out all the needed fixes for ARM builds. The last merge was unrelated to this here.

vanfanel commented 2 years ago

On my experience, If something works perfectly on X86_64 but doesn't work well on aarch64, it's usually because of char signedness: on arm, plain char is unsigned, while on x86 it's signed.

GrimSqueaker commented 2 years ago

Thanks for the hint. I did not know that. And this will most probably be a problem in our code base.

thobbsinteractive commented 2 years ago

So I am trying to get it to build on the Pi 4 (which is Arm64), I will have another go this weekend. I ran into some errors finding SDL but I think it was looking for source directory we have in our source as the Pi comes with SDL2 installed.

vanfanel commented 2 years ago

System-installed SDL2 is the way to go: I for one use SDL2 with KMS/DRM enabled.

thobbsinteractive commented 2 years ago

@vanfanel we could maybe fix that by replacing all chars with int8_t as most of the time it is either a number or a pointer to a memory address. If I can get it to compile, I will try this.

vanfanel commented 2 years ago

@thobbsinteractive Yes, that should fix the ARM-specific issues, as far as I know. I will test if you try to fix it!

thobbsinteractive commented 2 years ago

So even though I used apt-get to get the sdl2 library I seem to be getting this error, which probably means I have some environment vars unset or need to build SDL2?

CMake Error at /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message): Could NOT find SDL2 (missing: SDL2_LIBRARY SDL2_INCLUDE_DIR) Call Stack (most recent call first): /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE) cmake/sdl2/FindSDL2.cmake:313 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) CMakeLists.txt:22 (find_package)

thobbsinteractive commented 2 years ago

So i need to tell cmake to find sdl2 in CMakeCache.txt?

GrimSqueaker commented 2 years ago

Hi @thobbsinteractive , no, that should not be necessary. Did you install the devel packages? I think those were all the libs I needed to install:

sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libpng-dev libpng++-dev libboost-system-dev
thobbsinteractive commented 2 years ago

No I did not. My mistake lol. I am new to the linux world,

GrimSqueaker commented 2 years ago

No problem. We could give this command line as an example for debian-based systems in the readme.md. On my main system (Fedora) the packages have different names. That is why I vaguely wrote "install the dev packages of these libs".

thobbsinteractive commented 2 years ago

Yeah I figured. I was thinking of putting a link to the pi/debian? install instructions rather than have it on the main readme page.

thobbsinteractive commented 2 years ago

or we make a bash script to do it

thobbsinteractive commented 2 years ago

Now I am getting this crap. apt does not seem to have an entry for findfirst

CMake Error at remc2/CMakeLists.txt:148 (add_library):
  Cannot find source file:
 ../findfirst/findfirst.c

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx

CMake Error at remc2/CMakeLists.txt:148 (add_library):
  No SOURCES given to target: findfirst
GrimSqueaker commented 2 years ago

Did you init the submodule whilst cloning the repo? If not, you have to do it manually. I do not know how VSCode handles this. Just do the following in the working copy of the repo

git submodule init
git submodule update
thobbsinteractive commented 2 years ago

It should be in the repo. It would seem it was not pulled down with the rest of the code for some reason

GrimSqueaker commented 2 years ago

Findfirst comes with our repo as a git submodule to the github repo of findfirst. In my "remc2clean" repo I replaced all file accesses by C++17 code and did not need it as a dependency. I am planning to do the same here in the future.

GrimSqueaker commented 2 years ago

Btw.: we should have a slack channel or some other chat tool for these discussions :-)

thobbsinteractive commented 2 years ago

Yeah I was thinking we need slack or discord when I was saying to tom yesterday about testing multi-player. So @GrimSqueaker @turican0, Slack or Discord? Discord is more games orientated, but I know Slack better from work.

thobbsinteractive commented 2 years ago

This is strange I cannot pull the contents of /findfirst onto the Pi. It is fine in the development branch on my windows machine. But I have tried deleting and re-cloning the repo and it will not pull the contents of /findfirst. It is the strangest thing

thobbsinteractive commented 2 years ago

So I copied to a memory stick and got it on the pi that way. Maybe it is because it is a git repo, has a .get file and needs to be pull itself?

GrimSqueaker commented 2 years ago

The git submodule commands from above should initialise the submodule and provide you with the contents of that directory. Alternatively, you can also initialise them during cloning:

    git clone --recurse-submodules https://github.com/thobbsinteractive/magic-carpet-2-hd.git
GrimSqueaker commented 2 years ago

I have not used Slack and Discord before. Just pick any and I will join there.

thobbsinteractive commented 2 years ago

Okay. I will set up something today.

turican0 commented 2 years ago

Like GrimSqueaker, I don't use either, but I have no problem signing up somewhere.

thobbsinteractive commented 2 years ago

Here it is: https://discord.gg/mFMRUVeu I have a PR to include it in the Readme

thobbsinteractive commented 2 years ago

So my current plan is to convert all the left and right shifted bits to their likely original calculations. E.g. (n << 1) is actually (n * 2). I will also to look at the flow, as the level loading screen is showing and not the map/level selection screen indicating some sort of flow issue, likely to do with indexing