@@ -46,7 +46,24 @@ static void write_open_bus(void* opaque, uint32_t address, uint32_t value, uint3
4646{
4747}
4848
49+
50+ #if defined(NO64DD ) /* build option to disable 64 Disk Drive support */
51+ static unsigned int dd_dom_dma_read (void * opaque , const uint8_t * dram , uint32_t dram_addr , uint32_t cart_addr , uint32_t length )
52+ {
53+ return /* length / 8 */ 0x1000 ;
54+ }
55+
56+
57+ static unsigned int dd_dom_dma_write (void * opaque , uint8_t * dram , uint32_t dram_addr , uint32_t cart_addr , uint32_t length )
58+ {
59+ return /* length / 8 */ 0x1000 ;
60+ }
61+
62+
63+ static void get_pi_dma_handler (struct device * dev , uint32_t address , void * * opaque , const struct pi_dma_handler * * handler )
64+ #else
4965static void get_pi_dma_handler (struct cart * cart , struct dd_controller * dd , uint32_t address , void * * opaque , const struct pi_dma_handler * * handler )
66+ #endif /* build option to disable 64 Disk Drive support */
5067{
5168#define RW (o , x ) \
5269 do { \
@@ -58,21 +75,37 @@ static void get_pi_dma_handler(struct cart* cart, struct dd_controller* dd, uint
5875 if (address >= MM_CART_ROM ) {
5976 if (address >= MM_CART_DOM3 ) {
6077 /* 0x1fd00000 - 0x7fffffff : dom3 addr2, cart rom (Paper Mario (U)) ??? */
78+ #if defined(NO64DD ) /* build option to disable 64 Disk Drive support */
79+ RW (& dev -> cart , cart_dom3 );
80+ #else
6181 RW (cart , cart_dom3 );
82+ #endif /* build option to disable 64 Disk Drive support */
6283 }
6384 else {
6485 /* 0x10000000 - 0x1fbfffff : dom1 addr2, cart rom */
86+ #if defined(NO64DD ) /* build option to disable 64 Disk Drive support */
87+ RW (& dev -> cart .cart_rom , cart_rom );
88+ #else
6589 RW (& cart -> cart_rom , cart_rom );
90+ #endif /* build option to disable 64 Disk Drive support */
6691 }
6792 }
6893 else if (address >= MM_DOM2_ADDR2 ) {
6994 /* 0x08000000 - 0x0fffffff : dom2 addr2, cart save */
95+ #if defined(NO64DD ) /* build option to disable 64 Disk Drive support */
96+ RW (& dev -> cart , cart_dom2 );
97+ #else
7098 RW (cart , cart_dom2 );
99+ #endif /* build option to disable 64 Disk Drive support */
71100 }
72101 else if (address >= MM_DOM2_ADDR1 ) {
73102 /* 0x05000000 - 0x05ffffff : dom2 addr1, dd buffers */
74103 /* 0x06000000 - 0x07ffffff : dom1 addr1, dd rom */
104+ #if defined(NO64DD ) /* build option to disable 64 Disk Drive support */
105+ RW (NULL , dd_dom );
106+ #else
75107 RW (dd , dd_dom );
108+ #endif /* build option to disable 64 Disk Drive support */
76109 }
77110#undef RW
78111}
@@ -103,11 +136,15 @@ void init_device(struct device* dev,
103136 void * eeprom_storage , const struct storage_backend_interface * ieeprom_storage ,
104137 uint32_t flashram_type ,
105138 void * flashram_storage , const struct storage_backend_interface * iflashram_storage ,
139+ #if defined(NO64DD ) /* build option to disable 64 Disk Drive support */
140+ void * sram_storage , const struct storage_backend_interface * isram_storage )
141+ #else
106142 void * sram_storage , const struct storage_backend_interface * isram_storage ,
107143 /* dd */
108144 void * dd_rtc_clock , const struct clock_backend_interface * dd_rtc_iclock ,
109145 size_t dd_rom_size ,
110146 void * dd_disk , const struct storage_backend_interface * dd_idisk )
147+ #endif /* build option to disable 64 Disk Drive support */
111148{
112149 struct interrupt_handler interrupt_handlers [] = {
113150 { & dev -> vi , vi_vertical_interrupt_event }, /* VI */
@@ -145,13 +182,16 @@ void init_device(struct device* dev,
145182 { A (MM_PI_REGS , 0xffff ), M64P_MEM_PI , { & dev -> pi , RW (pi_regs ) } },
146183 { A (MM_RI_REGS , 0xffff ), M64P_MEM_RI , { & dev -> ri , RW (ri_regs ) } },
147184 { A (MM_SI_REGS , 0xffff ), M64P_MEM_SI , { & dev -> si , RW (si_regs ) } },
185+ #if !defined (NO64DD ) /* build option to disable 64 Disk Drive support */
148186 { A (MM_DOM2_ADDR1 , 0xffffff ), M64P_MEM_NOTHING , { NULL , RW (open_bus ) } },
149187 { A (MM_DD_ROM , 0x1ffffff ), M64P_MEM_NOTHING , { NULL , RW (open_bus ) } },
188+ #endif /* build option to disable 64 Disk Drive support */
150189 { A (MM_DOM2_ADDR2 , 0x1ffff ), M64P_MEM_FLASHRAMSTAT , { & dev -> cart , RW (cart_dom2 ) } },
151190 { A (MM_CART_ROM , rom_size - 1 ), M64P_MEM_ROM , { & dev -> cart .cart_rom , RW (cart_rom ) } },
152191 { A (MM_PIF_MEM , 0xffff ), M64P_MEM_PIF , { & dev -> pif , RW (pif_ram ) } }
153192 };
154193
194+ #if !defined(NO64DD ) /* build option to disable 64 Disk Drive support */
155195 /* init and map DD if present */
156196 if (dd_rom_size > 0 ) {
157197 mappings [14 ] = (struct mem_mapping ){ A (MM_DOM2_ADDR1 , 0xffffff ), M64P_MEM_NOTHING , { & dev -> dd , RW (dd_regs ) } };
@@ -163,6 +203,7 @@ void init_device(struct device* dev,
163203 dd_disk , dd_idisk ,
164204 & dev -> r4300 );
165205 }
206+ #endif /* build option to disable 64 Disk Drive support */
166207
167208 struct mem_handler dbg_handler = { & dev -> r4300 , RW (with_bp_checks ) };
168209#undef A
@@ -181,13 +222,18 @@ void init_device(struct device* dev,
181222 init_ai (& dev -> ai , & dev -> mi , & dev -> ri , & dev -> vi , aout , iaout );
182223 init_mi (& dev -> mi , & dev -> r4300 );
183224 init_pi (& dev -> pi ,
225+ #if defined(NO64DD ) /* build option to disable 64 Disk Drive support */
226+ dev , get_pi_dma_handler ,
227+ #else
184228 get_pi_dma_handler ,
185229 & dev -> cart , & dev -> dd ,
230+ #endif /* build option to disable 64 Disk Drive support */
186231 & dev -> mi , & dev -> ri , & dev -> dp );
187232 init_ri (& dev -> ri , & dev -> rdram );
188233 init_si (& dev -> si , si_dma_duration , & dev -> mi , & dev -> pif , & dev -> ri );
189234 init_vi (& dev -> vi , vi_clock , expected_refresh_rate , & dev -> mi , & dev -> dp );
190235
236+ #if !defined(NO64DD ) /* build option to disable 64 Disk Drive support */
191237 /* FIXME: should boot on cart, unless only a disk is present, but having no cart is not yet supported by ui/core,
192238 * so use another way of selecting boot device:
193239 * use CART unless DD is plugged and the plugged CART is not a combo media (cart+disk).
@@ -196,11 +242,16 @@ void init_device(struct device* dev,
196242 uint32_t rom_base = (dd_rom_size > 0 && media != 'C' )
197243 ? MM_DD_ROM
198244 : MM_CART_ROM ;
245+ #endif /* build option to disable 64 Disk Drive support */
199246
200247 init_pif (& dev -> pif ,
201248 (uint8_t * )mem_base_u32 (base , MM_PIF_MEM ),
202249 jbds , ijbds ,
250+ #if defined(NO64DD ) /* build option to disable 64 Disk Drive support */
251+ (uint8_t * )mem_base_u32 (base , MM_CART_ROM + 0x40 ),
252+ #else
203253 (uint8_t * )mem_base_u32 (base , rom_base ) + 0x40 ,
254+ #endif /* build option to disable 64 Disk Drive support */
204255 & dev -> r4300 );
205256
206257 init_cart (& dev -> cart ,
@@ -240,10 +291,12 @@ void poweron_device(struct device* dev)
240291 channel -> ijbd -> poweron (channel -> jbd );
241292 }
242293 }
243-
294+
295+ #if !defined(NO64DD ) /* build option to disable 64 Disk Drive support */
244296 if (dev -> dd .rom != NULL ) {
245297 poweron_dd (& dev -> dd );
246298 }
299+ #endif /* build option to disable 64 Disk Drive support */
247300}
248301
249302void run_device (struct device * dev )
0 commit comments