2 * $Id: main.c,v 1.16 2006-03-16 12:41:59 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"
35 #define S3M_PLAYER "s3mplay.bin"
37 char *option_list = "a:s:A:V:phb";
38 struct option longopts[1] = { { NULL, 0, 0, 0 } };
39 char *aica_program = NULL;
40 char *s3m_file = NULL;
41 char *video_driver_name = "gtk";
42 char *audio_driver_name = "esd";
43 gboolean start_immediately = FALSE;
44 gboolean headless = FALSE;
45 gboolean without_bios = FALSE;
47 audio_driver_t audio_driver_list[] = { &audio_null_driver,
51 video_driver_t video_driver_list[] = { &video_null_driver,
55 int main (int argc, char *argv[])
59 bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
63 while( (opt = getopt_long( argc, argv, option_list, longopts, NULL )) != -1 ) {
65 case 'a': /* AICA only mode - argument is an AICA program */
66 aica_program = optarg;
68 case 's': /* AICA-only w/ S3M player */
69 aica_program = S3M_PLAYER;
72 case 'A': /* Audio driver */
73 audio_driver_name = optarg;
75 case 'V': /* Video driver */
76 video_driver_name = optarg;
78 case 'p': /* Start immediately */
79 start_immediately = TRUE;
81 case 'b': /* No BIOS */
84 case 'h': /* Headless */
90 if( aica_program == NULL ) {
92 gnome_init ("dreamon", VERSION, argc, argv);
94 dreamcast_register_module( >k_gui_module );
100 dreamcast_configure_aica_only();
101 mem_load_block( aica_program, 0x00800000, 2048*1024 );
102 if( s3m_file != NULL ) {
103 mem_load_block( s3m_file, 0x00810000, 2048*1024 - 0x10000 );
106 gnome_init ("dreamon", VERSION, argc, argv);
107 dreamcast_register_module( >k_gui_module );
108 set_disassembly_cpu( main_debug, "ARM7" );
117 for( i=0; audio_driver_list[i] != NULL; i++ ) {
118 if( strcasecmp( audio_driver_list[i]->name, audio_driver_name ) == 0 ) {
119 if( audio_set_driver( audio_driver_list[i], 44100, AUDIO_FMT_16ST ) == FALSE ) {
120 audio_set_driver( &audio_null_driver, 44100, AUDIO_FMT_16ST );
126 if( audio_driver_list[i] == NULL ) {
127 ERROR( "Audio driver '%s' not found, using null driver", audio_driver_name );
128 audio_set_driver( &audio_null_driver, 44100, AUDIO_FMT_16ST );
132 video_set_driver( &video_null_driver );
134 for( i=0; video_driver_list[i] != NULL; i++ ) {
135 if( strcasecmp( video_driver_list[i]->name, video_driver_name ) == 0 ) {
136 video_set_driver( video_driver_list[i] );
140 if( video_driver_list[i] == NULL ) {
141 ERROR( "Video driver '%s' not found, using null driver", video_driver_name );
142 video_set_driver( &video_null_driver );
146 INFO( "DreamOn! ready..." );
147 if( optind < argc ) {
148 file_load_magic( argv[optind] );
151 if( start_immediately )
.