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/amigaos/amigaos-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 	// Update support (AmiUpdate):
35 	// This will save ScummVM's system application name and add it's binary
36 	// path to a variable in the platforms native ENV(ARC) system.
37 	const char *const appname = "ScummVM";
38 
39 	BPTR lock;
40 	APTR reqwin;
41 
42 	// Obtain a lock to it's home directory.
43 	if ((lock = IDOS->GetProgramDir())) {
44 		TEXT progpath[2048];
45 		TEXT apppath[1024] = "AppPaths";
46 
47 		if (IDOS->DevNameFromLock(lock,	progpath, sizeof(progpath),	DN_FULLPATH)) {
48 			// Stop any "Please insert volume ..." type system requester.
49 			reqwin = IDOS->SetProcWindow((APTR)-1);
50 
51 			// Set the AppPaths variable to the path the binary was run from.
52 			IDOS->AddPart(apppath, appname, 1024);
53 			IDOS->SetVar(apppath, progpath, -1, GVF_GLOBAL_ONLY|GVF_SAVE_VAR);
54 
55 			// Turn system requester back on.
56 			IDOS->SetProcWindow(reqwin);
57 		}
58 	}
59 
60 	// Set a stack cookie to avoid crashes from a too low stack.
61 	static const char *stack_cookie __attribute__((used)) = "$STACK: 2048000";
62 
63 	// Create our OSystem instance.
64 	g_system = new OSystem_AmigaOS();
65 	assert(g_system);
66 
67 	// Pre-initialize the backend.
68 	g_system->init();
69 
70 #ifdef DYNAMIC_MODULES
71 	PluginManager::instance().addPluginProvider(new SDLPluginProvider());
72 #endif
73 
74 	// Invoke the actual ScummVM main entry point.
75 	int res = scummvm_main(argc, argv);
76 
77 	// Free OSystem.
78 	g_system->destroy();
79 
80 	return res;
81 }
82 
83 #endif
84