Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add platform "MorphOS" #9294

Draft
wants to merge 29 commits into
base: master
Choose a base branch
from
Draft

Add platform "MorphOS" #9294

wants to merge 29 commits into from

Conversation

BeWorld2018
Copy link

@BeWorld2018 BeWorld2018 commented Nov 23, 2024

MorphOS is PPC 32bit bigendian machine (like AmigaOS system)

To build it : make PLATFORM=morphos

@BeWorld2018 BeWorld2018 changed the title Add plaform "MorphOS" Add platform "MorphOS" Nov 23, 2024
Copy link
Collaborator

@oleg-derevenetz oleg-derevenetz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi all,

@BeWorld2018 first of all, thanks for your contribution efforts. Personally, I think that the proposed platform is quite exotic and have significant differences from POSIX in terms of filesystem structure, for instance. I'm not sure if it's worth adding support for such exotic platforms to the main codebase, because there will be issues with supporting this code - MorphOS is a proprietary platform for specific hardware, and I suspect that there are very few people who will be able to, say, test new code or changes in the existing code. The matter is complicated by the fact that, as far as I can see, the proposed changes are not "universal" changes, they are rather "ad hoc" changes.

Alternatively, if MorphOS has its own package manager, I would suggest the author to make and maintain a package (or a separate port) that will contain the necessary patches without integrating them into main codebase.

@ihhub what do you think?

Comment on lines +823 to +830
#if defined( _WIN32 ) || defined( __MORPHOS__ )
if ( fheroes2::cursor().isSoftwareEmulation() ) {
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
}
else {
flags |= SDL_WINDOW_FULLSCREEN;
}
#else

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is wrong and breaks platforms other than Windows or MorphOS.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @BeWorld2018 , please address this comment.

@@ -1090,7 +1090,7 @@ namespace

uint32_t flags = SDL_WINDOW_SHOWN;
if ( isFullScreen ) {
#if defined( _WIN32 )
#if defined( _WIN32 ) || defined( __MORPHOS__ )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use SDL_WINDOW_FULLSCREEN on MorphOS and not SDL_WINDOW_FULLSCREEN_DESKTOP? SDL_WINDOW_FULLSCREEN tends to alter the video card settings and does not work well with multimonitor configurations. On the contrary, we would like to throw the SDL_WINDOW_FULLSCREEN out some day.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SDL_WINDOW_FULLSCREEN on MorphOS use a real new screen, fullscreen desktop use window with no borderless and fullsize...

@@ -105,6 +116,10 @@

#include "math_base.h"

#ifdef __MORPHOS__
#undef tell
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Macros of this kind are always "nice", yeah :)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it done? o_O

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ihhub that's because somewhere inside the system headers of this platform, there is a preprocessor macro with the name tell. Macros have no idea about scopes, namespaces or class methods, which will break the build if your class has its own method with the same name, for instance. Of course, it cannot be said that this is a plus for the platform.

src/engine/system.cpp Outdated Show resolved Hide resolved
src/engine/system.cpp Outdated Show resolved Hide resolved
src/engine/system.cpp Outdated Show resolved Hide resolved
@@ -29,6 +29,10 @@
#include <zconf.h>
#include <zlib.h>

#ifdef __MORPHOS__
#undef bind
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah... not nice :-) releated with zlib.h from system headers (shared library)

#define STRINGIFY( x ) #x
#define TOSTRING( x ) STRINGIFY( x )
#define __AMIGAVER__ TOSTRING( MAJOR_VERSION ) "." TOSTRING( MINOR_VERSION ) "." TOSTRING( INTERMEDIATE_VERSION )
unsigned long __stack = 1024 * 1024;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this some sort of "service variable"?

#define TOSTRING( x ) STRINGIFY( x )
#define __AMIGAVER__ TOSTRING( MAJOR_VERSION ) "." TOSTRING( MINOR_VERSION ) "." TOSTRING( INTERMEDIATE_VERSION )
unsigned long __stack = 1024 * 1024;
static const std::string morphos_versions_tag = "$VER: fheroes2 " __AMIGAVER__ " (" __AMIGADATE__ ")";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where exactly is this variable used and for what?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specific MorphOS to put version string into executable

COUT( GetCaption() )

#endif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the issue with this call on MorphOS?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

open shell directly with title :-)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BeWorld2018 , is it true that logging just opens a shell command?

@ihhub
Copy link
Owner

ihhub commented Nov 24, 2024

Hi all,

@BeWorld2018 first of all, thanks for your contribution efforts. Personally, I think that the proposed platform is quite exotic and have significant differences from POSIX in terms of filesystem structure, for instance. I'm not sure if it's worth adding support for such exotic platforms to the main codebase, because there will be issues with supporting this code - MorphOS is a proprietary platform for specific hardware, and I suspect that there are very few people who will be able to, say, test new code or changes in the existing code. The matter is complicated by the fact that, as far as I can see, the proposed changes are not "universal" changes, they are rather "ad hoc" changes.

Alternatively, if MorphOS has its own package manager, I would suggest the author to make and maintain a package (or a separate port) that will contain the necessary patches without integrating them into main codebase.

@ihhub what do you think?

Hi @oleg-derevenetz , we are open to expand the range of supported platforms but as you noted it has to be done in a proper way that someone must maintain the code in a proper shape and up to date to avoid any issues and subsequent blame of the core team if a platform fails to support the engine.

@BeWorld2018 , could you please address the given comments. In order to accept the changes for the new platform we should have approved source code changes. Other things are missing in this pull request:

  • lack of prove that the code is indeed compilable on MorphOS platform. Could you please do the research if any of GitHub actions support this platform? If yes how long it takes to compile fheroes2 using the actions?
  • we need to expand the documentation to explain how to compile the engine for this platform. Please takes a look at https://github.com/ihhub/fheroes2/blob/master/docs/DEVELOPMENT.md
  • how to compile SDL 2 on MorphOS? Does it have a package manager which can provide SDL2 package?
  • is it possible to add fheroes2 as a package for the package manager in MorphOS?

I would recommend to expand the first message in this pull request to include a comprehensive description as well as all steps mentioned by me as tasks, so it would be easier to address them.

I will review this pull request in a while as well. As of now I am marking it as "Draft".

Copy link
Owner

@ihhub ihhub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @BeWorld2018 , I also put several comment here. Please take a look once you have time.

src/Makefile Outdated
@@ -104,7 +107,12 @@ CPPFLAGS := $(CPPFLAGS) $(CPPFLAGS_FH2)
ifdef FHEROES2_WITH_SYSTEM_SMACKER
LIBS := $(LIBS) -lsmacker
endif

ifeq ($(PLATFORM),morphos)
LIBS := $(LIBS) -lz_shared $(LDLIBS)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please explain why we need to use a shared variant of lz? Can we avoid it? Could you please point to a place where this is the only option available for this platform?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lz_shared use specific shared z library into us SDK. so specific to MorphOS.

@@ -0,0 +1,43 @@
###########################################################################
# fheroes2: https://github.com/ihhub/fheroes2 #
# Copyright (C) 2022 - 2024 #
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include only 2024 year.

# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
###########################################################################

AR = ppc-morphos-gcc-ar-11
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a default gcc version for MorphOS? Can we use the default one?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it's a last GCC available. but you right we can use ppc-morphos-gcc-ar (default)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the default one. We want to avoid forcing people to install any other packages just to compile the engine.

LDFLAGS := -L/gg/usr/local/lib $(LDFLAGS)
# Common flags (for both C and C++ compilers) for fheroes2 only
CCFLAGS_FH2 := -DTARGET_MORPHOS
# -DNDEBUG
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this line as it is not in use anywhere. We have a specific flag for this matter.

LIBS := $(LIBS) -latomic

ifdef FHEROES2_WITH_IMAGE
LIBS := $(LIBS) -ljpeg -lwebp
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't shell command exist for Makefile on MorphOS? Why we do need to include JPEG and WEBJ libraries here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worse, i dont build with this flags... FHEROES2_WITH_IMAGE:-) so i dont test this part... need to do.

src/engine/audio.cpp Outdated Show resolved Hide resolved
@@ -105,6 +116,10 @@

#include "math_base.h"

#ifdef __MORPHOS__
#undef tell
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it done? o_O

@ihhub ihhub marked this pull request as draft November 24, 2024 09:31
@oleg-derevenetz
Copy link
Collaborator

@ihhub the issue mostly is that fheroes2 expects the target platform to be more or less POSIX-compatible, especially in terms of filesystem structure and file names, and this platform is not POSIX-compatible (at least if it has the same filesystem structure principles as the original Amiga has at the time).

@BeWorld2018
Copy link
Author

Hi all,

@BeWorld2018 first of all, thanks for your contribution efforts. Personally, I think that the proposed platform is quite exotic and have significant differences from POSIX in terms of filesystem structure, for instance. I'm not sure if it's worth adding support for such exotic platforms to the main codebase, because there will be issues with supporting this code - MorphOS is a proprietary platform for specific hardware, and I suspect that there are very few people who will be able to, say, test new code or changes in the existing code. The matter is complicated by the fact that, as far as I can see, the proposed changes are not "universal" changes, they are rather "ad hoc" changes.

Alternatively, if MorphOS has its own package manager, I would suggest the author to make and maintain a package (or a separate port) that will contain the necessary patches without integrating them into main codebase.

@ihhub what do you think?

Hi, you certaintly right, MorphOS is little platform :-) and exotic
I can continue to port with my exotic code :-) on my git. no problem for me.

@oleg-derevenetz
Copy link
Collaborator

oleg-derevenetz commented Nov 24, 2024

Hi @BeWorld2018 let's try to implement some improvements step-by-step. I just made a few changes to this PR to implement some "generalization" of the filesystem interaction logic to support non-quite-POSIX-compliant filesystems (which exactly correspond to the changes from #9296). Could you please pull out these changes of mine in your PR and check if everything is working on your device (loading the original game resources, music playback, saving, loading and removing savefiles, map editor, and so on)?

@BeWorld2018
Copy link
Author

BeWorld2018 commented Nov 25, 2024

Hi @BeWorld2018 let's try to implement some improvements step-by-step. I just made a few changes to this PR to implement some "generalization" of the filesystem interaction logic to support non-quite-POSIX-compliant filesystems (which exactly correspond to the changes from #9296). Could you please pull out these changes of mine in your PR and check if everything is working on your device (loading the original game resources, music playback, saving, loading and removing savefiles, map editor, and so on)?

Yeah it's just perfect, just need to exclude MorphOS form GetCaseInsensitibePath, all datas are find with your changes.

Load/Save game = ok
Music = midi ok, ogg ok
Editor : Load/save = ok

@oleg-derevenetz
Copy link
Collaborator

oleg-derevenetz commented Nov 25, 2024

Hi @BeWorld2018

Yeah it's just perfect, just need to exclude MorphOS form GetCaseInsensitibePath, all datas are find with your changes.

OK, that's good, thank you. The next release will be any day now, after it comes out, we can merge #9296 and #9297 into the master branch to minimize the set of changes specific to MorphOS. After that I'll rebase this PR on top of the master branch, the changeset in this PR of yours will be reduced, and we'll think about what else we can do.

@BeWorld2018
Copy link
Author

Nice, thanks you !

@oleg-derevenetz
Copy link
Collaborator

oleg-derevenetz commented Nov 30, 2024

OK, the file system is more or less sorted out.

Now the question about fullscreen mode - what exactly is the problem with SDL_WINDOW_FULLSCREEN_DESKTOP? Yes, it does not cause video mode switching directly on the graphics card, and instead creates a full-screen borderless window with scaling, but that's exactly what it's supposed to do. This doesn't cause issues with multiple monitors and doesn't cause a mess with other windows or desktop icons due to changing the "real" video mode on the graphics card. What exactly is the problem? Does it somehow not look good on the screen? Does this cause any specific problems when playing? More detailed explanations (perhaps with screenshots) are welcome :)

@BeWorld2018
Copy link
Author

OK, the file system is more or less sorted out.

Now the question about fullscreen mode - what exactly is the problem with SDL_WINDOW_FULLSCREEN_DESKTOP? Yes, it does not cause video mode switching directly on the graphics card, and instead creates a full-screen borderless window with scaling, but that's exactly what it's supposed to do. This doesn't cause issues with multiple monitors and doesn't cause a mess with other windows or desktop icons due to changing the "real" video mode on the graphics card. What exactly is the problem? Does it somehow not look good on the screen? Does this cause any specific problems when playing? More detailed explanations (perhaps with screenshots) are welcome :)

No problem here....
On MorphOS this flags SDL_WINDOW_FULLSCREEN_DESKTOP = false fullscreen mean Window take desktop size with borderless (and if you desktop size is 1920x1080... can be slow.. because MorphOS run on G4 / G5 PowerPC... so very old hardware)
and SDL_WINDOW_FULLSCREEN = create new screen with specific size.

@oleg-derevenetz
Copy link
Collaborator

On MorphOS this flags SDL_WINDOW_FULLSCREEN_DESKTOP = false fullscreen mean Window take desktop size with borderless (and if you desktop size is 1920x1080... can be slow.. because MorphOS run on G4 / G5 PowerPC... so very old hardware)
and SDL_WINDOW_FULLSCREEN = create new screen with specific size.

So the real issue here is that SDL_WINDOW_FULLSCREEN_DESKTOP is slow on high display resolutions? Is this slowdown really being observed?

@ihhub
Copy link
Owner

ihhub commented Dec 6, 2024

No problem here.... On MorphOS this flags SDL_WINDOW_FULLSCREEN_DESKTOP = false fullscreen mean Window take desktop size with borderless (and if you desktop size is 1920x1080... can be slow.. because MorphOS run on G4 / G5 PowerPC... so very old hardware) and SDL_WINDOW_FULLSCREEN = create new screen with specific size.

The engine has FPS counter for this matter. Please enable it and see how it affects. Also, do it only on release build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants