Exemple #1
0
UInt32
start ()
{
  SysAppInfoType *appInfo;
  void *prevGlobals;
  void *globalsPtr;

  if (SysAppStartup (&appInfo, &prevGlobals, &globalsPtr) != 0)
    {
      SndPlaySystemSound (sndError);
      return -1;
    }
  else
    {
      Int16 mainCmd = appInfo->cmd;
      void *mainPBP = appInfo->cmdPBP;
      UInt16 mainFlags = appInfo->launchFlags;
      UInt32 result;

#ifdef __OWNGP__
      UInt32 save_a4 = reg_a4;

      if (mainFlags & sysAppLaunchFlagNewGlobals)
	asm ("move.l %%a5,%%a4; sub.l #edata,%%a4" : : : "%a4");
      else
	reg_a4 = 0;
#endif

      if (mainFlags & sysAppLaunchFlagNewGlobals)
	_GccRelocateData ();

      __do_bhook (mainCmd, mainPBP, mainFlags);

      if (mainFlags & sysAppLaunchFlagNewGlobals)
	__do_ctors ();

      result = PilotMain (mainCmd, mainPBP, mainFlags);

      if (mainFlags & sysAppLaunchFlagNewGlobals)
	__do_dtors ();

      __do_ehook (mainCmd, mainPBP, mainFlags);

#ifdef __OWNGP__
      reg_a4 = save_a4;
#endif

      SysAppExit (appInfo, prevGlobals, globalsPtr);

      return result;
    }
/*
 * This is the real entrypoint for Tapwave Native Application. It
 * depends on various CodeWarrior 9.2 compiler/linker/runtime features.
 */
static SYSTEM_CALLBACK UInt32
Startup(const void *emulStateP, void *userData68KP, Call68KFuncType *call68KFuncP)
{
    if (emulStateP) {
        twEmulState = emulStateP;
        twCall68KFunc = call68KFuncP;
        // COMMENT: normal pace native object launch
        return PilotMain(sysAppLaunchCmdNormalLaunch, userData68KP, 0);
    } else {
        // Setup TNA interface dispatch table
        twGlue = (struct TwGlue*) userData68KP;

        // OPTIONAL: relocate data segment
        relocate();

        // OPTIONAL: initialize the floating-point library
 //       _fp_init();

        return 0;
    }
}