Welcome, Guest. Please login or register.

Author Topic: AmiDARK Engine Flying Feather on AROS  (Read 4604 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline AmiDARKTopic starter

Re: AmiDARK Engine Flying Feather on AROS
« Reply #14 from previous page: June 10, 2014, 10:55:04 AM »
Here are the 2 functions :

Quote
BOOL deOpenDevice_Input( void ){
  BOOL mReturn = FALSE;
  struct Message * mio_Message;
  m_inputPort = MyCreateMsgPort();
  if ( m_inputPort ){
    m_inputsigflag = 1L << m_inputPort->mp_SigBit;
    #if defined( __amigaos4__ )
      m_inputRequest = ( struct IOStdReq *  )MyCreateIORequest( m_inputPort, sizeof( struct IORequest ) );
     #elif defined( __MORPHOS__ )
      m_inputRequest = (struct IOStdReq * )CreateExtIO( m_inputPort, sizeof( struct IOStdReq ) );
     #elif defined( __AROS__ )
      m_inputRequest = ( struct IOStdReq  * )MyCreateIORequest( ( struct MstPort * )m_inputPort, (int)sizeof( struct IOStdReq ) );
      mio_Message = &m_inputRequest->io_Message;
      mio_Message->mn_Length = (ULONG)sizeof( m_inputRequest );
     #endif
    if ( m_inputRequest ){
      if ( MyOpenDevice( "input.device", 0, (struct IORequest *)m_inputRequest, 0 ) ){
        #if defined( __amigaos4__ )
          InputBase = m_inputRequest->io_Device;
          m_IInput = (struct InputIFace *)MyGetInterface( ( struct Library *)InputBase, "main", 0 );
         #endif
        mReturn = TRUE;
       }
     }
   }
  return mReturn;
 }


Quote
BOOL deOpenDevice_Timer( void ){
  BOOL mReturn = FALSE;
  timerPort = MyCreateMsgPort();
  if ( timerPort ){
    timersigflag = 1 << timerPort->mp_SigBit;
    #if defined( __amigaos4__ )
      timerRequest = ( struct TimeRequest * )MyCreateIORequest( timerPort, sizeof( struct TimeRequest ) );
     #elif defined( __MORPHOS__ )
      timerRequest = (struct timerequest *)CreateExtIO( timerPort, sizeof( struct timerequest ) );
     #elif defined( __AROS__ )
      timerRequest = CreateExtIO( timerPort, sizeof( struct timerequest ) );
     #endif

    if ( timerRequest ){
      if ( MyOpenDevice( "timer.device", UNIT_MICROHZ, (struct IORequest *)timerRequest, 0 ) ){
        #if defined( __amigaos4__ )
          TimerBase = timerRequest->Request.io_Device;
          ITimer = (struct TimerIFace *)MyGetInterface( ( struct Library *)TimerBase, "main", 1 );
         #endif
        MyGetSysTime( MyTimeVal );
        timerFirst = TRUE;
        #if defined( __amigaos4__ )
          NewTimer = ( MyTimeVal->Seconds * 1000000 ) + MyTimeVal->Microseconds;
         #else
          NewTimer = ( MyTimeVal->tv_secs * 1000000 ) + MyTimeVal->tv_micro;
         #endif
        OldTimer = NewTimer;
        DemoStartTimer = NewTimer;
        mReturn = TRUE;
       }
     }
   }
  return mReturn;
 }
 

Offline BSzili

  • Full Member
  • ***
  • Join Date: May 2012
  • Posts: 112
  • Country: 00
    • Show only replies by BSzili
    • http://bszili.morphos.me
Re: AmiDARK Engine Flying Feather on AROS
« Reply #15 on: June 10, 2014, 11:09:35 AM »
Ok, I didn't know you have had error handling somewhere else. Thanks for the code, I'll write a small test program to figure out why they wouldn't work. I see there MyCreateIORequest and CreateExtIO used interchangeably. Does MyCreateIORequest use CreateExtIO internally? I have the same question about  MyCreateMsgPort, I presume it's a wrapper around CreateMsgPort.
This is just like television, only you can see much further.
 

Offline AmiDARKTopic starter

Re: AmiDARK Engine Flying Feather on AROS
« Reply #16 on: June 10, 2014, 11:22:34 AM »
Yes, they're wrapper :

Quote
struct IORequest * MyCreateIORequest( struct MsgPort * MyIOPort, int SizeRequest ){
  struct IORequest * MyIORequest;
  #if defined( __amigaos4__ )
    MyIORequest= IExec->CreateIORequest( MyIOPort, SizeRequest );
   #else
    MyIORequest = CreateIORequest( MyIOPort, SizeRequest );
   #endif
  return MyIORequest;
 }


Quote
struct MsgPort * MyCreateMsgPort( void ){
  struct MsgPort * MyMessagePort;
  #if defined( __amigaos4__ )
    MyMessagePort = IExec->CreateMsgPort();
   #else
    MyMessagePort = CreateMsgPort();
   #endif
  return MyMessagePort;
 }
 

Offline BSzili

  • Full Member
  • ***
  • Join Date: May 2012
  • Posts: 112
  • Country: 00
    • Show only replies by BSzili
    • http://bszili.morphos.me
Re: AmiDARK Engine Flying Feather on AROS
« Reply #17 on: June 10, 2014, 12:36:56 PM »
While that's a perfectly sound way of doing it, if you want to avoid wrapper functions like that, you can define __USE_INLINE__ on AmigaOS4. That will define you a bunch of compatibility macros, so you can use CreateMsgPort instead of IExec->CreateMsgPort.
Back to the AROS. This code doesn't look right to me:
Code: [Select]
if ( MyOpenDevice( &quot;input.device&quot;, 0, (struct IORequest *)m_inputRequest, 0 ) ){
        #if defined( __amigaos4__ )
          InputBase = m_inputRequest->io_Device;
          m_IInput = (struct InputIFace *)MyGetInterface( ( struct Library *)InputBase, &quot;main&quot;, 0 );
         #endif
        mReturn = TRUE;
       }
Unless you changed that in MyOpendevice, OpenDevice returns 0 if the device was opened successfully and an != 0 error code if it failed.
The second problem is InputBase. You only set it on AmigaOS4, which means it will be uninitialized on other platforms, unless a library auto-opener does it for you. Since you are already opening input.device, InputBase should be always initialized.
The same goes for TimerBase, the initializer function most likely segfaults on the first GetSysTime call, because TimerBase is not initialized, and holds a random value.
This is just like television, only you can see much further.
 

Offline AmiDARKTopic starter

Re: AmiDARK Engine Flying Feather on AROS
« Reply #18 on: June 10, 2014, 12:43:45 PM »
Yes, I know that.
But, it exists few commands/functions in the AmigaOS4 that do not exist on other Amiga OSes and that need to be developed differently.
That's why I decided to keep this form. To be sure I never lose focus on AmigaOS4 specific commands/functions and other OSes ones ;)
 

Offline BSzili

  • Full Member
  • ***
  • Join Date: May 2012
  • Posts: 112
  • Country: 00
    • Show only replies by BSzili
    • http://bszili.morphos.me
Re: AmiDARK Engine Flying Feather on AROS
« Reply #19 on: June 10, 2014, 01:14:08 PM »
What about the second part of my post? E.g. the return value of OpenDevice, TimerBase and InputBase not being set, etc.
This is just like television, only you can see much further.
 

Offline AmiDARKTopic starter

Re: AmiDARK Engine Flying Feather on AROS
« Reply #20 on: June 10, 2014, 01:49:41 PM »
I'll check these.