Skip to content

Commit 6d116fd

Browse files
committed
Build option to disable 64 Disk Drive support
1 parent b4566a6 commit 6d116fd

File tree

15 files changed

+167
-19
lines changed

15 files changed

+167
-19
lines changed

README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Type 'make' by itself to view all available build options:
6363
NO_ASM=1 == build without assembly (no dynamic recompiler or MMX/SSE code)
6464
USE_GLES=1 == build against GLESv2 instead of OpenGL
6565
VC=1 == build against Broadcom Videocore GLESv2
66+
NO_64DD=1 == build without 64 Disk Drive support
6667
NEON=1 == (ARM only) build for hard floating point environments
6768
VFP_HARD=1 == (ARM only) full hardware floating point ABI
6869
SHAREDIR=path == extra path to search for shared data files

projects/unix/Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,6 @@ SOURCE = \
504504
$(SRCDIR)/device/controllers/paks/mempak.c \
505505
$(SRCDIR)/device/controllers/paks/rumblepak.c \
506506
$(SRCDIR)/device/controllers/paks/transferpak.c \
507-
$(SRCDIR)/device/dd/dd_controller.c \
508507
$(SRCDIR)/device/device.c \
509508
$(SRCDIR)/device/gb/gb_cart.c \
510509
$(SRCDIR)/device/gb/mbc3_rtc.c \
@@ -548,6 +547,14 @@ SOURCE = \
548547
$(SRCDIR)/plugin/dummy_rsp.c \
549548
$(MINIZIP_SOURCE)
550549

550+
# Include 64 Disk Drive support
551+
NO_64DD ?= 0
552+
ifeq ($(NO_64DD), 0)
553+
SOURCE += $(SRCDIR)/device/dd/dd_controller.c
554+
else
555+
CFLAGS += -DNO64DD
556+
endif
557+
551558
# MD5 lib
552559
SOURCE += \
553560
$(SUBDIR)/md5/md5.c

src/api/m64p_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ typedef struct {
190190
*/
191191
char* (*get_gb_cart_ram)(void* cb_data, int controller_num);
192192

193+
#if !defined(NO64DD) /* build option to disable 64 Disk Drive support */
193194
/* Allow the frontend to specify the DD IPL ROM file to load
194195
* cb_data: points to frontend-defined callback data.
195196
* Returns a NULL-terminated string owned by the core specifying the DD IPL ROM filename to load
@@ -203,6 +204,7 @@ typedef struct {
203204
* Empty or NULL string results in no DD disk being loaded (eg. empty disk drive).
204205
*/
205206
char* (*get_dd_disk)(void* cb_data);
207+
#endif /* build option to disable 64 Disk Drive support */
206208
} m64p_media_loader;
207209

208210
/* ----------------------------------------- */

src/backends/file_storage.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
#include "api/callbacks.h"
2727
#include "api/m64p_types.h"
2828
#include "backends/api/storage_backend.h"
29+
#if !defined(NO64DD) /* build option to disable 64 Disk Drive support */
2930
#include "device/dd/dd_controller.h"
31+
#endif /* build option to disable 64 Disk Drive support */
3032
#include "main/util.h"
3133

3234
int open_file_storage(struct file_storage* fstorage, size_t size, const char* filename)
@@ -103,6 +105,7 @@ static void file_storage_parent_save(void* storage)
103105
file_storage_save(fstorage);
104106
}
105107

108+
#if !defined(NO64DD) /* build option to disable 64 Disk Drive support */
106109
static void file_storage_dd_sdk_dump_save(void* storage)
107110
{
108111
static uint8_t sdk_buffer[SDK_FORMAT_DUMP_SIZE];
@@ -131,7 +134,7 @@ static void file_storage_dd_sdk_dump_save(void* storage)
131134

132135
free(filename);
133136
}
134-
137+
#endif /* build option to disable 64 Disk Drive support */
135138

136139

137140
const struct storage_backend_interface g_ifile_storage =
@@ -156,9 +159,11 @@ const struct storage_backend_interface g_isubfile_storage =
156159
file_storage_parent_save
157160
};
158161

162+
#if !defined(NO64DD) /* build option to disable 64 Disk Drive support */
159163
const struct storage_backend_interface g_ifile_storage_dd_sdk_dump =
160164
{
161165
file_storage_data,
162166
file_storage_size,
163167
file_storage_dd_sdk_dump_save
164168
};
169+
#endif /* build option to disable 64 Disk Drive support */

src/backends/file_storage.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ void close_file_storage(struct file_storage* storage);
4040
extern const struct storage_backend_interface g_ifile_storage;
4141
extern const struct storage_backend_interface g_ifile_storage_ro;
4242
extern const struct storage_backend_interface g_isubfile_storage;
43+
#if !defined(NO64DD) /* build option to disable 64 Disk Drive support */
4344
extern const struct storage_backend_interface g_ifile_storage_dd_sdk_dump;
45+
#endif /* build option to disable 64 Disk Drive support */
4446

4547
#endif

src/device/device.c

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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
4965
static 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

249302
void run_device(struct device* dev)

src/device/device.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
#include "controllers/paks/mempak.h"
3232
#include "controllers/paks/rumblepak.h"
3333
#include "controllers/paks/transferpak.h"
34+
#if !defined(NO64DD) /* build option to disable 64 Disk Drive support */
3435
#include "dd/dd_controller.h"
36+
#endif /* build option to disable 64 Disk Drive support */
3537
#include "gb/gb_cart.h"
3638
#include "memory/memory.h"
3739
#include "pif/pif.h"
@@ -70,10 +72,12 @@ enum { GAME_CONTROLLERS_COUNT = 4 };
7072
#define MM_SI_REGS UINT32_C(0x04800000)
7173

7274
#define MM_DOM2_ADDR1 UINT32_C(0x05000000)
75+
#if !defined(NO64DD) /* build option to disable 64 Disk Drive support */
7376
#define MM_DD_C2S_BUFFER UINT32_C(0x05000000)
7477
#define MM_DD_DS_BUFFER UINT32_C(0x05000400)
7578
#define MM_DD_REGS UINT32_C(0x05000500)
7679
#define MM_DD_MS_RAM UINT32_C(0x05000580)
80+
#endif /* build option to disable 64 Disk Drive support */
7781
#define MM_DD_ROM UINT32_C(0x06000000)
7882

7983
#define MM_DOM2_ADDR2 UINT32_C(0x08000000)
@@ -107,8 +111,9 @@ struct device
107111
struct gb_cart gb_carts[GAME_CONTROLLERS_COUNT];
108112

109113
struct cart cart;
110-
114+
#if !defined(NO64DD) /* build option to disable 64 Disk Drive support */
111115
struct dd_controller dd;
116+
#endif /* build option to disable 64 Disk Drive support */
112117
};
113118

114119
/* Setup device "static" properties. */
@@ -138,11 +143,15 @@ void init_device(struct device* dev,
138143
void* eeprom_storage, const struct storage_backend_interface* ieeprom_storage,
139144
uint32_t flashram_type,
140145
void* flashram_storage, const struct storage_backend_interface* iflashram_storage,
146+
#if defined(NO64DD) /* build option to disable 64 Disk Drive support */
147+
void* sram_storage, const struct storage_backend_interface* isram_storage);
148+
#else
141149
void* sram_storage, const struct storage_backend_interface* isram_storage,
142150
/* dd */
143151
void* dd_rtc_clock, const struct clock_backend_interface* dd_rtc_iclock,
144152
size_t dd_rom_size,
145153
void* dd_disk, const struct storage_backend_interface* dd_idisk);
154+
#endif /* build option to disable 64 Disk Drive support */
146155

147156
/* Setup device such that it's state is
148157
* what it should be after power on.

src/device/pif/cic.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@ void init_cic_using_ipl3(struct cic* cic, const void* ipl3)
4545
{ "X103", CIC_X103, 0x78 },
4646
{ "X105", CIC_X105, 0x91 },
4747
{ "X106", CIC_X106, 0x85 },
48+
#if defined(NO64DD) /* build option to disable 64 Disk Drive support */
49+
{ "5167", CIC_5167, 0xdd }
50+
#else
4851
{ "5167", CIC_5167, 0xdd },
4952
{ "8303", CIC_8303, 0xdd }
53+
#endif /* build option to disable 64 Disk Drive support */
5054
};
5155

5256
for (i = 0; i < 0xfc0/4; i++)
@@ -65,7 +69,9 @@ void init_cic_using_ipl3(struct cic* cic, const void* ipl3)
6569
case UINT64_C(0x000000D6D5BE5580): i = 5; break; /* CIC_X106 */
6670
case UINT64_C(0x000001053BC19870): i = 6; break; /* CIC 5167 */
6771
case UINT64_C(0x000000A5F80BF620): i = 0; break; /* CIC 5101 */
72+
#if !defined(NO64DD) /* build option to disable 64 Disk Drive support */
6873
case UINT64_C(0x000000D2E53EF008): i = 7; break; /* CIC 8303 */
74+
#endif /* build option to disable 64 Disk Drive support */
6975
}
7076

7177
memcpy(cic, &cics[i], sizeof(*cic));

src/device/pif/cic.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@ enum cic_version
3030
CIC_X105,
3131
CIC_X106,
3232
CIC_5101,
33+
#if defined(NO64DD) /* build option to disable 64 Disk Drive support */
34+
CIC_5167
35+
#else
3336
CIC_5167,
3437
CIC_8303
38+
#endif /* build option to disable 64 Disk Drive support */
3539
};
3640

3741
struct cic

src/device/pif/pif.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ void reset_pif(struct pif* pif, unsigned int reset_type)
146146
size_t i;
147147

148148
/* HACK: for allowing pifbootrom execution */
149+
#if defined(NO64DD) /* build option to disable 64 Disk Drive support */
150+
unsigned int rom_type = 0;
151+
#else
149152
unsigned int rom_type = (pif->cic.version == CIC_8303) ? 1 : 0;
153+
#endif /* build option to disable 64 Disk Drive support */
150154
unsigned int s7 = 0;
151155

152156
/* 0:ColdReset, 1:NMI */

0 commit comments

Comments
 (0)