ptitSeb / Eldritch

Eldritch port to the OpenPandora (meaning Arm / GLES2 / OpenAL): Status Working (with latest data file from Steam)
https://boards.openpandora.org/topic/18323-eldritch/
Other
4 stars 2 forks source link

AmigaOS4 (or general): "Ressurect in Asylum" didn't work #8

Closed kas1e closed 3 years ago

kas1e commented 4 years ago

Find out (At least on AmigaOS4), that if we go for example left/left in the first level to the table with a pumpkin head, and press "f" there so go to a new level and then die there, we have a question: resurrect or resurrect in Asylum. If I choose pure resurrect, then all fine, the game starts from the beginning, if we choose to resurrect in Asylum, then nothing changes. In console I have :

"Warn failed: "false" () in unknown fucntion in code/Projects/Eldritch/src/eldritchgame.cpp at line 275.

kas1e commented 4 years ago

Oh, I find out the more easy way to check: just go forward, then right, and one of the books asks you "You will lose your current progress when you enter the Asylum. Are you sure you wish to enter ?" And pressing "YES" do nothing the same, and bring the same warning in the same file.

kas1e commented 4 years ago

Btw, this one works on pandora? I assume it may work because when we fix before endian issues with the master.save the file, it also brings warnings of such kind. I can make a video to show in which direction need to go to meet that error (will be easy for you to see where it happens, as my English-kind explains can be not good enough:) )

kas1e commented 3 years ago

I assume this "resurrect on asylum" also didn't work on Pandora?

Anyway, with that fix from Rajdakin: https://github.com/rajdakin/Eldritch/commit/488083103780a6e9bf0bde5878047feaea61bec0

This one also didn't crash anymore, but instead give me "Tried to reinitialize nullptr". So for some reason, when we tried to load the "asylum" level, we by some reason have nullptr.

kas1e commented 3 years ago

I also made a video to show how/where from the beginning of the game found that "asylum" level (to compare how it now, and how it in PC version where new level starts). Not sure how it on Pandora, but IMHO the same didn't work as on AmigaOS. Sorry for the low-quality video, but necessary things can be seen still: https://youtu.be/3xLRHrrMR0Y

rajdakin commented 3 years ago

I've done a quick debug on the issue, and it was due to the level not having a name (and trying to load "" can be quite hard...). I hope that this is fixed in the 2019 release (which is not far from being done, at least the first pass... I'll need to make sure it can compile first though, both on my computer and on Pandora).

kas1e commented 3 years ago

and it was due to the level not having a name

Hm, but in their data files, there is an Asylum level present? If so, maybe we can just put the necessary name into the code (at least for time being to make it works)?

rajdakin commented 3 years ago

Well, I didn't see anything indicating there was an asylum (though I couldn't find the string either... Maybe I looked at the wrong place). Also, I don't know where to put the level string (if it is as simple as that), since levels are binary data... In any case, I'm mostly done with the porting of the old changes to the 2019 version, after that I'll need to fix all compiler errors on my computer and finally on Pandora, and I'll push what I get on Github afterward (maybe that'll be tomorrow though).

kas1e commented 3 years ago

Woah, cool! That with big-endian amigaos4 changes too? Or without?

rajdakin commented 3 years ago

Yes, I git diffed all commits made to the repo from the initial commit up to master (except for that one where everything was reformatted...) and I'm manually reporting the changes to the 2019 source code (I think only 10-ish files are left now, and not the biggest ones, 3D is already done). After that there will be some CMakeLists.txt to add, and then a cycle of make and fixes. (I'll very likely finish it tomorrow though.)

ptitSeb commented 3 years ago

Hey @kas1e , with rajdakin hard work on the merging of the source, this Eldrich version is now able to use latest data from HumbleBundle or Steam. You should try it on Amiga quickly, while rajdakin is still in holyday this week, in case there are some BigEndian adjustments to do ;)

kas1e commented 3 years ago

@ptitSeb I am not at home for the next 5 days, but I tried to build it still on cross-compiler, and have found that at least there issue with one big-endian part on compiling stage: meshfactory.cpp , on the lines from 1614 till 1625 saying Animations not declared.

kas1e commented 3 years ago

@all Checked latest sources, when tried to build also have that:

[  0%] Building CXX object Libraries/Core/CMakeFiles/Core.dir/src/allocator.cpp.obj
In file included from /amiga/Eldritch-master/code/Libraries/Core/src/allocator.cpp:4:
/amiga/Eldritch-master/code/Libraries/Core/src/idatastream.h:54:26: error: ‘uint8’ has not been declared
   54 |  inline void WriteUInt8( uint8 i ) const { Write( 1, &i ); }
      |                          ^~~~~
/amiga/Eldritch-master/code/Libraries/Core/src/idatastream.h:55:27: error: ‘uint16’ has not been declared
   55 |  inline void WriteUInt16( uint16 i ) const { littleBigEndian( &i ); Write( 2, &i ); }
      |                           ^~~~~~
/amiga/Eldritch-master/code/Libraries/Core/src/idatastream.h:56:27: error: ‘uint32’ has not been declared
   56 |  inline void WriteUInt32( uint32 i ) const { littleBigEndian( &i ); Write( 4, &i ); }
      |                           ^~~~~~
/amiga/Eldritch-master/code/Libraries/Core/src/idatastream.h:57:25: error: ‘int8’ has not been declared
   57 |  inline void WriteInt8( int8 i ) const { Write( 1, &i ); }
      |                         ^~~~
/amiga/Eldritch-master/code/Libraries/Core/src/idatastream.h:58:26: error: ‘int16’ has not been declared
   58 |  inline void WriteInt16( int16 i ) const { littleBigEndian( &i ); Write( 2, &i ); }
      |                          ^~~~~
/amiga/Eldritch-master/code/Libraries/Core/src/idatastream.h:59:26: error: ‘int32’ has not been declared
   59 |  inline void WriteInt32( int32 i ) const { littleBigEndian( &i ); Write( 4, &i ); }

Probabaly that because there all ints/units etc now are c_uint8, etc ?

rajdakin commented 3 years ago

Yes, indeed. Did you compile it with -k (are they the only errors)? In either case, could you try again with the change? (I pushed the change on my side, under the fix8 branch, but you can also manually edit it for now. Also, there is one error missing here, in the WriteHashedString function.) EDIT: there is also a bug I just fixed (on my branch), when reading a HashedString.

kas1e commented 3 years ago

@rajdakin Tried fix8, yeah, this uint/int issues gone. Next one

code/Libraries/Core/src/idatastream.h:144:20: error: ‘i’ was not declared in this scope
  144 |   littleBigEndian(&i);

As far as I can see should be f

Next error is in "allocator.h" and "allocator.cpp", also gl2texture and gl2cubesphera about error: ‘uintptr_t’ does not name a type. I fixed that by adding #include <stdint.h> to allocator.h at top. And the same #include <stdint.h> at top of idatastream.h

Another few errors is about few unimplemented functions in fileutil.cpp and timedate.cpp _ timedate.h. The all can be fixed by changing all #elif BUILD_LINUX || BUILD_MAC on #elif BUILD_LINUX || BUILD_MAC || __amigaos4__

Another error in meshfactory.cpp:1465:27 :

code/Libraries/3D/src/meshfactory.cpp:1465:27: error: ‘struct SCompiledMeshHeader’ has no member named ‘m_NumCollisionTris’; did you mean ‘m_PADDING_NumCollisionTris’?
 1465 |  littleBigEndian( &Header.m_NumCollisionTris );
      |                           ^~~~~~~~~~~~~~~~~

That seems because in v8 fixes about Pading didn't fits ?

rajdakin commented 3 years ago

OK, I've fixed those issues and pushed the changes on my branch, could you test it now? (Also, the error was because of // For compatibility with legacy meshes.) If I missed any error, please tell me.

kas1e commented 3 years ago

Thanks, tested new v8:

allocator.h still need #include <cstdint> too

and then fileutil.cpp also need those changes with adding || __amigaos4__ on the lines 386 and 468

After fixing that, i were able to build all source code. Thorugh i fail on linking with:

../../Libraries/SoLoud/libSoLoud.a(soloud.cpp.obj): In function `_ZN6SoLoud6Soloud4initEjjjjj':
soloud.cpp:(.text+0x56c): undefined reference to `_ZN6SoLoud8sdl_initEPNS_6SoloudEjjjj'

But that i need to check on my side, probabaly some missing define somewhere.. Maybe i need to add some additional flag to Cmake line now ?

rajdakin commented 3 years ago

I don't think allocator.h needs this include, what is the error there? (I've built using -D__amigaos4__ and I didn't get any error...) What sound backend are you using? (eg, which WITH_ is enabled?)

kas1e commented 3 years ago

I don't think allocator.h needs this include, what is the error there? (I've built using -Damigaos4 and I didn't get any error...)

Same as when there is no include of cstdint in other ones:

user@DESKTOP-3NFAB0O /amiga/Eldritch-fix8/code/build
$ make Eld
Consolidate compiler generated dependencies of target UI
[  5%] Built target UI
Consolidate compiler generated dependencies of target Core
[  5%] Building CXX object Libraries/Core/CMakeFiles/Core.dir/src/allocator.cpp.obj
[  6%] Building CXX object Libraries/Core/CMakeFiles/Core.dir/src/allocatorchunk.cpp.obj
/amiga/Eldritch-fix8/code/Libraries/Core/src/allocatorchunk.cpp: In member function ‘void AllocatorChunk::SplitToAlignment(AllocatorChunk::SAllocatorBlock*, uint)’:
/amiga/Eldritch-fix8/code/Libraries/Core/src/allocatorchunk.cpp:293:58: error: ‘uintptr_t’ does not name a type
  293 |  const uint AlignPad    = Alignment - ( reinterpret_cast<uintptr_t>( reinterpret_cast<byte*>( BlockToSplit ) + ( Allocator::m_BlockHeaderSize << 1 ) ) % Alignment );
      |                                                          ^~~~~~~~~
/amiga/Eldritch-fix8/code/Libraries/Core/src/allocatorchunk.cpp: In member function ‘bool AllocatorChunk::CanSplitToAlignment(const AllocatorChunk::SAllocatorBlock*, uint, uint) const’:
/amiga/Eldritch-fix8/code/Libraries/Core/src/allocatorchunk.cpp:324:51: error: ‘uintptr_t’ does not name a type
  324 |  uint AlignPad   = Alignment - ( reinterpret_cast<uintptr_t>( reinterpret_cast<const byte*>( BlockToSplit ) + ( Allocator::m_BlockHeaderSize << 1 ) ) % Alignment );
      |                                                   ^~~~~~~~~
/amiga/Eldritch-fix8/code/Libraries/Core/src/allocatorchunk.cpp: In member function ‘bool AllocatorChunk::IsAligned(const AllocatorChunk::SAllocatorBlock*, uint) const’:
/amiga/Eldritch-fix8/code/Libraries/Core/src/allocatorchunk.cpp:358:28: error: ‘uintptr_t’ does not name a type
  358 |  return ( reinterpret_cast<uintptr_t>( reinterpret_cast<const byte*>( pBlock ) + Allocator::m_BlockHeaderSize ) % Alignment ) == 0;
      |                            ^~~~~~~~~
make[3]: *** [Libraries/Core/CMakeFiles/Core.dir/build.make:132: Libraries/Core/CMakeFiles/Core.dir/src/allocatorchunk.cpp.obj] Error 1
make[2]: *** [CMakeFiles/Makefile2:350: Libraries/Core/CMakeFiles/Core.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:629: Projects/Eld/CMakeFiles/Eld.dir/rule] Error 2
make: *** [Makefile:254: Eld] Error 2

As for the sound: dunno, I run CMAKE as before, like this for the moment:

cmake \
-DCMAKE_SYSTEM_NAME=Generic \
-DCMAKE_SYSTEM_VERSION=1 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER="/usr/local/amiga/bin/ppc-amigaos-gcc" \
-DCMAKE_CXX_COMPILER="/usr/local/amiga/bin/ppc-amigaos-g++" \
-DCMAKE_CXX_FLAGS="-D__USE_AMIGAOS_NAMESPACE__" \
-DCMAKE_LINKER="/usr/local/amiga/bin/ppc-amigaos-ld" \
-DCMAKE_AR="/usr/local/amiga/bin/ppc-amigaos-gcc-ar" \
-DCMAKE_RANLIB="/usr/local/amiga/bin/ppc-amigaos-gcc-ranlib" \
-DCMAKE_FIND_ROOT_PATH="/usr/local/amiga/ppc-amigaos/" \
-DGLES=ON \
..

I probably better to use SDL2 sound backend, should i add something like -DWITH_SDL=ON ?

rajdakin commented 3 years ago

Ah, so allocatorchunk.cpp needs it then.

SDL cannot compile (missing #define...), so if you want to use SDL, use SDL2 (-DWITH_SDL2=ON). However, you must already have one backend enabled (otherwise, SoLoud wouldn't even start to compile): run ccmake .. instead to see the cache (or read CMakeCache.txt to find the enabled backend).

kas1e commented 3 years ago

Seems with -DWITH_SDL2=ON it want to use shared version of SDL2 , while i can only use static one. Will check with SDL2_STATIC

rajdakin commented 3 years ago

Don't forget to turn the unwanted backends OFF after (they are kept in the cache).

kas1e commented 3 years ago

Yeah, with -DWITH_SDL2_STATIC=ON \ all compiles and links. So, just a fix in allocatorchunk.cpp need it, and after 2 days will be at home can check if binary works at all :)

kas1e commented 3 years ago

Btw, is "resurrect to Asylum" works on Pandora with the latest version we have now + latest Steam files?

kas1e commented 3 years ago

@All Ok, i tried amigaos4 binary today: crashes on running in the CreateSplashWindow, with saying in the console:

Using display mode 800x600
Asserion failed: "BitCount == 32" ()
in unknow function in code/libraries/3d/src/surface.cpp at line 426
Assertion failed: "m_Surface" ()
in unknown function in code/libraryed/3d/src/surface.cpp at line 287

Probably related to some latest change done about removing splash screen?

rajdakin commented 3 years ago

This diff should fix it:

diff --git a/Code/Libraries/3D/src/surface.cpp b/Code/Libraries/3D/src/surface.cpp
index 1b8a5bf..7e5c44d 100644
--- a/Code/Libraries/3D/src/surface.cpp
+++ b/Code/Libraries/3D/src/surface.cpp
@@ -111,6 +111,24 @@ int Surface::LoadBMP( const IDataStream& Stream )

        Stream.Read( sizeof( SBitmapFileHeader ), &BMPFileHeader );
        Stream.Read( sizeof( SBitmapInfoHeader ), &BMPInfoHeader );
+#ifdef __amigaos4__
+       littleBigEndian( &BMPFileHeader.m_Type );
+       littleBigEndian( &BMPFileHeader.m_Size );
+       littleBigEndian( &BMPFileHeader.m_Reserved1 );
+       littleBigEndian( &BMPFileHeader.m_Reserved2 );
+       littleBigEndian( &BMPFileHeader.m_OffsetBits );
+       littleBigEndian( &BMPInfoHeader.m_Size );
+       littleBigEndian( &BMPInfoHeader.m_Width );
+       littleBigEndian( &BMPInfoHeader.m_Height );
+       littleBigEndian( &BMPInfoHeader.m_Planes );
+       littleBigEndian( &BMPInfoHeader.m_BitCount );
+       littleBigEndian( &BMPInfoHeader.m_Compression );
+       littleBigEndian( &BMPInfoHeader.m_SizeImage );
+       littleBigEndian( &BMPInfoHeader.m_PixelsPerMeterX );
+       littleBigEndian( &BMPInfoHeader.m_PixelsPerMeterY );
+       littleBigEndian( &BMPInfoHeader.m_ColorUsed );
+       littleBigEndian( &BMPInfoHeader.m_ColorImportant );
+#endif

        // Support extensions by reading whatever is available into header
        SBitmapInfoHeaderExt    BMPInfoHeaderExt = { 0 };
@@ -121,6 +139,23 @@ int Surface::LoadBMP( const IDataStream& Stream )
        if( Remaining > 0 )
        {
                Stream.Read( Min( SizeOfExt, Remaining ), &BMPInfoHeaderExt );
+#ifdef __amigaos4__
+       littleBigEndian( &BMPInfoHeaderExt.m_RedMask );
+       littleBigEndian( &BMPInfoHeaderExt.m_GreenMask );
+       littleBigEndian( &BMPInfoHeaderExt.m_BlueMask );
+       littleBigEndian( &BMPInfoHeaderExt.m_AlphaMask );
+       littleBigEndian( &BMPInfoHeaderExt.m_ColorSpaceType );
+       littleBigEndian( &BMPInfoHeaderExt.m_EndpointsX );
+       littleBigEndian( &BMPInfoHeaderExt.m_EndpointsY );
+       littleBigEndian( &BMPInfoHeaderExt.m_EndpointsZ );
+       littleBigEndian( &BMPInfoHeaderExt.m_GammaRed );
+       littleBigEndian( &BMPInfoHeaderExt.m_GammaGreen );
+       littleBigEndian( &BMPInfoHeaderExt.m_GammaBlue );
+       littleBigEndian( &BMPInfoHeaderExt.m_Intent );
+       littleBigEndian( &BMPInfoHeaderExt.m_ProfileData );
+       littleBigEndian( &BMPInfoHeaderExt.m_ProfileSize );
+       littleBigEndian( &BMPInfoHeaderExt.m_Reserved );
+#endif
                Remaining -= SizeOfExt;
                NeedsSwizzle = true;    // HACKHACK, see below

@@ -352,10 +387,19 @@ void Surface::SaveBMP( const IDataStream& Stream )
        Header.m_Type           = 'MB';
        Header.m_Size           = static_cast<uint>( 54 + Size );
        Header.m_OffsetBits     = 54;
+#ifdef __amigaos4__
+       littleBigEndian( &m_BitmapInfo.m_Header.m_SizeImage );
+       littleBigEndian( &Header.m_Type );
+       littleBigEndian( &Header.m_Size );
+       littleBigEndian( &Header.m_OffsetBits );
+#endif

        Stream.Write( sizeof( SBitmapFileHeader ), &Header );
        Stream.Write( sizeof( SBitmapInfoHeader ), &m_BitmapInfo.m_Header );
        Stream.Write( Size, m_pPixels );
+#ifdef __amigaos4__
+       littleBigEndian( &m_BitmapInfo.m_Header.m_SizeImage );
+#endif
 }

 // This assumes that both Surfaces are the same format and bit depth

The issue is simply that some data is still read as little-endian on a big-endian machine... I'm also pushing the change on the fix8 branch on my fork.

kas1e commented 3 years ago

This diff should fix it

Right! The game starts now for sure!

Through I have no sound in-game, and it brings me in the console that:

Assertion failed: "Result = SoLoud::SO_NO_ERROR"()
in unknown function in code/Libraries/Audio/src/soloudsound.cpp at line 100
Assertion failed: "Result == SoLoud::SO_NO_ERROR"()
in unknown function in code/Libraries/Audio/src/soloudsound.cpp at line 127

While I build everything with -DWITH_SDL2_STATIC=ON \

But what is good, is that we have no more issues with colors in the game! It looks as expected! And "resurrect to asylum" also works! Yeah!

The only real issue I have now is the speed of the scenes where I have enemies and a more or less complex world: slow pretty much. I fear it can be because of big-endian changes on the fly for everything? Like for meshes, etc? I will try to play now with disabling things to see if it changes anyhow. Even fade-in/fade-out effects at the beginning of logos not that fast, but that may be because of no sound?

rajdakin commented 3 years ago

For sound not working, that is strange indeed... Maybe an issue with endianness? Though, SDL should be able to compensate for that... As for playability, unfortunately I think it's simply a matter of the game needing a too powerful cpu/gpu... (Not an issue with endianness conversion though, that I'm sure of.)

rajdakin commented 3 years ago

I think I've found the source of the sound bug, though I'm not sure it'll work... I've also pushed the diff onto my branch.

diff --git a/Code/Libraries/SoLoud/src/core/soloud_file.cpp b/Code/Libraries/SoLoud/src/core/soloud_file.cpp
index c38f4b9..2f86911 100644
--- a/Code/Libraries/SoLoud/src/core/soloud_file.cpp
+++ b/Code/Libraries/SoLoud/src/core/soloud_file.cpp
@@ -53,6 +53,26 @@ namespace SoLoud
                return d;
        }

+       unsigned int DiskFile::read16()
+       {
+               unsigned short d = 0;
+               read((unsigned char*)&d, 2);
+#ifdef __amigaos4__
+               d = (d >> 8) | (d << 8);
+#endif
+               return d;
+       }
+
+       unsigned int DiskFile::read32()
+       {
+               unsigned int d = 0;
+               read((unsigned char*)&d, 4);
+#ifdef __amigaos4__
+               d = (d >> 24) | ((d >> 8) & 0xFF00) | ((d << 8) & 0xFF0000) | (d << 24);
+#endif
+               return d;
+       }
+

        unsigned int DiskFile::read(unsigned char *aDst, unsigned int aBytes)
        {
@@ -293,4 +313,4 @@ extern "C"
                }
                return (Soloud_Filehack*)df;
        }
-}
\ No newline at end of file
+}
diff --git a/Code/Libraries/SoLoud/src/soloud_file.h b/Code/Libraries/SoLoud/src/soloud_file.h
index 2bc3e18..c18955c 100644
--- a/Code/Libraries/SoLoud/src/soloud_file.h
+++ b/Code/Libraries/SoLoud/src/soloud_file.h
@@ -37,8 +37,8 @@ namespace SoLoud
        public:
                virtual ~File() {}
                unsigned int read8();
-               unsigned int read16();
-               unsigned int read32();
+               virtual unsigned int read16();
+               virtual unsigned int read32();
                virtual int eof() = 0;
                virtual unsigned int read(unsigned char *aDst, unsigned int aBytes) = 0;
                virtual unsigned int length() = 0;
@@ -53,6 +53,8 @@ namespace SoLoud
        public:
                FILE *mFileHandle;

+               virtual unsigned int read16();
+               virtual unsigned int read32();
                virtual int eof();
                virtual unsigned int read(unsigned char *aDst, unsigned int aBytes);
                virtual unsigned int length();
kas1e commented 3 years ago

@rajdakin Thanks for trying, but nope, same error :( On the same line 127 and line 100 of soloudsound.cpp

Maybe issue is loadFile() for example ? And needs for "PROGDIR:" or something?

kas1e commented 3 years ago

@rajdakin As I see in the log of dos-tracer on my side, it fails to open both sounds. I mean:

FAIL = Open("Audio/music-swapm-2.ogg")
FAIL = Open("Audio/watson-prime.ogg")

While eldritch-audio.cpk surely found and opened

rajdakin commented 3 years ago

Ah, maybe I misinterpreted the classes names... Try now (I changed the same two files as above, but I reverted one commit. If you use git to pull from my branch, you'll probably have to do git checkout origin/fix8 && git branch -f fix8 HEAD && git checkout fix8 after git pulling.)

kas1e commented 3 years ago

@rajdakin Yes! Sound works now on my side! Cool!

As for the speed: I have 2 GHZ CPU + Radeon RX 560, so there shouldn't be issues with raw CPU/GPU power. We surely have issues with missing DMA in drivers, that alone can cause issues, but I still think the issue can be somewhere in the code of the game (maybe not Endian ones, but that needs to double-recheck from my side).

Why I think there some issues with code: because I didn't have more than 80% of CPU loading. I may try for sake of tests to disable some big-endian changes in colors (for meshes, etc), to see, if it will be faster with the wrong colors or not.

Anyway, at the moment the only issue is speed, I need to check more of course, but briefly: colors fine, resurrect to asylum works, sound now works too, etc. So, if you don't mind I want to donate to your work :) Can you share your PayPal acc plz? Thanks!

Also, maybe you want to get another 50-100$ to add a little bit to GL4ES named "shadows"? If you interesting i can bring more details about it.

rajdakin commented 3 years ago

Great! Well, I can't open a Paypal account (because I'm underage). You can put the money in @ptitSeb's account though, and he will transfer the money to me. With that said, I won't have time to add shadows to gl4es because school will resume tomorrow... Maybe later, but for now I can't do it.

kas1e commented 3 years ago

@ptitSeb and rajdakin As promised donated, thanks a bunch!

ptitSeb commented 3 years ago

Thanks for him, I'll give him cash :)

kas1e commented 3 years ago

If you consider adding those "shadows" in gl4es (for friking shark, etc), I will happy to donate another 50-100$ :)