Search
lxdream.org :: lxdream/src/main.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/main.c
changeset 87:11208d725b61
prev77:935dd09c5ace
next94:8d80d9c7cc7d
author nkeynes
date Sun Jan 22 22:40:53 2006 +0000 (15 years ago)
permissions -rw-r--r--
last change Add dummied-up BIOS syscalls
file annotate diff log raw
nkeynes@30
     1
/**
nkeynes@87
     2
 * $Id: main.c,v 1.12 2006-01-22 22:40:53 nkeynes Exp $
nkeynes@30
     3
 *
nkeynes@30
     4
 * Main program, initializes dreamcast and gui, then passes control off to
nkeynes@30
     5
 * the gtk main loop (currently). 
nkeynes@30
     6
 *
nkeynes@30
     7
 * FIXME: Remove explicit GTK/Gnome references from this file
nkeynes@30
     8
 *
nkeynes@30
     9
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@30
    10
 *
nkeynes@30
    11
 * This program is free software; you can redistribute it and/or modify
nkeynes@30
    12
 * it under the terms of the GNU General Public License as published by
nkeynes@30
    13
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@30
    14
 * (at your option) any later version.
nkeynes@30
    15
 *
nkeynes@30
    16
 * This program is distributed in the hope that it will be useful,
nkeynes@30
    17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@30
    18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@30
    19
 * GNU General Public License for more details.
nkeynes@1
    20
 */
nkeynes@1
    21
nkeynes@1
    22
#ifdef HAVE_CONFIG_H
nkeynes@1
    23
#  include <config.h>
nkeynes@1
    24
#endif
nkeynes@1
    25
nkeynes@68
    26
#include <unistd.h>
nkeynes@1
    27
#include <gnome.h>
nkeynes@25
    28
#include "gui/gui.h"
nkeynes@27
    29
#include "dream.h"
nkeynes@87
    30
#include "bios.h"
nkeynes@27
    31
#include "dreamcast.h"
nkeynes@11
    32
nkeynes@77
    33
#define S3M_PLAYER "s3mplay.bin"
nkeynes@77
    34
nkeynes@87
    35
char *option_list = "a:s:A:V:phb";
nkeynes@68
    36
char *aica_program = NULL;
nkeynes@77
    37
char *s3m_file = NULL;
nkeynes@68
    38
gboolean start_immediately = FALSE;
nkeynes@77
    39
gboolean headless = FALSE;
nkeynes@87
    40
gboolean without_bios = FALSE;
nkeynes@68
    41
nkeynes@30
    42
int main (int argc, char *argv[])
nkeynes@1
    43
{
nkeynes@68
    44
    int opt;
nkeynes@1
    45
#ifdef ENABLE_NLS
nkeynes@68
    46
    bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
nkeynes@68
    47
    textdomain (PACKAGE);
nkeynes@1
    48
#endif
nkeynes@68
    49
  
nkeynes@68
    50
    while( (opt = getopt( argc, argv, option_list )) != -1 ) {
nkeynes@68
    51
	switch( opt ) {
nkeynes@68
    52
	case 'a': /* AICA only mode - argument is an AICA program */
nkeynes@68
    53
	    aica_program = optarg;
nkeynes@68
    54
	    break;
nkeynes@77
    55
	case 's': /* AICA-only w/ S3M player */
nkeynes@77
    56
	    aica_program = S3M_PLAYER;
nkeynes@77
    57
	    s3m_file = optarg;
nkeynes@77
    58
	    break;
nkeynes@68
    59
	case 'A': /* Audio driver */
nkeynes@68
    60
	    break;
nkeynes@68
    61
	case 'V': /* Video driver */
nkeynes@68
    62
	    break;
nkeynes@68
    63
	case 'p': /* Start immediately */
nkeynes@68
    64
	    start_immediately = TRUE;
nkeynes@77
    65
    	    break;
nkeynes@87
    66
    	case 'b': /* No BIOS */
nkeynes@87
    67
    	    without_bios = TRUE;
nkeynes@87
    68
    	    break;
nkeynes@77
    69
        case 'h': /* Headless */
nkeynes@77
    70
            headless = TRUE;
nkeynes@77
    71
            break;
nkeynes@68
    72
	}
nkeynes@68
    73
    }
nkeynes@30
    74
nkeynes@68
    75
    if( aica_program == NULL ) {
nkeynes@68
    76
	dreamcast_init();
nkeynes@77
    77
	if( !headless ) {
nkeynes@77
    78
	    gnome_init ("dreamon", VERSION, argc, argv);
nkeynes@77
    79
	    video_open();
nkeynes@77
    80
	    dreamcast_register_module( &gtk_gui_module );
nkeynes@77
    81
	}
nkeynes@68
    82
    } else {
nkeynes@68
    83
	dreamcast_configure_aica_only();
nkeynes@68
    84
	mem_load_block( aica_program, 0x00800000, 2048*1024 );
nkeynes@77
    85
	if( s3m_file != NULL ) {
nkeynes@77
    86
	    mem_load_block( s3m_file, 0x00810000, 2048*1024 - 0x10000 );
nkeynes@77
    87
	}
nkeynes@77
    88
	if( !headless ) {
nkeynes@77
    89
	    gnome_init ("dreamon", VERSION, argc, argv);
nkeynes@77
    90
	    dreamcast_register_module( &gtk_gui_module );
nkeynes@77
    91
	    set_disassembly_cpu( main_debug, "ARM7" );
nkeynes@77
    92
	}
nkeynes@68
    93
    }
nkeynes@1
    94
nkeynes@87
    95
    if( without_bios ) {
nkeynes@87
    96
    	bios_install();
nkeynes@87
    97
    }
nkeynes@68
    98
    INFO( "DreamOn! ready..." );
nkeynes@68
    99
    if( start_immediately )
nkeynes@68
   100
	dreamcast_run();
nkeynes@77
   101
    if( !headless ) {
nkeynes@77
   102
        gtk_main ();
nkeynes@77
   103
    }
nkeynes@68
   104
    return 0;
nkeynes@1
   105
}
nkeynes@1
   106
.