Search
lxdream.org :: lxdream/src/main.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/main.c
changeset 105:1faa0745f200
prev94:8d80d9c7cc7d
next106:9048bac046c3
author nkeynes
date Tue Mar 14 11:44:29 2006 +0000 (15 years ago)
permissions -rw-r--r--
last change Add elf loader suppt
view annotate diff log raw
     1 /**
     2  * $Id: main.c,v 1.14 2006-03-14 11:44:29 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"
    33 #define S3M_PLAYER "s3mplay.bin"
    35 char *option_list = "a:s:A:V:phb";
    36 struct option longopts[1] = { { NULL, 0, 0, 0 } };
    37 char *aica_program = NULL;
    38 char *s3m_file = NULL;
    39 gboolean start_immediately = FALSE;
    40 gboolean headless = FALSE;
    41 gboolean without_bios = FALSE;
    43 int main (int argc, char *argv[])
    44 {
    45     int opt;
    46 #ifdef ENABLE_NLS
    47     bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
    48     textdomain (PACKAGE);
    49 #endif
    51     while( (opt = getopt_long( argc, argv, option_list, longopts, NULL )) != -1 ) {
    52 	switch( opt ) {
    53 	case 'a': /* AICA only mode - argument is an AICA program */
    54 	    aica_program = optarg;
    55 	    break;
    56 	case 's': /* AICA-only w/ S3M player */
    57 	    aica_program = S3M_PLAYER;
    58 	    s3m_file = optarg;
    59 	    break;
    60 	case 'A': /* Audio driver */
    61 	    break;
    62 	case 'V': /* Video driver */
    63 	    break;
    64 	case 'p': /* Start immediately */
    65 	    start_immediately = TRUE;
    66     	    break;
    67     	case 'b': /* No BIOS */
    68     	    without_bios = TRUE;
    69     	    break;
    70         case 'h': /* Headless */
    71             headless = TRUE;
    72             break;
    73 	}
    74     }
    76     if( aica_program == NULL ) {
    77 	if( !headless ) {
    78 	    gnome_init ("dreamon", VERSION, argc, argv);
    79 	    dreamcast_init();
    80 	    dreamcast_register_module( &gtk_gui_module );
    81 	} else {
    82 	    dreamcast_init();
    83 	}
    85     } else {
    86 	dreamcast_configure_aica_only();
    87 	mem_load_block( aica_program, 0x00800000, 2048*1024 );
    88 	if( s3m_file != NULL ) {
    89 	    mem_load_block( s3m_file, 0x00810000, 2048*1024 - 0x10000 );
    90 	}
    91 	if( !headless ) {
    92 	    gnome_init ("dreamon", VERSION, argc, argv);
    93 	    dreamcast_register_module( &gtk_gui_module );
    94 	    set_disassembly_cpu( main_debug, "ARM7" );
    95 	}
    96     }
    98     if( without_bios ) {
    99     	bios_install();
   100 	dcload_install();
   101     }
   102     INFO( "DreamOn! ready..." );
   103     if( optind < argc ) {
   104 	file_load_magic( argv[optind] );
   105     }
   107     if( start_immediately )
   108 	dreamcast_run();
   109     if( !headless ) {
   110         gtk_main ();
   111     }
   112     return 0;
   113 }
.