2 * $Id: main.c,v 1.20 2006-08-07 13:18:16 nkeynes Exp $
4 * Main program, initializes dreamcast and gui, then passes control off to
5 * the gtk main loop (currently).
7 * FIXME: Remove explicit GTK/Gnome references from this file
9 * Copyright (c) 2005 Nathan Keynes.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
31 #include "dreamcast.h"
32 #include "aica/audio.h"
34 #include "maple/maple.h"
36 #define S3M_PLAYER "s3mplay.bin"
38 char *option_list = "a:s:A:V:puhbd:c:";
39 struct option longopts[1] = { { NULL, 0, 0, 0 } };
40 char *aica_program = NULL;
41 char *s3m_file = NULL;
42 char *disc_file = NULL;
43 char *display_driver_name = "gtk";
44 char *audio_driver_name = "esd";
45 char *config_file = DEFAULT_CONFIG_FILENAME;
46 gboolean start_immediately = FALSE;
47 gboolean headless = FALSE;
48 gboolean without_bios = FALSE;
50 audio_driver_t audio_driver_list[] = { &audio_null_driver,
54 display_driver_t display_driver_list[] = { &display_null_driver,
58 int main (int argc, char *argv[])
62 bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
66 while( (opt = getopt_long( argc, argv, option_list, longopts, NULL )) != -1 ) {
68 case 'a': /* AICA only mode - argument is an AICA program */
69 aica_program = optarg;
71 case 'c': /* Config file */
74 case 'd': /* Mount disc */
77 case 's': /* AICA-only w/ S3M player */
78 aica_program = S3M_PLAYER;
81 case 'A': /* Audio driver */
82 audio_driver_name = optarg;
84 case 'V': /* Video driver */
85 display_driver_name = optarg;
87 case 'p': /* Start immediately */
88 start_immediately = TRUE;
90 case 'u': /* Allow unsafe dcload syscalls */
91 dcload_set_allow_unsafe(TRUE);
93 case 'b': /* No BIOS */
96 case 'h': /* Headless */
102 dreamcast_load_config( config_file );
104 if( aica_program == NULL ) {
106 gnome_init ("lxdream", VERSION, argc, argv);
108 dreamcast_register_module( >k_gui_module );
114 dreamcast_configure_aica_only();
115 mem_load_block( aica_program, 0x00800000, 2048*1024 );
116 if( s3m_file != NULL ) {
117 mem_load_block( s3m_file, 0x00810000, 2048*1024 - 0x10000 );
120 gnome_init ("lxdream", VERSION, argc, argv);
121 dreamcast_register_module( >k_gui_module );
122 set_disassembly_cpu( main_debug, "ARM7" );
131 for( i=0; audio_driver_list[i] != NULL; i++ ) {
132 if( strcasecmp( audio_driver_list[i]->name, audio_driver_name ) == 0 ) {
133 if( audio_set_driver( audio_driver_list[i], 44100, AUDIO_FMT_16ST ) == FALSE ) {
134 audio_set_driver( &audio_null_driver, 44100, AUDIO_FMT_16ST );
140 if( audio_driver_list[i] == NULL ) {
141 ERROR( "Audio driver '%s' not found, using null driver", audio_driver_name );
142 audio_set_driver( &audio_null_driver, 44100, AUDIO_FMT_16ST );
146 display_set_driver( &display_null_driver );
148 for( i=0; display_driver_list[i] != NULL; i++ ) {
149 if( strcasecmp( display_driver_list[i]->name, display_driver_name ) == 0 ) {
150 display_set_driver( display_driver_list[i] );
154 if( display_driver_list[i] == NULL ) {
155 ERROR( "Video driver '%s' not found, using null driver", display_driver_name );
156 display_set_driver( &display_null_driver );
160 maple_reattach_all();
161 INFO( "%s! ready...", APP_NAME );
162 if( optind < argc ) {
163 file_load_magic( argv[optind] );
166 if( disc_file != NULL ) {
167 gdrom_mount_image( disc_file );
170 if( start_immediately )
.