Search
lxdream.org :: lxdream/src/main.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/main.c
changeset 94:8d80d9c7cc7d
prev87:11208d725b61
next105:1faa0745f200
author nkeynes
date Mon Mar 13 12:38:39 2006 +0000 (18 years ago)
permissions -rw-r--r--
last change Refactor bios into more generic syscall structure. Add initial hooks for
dc-load functions
view annotate diff log raw
     1 /**
     2  * $Id: main.c,v 1.13 2006-02-05 04:05:27 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 "bios.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 	}
    84     } else {
    85 	dreamcast_configure_aica_only();
    86 	mem_load_block( aica_program, 0x00800000, 2048*1024 );
    87 	if( s3m_file != NULL ) {
    88 	    mem_load_block( s3m_file, 0x00810000, 2048*1024 - 0x10000 );
    89 	}
    90 	if( !headless ) {
    91 	    gnome_init ("dreamon", VERSION, argc, argv);
    92 	    dreamcast_register_module( &gtk_gui_module );
    93 	    set_disassembly_cpu( main_debug, "ARM7" );
    94 	}
    95     }
    97     if( without_bios ) {
    98     	bios_install();
    99     }
   100     INFO( "DreamOn! ready..." );
   101     if( optind < argc ) {
   102 	file_load_magic( argv[optind] );
   103     }
   105     if( start_immediately )
   106 	dreamcast_run();
   107     if( !headless ) {
   108         gtk_main ();
   109     }
   110     return 0;
   111 }
.