Search
lxdream.org :: lxdream/src/main.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/main.c
changeset 77:935dd09c5ace
prev68:0cf3ead96627
next87:11208d725b61
author nkeynes
date Mon Jan 16 11:18:29 2006 +0000 (15 years ago)
permissions -rw-r--r--
last change Add 's3m' mode (for testing) and also headless mode
file annotate diff log raw
nkeynes@30
     1
/**
nkeynes@77
     2
 * $Id: main.c,v 1.11 2006-01-16 11:18:29 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@27
    30
#include "dreamcast.h"
nkeynes@11
    31
nkeynes@77
    32
#define S3M_PLAYER "s3mplay.bin"
nkeynes@77
    33
nkeynes@77
    34
char *option_list = "a:s:A:V:ph";
nkeynes@68
    35
char *aica_program = NULL;
nkeynes@77
    36
char *s3m_file = NULL;
nkeynes@68
    37
gboolean start_immediately = FALSE;
nkeynes@77
    38
gboolean headless = FALSE;
nkeynes@68
    39
nkeynes@30
    40
int main (int argc, char *argv[])
nkeynes@1
    41
{
nkeynes@68
    42
    int opt;
nkeynes@1
    43
#ifdef ENABLE_NLS
nkeynes@68
    44
    bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
nkeynes@68
    45
    textdomain (PACKAGE);
nkeynes@1
    46
#endif
nkeynes@68
    47
  
nkeynes@68
    48
    while( (opt = getopt( argc, argv, option_list )) != -1 ) {
nkeynes@68
    49
	switch( opt ) {
nkeynes@68
    50
	case 'a': /* AICA only mode - argument is an AICA program */
nkeynes@68
    51
	    aica_program = optarg;
nkeynes@68
    52
	    break;
nkeynes@77
    53
	case 's': /* AICA-only w/ S3M player */
nkeynes@77
    54
	    aica_program = S3M_PLAYER;
nkeynes@77
    55
	    s3m_file = optarg;
nkeynes@77
    56
	    break;
nkeynes@68
    57
	case 'A': /* Audio driver */
nkeynes@68
    58
	    break;
nkeynes@68
    59
	case 'V': /* Video driver */
nkeynes@68
    60
	    break;
nkeynes@68
    61
	case 'p': /* Start immediately */
nkeynes@68
    62
	    start_immediately = TRUE;
nkeynes@77
    63
    	    break;
nkeynes@77
    64
        case 'h': /* Headless */
nkeynes@77
    65
            headless = TRUE;
nkeynes@77
    66
            break;
nkeynes@68
    67
	}
nkeynes@68
    68
    }
nkeynes@30
    69
nkeynes@68
    70
    if( aica_program == NULL ) {
nkeynes@68
    71
	dreamcast_init();
nkeynes@77
    72
	if( !headless ) {
nkeynes@77
    73
	    gnome_init ("dreamon", VERSION, argc, argv);
nkeynes@77
    74
	    video_open();
nkeynes@77
    75
	    dreamcast_register_module( &gtk_gui_module );
nkeynes@77
    76
	}
nkeynes@68
    77
    } else {
nkeynes@68
    78
	dreamcast_configure_aica_only();
nkeynes@68
    79
	mem_load_block( aica_program, 0x00800000, 2048*1024 );
nkeynes@77
    80
	if( s3m_file != NULL ) {
nkeynes@77
    81
	    mem_load_block( s3m_file, 0x00810000, 2048*1024 - 0x10000 );
nkeynes@77
    82
	}
nkeynes@77
    83
	if( !headless ) {
nkeynes@77
    84
	    gnome_init ("dreamon", VERSION, argc, argv);
nkeynes@77
    85
	    dreamcast_register_module( &gtk_gui_module );
nkeynes@77
    86
	    set_disassembly_cpu( main_debug, "ARM7" );
nkeynes@77
    87
	}
nkeynes@68
    88
    }
nkeynes@1
    89
nkeynes@68
    90
    INFO( "DreamOn! ready..." );
nkeynes@68
    91
    if( start_immediately )
nkeynes@68
    92
	dreamcast_run();
nkeynes@77
    93
    if( !headless ) {
nkeynes@77
    94
        gtk_main ();
nkeynes@77
    95
    }
nkeynes@68
    96
    return 0;
nkeynes@1
    97
}
nkeynes@1
    98
.