1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "common/scummsys.h"
24 
25 #if defined(__amigaos4__)
26 
27 #include "backends/fs/amigaos4/amigaos4-fs.h"
28 #include "backends/platform/sdl/amigaos/amigaos.h"
29 #include "backends/plugins/sdl/sdl-provider.h"
30 #include "base/main.h"
31 
main(int argc,char * argv[])32 int main(int argc, char *argv[]) {
33 
34 	// The following will gather the application name and add the install path
35 	// to a variable in AmigaOS4's ENV(ARC) system. It will be placed in AppPaths
36 	// so that ScummVM can become AmiUpdate aware
37 	const char *const appname = "ResidualVM";
38 
39 	BPTR lock;
40 	APTR oldwin;
41 
42 	// Obtain a lock to the home directory
43 	if ((lock = IDOS->GetProgramDir())) {
44 		TEXT progpath[2048];
45 		TEXT apppath[1024] = "AppPaths";
46 
47 		if (IDOS->DevNameFromLock(lock,
48 			progpath,
49 			sizeof(progpath),
50 			DN_FULLPATH)) {
51 
52 			// Stop any "Insert volume..." type requesters
53 			oldwin = IDOS->SetProcWindow((APTR)-1);
54 
55 			// Finally, set the variable to the path the executable was run from
56 			IDOS->AddPart( apppath, appname, 1024);
57 			IDOS->SetVar( apppath, progpath, -1, GVF_GLOBAL_ONLY|GVF_SAVE_VAR );
58 
59 			// Turn system requesters back on
60 			IDOS->SetProcWindow( oldwin );
61 		}
62 	}
63 
64 	// Set up a stack cookie to avoid crashes from a stack set too low
65 	static const char *stack_cookie __attribute__((used)) = "$STACK: 600000";
66 
67 	// Create our OSystem instance
68 	g_system = new OSystem_AmigaOS();
69 	assert(g_system);
70 
71 	// Pre initialize the backend
72 	((OSystem_AmigaOS *)g_system)->init();
73 
74 #ifdef DYNAMIC_MODULES
75 	PluginManager::instance().addPluginProvider(new SDLPluginProvider());
76 #endif
77 
78 	// Invoke the actual ScummVM main entry point
79 	int res = scummvm_main(argc, argv);
80 
81 	// Free OSystem
82 	delete (OSystem_AmigaOS *)g_system;
83 
84 	return res;
85 }
86 
87 #endif
88