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 Sun Feb 05 04:05:27 2006 +0000 (15 years ago)
permissions -rw-r--r--
last change Video code reshuffle to start getting real video happening.
Implement colourspace conversions
Various tweaks
file annotate diff log raw
nkeynes@30
     1
/**
nkeynes@94
     2
 * $Id: main.c,v 1.13 2006-02-05 04:05:27 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@68
    25
#include <unistd.h>
nkeynes@94
    26
#include <getopt.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@94
    36
struct option longopts[1] = { { NULL, 0, 0, 0 } };
nkeynes@68
    37
char *aica_program = NULL;
nkeynes@77
    38
char *s3m_file = NULL;
nkeynes@68
    39
gboolean start_immediately = FALSE;
nkeynes@77
    40
gboolean headless = FALSE;
nkeynes@87
    41
gboolean without_bios = FALSE;
nkeynes@68
    42
nkeynes@30
    43
int main (int argc, char *argv[])
nkeynes@1
    44
{
nkeynes@68
    45
    int opt;
nkeynes@1
    46
#ifdef ENABLE_NLS
nkeynes@68
    47
    bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
nkeynes@68
    48
    textdomain (PACKAGE);
nkeynes@1
    49
#endif
nkeynes@68
    50
  
nkeynes@94
    51
    while( (opt = getopt_long( argc, argv, option_list, longopts, NULL )) != -1 ) {
nkeynes@68
    52
	switch( opt ) {
nkeynes@68
    53
	case 'a': /* AICA only mode - argument is an AICA program */
nkeynes@68
    54
	    aica_program = optarg;
nkeynes@68
    55
	    break;
nkeynes@77
    56
	case 's': /* AICA-only w/ S3M player */
nkeynes@77
    57
	    aica_program = S3M_PLAYER;
nkeynes@77
    58
	    s3m_file = optarg;
nkeynes@77
    59
	    break;
nkeynes@68
    60
	case 'A': /* Audio driver */
nkeynes@68
    61
	    break;
nkeynes@68
    62
	case 'V': /* Video driver */
nkeynes@68
    63
	    break;
nkeynes@68
    64
	case 'p': /* Start immediately */
nkeynes@68
    65
	    start_immediately = TRUE;
nkeynes@77
    66
    	    break;
nkeynes@87
    67
    	case 'b': /* No BIOS */
nkeynes@87
    68
    	    without_bios = TRUE;
nkeynes@87
    69
    	    break;
nkeynes@77
    70
        case 'h': /* Headless */
nkeynes@77
    71
            headless = TRUE;
nkeynes@77
    72
            break;
nkeynes@68
    73
	}
nkeynes@68
    74
    }
nkeynes@30
    75
nkeynes@68
    76
    if( aica_program == NULL ) {
nkeynes@77
    77
	if( !headless ) {
nkeynes@77
    78
	    gnome_init ("dreamon", VERSION, argc, argv);
nkeynes@94
    79
	    dreamcast_init();
nkeynes@77
    80
	    dreamcast_register_module( &gtk_gui_module );
nkeynes@94
    81
	} else {
nkeynes@94
    82
	    dreamcast_init();
nkeynes@77
    83
	}
nkeynes@68
    84
    } else {
nkeynes@68
    85
	dreamcast_configure_aica_only();
nkeynes@68
    86
	mem_load_block( aica_program, 0x00800000, 2048*1024 );
nkeynes@77
    87
	if( s3m_file != NULL ) {
nkeynes@77
    88
	    mem_load_block( s3m_file, 0x00810000, 2048*1024 - 0x10000 );
nkeynes@77
    89
	}
nkeynes@77
    90
	if( !headless ) {
nkeynes@77
    91
	    gnome_init ("dreamon", VERSION, argc, argv);
nkeynes@77
    92
	    dreamcast_register_module( &gtk_gui_module );
nkeynes@77
    93
	    set_disassembly_cpu( main_debug, "ARM7" );
nkeynes@77
    94
	}
nkeynes@68
    95
    }
nkeynes@1
    96
nkeynes@87
    97
    if( without_bios ) {
nkeynes@87
    98
    	bios_install();
nkeynes@87
    99
    }
nkeynes@68
   100
    INFO( "DreamOn! ready..." );
nkeynes@94
   101
    if( optind < argc ) {
nkeynes@94
   102
	file_load_magic( argv[optind] );
nkeynes@94
   103
    }
nkeynes@94
   104
nkeynes@68
   105
    if( start_immediately )
nkeynes@68
   106
	dreamcast_run();
nkeynes@77
   107
    if( !headless ) {
nkeynes@77
   108
        gtk_main ();
nkeynes@77
   109
    }
nkeynes@68
   110
    return 0;
nkeynes@1
   111
}
nkeynes@1
   112
.