Search
lxdream.org :: lxdream/src/dreamcast.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/dreamcast.c
changeset 16:f383e7640da4
prev15:5194dd0fdb60
next17:944f75eea496
author nkeynes
date Tue Dec 13 12:17:26 2005 +0000 (15 years ago)
permissions -rw-r--r--
last change Cleanup init config => dreamcast_config
file annotate diff log raw
1.1 --- a/src/dreamcast.c Mon Dec 12 13:11:11 2005 +0000
1.2 +++ b/src/dreamcast.c Tue Dec 13 12:17:26 2005 +0000
1.3 @@ -4,6 +4,7 @@
1.4 #include "asic.h"
1.5 #include "ide.h"
1.6 #include "dreamcast.h"
1.7 +#include "maple.h"
1.8 #include "modules.h"
1.9
1.10 /* Central switchboard for the system */
1.11 @@ -11,35 +12,56 @@
1.12 #define MAX_MODULES 32
1.13 static int num_modules = 0;
1.14 static int dreamcast_state = 0;
1.15 -dreamcast_module_t modules[];
1.16 +dreamcast_module_t modules[MAX_MODULES];
1.17
1.18 +/**
1.19 + * This function is responsible for defining how all the pieces of the
1.20 + * dreamcast actually fit together. Among other things, this lets us
1.21 + * (reasonably) easily redefine the structure for eg various versions of the
1.22 + * Naomi.
1.23 + *
1.24 + * Note currently the locations of the various MMIO pages are hard coded in
1.25 + * the MMIO definitions - they should probably be moved here.
1.26 + */
1.27 void dreamcast_configure( )
1.28 {
1.29 + /* Register the memory framework */
1.30 dreamcast_register_module( &mem_module );
1.31 +
1.32 + /* Setup standard memory map */
1.33 + mem_create_ram_region( 0x0C000000, 16 MB, MEM_REGION_MAIN );
1.34 + mem_create_ram_region( 0x00800000, 2 MB, MEM_REGION_AUDIO );
1.35 + mem_create_ram_region( 0x00703000, 8 KB, MEM_REGION_AUDIO_SCRATCH );
1.36 + mem_create_ram_region( 0x05000000, 8 MB, MEM_REGION_VIDEO );
1.37 + mem_load_rom( "dcboot.rom", 0x00000000, 0x00200000, 0x89f2b1a1 );
1.38 + mem_load_rom( "dcflash.rom",0x00200000, 0x00020000, 0x357c3568 );
1.39 +
1.40 + /* Load in the rest of the core modules */
1.41 dreamcast_register_module( &sh4_module );
1.42 dreamcast_register_module( &asic_module );
1.43 dreamcast_register_module( &pvr2_module );
1.44 dreamcast_register_module( &aica_module );
1.45 dreamcast_register_module( &maple_module );
1.46 dreamcast_register_module( &ide_module );
1.47 +
1.48 + /* Attach any default maple devices, ie a pair of controllers */
1.49 + maple_device_t controller1 = controller_new();
1.50 + maple_device_t controller2 = controller_new();
1.51 + maple_attach_device( controller1, 0, 0 );
1.52 + maple_attach_device( controller2, 1, 0 );
1.53 }
1.54
1.55 void dreamcast_register_module( dreamcast_module_t module )
1.56 {
1.57 modules[num_modules++] = module;
1.58 + if( module->init != NULL )
1.59 + module->init();
1.60 }
1.61
1.62
1.63 void dreamcast_init( void )
1.64 {
1.65 - int i;
1.66 dreamcast_configure();
1.67 - for( i=0; i<num_modules; i++ ) {
1.68 - if( modules[i]->init != NULL )
1.69 - modules[i]->init();
1.70 - }
1.71 - mem_load_rom( "dcboot.rom", 0x00000000, 0x00200000, 0x89f2b1a1 );
1.72 - mem_load_rom( "dcflash.rom",0x00200000, 0x00020000, 0x357c3568 );
1.73 }
1.74
1.75 void dreamcast_reset( void )
.