Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
195 user(s) are online (179 user(s) are browsing Forums)

Members: 0
Guests: 195

more...

Support us!

Headlines

 
  Register To Post  

Compiling OS4 sources to target OS3
Just popping in
Just popping in


See User information
Hi
Is it possible to write OS4 programs who do not rely on specifcs features and build a 68k exécutable for AOS3?
So later I could target OS4 without modifying the code. (Not interested in ifdef stuff)

Thanks
Kamelito

Go to top
Re: Compiling OS4 sources to target OS3
Amigans Defender
Amigans Defender


See User information
Quote:

Kamelito wrote:
Hi
Is it possible to write OS4 programs who do not rely on specifcs features and build a 68k exécutable for AOS3?


Yes.

Quote:
So later I could target OS4 without modifying the code. (Not interested in ifdef stuff)


That could be a problem.

You'll need to define __USE_INLINE__ when you build for OS4.

You will also need to add code to GetInterface and DropInterface if you open any libraries (#ifdef __amigaos4__). You might be able to avoid that by using -lauto though.

Go to top
Re: Compiling OS4 sources to target OS3
Home away from home
Home away from home


See User information
There is few differences.

1. You don't need to open libraries on AmigaOS4.
2. If you OpenLibraries manually you need to also obtain a interface (main)
3. Close Libraries also need a close interface.

So this part of code might look a bit different.

4. Some OS3.x functions are obsoleted, mostly functions related to filesystem like opening files, and listing files and folders.

If you use -D__USE_INLINE__ on the compile line AmigaOS4 compiles AmigaOS3 pretty easy, if you don't you need to write IEXEC -> infront of all exec library functions and IDOS -> infront of all dos functions etc.

5. Some timer stuff has changed names.

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: Compiling OS4 sources to target OS3
Home away from home
Home away from home


See User information
@Kamelito
That is fairly easy to achieve using the PortablE language, since it already hides OS4's different library conventions. So as long as you avoid using OS4-specific stuff, you can simply recompile for OS3/AROS/MOS in most cases.

And for stuff which *is* OS4 specific, but which has equivalents on OS3/AROS/MOS (e.g. Picasso96 vs CyberGfx), I've written (but not documented!) quite a few simple abstractions (wrapper modules) to hide those differences. Those modules typically have names like 'CSH/pAmigaXXX' where XXX is the relevant Amiga library (although in the case of P96/CGX I use "RTG" instead).


Edited by ChrisH on 2013/7/9 20:07:29
Author of the PortablE programming language.
Go to top
Re: Compiling OS4 sources to target OS3
Just popping in
Just popping in


See User information
Actually I was thinking about C but PortablE is an interesting option. I miss an OS X port though :)
Kamelito

Go to top
Re: Compiling OS4 sources to target OS3
Not too shy to talk
Not too shy to talk


See User information
Just add this at the beginning
#ifdef __amigaos4__
#define OS4
#else
#define OS3
#endif

#ifdef OS4
#define __USE_INLINE__
#define __USE_BASETYPE__
#define __USE_OLD_TIMEVAL__
#pragma pack(2)
#endif


and open the .library this way


/*==================================================================================*/
BOOL OpenAmigaLibraries()
{
/* Initialize the needed libraries */
#define LIBOPEN(libbase,name,version) libbase =(void*)OpenLibrary(#name,(ULONG)version); if(libbase==NULL) return(FALSE);
#define LIBOPEN4(interface,libbase) interface=(void*)GetInterface((struct Library *)libbase, "main", 1, NULL); if(interface==NULL) return(FALSE);



LIBOPEN(DOSBase,dos.library,36)
LIBOPEN(GfxBase,graphics.library,0)
LIBOPEN(IntuitionBase,intuition.library,0)
LIBOPEN(CyberGfxBase,cybergraphics.library,0)

if (OpenDevice(TIMERNAME, UNIT_MICROHZ, (struct IORequest *)&tr, 0L) != 0)
return(FALSE);
TimerBase = (struct Device *) tr.tr_node.io_Device;

#ifdef OS4
LIBOPEN4(IExec,SysBase)

LIBOPEN(NewlibBase,newlib.library, 52)
LIBOPEN4(INewlib,NewlibBase)

LIBOPEN4(IDOS,DOSBase)
LIBOPEN4(IGraphics,GfxBase)
LIBOPEN4(IIntuition,IntuitionBase)
LIBOPEN4(ICyberGfx,CyberGfxBase)

LIBOPEN4(ITimer,TimerBase);
#endif

return(TRUE);
}
/*======================================================================================*/
void CloseAmigaLibraries()
{
#define LIBCLOSE(libbase) if(libbase !=NULL) { CloseLibrary((struct Library *)libbase ); libbase=NULL; }
#define LIBCLOSE4(interface) if(interface!=NULL) { DropInterface((struct Interface*)interface ); interface=NULL; }


#ifdef OS4
LIBCLOSE4(INewlib)
LIBCLOSE(NewlibBase)

LIBCLOSE4(IDOS)
LIBCLOSE4(IGraphics)
LIBCLOSE4(IIntuition)
LIBCLOSE4(ICyberGfx)

LIBCLOSE4(ITimer)
#endif

LIBCLOSE(DOSBase)
LIBCLOSE(GfxBase)
LIBCLOSE(IntuitionBase)
LIBCLOSE(CyberGfxBase)

CloseDevice((struct IORequest *)&tr);
}
/*==================================================================================*/

Go to top
Re: Compiling OS4 sources to target OS3
Just popping in
Just popping in


See User information
Thanks but when you access libraries you'll still need all those interfaces naming right?
Kamelito

Go to top
Re: Compiling OS4 sources to target OS3
Not too shy to talk
Not too shy to talk


See User information
>you'll still need all those interfaces naming
No No you write the same code you did on OS3

It is the us __USE_INLINE__ that do the magic
It works this way in include/inline4/xxx.h:
#define OpenWindow(newWindow) IIntuition->OpenWindow((newWindow))

So you only need to write the os3 way:

OpenWindow(mynewwin);

Simple

Alain

PS: also remenber to declare the interface at the beginning of your code:

/*==================================================================*/
#ifdef OS4
struct Library* NewlibBase =NULL;
struct Interface* INewlib =NULL;

struct ExecIFace* IExec =NULL;
struct DOSIFace* IDOS =NULL;
struct GraphicsIFace* IGraphics =NULL;
struct IntuitionIFace* IIntuition =NULL;
struct CyberGfxIFace* ICyberGfx =NULL;

struct TimerIFace* ITimer =NULL;
#endif


Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project