filename | src/main.c |
changeset | 111:230243c2b520 |
prev | 106:9048bac046c3 |
next | 144:7f0714e89aaa |
author | nkeynes |
date | Thu Mar 30 11:30:59 2006 +0000 (18 years ago) |
permissions | -rw-r--r-- |
last change | Unfubar the pvr event generation Move state into pvr2_state structure for ease of save/load |
view | annotate | diff | log | raw |
1 /**
2 * $Id: main.c,v 1.16 2006-03-16 12:41:59 nkeynes Exp $
3 *
4 * Main program, initializes dreamcast and gui, then passes control off to
5 * the gtk main loop (currently).
6 *
7 * FIXME: Remove explicit GTK/Gnome references from this file
8 *
9 * Copyright (c) 2005 Nathan Keynes.
10 *
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.
15 *
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.
20 */
22 #ifdef HAVE_CONFIG_H
23 # include <config.h>
24 #endif
25 #include <unistd.h>
26 #include <getopt.h>
27 #include <gnome.h>
28 #include "gui/gui.h"
29 #include "dream.h"
30 #include "syscall.h"
31 #include "dreamcast.h"
32 #include "aica/audio.h"
33 #include "video.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,
48 &audio_esd_driver,
49 NULL };
51 video_driver_t video_driver_list[] = { &video_null_driver,
52 &video_gtk_driver,
53 NULL };
55 int main (int argc, char *argv[])
56 {
57 int opt, i;
58 #ifdef ENABLE_NLS
59 bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
60 textdomain (PACKAGE);
61 #endif
63 while( (opt = getopt_long( argc, argv, option_list, longopts, NULL )) != -1 ) {
64 switch( opt ) {
65 case 'a': /* AICA only mode - argument is an AICA program */
66 aica_program = optarg;
67 break;
68 case 's': /* AICA-only w/ S3M player */
69 aica_program = S3M_PLAYER;
70 s3m_file = optarg;
71 break;
72 case 'A': /* Audio driver */
73 audio_driver_name = optarg;
74 break;
75 case 'V': /* Video driver */
76 video_driver_name = optarg;
77 break;
78 case 'p': /* Start immediately */
79 start_immediately = TRUE;
80 break;
81 case 'b': /* No BIOS */
82 without_bios = TRUE;
83 break;
84 case 'h': /* Headless */
85 headless = TRUE;
86 break;
87 }
88 }
90 if( aica_program == NULL ) {
91 if( !headless ) {
92 gnome_init ("dreamon", VERSION, argc, argv);
93 dreamcast_init();
94 dreamcast_register_module( >k_gui_module );
95 } else {
96 dreamcast_init();
97 }
99 } else {
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 );
104 }
105 if( !headless ) {
106 gnome_init ("dreamon", VERSION, argc, argv);
107 dreamcast_register_module( >k_gui_module );
108 set_disassembly_cpu( main_debug, "ARM7" );
109 }
110 }
112 if( without_bios ) {
113 bios_install();
114 dcload_install();
115 }
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 );
121 }
122 break;
123 }
125 }
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 );
129 }
131 if( headless ) {
132 video_set_driver( &video_null_driver );
133 } else {
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] );
137 break;
138 }
139 }
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 );
143 }
144 }
146 INFO( "DreamOn! ready..." );
147 if( optind < argc ) {
148 file_load_magic( argv[optind] );
149 }
151 if( start_immediately )
152 dreamcast_run();
153 if( !headless ) {
154 gtk_main ();
155 }
156 return 0;
157 }
.